zss-engine 0.2.10 → 0.2.11

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 (45) hide show
  1. package/dist/index.js +30 -236
  2. package/dist/index.mjs +8 -225
  3. package/dist/types/common/css-properties.js +2 -0
  4. package/dist/types/common/css-properties.mjs +1 -0
  5. package/dist/types/common/css-property.js +2 -0
  6. package/dist/types/common/css-property.mjs +1 -0
  7. package/dist/types/index.js +21 -0
  8. package/dist/types/index.mjs +5 -0
  9. package/dist/types/main/create.js +2 -0
  10. package/dist/types/main/create.mjs +1 -0
  11. package/dist/types/main/global.js +2 -0
  12. package/dist/types/main/global.mjs +1 -0
  13. package/dist/types/main/vars.js +2 -0
  14. package/dist/types/main/vars.mjs +1 -0
  15. package/dist/utils/build.js +27 -0
  16. package/dist/utils/build.mjs +23 -0
  17. package/dist/utils/hash.js +34 -0
  18. package/dist/utils/hash.mjs +31 -0
  19. package/dist/utils/helper.js +21 -0
  20. package/dist/utils/helper.mjs +16 -0
  21. package/dist/utils/inject-client-css.js +51 -0
  22. package/dist/utils/inject-client-css.mjs +47 -0
  23. package/dist/utils/inject-client-global-css.js +18 -0
  24. package/dist/utils/inject-client-global-css.mjs +15 -0
  25. package/dist/utils/inject-server-css.js +11 -0
  26. package/dist/utils/inject-server-css.mjs +7 -0
  27. package/dist/utils/transpiler.js +125 -0
  28. package/dist/utils/transpiler.mjs +122 -0
  29. package/package.json +5 -3
  30. package/types/index.d.ts +8 -130
  31. package/types/types/common/css-properties.d.ts +46 -0
  32. package/types/types/common/css-property.d.ts +5 -0
  33. package/types/types/index.d.ts +5 -0
  34. package/types/types/main/create.d.ts +10 -0
  35. package/types/types/main/global.d.ts +37 -0
  36. package/types/types/main/vars.d.ts +10 -0
  37. package/types/utils/build.d.ts +1 -0
  38. package/types/utils/hash.d.ts +2 -0
  39. package/types/utils/helper.d.ts +6 -0
  40. package/types/utils/inject-client-css.d.ts +2 -0
  41. package/types/utils/inject-client-global-css.d.ts +1 -0
  42. package/types/utils/inject-server-css.d.ts +2 -0
  43. package/types/utils/transpiler.d.ts +4 -0
  44. package/dist/build-12x-B3dvmUcg.mjs +0 -52
  45. package/dist/build-12x-C7vH1H69.js +0 -54
package/dist/index.js CHANGED
@@ -1,238 +1,32 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- var build12x = require('./build-12x-C7vH1H69.js');
4
-
5
- const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
6
- function simpleHash(str) {
7
- let hash = 0;
8
- for(let i = 0; i < str.length; i++){
9
- const char = str.charCodeAt(i);
10
- hash = (hash << 5) - hash + char;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
7
  }
12
- return Math.abs(hash);
13
- }
14
- function encodeBase36(num) {
15
- let result = '';
16
- do {
17
- result = chars[num % 36] + result;
18
- num = Math.floor(num / 36);
19
- }while (num > 0)
20
- return result;
21
- }
22
- function getStartingChar(hash) {
23
- const chars = 'abcdefghijklmnopqrstuvwxyz';
24
- return chars[hash % chars.length];
25
- }
26
- function genBase36Hash(object, n) {
27
- const serialized = JSON.stringify(object);
28
- const hash = simpleHash(serialized);
29
- let base36Hash = encodeBase36(hash);
30
- const startingChar = getStartingChar(hash);
31
- while(base36Hash.length < n - 1){
32
- base36Hash = chars[hash % chars.length] + base36Hash;
33
- }
34
- return startingChar + base36Hash.slice(0, n - 1);
35
- }
36
-
37
- const styleSheets$1 = {};
38
- const hashCache = {};
39
- function createStyleElement(hash) {
40
- if (document.getElementById(hash)) return null;
41
- const styleElement = document.createElement('style');
42
- styleElement.setAttribute('id', hash);
43
- styleElement.setAttribute('type', 'text/css');
44
- styleSheets$1[hash] = styleElement;
45
- document.head.appendChild(styleElement);
46
- return styleSheets$1[hash];
47
- }
48
- function injectClientCSS(hash, sheet) {
49
- if (build12x.isServer) return;
50
- requestAnimationFrame(()=>{
51
- styleCleanUp();
52
- });
53
- hashCache[hash] = hash;
54
- const styleElement = createStyleElement(hash);
55
- if (styleElement == null) return;
56
- styleElement.textContent = sheet;
57
- }
58
- function styleCleanUp() {
59
- requestAnimationFrame(()=>{
60
- for(const hash in hashCache){
61
- const classElements = document.querySelectorAll(`[class*="${hash}"]`);
62
- if (classElements.length === 0) {
63
- removeStyleElement(hashCache[hash]);
64
- }
65
- }
66
- });
67
- }
68
- function removeStyleElement(hash) {
69
- if (styleSheets$1[hash]) {
70
- delete styleSheets$1[hash];
71
- if (hashCache.hasOwnProperty.call(hashCache, hash)) {
72
- delete hashCache[hash];
73
- }
74
- const styleElement = document.getElementById(hash);
75
- if (styleElement) {
76
- document.head.removeChild(styleElement);
77
- }
78
- }
79
- }
80
-
81
- function injectClientGlobalCSS(sheet, scoped) {
82
- if (build12x.isServer) return;
83
- const existingStyleElement = document.querySelector(`[data-scope="${scoped}"]`);
84
- if (existingStyleElement instanceof HTMLStyleElement) {
85
- existingStyleElement.textContent += sheet;
86
- return;
87
- }
88
- const styleElement = document.createElement('style');
89
- styleElement.setAttribute('data-scope', scoped);
90
- styleElement.setAttribute('type', 'text/css');
91
- styleElement.textContent = sheet;
92
- document.head.appendChild(styleElement);
93
- }
94
-
95
- const styleSheets = {};
96
- function injectServerCSS(hash, sheet) {
97
- styleSheets[hash] = sheet;
98
- }
99
- function getServerCSS() {
100
- return Object.values(styleSheets).join('\n');
101
- }
102
-
103
- const createKeyframes = (property, content)=>{
104
- let keyframesRules = `${property} {\n`;
105
- for(const key in content){
106
- if (Object.prototype.hasOwnProperty.call(content, key)) {
107
- const keyframeValue = content[key];
108
- keyframesRules += ` ${key} {\n`;
109
- for(const prop in keyframeValue){
110
- if (Object.prototype.hasOwnProperty.call(keyframeValue, prop)) {
111
- const CSSProp = build12x.camelToKebabCase(prop);
112
- const value = keyframeValue[prop];
113
- if (typeof value === 'string' || typeof value === 'number') {
114
- const applyValue = build12x.applyCssValue(value, CSSProp);
115
- keyframesRules += ` ${CSSProp}: ${applyValue};\n`;
116
- }
117
- }
118
- }
119
- keyframesRules += ` }\n`;
120
- }
121
- }
122
- keyframesRules += `}\n`;
123
- return keyframesRules;
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
124
15
  };
125
- function transpiler(object, base36Hash, core) {
126
- let styleSheet = '';
127
- const mediaQueries = [];
128
- const classNameType = (property)=>{
129
- return core === '--global' ? property : `.${property}_${base36Hash}`;
130
- };
131
- const rules = (indent, rulesValue, property)=>{
132
- if (typeof property !== 'string') return '';
133
- const value = rulesValue[property];
134
- const cssProp = build12x.camelToKebabCase(property);
135
- return `${indent}${cssProp}: ${value};\n`;
136
- };
137
- const stringConverter = (className, properties, indentLevel = 0)=>{
138
- const classSelector = {};
139
- const indent = ''.repeat(indentLevel);
140
- const innerIndent = ' '.repeat(indentLevel + 1);
141
- let cssRule = '';
142
- for(const property in properties){
143
- if (Object.prototype.hasOwnProperty.call(properties, property)) {
144
- const value = properties[property];
145
- if (typeof value === 'string' || typeof value === 'number') {
146
- let CSSProp = build12x.camelToKebabCase(property);
147
- if (property.startsWith('ms')) {
148
- CSSProp = `-${CSSProp}`;
149
- }
150
- const applyValue = build12x.applyCssValue(value, CSSProp);
151
- cssRule += ` ${CSSProp}: ${applyValue};\n`;
152
- } else if (!property.startsWith('@')) {
153
- const kebabPseudoSelector = build12x.camelToKebabCase(property.replace('&', ''));
154
- const styles = stringConverter(className + kebabPseudoSelector, value, indentLevel);
155
- Object.assign(classSelector, styles);
156
- } else if (property.startsWith('@media') || property.startsWith('@container')) {
157
- const mediaRule = property;
158
- let nestedRules = '';
159
- let regularRules = '';
160
- for(const mediaProp in value){
161
- if (Object.prototype.hasOwnProperty.call(value, mediaProp)) {
162
- const mediaValue = value[mediaProp];
163
- const isColon = mediaProp.startsWith(':');
164
- const isAnd = mediaProp.startsWith('&');
165
- if (isColon || isAnd) {
166
- const kebabMediaProp = build12x.camelToKebabCase(mediaProp.replace('&', ''));
167
- let pseudoClassRule = '';
168
- if (typeof mediaValue === 'object' && mediaValue !== null) {
169
- for(const pseudoProp in mediaValue){
170
- if (Object.prototype.hasOwnProperty.call(mediaValue, pseudoProp)) {
171
- const CSSProp = build12x.camelToKebabCase(pseudoProp);
172
- const applyValue = build12x.applyCssValue(mediaValue[pseudoProp], CSSProp);
173
- pseudoClassRule += rules(innerIndent + ' ', {
174
- [pseudoProp]: applyValue
175
- }, pseudoProp);
176
- }
177
- }
178
- }
179
- nestedRules += `${innerIndent}${className}${kebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
180
- } else {
181
- const CSSProp = build12x.camelToKebabCase(mediaProp);
182
- const applyValue = build12x.applyCssValue(mediaValue, CSSProp);
183
- regularRules += rules(innerIndent + ' ', {
184
- [mediaProp]: applyValue
185
- }, mediaProp);
186
- }
187
- }
188
- }
189
- if (regularRules) {
190
- mediaQueries.push({
191
- media: mediaRule,
192
- css: `${mediaRule} {\n${innerIndent}${className} {\n${regularRules} }\n${nestedRules}${indent}}${indent}\n`
193
- });
194
- } else {
195
- mediaQueries.push({
196
- media: mediaRule,
197
- css: `${mediaRule} {\n${nestedRules}${indent}}\n`
198
- });
199
- }
200
- }
201
- }
202
- }
203
- classSelector[className] = cssRule;
204
- return classSelector;
205
- };
206
- for(const property in object){
207
- if (property.startsWith('@keyframes')) {
208
- const keyframesContent = object[property];
209
- styleSheet += createKeyframes(property, keyframesContent);
210
- }
211
- const classSelectors = stringConverter(classNameType(property), object[property], 1);
212
- for(const selector in classSelectors){
213
- if (!selector.startsWith('@keyframes') && classSelectors[selector]) {
214
- styleSheet += selector + ' {\n' + classSelectors[selector] + '}\n';
215
- }
216
- }
217
- }
218
- mediaQueries.forEach(({ css })=>{
219
- styleSheet += css;
220
- });
221
- return {
222
- styleSheet
223
- };
224
- }
225
-
226
- exports.applyCssValue = build12x.applyCssValue;
227
- exports.build = build12x.build;
228
- exports.camelToKebabCase = build12x.camelToKebabCase;
229
- exports.isDevAndTest = build12x.isDevAndTest;
230
- exports.isDevServer = build12x.isDevServer;
231
- exports.isDevelopment = build12x.isDevelopment;
232
- exports.isServer = build12x.isServer;
233
- exports.genBase36Hash = genBase36Hash;
234
- exports.getServerCSS = getServerCSS;
235
- exports.injectClientCSS = injectClientCSS;
236
- exports.injectClientGlobalCSS = injectClientGlobalCSS;
237
- exports.injectServerCSS = injectServerCSS;
238
- exports.transpiler = transpiler;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.transpiler = exports.build = exports.getServerCSS = exports.injectServerCSS = exports.injectClientGlobalCSS = exports.injectClientCSS = exports.genBase36Hash = void 0;
18
+ __exportStar(require("./types"), exports);
19
+ __exportStar(require("./utils/helper"), exports);
20
+ var hash_1 = require("./utils/hash");
21
+ Object.defineProperty(exports, "genBase36Hash", { enumerable: true, get: function () { return hash_1.genBase36Hash; } });
22
+ var inject_client_css_1 = require("./utils/inject-client-css");
23
+ Object.defineProperty(exports, "injectClientCSS", { enumerable: true, get: function () { return inject_client_css_1.injectClientCSS; } });
24
+ var inject_client_global_css_1 = require("./utils/inject-client-global-css");
25
+ Object.defineProperty(exports, "injectClientGlobalCSS", { enumerable: true, get: function () { return inject_client_global_css_1.injectClientGlobalCSS; } });
26
+ var inject_server_css_1 = require("./utils/inject-server-css");
27
+ Object.defineProperty(exports, "injectServerCSS", { enumerable: true, get: function () { return inject_server_css_1.injectServerCSS; } });
28
+ Object.defineProperty(exports, "getServerCSS", { enumerable: true, get: function () { return inject_server_css_1.getServerCSS; } });
29
+ var build_1 = require("./utils/build");
30
+ Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
31
+ var transpiler_1 = require("./utils/transpiler");
32
+ Object.defineProperty(exports, "transpiler", { enumerable: true, get: function () { return transpiler_1.transpiler; } });
package/dist/index.mjs CHANGED
@@ -1,225 +1,8 @@
1
- import { i as isServer, c as camelToKebabCase, a as applyCssValue } from './build-12x-B3dvmUcg.mjs';
2
- export { b as build, e as isDevAndTest, f as isDevServer, d as isDevelopment } from './build-12x-B3dvmUcg.mjs';
3
-
4
- const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
5
- function simpleHash(str) {
6
- let hash = 0;
7
- for(let i = 0; i < str.length; i++){
8
- const char = str.charCodeAt(i);
9
- hash = (hash << 5) - hash + char;
10
- }
11
- return Math.abs(hash);
12
- }
13
- function encodeBase36(num) {
14
- let result = '';
15
- do {
16
- result = chars[num % 36] + result;
17
- num = Math.floor(num / 36);
18
- }while (num > 0)
19
- return result;
20
- }
21
- function getStartingChar(hash) {
22
- const chars = 'abcdefghijklmnopqrstuvwxyz';
23
- return chars[hash % chars.length];
24
- }
25
- function genBase36Hash(object, n) {
26
- const serialized = JSON.stringify(object);
27
- const hash = simpleHash(serialized);
28
- let base36Hash = encodeBase36(hash);
29
- const startingChar = getStartingChar(hash);
30
- while(base36Hash.length < n - 1){
31
- base36Hash = chars[hash % chars.length] + base36Hash;
32
- }
33
- return startingChar + base36Hash.slice(0, n - 1);
34
- }
35
-
36
- const styleSheets$1 = {};
37
- const hashCache = {};
38
- function createStyleElement(hash) {
39
- if (document.getElementById(hash)) return null;
40
- const styleElement = document.createElement('style');
41
- styleElement.setAttribute('id', hash);
42
- styleElement.setAttribute('type', 'text/css');
43
- styleSheets$1[hash] = styleElement;
44
- document.head.appendChild(styleElement);
45
- return styleSheets$1[hash];
46
- }
47
- function injectClientCSS(hash, sheet) {
48
- if (isServer) return;
49
- requestAnimationFrame(()=>{
50
- styleCleanUp();
51
- });
52
- hashCache[hash] = hash;
53
- const styleElement = createStyleElement(hash);
54
- if (styleElement == null) return;
55
- styleElement.textContent = sheet;
56
- }
57
- function styleCleanUp() {
58
- requestAnimationFrame(()=>{
59
- for(const hash in hashCache){
60
- const classElements = document.querySelectorAll(`[class*="${hash}"]`);
61
- if (classElements.length === 0) {
62
- removeStyleElement(hashCache[hash]);
63
- }
64
- }
65
- });
66
- }
67
- function removeStyleElement(hash) {
68
- if (styleSheets$1[hash]) {
69
- delete styleSheets$1[hash];
70
- if (hashCache.hasOwnProperty.call(hashCache, hash)) {
71
- delete hashCache[hash];
72
- }
73
- const styleElement = document.getElementById(hash);
74
- if (styleElement) {
75
- document.head.removeChild(styleElement);
76
- }
77
- }
78
- }
79
-
80
- function injectClientGlobalCSS(sheet, scoped) {
81
- if (isServer) return;
82
- const existingStyleElement = document.querySelector(`[data-scope="${scoped}"]`);
83
- if (existingStyleElement instanceof HTMLStyleElement) {
84
- existingStyleElement.textContent += sheet;
85
- return;
86
- }
87
- const styleElement = document.createElement('style');
88
- styleElement.setAttribute('data-scope', scoped);
89
- styleElement.setAttribute('type', 'text/css');
90
- styleElement.textContent = sheet;
91
- document.head.appendChild(styleElement);
92
- }
93
-
94
- const styleSheets = {};
95
- function injectServerCSS(hash, sheet) {
96
- styleSheets[hash] = sheet;
97
- }
98
- function getServerCSS() {
99
- return Object.values(styleSheets).join('\n');
100
- }
101
-
102
- const createKeyframes = (property, content)=>{
103
- let keyframesRules = `${property} {\n`;
104
- for(const key in content){
105
- if (Object.prototype.hasOwnProperty.call(content, key)) {
106
- const keyframeValue = content[key];
107
- keyframesRules += ` ${key} {\n`;
108
- for(const prop in keyframeValue){
109
- if (Object.prototype.hasOwnProperty.call(keyframeValue, prop)) {
110
- const CSSProp = camelToKebabCase(prop);
111
- const value = keyframeValue[prop];
112
- if (typeof value === 'string' || typeof value === 'number') {
113
- const applyValue = applyCssValue(value, CSSProp);
114
- keyframesRules += ` ${CSSProp}: ${applyValue};\n`;
115
- }
116
- }
117
- }
118
- keyframesRules += ` }\n`;
119
- }
120
- }
121
- keyframesRules += `}\n`;
122
- return keyframesRules;
123
- };
124
- function transpiler(object, base36Hash, core) {
125
- let styleSheet = '';
126
- const mediaQueries = [];
127
- const classNameType = (property)=>{
128
- return core === '--global' ? property : `.${property}_${base36Hash}`;
129
- };
130
- const rules = (indent, rulesValue, property)=>{
131
- if (typeof property !== 'string') return '';
132
- const value = rulesValue[property];
133
- const cssProp = camelToKebabCase(property);
134
- return `${indent}${cssProp}: ${value};\n`;
135
- };
136
- const stringConverter = (className, properties, indentLevel = 0)=>{
137
- const classSelector = {};
138
- const indent = ''.repeat(indentLevel);
139
- const innerIndent = ' '.repeat(indentLevel + 1);
140
- let cssRule = '';
141
- for(const property in properties){
142
- if (Object.prototype.hasOwnProperty.call(properties, property)) {
143
- const value = properties[property];
144
- if (typeof value === 'string' || typeof value === 'number') {
145
- let CSSProp = camelToKebabCase(property);
146
- if (property.startsWith('ms')) {
147
- CSSProp = `-${CSSProp}`;
148
- }
149
- const applyValue = applyCssValue(value, CSSProp);
150
- cssRule += ` ${CSSProp}: ${applyValue};\n`;
151
- } else if (!property.startsWith('@')) {
152
- const kebabPseudoSelector = camelToKebabCase(property.replace('&', ''));
153
- const styles = stringConverter(className + kebabPseudoSelector, value, indentLevel);
154
- Object.assign(classSelector, styles);
155
- } else if (property.startsWith('@media') || property.startsWith('@container')) {
156
- const mediaRule = property;
157
- let nestedRules = '';
158
- let regularRules = '';
159
- for(const mediaProp in value){
160
- if (Object.prototype.hasOwnProperty.call(value, mediaProp)) {
161
- const mediaValue = value[mediaProp];
162
- const isColon = mediaProp.startsWith(':');
163
- const isAnd = mediaProp.startsWith('&');
164
- if (isColon || isAnd) {
165
- const kebabMediaProp = camelToKebabCase(mediaProp.replace('&', ''));
166
- let pseudoClassRule = '';
167
- if (typeof mediaValue === 'object' && mediaValue !== null) {
168
- for(const pseudoProp in mediaValue){
169
- if (Object.prototype.hasOwnProperty.call(mediaValue, pseudoProp)) {
170
- const CSSProp = camelToKebabCase(pseudoProp);
171
- const applyValue = applyCssValue(mediaValue[pseudoProp], CSSProp);
172
- pseudoClassRule += rules(innerIndent + ' ', {
173
- [pseudoProp]: applyValue
174
- }, pseudoProp);
175
- }
176
- }
177
- }
178
- nestedRules += `${innerIndent}${className}${kebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
179
- } else {
180
- const CSSProp = camelToKebabCase(mediaProp);
181
- const applyValue = applyCssValue(mediaValue, CSSProp);
182
- regularRules += rules(innerIndent + ' ', {
183
- [mediaProp]: applyValue
184
- }, mediaProp);
185
- }
186
- }
187
- }
188
- if (regularRules) {
189
- mediaQueries.push({
190
- media: mediaRule,
191
- css: `${mediaRule} {\n${innerIndent}${className} {\n${regularRules} }\n${nestedRules}${indent}}${indent}\n`
192
- });
193
- } else {
194
- mediaQueries.push({
195
- media: mediaRule,
196
- css: `${mediaRule} {\n${nestedRules}${indent}}\n`
197
- });
198
- }
199
- }
200
- }
201
- }
202
- classSelector[className] = cssRule;
203
- return classSelector;
204
- };
205
- for(const property in object){
206
- if (property.startsWith('@keyframes')) {
207
- const keyframesContent = object[property];
208
- styleSheet += createKeyframes(property, keyframesContent);
209
- }
210
- const classSelectors = stringConverter(classNameType(property), object[property], 1);
211
- for(const selector in classSelectors){
212
- if (!selector.startsWith('@keyframes') && classSelectors[selector]) {
213
- styleSheet += selector + ' {\n' + classSelectors[selector] + '}\n';
214
- }
215
- }
216
- }
217
- mediaQueries.forEach(({ css })=>{
218
- styleSheet += css;
219
- });
220
- return {
221
- styleSheet
222
- };
223
- }
224
-
225
- export { applyCssValue, camelToKebabCase, genBase36Hash, getServerCSS, injectClientCSS, injectClientGlobalCSS, injectServerCSS, isServer, transpiler };
1
+ export * from './types';
2
+ export * from './utils/helper';
3
+ export { genBase36Hash } from './utils/hash';
4
+ export { injectClientCSS } from './utils/inject-client-css';
5
+ export { injectClientGlobalCSS } from './utils/inject-client-global-css';
6
+ export { injectServerCSS, getServerCSS } from './utils/inject-server-css';
7
+ export { build } from './utils/build';
8
+ export { transpiler } from './utils/transpiler';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common/css-properties"), exports);
18
+ __exportStar(require("./common/css-property"), exports);
19
+ __exportStar(require("./main/create"), exports);
20
+ __exportStar(require("./main/global"), exports);
21
+ __exportStar(require("./main/vars"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './common/css-properties';
2
+ export * from './common/css-property';
3
+ export * from './main/create';
4
+ export * from './main/global';
5
+ export * from './main/vars';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ 'use server';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.build = void 0;
5
+ const helper_1 = require("./helper");
6
+ const build = async (styleSheet, filePath, global) => {
7
+ if (!helper_1.isServer)
8
+ return;
9
+ const fs = require('fs');
10
+ const { styleText } = require('util');
11
+ const message = global === '--global' ? styleText('underline', `✅Generated global CSS\n\n`) : styleText('underline', `✅Generated create CSS\n\n`);
12
+ try {
13
+ if (fs.existsSync(filePath)) {
14
+ const cssData = fs.readFileSync(filePath, 'utf-8');
15
+ if (!cssData.includes(styleSheet)) {
16
+ fs.appendFileSync(filePath, styleSheet, 'utf-8');
17
+ if (process.argv.includes('--log'))
18
+ console.log(message + styleSheet);
19
+ }
20
+ }
21
+ return;
22
+ }
23
+ catch (error) {
24
+ console.error('Error writing to file:', error);
25
+ }
26
+ };
27
+ exports.build = build;
@@ -0,0 +1,23 @@
1
+ 'use server';
2
+ import { isServer } from './helper';
3
+ export const build = async (styleSheet, filePath, global) => {
4
+ if (!isServer)
5
+ return;
6
+ const fs = require('fs');
7
+ const { styleText } = require('util');
8
+ const message = global === '--global' ? styleText('underline', `✅Generated global CSS\n\n`) : styleText('underline', `✅Generated create CSS\n\n`);
9
+ try {
10
+ if (fs.existsSync(filePath)) {
11
+ const cssData = fs.readFileSync(filePath, 'utf-8');
12
+ if (!cssData.includes(styleSheet)) {
13
+ fs.appendFileSync(filePath, styleSheet, 'utf-8');
14
+ if (process.argv.includes('--log'))
15
+ console.log(message + styleSheet);
16
+ }
17
+ }
18
+ return;
19
+ }
20
+ catch (error) {
21
+ console.error('Error writing to file:', error);
22
+ }
23
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.genBase36Hash = genBase36Hash;
4
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
5
+ function simpleHash(str) {
6
+ let hash = 0;
7
+ for (let i = 0; i < str.length; i++) {
8
+ const char = str.charCodeAt(i);
9
+ hash = (hash << 5) - hash + char;
10
+ }
11
+ return Math.abs(hash);
12
+ }
13
+ function encodeBase36(num) {
14
+ let result = '';
15
+ do {
16
+ result = chars[num % 36] + result;
17
+ num = Math.floor(num / 36);
18
+ } while (num > 0);
19
+ return result;
20
+ }
21
+ function getStartingChar(hash) {
22
+ const chars = 'abcdefghijklmnopqrstuvwxyz';
23
+ return chars[hash % chars.length];
24
+ }
25
+ function genBase36Hash(object, n) {
26
+ const serialized = JSON.stringify(object);
27
+ const hash = simpleHash(serialized);
28
+ let base36Hash = encodeBase36(hash);
29
+ const startingChar = getStartingChar(hash);
30
+ while (base36Hash.length < n - 1) {
31
+ base36Hash = chars[hash % chars.length] + base36Hash;
32
+ }
33
+ return startingChar + base36Hash.slice(0, n - 1);
34
+ }