vxrn 2.13.7 → 2.13.9
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/dist/cli.mjs +3 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/cli.native.js +5 -2
- package/dist/cli.native.js.map +1 -1
- package/dist/config/getBaseViteConfigOnly.mjs +3 -3
- package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js +3 -3
- package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
- package/dist/config/getOptionsFilled.mjs +24 -2
- package/dist/config/getOptionsFilled.mjs.map +1 -1
- package/dist/config/getOptionsFilled.native.js +25 -2
- package/dist/config/getOptionsFilled.native.js.map +1 -1
- package/dist/config/getServerOptionsFilled.mjs +119 -1
- package/dist/config/getServerOptionsFilled.mjs.map +1 -1
- package/dist/config/getServerOptionsFilled.native.js +137 -1
- package/dist/config/getServerOptionsFilled.native.js.map +1 -1
- package/dist/exports/build.mjs +6 -9
- package/dist/exports/build.mjs.map +1 -1
- package/dist/exports/build.native.js +6 -9
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/dev.mjs +4 -6
- package/dist/exports/dev.mjs.map +1 -1
- package/dist/exports/dev.native.js +6 -6
- package/dist/exports/dev.native.js.map +1 -1
- package/dist/exports/prebuild.mjs +4 -4
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js +4 -4
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +95 -88
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +95 -88
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs +3 -3
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js +3 -3
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs +4 -4
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js +4 -4
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +18 -5
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +18 -5
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/user-interface/index.mjs +1 -1
- package/dist/user-interface/index.mjs.map +1 -1
- package/dist/user-interface/index.native.js +1 -1
- package/dist/user-interface/index.native.js.map +1 -1
- package/dist/utils/env-editor.mjs +198 -0
- package/dist/utils/env-editor.mjs.map +1 -0
- package/dist/utils/env-editor.native.js +266 -0
- package/dist/utils/env-editor.native.js.map +1 -0
- package/dist/utils/fs.mjs +48 -0
- package/dist/utils/fs.mjs.map +1 -0
- package/dist/utils/fs.native.js +48 -0
- package/dist/utils/fs.native.js.map +1 -0
- package/dist/utils/getVitePath.mjs +2 -2
- package/dist/utils/getVitePath.mjs.map +1 -1
- package/dist/utils/getVitePath.native.js +2 -2
- package/dist/utils/getVitePath.native.js.map +1 -1
- package/dist/utils/patches.mjs +38 -29
- package/dist/utils/patches.mjs.map +1 -1
- package/dist/utils/patches.native.js +38 -29
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +12 -11
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +12 -11
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/dist/utils/state.mjs +5 -5
- package/dist/utils/state.mjs.map +1 -1
- package/dist/utils/state.native.js +5 -5
- package/dist/utils/state.native.js.map +1 -1
- package/dist/utils/utils.mjs +4 -3
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.native.js +4 -3
- package/dist/utils/utils.native.js.map +1 -1
- package/package.json +12 -18
- package/src/cli.ts +5 -4
- package/src/config/getBaseViteConfigOnly.ts +3 -3
- package/src/config/getOptionsFilled.ts +35 -2
- package/src/config/getServerOptionsFilled.test.ts +37 -0
- package/src/config/getServerOptionsFilled.ts +57 -1
- package/src/exports/build.ts +5 -12
- package/src/exports/clean.test.ts +1 -1
- package/src/exports/dev.ts +5 -6
- package/src/exports/prebuild.ts +4 -4
- package/src/exports/prebuildWithoutExpo.ts +102 -89
- package/src/plugins/autoDepOptimizePlugin.ts +3 -3
- package/src/plugins/reactNativeDevAssetPlugin.ts +4 -4
- package/src/rn-commands/bundle/buildBundle.ts +15 -5
- package/src/user-interface/index.ts +1 -1
- package/src/utils/env-editor.LICENSE +9 -0
- package/src/utils/env-editor.ts +214 -0
- package/src/utils/fs.ts +59 -0
- package/src/utils/getVitePath.ts +2 -2
- package/src/utils/patches.test.ts +36 -36
- package/src/utils/patches.ts +39 -27
- package/src/utils/scanDepsToOptimize.test.ts +2 -2
- package/src/utils/scanDepsToOptimize.ts +6 -5
- package/src/utils/state.ts +5 -7
- package/src/utils/utils.ts +5 -5
- package/types/config/getOptionsFilled.d.ts +9 -2
- package/types/config/getOptionsFilled.d.ts.map +1 -1
- package/types/config/getServerOptionsFilled.d.ts.map +1 -1
- package/types/exports/build.d.ts +1 -1
- package/types/exports/build.d.ts.map +1 -1
- package/types/exports/dev.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/user-interface/index.d.ts.map +1 -1
- package/types/utils/env-editor.d.ts +9 -0
- package/types/utils/env-editor.d.ts.map +1 -0
- package/types/utils/fs.d.ts +9 -0
- package/types/utils/fs.d.ts.map +1 -0
- package/types/utils/patches.d.ts.map +1 -1
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/types/utils/state.d.ts.map +1 -1
- package/types/utils/utils.d.ts +2 -2
- package/types/utils/utils.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVitePath.native.js","names":[],"sources":["utils/getVitePath.native.js"],"sourcesContent":["import { dirname, join } from \"path\";\nimport
|
|
1
|
+
{"version":3,"file":"getVitePath.native.js","names":[],"sources":["utils/getVitePath.native.js"],"sourcesContent":["import { dirname, join } from \"path\";\nimport { realpath } from \"fs/promises\";\nimport { normalizePath } from \"vite\";\nasync function getVitePath(rootPath, importer, moduleName, resolver, resolverWithPlugins) {\n var absolute = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;\n if (moduleName === \"react-native\") {\n return \"react-native\";\n }\n if (moduleName === \"react\") {\n return \"react\";\n }\n if (moduleName === \"react/jsx-runtime\") {\n return \"react/jsx-runtime\";\n }\n if (moduleName === \"react/jsx-dev-runtime\") {\n return \"react/jsx-dev-runtime\";\n }\n if (moduleName.includes(\"one/dist/esm/index\")) {\n return \"one\";\n }\n if (moduleName[0] === \".\") {\n var rootAt = importer.indexOf(rootPath);\n var base = join(dirname(importer.slice(rootAt)), moduleName);\n return base + \".js\";\n }\n if (moduleName === \"one\") {\n return \"one\";\n }\n if (moduleName === \"one\") {\n return \"one\";\n }\n var sourceFile = join(process.cwd(), \"index.js\");\n var resolved = await resolver(moduleName, sourceFile) || await resolverWithPlugins(moduleName, importer);\n if (!resolved) {\n return \"one\";\n }\n if (!resolved) {\n throw new Error(` \\u274C Path not found ${sourceFile} (rootPath ${rootPath}, importer ${importer}, moduleName ${moduleName})`);\n }\n var real = await realpath(resolved);\n var id = real;\n if (normalizePath(id).endsWith(`/react/jsx-dev-runtime.js`)) {\n id = \"react/jsx-runtime\";\n }\n return id;\n}\nexport {\n getVitePath\n};\n//# sourceMappingURL=getVitePath.js.map\n"],"mappings":";;;;;AAGA,eAAe,YAAY,UAAU,UAAU,YAAY,UAAU,qBAAqB;CACxF,IAAI,WAAW,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAChF,IAAI,eAAe,gBAAgB;EACjC,OAAO;CACT;CACA,IAAI,eAAe,SAAS;EAC1B,OAAO;CACT;CACA,IAAI,eAAe,qBAAqB;EACtC,OAAO;CACT;CACA,IAAI,eAAe,yBAAyB;EAC1C,OAAO;CACT;CACA,IAAI,WAAW,SAAS,oBAAoB,GAAG;EAC7C,OAAO;CACT;CACA,IAAI,WAAW,OAAO,KAAK;EACzB,IAAI,SAAS,SAAS,QAAQ,QAAQ;EACtC,IAAI,OAAO,KAAK,QAAQ,SAAS,MAAM,MAAM,CAAC,GAAG,UAAU;EAC3D,OAAO,OAAO;CAChB;CACA,IAAI,eAAe,OAAO;EACxB,OAAO;CACT;CACA,IAAI,eAAe,OAAO;EACxB,OAAO;CACT;CACA,IAAI,aAAa,KAAK,QAAQ,IAAI,GAAG,UAAU;CAC/C,IAAI,WAAW,MAAM,SAAS,YAAY,UAAU,KAAK,MAAM,oBAAoB,YAAY,QAAQ;CACvG,IAAI,CAAC,UAAU;EACb,OAAO;CACT;CACA,IAAI,CAAC,UAAU;EACb,MAAM,IAAI,MAAM,0BAA0B,WAAW,aAAa,SAAS,aAAa,SAAS,eAAe,WAAW,EAAE;CAC/H;CACA,IAAI,OAAO,MAAM,SAAS,QAAQ;CAClC,IAAI,KAAK;CACT,IAAI,cAAc,EAAE,CAAC,CAAC,SAAS,2BAA2B,GAAG;EAC3D,KAAK;CACP;CACA,OAAO;AACT"}
|
package/dist/utils/patches.mjs
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { transformSWC } from "@vxrn/compiler";
|
|
2
2
|
import { transformFlowBabel } from "@vxrn/vite-flow";
|
|
3
3
|
import Glob from "fast-glob";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { rename } from "node:fs/promises";
|
|
4
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { readFile, rename, stat, writeFile } from "node:fs/promises";
|
|
9
7
|
import semver from "semver";
|
|
10
8
|
import { builtInDepPatches } from "../patches/builtInDepPatches.mjs";
|
|
9
|
+
import { readJSON, writeJSON } from "./fs.mjs";
|
|
11
10
|
import { globDir } from "./globDir.mjs";
|
|
12
11
|
|
|
12
|
+
function findNodeModulesDirs(root) {
|
|
13
|
+
const dirs = [];
|
|
14
|
+
let dir = resolve(root);
|
|
15
|
+
for (;;) {
|
|
16
|
+
const candidate = join(dir, "node_modules");
|
|
17
|
+
if (existsSync(candidate)) dirs.push(candidate);
|
|
18
|
+
const parent = dirname(dir);
|
|
19
|
+
if (parent === dir) return dirs;
|
|
20
|
+
dir = parent;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
13
23
|
var Bail = class extends Error {};
|
|
14
24
|
function bailIfUnchanged(obj1, obj2) {
|
|
15
25
|
if (JSON.stringify(obj1) === JSON.stringify(obj2)) {
|
|
@@ -50,26 +60,25 @@ function getOriginalPath(fullPath) {
|
|
|
50
60
|
}
|
|
51
61
|
async function readPatchStats(nodeModulesDir) {
|
|
52
62
|
try {
|
|
53
|
-
return await
|
|
63
|
+
return await readJSON(join(nodeModulesDir, STATS_FILE));
|
|
54
64
|
} catch {
|
|
55
65
|
return {};
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
68
|
async function writePatchStats(nodeModulesDir, stats) {
|
|
59
|
-
await
|
|
69
|
+
await writeJSON(join(nodeModulesDir, STATS_FILE), stats);
|
|
60
70
|
}
|
|
61
71
|
function moduleToPnpmStorePattern(moduleName) {
|
|
62
72
|
return moduleName.replace("/", "+");
|
|
63
73
|
}
|
|
64
74
|
async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
65
75
|
const patchModuleNames = [...new Set(patches.map((p) => p.module))];
|
|
66
|
-
const nodeModulesDirs =
|
|
67
|
-
const dir = join(root, relativePath);
|
|
76
|
+
const nodeModulesDirs = findNodeModulesDirs(root).flatMap((dir) => {
|
|
68
77
|
const dirs = [dir];
|
|
69
78
|
const pnpmBase = join(dir, ".pnpm");
|
|
70
|
-
if (!
|
|
79
|
+
if (!existsSync(pnpmBase)) return dirs;
|
|
71
80
|
const pnpmHoistedDir = join(pnpmBase, "node_modules");
|
|
72
|
-
if (
|
|
81
|
+
if (existsSync(pnpmHoistedDir)) {
|
|
73
82
|
dirs.push(pnpmHoistedDir);
|
|
74
83
|
}
|
|
75
84
|
for (const moduleName of patchModuleNames) {
|
|
@@ -93,7 +102,7 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
93
102
|
await Promise.all(patches.map(async (patch) => {
|
|
94
103
|
try {
|
|
95
104
|
const nodeModuleDir = join(nodeModulesDir, patch.module);
|
|
96
|
-
if (!
|
|
105
|
+
if (!existsSync(nodeModuleDir)) return;
|
|
97
106
|
let realModuleDir;
|
|
98
107
|
try {
|
|
99
108
|
realModuleDir = realpathSync(nodeModuleDir);
|
|
@@ -106,7 +115,7 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
106
115
|
patchedRealPaths.add(dedupKey);
|
|
107
116
|
const version = patch.patchFiles.version;
|
|
108
117
|
if (typeof version === "string") {
|
|
109
|
-
const pkgJSON = await
|
|
118
|
+
const pkgJSON = await readJSON(join(nodeModuleDir, "package.json"));
|
|
110
119
|
if (!semver.satisfies(pkgJSON.version, version)) return;
|
|
111
120
|
}
|
|
112
121
|
const filePatches = [];
|
|
@@ -123,11 +132,11 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
123
132
|
const fileStatsResults = await Promise.all(filePatches.map(async ({ relativePath }) => {
|
|
124
133
|
const fullPath = join(nodeModuleDir, relativePath);
|
|
125
134
|
try {
|
|
126
|
-
const
|
|
135
|
+
const fileStat = await stat(fullPath);
|
|
127
136
|
return {
|
|
128
137
|
relativePath,
|
|
129
138
|
fullPath,
|
|
130
|
-
stat,
|
|
139
|
+
stat: fileStat,
|
|
131
140
|
exists: true
|
|
132
141
|
};
|
|
133
142
|
} catch {
|
|
@@ -139,12 +148,12 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
139
148
|
};
|
|
140
149
|
}
|
|
141
150
|
}));
|
|
142
|
-
const filesToProcess = fileStatsResults.filter(({ fullPath, stat, exists }) => {
|
|
143
|
-
if (!exists || !
|
|
151
|
+
const filesToProcess = fileStatsResults.filter(({ fullPath, stat: fileStat, exists }) => {
|
|
152
|
+
if (!exists || !fileStat) return false;
|
|
144
153
|
if (process.env.VXRN_FORCE_PATCH) return true;
|
|
145
154
|
const cached = patchStats[fullPath];
|
|
146
155
|
if (!cached) return true;
|
|
147
|
-
return
|
|
156
|
+
return fileStat.size !== cached.size || fileStat.mtimeMs !== cached.mtimeMs;
|
|
148
157
|
});
|
|
149
158
|
if (filesToProcess.length === 0) {
|
|
150
159
|
if (!results.has(patch.module)) {
|
|
@@ -157,7 +166,7 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
157
166
|
try {
|
|
158
167
|
const patchDef = filePatches.find((p) => p.relativePath === relativePath).patchDefinition;
|
|
159
168
|
const originalPath = getOriginalPath(fullPath);
|
|
160
|
-
const [targetContent, originalContent] = await Promise.all([
|
|
169
|
+
const [targetContent, originalContent] = await Promise.all([readFile(fullPath, "utf-8"), readFile(originalPath, "utf-8").catch(() => null)]);
|
|
161
170
|
const sourceContent = originalContent ?? targetContent;
|
|
162
171
|
let patchedContent = null;
|
|
163
172
|
if (typeof patchDef === "string") {
|
|
@@ -200,19 +209,19 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
200
209
|
}
|
|
201
210
|
if (patchedContent !== null) {
|
|
202
211
|
if (targetContent === patchedContent) {
|
|
203
|
-
const
|
|
212
|
+
const fileStat2 = await stat(fullPath);
|
|
204
213
|
patchStats[fullPath] = {
|
|
205
|
-
size:
|
|
206
|
-
mtimeMs:
|
|
214
|
+
size: fileStat2.size,
|
|
215
|
+
mtimeMs: fileStat2.mtimeMs
|
|
207
216
|
};
|
|
208
217
|
statsChanged = true;
|
|
209
218
|
return;
|
|
210
219
|
}
|
|
211
220
|
await Promise.all([originalContent === null && atomicWriteFile(originalPath, sourceContent), atomicWriteFile(fullPath, patchedContent)]);
|
|
212
|
-
const
|
|
221
|
+
const fileStat = await stat(fullPath);
|
|
213
222
|
patchStats[fullPath] = {
|
|
214
|
-
size:
|
|
215
|
-
mtimeMs:
|
|
223
|
+
size: fileStat.size,
|
|
224
|
+
mtimeMs: fileStat.mtimeMs
|
|
216
225
|
};
|
|
217
226
|
statsChanged = true;
|
|
218
227
|
didApplyPatch = true;
|
|
@@ -220,10 +229,10 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
220
229
|
console.info(` - Applied patch to ${patch.module}: ${relativePath}`);
|
|
221
230
|
}
|
|
222
231
|
} else {
|
|
223
|
-
const
|
|
232
|
+
const fileStat = await stat(fullPath);
|
|
224
233
|
patchStats[fullPath] = {
|
|
225
|
-
size:
|
|
226
|
-
mtimeMs:
|
|
234
|
+
size: fileStat.size,
|
|
235
|
+
mtimeMs: fileStat.mtimeMs
|
|
227
236
|
};
|
|
228
237
|
statsChanged = true;
|
|
229
238
|
}
|
|
@@ -256,7 +265,7 @@ async function applyDependencyPatches(patches, { root = process.cwd() } = {}) {
|
|
|
256
265
|
}
|
|
257
266
|
async function atomicWriteFile(filePath, contents) {
|
|
258
267
|
const tempPath = filePath + ".vxrn.tmp." + process.pid + "." + Date.now();
|
|
259
|
-
await
|
|
268
|
+
await writeFile(tempPath, contents);
|
|
260
269
|
await rename(tempPath, filePath);
|
|
261
270
|
}
|
|
262
271
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patches.js","names":[],"sources":["utils/patches.js"],"sourcesContent":["import { transformSWC } from \"@vxrn/compiler\";\nimport { transformFlowBabel } from \"@vxrn/vite-flow\";\nimport Glob from \"fast-glob\";\nimport findNodeModules from \"find-node-modules\";\nimport FSExtra from \"fs-extra\";\nimport { realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { rename } from \"node:fs/promises\";\nimport semver from \"semver\";\nimport { builtInDepPatches } from \"../patches/builtInDepPatches\";\nimport { globDir } from \"./globDir\";\nclass Bail extends Error {\n}\nfunction bailIfUnchanged(obj1, obj2) {\n if (JSON.stringify(obj1) === JSON.stringify(obj2)) {\n throw new Bail();\n }\n}\nfunction bailIfExists(haystack, needle) {\n if (haystack.includes(needle)) {\n throw new Bail();\n }\n}\nasync function applyBuiltInPatches(options, extraPatches) {\n const all = [...builtInDepPatches];\n if (extraPatches) {\n for (const key in extraPatches) {\n const extraPatchFiles = extraPatches[key];\n const existing = all.find((x) => x.module === key);\n if (existing) {\n for (const patchKey in extraPatchFiles) {\n if (existing.patchFiles[patchKey]) {\n console.warn(\n `Warning: Overwriting One built-in patch with user patch`,\n key,\n patchKey\n );\n }\n existing.patchFiles[patchKey] = extraPatchFiles[patchKey];\n }\n } else {\n all.push({ module: key, patchFiles: extraPatchFiles });\n }\n }\n }\n await applyDependencyPatches(all, { root: options.root });\n}\nconst STATS_FILE = \".vxrn.patch-stats.json\";\nfunction getOriginalPath(fullPath) {\n return fullPath + \".vxrn.original\";\n}\nasync function readPatchStats(nodeModulesDir) {\n try {\n return await FSExtra.readJSON(join(nodeModulesDir, STATS_FILE));\n } catch {\n return {};\n }\n}\nasync function writePatchStats(nodeModulesDir, stats) {\n await FSExtra.writeJSON(join(nodeModulesDir, STATS_FILE), stats);\n}\nfunction moduleToPnpmStorePattern(moduleName) {\n return moduleName.replace(\"/\", \"+\");\n}\nasync function applyDependencyPatches(patches, { root = process.cwd() } = {}) {\n const patchModuleNames = [...new Set(patches.map((p) => p.module))];\n const nodeModulesDirs = findNodeModules({ cwd: root }).flatMap((relativePath) => {\n const dir = join(root, relativePath);\n const dirs = [dir];\n const pnpmBase = join(dir, \".pnpm\");\n if (!FSExtra.existsSync(pnpmBase)) return dirs;\n const pnpmHoistedDir = join(pnpmBase, \"node_modules\");\n if (FSExtra.existsSync(pnpmHoistedDir)) {\n dirs.push(pnpmHoistedDir);\n }\n for (const moduleName of patchModuleNames) {\n const storePattern = moduleToPnpmStorePattern(moduleName);\n const storeMatches = Glob.sync(`${storePattern}@*/node_modules`, {\n cwd: pnpmBase,\n onlyDirectories: true\n });\n for (const match of storeMatches) {\n dirs.push(join(pnpmBase, match));\n }\n }\n return dirs;\n });\n const results = /* @__PURE__ */ new Map();\n const transformWarnedModules = /* @__PURE__ */ new Set();\n const patchedRealPaths = /* @__PURE__ */ new Set();\n await Promise.all(\n nodeModulesDirs.map(async (nodeModulesDir) => {\n const patchStats = await readPatchStats(nodeModulesDir);\n let statsChanged = false;\n await Promise.all(\n patches.map(async (patch) => {\n try {\n const nodeModuleDir = join(nodeModulesDir, patch.module);\n if (!FSExtra.existsSync(nodeModuleDir)) return;\n let realModuleDir;\n try {\n realModuleDir = realpathSync(nodeModuleDir);\n } catch {\n return;\n }\n const patchIdx = patches.indexOf(patch);\n const dedupKey = `${patchIdx}\\0${realModuleDir}`;\n if (patchedRealPaths.has(dedupKey)) return;\n patchedRealPaths.add(dedupKey);\n const version = patch.patchFiles.version;\n if (typeof version === \"string\") {\n const pkgJSON = await FSExtra.readJSON(join(nodeModuleDir, \"package.json\"));\n if (!semver.satisfies(pkgJSON.version, version)) return;\n }\n const filePatches = [];\n for (const file in patch.patchFiles) {\n if (file === \"version\") continue;\n const filesToApply = file.includes(\"*\") ? globDir(nodeModuleDir, file) : [file];\n for (const relativePath of filesToApply) {\n filePatches.push({\n relativePath,\n patchDefinition: patch.patchFiles[file]\n });\n }\n }\n const fileStatsResults = await Promise.all(\n filePatches.map(async ({ relativePath }) => {\n const fullPath = join(nodeModuleDir, relativePath);\n try {\n const stat = await FSExtra.stat(fullPath);\n return { relativePath, fullPath, stat, exists: true };\n } catch {\n return { relativePath, fullPath, stat: null, exists: false };\n }\n })\n );\n const filesToProcess = fileStatsResults.filter(\n ({ fullPath, stat, exists }) => {\n if (!exists || !stat) return false;\n if (process.env.VXRN_FORCE_PATCH) return true;\n const cached = patchStats[fullPath];\n if (!cached) return true;\n return stat.size !== cached.size || stat.mtimeMs !== cached.mtimeMs;\n }\n );\n if (filesToProcess.length === 0) {\n if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n return;\n }\n let didApplyPatch = false;\n await Promise.all(\n filesToProcess.map(async ({ relativePath, fullPath }) => {\n try {\n const patchDef = filePatches.find(\n (p) => p.relativePath === relativePath\n ).patchDefinition;\n const originalPath = getOriginalPath(fullPath);\n const [targetContent, originalContent] = await Promise.all([\n FSExtra.readFile(fullPath, \"utf-8\"),\n FSExtra.readFile(originalPath, \"utf-8\").catch(() => null)\n ]);\n const sourceContent = originalContent ?? targetContent;\n let patchedContent = null;\n if (typeof patchDef === \"string\") {\n patchedContent = patchDef;\n } else if (Array.isArray(patchDef)) {\n try {\n let contents = sourceContent;\n for (const strategy of patchDef) {\n if (strategy === \"flow\") {\n contents = await transformFlowBabel(contents);\n }\n if (strategy === \"swc\" || strategy === \"jsx\") {\n contents = (await transformSWC(fullPath, contents, {\n mode: \"build\",\n environment: \"ios\",\n forceJSX: strategy === \"jsx\",\n noHMR: true,\n fixNonTypeSpecificImports: true,\n // a patch is written to node_modules ONCE and then read by\n // every later build, dev and production alike, so its output\n // has to be valid in both. the automatic JSX runtime is not:\n // its dev form emits `jsxDEV` from react/jsx-dev-runtime, and\n // React's production build exports `jsxDEV = void 0`, so a\n // patched dependency that renders JSX throws \"undefined is not\n // a function\" from render in any production bundle. `jsx`/`jsxs`\n // work in both builds, and refresh is already off for\n // node_modules, so the stable runtime is the only correct output.\n production: true\n }))?.code || contents;\n }\n }\n if (contents !== sourceContent) {\n patchedContent = contents;\n }\n } catch (transformErr) {\n if (!transformWarnedModules.has(patch.module)) {\n transformWarnedModules.add(patch.module);\n console.warn(\n ` \\u26A0 Patch transform failed for ${patch.module} in ${relativePath}, skipping non-critical patch: ${transformErr?.stack ?? transformErr}`\n );\n }\n return;\n }\n } else {\n const out = await patchDef(sourceContent);\n if (typeof out === \"string\" && out !== sourceContent) {\n patchedContent = out;\n } else if (typeof out === \"string\") {\n console.warn(\n `[vxrn] patch for ${patch.module} matched nothing in ${relativePath} \\u2014 it is stale and is no longer protecting anything`\n );\n }\n }\n if (patchedContent !== null) {\n if (targetContent === patchedContent) {\n const stat2 = await FSExtra.stat(fullPath);\n patchStats[fullPath] = { size: stat2.size, mtimeMs: stat2.mtimeMs };\n statsChanged = true;\n return;\n }\n await Promise.all([\n originalContent === null && atomicWriteFile(originalPath, sourceContent),\n atomicWriteFile(fullPath, patchedContent)\n ]);\n const stat = await FSExtra.stat(fullPath);\n patchStats[fullPath] = { size: stat.size, mtimeMs: stat.mtimeMs };\n statsChanged = true;\n didApplyPatch = true;\n if (process.env.DEBUG) {\n console.info(\n ` - Applied patch to ${patch.module}: ${relativePath}`\n );\n }\n } else {\n const stat = await FSExtra.stat(fullPath);\n patchStats[fullPath] = { size: stat.size, mtimeMs: stat.mtimeMs };\n statsChanged = true;\n }\n } catch (err) {\n if (err instanceof Bail) return;\n throw err;\n }\n })\n );\n if (didApplyPatch) {\n results.set(patch.module, \"applied\");\n } else if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n } catch (err) {\n console.error(`\\u{1F6A8} Error applying patch to`, patch.module);\n console.error(err);\n }\n })\n );\n if (statsChanged) {\n await writePatchStats(nodeModulesDir, patchStats);\n }\n })\n );\n for (const [module, result] of results) {\n if (result === \"applied\") {\n console.info(` \\u{1FA79} ${module}`);\n } else if (result === \"ok\" && process.env.VXRN_FORCE_PATCH) {\n console.info(` \\u2713 ${module}`);\n }\n }\n}\nasync function atomicWriteFile(filePath, contents) {\n const tempPath = filePath + \".vxrn.tmp.\" + process.pid + \".\" + Date.now();\n await FSExtra.writeFile(tempPath, contents);\n await rename(tempPath, filePath);\n}\nexport {\n applyBuiltInPatches,\n applyDependencyPatches,\n bailIfExists,\n bailIfUnchanged,\n moduleToPnpmStorePattern\n};\n//# sourceMappingURL=pat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Ae,gBAAgB,UAAU,UAAU;CACjD,MAAM,WAAW,WAAW,eAAe,QAAQ,MAAM,MAAM,KAAK,IAAI;CACxE,MAAM,QAAQ,UAAU,UAAU,QAAQ;CAC1C,MAAM,OAAO,UAAU,QAAQ;AACjC"}
|
|
1
|
+
{"version":3,"file":"patches.js","names":[],"sources":["utils/patches.js"],"sourcesContent":["import { transformSWC } from \"@vxrn/compiler\";\nimport { transformFlowBabel } from \"@vxrn/vite-flow\";\nimport Glob from \"fast-glob\";\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { readFile, rename, stat, writeFile } from \"node:fs/promises\";\nimport semver from \"semver\";\nimport { builtInDepPatches } from \"../patches/builtInDepPatches\";\nimport { readJSON, writeJSON } from \"./fs\";\nimport { globDir } from \"./globDir\";\nfunction findNodeModulesDirs(root) {\n const dirs = [];\n let dir = resolve(root);\n for (; ; ) {\n const candidate = join(dir, \"node_modules\");\n if (existsSync(candidate)) dirs.push(candidate);\n const parent = dirname(dir);\n if (parent === dir) return dirs;\n dir = parent;\n }\n}\nclass Bail extends Error {\n}\nfunction bailIfUnchanged(obj1, obj2) {\n if (JSON.stringify(obj1) === JSON.stringify(obj2)) {\n throw new Bail();\n }\n}\nfunction bailIfExists(haystack, needle) {\n if (haystack.includes(needle)) {\n throw new Bail();\n }\n}\nasync function applyBuiltInPatches(options, extraPatches) {\n const all = [...builtInDepPatches];\n if (extraPatches) {\n for (const key in extraPatches) {\n const extraPatchFiles = extraPatches[key];\n const existing = all.find((x) => x.module === key);\n if (existing) {\n for (const patchKey in extraPatchFiles) {\n if (existing.patchFiles[patchKey]) {\n console.warn(\n `Warning: Overwriting One built-in patch with user patch`,\n key,\n patchKey\n );\n }\n existing.patchFiles[patchKey] = extraPatchFiles[patchKey];\n }\n } else {\n all.push({ module: key, patchFiles: extraPatchFiles });\n }\n }\n }\n await applyDependencyPatches(all, { root: options.root });\n}\nconst STATS_FILE = \".vxrn.patch-stats.json\";\nfunction getOriginalPath(fullPath) {\n return fullPath + \".vxrn.original\";\n}\nasync function readPatchStats(nodeModulesDir) {\n try {\n return await readJSON(join(nodeModulesDir, STATS_FILE));\n } catch {\n return {};\n }\n}\nasync function writePatchStats(nodeModulesDir, stats) {\n await writeJSON(join(nodeModulesDir, STATS_FILE), stats);\n}\nfunction moduleToPnpmStorePattern(moduleName) {\n return moduleName.replace(\"/\", \"+\");\n}\nasync function applyDependencyPatches(patches, { root = process.cwd() } = {}) {\n const patchModuleNames = [...new Set(patches.map((p) => p.module))];\n const nodeModulesDirs = findNodeModulesDirs(root).flatMap((dir) => {\n const dirs = [dir];\n const pnpmBase = join(dir, \".pnpm\");\n if (!existsSync(pnpmBase)) return dirs;\n const pnpmHoistedDir = join(pnpmBase, \"node_modules\");\n if (existsSync(pnpmHoistedDir)) {\n dirs.push(pnpmHoistedDir);\n }\n for (const moduleName of patchModuleNames) {\n const storePattern = moduleToPnpmStorePattern(moduleName);\n const storeMatches = Glob.sync(`${storePattern}@*/node_modules`, {\n cwd: pnpmBase,\n onlyDirectories: true\n });\n for (const match of storeMatches) {\n dirs.push(join(pnpmBase, match));\n }\n }\n return dirs;\n });\n const results = /* @__PURE__ */ new Map();\n const transformWarnedModules = /* @__PURE__ */ new Set();\n const patchedRealPaths = /* @__PURE__ */ new Set();\n await Promise.all(\n nodeModulesDirs.map(async (nodeModulesDir) => {\n const patchStats = await readPatchStats(nodeModulesDir);\n let statsChanged = false;\n await Promise.all(\n patches.map(async (patch) => {\n try {\n const nodeModuleDir = join(nodeModulesDir, patch.module);\n if (!existsSync(nodeModuleDir)) return;\n let realModuleDir;\n try {\n realModuleDir = realpathSync(nodeModuleDir);\n } catch {\n return;\n }\n const patchIdx = patches.indexOf(patch);\n const dedupKey = `${patchIdx}\\0${realModuleDir}`;\n if (patchedRealPaths.has(dedupKey)) return;\n patchedRealPaths.add(dedupKey);\n const version = patch.patchFiles.version;\n if (typeof version === \"string\") {\n const pkgJSON = await readJSON(join(nodeModuleDir, \"package.json\"));\n if (!semver.satisfies(pkgJSON.version, version)) return;\n }\n const filePatches = [];\n for (const file in patch.patchFiles) {\n if (file === \"version\") continue;\n const filesToApply = file.includes(\"*\") ? globDir(nodeModuleDir, file) : [file];\n for (const relativePath of filesToApply) {\n filePatches.push({\n relativePath,\n patchDefinition: patch.patchFiles[file]\n });\n }\n }\n const fileStatsResults = await Promise.all(\n filePatches.map(async ({ relativePath }) => {\n const fullPath = join(nodeModuleDir, relativePath);\n try {\n const fileStat = await stat(fullPath);\n return { relativePath, fullPath, stat: fileStat, exists: true };\n } catch {\n return { relativePath, fullPath, stat: null, exists: false };\n }\n })\n );\n const filesToProcess = fileStatsResults.filter(\n ({ fullPath, stat: fileStat, exists }) => {\n if (!exists || !fileStat) return false;\n if (process.env.VXRN_FORCE_PATCH) return true;\n const cached = patchStats[fullPath];\n if (!cached) return true;\n return fileStat.size !== cached.size || fileStat.mtimeMs !== cached.mtimeMs;\n }\n );\n if (filesToProcess.length === 0) {\n if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n return;\n }\n let didApplyPatch = false;\n await Promise.all(\n filesToProcess.map(async ({ relativePath, fullPath }) => {\n try {\n const patchDef = filePatches.find(\n (p) => p.relativePath === relativePath\n ).patchDefinition;\n const originalPath = getOriginalPath(fullPath);\n const [targetContent, originalContent] = await Promise.all([\n readFile(fullPath, \"utf-8\"),\n readFile(originalPath, \"utf-8\").catch(() => null)\n ]);\n const sourceContent = originalContent ?? targetContent;\n let patchedContent = null;\n if (typeof patchDef === \"string\") {\n patchedContent = patchDef;\n } else if (Array.isArray(patchDef)) {\n try {\n let contents = sourceContent;\n for (const strategy of patchDef) {\n if (strategy === \"flow\") {\n contents = await transformFlowBabel(contents);\n }\n if (strategy === \"swc\" || strategy === \"jsx\") {\n contents = (await transformSWC(fullPath, contents, {\n mode: \"build\",\n environment: \"ios\",\n forceJSX: strategy === \"jsx\",\n noHMR: true,\n fixNonTypeSpecificImports: true,\n // a patch is written to node_modules ONCE and then read by\n // every later build, dev and production alike, so its output\n // has to be valid in both. the automatic JSX runtime is not:\n // its dev form emits `jsxDEV` from react/jsx-dev-runtime, and\n // React's production build exports `jsxDEV = void 0`, so a\n // patched dependency that renders JSX throws \"undefined is not\n // a function\" from render in any production bundle. `jsx`/`jsxs`\n // work in both builds, and refresh is already off for\n // node_modules, so the stable runtime is the only correct output.\n production: true\n }))?.code || contents;\n }\n }\n if (contents !== sourceContent) {\n patchedContent = contents;\n }\n } catch (transformErr) {\n if (!transformWarnedModules.has(patch.module)) {\n transformWarnedModules.add(patch.module);\n console.warn(\n ` \\u26A0 Patch transform failed for ${patch.module} in ${relativePath}, skipping non-critical patch: ${transformErr?.stack ?? transformErr}`\n );\n }\n return;\n }\n } else {\n const out = await patchDef(sourceContent);\n if (typeof out === \"string\" && out !== sourceContent) {\n patchedContent = out;\n } else if (typeof out === \"string\") {\n console.warn(\n `[vxrn] patch for ${patch.module} matched nothing in ${relativePath} \\u2014 it is stale and is no longer protecting anything`\n );\n }\n }\n if (patchedContent !== null) {\n if (targetContent === patchedContent) {\n const fileStat2 = await stat(fullPath);\n patchStats[fullPath] = { size: fileStat2.size, mtimeMs: fileStat2.mtimeMs };\n statsChanged = true;\n return;\n }\n await Promise.all([\n originalContent === null && atomicWriteFile(originalPath, sourceContent),\n atomicWriteFile(fullPath, patchedContent)\n ]);\n const fileStat = await stat(fullPath);\n patchStats[fullPath] = { size: fileStat.size, mtimeMs: fileStat.mtimeMs };\n statsChanged = true;\n didApplyPatch = true;\n if (process.env.DEBUG) {\n console.info(\n ` - Applied patch to ${patch.module}: ${relativePath}`\n );\n }\n } else {\n const fileStat = await stat(fullPath);\n patchStats[fullPath] = { size: fileStat.size, mtimeMs: fileStat.mtimeMs };\n statsChanged = true;\n }\n } catch (err) {\n if (err instanceof Bail) return;\n throw err;\n }\n })\n );\n if (didApplyPatch) {\n results.set(patch.module, \"applied\");\n } else if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n } catch (err) {\n console.error(`\\u{1F6A8} Error applying patch to`, patch.module);\n console.error(err);\n }\n })\n );\n if (statsChanged) {\n await writePatchStats(nodeModulesDir, patchStats);\n }\n })\n );\n for (const [module, result] of results) {\n if (result === \"applied\") {\n console.info(` \\u{1FA79} ${module}`);\n } else if (result === \"ok\" && process.env.VXRN_FORCE_PATCH) {\n console.info(` \\u2713 ${module}`);\n }\n }\n}\nasync function atomicWriteFile(filePath, contents) {\n const tempPath = filePath + \".vxrn.tmp.\" + process.pid + \".\" + Date.now();\n await writeFile(tempPath, contents);\n await rename(tempPath, filePath);\n}\nexport {\n applyBuiltInPatches,\n applyDependencyPatches,\n bailIfExists,\n bailIfUnchanged,\n moduleToPnpmStorePattern\n};\n//# sourceMappingURL=patches.js.map\n"],"mappings":";;;;;;;;;;;;AAUA,SAAS,oBAAoB,MAAM;CACjC,MAAM,OAAO,CAAC;CACd,IAAI,MAAM,QAAQ,IAAI;CACtB,SAAW;EACT,MAAM,YAAY,KAAK,KAAK,cAAc;EAC1C,IAAI,WAAW,SAAS,GAAG,KAAK,KAAK,SAAS;EAC9C,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF;AACA,IAAM,OAAN,cAAmB,MAAM,CACzB;AACA,SAAS,gBAAgB,MAAM,MAAM;CACnC,IAAI,KAAK,UAAU,IAAI,MAAM,KAAK,UAAU,IAAI,GAAG;EACjD,MAAM,IAAI,KAAK;CACjB;AACF;AACA,SAAS,aAAa,UAAU,QAAQ;CACtC,IAAI,SAAS,SAAS,MAAM,GAAG;EAC7B,MAAM,IAAI,KAAK;CACjB;AACF;AACA,eAAe,oBAAoB,SAAS,cAAc;CACxD,MAAM,MAAM,CAAC,GAAG,iBAAiB;CACjC,IAAI,cAAc;EAChB,KAAK,MAAM,OAAO,cAAc;GAC9B,MAAM,kBAAkB,aAAa;GACrC,MAAM,WAAW,IAAI,MAAM,MAAM,EAAE,WAAW,GAAG;GAC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Z,IAAI,eAAe,MAAM;MACzB,MAAM;KACR;IACF,CAAC,CACH;IACA,IAAI,eAAe;KACjB,QAAQ,IAAI,MAAM,QAAQ,SAAS;IACrC,OAAO,IAAI,CAAC,QAAQ,IAAI,MAAM,MAAM,GAAG;KACrC,QAAQ,IAAI,MAAM,QAAQ,IAAI;IAChC;GACF,SAAS,KAAK;IACZ,QAAQ,MAAM,qCAAqC,MAAM,MAAM;IAC/D,QAAQ,MAAM,GAAG;GACnB;EACF,CAAC,CACH;EACA,IAAI,cAAc;GAChB,MAAM,gBAAgB,gBAAgB,UAAU;EAClD;CACF,CAAC,CACH;CACA,KAAK,MAAM,CAAC,QAAQ,WAAW,SAAS;EACtC,IAAI,WAAW,WAAW;GACxB,QAAQ,KAAK,cAAc,QAAQ;EACrC,OAAO,IAAI,WAAW,QAAQ,QAAQ,IAAI,kBAAkB;GAC1D,QAAQ,KAAK,WAAW,QAAQ;EAClC;CACF;AACF;AACA,eAAe,gBAAgB,UAAU,UAAU;CACjD,MAAM,WAAW,WAAW,eAAe,QAAQ,MAAM,MAAM,KAAK,IAAI;CACxE,MAAM,UAAU,UAAU,QAAQ;CAClC,MAAM,OAAO,UAAU,QAAQ;AACjC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { transformSWC } from "@vxrn/compiler";
|
|
2
2
|
import { transformFlowBabel } from "@vxrn/vite-flow";
|
|
3
3
|
import Glob from "fast-glob";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { join } from "path";
|
|
8
|
-
import { rename } from "fs/promises";
|
|
4
|
+
import { existsSync, realpathSync } from "fs";
|
|
5
|
+
import { dirname, join, resolve } from "path";
|
|
6
|
+
import { readFile, rename, stat, writeFile } from "fs/promises";
|
|
9
7
|
import semver from "semver";
|
|
10
8
|
import { builtInDepPatches } from "../patches/builtInDepPatches.native.js";
|
|
9
|
+
import { readJSON, writeJSON } from "./fs.native.js";
|
|
11
10
|
import { globDir } from "./globDir.native.js";
|
|
12
11
|
|
|
13
12
|
function _assert_this_initialized(self) {
|
|
@@ -100,6 +99,17 @@ function _wrap_native_super(Class) {
|
|
|
100
99
|
};
|
|
101
100
|
return _wrap_native_super(Class);
|
|
102
101
|
}
|
|
102
|
+
function findNodeModulesDirs(root) {
|
|
103
|
+
var dirs = [];
|
|
104
|
+
var dir = resolve(root);
|
|
105
|
+
for (;;) {
|
|
106
|
+
var candidate = join(dir, "node_modules");
|
|
107
|
+
if (existsSync(candidate)) dirs.push(candidate);
|
|
108
|
+
var parent = dirname(dir);
|
|
109
|
+
if (parent === dir) return dirs;
|
|
110
|
+
dir = parent;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
103
113
|
var Bail = /* @__PURE__ */ (function(Error1) {
|
|
104
114
|
"use strict";
|
|
105
115
|
_inherits(Bail2, Error1);
|
|
@@ -151,13 +161,13 @@ function getOriginalPath(fullPath) {
|
|
|
151
161
|
}
|
|
152
162
|
async function readPatchStats(nodeModulesDir) {
|
|
153
163
|
try {
|
|
154
|
-
return await
|
|
164
|
+
return await readJSON(join(nodeModulesDir, STATS_FILE));
|
|
155
165
|
} catch (unused) {
|
|
156
166
|
return {};
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
async function writePatchStats(nodeModulesDir, stats) {
|
|
160
|
-
await
|
|
170
|
+
await writeJSON(join(nodeModulesDir, STATS_FILE), stats);
|
|
161
171
|
}
|
|
162
172
|
function moduleToPnpmStorePattern(moduleName) {
|
|
163
173
|
return moduleName.replace("/", "+");
|
|
@@ -167,13 +177,12 @@ async function applyDependencyPatches(patches) {
|
|
|
167
177
|
var patchModuleNames = [...new Set(patches.map(function(p) {
|
|
168
178
|
return p.module;
|
|
169
179
|
}))];
|
|
170
|
-
var nodeModulesDirs =
|
|
171
|
-
var dir = join(root, relativePath);
|
|
180
|
+
var nodeModulesDirs = findNodeModulesDirs(root).flatMap(function(dir) {
|
|
172
181
|
var dirs = [dir];
|
|
173
182
|
var pnpmBase = join(dir, ".pnpm");
|
|
174
|
-
if (!
|
|
183
|
+
if (!existsSync(pnpmBase)) return dirs;
|
|
175
184
|
var pnpmHoistedDir = join(pnpmBase, "node_modules");
|
|
176
|
-
if (
|
|
185
|
+
if (existsSync(pnpmHoistedDir)) {
|
|
177
186
|
dirs.push(pnpmHoistedDir);
|
|
178
187
|
}
|
|
179
188
|
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
@@ -231,7 +240,7 @@ async function applyDependencyPatches(patches) {
|
|
|
231
240
|
await Promise.all(patches.map(async function(patch) {
|
|
232
241
|
try {
|
|
233
242
|
var nodeModuleDir = join(nodeModulesDir, patch.module);
|
|
234
|
-
if (!
|
|
243
|
+
if (!existsSync(nodeModuleDir)) return;
|
|
235
244
|
var realModuleDir;
|
|
236
245
|
try {
|
|
237
246
|
realModuleDir = realpathSync(nodeModuleDir);
|
|
@@ -244,7 +253,7 @@ async function applyDependencyPatches(patches) {
|
|
|
244
253
|
patchedRealPaths.add(dedupKey);
|
|
245
254
|
var version = patch.patchFiles.version;
|
|
246
255
|
if (typeof version === "string") {
|
|
247
|
-
var pkgJSON = await
|
|
256
|
+
var pkgJSON = await readJSON(join(nodeModuleDir, "package.json"));
|
|
248
257
|
if (!semver.satisfies(pkgJSON.version, version)) return;
|
|
249
258
|
}
|
|
250
259
|
var filePatches = [];
|
|
@@ -279,11 +288,11 @@ async function applyDependencyPatches(patches) {
|
|
|
279
288
|
var { relativePath: relativePath2 } = param;
|
|
280
289
|
var fullPath = join(nodeModuleDir, relativePath2);
|
|
281
290
|
try {
|
|
282
|
-
var
|
|
291
|
+
var fileStat = await stat(fullPath);
|
|
283
292
|
return {
|
|
284
293
|
relativePath: relativePath2,
|
|
285
294
|
fullPath,
|
|
286
|
-
stat,
|
|
295
|
+
stat: fileStat,
|
|
287
296
|
exists: true
|
|
288
297
|
};
|
|
289
298
|
} catch (unused) {
|
|
@@ -296,12 +305,12 @@ async function applyDependencyPatches(patches) {
|
|
|
296
305
|
}
|
|
297
306
|
}));
|
|
298
307
|
var filesToProcess = fileStatsResults.filter(function(param) {
|
|
299
|
-
var { fullPath, stat, exists } = param;
|
|
300
|
-
if (!exists || !
|
|
308
|
+
var { fullPath, stat: fileStat, exists } = param;
|
|
309
|
+
if (!exists || !fileStat) return false;
|
|
301
310
|
if (process.env.VXRN_FORCE_PATCH) return true;
|
|
302
311
|
var cached = patchStats[fullPath];
|
|
303
312
|
if (!cached) return true;
|
|
304
|
-
return
|
|
313
|
+
return fileStat.size !== cached.size || fileStat.mtimeMs !== cached.mtimeMs;
|
|
305
314
|
});
|
|
306
315
|
if (filesToProcess.length === 0) {
|
|
307
316
|
if (!results.has(patch.module)) {
|
|
@@ -317,7 +326,7 @@ async function applyDependencyPatches(patches) {
|
|
|
317
326
|
return p.relativePath === relativePath2;
|
|
318
327
|
}).patchDefinition;
|
|
319
328
|
var originalPath = getOriginalPath(fullPath);
|
|
320
|
-
var [targetContent, originalContent] = await Promise.all([
|
|
329
|
+
var [targetContent, originalContent] = await Promise.all([readFile(fullPath, "utf-8"), readFile(originalPath, "utf-8").catch(function() {
|
|
321
330
|
return null;
|
|
322
331
|
})]);
|
|
323
332
|
var sourceContent = originalContent !== null && originalContent !== void 0 ? originalContent : targetContent;
|
|
@@ -381,19 +390,19 @@ async function applyDependencyPatches(patches) {
|
|
|
381
390
|
}
|
|
382
391
|
if (patchedContent !== null) {
|
|
383
392
|
if (targetContent === patchedContent) {
|
|
384
|
-
var
|
|
393
|
+
var fileStat = await stat(fullPath);
|
|
385
394
|
patchStats[fullPath] = {
|
|
386
|
-
size:
|
|
387
|
-
mtimeMs:
|
|
395
|
+
size: fileStat.size,
|
|
396
|
+
mtimeMs: fileStat.mtimeMs
|
|
388
397
|
};
|
|
389
398
|
statsChanged = true;
|
|
390
399
|
return;
|
|
391
400
|
}
|
|
392
401
|
await Promise.all([originalContent === null && atomicWriteFile(originalPath, sourceContent), atomicWriteFile(fullPath, patchedContent)]);
|
|
393
|
-
var
|
|
402
|
+
var fileStat1 = await stat(fullPath);
|
|
394
403
|
patchStats[fullPath] = {
|
|
395
|
-
size:
|
|
396
|
-
mtimeMs:
|
|
404
|
+
size: fileStat1.size,
|
|
405
|
+
mtimeMs: fileStat1.mtimeMs
|
|
397
406
|
};
|
|
398
407
|
statsChanged = true;
|
|
399
408
|
didApplyPatch = true;
|
|
@@ -401,10 +410,10 @@ async function applyDependencyPatches(patches) {
|
|
|
401
410
|
console.info(` - Applied patch to ${patch.module}: ${relativePath2}`);
|
|
402
411
|
}
|
|
403
412
|
} else {
|
|
404
|
-
var
|
|
413
|
+
var fileStat2 = await stat(fullPath);
|
|
405
414
|
patchStats[fullPath] = {
|
|
406
|
-
size:
|
|
407
|
-
mtimeMs:
|
|
415
|
+
size: fileStat2.size,
|
|
416
|
+
mtimeMs: fileStat2.mtimeMs
|
|
408
417
|
};
|
|
409
418
|
statsChanged = true;
|
|
410
419
|
}
|
|
@@ -454,7 +463,7 @@ async function applyDependencyPatches(patches) {
|
|
|
454
463
|
}
|
|
455
464
|
async function atomicWriteFile(filePath, contents) {
|
|
456
465
|
var tempPath = filePath + ".vxrn.tmp." + process.pid + "." + Date.now();
|
|
457
|
-
await
|
|
466
|
+
await writeFile(tempPath, contents);
|
|
458
467
|
await rename(tempPath, filePath);
|
|
459
468
|
}
|
|
460
469
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patches.native.js","names":[],"sources":["utils/patches.native.js"],"sourcesContent":["import { transformSWC } from \"@vxrn/compiler\";\nimport { transformFlowBabel } from \"@vxrn/vite-flow\";\nimport Glob from \"fast-glob\";\nimport findNodeModules from \"find-node-modules\";\nimport FSExtra from \"fs-extra\";\nimport { realpathSync } from \"fs\";\nimport { join } from \"path\";\nimport { rename } from \"fs/promises\";\nimport semver from \"semver\";\nimport { builtInDepPatches } from \"../patches/builtInDepPatches\";\nimport { globDir } from \"./globDir\";\nfunction _assert_this_initialized(self) {\n if (self === void 0) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n return self;\n}\nfunction _call_super(_this, derived, args) {\n derived = _get_prototype_of(derived);\n return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));\n}\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) throw new TypeError(\"Cannot call a class as a function\");\n}\nfunction _construct(Parent, args, Class) {\n if (_is_native_reflect_construct()) _construct = Reflect.construct;\n else {\n _construct = function construct(Parent2, args2, Class2) {\n var a = [\n null\n ];\n a.push.apply(a, args2);\n var Constructor = Function.bind.apply(Parent2, a);\n var instance = new Constructor();\n if (Class2) _set_prototype_of(instance, Class2.prototype);\n return instance;\n };\n }\n return _construct.apply(null, arguments);\n}\nfunction _get_prototype_of(o) {\n _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {\n return o2.__proto__ || Object.getPrototypeOf(o2);\n };\n return _get_prototype_of(o);\n}\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _set_prototype_of(subClass, superClass);\n}\nfunction _is_native_function(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\nfunction _is_native_reflect_construct() {\n try {\n var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {\n }));\n } catch (_) {\n }\n return (_is_native_reflect_construct = function() {\n return !!result;\n })();\n}\nfunction _possible_constructor_return(self, call) {\n if (call && (_type_of(call) === \"object\" || typeof call === \"function\")) return call;\n return _assert_this_initialized(self);\n}\nfunction _set_prototype_of(o, p) {\n _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {\n o2.__proto__ = p2;\n return o2;\n };\n return _set_prototype_of(o, p);\n}\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nfunction _wrap_native_super(Class) {\n var _cache = typeof Map === \"function\" ? /* @__PURE__ */ new Map() : void 0;\n _wrap_native_super = function(Class2) {\n if (Class2 === null || !_is_native_function(Class2)) return Class2;\n if (typeof Class2 !== \"function\") throw new TypeError(\"Super expression must either be null or a function\");\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class2)) return _cache.get(Class2);\n _cache.set(Class2, Wrapper);\n }\n function Wrapper() {\n return _construct(Class2, arguments, _get_prototype_of(this).constructor);\n }\n Wrapper.prototype = Object.create(Class2.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _set_prototype_of(Wrapper, Class2);\n };\n return _wrap_native_super(Class);\n}\nvar Bail = /* @__PURE__ */ (function(Error1) {\n \"use strict\";\n _inherits(Bail2, Error1);\n function Bail2() {\n _class_call_check(this, Bail2);\n return _call_super(this, Bail2, arguments);\n }\n return Bail2;\n})(_wrap_native_super(Error));\nfunction bailIfUnchanged(obj1, obj2) {\n if (JSON.stringify(obj1) === JSON.stringify(obj2)) {\n throw new Bail();\n }\n}\nfunction bailIfExists(haystack, needle) {\n if (haystack.includes(needle)) {\n throw new Bail();\n }\n}\nasync function applyBuiltInPatches(options, extraPatches) {\n var all = [\n ...builtInDepPatches\n ];\n if (extraPatches) {\n var _loop = function(key2) {\n var extraPatchFiles = extraPatches[key2];\n var existing = all.find(function(x) {\n return x.module === key2;\n });\n if (existing) {\n for (var patchKey in extraPatchFiles) {\n if (existing.patchFiles[patchKey]) {\n console.warn(`Warning: Overwriting One built-in patch with user patch`, key2, patchKey);\n }\n existing.patchFiles[patchKey] = extraPatchFiles[patchKey];\n }\n } else {\n all.push({\n module: key2,\n patchFiles: extraPatchFiles\n });\n }\n };\n for (var key in extraPatches) _loop(key);\n }\n await applyDependencyPatches(all, {\n root: options.root\n });\n}\nvar STATS_FILE = \".vxrn.patch-stats.json\";\nfunction getOriginalPath(fullPath) {\n return fullPath + \".vxrn.original\";\n}\nasync function readPatchStats(nodeModulesDir) {\n try {\n return await FSExtra.readJSON(join(nodeModulesDir, STATS_FILE));\n } catch (unused) {\n return {};\n }\n}\nasync function writePatchStats(nodeModulesDir, stats) {\n await FSExtra.writeJSON(join(nodeModulesDir, STATS_FILE), stats);\n}\nfunction moduleToPnpmStorePattern(moduleName) {\n return moduleName.replace(\"/\", \"+\");\n}\nasync function applyDependencyPatches(patches) {\n var { root = process.cwd() } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var patchModuleNames = [\n ...new Set(patches.map(function(p) {\n return p.module;\n }))\n ];\n var nodeModulesDirs = findNodeModules({\n cwd: root\n }).flatMap(function(relativePath) {\n var dir = join(root, relativePath);\n var dirs = [\n dir\n ];\n var pnpmBase = join(dir, \".pnpm\");\n if (!FSExtra.existsSync(pnpmBase)) return dirs;\n var pnpmHoistedDir = join(pnpmBase, \"node_modules\");\n if (FSExtra.existsSync(pnpmHoistedDir)) {\n dirs.push(pnpmHoistedDir);\n }\n var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n try {\n for (var _iterator2 = patchModuleNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var moduleName = _step2.value;\n var storePattern = moduleToPnpmStorePattern(moduleName);\n var storeMatches = Glob.sync(`${storePattern}@*/node_modules`, {\n cwd: pnpmBase,\n onlyDirectories: true\n });\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = storeMatches[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var match = _step1.value;\n dirs.push(join(pnpmBase, match));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n return dirs;\n });\n var results = /* @__PURE__ */ new Map();\n var transformWarnedModules = /* @__PURE__ */ new Set();\n var patchedRealPaths = /* @__PURE__ */ new Set();\n await Promise.all(nodeModulesDirs.map(async function(nodeModulesDir) {\n var patchStats = await readPatchStats(nodeModulesDir);\n var statsChanged = false;\n await Promise.all(patches.map(async function(patch) {\n try {\n var nodeModuleDir = join(nodeModulesDir, patch.module);\n if (!FSExtra.existsSync(nodeModuleDir)) return;\n var realModuleDir;\n try {\n realModuleDir = realpathSync(nodeModuleDir);\n } catch (unused) {\n return;\n }\n var patchIdx = patches.indexOf(patch);\n var dedupKey = `${patchIdx}\\0${realModuleDir}`;\n if (patchedRealPaths.has(dedupKey)) return;\n patchedRealPaths.add(dedupKey);\n var version = patch.patchFiles.version;\n if (typeof version === \"string\") {\n var pkgJSON = await FSExtra.readJSON(join(nodeModuleDir, \"package.json\"));\n if (!semver.satisfies(pkgJSON.version, version)) return;\n }\n var filePatches = [];\n for (var file in patch.patchFiles) {\n if (file === \"version\") continue;\n var filesToApply = file.includes(\"*\") ? globDir(nodeModuleDir, file) : [\n file\n ];\n var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n try {\n for (var _iterator2 = filesToApply[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var relativePath = _step2.value;\n filePatches.push({\n relativePath,\n patchDefinition: patch.patchFiles[file]\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n var fileStatsResults = await Promise.all(filePatches.map(async function(param) {\n var { relativePath: relativePath2 } = param;\n var fullPath = join(nodeModuleDir, relativePath2);\n try {\n var stat = await FSExtra.stat(fullPath);\n return {\n relativePath: relativePath2,\n fullPath,\n stat,\n exists: true\n };\n } catch (unused) {\n return {\n relativePath: relativePath2,\n fullPath,\n stat: null,\n exists: false\n };\n }\n }));\n var filesToProcess = fileStatsResults.filter(function(param) {\n var { fullPath, stat, exists } = param;\n if (!exists || !stat) return false;\n if (process.env.VXRN_FORCE_PATCH) return true;\n var cached = patchStats[fullPath];\n if (!cached) return true;\n return stat.size !== cached.size || stat.mtimeMs !== cached.mtimeMs;\n });\n if (filesToProcess.length === 0) {\n if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n return;\n }\n var didApplyPatch = false;\n await Promise.all(filesToProcess.map(async function(param) {\n var { relativePath: relativePath2, fullPath } = param;\n try {\n var patchDef = filePatches.find(function(p) {\n return p.relativePath === relativePath2;\n }).patchDefinition;\n var originalPath = getOriginalPath(fullPath);\n var [targetContent, originalContent] = await Promise.all([\n FSExtra.readFile(fullPath, \"utf-8\"),\n FSExtra.readFile(originalPath, \"utf-8\").catch(function() {\n return null;\n })\n ]);\n var sourceContent = originalContent !== null && originalContent !== void 0 ? originalContent : targetContent;\n var patchedContent = null;\n if (typeof patchDef === \"string\") {\n patchedContent = patchDef;\n } else if (Array.isArray(patchDef)) {\n try {\n var contents = sourceContent;\n var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;\n try {\n for (var _iterator3 = patchDef[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var strategy = _step3.value;\n if (strategy === \"flow\") {\n contents = await transformFlowBabel(contents);\n }\n if (strategy === \"swc\" || strategy === \"jsx\") {\n var _this;\n contents = ((_this = await transformSWC(fullPath, contents, {\n mode: \"build\",\n environment: \"ios\",\n forceJSX: strategy === \"jsx\",\n noHMR: true,\n fixNonTypeSpecificImports: true,\n // a patch is written to node_modules ONCE and then read by\n // every later build, dev and production alike, so its output\n // has to be valid in both. the automatic JSX runtime is not:\n // its dev form emits `jsxDEV` from react/jsx-dev-runtime, and\n // React's production build exports `jsxDEV = void 0`, so a\n // patched dependency that renders JSX throws \"undefined is not\n // a function\" from render in any production bundle. `jsx`/`jsxs`\n // work in both builds, and refresh is already off for\n // node_modules, so the stable runtime is the only correct output.\n production: true\n })) === null || _this === void 0 ? void 0 : _this.code) || contents;\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n if (contents !== sourceContent) {\n patchedContent = contents;\n }\n } catch (transformErr) {\n if (!transformWarnedModules.has(patch.module)) {\n var _ref;\n transformWarnedModules.add(patch.module);\n console.warn(` \\u26A0 Patch transform failed for ${patch.module} in ${relativePath2}, skipping non-critical patch: ${(_ref = transformErr === null || transformErr === void 0 ? void 0 : transformErr.stack) !== null && _ref !== void 0 ? _ref : transformErr}`);\n }\n return;\n }\n } else {\n var out = await patchDef(sourceContent);\n if (typeof out === \"string\" && out !== sourceContent) {\n patchedContent = out;\n } else if (typeof out === \"string\") {\n console.warn(`[vxrn] patch for ${patch.module} matched nothing in ${relativePath2} \\u2014 it is stale and is no longer protecting anything`);\n }\n }\n if (patchedContent !== null) {\n if (targetContent === patchedContent) {\n var stat = await FSExtra.stat(fullPath);\n patchStats[fullPath] = {\n size: stat.size,\n mtimeMs: stat.mtimeMs\n };\n statsChanged = true;\n return;\n }\n await Promise.all([\n originalContent === null && atomicWriteFile(originalPath, sourceContent),\n atomicWriteFile(fullPath, patchedContent)\n ]);\n var stat1 = await FSExtra.stat(fullPath);\n patchStats[fullPath] = {\n size: stat1.size,\n mtimeMs: stat1.mtimeMs\n };\n statsChanged = true;\n didApplyPatch = true;\n if (process.env.DEBUG) {\n console.info(` - Applied patch to ${patch.module}: ${relativePath2}`);\n }\n } else {\n var stat2 = await FSExtra.stat(fullPath);\n patchStats[fullPath] = {\n size: stat2.size,\n mtimeMs: stat2.mtimeMs\n };\n statsChanged = true;\n }\n } catch (err) {\n if (err instanceof Bail) return;\n throw err;\n }\n }));\n if (didApplyPatch) {\n results.set(patch.module, \"applied\");\n } else if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n } catch (err) {\n console.error(`\\u{1F6A8} Error applying patch to`, patch.module);\n console.error(err);\n }\n }));\n if (statsChanged) {\n await writePatchStats(nodeModulesDir, patchStats);\n }\n }));\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = results[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var [module, result] = _step.value;\n if (result === \"applied\") {\n console.info(` \\u{1FA79} ${module}`);\n } else if (result === \"ok\" && process.env.VXRN_FORCE_PATCH) {\n console.info(` \\u2713 ${module}`);\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nasync function atomicWriteFile(filePath, contents) {\n var tempPath = filePath + \".vxrn.tmp.\" + process.pid + \".\" + Date.now();\n await FSExtra.writeFile(tempPath, contents);\n await rename(tempPath, filePath);\n}\nexport {\n applyBuiltInPatches,\n applyDependencyPatches,\n bailIfExists,\n bailIfUnchanged,\n moduleToPnpmStorePattern\n};\n//# sourceMappingURL=patches.js.map\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAS,yBAAyB,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UAAU;EACR,IAAI;GACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;IAC1D,UAAU,OAAO;GACnB;EACF,UAAU;GACR,IAAI,mBAAmB;IACrB,MAAM;GACR;EACF;CACF;AACF;AACA,eAAe,gBAAgB,UAAU,UAAU;CACjD,IAAI,WAAW,WAAW,eAAe,QAAQ,MAAM,MAAM,KAAK,IAAI;CACtE,MAAM,QAAQ,UAAU,UAAU,QAAQ;CAC1C,MAAM,OAAO,UAAU,QAAQ;AACjC"}
|
|
1
|
+
{"version":3,"file":"patches.native.js","names":[],"sources":["utils/patches.native.js"],"sourcesContent":["import { transformSWC } from \"@vxrn/compiler\";\nimport { transformFlowBabel } from \"@vxrn/vite-flow\";\nimport Glob from \"fast-glob\";\nimport { existsSync, realpathSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { readFile, rename, stat, writeFile } from \"fs/promises\";\nimport semver from \"semver\";\nimport { builtInDepPatches } from \"../patches/builtInDepPatches\";\nimport { readJSON, writeJSON } from \"./fs\";\nimport { globDir } from \"./globDir\";\nfunction _assert_this_initialized(self) {\n if (self === void 0) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n return self;\n}\nfunction _call_super(_this, derived, args) {\n derived = _get_prototype_of(derived);\n return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));\n}\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) throw new TypeError(\"Cannot call a class as a function\");\n}\nfunction _construct(Parent, args, Class) {\n if (_is_native_reflect_construct()) _construct = Reflect.construct;\n else {\n _construct = function construct(Parent2, args2, Class2) {\n var a = [\n null\n ];\n a.push.apply(a, args2);\n var Constructor = Function.bind.apply(Parent2, a);\n var instance = new Constructor();\n if (Class2) _set_prototype_of(instance, Class2.prototype);\n return instance;\n };\n }\n return _construct.apply(null, arguments);\n}\nfunction _get_prototype_of(o) {\n _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {\n return o2.__proto__ || Object.getPrototypeOf(o2);\n };\n return _get_prototype_of(o);\n}\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _set_prototype_of(subClass, superClass);\n}\nfunction _is_native_function(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\nfunction _is_native_reflect_construct() {\n try {\n var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {\n }));\n } catch (_) {\n }\n return (_is_native_reflect_construct = function() {\n return !!result;\n })();\n}\nfunction _possible_constructor_return(self, call) {\n if (call && (_type_of(call) === \"object\" || typeof call === \"function\")) return call;\n return _assert_this_initialized(self);\n}\nfunction _set_prototype_of(o, p) {\n _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {\n o2.__proto__ = p2;\n return o2;\n };\n return _set_prototype_of(o, p);\n}\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nfunction _wrap_native_super(Class) {\n var _cache = typeof Map === \"function\" ? /* @__PURE__ */ new Map() : void 0;\n _wrap_native_super = function(Class2) {\n if (Class2 === null || !_is_native_function(Class2)) return Class2;\n if (typeof Class2 !== \"function\") throw new TypeError(\"Super expression must either be null or a function\");\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class2)) return _cache.get(Class2);\n _cache.set(Class2, Wrapper);\n }\n function Wrapper() {\n return _construct(Class2, arguments, _get_prototype_of(this).constructor);\n }\n Wrapper.prototype = Object.create(Class2.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _set_prototype_of(Wrapper, Class2);\n };\n return _wrap_native_super(Class);\n}\nfunction findNodeModulesDirs(root) {\n var dirs = [];\n var dir = resolve(root);\n for (; ; ) {\n var candidate = join(dir, \"node_modules\");\n if (existsSync(candidate)) dirs.push(candidate);\n var parent = dirname(dir);\n if (parent === dir) return dirs;\n dir = parent;\n }\n}\nvar Bail = /* @__PURE__ */ (function(Error1) {\n \"use strict\";\n _inherits(Bail2, Error1);\n function Bail2() {\n _class_call_check(this, Bail2);\n return _call_super(this, Bail2, arguments);\n }\n return Bail2;\n})(_wrap_native_super(Error));\nfunction bailIfUnchanged(obj1, obj2) {\n if (JSON.stringify(obj1) === JSON.stringify(obj2)) {\n throw new Bail();\n }\n}\nfunction bailIfExists(haystack, needle) {\n if (haystack.includes(needle)) {\n throw new Bail();\n }\n}\nasync function applyBuiltInPatches(options, extraPatches) {\n var all = [\n ...builtInDepPatches\n ];\n if (extraPatches) {\n var _loop = function(key2) {\n var extraPatchFiles = extraPatches[key2];\n var existing = all.find(function(x) {\n return x.module === key2;\n });\n if (existing) {\n for (var patchKey in extraPatchFiles) {\n if (existing.patchFiles[patchKey]) {\n console.warn(`Warning: Overwriting One built-in patch with user patch`, key2, patchKey);\n }\n existing.patchFiles[patchKey] = extraPatchFiles[patchKey];\n }\n } else {\n all.push({\n module: key2,\n patchFiles: extraPatchFiles\n });\n }\n };\n for (var key in extraPatches) _loop(key);\n }\n await applyDependencyPatches(all, {\n root: options.root\n });\n}\nvar STATS_FILE = \".vxrn.patch-stats.json\";\nfunction getOriginalPath(fullPath) {\n return fullPath + \".vxrn.original\";\n}\nasync function readPatchStats(nodeModulesDir) {\n try {\n return await readJSON(join(nodeModulesDir, STATS_FILE));\n } catch (unused) {\n return {};\n }\n}\nasync function writePatchStats(nodeModulesDir, stats) {\n await writeJSON(join(nodeModulesDir, STATS_FILE), stats);\n}\nfunction moduleToPnpmStorePattern(moduleName) {\n return moduleName.replace(\"/\", \"+\");\n}\nasync function applyDependencyPatches(patches) {\n var { root = process.cwd() } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var patchModuleNames = [\n ...new Set(patches.map(function(p) {\n return p.module;\n }))\n ];\n var nodeModulesDirs = findNodeModulesDirs(root).flatMap(function(dir) {\n var dirs = [\n dir\n ];\n var pnpmBase = join(dir, \".pnpm\");\n if (!existsSync(pnpmBase)) return dirs;\n var pnpmHoistedDir = join(pnpmBase, \"node_modules\");\n if (existsSync(pnpmHoistedDir)) {\n dirs.push(pnpmHoistedDir);\n }\n var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n try {\n for (var _iterator2 = patchModuleNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var moduleName = _step2.value;\n var storePattern = moduleToPnpmStorePattern(moduleName);\n var storeMatches = Glob.sync(`${storePattern}@*/node_modules`, {\n cwd: pnpmBase,\n onlyDirectories: true\n });\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = storeMatches[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var match = _step1.value;\n dirs.push(join(pnpmBase, match));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n return dirs;\n });\n var results = /* @__PURE__ */ new Map();\n var transformWarnedModules = /* @__PURE__ */ new Set();\n var patchedRealPaths = /* @__PURE__ */ new Set();\n await Promise.all(nodeModulesDirs.map(async function(nodeModulesDir) {\n var patchStats = await readPatchStats(nodeModulesDir);\n var statsChanged = false;\n await Promise.all(patches.map(async function(patch) {\n try {\n var nodeModuleDir = join(nodeModulesDir, patch.module);\n if (!existsSync(nodeModuleDir)) return;\n var realModuleDir;\n try {\n realModuleDir = realpathSync(nodeModuleDir);\n } catch (unused) {\n return;\n }\n var patchIdx = patches.indexOf(patch);\n var dedupKey = `${patchIdx}\\0${realModuleDir}`;\n if (patchedRealPaths.has(dedupKey)) return;\n patchedRealPaths.add(dedupKey);\n var version = patch.patchFiles.version;\n if (typeof version === \"string\") {\n var pkgJSON = await readJSON(join(nodeModuleDir, \"package.json\"));\n if (!semver.satisfies(pkgJSON.version, version)) return;\n }\n var filePatches = [];\n for (var file in patch.patchFiles) {\n if (file === \"version\") continue;\n var filesToApply = file.includes(\"*\") ? globDir(nodeModuleDir, file) : [\n file\n ];\n var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n try {\n for (var _iterator2 = filesToApply[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var relativePath = _step2.value;\n filePatches.push({\n relativePath,\n patchDefinition: patch.patchFiles[file]\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n var fileStatsResults = await Promise.all(filePatches.map(async function(param) {\n var { relativePath: relativePath2 } = param;\n var fullPath = join(nodeModuleDir, relativePath2);\n try {\n var fileStat = await stat(fullPath);\n return {\n relativePath: relativePath2,\n fullPath,\n stat: fileStat,\n exists: true\n };\n } catch (unused) {\n return {\n relativePath: relativePath2,\n fullPath,\n stat: null,\n exists: false\n };\n }\n }));\n var filesToProcess = fileStatsResults.filter(function(param) {\n var { fullPath, stat: fileStat, exists } = param;\n if (!exists || !fileStat) return false;\n if (process.env.VXRN_FORCE_PATCH) return true;\n var cached = patchStats[fullPath];\n if (!cached) return true;\n return fileStat.size !== cached.size || fileStat.mtimeMs !== cached.mtimeMs;\n });\n if (filesToProcess.length === 0) {\n if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n return;\n }\n var didApplyPatch = false;\n await Promise.all(filesToProcess.map(async function(param) {\n var { relativePath: relativePath2, fullPath } = param;\n try {\n var patchDef = filePatches.find(function(p) {\n return p.relativePath === relativePath2;\n }).patchDefinition;\n var originalPath = getOriginalPath(fullPath);\n var [targetContent, originalContent] = await Promise.all([\n readFile(fullPath, \"utf-8\"),\n readFile(originalPath, \"utf-8\").catch(function() {\n return null;\n })\n ]);\n var sourceContent = originalContent !== null && originalContent !== void 0 ? originalContent : targetContent;\n var patchedContent = null;\n if (typeof patchDef === \"string\") {\n patchedContent = patchDef;\n } else if (Array.isArray(patchDef)) {\n try {\n var contents = sourceContent;\n var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;\n try {\n for (var _iterator3 = patchDef[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var strategy = _step3.value;\n if (strategy === \"flow\") {\n contents = await transformFlowBabel(contents);\n }\n if (strategy === \"swc\" || strategy === \"jsx\") {\n var _this;\n contents = ((_this = await transformSWC(fullPath, contents, {\n mode: \"build\",\n environment: \"ios\",\n forceJSX: strategy === \"jsx\",\n noHMR: true,\n fixNonTypeSpecificImports: true,\n // a patch is written to node_modules ONCE and then read by\n // every later build, dev and production alike, so its output\n // has to be valid in both. the automatic JSX runtime is not:\n // its dev form emits `jsxDEV` from react/jsx-dev-runtime, and\n // React's production build exports `jsxDEV = void 0`, so a\n // patched dependency that renders JSX throws \"undefined is not\n // a function\" from render in any production bundle. `jsx`/`jsxs`\n // work in both builds, and refresh is already off for\n // node_modules, so the stable runtime is the only correct output.\n production: true\n })) === null || _this === void 0 ? void 0 : _this.code) || contents;\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n if (contents !== sourceContent) {\n patchedContent = contents;\n }\n } catch (transformErr) {\n if (!transformWarnedModules.has(patch.module)) {\n var _ref;\n transformWarnedModules.add(patch.module);\n console.warn(` \\u26A0 Patch transform failed for ${patch.module} in ${relativePath2}, skipping non-critical patch: ${(_ref = transformErr === null || transformErr === void 0 ? void 0 : transformErr.stack) !== null && _ref !== void 0 ? _ref : transformErr}`);\n }\n return;\n }\n } else {\n var out = await patchDef(sourceContent);\n if (typeof out === \"string\" && out !== sourceContent) {\n patchedContent = out;\n } else if (typeof out === \"string\") {\n console.warn(`[vxrn] patch for ${patch.module} matched nothing in ${relativePath2} \\u2014 it is stale and is no longer protecting anything`);\n }\n }\n if (patchedContent !== null) {\n if (targetContent === patchedContent) {\n var fileStat = await stat(fullPath);\n patchStats[fullPath] = {\n size: fileStat.size,\n mtimeMs: fileStat.mtimeMs\n };\n statsChanged = true;\n return;\n }\n await Promise.all([\n originalContent === null && atomicWriteFile(originalPath, sourceContent),\n atomicWriteFile(fullPath, patchedContent)\n ]);\n var fileStat1 = await stat(fullPath);\n patchStats[fullPath] = {\n size: fileStat1.size,\n mtimeMs: fileStat1.mtimeMs\n };\n statsChanged = true;\n didApplyPatch = true;\n if (process.env.DEBUG) {\n console.info(` - Applied patch to ${patch.module}: ${relativePath2}`);\n }\n } else {\n var fileStat2 = await stat(fullPath);\n patchStats[fullPath] = {\n size: fileStat2.size,\n mtimeMs: fileStat2.mtimeMs\n };\n statsChanged = true;\n }\n } catch (err) {\n if (err instanceof Bail) return;\n throw err;\n }\n }));\n if (didApplyPatch) {\n results.set(patch.module, \"applied\");\n } else if (!results.has(patch.module)) {\n results.set(patch.module, \"ok\");\n }\n } catch (err) {\n console.error(`\\u{1F6A8} Error applying patch to`, patch.module);\n console.error(err);\n }\n }));\n if (statsChanged) {\n await writePatchStats(nodeModulesDir, patchStats);\n }\n }));\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = results[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var [module, result] = _step.value;\n if (result === \"applied\") {\n console.info(` \\u{1FA79} ${module}`);\n } else if (result === \"ok\" && process.env.VXRN_FORCE_PATCH) {\n console.info(` \\u2713 ${module}`);\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nasync function atomicWriteFile(filePath, contents) {\n var tempPath = filePath + \".vxrn.tmp.\" + process.pid + \".\" + Date.now();\n await writeFile(tempPath, contents);\n await rename(tempPath, filePath);\n}\nexport {\n applyBuiltInPatches,\n applyDependencyPatches,\n bailIfExists,\n bailIfUnchanged,\n moduleToPnpmStorePattern\n};\n//# sourceMappingURL=patches.js.map\n"],"mappings":";;;;;;;;;;;;AAUA,SAAS,yBAAyB,MAAM;CACtC,IAAI,SAAS,KAAK,GAAG,MAAM,IAAI,eAAe,2DAA2D;CACzG,OAAO;AACT;AACA,SAAS,YAAY,OAAO,SAAS,MAAM;CACzC,UAAU,kBAAkB,OAAO;CACnC,OAAO,6BAA6B,OAAO,6BAA6B,IAAI,QAAQ,UAAU,SAAS,QAAQ,CAAC,GAAG,kBAAkB,KAAK,CAAC,CAAC,WAAW,IAAI,QAAQ,MAAM,OAAO,IAAI,CAAC;AACvL;AACA,SAAS,kBAAkB,UAAU,aAAa;CAChD,IAAI,EAAE,oBAAoB,cAAc,MAAM,IAAI,UAAU,mCAAmC;AACjG;AACA,SAAS,WAAW,QAAQ,MAAM,OAAO;CACvC,IAAI,6BA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