@niibase/uniwind 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/cli/index.cjs +91 -0
  3. package/dist/cli/index.mjs +84 -0
  4. package/dist/common/bundler/artifacts/css/themes.js +3 -0
  5. package/dist/common/bundler/cli/index.js +76 -0
  6. package/dist/common/bundler/config.js +6 -0
  7. package/dist/common/bundler/css-compiler/compileNativeCSS.js +3 -3
  8. package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +3 -3
  9. package/dist/common/bundler/css-processor/color.js +1 -1
  10. package/dist/common/bundler/css-processor/css.js +2 -2
  11. package/dist/common/bundler/css-processor/processor.js +7 -7
  12. package/dist/common/bundler/css-processor/units.js +1 -1
  13. package/dist/common/bundler/css-processor/utils.js +3 -5
  14. package/dist/common/bundler/css-processor/var.js +1 -1
  15. package/dist/common/bundler/css-visitor/rule-visitor.js +2 -2
  16. package/dist/common/bundler/logger.js +3 -0
  17. package/dist/common/core/config/config.native.js +1 -5
  18. package/dist/common/core/native/native-utils.js +1 -8
  19. package/dist/common/core/native/parsers/textShadow.js +6 -18
  20. package/dist/common/core/native/parsers/transforms.js +1 -5
  21. package/dist/common/core/native/store.js +19 -65
  22. package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +4 -1
  23. package/dist/metro/index.cjs +29 -13
  24. package/dist/metro/index.mjs +22 -6
  25. package/dist/metro/transformer.cjs +61 -65
  26. package/dist/metro/transformer.mjs +23 -27
  27. package/dist/module/bundler/artifacts/css/themes.js +3 -0
  28. package/dist/module/bundler/cli/index.d.ts +2 -0
  29. package/dist/module/bundler/cli/index.js +81 -0
  30. package/dist/module/bundler/config.d.ts +1 -0
  31. package/dist/module/bundler/config.js +8 -0
  32. package/dist/module/bundler/css-compiler/compileNativeCSS.js +3 -3
  33. package/dist/module/bundler/css-compiler/compileTailwind.d.ts +1 -1
  34. package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +3 -3
  35. package/dist/module/bundler/css-processor/color.js +1 -1
  36. package/dist/module/bundler/css-processor/css.js +2 -2
  37. package/dist/module/bundler/css-processor/processor.js +7 -7
  38. package/dist/module/bundler/css-processor/units.js +1 -1
  39. package/dist/module/bundler/css-processor/utils.d.ts +0 -1
  40. package/dist/module/bundler/css-processor/utils.js +2 -4
  41. package/dist/module/bundler/css-processor/var.js +1 -1
  42. package/dist/module/bundler/css-visitor/rule-visitor.js +2 -2
  43. package/dist/module/bundler/logger.d.ts +1 -0
  44. package/dist/module/bundler/logger.js +3 -0
  45. package/dist/module/components/native/useStyle.d.ts +1 -1
  46. package/dist/module/components/react-native-gesture-handler/native/Text.d.ts +4 -1
  47. package/dist/module/core/config/config.native.js +1 -5
  48. package/dist/module/core/native/native-utils.d.ts +0 -1
  49. package/dist/module/core/native/native-utils.js +0 -6
  50. package/dist/module/core/native/parsers/textShadow.js +6 -18
  51. package/dist/module/core/native/parsers/transforms.js +1 -5
  52. package/dist/module/core/native/store.d.ts +2 -2
  53. package/dist/module/core/native/store.js +21 -63
  54. package/dist/module/core/types.d.ts +6 -4
  55. package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +4 -1
  56. package/dist/shared/{uniwind.CFiAZ3D-.cjs → uniwind.BEqYiPBB.cjs} +17 -5
  57. package/dist/shared/uniwind.CFAAUZ2t.mjs +3 -0
  58. package/dist/shared/uniwind.DJ5M1Q4q.cjs +5 -0
  59. package/dist/shared/{uniwind.u-s1XVU8.mjs → uniwind.DgC4MT51.mjs} +18 -5
  60. package/dist/vite/index.cjs +75 -42
  61. package/dist/vite/index.mjs +72 -40
  62. package/package.json +37 -21
  63. package/src/bundler/adapters/metro/metro.ts +24 -3
  64. package/src/bundler/adapters/metro/patches.ts +1 -1
  65. package/src/bundler/adapters/vite/vite.ts +104 -51
  66. package/src/bundler/artifacts/css/themes.ts +6 -1
  67. package/src/bundler/cli/index.ts +105 -0
  68. package/src/bundler/config.ts +10 -0
  69. package/src/bundler/css-compiler/compileNativeCSS.ts +3 -3
  70. package/src/bundler/css-processor/addMetaToStylesTemplate.ts +3 -3
  71. package/src/bundler/css-processor/color.ts +1 -1
  72. package/src/bundler/css-processor/css.ts +2 -2
  73. package/src/bundler/css-processor/processor.ts +7 -7
  74. package/src/bundler/css-processor/units.ts +1 -1
  75. package/src/bundler/css-processor/utils.ts +2 -5
  76. package/src/bundler/css-processor/var.ts +1 -1
  77. package/src/bundler/css-visitor/rule-visitor.ts +2 -2
  78. package/src/bundler/logger.ts +4 -0
  79. package/src/core/config/config.native.ts +1 -5
  80. package/src/core/native/native-utils.ts +0 -9
  81. package/src/core/native/parsers/textShadow.ts +6 -18
  82. package/src/core/native/parsers/transforms.ts +1 -5
  83. package/src/core/native/runtime.ts +1 -1
  84. package/src/core/native/store.ts +24 -66
  85. package/src/core/types.ts +7 -4
  86. package/src/hooks/useCSSVariable/getVariableValue.native.ts +5 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ ## What's Changed in 1.8.0
2
+
3
+
4
+
5
+ ### 🚀 Features
6
+
7
+ * vite 8 support (#560) by @Brentlok
8
+ * public generate-artifacts script (#550) by @Brentlok
9
+
10
+ ### 🐛 Bug Fixes
11
+
12
+ * bundler infinite loop when multiple uniwind instances are installed (#570) by @Brentlok
13
+ * combined variants overriding each other (#567) by @Brentlok
14
+ * phantom dependencies (#561) by @Brentlok
15
+
16
+ ### 🔨 Refactoring
17
+
18
+ * replace computed with functions in styles (#547) by @Brentlok
19
+
20
+ ### 🧪 Testing
21
+
22
+ * generate artifacts before test by @Brentlok
23
+
24
+ ### 🏠 Chores
25
+
26
+ * update dependencies (#549) by @Brentlok
27
+
28
+ ### 📦 Other
29
+
30
+ * Merge branch 'updates' by @divineniiquaye
31
+
32
+
33
+ **Full Changelog**: https://github.com/divineniiquaye/uniwind/compare/v1.7.0...v1.8.0
34
+
35
+
1
36
  ## What's Changed in 1.7.0
2
37
 
3
38
 
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const config = require('../shared/uniwind.BEqYiPBB.cjs');
5
+ const node_url = require('node:url');
6
+ const path = require('path');
7
+ require('fs');
8
+ require('@tailwindcss/node');
9
+ require('lightningcss');
10
+
11
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
13
+
14
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
15
+
16
+ const dirname = path__default.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli/index.cjs', document.baseURI).href))));
17
+ const cssArtifactPath = path__default.resolve(dirname, "../../uniwind.css");
18
+ const printHelp = () => {
19
+ console.log([
20
+ "Usage: uniwind generate-artifacts --css <file> [--theme <name>...] [--dts <file>]",
21
+ "",
22
+ "Options:",
23
+ " --css <file> CSS entry file path, e.g. ./global.css",
24
+ " --theme <name> Extra theme name. Can be passed multiple times",
25
+ " --dts <file> Generated TypeScript declarations path",
26
+ " --help Show help"
27
+ ].join("\n"));
28
+ };
29
+ const readValue = (args, index, flag) => {
30
+ const value = args[index + 1];
31
+ if (value === void 0 || value.startsWith("--")) {
32
+ throw new Error(`Uniwind: ${flag} requires a value`);
33
+ }
34
+ return value;
35
+ };
36
+ const parseGenerateArtifactsArgs = (args) => {
37
+ const parsed = {
38
+ extraThemes: []
39
+ };
40
+ for (let index = 0; index < args.length; index++) {
41
+ const arg = args[index];
42
+ switch (arg) {
43
+ case "--css":
44
+ parsed.cssEntryFile = readValue(args, index, arg);
45
+ index++;
46
+ break;
47
+ case "--theme":
48
+ parsed.extraThemes.push(readValue(args, index, arg));
49
+ index++;
50
+ break;
51
+ case "--dts":
52
+ parsed.dtsFile = readValue(args, index, arg);
53
+ index++;
54
+ break;
55
+ case "--help":
56
+ printHelp();
57
+ process.exit(0);
58
+ default:
59
+ throw new Error(`Uniwind: Unknown option ${arg}`);
60
+ }
61
+ }
62
+ return parsed;
63
+ };
64
+ const generateArtifacts = async (args) => {
65
+ const parsed = parseGenerateArtifactsArgs(args);
66
+ const bundlerConfig = config.UniwindBundlerConfig.fromCliConfig({
67
+ cssEntryFile: parsed.cssEntryFile,
68
+ dtsFile: parsed.dtsFile,
69
+ extraThemes: parsed.extraThemes
70
+ });
71
+ await bundlerConfig.generateArtifacts(cssArtifactPath);
72
+ config.Logger.info("Artifacts generated");
73
+ };
74
+ const main = async () => {
75
+ const [command, ...args] = process.argv.slice(2);
76
+ if (command === "--help" || command === void 0) {
77
+ printHelp();
78
+ return;
79
+ }
80
+ switch (command) {
81
+ case "generate-artifacts":
82
+ await generateArtifacts(args);
83
+ break;
84
+ default:
85
+ throw new Error(`Uniwind: Unknown command ${command}`);
86
+ }
87
+ };
88
+ main().catch((error) => {
89
+ console.error(error instanceof Error ? error.message : error);
90
+ process.exit(1);
91
+ });
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ import { U as UniwindBundlerConfig, L as Logger } from '../shared/uniwind.DgC4MT51.mjs';
3
+ import { fileURLToPath } from 'node:url';
4
+ import path from 'path';
5
+ import 'fs';
6
+ import '@tailwindcss/node';
7
+ import 'lightningcss';
8
+
9
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const cssArtifactPath = path.resolve(dirname, "../../uniwind.css");
11
+ const printHelp = () => {
12
+ console.log([
13
+ "Usage: uniwind generate-artifacts --css <file> [--theme <name>...] [--dts <file>]",
14
+ "",
15
+ "Options:",
16
+ " --css <file> CSS entry file path, e.g. ./global.css",
17
+ " --theme <name> Extra theme name. Can be passed multiple times",
18
+ " --dts <file> Generated TypeScript declarations path",
19
+ " --help Show help"
20
+ ].join("\n"));
21
+ };
22
+ const readValue = (args, index, flag) => {
23
+ const value = args[index + 1];
24
+ if (value === void 0 || value.startsWith("--")) {
25
+ throw new Error(`Uniwind: ${flag} requires a value`);
26
+ }
27
+ return value;
28
+ };
29
+ const parseGenerateArtifactsArgs = (args) => {
30
+ const parsed = {
31
+ extraThemes: []
32
+ };
33
+ for (let index = 0; index < args.length; index++) {
34
+ const arg = args[index];
35
+ switch (arg) {
36
+ case "--css":
37
+ parsed.cssEntryFile = readValue(args, index, arg);
38
+ index++;
39
+ break;
40
+ case "--theme":
41
+ parsed.extraThemes.push(readValue(args, index, arg));
42
+ index++;
43
+ break;
44
+ case "--dts":
45
+ parsed.dtsFile = readValue(args, index, arg);
46
+ index++;
47
+ break;
48
+ case "--help":
49
+ printHelp();
50
+ process.exit(0);
51
+ default:
52
+ throw new Error(`Uniwind: Unknown option ${arg}`);
53
+ }
54
+ }
55
+ return parsed;
56
+ };
57
+ const generateArtifacts = async (args) => {
58
+ const parsed = parseGenerateArtifactsArgs(args);
59
+ const bundlerConfig = UniwindBundlerConfig.fromCliConfig({
60
+ cssEntryFile: parsed.cssEntryFile,
61
+ dtsFile: parsed.dtsFile,
62
+ extraThemes: parsed.extraThemes
63
+ });
64
+ await bundlerConfig.generateArtifacts(cssArtifactPath);
65
+ Logger.info("Artifacts generated");
66
+ };
67
+ const main = async () => {
68
+ const [command, ...args] = process.argv.slice(2);
69
+ if (command === "--help" || command === void 0) {
70
+ printHelp();
71
+ return;
72
+ }
73
+ switch (command) {
74
+ case "generate-artifacts":
75
+ await generateArtifacts(args);
76
+ break;
77
+ default:
78
+ throw new Error(`Uniwind: Unknown command ${command}`);
79
+ }
80
+ };
81
+ main().catch((error) => {
82
+ console.error(error instanceof Error ? error.message : error);
83
+ process.exit(1);
84
+ });
@@ -53,6 +53,9 @@ const generateCSSForThemes = async (themes, input) => {
53
53
  }
54
54
  const importUrls = /* @__PURE__ */new Set();
55
55
  const importsCSS = dependencies.filter(dependency => {
56
+ if (dependency.type !== "import") {
57
+ return false;
58
+ }
56
59
  if (dependency.url.startsWith(".")) {
57
60
  importUrls.add(_path.default.resolve(_path.default.dirname(cssPath), dependency.url));
58
61
  return false;
@@ -0,0 +1,76 @@
1
+ // #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _config = require("@/bundler/config");
5
+ var _logger = require("@/bundler/logger");
6
+ var _nodeUrl = require("node:url");
7
+ var _path = _interopRequireDefault(require("path"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const dirname = _path.default.dirname((0, _nodeUrl.fileURLToPath)(require('url').pathToFileURL(__filename).toString()));
10
+ const cssArtifactPath = _path.default.resolve(dirname, "../../uniwind.css");
11
+ const printHelp = () => {
12
+ console.log(["Usage: uniwind generate-artifacts --css <file> [--theme <name>...] [--dts <file>]", "", "Options:", " --css <file> CSS entry file path, e.g. ./global.css", " --theme <name> Extra theme name. Can be passed multiple times", " --dts <file> Generated TypeScript declarations path", " --help Show help"].join("\n"));
13
+ };
14
+ const readValue = (args, index, flag) => {
15
+ const value = args[index + 1];
16
+ if (value === void 0 || value.startsWith("--")) {
17
+ throw new Error(`Uniwind: ${flag} requires a value`);
18
+ }
19
+ return value;
20
+ };
21
+ const parseGenerateArtifactsArgs = args => {
22
+ const parsed = {
23
+ extraThemes: []
24
+ };
25
+ for (let index = 0; index < args.length; index++) {
26
+ const arg = args[index];
27
+ switch (arg) {
28
+ case "--css":
29
+ parsed.cssEntryFile = readValue(args, index, arg);
30
+ index++;
31
+ break;
32
+ case "--theme":
33
+ parsed.extraThemes.push(readValue(args, index, arg));
34
+ index++;
35
+ break;
36
+ case "--dts":
37
+ parsed.dtsFile = readValue(args, index, arg);
38
+ index++;
39
+ break;
40
+ case "--help":
41
+ printHelp();
42
+ process.exit(0);
43
+ default:
44
+ throw new Error(`Uniwind: Unknown option ${arg}`);
45
+ }
46
+ }
47
+ return parsed;
48
+ };
49
+ const generateArtifacts = async args => {
50
+ const parsed = parseGenerateArtifactsArgs(args);
51
+ const bundlerConfig = _config.UniwindBundlerConfig.fromCliConfig({
52
+ cssEntryFile: parsed.cssEntryFile,
53
+ dtsFile: parsed.dtsFile,
54
+ extraThemes: parsed.extraThemes
55
+ });
56
+ await bundlerConfig.generateArtifacts(cssArtifactPath);
57
+ _logger.Logger.info("Artifacts generated");
58
+ };
59
+ const main = async () => {
60
+ const [command, ...args] = process.argv.slice(2);
61
+ if (command === "--help" || command === void 0) {
62
+ printHelp();
63
+ return;
64
+ }
65
+ switch (command) {
66
+ case "generate-artifacts":
67
+ await generateArtifacts(args);
68
+ break;
69
+ default:
70
+ throw new Error(`Uniwind: Unknown command ${command}`);
71
+ }
72
+ };
73
+ main().catch(error => {
74
+ console.error(error instanceof Error ? error.message : error);
75
+ process.exit(1);
76
+ });
@@ -43,6 +43,12 @@ class UniwindBundlerConfig {
43
43
  static fromViteConfig(config) {
44
44
  return new UniwindBundlerConfig(config, _consts.Platform.Web);
45
45
  }
46
+ static fromCliConfig(config) {
47
+ if (typeof config.cssEntryFile === "undefined") {
48
+ throw new Error("Uniwind: You need to pass css entry file, e.g. uniwind generate-artifacts --css ./global.css. Run uniwind generate-artifacts --help for usage.");
49
+ }
50
+ return new UniwindBundlerConfig(config, _consts.Platform.Web);
51
+ }
46
52
  get cssPath() {
47
53
  return _path.default.join(process.cwd(), this.config.cssEntryFile);
48
54
  }
@@ -9,11 +9,11 @@ const compileNativeCSS = (bundlerConfig, tailwindCSS) => {
9
9
  const Processor = new _cssProcessor.ProcessorBuilder(bundlerConfig);
10
10
  Processor.transform(tailwindCSS);
11
11
  const stylesheet = (0, _cssProcessor.serializeJSObject)((0, _cssProcessor.addMetaToStylesTemplate)(Processor, bundlerConfig.platform), (key, value) => `"${key}": ${value}`);
12
- const vars = (0, _cssProcessor.serializeJSObject)(Processor.vars, (key, value) => `get "${key}"() { return ${value} }`);
12
+ const vars = (0, _cssProcessor.serializeJSObject)(Processor.vars, (key, value) => `"${key}": vars => ${value}`);
13
13
  const keyframes = (0, _cssProcessor.serializeJSObject)(Processor.keyframes, (key, value) => `get "${key}"() { return ${value} }`);
14
- const scopedVars = Object.fromEntries(Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [scopedVarsName, (0, _cssProcessor.serializeJSObject)(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)]));
14
+ const scopedVars = Object.fromEntries(Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [scopedVarsName, (0, _cssProcessor.serializeJSObject)(scopedVars2, (key, value) => `"${key}": vars => ${value}`)]));
15
15
  const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
16
- const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
16
+ const currentColorVar = `currentColor: () => rt.colorScheme === 'dark' ? '#ffffff' : '#000000',`;
17
17
  return ["({", `scopedVars: ({ ${serializedScopedVars} }),`, `vars: ({ ${currentColorVar} ${vars} }),`, `stylesheet: ({ ${stylesheet} }),`, `keyframes: ({ ${keyframes} }),`, "})"].join("");
18
18
  };
19
19
  exports.compileNativeCSS = compileNativeCSS;
@@ -9,8 +9,8 @@ var _utils = require("@/common/utils");
9
9
  var _serialize = require("./serialize");
10
10
  var _utils2 = require("./utils");
11
11
  const extractVarsFromString = value => {
12
- const thisIndexes = [...value.matchAll(/this\[/g)].map(m => m.index);
13
- return thisIndexes.map(index => {
12
+ const varsIndexes = [...value.matchAll(/vars\[/g)].map(m => m.index);
13
+ return varsIndexes.map(index => {
14
14
  const afterIndex = value.slice(index + 5);
15
15
  const closingIndex = afterIndex.indexOf("]");
16
16
  const varName = afterIndex.slice(0, closingIndex);
@@ -62,7 +62,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
62
62
  dataAttributes,
63
63
  ...rest
64
64
  } = style;
65
- const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${(0, _serialize.serialize)(value)} }`]);
65
+ const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function(vars) { return ${(0, _serialize.serialize)(value)} }`]);
66
66
  if (platform) {
67
67
  const isTV = currentPlatform === _consts.Platform.AndroidTV || currentPlatform === _consts.Platform.AppleTV;
68
68
  const commonPlatform = isTV ? _consts.Platform.TV : _consts.Platform.Native;
@@ -30,7 +30,7 @@ class Color {
30
30
  }
31
31
  try {
32
32
  if (color.type === "currentcolor") {
33
- return 'this["currentColor"]';
33
+ return 'vars["currentColor"]?.(vars)';
34
34
  }
35
35
  if (color.type === "rgb" || color.type === "srgb") {
36
36
  const alpha = typeof color.alpha === "number" ? color.alpha : (0, _utils.pipe)(color.alpha)(x => this.Processor.CSS.processValue(x), Number, x => isNaN(x) ? 1 : x);
@@ -228,7 +228,7 @@ class CSS {
228
228
  return this.Processor.Color.processColor(declarationValue.value);
229
229
  }
230
230
  if (declarationValue.value === "currentcolor") {
231
- return 'this["currentColor"]';
231
+ return 'vars["currentColor"]?.(vars)';
232
232
  }
233
233
  return declarationValue.value;
234
234
  case "env":
@@ -260,7 +260,7 @@ class CSS {
260
260
  case "pair":
261
261
  return declarationValue.inside.type;
262
262
  case "currentcolor":
263
- return 'this["currentColor"]';
263
+ return 'vars["currentColor"]?.(vars)';
264
264
  case "calc":
265
265
  return this.Processor.Functions.processCalc(declarationValue.value);
266
266
  case "min":
@@ -130,7 +130,7 @@ class ProcessorBuilder {
130
130
  if (!isVar && important) {
131
131
  style.importantProperties.push(property);
132
132
  }
133
- const match = typeof value === "string" ? value.match(/this\[`(.*?)`\]/) : null;
133
+ const match = typeof value === "string" ? value.match(/vars\["(.*?)"\]/) : null;
134
134
  if (match && !isVar) {
135
135
  const className = this.declarationConfig.className;
136
136
  if (className === null) {
@@ -262,12 +262,12 @@ class ProcessorBuilder {
262
262
  }
263
263
  });
264
264
  if ([rtl, theme, active, focus, disabled, dataAttributes].some(Boolean)) {
265
- this.declarationConfig.rtl = rtl;
266
- this.declarationConfig.theme = theme;
267
- this.declarationConfig.active = active;
268
- this.declarationConfig.focus = focus;
269
- this.declarationConfig.disabled = disabled;
270
- this.declarationConfig.dataAttributes = dataAttributes;
265
+ this.declarationConfig.rtl ??= rtl;
266
+ this.declarationConfig.theme ??= theme;
267
+ this.declarationConfig.active ??= active;
268
+ this.declarationConfig.focus ??= focus;
269
+ this.declarationConfig.disabled ??= disabled;
270
+ this.declarationConfig.dataAttributes ??= dataAttributes;
271
271
  rule.value.declarations?.declarations?.forEach(declaration => this.addDeclaration(declaration));
272
272
  rule.value.declarations?.importantDeclarations?.forEach(declaration => this.addDeclaration(declaration, true));
273
273
  rule.value.rules?.forEach(rule2 => this.parseRuleRec(rule2));
@@ -25,7 +25,7 @@ class Units {
25
25
  case "rem":
26
26
  return length.value * this.Processor.vars["--uniwind-em"];
27
27
  case "em":
28
- return `this[\`--uniwind-em\`] * ${length.value}`;
28
+ return `vars["--uniwind-em"]?.(vars) * ${length.value}`;
29
29
  default:
30
30
  this.logger.warn(`Unsupported unit - ${length.unit}`);
31
31
  return length.value;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.uniq = exports.toCamelCase = exports.smartSplit = exports.shouldBeSerialized = exports.roundToPrecision = exports.removeKeys = exports.pipe = exports.isValidJSValue = exports.isNumber = exports.deepEqual = exports.addMissingSpaces = void 0;
6
+ exports.toCamelCase = exports.smartSplit = exports.shouldBeSerialized = exports.roundToPrecision = exports.removeKeys = exports.pipe = exports.isValidJSValue = exports.isNumber = exports.deepEqual = exports.addMissingSpaces = void 0;
7
7
  const toCamelCase = str => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
8
8
  exports.toCamelCase = toCamelCase;
9
9
  const pipe = data => (...fns) => fns.reduce((acc, fn) => fn(acc), data);
@@ -23,10 +23,8 @@ const smartSplit = (str, separator = " ") => {
23
23
  return pipe(str)(x => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`), x => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`), x => x.split(separator), x => x.map(token => token.replace(new RegExp(escaper, "g"), " ")));
24
24
  };
25
25
  exports.smartSplit = smartSplit;
26
- const addMissingSpaces = str => pipe(str)(x => x.trim(), x => x.replace(/([^ {])this/g, "$1 this"), x => x.replace(/\](?=\d)/g, "] "), x => x.replace(/\](?=")/g, "] "), x => x.replace(/\)(?=\S)/g, ") "), x => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" '));
26
+ const addMissingSpaces = str => pipe(str)(x => x.trim(), x => x.replace(/\](?=\d)/g, "] "), x => x.replace(/\](?=")/g, "] "), x => x.replace(/\)(?=[^\s,])/g, ") "), x => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" '));
27
27
  exports.addMissingSpaces = addMissingSpaces;
28
- const uniq = arr => Array.from(new Set(arr));
29
- exports.uniq = uniq;
30
28
  const isValidJSValue = jsValueString => {
31
29
  try {
32
30
  new Function(`const test = ${jsValueString}`);
@@ -40,7 +38,7 @@ const shouldBeSerialized = value => {
40
38
  if (value.includes("-")) {
41
39
  return value.split("-").some(shouldBeSerialized);
42
40
  }
43
- return [isNumber(value), value.startsWith("this["), value.startsWith("rt."), /[*/+-]/.test(value), value.includes('"'), value.includes(" "), value === "(", value === ")"].some(Boolean);
41
+ return [isNumber(value), value.startsWith("vars["), value.startsWith("rt."), /[*/+-]/.test(value), value.includes('"'), value.includes(" "), value === "(", value === ")"].some(Boolean);
44
42
  };
45
43
  exports.shouldBeSerialized = shouldBeSerialized;
46
44
  const roundToPrecision = (value, precision) => parseFloat(value.toFixed(precision));
@@ -9,7 +9,7 @@ class Var {
9
9
  this.Processor = Processor;
10
10
  }
11
11
  processVar(variable) {
12
- const value = `this[\`${variable.name.ident}\`]`;
12
+ const value = `vars[${JSON.stringify(variable.name.ident)}]?.(vars)`;
13
13
  if (!variable.fallback || variable.fallback.length === 0) {
14
14
  return value;
15
15
  }
@@ -87,7 +87,7 @@ class RuleVisitor {
87
87
  return;
88
88
  }
89
89
  this.processedClassNames.add(firstSelector.name);
90
- return {
90
+ return this.removeNulls({
91
91
  type: "scope",
92
92
  value: {
93
93
  loc: styleRule.value.loc,
@@ -101,7 +101,7 @@ class RuleVisitor {
101
101
  name: theme
102
102
  }])
103
103
  }
104
- };
104
+ });
105
105
  }
106
106
  // Fixes lightningcss serialization bug
107
107
  removeNulls(value) {
@@ -19,6 +19,9 @@ class Logger {
19
19
  }
20
20
  console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);
21
21
  }
22
+ static info(message) {
23
+ console.log(`${blue}[Uniwind] ${message}${reset}`);
24
+ }
22
25
  static error(message, meta = "") {
23
26
  console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
24
27
  }
@@ -31,11 +31,7 @@ class UniwindConfigBuilder extends _config.UniwindConfigBuilder {
31
31
  return varValue;
32
32
  };
33
33
  _native.UniwindStore.vars[theme] ??= {};
34
- Object.defineProperty(_native.UniwindStore.vars[theme], varName, {
35
- configurable: true,
36
- enumerable: true,
37
- get: getValue
38
- });
34
+ _native.UniwindStore.vars[theme][varName] = getValue;
39
35
  });
40
36
  _listener.UniwindListener.notify([_consts.StyleDependency.Variables]);
41
37
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.colorMix = exports.cloneWithAccessors = void 0;
6
+ exports.colorMix = void 0;
7
7
  exports.lightDark = lightDark;
8
8
  exports.parseColor = void 0;
9
9
  var _culori = require("culori");
@@ -28,13 +28,6 @@ function lightDark(light, dark) {
28
28
  }
29
29
  return light;
30
30
  }
31
- const cloneWithAccessors = obj => {
32
- const proto = Object.getPrototypeOf(obj);
33
- const clone = Object.create(proto);
34
- Object.defineProperties(clone, Object.getOwnPropertyDescriptors(obj));
35
- return clone;
36
- };
37
- exports.cloneWithAccessors = cloneWithAccessors;
38
31
  const parseColor = (type, color) => {
39
32
  try {
40
33
  const parsedColor = (0, _culori.parse)(`${type}(${color})`);
@@ -13,27 +13,15 @@ const parseTextShadowMutation = styles => {
13
13
  const offsets = tokens.filter(token => token !== color);
14
14
  const [offsetX, offsetY, radius] = offsets;
15
15
  if (offsetX !== void 0 && offsetY !== void 0) {
16
- Object.defineProperty(styles, "textShadowOffset", {
17
- configurable: true,
18
- enumerable: true,
19
- value: {
20
- width: Number(offsetX),
21
- height: Number(offsetY)
22
- }
23
- });
16
+ styles.textShadowOffset = {
17
+ width: Number(offsetX),
18
+ height: Number(offsetY)
19
+ };
24
20
  delete styles.textShadow;
25
21
  }
26
22
  if (radius !== void 0) {
27
- Object.defineProperty(styles, "textShadowRadius", {
28
- configurable: true,
29
- enumerable: true,
30
- value: Number(radius)
31
- });
23
+ styles.textShadowRadius = Number(radius);
32
24
  }
33
- Object.defineProperty(styles, "textShadowColor", {
34
- configurable: true,
35
- enumerable: true,
36
- value: color
37
- });
25
+ styles.textShadowColor = color;
38
26
  };
39
27
  exports.parseTextShadowMutation = parseTextShadowMutation;
@@ -37,11 +37,7 @@ const parseTransformsMutation = (styles, preserve = false) => {
37
37
  }
38
38
  }
39
39
  if (transformsResult.length > 0) {
40
- Object.defineProperty(styles, "transform", {
41
- configurable: true,
42
- enumerable: true,
43
- value: transformsResult
44
- });
40
+ styles.transform = transformsResult;
45
41
  }
46
42
  };
47
43
  exports.parseTransformsMutation = parseTransformsMutation;