@plumeria/core 0.8.14 → 0.9.2

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.
Files changed (39) hide show
  1. package/README.md +36 -26
  2. package/dist/cjs/css.js +79 -11
  3. package/dist/cjs/cx.js +1 -2
  4. package/dist/cjs/index.js +6 -3
  5. package/dist/cjs/processors/css.js +64 -0
  6. package/dist/cjs/rx.js +1 -2
  7. package/dist/esm/css.js +78 -8
  8. package/dist/esm/cx.js +2 -1
  9. package/dist/esm/index.js +3 -3
  10. package/dist/esm/processors/css.js +59 -0
  11. package/dist/esm/rx.js +2 -1
  12. package/package.json +11 -11
  13. package/types/css.d.ts +199 -40
  14. package/types/cx.d.ts +2 -1
  15. package/types/index.d.ts +4 -3
  16. package/types/processors/css.d.ts +10 -0
  17. package/types/rx.d.ts +2 -1
  18. package/dist/cjs/methods/build-helper.js +0 -7
  19. package/dist/cjs/methods/create-build-helper.js +0 -34
  20. package/dist/cjs/methods/create.js +0 -24
  21. package/dist/cjs/methods/define-theme-vars.js +0 -29
  22. package/dist/cjs/methods/global-build-helper.js +0 -34
  23. package/dist/cjs/methods/global.js +0 -16
  24. package/dist/cjs/methods/keyframes.js +0 -11
  25. package/dist/esm/methods/build-helper.js +0 -2
  26. package/dist/esm/methods/create-build-helper.js +0 -30
  27. package/dist/esm/methods/create.js +0 -21
  28. package/dist/esm/methods/define-theme-vars.js +0 -25
  29. package/dist/esm/methods/global-build-helper.js +0 -30
  30. package/dist/esm/methods/global.js +0 -13
  31. package/dist/esm/methods/keyframes.js +0 -7
  32. package/types/methods/build-helper.d.ts +0 -2
  33. package/types/methods/create-build-helper.d.ts +0 -5
  34. package/types/methods/create.d.ts +0 -2
  35. package/types/methods/define-theme-vars.d.ts +0 -2
  36. package/types/methods/global-build-helper.d.ts +0 -5
  37. package/types/methods/global.d.ts +0 -2
  38. package/types/methods/keyframes.d.ts +0 -2
  39. /package/{stylesheet/core.css → stylesheet.css} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @plumeria/core
2
2
 
3
- Plumeria is a Near zero-runtime CSS-in-JS for efficient design systems.
3
+ **Zero-runtime CSS in JS library in TypeScript.**
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,7 +25,7 @@ Import stylesheet in your application's entry point.
25
25
  Applies the static stylesheet for production environments.
26
26
 
27
27
  ```ts
28
- import '@plumeria/core/stylesheet';
28
+ import '@plumeria/core/stylesheet.css';
29
29
  ```
30
30
 
31
31
  ## API
@@ -97,21 +97,6 @@ css.global({
97
97
  });
98
98
  ```
99
99
 
100
- ### cx
101
-
102
- Merges strings such as class names and pseudo.
103
-
104
- ```tsx
105
- const styles = css.create({
106
- text: {
107
- [cx(css.pseudo.hover, css.pseudo.after)]: {
108
- color: 'yellow',
109
- opacity: 0.9,
110
- },
111
- },
112
- });
113
- ```
114
-
115
100
  ### css.keyframes()
116
101
 
117
102
  Define @keyframes and set the return value directly to animationName.
@@ -134,19 +119,33 @@ const styles = css.create({
134
119
  });
135
120
  ```
136
121
 
137
- ### css.defineThemeVars()
122
+ ### css.defineVars()
138
123
 
139
- Define data-theme and regular variables as objects.
124
+ Defines custom CSS variables (custom properties) at the `:root` level.
125
+ This API allows you to declare design tokens such as spacing, sizes, or other constants, which can be referenced throughout your styles using the tokens.sm to `var(--sm)` syntax.
126
+
127
+ ```ts
128
+ const tokens = css.defineVars({
129
+ xs: 240,
130
+ sm: 360,
131
+ md: 480,
132
+ lg: 600,
133
+ xl: 768,
134
+ });
135
+ ```
136
+
137
+ ### css.defineTheme()
138
+
139
+ Define data-theme as objects.
140
140
  A default compile to :root, and the rest as a string compile to data-theme, You can also use media and container here.
141
141
 
142
142
  ```ts
143
- const tokens = css.defineThemeVars({
144
- white: 'white',
143
+ const themes = css.defineTheme({
145
144
  text_primary: {
146
145
  default: 'rgb(60,60,60)',
147
146
  light: 'black',
148
147
  dark: 'white',
149
- [css.media.max('width: 700px')]: 'gray',
148
+ [css.media.maxWidth(700)]: 'gray',
150
149
  },
151
150
  bg_primary: {
152
151
  light: 'white',
@@ -163,6 +162,17 @@ The first argument takes the color and the second argument takes the same value
163
162
  ```ts
164
163
  color: css.color.darken('skyblue', 0.12),
165
164
  color: css.color.lighten('navy', 0.6),
165
+ color: css.color.skyblue,
166
+ color: css.color.navy,
167
+ ```
168
+
169
+ ### cx
170
+
171
+ Merges strings such as class names and pseudo.
172
+
173
+ ```tsx
174
+ cx(css.pseudo.hover, css.pseudo.after); // ":hover::after"
175
+ cx(styles.text, styles, box); // "text_hash box_hash"
166
176
  ```
167
177
 
168
178
  ## ESLint
@@ -171,10 +181,10 @@ color: css.color.lighten('navy', 0.6),
171
181
 
172
182
  ### Rules: recommended
173
183
 
174
- \- no-inner-call:(error)
175
- \- no-unused-keys:(warn)
176
- \- sort-properties:(warn)
177
- \- validate-values:(warn)
184
+ \- **no-inner-call:(error)**
185
+ \- **no-unused-keys:(warn)**
186
+ \- **sort-properties:(warn)**
187
+ \- **validate-values:(warn)**
178
188
 
179
189
  It is recommended to use it in conjunction with TypeScript completion, which is one of the big advantages of using plumeria.
180
190
 
package/dist/cjs/css.js CHANGED
@@ -1,27 +1,95 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.css = void 0;
3
+ const zss_engine_1 = require("zss-engine");
4
+ const css_js_1 = require("./processors/css.js");
4
5
  const zss_utils_1 = require("zss-utils");
5
- const create_1 = require("./methods/create");
6
- const global_1 = require("./methods/global");
7
- const keyframes_1 = require("./methods/keyframes");
8
- const define_theme_vars_1 = require("./methods/define-theme-vars");
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
+ };
9
74
  class css {
10
75
  static create(object) {
11
- return (0, create_1.create)(object);
76
+ return create(object);
12
77
  }
13
78
  static global(object) {
14
- return (0, global_1.global)(object);
79
+ return global(object);
80
+ }
81
+ static defineVars(object) {
82
+ return defineVars(object);
15
83
  }
16
- static defineThemeVars(object) {
17
- return (0, define_theme_vars_1.defineThemeVars)(object);
84
+ static defineTheme(object) {
85
+ return defineTheme(object);
18
86
  }
19
87
  static keyframes(object) {
20
- return (0, keyframes_1.keyframes)(object);
88
+ return keyframes(object);
21
89
  }
22
90
  static media = zss_utils_1.media;
23
91
  static container = zss_utils_1.container;
24
92
  static pseudo = zss_utils_1.pseudo;
25
93
  static color = zss_utils_1.color;
26
94
  }
27
- exports.css = css;
95
+ exports.default = css;
package/dist/cjs/cx.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cx = void 0;
4
3
  const cx = (...strings) => {
5
4
  let result = '';
6
5
  let isFirst = true;
@@ -20,4 +19,4 @@ const cx = (...strings) => {
20
19
  });
21
20
  return result;
22
21
  };
23
- exports.cx = cx;
22
+ exports.default = cx;
package/dist/cjs/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.rx = exports.cx = exports.css = void 0;
4
7
  var css_1 = require("./css");
5
- Object.defineProperty(exports, "css", { enumerable: true, get: function () { return css_1.css; } });
8
+ Object.defineProperty(exports, "css", { enumerable: true, get: function () { return __importDefault(css_1).default; } });
6
9
  var cx_1 = require("./cx");
7
- Object.defineProperty(exports, "cx", { enumerable: true, get: function () { return cx_1.cx; } });
10
+ Object.defineProperty(exports, "cx", { enumerable: true, get: function () { return __importDefault(cx_1).default; } });
8
11
  var rx_1 = require("./rx");
9
- Object.defineProperty(exports, "rx", { enumerable: true, get: function () { return rx_1.rx; } });
12
+ Object.defineProperty(exports, "rx", { enumerable: true, get: function () { return __importDefault(rx_1).default; } });
@@ -0,0 +1,64 @@
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 CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rx = void 0;
4
3
  const rx = (className, varSet) => ({
5
4
  className,
6
5
  style: Object.fromEntries(Object.entries(varSet).map(([key, value]) => [key, value])),
7
6
  });
8
- exports.rx = rx;
7
+ exports.default = rx;
package/dist/esm/css.js CHANGED
@@ -1,17 +1,86 @@
1
- import { media, pseudo, color, container } from 'zss-utils';
2
- import { create } from './methods/create';
3
- import { global } from './methods/global';
4
- import { keyframes } from './methods/keyframes';
5
- import { defineThemeVars } from './methods/define-theme-vars';
6
- export class css {
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 {
7
73
  static create(object) {
8
74
  return create(object);
9
75
  }
10
76
  static global(object) {
11
77
  return global(object);
12
78
  }
13
- static defineThemeVars(object) {
14
- return defineThemeVars(object);
79
+ static defineVars(object) {
80
+ return defineVars(object);
81
+ }
82
+ static defineTheme(object) {
83
+ return defineTheme(object);
15
84
  }
16
85
  static keyframes(object) {
17
86
  return keyframes(object);
@@ -21,3 +90,4 @@ export class css {
21
90
  static pseudo = pseudo;
22
91
  static color = color;
23
92
  }
93
+ export default css;
package/dist/esm/cx.js CHANGED
@@ -1,4 +1,4 @@
1
- export const cx = (...strings) => {
1
+ const cx = (...strings) => {
2
2
  let result = '';
3
3
  let isFirst = true;
4
4
  strings.filter(Boolean).forEach((str) => {
@@ -17,3 +17,4 @@ export const cx = (...strings) => {
17
17
  });
18
18
  return result;
19
19
  };
20
+ export default cx;
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { css } from './css';
2
- export { cx } from './cx';
3
- export { rx } from './rx';
1
+ export { default as css } from './css';
2
+ export { default as cx } from './cx';
3
+ export { default as rx } from './rx';
@@ -0,0 +1,59 @@
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 };
package/dist/esm/rx.js CHANGED
@@ -1,4 +1,5 @@
1
- export const rx = (className, varSet) => ({
1
+ const rx = (className, varSet) => ({
2
2
  className,
3
3
  style: Object.fromEntries(Object.entries(varSet).map(([key, value]) => [key, value])),
4
4
  });
5
+ export default rx;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "0.8.14",
4
- "description": "Near Zero-runtime CSS-in-JS for efficient design systems.",
3
+ "version": "0.9.2",
4
+ "description": "Zero-runtime CSS in JS library in TypeScript.",
5
5
  "keywords": [
6
6
  "css",
7
7
  "css-in-js",
@@ -19,16 +19,16 @@
19
19
  "sideEffects": false,
20
20
  "exports": {
21
21
  "./package.json": "./package.json",
22
- "./stylesheet": "./stylesheet/core.css",
23
- "./build-helper": {
24
- "types": "./types/methods/build-helper.d.ts",
25
- "import": "./dist/esm/methods/build-helper.js",
26
- "default": "./dist/cjs/methods/build-helper.js"
27
- },
22
+ "./stylesheet.css": "./stylesheet.css",
28
23
  ".": {
29
24
  "types": "./types/index.d.ts",
30
25
  "import": "./dist/esm/index.js",
31
26
  "default": "./dist/cjs/index.js"
27
+ },
28
+ "./processors": {
29
+ "types": "./types/processors/css.d.ts",
30
+ "import": "./dist/esm/processors/css.js",
31
+ "default": "./dist/cjs/processors/css.js"
32
32
  }
33
33
  },
34
34
  "main": "dist/cjs/index.js",
@@ -37,11 +37,11 @@
37
37
  "files": [
38
38
  "dist/",
39
39
  "types/",
40
- "stylesheet/"
40
+ "stylesheet.css"
41
41
  ],
42
42
  "dependencies": {
43
- "zss-engine": "^0.2.27",
44
- "zss-utils": "0.2.0"
43
+ "zss-engine": "0.2.32",
44
+ "zss-utils": "0.2.2"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
package/types/css.d.ts CHANGED
@@ -1,46 +1,49 @@
1
- import type { CreateStyle, CustomHTMLType, CustomProperties, KeyframesDefinition, ReturnType, VarsDefinition } from 'zss-engine';
2
- export declare class css {
3
- static create<T extends Record<string, CustomProperties>>(object: CreateStyle<T>): ReturnType<T>;
4
- static global(object: CustomHTMLType): void;
5
- static defineThemeVars<const T extends VarsDefinition>(object: T): { [K in keyof T]: `var(--${string & K})`; };
6
- static keyframes(object: KeyframesDefinition): string;
1
+ import type { CSSProperties, CSSHTML, CreateStyleType, CreateTheme, CreateVars, CreateKeyframes, ReturnType, CreateStyle } from 'zss-engine';
2
+ declare class css {
3
+ static create<T extends Record<string, CSSProperties>>(object: CreateStyleType<T>): ReturnType<T>;
4
+ static global(object: CSSHTML): void;
5
+ static defineVars<const T extends CreateVars>(object: T): { [K in keyof T]: `var(--${string & K})`; };
6
+ static defineTheme<const T extends CreateTheme>(object: T): { [K in keyof T]: `var(--${string & K})`; };
7
+ static keyframes(object: CreateKeyframes): string;
7
8
  static media: {
8
- range: (range: string) => "@media ()";
9
- max: (str: string) => "@media (max-)";
10
- min: (str: string) => "@media (min-)";
11
- scheme: {
12
- readonly dark: "@media (prefers-color-scheme: dark)";
13
- readonly light: "@media (prefers-color-scheme: light)";
14
- };
9
+ dark: "@media (prefers-color-scheme: dark)";
10
+ light: "@media (prefers-color-scheme: light)";
11
+ range: <S extends string>(range: S) => `@media (${S})`;
12
+ maxWidth: <V extends string | number>(value: V) => `@media (max-width: ${V}px)`;
13
+ maxHeight: <V extends string | number>(value: V) => `@media (max-height: ${V}px)`;
14
+ minWidth: <V extends string | number>(value: V) => `@media (min-width: ${V}px)`;
15
+ minHeight: <V extends string | number>(value: V) => `@media (min-height: ${V}px)`;
15
16
  };
16
17
  static container: {
17
- range: (range: string) => "@container ()";
18
- max: (str: string) => "@container (max-)";
19
- min: (str: string) => "@container (min-)";
18
+ range: <S extends string>(range: S) => `@container (${S})`;
19
+ maxWidth: <V extends string | number>(value: V) => V extends number ? `@container (max-width: ${V}px)` : `@container (max-width: ${V})`;
20
+ maxHeight: <V extends string | number>(value: V) => V extends number ? `@container (max-height: ${V}px)` : `@container (max-height: ${V})`;
21
+ minWidth: <V extends string | number>(value: V) => V extends number ? `@container (min-width: ${V}px)` : `@container (min-width: ${V})`;
22
+ minHeight: <V extends string | number>(value: V) => V extends number ? `@container (min-height: ${V}px)` : `@container (min-height: ${V})`;
20
23
  };
21
24
  static pseudo: {
22
25
  fn: {
23
- cue: (str: string) => "::cue()";
24
- dir: (str: string) => ":dir()";
25
- has: (str: string) => ":has()";
26
- host: (str: string) => ":host()";
27
- hostContext: (str: string) => ":host-context()";
28
- is: (str: string) => ":is()";
29
- lang: (str: string) => ":lang()";
30
- nthChild: (str: string) => ":nth-child()";
31
- nthLastChild: (str: string) => ":nth-last-child()";
32
- nthLastOfType: (str: string) => ":nth-last-of-type()";
33
- nthOfType: (str: string) => ":nth-of-type()";
34
- not: (str: string) => ":not()";
35
- state: (str: string) => ":state()";
36
- where: (str: string) => ":where()";
37
- highlight: (str: string) => "::highlight()";
38
- part: (str: string) => "::part()";
39
- slotted: (str: string) => "::slotted()";
40
- viewTransitionImagePair: (str: string) => "::view-transition-image-pair()";
41
- viewTransitionGroup: (str: string) => "::view-transition-group()";
42
- viewTransitionOld: (str: string) => "::view-transition-old()";
43
- viewTransitionNew: (str: string) => "::view-transition-new()";
26
+ cue: <S extends string>(str: S) => `::cue(${S})`;
27
+ dir: <S extends string>(str: S) => `:dir(${S})`;
28
+ has: <S extends string>(str: S) => `:has(${S})`;
29
+ host: <S extends string>(str: S) => `:host(${S})`;
30
+ hostContext: <S extends string>(str: S) => `:host-context(${S})`;
31
+ is: <S extends string>(str: S) => `:is(${S})`;
32
+ lang: <S extends string>(str: S) => `:lang(${S})`;
33
+ nthChild: <S extends string>(str: S) => `:nth-child(${S})`;
34
+ nthLastChild: <S extends string>(str: S) => `:nth-last-child(${S})`;
35
+ nthLastOfType: <S extends string>(str: S) => `:nth-last-of-type(${S})`;
36
+ nthOfType: <S extends string>(str: S) => `:nth-of-type(${S})`;
37
+ not: <S extends string>(str: S) => `:not(${S})`;
38
+ state: <S extends string>(str: S) => `:state(${S})`;
39
+ where: <S extends string>(str: S) => `:where(${S})`;
40
+ highlight: <S extends string>(str: S) => `::highlight(${S})`;
41
+ part: <S extends string>(str: S) => `::part(${S})`;
42
+ slotted: <S extends string>(str: S) => `::slotted(${S})`;
43
+ viewTransitionImagePair: <S extends string>(str: S) => `::view-transition-image-pair(${S})`;
44
+ viewTransitionGroup: <S extends string>(str: S) => `::view-transition-group(${S})`;
45
+ viewTransitionOld: <S extends string>(str: S) => `::view-transition-old(${S})`;
46
+ viewTransitionNew: <S extends string>(str: S) => `::view-transition-new(${S})`;
44
47
  };
45
48
  active: ":active";
46
49
  anyLink: ":any-link";
@@ -87,7 +90,7 @@ export declare class css {
87
90
  readWrite: ":read-write";
88
91
  required: ":required";
89
92
  right: ":right";
90
- root: "root";
93
+ root: ":root";
91
94
  scope: ":scope";
92
95
  seeking: ":seeking";
93
96
  stalled: ":stalled";
@@ -114,7 +117,163 @@ export declare class css {
114
117
  viewTransition: "::view-transition";
115
118
  };
116
119
  static color: {
117
- lighten: (color: string, amount: string | number) => string;
118
- darken: (color: string, amount: string | number) => string;
120
+ lighten: (color: string, amount: string | number) => `color-mix(in srgb, ${string}, white ${number}%)`;
121
+ darken: (color: string, amount: string | number) => `color-mix(in srgb, ${string}, black ${number}%)`;
122
+ primary: "#0070f3";
123
+ secondary: "#ff4081";
124
+ success: "#2e7d32";
125
+ warning: "#ed6c02";
126
+ error: "#d32f2f";
127
+ aliceblue: "aliceblue";
128
+ antiquewhite: "antiquewhite";
129
+ aqua: "aqua";
130
+ aquamarine: "aquamarine";
131
+ azure: "azure";
132
+ beige: "beige";
133
+ bisque: "bisque";
134
+ black: "black";
135
+ blanchedalmond: "blanchedalmond";
136
+ blue: "blue";
137
+ blueviolet: "blueviolet";
138
+ brown: "brown";
139
+ burlywood: "burlywood";
140
+ cadetblue: "cadetblue";
141
+ chartreuse: "chartreuse";
142
+ chocolate: "chocolate";
143
+ coral: "coral";
144
+ cornflowerblue: "cornflowerblue";
145
+ cornsilk: "cornsilk";
146
+ crimson: "crimson";
147
+ cyan: "cyan";
148
+ darkblue: "darkblue";
149
+ darkcyan: "darkcyan";
150
+ darkgoldenrod: "darkgoldenrod";
151
+ darkgray: "darkgray";
152
+ darkgreen: "darkgreen";
153
+ darkgrey: "darkgrey";
154
+ darkkhaki: "darkkhaki";
155
+ darkmagenta: "darkmagenta";
156
+ darkolivegreen: "darkolivegreen";
157
+ darkorange: "darkorange";
158
+ darkorchid: "darkorchid";
159
+ darkred: "darkred";
160
+ darksalmon: "darksalmon";
161
+ darkseagreen: "darkseagreen";
162
+ darkslateblue: "darkslateblue";
163
+ darkslategray: "darkslategray";
164
+ darkslategrey: "darkslategrey";
165
+ darkturquoise: "darkturquoise";
166
+ darkviolet: "darkviolet";
167
+ deeppink: "deeppink";
168
+ deepskyblue: "deepskyblue";
169
+ dimgray: "dimgray";
170
+ dimgrey: "dimgrey";
171
+ dodgerblue: "dodgerblue";
172
+ firebrick: "firebrick";
173
+ floralwhite: "floralwhite";
174
+ forestgreen: "forestgreen";
175
+ fuchsia: "fuchsia";
176
+ gainsboro: "gainsboro";
177
+ ghostwhite: "ghostwhite";
178
+ gold: "gold";
179
+ goldenrod: "goldenrod";
180
+ gray: "gray";
181
+ green: "green";
182
+ greenyellow: "greenyellow";
183
+ grey: "grey";
184
+ honeydew: "honeydew";
185
+ hotpink: "hotpink";
186
+ indianred: "indianred";
187
+ indigo: "indigo";
188
+ ivory: "ivory";
189
+ khaki: "khaki";
190
+ lavender: "lavender";
191
+ lavenderblush: "lavenderblush";
192
+ lawngreen: "lawngreen";
193
+ lemonchiffon: "lemonchiffon";
194
+ lightblue: "lightblue";
195
+ lightcoral: "lightcoral";
196
+ lightcyan: "lightcyan";
197
+ lightgoldenrodyellow: "lightgoldenrodyellow";
198
+ lightgray: "lightgray";
199
+ lightgreen: "lightgreen";
200
+ lightgrey: "lightgrey";
201
+ lightpink: "lightpink";
202
+ lightsalmon: "lightsalmon";
203
+ lightseagreen: "lightseagreen";
204
+ lightskyblue: "lightskyblue";
205
+ lightslategray: "lightslategray";
206
+ lightslategrey: "lightslategrey";
207
+ lightsteelblue: "lightsteelblue";
208
+ lightyellow: "lightyellow";
209
+ lime: "lime";
210
+ limegreen: "limegreen";
211
+ linen: "linen";
212
+ magenta: "magenta";
213
+ maroon: "maroon";
214
+ mediumaquamarine: "mediumaquamarine";
215
+ mediumblue: "mediumblue";
216
+ mediumorchid: "mediumorchid";
217
+ mediumpurple: "mediumpurple";
218
+ mediumseagreen: "mediumseagreen";
219
+ mediumslateblue: "mediumslateblue";
220
+ mediumspringgreen: "mediumspringgreen";
221
+ mediumturquoise: "mediumturquoise";
222
+ mediumvioletred: "mediumvioletred";
223
+ midnightblue: "midnightblue";
224
+ mintcream: "mintcream";
225
+ mistyrose: "mistyrose";
226
+ moccasin: "moccasin";
227
+ navajowhite: "navajowhite";
228
+ navy: "navy";
229
+ oldlace: "oldlace";
230
+ olive: "olive";
231
+ olivedrab: "olivedrab";
232
+ orange: "orange";
233
+ orangered: "orangered";
234
+ orchid: "orchid";
235
+ palegoldenrod: "palegoldenrod";
236
+ palegreen: "palegreen";
237
+ paleturquoise: "paleturquoise";
238
+ palevioletred: "palevioletred";
239
+ papayawhip: "papayawhip";
240
+ peachpuff: "peachpuff";
241
+ peru: "peru";
242
+ pink: "pink";
243
+ plum: "plum";
244
+ powderblue: "powderblue";
245
+ purple: "purple";
246
+ rebeccapurple: "rebeccapurple";
247
+ red: "red";
248
+ rosybrown: "rosybrown";
249
+ royalblue: "royalblue";
250
+ saddlebrown: "saddlebrown";
251
+ salmon: "salmon";
252
+ sandybrown: "sandybrown";
253
+ seagreen: "seagreen";
254
+ seashell: "seashell";
255
+ sienna: "sienna";
256
+ silver: "silver";
257
+ skyblue: "skyblue";
258
+ slateblue: "slateblue";
259
+ slategray: "slategray";
260
+ slategrey: "slategrey";
261
+ snow: "snow";
262
+ springgreen: "springgreen";
263
+ steelblue: "steelblue";
264
+ tan: "tan";
265
+ teal: "teal";
266
+ thistle: "thistle";
267
+ tomato: "tomato";
268
+ transparent: "transparent";
269
+ turquoise: "turquoise";
270
+ violet: "violet";
271
+ wheat: "wheat";
272
+ white: "white";
273
+ whitesmoke: "whitesmoke";
274
+ yellow: "yellow";
275
+ yellowgreen: "yellowgreen";
119
276
  };
120
277
  }
278
+ export default css;
279
+ export type { CSSProperties, CSSHTML, CreateStyle };
package/types/cx.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare const cx: (...strings: Array<string | null | undefined | false>) => string & ":";
1
+ declare const cx: (...strings: Array<string | null | undefined | false>) => string & ":";
2
+ export default cx;
package/types/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { css } from './css';
2
- export { cx } from './cx';
3
- export { rx } from './rx';
1
+ export { default as css } from './css';
2
+ export { default as cx } from './cx';
3
+ export { default as rx } from './rx';
4
+ export type { CreateStyle, CSSProperties, CSSHTML } from './css';
@@ -0,0 +1,10 @@
1
+ declare let resolvePromise_1: (value: string) => void;
2
+ declare let globalPromise_1: Promise<string>;
3
+ declare function initPromise_1(): void;
4
+ export declare function buildCreate(filePath: string): Promise<void>;
5
+ export { resolvePromise_1, globalPromise_1, initPromise_1 };
6
+ declare let resolvePromise_2: (value: string) => void;
7
+ declare let globalPromise_2: Promise<string>;
8
+ declare function initPromise_2(): void;
9
+ export declare function buildGlobal(filePath: string): Promise<void>;
10
+ export { resolvePromise_2, globalPromise_2, initPromise_2 };
package/types/rx.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const rx: (className: string, varSet: {
1
+ declare const rx: (className: string, varSet: {
2
2
  [key: `--${string}`]: string;
3
3
  }) => {
4
4
  className: string;
@@ -6,3 +6,4 @@ export declare const rx: (className: string, varSet: {
6
6
  [k: string]: string;
7
7
  };
8
8
  };
9
+ export default rx;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildGlobal = exports.buildCreate = void 0;
4
- var create_build_helper_js_1 = require("./create-build-helper.js");
5
- Object.defineProperty(exports, "buildCreate", { enumerable: true, get: function () { return create_build_helper_js_1.buildCreate; } });
6
- var global_build_helper_js_1 = require("./global-build-helper.js");
7
- Object.defineProperty(exports, "buildGlobal", { enumerable: true, get: function () { return global_build_helper_js_1.buildGlobal; } });
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globalPromise = exports.resolvePromise = void 0;
4
- exports.buildCreate = buildCreate;
5
- exports.initPromise = initPromise;
6
- const zss_engine_1 = require("zss-engine");
7
- let resolvePromise;
8
- let globalPromise;
9
- const sheetQueue = [];
10
- let isProcessing = false;
11
- function initPromise() {
12
- exports.globalPromise = globalPromise = new Promise((resolve) => {
13
- exports.resolvePromise = resolvePromise = (value) => {
14
- sheetQueue.push(value);
15
- resolve(value);
16
- };
17
- });
18
- }
19
- async function processQueue(filePath) {
20
- while (sheetQueue.length > 0) {
21
- const styleSheet = sheetQueue.shift();
22
- if (!zss_engine_1.isDevelopment && styleSheet)
23
- (0, zss_engine_1.build)(styleSheet, filePath);
24
- }
25
- isProcessing = false;
26
- }
27
- async function buildCreate(filePath) {
28
- if (typeof globalPromise === 'undefined')
29
- initPromise();
30
- if (!isProcessing && sheetQueue.length > 0) {
31
- isProcessing = true;
32
- processQueue(filePath);
33
- }
34
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = create;
4
- const zss_engine_1 = require("zss-engine");
5
- const create_build_helper_js_1 = require("./create-build-helper.js");
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 create_build_helper_js_1.globalPromise === 'undefined')
11
- (0, create_build_helper_js_1.initPromise)();
12
- (0, create_build_helper_js_1.resolvePromise)(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
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineThemeVars = void 0;
4
- const global_js_1 = require("./global.js");
5
- const defineThemeVars = (object) => {
6
- const globalStyles = {};
7
- const result = {};
8
- Object.entries(object).forEach(([key, value]) => {
9
- result[key] = `var(--${key})`;
10
- if (typeof value === 'string') {
11
- (globalStyles[':root'] ||= {})[`--${key}`] = value;
12
- }
13
- else if (typeof value === 'object') {
14
- Object.entries(value).forEach(([subKey, subValue]) => {
15
- if (subKey.startsWith('@media')) {
16
- (globalStyles[':root'] ||= {})[subKey] ||= {};
17
- globalStyles[':root'][subKey][`--${key}`] = subValue;
18
- }
19
- else {
20
- const themeSelector = subKey === 'default' ? ':root' : `:root[data-theme="${subKey}"]`;
21
- (globalStyles[themeSelector] ||= {})[`--${key}`] = subValue;
22
- }
23
- });
24
- }
25
- });
26
- (0, global_js_1.global)(globalStyles);
27
- return result;
28
- };
29
- exports.defineThemeVars = defineThemeVars;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globalPromise = exports.resolvePromise = void 0;
4
- exports.buildGlobal = buildGlobal;
5
- exports.initPromise = initPromise;
6
- const zss_engine_1 = require("zss-engine");
7
- let resolvePromise;
8
- let globalPromise;
9
- const seetQueue = [];
10
- let isProcessing = false;
11
- function initPromise() {
12
- exports.globalPromise = globalPromise = new Promise((resolve) => {
13
- exports.resolvePromise = resolvePromise = (value) => {
14
- seetQueue.push(value);
15
- resolve(value);
16
- };
17
- });
18
- }
19
- async function processSheets(filePath) {
20
- while (seetQueue.length > 0) {
21
- const [styleSheet, option] = seetQueue.shift();
22
- if (!zss_engine_1.isDevelopment && styleSheet)
23
- (0, zss_engine_1.build)(styleSheet, filePath, option);
24
- }
25
- isProcessing = false;
26
- }
27
- async function buildGlobal(filePath) {
28
- if (typeof globalPromise === 'undefined')
29
- initPromise();
30
- if (!isProcessing && seetQueue.length > 0) {
31
- isProcessing = true;
32
- processSheets(filePath);
33
- }
34
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.global = global;
4
- const zss_engine_1 = require("zss-engine");
5
- const global_build_helper_js_1 = require("./global-build-helper.js");
6
- function global(object) {
7
- const base36Hash = (0, zss_engine_1.genBase36Hash)(object, 8);
8
- const { styleSheet } = (0, zss_engine_1.transpiler)(object, undefined, '--global');
9
- if (typeof global_build_helper_js_1.globalPromise === 'undefined')
10
- (0, global_build_helper_js_1.initPromise)();
11
- (0, global_build_helper_js_1.resolvePromise)([styleSheet, '--global']);
12
- if (zss_engine_1.isDevAndTest)
13
- zss_engine_1.isServer
14
- ? (0, zss_engine_1.injectServerCSS)(base36Hash, styleSheet)
15
- : (0, zss_engine_1.injectClientGlobalCSS)(styleSheet, 'global');
16
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keyframes = void 0;
4
- const zss_engine_1 = require("zss-engine");
5
- const global_js_1 = require("./global.js");
6
- const keyframes = (object) => {
7
- const prefix = (0, zss_engine_1.genBase36Hash)(object, 8);
8
- (0, global_js_1.global)({ [`@keyframes ${prefix}`]: object });
9
- return prefix;
10
- };
11
- exports.keyframes = keyframes;
@@ -1,2 +0,0 @@
1
- export { buildCreate } from './create-build-helper.js';
2
- export { buildGlobal } from './global-build-helper.js';
@@ -1,30 +0,0 @@
1
- import { build, isDevelopment } from 'zss-engine';
2
- let resolvePromise;
3
- let globalPromise;
4
- const sheetQueue = [];
5
- let isProcessing = false;
6
- function initPromise() {
7
- globalPromise = new Promise((resolve) => {
8
- resolvePromise = (value) => {
9
- sheetQueue.push(value);
10
- resolve(value);
11
- };
12
- });
13
- }
14
- async function processQueue(filePath) {
15
- while (sheetQueue.length > 0) {
16
- const styleSheet = sheetQueue.shift();
17
- if (!isDevelopment && styleSheet)
18
- build(styleSheet, filePath);
19
- }
20
- isProcessing = false;
21
- }
22
- export async function buildCreate(filePath) {
23
- if (typeof globalPromise === 'undefined')
24
- initPromise();
25
- if (!isProcessing && sheetQueue.length > 0) {
26
- isProcessing = true;
27
- processQueue(filePath);
28
- }
29
- }
30
- export { resolvePromise, globalPromise, initPromise };
@@ -1,21 +0,0 @@
1
- import { isDevAndTest, transpiler, genBase36Hash, isServer, injectServerCSS, injectClientCSS, } from 'zss-engine';
2
- import { initPromise, globalPromise, resolvePromise, } from './create-build-helper.js';
3
- export function create(object) {
4
- const base36Hash = genBase36Hash(object, 6);
5
- const { styleSheet } = transpiler(object, base36Hash);
6
- const injectCSS = isServer ? injectServerCSS : injectClientCSS;
7
- if (typeof globalPromise === 'undefined')
8
- initPromise();
9
- resolvePromise(styleSheet);
10
- Object.keys(object).forEach((key) => {
11
- Object.defineProperty(object, key, {
12
- get: () => {
13
- const className = key + '_' + base36Hash;
14
- if (isDevAndTest)
15
- injectCSS(base36Hash, styleSheet);
16
- return className;
17
- },
18
- });
19
- });
20
- return Object.freeze(object);
21
- }
@@ -1,25 +0,0 @@
1
- import { global } from './global.js';
2
- export const defineThemeVars = (object) => {
3
- const globalStyles = {};
4
- const result = {};
5
- Object.entries(object).forEach(([key, value]) => {
6
- result[key] = `var(--${key})`;
7
- if (typeof value === 'string') {
8
- (globalStyles[':root'] ||= {})[`--${key}`] = value;
9
- }
10
- else if (typeof value === 'object') {
11
- Object.entries(value).forEach(([subKey, subValue]) => {
12
- if (subKey.startsWith('@media')) {
13
- (globalStyles[':root'] ||= {})[subKey] ||= {};
14
- globalStyles[':root'][subKey][`--${key}`] = subValue;
15
- }
16
- else {
17
- const themeSelector = subKey === 'default' ? ':root' : `:root[data-theme="${subKey}"]`;
18
- (globalStyles[themeSelector] ||= {})[`--${key}`] = subValue;
19
- }
20
- });
21
- }
22
- });
23
- global(globalStyles);
24
- return result;
25
- };
@@ -1,30 +0,0 @@
1
- import { build, isDevelopment } from 'zss-engine';
2
- let resolvePromise;
3
- let globalPromise;
4
- const seetQueue = [];
5
- let isProcessing = false;
6
- function initPromise() {
7
- globalPromise = new Promise((resolve) => {
8
- resolvePromise = (value) => {
9
- seetQueue.push(value);
10
- resolve(value);
11
- };
12
- });
13
- }
14
- async function processSheets(filePath) {
15
- while (seetQueue.length > 0) {
16
- const [styleSheet, option] = seetQueue.shift();
17
- if (!isDevelopment && styleSheet)
18
- build(styleSheet, filePath, option);
19
- }
20
- isProcessing = false;
21
- }
22
- export async function buildGlobal(filePath) {
23
- if (typeof globalPromise === 'undefined')
24
- initPromise();
25
- if (!isProcessing && seetQueue.length > 0) {
26
- isProcessing = true;
27
- processSheets(filePath);
28
- }
29
- }
30
- export { resolvePromise, globalPromise, initPromise };
@@ -1,13 +0,0 @@
1
- import { isDevAndTest, isServer, injectServerCSS, injectClientGlobalCSS, transpiler, genBase36Hash, } from 'zss-engine';
2
- import { resolvePromise, globalPromise, initPromise, } from './global-build-helper.js';
3
- export function global(object) {
4
- const base36Hash = genBase36Hash(object, 8);
5
- const { styleSheet } = transpiler(object, undefined, '--global');
6
- if (typeof globalPromise === 'undefined')
7
- initPromise();
8
- resolvePromise([styleSheet, '--global']);
9
- if (isDevAndTest)
10
- isServer
11
- ? injectServerCSS(base36Hash, styleSheet)
12
- : injectClientGlobalCSS(styleSheet, 'global');
13
- }
@@ -1,7 +0,0 @@
1
- import { genBase36Hash } from 'zss-engine';
2
- import { global } from './global.js';
3
- export const keyframes = (object) => {
4
- const prefix = genBase36Hash(object, 8);
5
- global({ [`@keyframes ${prefix}`]: object });
6
- return prefix;
7
- };
@@ -1,2 +0,0 @@
1
- export { buildCreate } from './create-build-helper.js';
2
- export { buildGlobal } from './global-build-helper.js';
@@ -1,5 +0,0 @@
1
- declare let resolvePromise: (value: string) => void;
2
- declare let globalPromise: Promise<string>;
3
- declare function initPromise(): void;
4
- export declare function buildCreate(filePath: string): Promise<void>;
5
- export { resolvePromise, globalPromise, initPromise };
@@ -1,2 +0,0 @@
1
- import type { ReturnType, CreateStyle, CustomProperties } from 'zss-engine';
2
- export declare function create<T extends Record<string, CustomProperties>>(object: CreateStyle<T>): ReturnType<T>;
@@ -1,2 +0,0 @@
1
- import type { VarsDefinition } from 'zss-engine';
2
- export declare const defineThemeVars: <const T extends VarsDefinition>(object: T) => { [K in keyof T]: `var(--${string & K})`; };
@@ -1,5 +0,0 @@
1
- declare let resolvePromise: (value: [string, string]) => void;
2
- declare let globalPromise: Promise<[string, string]>;
3
- declare function initPromise(): void;
4
- export declare function buildGlobal(filePath: string): Promise<void>;
5
- export { resolvePromise, globalPromise, initPromise };
@@ -1,2 +0,0 @@
1
- import type { CustomHTMLType, VarsDefinition } from 'zss-engine';
2
- export declare function global(object: CustomHTMLType | VarsDefinition): void;
@@ -1,2 +0,0 @@
1
- import { type KeyframesDefinition } from 'zss-engine';
2
- export declare const keyframes: (object: KeyframesDefinition) => string;
File without changes