@cdx-ui/components 0.0.1-beta.75 → 0.0.1-beta.76

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.
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.withForgeMetroConfig = withForgeMetroConfig;
7
+ var _nodePath = _interopRequireDefault(require("node:path"));
7
8
  var _metro = require("uniwind/metro");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
10
  /**
9
11
  * Wraps a Metro config with Forge UI's styling-layer configuration.
10
12
  *
@@ -16,9 +18,56 @@ var _metro = require("uniwind/metro");
16
18
  * like `withStorybook`).
17
19
  */
18
20
  function withForgeMetroConfig(config, options) {
19
- return (0, _metro.withUniwindConfig)(config, {
21
+ const withUniwind = (0, _metro.withUniwindConfig)(config, {
20
22
  cssEntryFile: options.cssEntryFile,
21
23
  dtsFile: options.generatedTypesFile
22
24
  });
25
+ return withUniwindMultiCopyFix(withUniwind);
26
+ }
27
+
28
+ /**
29
+ * Fixes Uniwind 1.9's nativeResolver in pnpm monorepos with multiple Uniwind copies.
30
+ *
31
+ * Uniwind decides whether to wrap a `react-native` import by comparing
32
+ * `originModulePath` against a cached internal base path resolved via
33
+ * `require.resolve('uniwind/package.json')`. In pnpm, the Metro config loaded
34
+ * by Node and the Uniwind copy bundled for the app may resolve to different
35
+ * physical paths (different peer-dep hashes in the virtual store), so the
36
+ * `isInternal` check returns false for Uniwind-internal code. The
37
+ * nativeResolver then re-routes `react-native` to `uniwind/components`, which
38
+ * re-exports from `react-native` — a circular `get NativeModules` getter that
39
+ * overflows the stack at runtime.
40
+ *
41
+ * Fix: intercept `react-native` requests originating from inside any Uniwind
42
+ * copy and resolve them from the app's `projectRoot`, bypassing the broken
43
+ * `isInternal` check entirely.
44
+ */
45
+ function withUniwindMultiCopyFix(config) {
46
+ const resolver = config.resolver;
47
+ if (!resolver) return config;
48
+ const innerResolveRequest = resolver.resolveRequest;
49
+ const uniwindPathFragment = `${_nodePath.default.sep}node_modules${_nodePath.default.sep}uniwind${_nodePath.default.sep}`;
50
+ const projectRoot = config.projectRoot;
51
+ const appOriginModulePath = projectRoot ? _nodePath.default.join(projectRoot, 'package.json') : undefined;
52
+ return {
53
+ ...config,
54
+ resolver: {
55
+ ...resolver,
56
+ resolveRequest: (context, moduleName, platform) => {
57
+ const fromUniwind = context.originModulePath?.includes(uniwindPathFragment) ?? false;
58
+ if (fromUniwind && (moduleName === 'react-native' || moduleName.startsWith('react-native/'))) {
59
+ const rewrittenContext = appOriginModulePath ? {
60
+ ...context,
61
+ originModulePath: appOriginModulePath
62
+ } : context;
63
+ return context.resolveRequest(rewrittenContext, moduleName, platform);
64
+ }
65
+ if (innerResolveRequest) {
66
+ return innerResolveRequest(context, moduleName, platform);
67
+ }
68
+ return context.resolveRequest(context, moduleName, platform);
69
+ }
70
+ }
71
+ };
23
72
  }
24
73
  //# sourceMappingURL=withForgeMetroConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_metro","require","withForgeMetroConfig","config","options","withUniwindConfig","cssEntryFile","dtsFile","generatedTypesFile"],"sourceRoot":"../../../src","sources":["metro/withForgeMetroConfig.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CAClCC,MAAS,EACTC,OAAgC,EAC7B;EACH,OAAO,IAAAC,wBAAiB,EAACF,MAAM,EAAE;IAC/BG,YAAY,EAAEF,OAAO,CAACE,YAAY;IAClCC,OAAO,EAAEH,OAAO,CAACI;EACnB,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_nodePath","_interopRequireDefault","require","_metro","e","__esModule","default","withForgeMetroConfig","config","options","withUniwind","withUniwindConfig","cssEntryFile","dtsFile","generatedTypesFile","withUniwindMultiCopyFix","resolver","innerResolveRequest","resolveRequest","uniwindPathFragment","path","sep","projectRoot","appOriginModulePath","join","undefined","context","moduleName","platform","fromUniwind","originModulePath","includes","startsWith","rewrittenContext"],"sourceRoot":"../../../src","sources":["metro/withForgeMetroConfig.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAkD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,oBAAoBA,CAClCC,MAAS,EACTC,OAAgC,EAC7B;EACH,MAAMC,WAAW,GAAG,IAAAC,wBAAiB,EAACH,MAAM,EAAE;IAC5CI,YAAY,EAAEH,OAAO,CAACG,YAAY;IAClCC,OAAO,EAAEJ,OAAO,CAACK;EACnB,CAAC,CAAM;EAEP,OAAOC,uBAAuB,CAACL,WAAW,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,uBAAuBA,CAAwBP,MAAS,EAAK;EACpE,MAAMQ,QAAQ,GAAGR,MAAM,CAACQ,QAAQ;EAChC,IAAI,CAACA,QAAQ,EAAE,OAAOR,MAAM;EAE5B,MAAMS,mBAAmB,GAAGD,QAAQ,CAACE,cAAc;EACnD,MAAMC,mBAAmB,GAAG,GAAGC,iBAAI,CAACC,GAAG,eAAeD,iBAAI,CAACC,GAAG,UAAUD,iBAAI,CAACC,GAAG,EAAE;EAClF,MAAMC,WAAW,GAAGd,MAAM,CAACc,WAAW;EACtC,MAAMC,mBAAmB,GAAGD,WAAW,GAAGF,iBAAI,CAACI,IAAI,CAACF,WAAW,EAAE,cAAc,CAAC,GAAGG,SAAS;EAE5F,OAAO;IACL,GAAGjB,MAAM;IACTQ,QAAQ,EAAE;MACR,GAAGA,QAAQ;MACXE,cAAc,EAAEA,CAACQ,OAAO,EAAEC,UAAU,EAAEC,QAAQ,KAAK;QACjD,MAAMC,WAAW,GAAGH,OAAO,CAACI,gBAAgB,EAAEC,QAAQ,CAACZ,mBAAmB,CAAC,IAAI,KAAK;QACpF,IACEU,WAAW,KACVF,UAAU,KAAK,cAAc,IAAIA,UAAU,CAACK,UAAU,CAAC,eAAe,CAAC,CAAC,EACzE;UACA,MAAMC,gBAAgB,GAAGV,mBAAmB,GACxC;YAAE,GAAGG,OAAO;YAAEI,gBAAgB,EAAEP;UAAoB,CAAC,GACrDG,OAAO;UACX,OAAOA,OAAO,CAACR,cAAc,CAACe,gBAAgB,EAAEN,UAAU,EAAEC,QAAQ,CAAC;QACvE;QACA,IAAIX,mBAAmB,EAAE;UACvB,OAAOA,mBAAmB,CAACS,OAAO,EAAEC,UAAU,EAAEC,QAAQ,CAAC;QAC3D;QACA,OAAOF,OAAO,CAACR,cAAc,CAACQ,OAAO,EAAEC,UAAU,EAAEC,QAAQ,CAAC;MAC9D;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,6 +1 @@
1
1
  @source './**/*.{ts,tsx}';
2
-
3
- /* TODO: Can we keep this? Check with Michael/Jack */
4
- *:focus {
5
- outline: none;
6
- }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ import path from 'node:path';
3
4
  import { withUniwindConfig } from 'uniwind/metro';
4
5
  /**
5
6
  * Wraps a Metro config with Forge UI's styling-layer configuration.
@@ -12,9 +13,56 @@ import { withUniwindConfig } from 'uniwind/metro';
12
13
  * like `withStorybook`).
13
14
  */
14
15
  export function withForgeMetroConfig(config, options) {
15
- return withUniwindConfig(config, {
16
+ const withUniwind = withUniwindConfig(config, {
16
17
  cssEntryFile: options.cssEntryFile,
17
18
  dtsFile: options.generatedTypesFile
18
19
  });
20
+ return withUniwindMultiCopyFix(withUniwind);
21
+ }
22
+
23
+ /**
24
+ * Fixes Uniwind 1.9's nativeResolver in pnpm monorepos with multiple Uniwind copies.
25
+ *
26
+ * Uniwind decides whether to wrap a `react-native` import by comparing
27
+ * `originModulePath` against a cached internal base path resolved via
28
+ * `require.resolve('uniwind/package.json')`. In pnpm, the Metro config loaded
29
+ * by Node and the Uniwind copy bundled for the app may resolve to different
30
+ * physical paths (different peer-dep hashes in the virtual store), so the
31
+ * `isInternal` check returns false for Uniwind-internal code. The
32
+ * nativeResolver then re-routes `react-native` to `uniwind/components`, which
33
+ * re-exports from `react-native` — a circular `get NativeModules` getter that
34
+ * overflows the stack at runtime.
35
+ *
36
+ * Fix: intercept `react-native` requests originating from inside any Uniwind
37
+ * copy and resolve them from the app's `projectRoot`, bypassing the broken
38
+ * `isInternal` check entirely.
39
+ */
40
+ function withUniwindMultiCopyFix(config) {
41
+ const resolver = config.resolver;
42
+ if (!resolver) return config;
43
+ const innerResolveRequest = resolver.resolveRequest;
44
+ const uniwindPathFragment = `${path.sep}node_modules${path.sep}uniwind${path.sep}`;
45
+ const projectRoot = config.projectRoot;
46
+ const appOriginModulePath = projectRoot ? path.join(projectRoot, 'package.json') : undefined;
47
+ return {
48
+ ...config,
49
+ resolver: {
50
+ ...resolver,
51
+ resolveRequest: (context, moduleName, platform) => {
52
+ const fromUniwind = context.originModulePath?.includes(uniwindPathFragment) ?? false;
53
+ if (fromUniwind && (moduleName === 'react-native' || moduleName.startsWith('react-native/'))) {
54
+ const rewrittenContext = appOriginModulePath ? {
55
+ ...context,
56
+ originModulePath: appOriginModulePath
57
+ } : context;
58
+ return context.resolveRequest(rewrittenContext, moduleName, platform);
59
+ }
60
+ if (innerResolveRequest) {
61
+ return innerResolveRequest(context, moduleName, platform);
62
+ }
63
+ return context.resolveRequest(context, moduleName, platform);
64
+ }
65
+ }
66
+ };
19
67
  }
20
68
  //# sourceMappingURL=withForgeMetroConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withUniwindConfig","withForgeMetroConfig","config","options","cssEntryFile","dtsFile","generatedTypesFile"],"sourceRoot":"../../../src","sources":["metro/withForgeMetroConfig.ts"],"mappings":";;AACA,SAASA,iBAAiB,QAAQ,eAAe;AASjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,MAAS,EACTC,OAAgC,EAC7B;EACH,OAAOH,iBAAiB,CAACE,MAAM,EAAE;IAC/BE,YAAY,EAAED,OAAO,CAACC,YAAY;IAClCC,OAAO,EAAEF,OAAO,CAACG;EACnB,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["path","withUniwindConfig","withForgeMetroConfig","config","options","withUniwind","cssEntryFile","dtsFile","generatedTypesFile","withUniwindMultiCopyFix","resolver","innerResolveRequest","resolveRequest","uniwindPathFragment","sep","projectRoot","appOriginModulePath","join","undefined","context","moduleName","platform","fromUniwind","originModulePath","includes","startsWith","rewrittenContext"],"sourceRoot":"../../../src","sources":["metro/withForgeMetroConfig.ts"],"mappings":";;AAAA,OAAOA,IAAI,MAAM,WAAW;AAE5B,SAASC,iBAAiB,QAAQ,eAAe;AASjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,MAAS,EACTC,OAAgC,EAC7B;EACH,MAAMC,WAAW,GAAGJ,iBAAiB,CAACE,MAAM,EAAE;IAC5CG,YAAY,EAAEF,OAAO,CAACE,YAAY;IAClCC,OAAO,EAAEH,OAAO,CAACI;EACnB,CAAC,CAAM;EAEP,OAAOC,uBAAuB,CAACJ,WAAW,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,uBAAuBA,CAAwBN,MAAS,EAAK;EACpE,MAAMO,QAAQ,GAAGP,MAAM,CAACO,QAAQ;EAChC,IAAI,CAACA,QAAQ,EAAE,OAAOP,MAAM;EAE5B,MAAMQ,mBAAmB,GAAGD,QAAQ,CAACE,cAAc;EACnD,MAAMC,mBAAmB,GAAG,GAAGb,IAAI,CAACc,GAAG,eAAed,IAAI,CAACc,GAAG,UAAUd,IAAI,CAACc,GAAG,EAAE;EAClF,MAAMC,WAAW,GAAGZ,MAAM,CAACY,WAAW;EACtC,MAAMC,mBAAmB,GAAGD,WAAW,GAAGf,IAAI,CAACiB,IAAI,CAACF,WAAW,EAAE,cAAc,CAAC,GAAGG,SAAS;EAE5F,OAAO;IACL,GAAGf,MAAM;IACTO,QAAQ,EAAE;MACR,GAAGA,QAAQ;MACXE,cAAc,EAAEA,CAACO,OAAO,EAAEC,UAAU,EAAEC,QAAQ,KAAK;QACjD,MAAMC,WAAW,GAAGH,OAAO,CAACI,gBAAgB,EAAEC,QAAQ,CAACX,mBAAmB,CAAC,IAAI,KAAK;QACpF,IACES,WAAW,KACVF,UAAU,KAAK,cAAc,IAAIA,UAAU,CAACK,UAAU,CAAC,eAAe,CAAC,CAAC,EACzE;UACA,MAAMC,gBAAgB,GAAGV,mBAAmB,GACxC;YAAE,GAAGG,OAAO;YAAEI,gBAAgB,EAAEP;UAAoB,CAAC,GACrDG,OAAO;UACX,OAAOA,OAAO,CAACP,cAAc,CAACc,gBAAgB,EAAEN,UAAU,EAAEC,QAAQ,CAAC;QACvE;QACA,IAAIV,mBAAmB,EAAE;UACvB,OAAOA,mBAAmB,CAACQ,OAAO,EAAEC,UAAU,EAAEC,QAAQ,CAAC;QAC3D;QACA,OAAOF,OAAO,CAACP,cAAc,CAACO,OAAO,EAAEC,UAAU,EAAEC,QAAQ,CAAC;MAC9D;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,6 +1 @@
1
1
  @source './**/*.{ts,tsx}';
2
-
3
- /* TODO: Can we keep this? Check with Michael/Jack */
4
- *:focus {
5
- outline: none;
6
- }
@@ -1 +1 @@
1
- {"version":3,"file":"withForgeMetroConfig.d.ts","sourceRoot":"","sources":["../../../src/metro/withForgeMetroConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,EACxD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,uBAAuB,GAC/B,CAAC,CAKH"}
1
+ {"version":3,"file":"withForgeMetroConfig.d.ts","sourceRoot":"","sources":["../../../src/metro/withForgeMetroConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,EACxD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,uBAAuB,GAC/B,CAAC,CAOH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/components",
3
- "version": "0.0.1-beta.75",
3
+ "version": "0.0.1-beta.76",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",
@@ -66,10 +66,10 @@
66
66
  "dependencies": {
67
67
  "@gorhom/bottom-sheet": "^5.2.6",
68
68
  "class-variance-authority": "^0.7.1",
69
- "uniwind": "1.6.1",
70
- "@cdx-ui/primitives": "0.0.1-beta.75",
71
- "@cdx-ui/icons": "0.0.1-beta.75",
72
- "@cdx-ui/utils": "0.0.1-beta.75"
69
+ "uniwind": "1.10.0",
70
+ "@cdx-ui/primitives": "0.0.1-beta.76",
71
+ "@cdx-ui/utils": "0.0.1-beta.76",
72
+ "@cdx-ui/icons": "0.0.1-beta.76"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@react-navigation/bottom-tabs": "*",
@@ -1,3 +1,4 @@
1
+ import path from 'node:path';
1
2
  import type { MetroConfig } from 'metro-config';
2
3
  import { withUniwindConfig } from 'uniwind/metro';
3
4
 
@@ -22,8 +23,60 @@ export function withForgeMetroConfig<T extends MetroConfig>(
22
23
  config: T,
23
24
  options: ForgeMetroConfigOptions,
24
25
  ): T {
25
- return withUniwindConfig(config, {
26
+ const withUniwind = withUniwindConfig(config, {
26
27
  cssEntryFile: options.cssEntryFile,
27
28
  dtsFile: options.generatedTypesFile,
28
29
  }) as T;
30
+
31
+ return withUniwindMultiCopyFix(withUniwind);
32
+ }
33
+
34
+ /**
35
+ * Fixes Uniwind 1.9's nativeResolver in pnpm monorepos with multiple Uniwind copies.
36
+ *
37
+ * Uniwind decides whether to wrap a `react-native` import by comparing
38
+ * `originModulePath` against a cached internal base path resolved via
39
+ * `require.resolve('uniwind/package.json')`. In pnpm, the Metro config loaded
40
+ * by Node and the Uniwind copy bundled for the app may resolve to different
41
+ * physical paths (different peer-dep hashes in the virtual store), so the
42
+ * `isInternal` check returns false for Uniwind-internal code. The
43
+ * nativeResolver then re-routes `react-native` to `uniwind/components`, which
44
+ * re-exports from `react-native` — a circular `get NativeModules` getter that
45
+ * overflows the stack at runtime.
46
+ *
47
+ * Fix: intercept `react-native` requests originating from inside any Uniwind
48
+ * copy and resolve them from the app's `projectRoot`, bypassing the broken
49
+ * `isInternal` check entirely.
50
+ */
51
+ function withUniwindMultiCopyFix<T extends MetroConfig>(config: T): T {
52
+ const resolver = config.resolver;
53
+ if (!resolver) return config;
54
+
55
+ const innerResolveRequest = resolver.resolveRequest;
56
+ const uniwindPathFragment = `${path.sep}node_modules${path.sep}uniwind${path.sep}`;
57
+ const projectRoot = config.projectRoot;
58
+ const appOriginModulePath = projectRoot ? path.join(projectRoot, 'package.json') : undefined;
59
+
60
+ return {
61
+ ...config,
62
+ resolver: {
63
+ ...resolver,
64
+ resolveRequest: (context, moduleName, platform) => {
65
+ const fromUniwind = context.originModulePath?.includes(uniwindPathFragment) ?? false;
66
+ if (
67
+ fromUniwind &&
68
+ (moduleName === 'react-native' || moduleName.startsWith('react-native/'))
69
+ ) {
70
+ const rewrittenContext = appOriginModulePath
71
+ ? { ...context, originModulePath: appOriginModulePath }
72
+ : context;
73
+ return context.resolveRequest(rewrittenContext, moduleName, platform);
74
+ }
75
+ if (innerResolveRequest) {
76
+ return innerResolveRequest(context, moduleName, platform);
77
+ }
78
+ return context.resolveRequest(context, moduleName, platform);
79
+ },
80
+ },
81
+ } as T;
29
82
  }
package/src/styles.css CHANGED
@@ -1,6 +1 @@
1
1
  @source './**/*.{ts,tsx}';
2
-
3
- /* TODO: Can we keep this? Check with Michael/Jack */
4
- *:focus {
5
- outline: none;
6
- }