@medway-ui/native 1.9.0 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -241,6 +241,8 @@ cd ../medway-ui && pnpm install && pnpm build:lib && pnpm build:native
241
241
 
242
242
  Metro e Babel detectam o clone automaticamente pelo caminho real do `@medway-ui/native`, mesmo com o clone em outra pasta. Depois de mudanças na biblioteca, rode `pnpm build:native` de novo se estiver testando a lib compilada.
243
243
 
244
+ Os ícones continuam vindo do `@medway-ui/icons` instalado no app, não do `packages/icons` do clone: o Metro resolve primeiro pelo `node_modules` do app. Um ícone que ainda não saiu no npm aparece como `undefined` no app (erro "Element type is invalid" em runtime, sem erro de build). Para usar um ícone novo, espere a PR de versão dos ícones ser mergeada e atualize o `@medway-ui/icons` no app.
245
+
244
246
  Reinicie o Metro com cache limpo: `npx expo start --clear`.
245
247
 
246
248
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medway-ui/native",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "Medway UI components for React Native (iOS/Android via Expo)",
5
5
  "author": "Alekcarvalho",
6
6
  "license": "MIT",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@medway-ui/core": "^1.0.0",
70
- "@medway-ui/icons": "^1.12.0",
70
+ "@medway-ui/icons": "^1.17.0",
71
71
  "@react-native-masked-view/masked-view": ">=0.3.0",
72
72
  "@react-navigation/native": ">=6.0.0",
73
73
  "@react-navigation/native-stack": ">=6.0.0",
@@ -110,7 +110,7 @@
110
110
  }
111
111
  },
112
112
  "devDependencies": {
113
- "@medway-ui/icons": "^1.12.1",
113
+ "@medway-ui/icons": "1.17.0",
114
114
  "@react-native-masked-view/masked-view": "^0.3.2",
115
115
  "@react-navigation/native": "^7.3.18",
116
116
  "@react-navigation/native-stack": "^7.18.10",
package/setup/metro.js CHANGED
@@ -14,6 +14,8 @@ const NATIVE_SOURCE_SUBPATHS = {
14
14
  '@medway-ui/native/editor/protocol': 'editor/protocol.ts',
15
15
  };
16
16
 
17
+ const PACKAGE_NOT_FOUND = new Set(['FailedToResolveNameError', 'FailedToResolvePathError']);
18
+
17
19
  function loadWithNativeWind(projectRoot) {
18
20
  return require(require.resolve('nativewind/metro', { paths: [projectRoot] }))
19
21
  .withNativeWind;
@@ -48,65 +50,6 @@ function resolveMedwayAlias(moduleName, medwayUiNativeSrc, medwayUiSharedSrc) {
48
50
  );
49
51
  }
50
52
 
51
- function resolvePackageEntry(packageDir, entry) {
52
- const withoutExt = entry.replace(/\.(tsx|ts|jsx|js)$/, '');
53
- const candidates = [
54
- path.resolve(packageDir, entry),
55
- path.resolve(packageDir, withoutExt),
56
- ...['.tsx', '.ts', '.jsx', '.js'].map((ext) =>
57
- path.resolve(packageDir, `${withoutExt}${ext}`),
58
- ),
59
- ];
60
-
61
- for (const candidate of candidates) {
62
- if (fs.existsSync(candidate)) return candidate;
63
- }
64
-
65
- return null;
66
- }
67
-
68
- function getAppPackageJsonPath(moduleName, projectRoot) {
69
- const directPath = path.join(projectRoot, 'node_modules', moduleName, 'package.json');
70
-
71
- if (fs.existsSync(directPath)) {
72
- return directPath;
73
- }
74
-
75
- try {
76
- return require.resolve(`${moduleName}/package.json`, { paths: [projectRoot] });
77
- } catch {
78
- return null;
79
- }
80
- }
81
-
82
- function resolveBareModule(moduleName, searchRoots) {
83
- for (const root of searchRoots) {
84
- try {
85
- const packageJsonPath = getAppPackageJsonPath(moduleName, root);
86
-
87
- if (packageJsonPath) {
88
- const pkg = require(packageJsonPath);
89
- const packageDir = path.dirname(packageJsonPath);
90
- const reactNativeEntry = pkg['react-native'];
91
-
92
- if (typeof reactNativeEntry === 'string' && !reactNativeEntry.endsWith('cli.js')) {
93
- const resolved = resolvePackageEntry(packageDir, reactNativeEntry);
94
-
95
- if (resolved) {
96
- return resolved;
97
- }
98
- }
99
- }
100
-
101
- return require.resolve(moduleName, { paths: [root] });
102
- } catch {
103
- // try next root
104
- }
105
- }
106
-
107
- return null;
108
- }
109
-
110
53
  /**
111
54
  * Metro + NativeWind para @medway-ui/native (npm ou clone do medway-ui linkado).
112
55
  *
@@ -168,12 +111,30 @@ function withMedwayUi(config, options = {}) {
168
111
  );
169
112
  }
170
113
 
171
- function isBareImport(moduleName) {
172
- return !moduleName.startsWith('.') && !moduleName.startsWith('/');
114
+ function isPackageImport(moduleName) {
115
+ return !/^(\.|\/|@\/)/.test(moduleName);
173
116
  }
174
117
 
175
118
  const defaultResolveRequest = config.resolver.resolveRequest;
176
119
 
120
+ function resolveDefault(context, moduleName, platform) {
121
+ return (defaultResolveRequest ?? context.resolveRequest)(context, moduleName, platform);
122
+ }
123
+
124
+ // Metro's own rules (exports conditions, platform files) from the app, so the lib and the app share one copy.
125
+ function resolveFromApp(context, moduleName, platform) {
126
+ try {
127
+ return resolveDefault(
128
+ { ...context, originModulePath: path.join(projectRoot, 'package.json') },
129
+ moduleName,
130
+ platform,
131
+ );
132
+ } catch (error) {
133
+ if (PACKAGE_NOT_FOUND.has(error?.constructor?.name)) return null;
134
+ throw error;
135
+ }
136
+ }
137
+
177
138
  const portalEntry = require.resolve('@rn-primitives/portal', {
178
139
  paths: [projectRoot, nativePackageRoot],
179
140
  });
@@ -213,24 +174,16 @@ function withMedwayUi(config, options = {}) {
213
174
  }
214
175
  }
215
176
 
216
- if (isBareImport(moduleName)) {
217
- const resolved = resolveBareModule(moduleName, [
218
- projectRoot,
219
- nativePackageRoot,
220
- medwayUiNativeRoot,
221
- ]);
177
+ if (isPackageImport(moduleName)) {
178
+ const resolved = resolveFromApp(context, moduleName, platform);
222
179
 
223
180
  if (resolved) {
224
- return { filePath: resolved, type: 'sourceFile' };
181
+ return resolved;
225
182
  }
226
183
  }
227
184
  }
228
185
 
229
- if (defaultResolveRequest) {
230
- return defaultResolveRequest(context, moduleName, platform);
231
- }
232
-
233
- return context.resolveRequest(context, moduleName, platform);
186
+ return resolveDefault(context, moduleName, platform);
234
187
  };
235
188
 
236
189
  const withNativeWind = loadWithNativeWind(projectRoot);