@medway-ui/native 1.8.2 → 1.9.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.
- package/README.md +11 -7
- package/lib/commonjs/editor/editorHtml.generated.js +3 -3
- package/lib/commonjs/editor/index.js.map +1 -1
- package/lib/module/editor/editorHtml.generated.js +3 -3
- package/lib/module/editor/index.js.map +1 -1
- package/lib/typescript/editor/editorHtml.generated.d.ts +3 -3
- package/lib/typescript/editor/index.d.ts +2 -1
- package/lib/typescript/editor/index.d.ts.map +1 -1
- package/package.json +11 -20
- package/setup/babel-brownfield.js +14 -34
- package/setup/metro.js +6 -67
- package/setup/monorepo.js +102 -0
- package/setup/tailwind.js +5 -6
- package/src/editor/editorHtml.generated.ts +3 -3
- package/src/editor/index.ts +2 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","NoteEditor","EDITOR_PROTOCOL_VERSION","EDITOR_RECEIVE_HANDLER","isEditorMessage"],"sourceRoot":"../../../src","sources":["editor/index.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["default","NoteEditor","EDITOR_PROTOCOL_VERSION","EDITOR_RECEIVE_HANDLER","isEditorMessage"],"sourceRoot":"../../../src","sources":["editor/index.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;AAKpD,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,eAAe,QACV,YAAY","ignoreList":[]}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Single-file build of the Tiptap editor that runs inside the WebView rendered
|
|
5
5
|
* by `@medway-ui/native/NoteEditor`. Regenerate with:
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* pnpm build:editor-bundle
|
|
8
8
|
*
|
|
9
|
-
* Source lives in `editor-bundle/src`. The bridge protocol it speaks is defined
|
|
10
|
-
* in
|
|
9
|
+
* Source lives in `packages/editor-bundle/src`. The bridge protocol it speaks is defined
|
|
10
|
+
* in `packages/native/src/editor/protocol.ts`, which both sides compile against.
|
|
11
11
|
*/
|
|
12
12
|
export declare const EDITOR_HTML: string;
|
|
13
13
|
//# sourceMappingURL=editorHtml.generated.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as NoteEditor } from "./NoteEditor";
|
|
2
2
|
export type { NoteEditorHandle } from "./NoteEditor";
|
|
3
|
+
export type { EditorDocument } from "@medway-ui/notes-core";
|
|
3
4
|
export type { WebViewMessageEvent } from "react-native-webview";
|
|
4
5
|
export { EDITOR_PROTOCOL_VERSION, EDITOR_RECEIVE_HANDLER, isEditorMessage, } from "./protocol";
|
|
5
|
-
export type { EditorToNativeMessage, NativeToEditorMessage
|
|
6
|
+
export type { EditorToNativeMessage, NativeToEditorMessage } from "./protocol";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medway-ui/native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Medway UI components for React Native (iOS/Android via Expo)",
|
|
5
5
|
"author": "Alekcarvalho",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,16 +49,8 @@
|
|
|
49
49
|
"./setup/MedwayUiProvider.tsx",
|
|
50
50
|
"./setup/global.css"
|
|
51
51
|
],
|
|
52
|
-
"scripts": {
|
|
53
|
-
"prebuild:lib": "npm --prefix .. run build:notes-core",
|
|
54
|
-
"build:lib": "bob build",
|
|
55
|
-
"pretypecheck": "npm --prefix .. run build:notes-core",
|
|
56
|
-
"typecheck": "tsc --noEmit",
|
|
57
|
-
"changeset": "changeset",
|
|
58
|
-
"version": "changeset version",
|
|
59
|
-
"release": "yarn build:lib && changeset publish"
|
|
60
|
-
},
|
|
61
52
|
"dependencies": {
|
|
53
|
+
"@medway-ui/notes-core": "^0.2.1",
|
|
62
54
|
"@rn-primitives/alert-dialog": "^1.0.0",
|
|
63
55
|
"@rn-primitives/avatar": "^1.0.0",
|
|
64
56
|
"@rn-primitives/checkbox": "^1.0.0",
|
|
@@ -74,9 +66,8 @@
|
|
|
74
66
|
"@rn-primitives/tooltip": "^1.0.0"
|
|
75
67
|
},
|
|
76
68
|
"peerDependencies": {
|
|
77
|
-
"@medway-ui/core": "
|
|
69
|
+
"@medway-ui/core": "^1.0.0",
|
|
78
70
|
"@medway-ui/icons": "^1.12.0",
|
|
79
|
-
"@medway-ui/notes-core": ">=0.2.0",
|
|
80
71
|
"@react-native-masked-view/masked-view": ">=0.3.0",
|
|
81
72
|
"@react-navigation/native": ">=6.0.0",
|
|
82
73
|
"@react-navigation/native-stack": ">=6.0.0",
|
|
@@ -105,9 +96,6 @@
|
|
|
105
96
|
"@medway-ui/core": {
|
|
106
97
|
"optional": true
|
|
107
98
|
},
|
|
108
|
-
"@medway-ui/notes-core": {
|
|
109
|
-
"optional": true
|
|
110
|
-
},
|
|
111
99
|
"@react-native-masked-view/masked-view": {
|
|
112
100
|
"optional": true
|
|
113
101
|
},
|
|
@@ -122,8 +110,6 @@
|
|
|
122
110
|
}
|
|
123
111
|
},
|
|
124
112
|
"devDependencies": {
|
|
125
|
-
"@changesets/changelog-github": "^0.7.0",
|
|
126
|
-
"@changesets/cli": "^2.31.1",
|
|
127
113
|
"@medway-ui/icons": "^1.12.1",
|
|
128
114
|
"@react-native-masked-view/masked-view": "^0.3.2",
|
|
129
115
|
"@react-navigation/native": "^7.3.18",
|
|
@@ -141,6 +127,7 @@
|
|
|
141
127
|
"react-native-svg": "^15.15.5",
|
|
142
128
|
"react-native-webview": "^14.0.1",
|
|
143
129
|
"tailwind-merge": "^3.2.0",
|
|
130
|
+
"tailwindcss": "^3.4",
|
|
144
131
|
"typescript": "^5"
|
|
145
132
|
},
|
|
146
133
|
"react-native-builder-bob": {
|
|
@@ -168,7 +155,7 @@
|
|
|
168
155
|
"repository": {
|
|
169
156
|
"type": "git",
|
|
170
157
|
"url": "https://github.com/medway-dev/medway-ui.git",
|
|
171
|
-
"directory": "native"
|
|
158
|
+
"directory": "packages/native"
|
|
172
159
|
},
|
|
173
160
|
"keywords": [
|
|
174
161
|
"react-native",
|
|
@@ -179,5 +166,9 @@
|
|
|
179
166
|
"medway",
|
|
180
167
|
"ios",
|
|
181
168
|
"android"
|
|
182
|
-
]
|
|
183
|
-
|
|
169
|
+
],
|
|
170
|
+
"scripts": {
|
|
171
|
+
"build": "bob build",
|
|
172
|
+
"typecheck": "tsc --noEmit"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -1,68 +1,48 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const { medwayUiNativeRoots, resolveMedwayUiPaths } = require('./monorepo');
|
|
3
4
|
|
|
4
5
|
const DEFAULT_APP_PAGES_DIR = 'medway-ui';
|
|
5
6
|
|
|
7
|
+
function isInsideNativeRoot(filename, nativeRoots) {
|
|
8
|
+
return nativeRoots.some((root) => filename.startsWith(root + path.sep));
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
function createNativeWindScopeTest(options = {}) {
|
|
7
12
|
const appPagesDir = options.appPagesDir ?? DEFAULT_APP_PAGES_DIR;
|
|
8
13
|
const appPagesSegment = `${path.sep}pages${path.sep}${appPagesDir}${path.sep}`;
|
|
14
|
+
const nativeRoots = medwayUiNativeRoots(options.projectRoot ?? process.cwd());
|
|
9
15
|
|
|
10
16
|
return function isNativeWindScope(filename) {
|
|
11
17
|
return (
|
|
12
18
|
filename.includes(`${path.sep}@medway-ui${path.sep}native${path.sep}`) ||
|
|
13
19
|
filename.includes(`${path.sep}medway-ui${path.sep}native${path.sep}`) ||
|
|
20
|
+
isInsideNativeRoot(filename, nativeRoots) ||
|
|
14
21
|
filename.includes(`${path.sep}@rn-primitives${path.sep}`) ||
|
|
15
22
|
filename.includes(appPagesSegment)
|
|
16
23
|
);
|
|
17
24
|
};
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
function createMedwayUiSourceTest() {
|
|
27
|
+
function createMedwayUiSourceTest(projectRoot = process.cwd()) {
|
|
28
|
+
const nativeRoots = medwayUiNativeRoots(projectRoot);
|
|
29
|
+
|
|
21
30
|
return function isMedwayUiSourceFile(currentFile) {
|
|
22
31
|
return (
|
|
23
32
|
currentFile.includes(`${path.sep}@medway-ui${path.sep}native${path.sep}`) ||
|
|
24
|
-
currentFile.includes(`${path.sep}medway-ui${path.sep}native${path.sep}`)
|
|
33
|
+
currentFile.includes(`${path.sep}medway-ui${path.sep}native${path.sep}`) ||
|
|
34
|
+
isInsideNativeRoot(currentFile, nativeRoots)
|
|
25
35
|
);
|
|
26
36
|
};
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
function resolveMedwayUiNativeSrc(projectRoot) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (fs.existsSync(npmNativeSrc) && !isNativePackageSymlinkedToMonorepo(projectRoot)) {
|
|
33
|
-
return npmNativeSrc;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const monorepoNativeSrc = path.resolve(projectRoot, '../medway-ui/native/src');
|
|
37
|
-
if (fs.existsSync(monorepoNativeSrc)) {
|
|
38
|
-
return monorepoNativeSrc;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return npmNativeSrc;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isNativePackageSymlinkedToMonorepo(projectRoot) {
|
|
45
|
-
const nativePath = path.join(projectRoot, 'node_modules/@medway-ui/native');
|
|
46
|
-
|
|
47
|
-
if (!fs.existsSync(nativePath)) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const nativeRealPath = fs.realpathSync(nativePath);
|
|
53
|
-
const monorepoNativePath = fs.realpathSync(
|
|
54
|
-
path.resolve(projectRoot, '../medway-ui/native'),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return nativeRealPath === monorepoNativePath;
|
|
58
|
-
} catch {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
40
|
+
return resolveMedwayUiPaths(projectRoot).medwayUiNativeSrc;
|
|
61
41
|
}
|
|
62
42
|
|
|
63
43
|
function createMedwayUiAliasResolver(projectRoot) {
|
|
64
44
|
const medwayUiNativeSrc = resolveMedwayUiNativeSrc(projectRoot);
|
|
65
|
-
const isMedwayUiSourceFile = createMedwayUiSourceTest();
|
|
45
|
+
const isMedwayUiSourceFile = createMedwayUiSourceTest(projectRoot);
|
|
66
46
|
|
|
67
47
|
return function resolveMedwayUiAlias(sourcePath, currentFile) {
|
|
68
48
|
if (!isMedwayUiSourceFile(currentFile) || !sourcePath.startsWith('@/')) {
|
package/setup/metro.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const { detectLinkedMedwayUiRoot, resolveMedwayUiPaths } = require('./monorepo');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Subpaths whose `exports` entry points at `lib/` — the bob build output, which
|
|
@@ -107,74 +108,12 @@ function resolveBareModule(moduleName, searchRoots) {
|
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
-
* Prioriza npm quando o pacote não é symlink para o clone local.
|
|
112
|
-
*/
|
|
113
|
-
function isNativePackageSymlinkedToMonorepo(projectRoot) {
|
|
114
|
-
const nativePath = path.join(projectRoot, 'node_modules/@medway-ui/native');
|
|
115
|
-
|
|
116
|
-
if (!fs.existsSync(nativePath)) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
const nativeRealPath = fs.realpathSync(nativePath);
|
|
122
|
-
const monorepoNativePath = fs.realpathSync(
|
|
123
|
-
path.resolve(projectRoot, '../medway-ui/native'),
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
return nativeRealPath === monorepoNativePath;
|
|
127
|
-
} catch {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function detectLinkedMedwayUiRoot(projectRoot) {
|
|
133
|
-
const npmScopedRoot = 'node_modules/@medway-ui';
|
|
134
|
-
const npmNativeSrc = path.resolve(projectRoot, npmScopedRoot, 'native/src');
|
|
135
|
-
|
|
136
|
-
if (fs.existsSync(npmNativeSrc) && !isNativePackageSymlinkedToMonorepo(projectRoot)) {
|
|
137
|
-
return npmScopedRoot;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const monorepoRoot = '../medway-ui';
|
|
141
|
-
const monorepoNativeSrc = path.resolve(projectRoot, monorepoRoot, 'native/src');
|
|
142
|
-
|
|
143
|
-
if (fs.existsSync(monorepoNativeSrc)) {
|
|
144
|
-
return monorepoRoot;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (fs.existsSync(npmNativeSrc)) {
|
|
148
|
-
return npmScopedRoot;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return monorepoRoot;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function resolveMedwayUiPaths(projectRoot, linkedMedwayUiRoot, nativePackageRoot) {
|
|
155
|
-
const medwayUiRoot = path.resolve(projectRoot, linkedMedwayUiRoot);
|
|
156
|
-
const linkedNativeSrc = path.resolve(medwayUiRoot, 'native/src');
|
|
157
|
-
const npmNativeSrc = path.join(nativePackageRoot, 'src');
|
|
158
|
-
const isMonorepoLink = fs.existsSync(linkedNativeSrc);
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
medwayUiRoot: isMonorepoLink ? medwayUiRoot : nativePackageRoot,
|
|
162
|
-
medwayUiNativeRoot: isMonorepoLink
|
|
163
|
-
? path.resolve(medwayUiRoot, 'native')
|
|
164
|
-
: nativePackageRoot,
|
|
165
|
-
medwayUiNativeSrc: isMonorepoLink ? linkedNativeSrc : npmNativeSrc,
|
|
166
|
-
medwayUiSharedSrc: isMonorepoLink ? path.resolve(medwayUiRoot, 'src') : null,
|
|
167
|
-
isMonorepoLink,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Metro + NativeWind para @medway-ui/native (monorepo file: ou npm).
|
|
111
|
+
* Metro + NativeWind para @medway-ui/native (npm ou clone do medway-ui linkado).
|
|
173
112
|
*
|
|
174
113
|
* @param {import('expo/metro-config').MetroConfig} config
|
|
175
114
|
* @param {object} [options]
|
|
176
115
|
* @param {string} options.projectRoot
|
|
177
|
-
* @param {string} [options.linkedMedwayUiRoot] -
|
|
116
|
+
* @param {string} [options.linkedMedwayUiRoot] - raiz do clone do medway-ui; detectada quando omitida
|
|
178
117
|
* @param {boolean} [options.resolveNativeSource=true] - aponta @medway-ui/native para src/
|
|
179
118
|
*/
|
|
180
119
|
function withMedwayUi(config, options = {}) {
|
|
@@ -195,7 +134,7 @@ function withMedwayUi(config, options = {}) {
|
|
|
195
134
|
} = resolveMedwayUiPaths(projectRoot, linkedMedwayUiRoot, nativePackageRoot);
|
|
196
135
|
|
|
197
136
|
if (isMonorepoLink) {
|
|
198
|
-
const
|
|
137
|
+
const escapeRegex = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
199
138
|
|
|
200
139
|
config.watchFolders = [...(config.watchFolders ?? []), medwayUiRoot];
|
|
201
140
|
|
|
@@ -208,8 +147,8 @@ function withMedwayUi(config, options = {}) {
|
|
|
208
147
|
|
|
209
148
|
config.resolver.blockList = [
|
|
210
149
|
...blockListArray,
|
|
211
|
-
new RegExp(`${
|
|
212
|
-
new RegExp(`${
|
|
150
|
+
new RegExp(`${escapeRegex(medwayUiNativeRoot)}[\\\\/]node_modules[\\\\/].*`),
|
|
151
|
+
new RegExp(`${escapeRegex(medwayUiRoot)}[\\\\/]node_modules[\\\\/].*`),
|
|
213
152
|
];
|
|
214
153
|
}
|
|
215
154
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const NPM_MEDWAY_UI_ROOT = 'node_modules/@medway-ui';
|
|
5
|
+
const OWN_NATIVE_ROOT = path.resolve(__dirname, '..');
|
|
6
|
+
|
|
7
|
+
function realpathOrNull(target) {
|
|
8
|
+
try {
|
|
9
|
+
return fs.realpathSync(target);
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Same lookup as Node: the closest node_modules up from the app, so a hoisted install is found too. */
|
|
16
|
+
function findInstalledNative(projectRoot) {
|
|
17
|
+
for (let dir = path.resolve(projectRoot); ; dir = path.dirname(dir)) {
|
|
18
|
+
const nativeRoot = realpathOrNull(path.join(dir, 'node_modules', '@medway-ui', 'native'));
|
|
19
|
+
if (nativeRoot) return nativeRoot;
|
|
20
|
+
if (path.dirname(dir) === dir) return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function findWorkspaceRoot(fromDir) {
|
|
25
|
+
for (let dir = fromDir; ; dir = path.dirname(dir)) {
|
|
26
|
+
if (fs.existsSync(path.join(dir, 'pnpm-workspace.yaml'))) return dir;
|
|
27
|
+
if (path.dirname(dir) === dir) return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isMedwayUiClone(dir) {
|
|
32
|
+
return fs.existsSync(path.join(dir, 'packages', 'native', 'src'));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The medway-ui clone the app links to (`file:`/`link:` symlink), relative to the app, or
|
|
37
|
+
* `node_modules/@medway-ui` for an npm install. An npm copy always resolves inside a
|
|
38
|
+
* node_modules folder; a linked clone never does, whatever its folder is called.
|
|
39
|
+
*/
|
|
40
|
+
function detectLinkedMedwayUiRoot(projectRoot) {
|
|
41
|
+
const nativeRoot = findInstalledNative(projectRoot);
|
|
42
|
+
if (nativeRoot && !nativeRoot.split(path.sep).includes('node_modules')) {
|
|
43
|
+
const cloneRoot = findWorkspaceRoot(nativeRoot);
|
|
44
|
+
if (cloneRoot && isMedwayUiClone(cloneRoot)) {
|
|
45
|
+
return path.relative(projectRoot, cloneRoot) || '.';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return NPM_MEDWAY_UI_ROOT;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function resolveMedwayUiPaths(
|
|
52
|
+
projectRoot,
|
|
53
|
+
linkedMedwayUiRoot = detectLinkedMedwayUiRoot(projectRoot),
|
|
54
|
+
nativePackageRoot = OWN_NATIVE_ROOT,
|
|
55
|
+
) {
|
|
56
|
+
const cloneRoot = path.resolve(projectRoot, linkedMedwayUiRoot);
|
|
57
|
+
|
|
58
|
+
// node_modules/@medway-ui (npm) and pre-monorepo clones keep the shape apps already build with.
|
|
59
|
+
const flatNativeRoot = path.join(cloneRoot, 'native');
|
|
60
|
+
if (fs.existsSync(path.join(flatNativeRoot, 'src'))) {
|
|
61
|
+
return {
|
|
62
|
+
medwayUiRoot: cloneRoot,
|
|
63
|
+
medwayUiNativeRoot: flatNativeRoot,
|
|
64
|
+
medwayUiNativeSrc: path.join(flatNativeRoot, 'src'),
|
|
65
|
+
medwayUiSharedSrc: path.join(cloneRoot, 'src'),
|
|
66
|
+
isMonorepoLink: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (isMedwayUiClone(cloneRoot)) {
|
|
71
|
+
const nativeRoot = path.join(cloneRoot, 'packages', 'native');
|
|
72
|
+
return {
|
|
73
|
+
medwayUiRoot: cloneRoot,
|
|
74
|
+
medwayUiNativeRoot: nativeRoot,
|
|
75
|
+
medwayUiNativeSrc: path.join(nativeRoot, 'src'),
|
|
76
|
+
medwayUiSharedSrc: path.join(cloneRoot, 'packages', 'core', 'src'),
|
|
77
|
+
isMonorepoLink: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
medwayUiRoot: nativePackageRoot,
|
|
83
|
+
medwayUiNativeRoot: nativePackageRoot,
|
|
84
|
+
medwayUiNativeSrc: path.join(nativePackageRoot, 'src'),
|
|
85
|
+
medwayUiSharedSrc: null,
|
|
86
|
+
isMonorepoLink: false,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Real folders of @medway-ui/native for this app: the npm copy and, when linked, the clone's. */
|
|
91
|
+
function medwayUiNativeRoots(projectRoot) {
|
|
92
|
+
const roots = [OWN_NATIVE_ROOT, resolveMedwayUiPaths(projectRoot).medwayUiNativeRoot]
|
|
93
|
+
.map((root) => realpathOrNull(root) ?? root);
|
|
94
|
+
return [...new Set(roots)];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
NPM_MEDWAY_UI_ROOT,
|
|
99
|
+
detectLinkedMedwayUiRoot,
|
|
100
|
+
resolveMedwayUiPaths,
|
|
101
|
+
medwayUiNativeRoots,
|
|
102
|
+
};
|
package/setup/tailwind.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
1
|
const path = require('path');
|
|
2
|
+
const { resolveMedwayUiPaths } = require('./monorepo');
|
|
3
3
|
|
|
4
4
|
function loadDesignTokens(projectRoot) {
|
|
5
5
|
const tokensPath = require.resolve('@medway-ui/core/tokens', {
|
|
@@ -70,7 +70,7 @@ function createNativeMontserratFontPlugin() {
|
|
|
70
70
|
* @param {object} [options]
|
|
71
71
|
* @param {string} options.projectRoot - raiz do app consumidor
|
|
72
72
|
* @param {string[]} [options.content] - globs extras (ex.: telas migradas)
|
|
73
|
-
* @param {string} [options.linkedMedwayUiRoot] -
|
|
73
|
+
* @param {string} [options.linkedMedwayUiRoot] - clone do medway-ui (ex.: '../medway-ui')
|
|
74
74
|
*/
|
|
75
75
|
function createMedwayUiTailwindConfig(options = {}) {
|
|
76
76
|
const { projectRoot = process.cwd(), content = [], linkedMedwayUiRoot } = options;
|
|
@@ -92,14 +92,13 @@ function createMedwayUiTailwindConfig(options = {}) {
|
|
|
92
92
|
];
|
|
93
93
|
|
|
94
94
|
if (linkedMedwayUiRoot) {
|
|
95
|
-
const
|
|
95
|
+
const { medwayUiNativeSrc, isMonorepoLink } = resolveMedwayUiPaths(
|
|
96
96
|
projectRoot,
|
|
97
97
|
linkedMedwayUiRoot,
|
|
98
|
-
'native/src',
|
|
99
98
|
);
|
|
100
99
|
|
|
101
|
-
if (
|
|
102
|
-
libContent.push(path.join(
|
|
100
|
+
if (isMonorepoLink) {
|
|
101
|
+
libContent.push(path.join(medwayUiNativeSrc, '**/*.{ts,tsx}'));
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
|