@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
@@ -129,6 +129,7 @@ const overwriteDisabled = `@custom-variant disabled {
129
129
  const OVERWRITE_CSS = overwriteDisabled;
130
130
 
131
131
  const red = "\x1B[91m";
132
+ const blue = "\x1B[36m";
132
133
  const reset = "\x1B[0m";
133
134
  class Logger {
134
135
  constructor(name) {
@@ -140,6 +141,9 @@ class Logger {
140
141
  return;
141
142
  }
142
143
  }
144
+ static info(message) {
145
+ console.log(`${blue}[Uniwind] ${message}${reset}`);
146
+ }
143
147
  static error(message, meta = "") {
144
148
  console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
145
149
  }
@@ -205,6 +209,9 @@ const generateCSSForThemes = async (themes, input) => {
205
209
  }
206
210
  const importUrls = /* @__PURE__ */ new Set();
207
211
  const importsCSS = dependencies.filter((dependency) => {
212
+ if (dependency.type !== "import") {
213
+ return false;
214
+ }
208
215
  if (dependency.url.startsWith(".")) {
209
216
  importUrls.add(path.resolve(path.dirname(cssPath), dependency.url));
210
217
  return false;
@@ -448,7 +455,7 @@ class RuleVisitor {
448
455
  return;
449
456
  }
450
457
  this.processedClassNames.add(firstSelector.name);
451
- return {
458
+ return this.removeNulls({
452
459
  type: "scope",
453
460
  value: {
454
461
  loc: styleRule.value.loc,
@@ -456,7 +463,7 @@ class RuleVisitor {
456
463
  scopeStart: [[{ type: "class", name: selectedVariant }]],
457
464
  scopeEnd: this.bundlerConfig.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
458
465
  }
459
- };
466
+ });
460
467
  }
461
468
  // Fixes lightningcss serialization bug
462
469
  removeNulls(value) {
@@ -554,6 +561,14 @@ class UniwindBundlerConfig {
554
561
  static fromViteConfig(config) {
555
562
  return new UniwindBundlerConfig(config, Platform.Web);
556
563
  }
564
+ static fromCliConfig(config) {
565
+ if (typeof config.cssEntryFile === "undefined") {
566
+ throw new Error(
567
+ "Uniwind: You need to pass css entry file, e.g. uniwind generate-artifacts --css ./global.css. Run uniwind generate-artifacts --help for usage."
568
+ );
569
+ }
570
+ return new UniwindBundlerConfig(config, Platform.Web);
571
+ }
557
572
  get cssPath() {
558
573
  return path.join(process.cwd(), this.config.cssEntryFile);
559
574
  }
@@ -584,6 +599,4 @@ class UniwindBundlerConfig {
584
599
  }
585
600
  }
586
601
 
587
- const name = "@niibase/uniwind";
588
-
589
- export { DEFAULT_SCREEN_HEIGHT as D, Logger as L, Platform as P, StyleDependency as S, UniwindBundlerConfig as U, DEFAULT_SCREEN_WIDTH as a, UNIWIND_PLATFORM_VARIABLES as b, UNIWIND_THEME_VARIABLES as c, isDefined as i, name as n };
602
+ export { DEFAULT_SCREEN_HEIGHT as D, Logger as L, Platform as P, StyleDependency as S, UniwindBundlerConfig as U, DEFAULT_SCREEN_WIDTH as a, UNIWIND_PLATFORM_VARIABLES as b, UNIWIND_THEME_VARIABLES as c, isDefined as i };
@@ -1,11 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const node = require('@tailwindcss/node');
4
+ const node_module = require('node:module');
4
5
  const path = require('path');
5
- const _package = require('../shared/uniwind.CFiAZ3D-.cjs');
6
+ const _package = require('../shared/uniwind.DJ5M1Q4q.cjs');
7
+ const config = require('../shared/uniwind.BEqYiPBB.cjs');
6
8
  require('fs');
7
9
  require('lightningcss');
8
10
 
11
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
9
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
13
 
11
14
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
@@ -20,17 +23,79 @@ const styleSheetPath = path__default.resolve(
20
23
  "../module/components/web/createOrderedCSSStyleSheet.js"
21
24
  );
22
25
  const cssArtifactPath = path__default.resolve(dirname, "../../uniwind.css");
23
- const uniwind = (config) => {
24
- const bundlerConfig = _package.UniwindBundlerConfig.fromViteConfig(config);
26
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/index.cjs', document.baseURI).href)));
27
+ const viteVersion = require$1("vite/package.json").version;
28
+ const isVite8 = Number(viteVersion.split(".")[0]) >= 8;
29
+ const resolveOrderedCSSStyleSheet = (source, importer) => {
30
+ const normalizedSource = node.normalizePath(source);
31
+ const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
32
+ if (isTarget && importer !== void 0 && node.normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
33
+ return styleSheetPath;
34
+ }
35
+ };
36
+ const vite8OptimizeDeps = {
37
+ exclude: [_package.name, "react-native"],
38
+ rolldownOptions: {
39
+ plugins: [{
40
+ name: "uniwind-rolldown-plugin",
41
+ resolveId: resolveOrderedCSSStyleSheet
42
+ }]
43
+ }
44
+ };
45
+ const vite7OptimizeDeps = {
46
+ exclude: [_package.name, "react-native"],
47
+ esbuildOptions: {
48
+ plugins: [{
49
+ name: "uniwind-esbuild-plugin",
50
+ setup: (build) => {
51
+ build.onResolve(
52
+ { filter: /^\.\/createOrderedCSSStyleSheet$/ },
53
+ (args) => {
54
+ const resolved = resolveOrderedCSSStyleSheet(args.path, args.importer);
55
+ if (resolved !== void 0) {
56
+ return { path: resolved };
57
+ }
58
+ }
59
+ );
60
+ }
61
+ }]
62
+ }
63
+ };
64
+ const vite8Resolve = {
65
+ alias: [{
66
+ find: /^react-native$/,
67
+ replacement: componentPath,
68
+ customResolver: {
69
+ resolveId(_, importer) {
70
+ if (importer !== void 0 && node.normalizePath(importer).includes(`${_package.name}/dist`)) {
71
+ return this.resolve("react-native-web", importer, { skipSelf: true });
72
+ }
73
+ return componentPath;
74
+ }
75
+ }
76
+ }]
77
+ };
78
+ const vite7Resolve = {
79
+ alias: [{
80
+ find: /^react-native$/,
81
+ replacement: componentPath,
82
+ customResolver: {
83
+ resolveId(_, importer) {
84
+ if (importer !== void 0 && node.normalizePath(importer).includes(`${_package.name}/dist`)) {
85
+ return this.resolve("react-native-web");
86
+ }
87
+ return componentPath;
88
+ }
89
+ }
90
+ }]
91
+ };
92
+ const uniwind = (config$1) => {
93
+ const bundlerConfig = config.UniwindBundlerConfig.fromViteConfig(config$1);
25
94
  return {
26
95
  name: "uniwind",
27
96
  enforce: "pre",
28
97
  resolveId: (source, importer) => {
29
- const normalizedSource = node.normalizePath(source);
30
- const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
31
- if (isTarget && importer !== void 0 && node.normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
32
- return styleSheetPath;
33
- }
98
+ return resolveOrderedCSSStyleSheet(source, importer);
34
99
  },
35
100
  config: () => ({
36
101
  css: {
@@ -39,40 +104,8 @@ const uniwind = (config) => {
39
104
  visitor: bundlerConfig.cssVisitor
40
105
  }
41
106
  },
42
- optimizeDeps: {
43
- exclude: [_package.name, "react-native"],
44
- esbuildOptions: {
45
- plugins: [{
46
- name: "uniwind-esbuild-plugin",
47
- setup: (build) => {
48
- build.onResolve(
49
- { filter: /^\.\/createOrderedCSSStyleSheet$/ },
50
- (args) => {
51
- if (node.normalizePath(args.importer).includes("react-native-web/dist/exports/StyleSheet")) {
52
- return { path: styleSheetPath };
53
- }
54
- }
55
- );
56
- }
57
- }]
58
- }
59
- },
60
- resolve: {
61
- alias: [
62
- {
63
- find: /^react-native$/,
64
- replacement: componentPath,
65
- customResolver: {
66
- resolveId(_, importer) {
67
- if (importer !== void 0 && node.normalizePath(importer).includes(`${_package.name}/dist`)) {
68
- return this.resolve("react-native-web");
69
- }
70
- return componentPath;
71
- }
72
- }
73
- }
74
- ]
75
- }
107
+ optimizeDeps: isVite8 ? vite8OptimizeDeps : vite7OptimizeDeps,
108
+ resolve: isVite8 ? vite8Resolve : vite7Resolve
76
109
  }),
77
110
  transform: (code, id) => {
78
111
  const normalizedId = node.normalizePath(id);
@@ -1,6 +1,8 @@
1
1
  import { normalizePath } from '@tailwindcss/node';
2
+ import { createRequire } from 'node:module';
2
3
  import path from 'path';
3
- import { n as name, U as UniwindBundlerConfig } from '../shared/uniwind.u-s1XVU8.mjs';
4
+ import { n as name } from '../shared/uniwind.CFAAUZ2t.mjs';
5
+ import { U as UniwindBundlerConfig } from '../shared/uniwind.DgC4MT51.mjs';
4
6
  import 'fs';
5
7
  import 'lightningcss';
6
8
 
@@ -14,17 +16,79 @@ const styleSheetPath = path.resolve(
14
16
  "../module/components/web/createOrderedCSSStyleSheet.js"
15
17
  );
16
18
  const cssArtifactPath = path.resolve(dirname, "../../uniwind.css");
19
+ const require = createRequire(import.meta.url);
20
+ const viteVersion = require("vite/package.json").version;
21
+ const isVite8 = Number(viteVersion.split(".")[0]) >= 8;
22
+ const resolveOrderedCSSStyleSheet = (source, importer) => {
23
+ const normalizedSource = normalizePath(source);
24
+ const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
25
+ if (isTarget && importer !== void 0 && normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
26
+ return styleSheetPath;
27
+ }
28
+ };
29
+ const vite8OptimizeDeps = {
30
+ exclude: [name, "react-native"],
31
+ rolldownOptions: {
32
+ plugins: [{
33
+ name: "uniwind-rolldown-plugin",
34
+ resolveId: resolveOrderedCSSStyleSheet
35
+ }]
36
+ }
37
+ };
38
+ const vite7OptimizeDeps = {
39
+ exclude: [name, "react-native"],
40
+ esbuildOptions: {
41
+ plugins: [{
42
+ name: "uniwind-esbuild-plugin",
43
+ setup: (build) => {
44
+ build.onResolve(
45
+ { filter: /^\.\/createOrderedCSSStyleSheet$/ },
46
+ (args) => {
47
+ const resolved = resolveOrderedCSSStyleSheet(args.path, args.importer);
48
+ if (resolved !== void 0) {
49
+ return { path: resolved };
50
+ }
51
+ }
52
+ );
53
+ }
54
+ }]
55
+ }
56
+ };
57
+ const vite8Resolve = {
58
+ alias: [{
59
+ find: /^react-native$/,
60
+ replacement: componentPath,
61
+ customResolver: {
62
+ resolveId(_, importer) {
63
+ if (importer !== void 0 && normalizePath(importer).includes(`${name}/dist`)) {
64
+ return this.resolve("react-native-web", importer, { skipSelf: true });
65
+ }
66
+ return componentPath;
67
+ }
68
+ }
69
+ }]
70
+ };
71
+ const vite7Resolve = {
72
+ alias: [{
73
+ find: /^react-native$/,
74
+ replacement: componentPath,
75
+ customResolver: {
76
+ resolveId(_, importer) {
77
+ if (importer !== void 0 && normalizePath(importer).includes(`${name}/dist`)) {
78
+ return this.resolve("react-native-web");
79
+ }
80
+ return componentPath;
81
+ }
82
+ }
83
+ }]
84
+ };
17
85
  const uniwind = (config) => {
18
86
  const bundlerConfig = UniwindBundlerConfig.fromViteConfig(config);
19
87
  return {
20
88
  name: "uniwind",
21
89
  enforce: "pre",
22
90
  resolveId: (source, importer) => {
23
- const normalizedSource = normalizePath(source);
24
- const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
25
- if (isTarget && importer !== void 0 && normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
26
- return styleSheetPath;
27
- }
91
+ return resolveOrderedCSSStyleSheet(source, importer);
28
92
  },
29
93
  config: () => ({
30
94
  css: {
@@ -33,40 +97,8 @@ const uniwind = (config) => {
33
97
  visitor: bundlerConfig.cssVisitor
34
98
  }
35
99
  },
36
- optimizeDeps: {
37
- exclude: [name, "react-native"],
38
- esbuildOptions: {
39
- plugins: [{
40
- name: "uniwind-esbuild-plugin",
41
- setup: (build) => {
42
- build.onResolve(
43
- { filter: /^\.\/createOrderedCSSStyleSheet$/ },
44
- (args) => {
45
- if (normalizePath(args.importer).includes("react-native-web/dist/exports/StyleSheet")) {
46
- return { path: styleSheetPath };
47
- }
48
- }
49
- );
50
- }
51
- }]
52
- }
53
- },
54
- resolve: {
55
- alias: [
56
- {
57
- find: /^react-native$/,
58
- replacement: componentPath,
59
- customResolver: {
60
- resolveId(_, importer) {
61
- if (importer !== void 0 && normalizePath(importer).includes(`${name}/dist`)) {
62
- return this.resolve("react-native-web");
63
- }
64
- return componentPath;
65
- }
66
- }
67
- }
68
- ]
69
- }
100
+ optimizeDeps: isVite8 ? vite8OptimizeDeps : vite7OptimizeDeps,
101
+ resolve: isVite8 ? vite8Resolve : vite7Resolve
70
102
  }),
71
103
  transform: (code, id) => {
72
104
  const normalizedId = normalizePath(id);
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@niibase/uniwind",
4
- "version": "1.7.0",
4
+ "version": "1.8.0",
5
5
  "description": "A fork of Uniwind with Reanimated 4 support",
6
6
  "homepage": "https://uniwind.dev",
7
7
  "author": "Unistack",
8
8
  "type": "module",
9
+ "bin": {
10
+ "uniwind": "./dist/cli/index.mjs"
11
+ },
9
12
  "repository": "https://github.com/divineniiquaye/uniwind-oss",
10
13
  "sideEffects": false,
11
14
  "scripts": {
@@ -22,7 +25,7 @@
22
25
  "test:native": "jest --config jest.config.native.js",
23
26
  "test:web": "jest --config jest.config.web.js",
24
27
  "test:types": "tsc --project tests/type-test/tsconfig.json",
25
- "test:e2e": "playwright test",
28
+ "test:e2e": "bun --bun playwright test",
26
29
  "release": "release-it"
27
30
  },
28
31
  "keywords": [
@@ -83,8 +86,8 @@
83
86
  "LICENSE"
84
87
  ],
85
88
  "dependencies": {
86
- "@tailwindcss/node": "4.2.1",
87
- "@tailwindcss/oxide": "4.2.1",
89
+ "@tailwindcss/node": "4.3.0",
90
+ "@tailwindcss/oxide": "4.3.0",
88
91
  "culori": "4.0.2",
89
92
  "lightningcss": "1.30.1"
90
93
  },
@@ -94,35 +97,48 @@
94
97
  "react-native-gesture-handler": ">=2.28.0",
95
98
  "react-native-reanimated": ">=4",
96
99
  "react-native-safe-area-context": ">=5.6.0",
97
- "tailwindcss": ">=4"
100
+ "tailwindcss": ">=4",
101
+ "metro": "*",
102
+ "metro-cache": "*",
103
+ "@expo/metro-config": "*",
104
+ "metro-transform-worker": "*"
105
+ },
106
+ "peerDependenciesMeta": {
107
+ "@expo/metro-config": {
108
+ "optional": true
109
+ },
110
+ "metro-transform-worker": {
111
+ "optional": true
112
+ }
98
113
  },
99
114
  "devDependencies": {
100
- "@playwright/test": "1.58.2",
101
- "@react-native/babel-preset": "0.84.1",
115
+ "@playwright/test": "1.60.0",
116
+ "@react-native/babel-preset": "0.85.3",
117
+ "@react-native/jest-preset": "0.85.3",
118
+ "@swc/core": "1.15.33",
119
+ "@swc/jest": "0.2.39",
102
120
  "@testing-library/jest-dom": "6.9.1",
103
121
  "@testing-library/jest-native": "5.4.3",
104
122
  "@testing-library/react": "16.3.2",
105
123
  "@testing-library/react-native": "13.3.3",
106
124
  "@types/bun": "catalog:",
107
125
  "@types/culori": "4.0.1",
108
- "@types/jest": "30.0.0",
126
+ "@types/jest": "29.5.14",
109
127
  "@types/react": "catalog:",
110
- "dpdm": "4.0.1",
111
- "git-cliff": "2.12.0",
112
- "jest": "30.2.0",
113
- "jest-environment-jsdom": "30.2.0",
114
- "metro": "0.84.2",
115
- "prettier": "3.8.1",
116
- "react-native-gesture-handler": "2.28.0",
128
+ "dpdm": "4.2.0",
129
+ "git-cliff": "2.13.1",
130
+ "jest": "29.7.0",
131
+ "jest-environment-jsdom": "29.7.0",
132
+ "metro": "0.84.4",
133
+ "prettier": "3.8.3",
134
+ "react-native-gesture-handler": "2.31.2",
117
135
  "react-native-reanimated": "catalog:",
118
- "react-native-safe-area-context": "5.6.0",
136
+ "react-native-safe-area-context": "5.7.0",
119
137
  "react-native-web": "catalog:",
120
- "react-test-renderer": "19.2.4",
121
- "release-it": "19.2.4",
122
- "ts-jest": "29.4.6",
138
+ "react-test-renderer": "19.2.3",
139
+ "release-it": "20.0.1",
123
140
  "typescript": "catalog:",
124
141
  "unbuild": "3.6.1",
125
- "vite": "catalog:",
126
- "esbuild": "0.27.3"
142
+ "vite": "catalog:"
127
143
  }
128
144
  }
@@ -2,14 +2,21 @@ import { UniwindBundlerConfig } from '@/bundler/config'
2
2
  import type { UniwindConfig } from '@/bundler/types'
3
3
  import { Platform } from '@/common/consts'
4
4
  import type { MetroConfig } from 'metro-config'
5
+ import type { CustomResolver } from 'metro-resolver'
6
+ import { join } from 'node:path'
7
+ import { name as UNIWIND_PACKAGE_NAME } from '../../../../package.json'
5
8
  import { cacheStore, patchMetroGraphToSupportUncachedModules } from './patches'
6
9
  import { nativeResolver, webResolver } from './resolvers'
7
10
 
11
+ const isUniwindRequest = (moduleName: string) => moduleName === UNIWIND_PACKAGE_NAME || moduleName.startsWith(`${UNIWIND_PACKAGE_NAME}/`)
12
+
8
13
  export const withUniwindConfig = <T extends MetroConfig>(
9
14
  config: T,
10
15
  uniwindConfig: UniwindConfig,
11
16
  ): T => {
12
17
  const bundlerConfig = UniwindBundlerConfig.fromMetroConfig(uniwindConfig)
18
+ const pinnedUniwindOrigin = join(config.projectRoot ?? process.cwd(), 'package.json')
19
+
13
20
  patchMetroGraphToSupportUncachedModules()
14
21
 
15
22
  return {
@@ -30,9 +37,23 @@ export const withUniwindConfig = <T extends MetroConfig>(
30
37
  ext => ext !== 'css',
31
38
  ),
32
39
  resolveRequest: (context, moduleName, platform) => {
33
- const resolver = config.resolver?.resolveRequest ?? context.resolveRequest
34
- const platformResolver = (platform === Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {})
35
- const resolved = platformResolver({
40
+ const baseResolver = config.resolver?.resolveRequest ?? context.resolveRequest
41
+ const resolver: CustomResolver = (nextContext, nextModuleName, nextPlatform) => {
42
+ if (isUniwindRequest(nextModuleName)) {
43
+ return baseResolver(
44
+ {
45
+ ...nextContext,
46
+ originModulePath: pinnedUniwindOrigin,
47
+ },
48
+ nextModuleName,
49
+ nextPlatform,
50
+ )
51
+ }
52
+
53
+ return baseResolver(nextContext, nextModuleName, nextPlatform)
54
+ }
55
+ const platformResolver = platform === Platform.Web ? webResolver : nativeResolver
56
+ const resolved = platformResolver(uniwindConfig.extraComponents ?? {})({
36
57
  context,
37
58
  moduleName,
38
59
  platform,
@@ -39,7 +39,7 @@ export const patchMetroGraphToSupportUncachedModules = () => {
39
39
  function traverseDependencies(this: Graph, paths: Array<string>, options: GraphOptions<any>) {
40
40
  this.dependencies.forEach(dependency => {
41
41
  if (
42
- dependency.output.find(file => file.data.css?.skipCache === true)
42
+ dependency.output.find(file => (file.data as any)?.css?.skipCache === true)
43
43
  && !paths.includes(dependency.path)
44
44
  ) {
45
45
  // @ts-expect-error Hidden property