vxrn 2.0.0-beta.99.1 → 2.6.1
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/backgroundComputation.mjs +145 -0
- package/dist/backgroundComputation.mjs.map +1 -0
- package/dist/backgroundComputation.native.js +163 -0
- package/dist/backgroundComputation.native.js.map +1 -0
- package/dist/backgroundComputationNative.mjs +16 -0
- package/dist/backgroundComputationNative.mjs.map +1 -0
- package/dist/backgroundComputationNative.native.js +18 -0
- package/dist/backgroundComputationNative.native.js.map +1 -0
- package/dist/config/getBaseViteConfigOnly.mjs +6 -10
- package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js +6 -10
- package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
- package/dist/config/getOptimizeDeps.mjs +2 -1
- package/dist/config/getOptimizeDeps.mjs.map +1 -1
- package/dist/config/getOptimizeDeps.native.js +2 -1
- package/dist/config/getOptimizeDeps.native.js.map +1 -1
- package/dist/config/getViteServerConfig.mjs +13 -0
- package/dist/config/getViteServerConfig.mjs.map +1 -1
- package/dist/config/getViteServerConfig.native.js +15 -1
- package/dist/config/getViteServerConfig.native.js.map +1 -1
- package/dist/constants/defaults.mjs +4 -0
- package/dist/constants/defaults.mjs.map +1 -1
- package/dist/constants/defaults.native.js +4 -0
- package/dist/constants/defaults.native.js.map +1 -1
- package/dist/exports/build.native.js +1 -1
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/clean.native.js +1 -1
- package/dist/exports/clean.native.js.map +1 -1
- package/dist/exports/createServer.native.js +2 -2
- package/dist/exports/createServer.native.js.map +1 -1
- package/dist/exports/dev.mjs +3 -0
- package/dist/exports/dev.mjs.map +1 -1
- package/dist/exports/dev.native.js +6 -3
- package/dist/exports/dev.native.js.map +1 -1
- package/dist/exports/loadEnv.native.js +1 -1
- package/dist/exports/loadEnv.native.js.map +1 -1
- package/dist/exports/patch.native.js +1 -1
- package/dist/exports/patch.native.js.map +1 -1
- package/dist/exports/prebuild.mjs +0 -22
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js +1 -23
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +1116 -178
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +1592 -243
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/exports/runAndroid.native.js +1 -1
- package/dist/exports/runAndroid.native.js.map +1 -1
- package/dist/exports/runIos.native.js +1 -1
- package/dist/exports/runIos.native.js.map +1 -1
- package/dist/exports/serve.native.js +1 -1
- package/dist/exports/serve.native.js.map +1 -1
- package/dist/exports/serveStaticAssets.native.js +1 -1
- package/dist/exports/serveStaticAssets.native.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/dist/index.native.js +4 -1
- package/dist/native-source-contract.mjs +3 -0
- package/dist/native-source-contract.native.js +3 -0
- package/dist/patches/builtInDepPatches.mjs +0 -13
- package/dist/patches/builtInDepPatches.mjs.map +1 -1
- package/dist/patches/builtInDepPatches.native.js +0 -13
- package/dist/patches/builtInDepPatches.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs +3 -2
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js +6 -3
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/plugins/backgroundComputationPlugin.mjs +27 -0
- package/dist/plugins/backgroundComputationPlugin.mjs.map +1 -0
- package/dist/plugins/backgroundComputationPlugin.native.js +32 -0
- package/dist/plugins/backgroundComputationPlugin.native.js.map +1 -0
- package/dist/plugins/reactNativeCommonJsPlugin.native.js +3 -3
- package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs +2 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js +3 -2
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevServer.mjs +87 -24
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +162 -45
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/plugins/workletImportsPlugin.mjs +9 -30
- package/dist/plugins/workletImportsPlugin.mjs.map +1 -1
- package/dist/plugins/workletImportsPlugin.native.js +10 -35
- package/dist/plugins/workletImportsPlugin.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +3 -3
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +3 -3
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/hmr-client.native.js +3 -7
- package/dist/runtime/hmr-client.native.js.map +1 -1
- package/dist/runtime/hmr-runtime.native.js +32 -40
- package/dist/runtime/hmr-runtime.native.js.map +1 -1
- package/dist/serve/node.native.js +2 -2
- package/dist/serve/node.native.js.map +1 -1
- package/dist/swift-package-id.mjs +3 -0
- package/dist/swift-package-id.native.js +3 -0
- package/dist/user-interface/index.native.js +6 -6
- package/dist/user-interface/index.native.js.map +1 -1
- package/dist/utils/compileNativeDevBytecode.mjs +93 -0
- package/dist/utils/compileNativeDevBytecode.mjs.map +1 -0
- package/dist/utils/compileNativeDevBytecode.native.js +98 -0
- package/dist/utils/compileNativeDevBytecode.native.js.map +1 -0
- package/dist/utils/createNativeDevEngine.mjs +227 -20
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +249 -37
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/dist/utils/execSync.native.js +1 -1
- package/dist/utils/execSync.native.js.map +1 -1
- package/dist/utils/getServerEntry.native.js +2 -2
- package/dist/utils/getServerEntry.native.js.map +1 -1
- package/dist/utils/nativeRun.mjs +32 -16
- package/dist/utils/nativeRun.mjs.map +1 -1
- package/dist/utils/nativeRun.native.js +43 -18
- package/dist/utils/nativeRun.native.js.map +1 -1
- package/dist/utils/nativeSourceContract.mjs +1823 -0
- package/dist/utils/nativeSourceContract.mjs.map +1 -0
- package/dist/utils/nativeSourceContract.native.js +2425 -0
- package/dist/utils/nativeSourceContract.native.js.map +1 -0
- package/dist/utils/patches.native.js +15 -24
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/printServerUrls.native.js +1 -1
- package/dist/utils/printServerUrls.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +7 -1
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +27 -2
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/dist/utils/swiftPackageId.mjs +31 -2
- package/dist/utils/swiftPackageId.mjs.map +1 -1
- package/dist/utils/swiftPackageId.native.js +50 -2
- package/dist/utils/swiftPackageId.native.js.map +1 -1
- package/dist/vxrn-vite-plugin.native.js +1 -1
- package/dist/vxrn-vite-plugin.native.js.map +1 -1
- package/expo-plugin.cjs +792 -2
- package/native-project-patches.cjs +201 -10
- package/package.json +34 -15
- package/src/backgroundComputation.ts +220 -0
- package/src/backgroundComputationNative.ts +23 -0
- package/src/config/getBaseViteConfigOnly.ts +8 -9
- package/src/config/getOptimizeDeps.ts +3 -1
- package/src/config/getViteServerConfig.ts +16 -0
- package/src/config/glbAssets.test.ts +228 -0
- package/src/constants/defaults.ts +6 -0
- package/src/exports/dev.ts +5 -1
- package/src/exports/expoPlugin.test.mjs +337 -15
- package/src/exports/prebuild.ts +0 -31
- package/src/exports/prebuildWithoutExpo.test.ts +1588 -48
- package/src/exports/prebuildWithoutExpo.ts +1573 -213
- package/src/index.ts +8 -0
- package/src/native-source-contract.ts +16 -0
- package/src/patches/builtInDepPatches.ts +0 -21
- package/src/plugins/autoDepOptimizePlugin.ts +7 -2
- package/src/plugins/backgroundComputationPlugin.test.ts +77 -0
- package/src/plugins/backgroundComputationPlugin.ts +29 -0
- package/src/plugins/reactNativeDevAssetPlugin.ts +5 -1
- package/src/plugins/reactNativeDevServer.test.ts +74 -0
- package/src/plugins/reactNativeDevServer.ts +145 -28
- package/src/plugins/rnCodegenPlugin.test.ts +30 -0
- package/src/plugins/workletImportsPlugin.ts +19 -37
- package/src/rn-commands/bundle/buildBundle.ts +5 -3
- package/src/swift-package-id.ts +1 -0
- package/src/utils/compileNativeDevBytecode.test.ts +168 -0
- package/src/utils/compileNativeDevBytecode.ts +117 -0
- package/src/utils/createNativeDevEngine.test.ts +643 -18
- package/src/utils/createNativeDevEngine.ts +278 -48
- package/src/utils/nativeRun.test.ts +125 -23
- package/src/utils/nativeRun.ts +51 -23
- package/src/utils/nativeSourceArtifacts.test.ts +39 -0
- package/src/utils/nativeSourceContract.test.ts +600 -0
- package/src/utils/nativeSourceContract.ts +1897 -0
- package/src/utils/scanDepsToOptimize.test.ts +80 -0
- package/src/utils/scanDepsToOptimize.ts +18 -7
- package/src/utils/swiftPackageId.ts +25 -1
- package/types/backgroundComputation.d.ts +28 -0
- package/types/backgroundComputation.d.ts.map +1 -0
- package/types/backgroundComputationNative.d.ts +2 -0
- package/types/backgroundComputationNative.d.ts.map +1 -0
- package/types/config/getBaseViteConfigOnly.d.ts.map +1 -1
- package/types/config/getOptimizeDeps.d.ts.map +1 -1
- package/types/config/getViteServerConfig.d.ts.map +1 -1
- package/types/constants/defaults.d.ts.map +1 -1
- package/types/exports/dev.d.ts.map +1 -1
- package/types/exports/prebuild.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts +6 -0
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/native-source-contract.d.ts +2 -0
- package/types/native-source-contract.d.ts.map +1 -0
- package/types/patches/builtInDepPatches.d.ts.map +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
- package/types/plugins/backgroundComputationPlugin.d.ts +3 -0
- package/types/plugins/backgroundComputationPlugin.d.ts.map +1 -0
- package/types/plugins/reactNativeDevAssetPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
- package/types/plugins/workletImportsPlugin.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/swift-package-id.d.ts +2 -0
- package/types/swift-package-id.d.ts.map +1 -0
- package/types/utils/compileNativeDevBytecode.d.ts +3 -0
- package/types/utils/compileNativeDevBytecode.d.ts.map +1 -0
- package/types/utils/createNativeDevEngine.d.ts +7 -22
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/types/utils/nativeRun.d.ts.map +1 -1
- package/types/utils/nativeSourceContract.d.ts +121 -0
- package/types/utils/nativeSourceContract.d.ts.map +1 -0
- package/types/utils/scanDepsToOptimize.d.ts +1 -0
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/types/utils/swiftPackageId.d.ts +1 -0
- package/types/utils/swiftPackageId.d.ts.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileNativeDevBytecode.js","names":[],"sources":["utils/compileNativeDevBytecode.js"],"sourcesContent":["import { accessSync, constants, readFileSync, statSync } from \"node:fs\";\nimport { execFile } from \"node:child_process\";\nimport { mkdir, mkdtemp, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { promisify } from \"node:util\";\nconst execute = promisify(execFile);\nfunction useHermescOverride() {\n const override = process.env.HERMESC_PATH?.trim();\n if (!override) return void 0;\n let stat;\n try {\n stat = statSync(override);\n } catch {\n stat = void 0;\n }\n if (!stat?.isFile()) {\n throw new Error(\n `[vxrn] HERMESC_PATH is set but points nowhere: ${override}. Point it at the hermesc binary the native build used, or unset it to resolve the pod compiler.`\n );\n }\n try {\n accessSync(override, constants.X_OK);\n } catch {\n throw new Error(\n `[vxrn] HERMESC_PATH is not executable: ${override}. Point it at the hermesc binary the native build used, or unset it to resolve the pod compiler.`\n );\n }\n return override;\n}\nfunction resolvePodHermesc(root) {\n const pods = join(root, \"ios/Pods\");\n const podspecPath = join(pods, \"Local Podspecs/hermes-engine.podspec.json\");\n let podspec;\n try {\n podspec = JSON.parse(readFileSync(podspecPath, \"utf8\"));\n } catch (error) {\n throw new Error(\n `[vxrn] native iOS dev bytecode needs the pod hermesc but ${root} has no usable native project: cannot read ${podspecPath} (${error instanceof Error ? error.message : String(error)}). Run prebuild and pod install for this app, or set HERMESC_PATH to the hermesc the native build used.`\n );\n }\n if (!Array.isArray(podspec.subspecs)) {\n throw new Error(\n `[vxrn] native iOS dev bytecode needs the pod hermesc but ${podspecPath} declares no subspecs. Reinstall pods for this app, or set HERMESC_PATH to the hermesc the native build used.`\n );\n }\n const prebuilt = podspec.subspecs.some(\n (spec) => spec.name === \"Pre-built\"\n );\n if (prebuilt) {\n return join(pods, \"hermes-engine/destroot/bin/hermesc\");\n }\n const cliPath = podspec.user_target_xcconfig?.HERMES_CLI_PATH;\n if (!cliPath) {\n throw new Error(\n `[vxrn] native iOS dev bytecode needs the pod hermesc but ${podspecPath} declares no HERMES_CLI_PATH. Reinstall pods for this app, or set HERMESC_PATH to the hermesc the native build used.`\n );\n }\n return cliPath.replace(/\\$\\(PODS_ROOT\\)|\\$\\{PODS_ROOT\\}/g, pods);\n}\nfunction nativeDevBytecodeCompiler(root) {\n const compiler = useHermescOverride() ?? resolvePodHermesc(root);\n const compiled = /* @__PURE__ */ new WeakMap();\n return (bundle, sourceURL) => {\n let urls = compiled.get(bundle);\n if (!urls) compiled.set(bundle, urls = /* @__PURE__ */ new Map());\n const existing = urls.get(sourceURL);\n if (existing) return existing;\n const result = (async () => {\n const directory = await mkdtemp(join(tmpdir(), \"vxrn-dev-hermes-\"));\n try {\n const source = join(directory, sourceURL);\n await mkdir(dirname(source), { recursive: true });\n const output = join(directory, \"index.hbc\");\n await writeFile(source, bundle.code);\n await execute(\n compiler,\n [\"-Og\", \"-g\", \"-emit-binary\", \"-out\", output, sourceURL],\n { cwd: directory, maxBuffer: 16 * 1024 * 1024 }\n );\n return await readFile(output);\n } finally {\n await rm(directory, { recursive: true, force: true });\n }\n })().catch((error) => {\n urls.delete(sourceURL);\n throw error;\n });\n urls.set(sourceURL, result);\n return result;\n };\n}\nexport {\n nativeDevBytecodeCompiler\n};\n//# sourceMappingURL=compileNativeDevBytecode.js.map\n"],"mappings":";;;;;;;;AAMA,MAAM,UAAU,UAAU,QAAQ;AAClC,SAAS,qBAAqB;CAC5B,MAAM,WAAW,QAAQ,IAAI,cAAc,KAAK;CAChD,IAAI,CAAC,UAAU,OAAO,KAAK;CAC3B,IAAI;CACJ,IAAI;EACF,OAAO,SAAS,QAAQ;CAC1B,QAAQ;EACN,OAAO,KAAK;CACd;CACA,IAAI,CAAC,MAAM,OAAO,GAAG;EACnB,MAAM,IAAI,MACR,kDAAkD,SAAS,iGAC7D;CACF;CACA,IAAI;EACF,WAAW,UAAU,UAAU,IAAI;CACrC,QAAQ;EACN,MAAM,IAAI,MACR,0CAA0C,SAAS,iGACrD;CACF;CACA,OAAO;AACT;AACA,SAAS,kBAAkB,MAAM;CAC/B,MAAM,OAAO,KAAK,MAAM,UAAU;CAClC,MAAM,cAAc,KAAK,MAAM,2CAA2C;CAC1E,IAAI;CACJ,IAAI;EACF,UAAU,KAAK,MAAM,aAAa,aAAa,MAAM,CAAC;CACxD,SAAS,OAAO;EACd,MAAM,IAAI,MACR,4DAA4D,KAAK,6CAA6C,YAAY,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,wGACvL;CACF;CACA,IAAI,CAAC,MAAM,QAAQ,QAAQ,QAAQ,GAAG;EACpC,MAAM,IAAI,MACR,4DAA4D,YAAY,8GAC1E;CACF;CACA,MAAM,WAAW,QAAQ,SAAS,MAC/B,SAAS,KAAK,SAAS,WAC1B;CACA,IAAI,UAAU;EACZ,OAAO,KAAK,MAAM,oCAAoC;CACxD;CACA,MAAM,UAAU,QAAQ,sBAAsB;CAC9C,IAAI,CAAC,SAAS;EACZ,MAAM,IAAI,MACR,4DAA4D,YAAY,qHAC1E;CACF;CACA,OAAO,QAAQ,QAAQ,oCAAoC,IAAI;AACjE;AACA,SAAS,0BAA0B,MAAM;CACvC,MAAM,WAAW,mBAAmB,KAAK,kBAAkB,IAAI;CAC/D,MAAM,2BAA2B,IAAI,QAAQ;CAC7C,QAAQ,QAAQ,cAAc;EAC5B,IAAI,OAAO,SAAS,IAAI,MAAM;EAC9B,IAAI,CAAC,MAAM,SAAS,IAAI,QAAQ,uBAAuB,IAAI,IAAI,CAAC;EAChE,MAAM,WAAW,KAAK,IAAI,SAAS;EACnC,IAAI,UAAU,OAAO;EACrB,MAAM,UAAU,YAAY;GAC1B,MAAM,YAAY,MAAM,QAAQ,KAAK,OAAO,GAAG,kBAAkB,CAAC;GAClE,IAAI;IACF,MAAM,SAAS,KAAK,WAAW,SAAS;IACxC,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;IAChD,MAAM,SAAS,KAAK,WAAW,WAAW;IAC1C,MAAM,UAAU,QAAQ,OAAO,IAAI;IACnC,MAAM,QACJ,UACA;KAAC;KAAO;KAAM;KAAgB;KAAQ;KAAQ;IAAS,GACvD;KAAE,KAAK;KAAW,WAAW,KAAK,OAAO;IAAK,CAChD;IACA,OAAO,MAAM,SAAS,MAAM;GAC9B,UAAU;IACR,MAAM,GAAG,WAAW;KAAE,WAAW;KAAM,OAAO;IAAK,CAAC;GACtD;EACF,EAAC,CAAE,CAAC,CAAC,OAAO,UAAU;GACpB,KAAK,OAAO,SAAS;GACrB,MAAM;EACR,CAAC;EACD,KAAK,IAAI,WAAW,MAAM;EAC1B,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
2
|
+
import { execFile } from "child_process";
|
|
3
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "fs/promises";
|
|
4
|
+
import { tmpdir } from "os";
|
|
5
|
+
import { dirname, join } from "path";
|
|
6
|
+
import { promisify } from "util";
|
|
7
|
+
|
|
8
|
+
var execute = promisify(execFile);
|
|
9
|
+
function useHermescOverride() {
|
|
10
|
+
var _process_env_HERMESC_PATH;
|
|
11
|
+
var override = (_process_env_HERMESC_PATH = process.env.HERMESC_PATH) === null || _process_env_HERMESC_PATH === void 0 ? void 0 : _process_env_HERMESC_PATH.trim();
|
|
12
|
+
if (!override) return void 0;
|
|
13
|
+
var stat;
|
|
14
|
+
try {
|
|
15
|
+
stat = statSync(override);
|
|
16
|
+
} catch (unused) {
|
|
17
|
+
stat = void 0;
|
|
18
|
+
}
|
|
19
|
+
if (!(stat === null || stat === void 0 ? void 0 : stat.isFile())) {
|
|
20
|
+
throw new Error(`[vxrn] HERMESC_PATH is set but points nowhere: ${override}. Point it at the hermesc binary the native build used, or unset it to resolve the pod compiler.`);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
accessSync(override, constants.X_OK);
|
|
24
|
+
} catch (unused) {
|
|
25
|
+
throw new Error(`[vxrn] HERMESC_PATH is not executable: ${override}. Point it at the hermesc binary the native build used, or unset it to resolve the pod compiler.`);
|
|
26
|
+
}
|
|
27
|
+
return override;
|
|
28
|
+
}
|
|
29
|
+
function resolvePodHermesc(root) {
|
|
30
|
+
var _podspec_user_target_xcconfig;
|
|
31
|
+
var pods = join(root, "ios/Pods");
|
|
32
|
+
var podspecPath = join(pods, "Local Podspecs/hermes-engine.podspec.json");
|
|
33
|
+
var podspec;
|
|
34
|
+
try {
|
|
35
|
+
podspec = JSON.parse(readFileSync(podspecPath, "utf8"));
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new Error(`[vxrn] native iOS dev bytecode needs the pod hermesc but ${root} has no usable native project: cannot read ${podspecPath} (${error instanceof Error ? error.message : String(error)}). Run prebuild and pod install for this app, or set HERMESC_PATH to the hermesc the native build used.`);
|
|
38
|
+
}
|
|
39
|
+
if (!Array.isArray(podspec.subspecs)) {
|
|
40
|
+
throw new Error(`[vxrn] native iOS dev bytecode needs the pod hermesc but ${podspecPath} declares no subspecs. Reinstall pods for this app, or set HERMESC_PATH to the hermesc the native build used.`);
|
|
41
|
+
}
|
|
42
|
+
var prebuilt = podspec.subspecs.some(function(spec) {
|
|
43
|
+
return spec.name === "Pre-built";
|
|
44
|
+
});
|
|
45
|
+
if (prebuilt) {
|
|
46
|
+
return join(pods, "hermes-engine/destroot/bin/hermesc");
|
|
47
|
+
}
|
|
48
|
+
var cliPath = (_podspec_user_target_xcconfig = podspec.user_target_xcconfig) === null || _podspec_user_target_xcconfig === void 0 ? void 0 : _podspec_user_target_xcconfig.HERMES_CLI_PATH;
|
|
49
|
+
if (!cliPath) {
|
|
50
|
+
throw new Error(`[vxrn] native iOS dev bytecode needs the pod hermesc but ${podspecPath} declares no HERMES_CLI_PATH. Reinstall pods for this app, or set HERMESC_PATH to the hermesc the native build used.`);
|
|
51
|
+
}
|
|
52
|
+
return cliPath.replace(/\$\(PODS_ROOT\)|\$\{PODS_ROOT\}/g, pods);
|
|
53
|
+
}
|
|
54
|
+
function nativeDevBytecodeCompiler(root) {
|
|
55
|
+
var _useHermescOverride;
|
|
56
|
+
var compiler = (_useHermescOverride = useHermescOverride()) !== null && _useHermescOverride !== void 0 ? _useHermescOverride : resolvePodHermesc(root);
|
|
57
|
+
var compiled = /* @__PURE__ */ new WeakMap();
|
|
58
|
+
return function(bundle, sourceURL) {
|
|
59
|
+
var urls = compiled.get(bundle);
|
|
60
|
+
if (!urls) compiled.set(bundle, urls = /* @__PURE__ */ new Map());
|
|
61
|
+
var existing = urls.get(sourceURL);
|
|
62
|
+
if (existing) return existing;
|
|
63
|
+
var result = (async function() {
|
|
64
|
+
var directory = await mkdtemp(join(tmpdir(), "vxrn-dev-hermes-"));
|
|
65
|
+
try {
|
|
66
|
+
var source = join(directory, sourceURL);
|
|
67
|
+
await mkdir(dirname(source), { recursive: true });
|
|
68
|
+
var output = join(directory, "index.hbc");
|
|
69
|
+
await writeFile(source, bundle.code);
|
|
70
|
+
await execute(compiler, [
|
|
71
|
+
"-Og",
|
|
72
|
+
"-g",
|
|
73
|
+
"-emit-binary",
|
|
74
|
+
"-out",
|
|
75
|
+
output,
|
|
76
|
+
sourceURL
|
|
77
|
+
], {
|
|
78
|
+
cwd: directory,
|
|
79
|
+
maxBuffer: 16 * 1024 * 1024
|
|
80
|
+
});
|
|
81
|
+
return await readFile(output);
|
|
82
|
+
} finally {
|
|
83
|
+
await rm(directory, {
|
|
84
|
+
recursive: true,
|
|
85
|
+
force: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
})().catch(function(error) {
|
|
89
|
+
urls.delete(sourceURL);
|
|
90
|
+
throw error;
|
|
91
|
+
});
|
|
92
|
+
urls.set(sourceURL, result);
|
|
93
|
+
return result;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { nativeDevBytecodeCompiler };
|
|
98
|
+
//# sourceMappingURL=compileNativeDevBytecode.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileNativeDevBytecode.native.js","names":[],"sources":["utils/compileNativeDevBytecode.native.js"],"sourcesContent":["import { accessSync, constants, readFileSync, statSync } from \"fs\";\nimport { execFile } from \"child_process\";\nimport { mkdir, mkdtemp, readFile, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport { dirname, join } from \"path\";\nimport { promisify } from \"util\";\nvar execute = promisify(execFile);\nfunction useHermescOverride() {\n var _process_env_HERMESC_PATH;\n var override = (_process_env_HERMESC_PATH = process.env.HERMESC_PATH) === null || _process_env_HERMESC_PATH === void 0 ? void 0 : _process_env_HERMESC_PATH.trim();\n if (!override) return void 0;\n var stat;\n try {\n stat = statSync(override);\n } catch (unused) {\n stat = void 0;\n }\n if (!(stat === null || stat === void 0 ? void 0 : stat.isFile())) {\n throw new Error(`[vxrn] HERMESC_PATH is set but points nowhere: ${override}. Point it at the hermesc binary the native build used, or unset it to resolve the pod compiler.`);\n }\n try {\n accessSync(override, constants.X_OK);\n } catch (unused) {\n throw new Error(`[vxrn] HERMESC_PATH is not executable: ${override}. Point it at the hermesc binary the native build used, or unset it to resolve the pod compiler.`);\n }\n return override;\n}\nfunction resolvePodHermesc(root) {\n var _podspec_user_target_xcconfig;\n var pods = join(root, \"ios/Pods\");\n var podspecPath = join(pods, \"Local Podspecs/hermes-engine.podspec.json\");\n var podspec;\n try {\n podspec = JSON.parse(readFileSync(podspecPath, \"utf8\"));\n } catch (error) {\n throw new Error(`[vxrn] native iOS dev bytecode needs the pod hermesc but ${root} has no usable native project: cannot read ${podspecPath} (${error instanceof Error ? error.message : String(error)}). Run prebuild and pod install for this app, or set HERMESC_PATH to the hermesc the native build used.`);\n }\n if (!Array.isArray(podspec.subspecs)) {\n throw new Error(`[vxrn] native iOS dev bytecode needs the pod hermesc but ${podspecPath} declares no subspecs. Reinstall pods for this app, or set HERMESC_PATH to the hermesc the native build used.`);\n }\n var prebuilt = podspec.subspecs.some(function(spec) {\n return spec.name === \"Pre-built\";\n });\n if (prebuilt) {\n return join(pods, \"hermes-engine/destroot/bin/hermesc\");\n }\n var cliPath = (_podspec_user_target_xcconfig = podspec.user_target_xcconfig) === null || _podspec_user_target_xcconfig === void 0 ? void 0 : _podspec_user_target_xcconfig.HERMES_CLI_PATH;\n if (!cliPath) {\n throw new Error(`[vxrn] native iOS dev bytecode needs the pod hermesc but ${podspecPath} declares no HERMES_CLI_PATH. Reinstall pods for this app, or set HERMESC_PATH to the hermesc the native build used.`);\n }\n return cliPath.replace(/\\$\\(PODS_ROOT\\)|\\$\\{PODS_ROOT\\}/g, pods);\n}\nfunction nativeDevBytecodeCompiler(root) {\n var _useHermescOverride;\n var compiler = (_useHermescOverride = useHermescOverride()) !== null && _useHermescOverride !== void 0 ? _useHermescOverride : resolvePodHermesc(root);\n var compiled = /* @__PURE__ */ new WeakMap();\n return function(bundle, sourceURL) {\n var urls = compiled.get(bundle);\n if (!urls) compiled.set(bundle, urls = /* @__PURE__ */ new Map());\n var existing = urls.get(sourceURL);\n if (existing) return existing;\n var result = (async function() {\n var directory = await mkdtemp(join(tmpdir(), \"vxrn-dev-hermes-\"));\n try {\n var source = join(directory, sourceURL);\n await mkdir(dirname(source), {\n recursive: true\n });\n var output = join(directory, \"index.hbc\");\n await writeFile(source, bundle.code);\n await execute(compiler, [\n \"-Og\",\n \"-g\",\n \"-emit-binary\",\n \"-out\",\n output,\n sourceURL\n ], {\n cwd: directory,\n maxBuffer: 16 * 1024 * 1024\n });\n return await readFile(output);\n } finally {\n await rm(directory, {\n recursive: true,\n force: true\n });\n }\n })().catch(function(error) {\n urls.delete(sourceURL);\n throw error;\n });\n urls.set(sourceURL, result);\n return result;\n };\n}\nexport {\n nativeDevBytecodeCompiler\n};\n//# sourceMappingURL=compileNativeDevBytecode.js.map\n"],"mappings":";;;;;;;;AAMA,IAAI,UAAU,UAAU,QAAQ;AAChC,SAAS,qBAAqB;CAC5B,IAAI;CACJ,IAAI,YAAY,4BAA4B,QAAQ,IAAI,kBAAkB,QAAQ,8BAA8B,KAAK,IAAI,KAAK,IAAI,0BAA0B,KAAK;CACjK,IAAI,CAAC,UAAU,OAAO,KAAK;CAC3B,IAAI;CACJ,IAAI;EACF,OAAO,SAAS,QAAQ;CAC1B,SAAS,QAAQ;EACf,OAAO,KAAK;CACd;CACA,IAAI,EAAE,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,IAAI,KAAK,OAAO,IAAI;EAChE,MAAM,IAAI,MAAM,kDAAkD,SAAS,iGAAiG;CAC9K;CACA,IAAI;EACF,WAAW,UAAU,UAAU,IAAI;CACrC,SAAS,QAAQ;EACf,MAAM,IAAI,MAAM,0CAA0C,SAAS,iGAAiG;CACtK;CACA,OAAO;AACT;AACA,SAAS,kBAAkB,MAAM;CAC/B,IAAI;CACJ,IAAI,OAAO,KAAK,MAAM,UAAU;CAChC,IAAI,cAAc,KAAK,MAAM,2CAA2C;CACxE,IAAI;CACJ,IAAI;EACF,UAAU,KAAK,MAAM,aAAa,aAAa,MAAM,CAAC;CACxD,SAAS,OAAO;EACd,MAAM,IAAI,MAAM,4DAA4D,KAAK,6CAA6C,YAAY,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,wGAAwG;CAC/S;CACA,IAAI,CAAC,MAAM,QAAQ,QAAQ,QAAQ,GAAG;EACpC,MAAM,IAAI,MAAM,4DAA4D,YAAY,8GAA8G;CACxM;CACA,IAAI,WAAW,QAAQ,SAAS,KAAK,SAAS,MAAM;EAClD,OAAO,KAAK,SAAS;CACvB,CAAC;CACD,IAAI,UAAU;EACZ,OAAO,KAAK,MAAM,oCAAoC;CACxD;CACA,IAAI,WAAW,gCAAgC,QAAQ,0BAA0B,QAAQ,kCAAkC,KAAK,IAAI,KAAK,IAAI,8BAA8B;CAC3K,IAAI,CAAC,SAAS;EACZ,MAAM,IAAI,MAAM,4DAA4D,YAAY,qHAAqH;CAC/M;CACA,OAAO,QAAQ,QAAQ,oCAAoC,IAAI;AACjE;AACA,SAAS,0BAA0B,MAAM;CACvC,IAAI;CACJ,IAAI,YAAY,sBAAsB,mBAAmB,OAAO,QAAQ,wBAAwB,KAAK,IAAI,sBAAsB,kBAAkB,IAAI;CACrJ,IAAI,2BAA2B,IAAI,QAAQ;CAC3C,OAAO,SAAS,QAAQ,WAAW;EACjC,IAAI,OAAO,SAAS,IAAI,MAAM;EAC9B,IAAI,CAAC,MAAM,SAAS,IAAI,QAAQ,uBAAuB,IAAI,IAAI,CAAC;EAChE,IAAI,WAAW,KAAK,IAAI,SAAS;EACjC,IAAI,UAAU,OAAO;EACrB,IAAI,UAAU,iBAAiB;GAC7B,IAAI,YAAY,MAAM,QAAQ,KAAK,OAAO,GAAG,kBAAkB,CAAC;GAChE,IAAI;IACF,IAAI,SAAS,KAAK,WAAW,SAAS;IACtC,MAAM,MAAM,QAAQ,MAAM,GAAG,EAC3B,WAAW,KACb,CAAC;IACD,IAAI,SAAS,KAAK,WAAW,WAAW;IACxC,MAAM,UAAU,QAAQ,OAAO,IAAI;IACnC,MAAM,QAAQ,UAAU;KACtB;KACA;KACA;KACA;KACA;KACA;IACF,GAAG;KACD,KAAK;KACL,WAAW,KAAK,OAAO;IACzB,CAAC;IACD,OAAO,MAAM,SAAS,MAAM;GAC9B,UAAU;IACR,MAAM,GAAG,WAAW;KAClB,WAAW;KACX,OAAO;IACT,CAAC;GACH;EACF,EAAC,CAAE,CAAC,CAAC,MAAM,SAAS,OAAO;GACzB,KAAK,OAAO,SAAS;GACrB,MAAM;EACR,CAAC;EACD,KAAK,IAAI,WAAW,MAAM;EAC1B,OAAO;CACT;AACF"}
|
|
@@ -10,6 +10,7 @@ import { withExpoPublicEnvAliases } from "@vxrn/utils/publicEnv";
|
|
|
10
10
|
import { DEFAULT_ASSET_EXTS } from "../constants/defaults.mjs";
|
|
11
11
|
import { getNativePrelude } from "../runtime/native-prelude.mjs";
|
|
12
12
|
import { rnCodegenPlugin } from "../plugins/rnCodegenPlugin.mjs";
|
|
13
|
+
import { dedupe } from "../config/getBaseViteConfigOnly.mjs";
|
|
13
14
|
|
|
14
15
|
const HERMES_CLASS_TRANSFORMS = [
|
|
15
16
|
"transform-classes",
|
|
@@ -60,12 +61,14 @@ function getResolveExtensions(platform) {
|
|
|
60
61
|
function getNativeResolveConfig(platform) {
|
|
61
62
|
return {
|
|
62
63
|
extensions: getResolveExtensions(platform),
|
|
63
|
-
conditionNames: ["react-native"],
|
|
64
|
+
conditionNames: ["react-native", "browser"],
|
|
64
65
|
mainFields: [
|
|
65
66
|
"react-native",
|
|
66
|
-
"
|
|
67
|
-
"main"
|
|
68
|
-
|
|
67
|
+
"browser",
|
|
68
|
+
"main",
|
|
69
|
+
"module"
|
|
70
|
+
],
|
|
71
|
+
aliasFields: [["react-native"], ["browser"]]
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
74
|
function getNativeTransformConfig(platform, dev, root) {
|
|
@@ -157,14 +160,12 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
|
|
|
157
160
|
...globalThis.__vxrnAddNativePlugins?.(platform) || [],
|
|
158
161
|
serverFileExclusionPlugin(),
|
|
159
162
|
environmentGuardPlugin(),
|
|
163
|
+
missingDynamicImportPlugin(),
|
|
160
164
|
hmrClientNoopPlugin(),
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
resolveId(source, importer) {
|
|
164
|
-
if (source === "@react-native/assets-registry/registry") return this.resolve("react-native/asset-registry", importer, { skipSelf: true });
|
|
165
|
-
}
|
|
166
|
-
},
|
|
165
|
+
nativeIdentityAliasPlugin(platform),
|
|
166
|
+
nativeAssetRegistryPlugin(root),
|
|
167
167
|
reactNativeDedupePlugin(root),
|
|
168
|
+
nativePackageDedupePlugin(root),
|
|
168
169
|
cssStubPlugin(),
|
|
169
170
|
viteImportGlobPlugin({ root }),
|
|
170
171
|
vxrnCompilerPlugin(platform, dev, root, sourceMaps),
|
|
@@ -179,7 +180,9 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
|
|
|
179
180
|
}),
|
|
180
181
|
hermesCompatSWCPlugin(dev, sourceMaps),
|
|
181
182
|
hermesLoopsPlugin(sourceMaps),
|
|
182
|
-
...userPlugins
|
|
183
|
+
...userPlugins,
|
|
184
|
+
nativeExportsPrecedencePlugin(root, platform),
|
|
185
|
+
nativeDeclarationAliasPlugin(root, platform)
|
|
183
186
|
].map((plugin) => plugin.api?.vxrnNative ? plugin.api.vxrnNative(context) : plugin);
|
|
184
187
|
}
|
|
185
188
|
function getNativeOutputOptions(prelude, sourcemap, minify) {
|
|
@@ -290,7 +293,6 @@ async function createNativeDevEngine(options) {
|
|
|
290
293
|
let bundleResolve = null;
|
|
291
294
|
let bundleReject = null;
|
|
292
295
|
let bundlePromise = null;
|
|
293
|
-
const resolvedHost = host === "0.0.0.0" ? "localhost" : host;
|
|
294
296
|
const virtualEntry = nativeVirtualEntryPlugin(root, {
|
|
295
297
|
dev: true,
|
|
296
298
|
platform,
|
|
@@ -327,7 +329,8 @@ async function createNativeDevEngine(options) {
|
|
|
327
329
|
outro: `
|
|
328
330
|
try {
|
|
329
331
|
var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
|
|
330
|
-
var
|
|
332
|
+
var __devServer = (init_getDevServer(), __toCommonJS(getDevServer_exports)).default();
|
|
333
|
+
var __hmrUrl = __devServer.url.replace(/^http/, 'ws') + 'hot?platform=${platform}&clientId=' + encodeURIComponent(__rolldown_runtime__.clientId);
|
|
331
334
|
__rolldown_runtime__.setup(new __WS(__hmrUrl));
|
|
332
335
|
} catch(e) {
|
|
333
336
|
// a swallowed failure here leaves the app permanently without Fast Refresh and
|
|
@@ -503,7 +506,10 @@ async function buildNativeBundle(options) {
|
|
|
503
506
|
...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins),
|
|
504
507
|
nativeBundlePostProcessPlugin()
|
|
505
508
|
],
|
|
506
|
-
output:
|
|
509
|
+
output: {
|
|
510
|
+
...getNativeOutputOptions(prelude, sourcemap, minify),
|
|
511
|
+
format: "iife"
|
|
512
|
+
}
|
|
507
513
|
})).output.find((o) => o.type === "chunk" && o.isEntry);
|
|
508
514
|
if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
|
|
509
515
|
if (sourcemap && !chunk.map) throw new Error("[vxrn] a source map was requested but rolldown produced none for the production bundle");
|
|
@@ -608,16 +614,17 @@ ${routeHmr}
|
|
|
608
614
|
updateFiles(files) {
|
|
609
615
|
routes.files = files;
|
|
610
616
|
if (!useDynamicRouteRegistry) return;
|
|
617
|
+
mkdirSync(dirname(registryPath), { recursive: true });
|
|
618
|
+
const registryDir = realpathSync(dirname(registryPath));
|
|
611
619
|
const source = `export const routes = {
|
|
612
620
|
${[...files].sort().map((file) => {
|
|
613
621
|
const routeKey = `/${normalizePath(relative(root, file))}`;
|
|
614
|
-
let importPath = normalizePath(relative(
|
|
622
|
+
let importPath = normalizePath(relative(registryDir, file));
|
|
615
623
|
if (!importPath.startsWith(".")) importPath = `./${importPath}`;
|
|
616
624
|
return ` ${JSON.stringify(routeKey)}: () => import(${JSON.stringify(importPath)})`;
|
|
617
625
|
}).join(",\n")}
|
|
618
626
|
}
|
|
619
627
|
`;
|
|
620
|
-
mkdirSync(dirname(registryPath), { recursive: true });
|
|
621
628
|
if (!existsSync(registryPath) || readFileSync(registryPath, "utf8") !== source) writeFileSync(registryPath, source);
|
|
622
629
|
}
|
|
623
630
|
};
|
|
@@ -685,6 +692,33 @@ function serverFileExclusionPlugin() {
|
|
|
685
692
|
}
|
|
686
693
|
};
|
|
687
694
|
}
|
|
695
|
+
function missingDynamicImportPlugin() {
|
|
696
|
+
const PREFIX = "\0vxrn-missing-module:";
|
|
697
|
+
return {
|
|
698
|
+
name: "vxrn:missing-dynamic-import",
|
|
699
|
+
async resolveId(source, importer, options) {
|
|
700
|
+
if (options.kind !== "dynamic-import") return;
|
|
701
|
+
if (source.startsWith(".") || source.startsWith("/") || source.includes(":")) return;
|
|
702
|
+
if (source.startsWith("\0")) return;
|
|
703
|
+
const resolved = await this.resolve(source, importer, {
|
|
704
|
+
skipSelf: true,
|
|
705
|
+
kind: options.kind
|
|
706
|
+
});
|
|
707
|
+
if (resolved) return resolved;
|
|
708
|
+
return {
|
|
709
|
+
id: `${PREFIX}${source}`,
|
|
710
|
+
external: false
|
|
711
|
+
};
|
|
712
|
+
},
|
|
713
|
+
load(id) {
|
|
714
|
+
if (!id.startsWith(PREFIX)) return;
|
|
715
|
+
return {
|
|
716
|
+
code: `throw new Error(${JSON.stringify(`Cannot find module '${id.slice(21)}'`)});`,
|
|
717
|
+
moduleType: "js"
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
}
|
|
688
722
|
function environmentGuardPlugin() {
|
|
689
723
|
const THROWING = [
|
|
690
724
|
"server-only",
|
|
@@ -735,6 +769,168 @@ export default HMRClient`,
|
|
|
735
769
|
}
|
|
736
770
|
};
|
|
737
771
|
}
|
|
772
|
+
function nativeIdentityAliasPlugin(platform) {
|
|
773
|
+
const packages = /* @__PURE__ */ new Map();
|
|
774
|
+
let resolver;
|
|
775
|
+
const findPackage = (directory) => {
|
|
776
|
+
if (packages.has(directory)) return packages.get(directory);
|
|
777
|
+
let result = null;
|
|
778
|
+
const manifest = join(directory, "package.json");
|
|
779
|
+
if (existsSync(manifest)) try {
|
|
780
|
+
const field = JSON.parse(readFileSync(manifest, "utf8"))["react-native"];
|
|
781
|
+
result = {
|
|
782
|
+
root: directory,
|
|
783
|
+
aliases: field && typeof field === "object" ? field : {}
|
|
784
|
+
};
|
|
785
|
+
} catch {}
|
|
786
|
+
else {
|
|
787
|
+
const parent = dirname(directory);
|
|
788
|
+
if (parent !== directory) result = findPackage(parent);
|
|
789
|
+
}
|
|
790
|
+
packages.set(directory, result);
|
|
791
|
+
return result;
|
|
792
|
+
};
|
|
793
|
+
return {
|
|
794
|
+
name: "vxrn:native-identity-alias",
|
|
795
|
+
async resolveId(source, importer) {
|
|
796
|
+
if (!importer || !source.startsWith(".")) return;
|
|
797
|
+
const pkg = findPackage(dirname(importer));
|
|
798
|
+
if (!pkg) return;
|
|
799
|
+
const key = `./${normalizePath(relative(pkg.root, resolve(dirname(importer), source)))}`;
|
|
800
|
+
if (pkg.aliases[key] !== key) return;
|
|
801
|
+
if (!resolver) {
|
|
802
|
+
const { ResolverFactory } = await import("rolldown/experimental");
|
|
803
|
+
resolver = new ResolverFactory({
|
|
804
|
+
...getNativeResolveConfig(platform),
|
|
805
|
+
aliasFields: []
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
const result = resolver.sync(dirname(importer), source);
|
|
809
|
+
if (result.path) return result.path;
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function nativeExportsPrecedencePlugin(root, platform) {
|
|
814
|
+
const manifests = /* @__PURE__ */ new Map();
|
|
815
|
+
const readManifest = (directory) => {
|
|
816
|
+
if (!manifests.has(directory)) {
|
|
817
|
+
let manifest = null;
|
|
818
|
+
try {
|
|
819
|
+
manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
|
|
820
|
+
} catch {}
|
|
821
|
+
manifests.set(directory, manifest);
|
|
822
|
+
}
|
|
823
|
+
return manifests.get(directory);
|
|
824
|
+
};
|
|
825
|
+
const resolvers = /* @__PURE__ */ new Map();
|
|
826
|
+
return {
|
|
827
|
+
name: "vxrn:native-exports-precedence",
|
|
828
|
+
async resolveId(source, importer, options) {
|
|
829
|
+
if (source.startsWith(".") || source.startsWith("/") || source.includes(":")) return;
|
|
830
|
+
const resolved = await this.resolve(source, importer, {
|
|
831
|
+
skipSelf: true,
|
|
832
|
+
kind: options.kind
|
|
833
|
+
});
|
|
834
|
+
if (!resolved || resolved.external || resolved.id.startsWith("\0")) return resolved;
|
|
835
|
+
const name = source.split("/").slice(0, source.startsWith("@") ? 2 : 1).join("/");
|
|
836
|
+
let directory = dirname(resolved.id);
|
|
837
|
+
while (readManifest(directory)?.name !== name) {
|
|
838
|
+
if (dirname(directory) === directory) return resolved;
|
|
839
|
+
directory = dirname(directory);
|
|
840
|
+
}
|
|
841
|
+
const exportsMap = JSON.stringify(readManifest(directory)?.exports ?? null);
|
|
842
|
+
if (!exportsMap.includes("\"react-native\"") || !exportsMap.includes("\"browser\"")) return resolved;
|
|
843
|
+
const kind = options.kind === "require-call" ? "require" : "import";
|
|
844
|
+
let resolver = resolvers.get(kind);
|
|
845
|
+
if (!resolver) {
|
|
846
|
+
const { ResolverFactory } = await import("rolldown/experimental");
|
|
847
|
+
resolver = new ResolverFactory({
|
|
848
|
+
...getNativeResolveConfig(platform),
|
|
849
|
+
conditionNames: [
|
|
850
|
+
"react-native",
|
|
851
|
+
kind,
|
|
852
|
+
"default"
|
|
853
|
+
]
|
|
854
|
+
});
|
|
855
|
+
resolvers.set(kind, resolver);
|
|
856
|
+
}
|
|
857
|
+
const native = resolver.sync(importer ? dirname(importer) : root, source);
|
|
858
|
+
if (!native.path || native.path === resolved.id) return resolved;
|
|
859
|
+
return this.resolve(native.path, importer, {
|
|
860
|
+
skipSelf: true,
|
|
861
|
+
kind: options.kind
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function nativeDeclarationAliasPlugin(root, platform) {
|
|
867
|
+
const resolvers = /* @__PURE__ */ new Map();
|
|
868
|
+
return {
|
|
869
|
+
name: "vxrn:declaration-alias",
|
|
870
|
+
async resolveId(source, importer, options) {
|
|
871
|
+
if (source.startsWith(".") || source.startsWith("/") || source.includes(":")) return;
|
|
872
|
+
const resolved = await this.resolve(source, importer, {
|
|
873
|
+
skipSelf: true,
|
|
874
|
+
kind: options.kind
|
|
875
|
+
});
|
|
876
|
+
if (!resolved || resolved.external || !/\.d\.[cm]?ts$/.test(resolved.id)) return resolved;
|
|
877
|
+
const kind = options.kind === "require-call" ? "require" : "import";
|
|
878
|
+
let resolver = resolvers.get(kind);
|
|
879
|
+
if (!resolver) {
|
|
880
|
+
const { ResolverFactory } = await import("rolldown/experimental");
|
|
881
|
+
resolver = new ResolverFactory({
|
|
882
|
+
...getNativeResolveConfig(platform),
|
|
883
|
+
conditionNames: [
|
|
884
|
+
"react-native",
|
|
885
|
+
"browser",
|
|
886
|
+
kind,
|
|
887
|
+
"default"
|
|
888
|
+
]
|
|
889
|
+
});
|
|
890
|
+
resolvers.set(kind, resolver);
|
|
891
|
+
}
|
|
892
|
+
const runtime = resolver.sync(importer ? dirname(importer) : root, source);
|
|
893
|
+
if (!runtime.path || /\.d\.[cm]?ts$/.test(runtime.path)) this.error(`Native import ${source} resolves to a declaration without a runtime export`);
|
|
894
|
+
return this.resolve(runtime.path, importer, {
|
|
895
|
+
skipSelf: true,
|
|
896
|
+
kind: options.kind
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
function nativeAssetRegistryPlugin(root) {
|
|
902
|
+
let registryPath;
|
|
903
|
+
return {
|
|
904
|
+
name: "vxrn:asset-registry",
|
|
905
|
+
async resolveId(source, importer) {
|
|
906
|
+
if (source !== "react-native/asset-registry" && source !== "@react-native/assets-registry/registry") return;
|
|
907
|
+
if (registryPath === void 0) try {
|
|
908
|
+
const reactNativeRoot = dirname(resolvePath("react-native/package.json", root));
|
|
909
|
+
const exportedRegistry = join(reactNativeRoot, "src/asset-registry.js");
|
|
910
|
+
registryPath = existsSync(exportedRegistry) ? exportedRegistry : resolvePath("@react-native/assets-registry/registry", reactNativeRoot);
|
|
911
|
+
} catch {
|
|
912
|
+
registryPath = null;
|
|
913
|
+
}
|
|
914
|
+
if (registryPath) return this.resolve(normalizePath(registryPath), importer, { skipSelf: true });
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
function nativePackageDedupePlugin(root) {
|
|
919
|
+
const packages = /* @__PURE__ */ new Set([
|
|
920
|
+
...dedupe,
|
|
921
|
+
"react-native-worklets",
|
|
922
|
+
"react-native-nitro-modules"
|
|
923
|
+
]);
|
|
924
|
+
return {
|
|
925
|
+
name: "vxrn:native-package-dedupe",
|
|
926
|
+
async resolveId(source) {
|
|
927
|
+
const parts = source.split("/");
|
|
928
|
+
const packageName = source.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
929
|
+
if (!packages.has(packageName)) return;
|
|
930
|
+
return this.resolve(source, join(root, "package.json"), { skipSelf: true });
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
}
|
|
738
934
|
function reactNativeDedupePlugin(root) {
|
|
739
935
|
let reactNativeRoot;
|
|
740
936
|
return {
|
|
@@ -1110,12 +1306,12 @@ function hermesCompatSWCPlugin(dev, sourceMaps = false) {
|
|
|
1110
1306
|
async transform(code, id) {
|
|
1111
1307
|
if (!/\.[cm]?[jt]sx?$/.test(id)) return;
|
|
1112
1308
|
if (id.includes("\0") || id.includes("virtual:")) return;
|
|
1113
|
-
const hasClass =
|
|
1309
|
+
const hasClass = /\bclass(?:\s|\{)/.test(code);
|
|
1114
1310
|
const hasAsync = code.includes("async");
|
|
1115
|
-
const
|
|
1116
|
-
if (!hasClass && !hasAsync && !
|
|
1311
|
+
const hasBlockScopedBinding = /\b(?:const|let)\s/.test(code);
|
|
1312
|
+
if (!hasClass && !hasAsync && !hasBlockScopedBinding) return;
|
|
1117
1313
|
let output;
|
|
1118
|
-
if (code.length <= 5e5) {
|
|
1314
|
+
if (code.length <= 5e5 || hasClass) {
|
|
1119
1315
|
if (!oxc) oxc = await import("oxc-transform");
|
|
1120
1316
|
const lang = /\.[cm]?ts$/.test(id) ? "ts" : id.endsWith(".tsx") ? "tsx" : "jsx";
|
|
1121
1317
|
const result = oxc.transformSync(id, code, {
|
|
@@ -1136,6 +1332,17 @@ ${err.codeframe}` : ""));
|
|
|
1136
1332
|
map: sourceMaps ? result.map : void 0
|
|
1137
1333
|
};
|
|
1138
1334
|
}
|
|
1335
|
+
if (hasClass || hasBlockScopedBinding) {
|
|
1336
|
+
const { transformHermesClasses } = await import("@vxrn/compiler");
|
|
1337
|
+
const classes = await transformHermesClasses(output?.code ?? code, id, sourceMaps);
|
|
1338
|
+
if (classes) {
|
|
1339
|
+
if (classes.map && output?.map) {
|
|
1340
|
+
const remapping = (await import("@jridgewell/remapping")).default;
|
|
1341
|
+
classes.map = remapping([classes.map, output.map], () => null);
|
|
1342
|
+
}
|
|
1343
|
+
output = classes;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1139
1346
|
const lowered = await transformHermesAsync(output?.code ?? code, id, sourceMaps);
|
|
1140
1347
|
if (!lowered) return output;
|
|
1141
1348
|
if (lowered.map && output?.map) {
|