vxrn 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/config/getBaseVitePlugins.mjs +3 -1
  2. package/dist/config/getBaseVitePlugins.mjs.map +1 -1
  3. package/dist/config/getBaseVitePlugins.native.js +3 -1
  4. package/dist/config/getBaseVitePlugins.native.js.map +1 -1
  5. package/dist/constants.mjs +23 -1
  6. package/dist/constants.mjs.map +1 -1
  7. package/dist/constants.native.js +23 -1
  8. package/dist/constants.native.js.map +1 -1
  9. package/dist/exports/build.mjs +6 -4
  10. package/dist/exports/build.mjs.map +1 -1
  11. package/dist/exports/build.native.js +6 -4
  12. package/dist/exports/build.native.js.map +1 -1
  13. package/dist/index.js +2 -1
  14. package/dist/index.mjs +2 -1
  15. package/dist/index.native.js +2 -1
  16. package/dist/plugins/reactNativeDevServer.mjs +7 -5
  17. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  18. package/dist/plugins/reactNativeDevServer.native.js +8 -5
  19. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  20. package/dist/rn-commands/bundle/buildBundle.mjs +9 -0
  21. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  22. package/dist/rn-commands/bundle/buildBundle.native.js +9 -0
  23. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  24. package/dist/runtime/native-prelude.mjs +7 -1
  25. package/dist/runtime/native-prelude.mjs.map +1 -1
  26. package/dist/runtime/native-prelude.native.js +7 -1
  27. package/dist/runtime/native-prelude.native.js.map +1 -1
  28. package/dist/utils/compileNativeDevBytecode.mjs +13 -3
  29. package/dist/utils/compileNativeDevBytecode.mjs.map +1 -1
  30. package/dist/utils/compileNativeDevBytecode.native.js +13 -3
  31. package/dist/utils/compileNativeDevBytecode.native.js.map +1 -1
  32. package/dist/utils/createNativeDevEngine.mjs +375 -173
  33. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  34. package/dist/utils/createNativeDevEngine.native.js +429 -193
  35. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  36. package/dist/utils/environmentUtils.mjs +1 -1
  37. package/dist/utils/environmentUtils.mjs.map +1 -1
  38. package/dist/utils/environmentUtils.native.js +1 -1
  39. package/dist/utils/environmentUtils.native.js.map +1 -1
  40. package/dist/utils/scanDepsToOptimize.mjs +37 -15
  41. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  42. package/dist/utils/scanDepsToOptimize.native.js +45 -15
  43. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  44. package/package.json +13 -13
  45. package/src/config/getBaseVitePlugins.ts +2 -0
  46. package/src/constants.ts +24 -0
  47. package/src/exports/build.lifecycle.test.ts +2 -1
  48. package/src/exports/build.ts +11 -4
  49. package/src/index.ts +1 -0
  50. package/src/plugins/reactNativeCommonJsPlugin.ts +1 -1
  51. package/src/plugins/reactNativeDevServer.ts +19 -8
  52. package/src/rn-commands/bundle/buildBundle.ts +13 -1
  53. package/src/runtime/native-prelude.ts +7 -1
  54. package/src/types.ts +1 -1
  55. package/src/utils/compileNativeDevBytecode.test.ts +8 -8
  56. package/src/utils/compileNativeDevBytecode.ts +22 -2
  57. package/src/utils/createNativeDevEngine.test.ts +52 -25
  58. package/src/utils/createNativeDevEngine.ts +567 -254
  59. package/src/utils/environmentUtils.ts +6 -1
  60. package/src/utils/scanDepsToOptimize.test.ts +46 -2
  61. package/src/utils/scanDepsToOptimize.ts +78 -18
  62. package/types/config/getBaseVitePlugins.d.ts.map +1 -1
  63. package/types/constants.d.ts +2 -0
  64. package/types/constants.d.ts.map +1 -1
  65. package/types/exports/build.d.ts.map +1 -1
  66. package/types/index.d.ts +1 -0
  67. package/types/index.d.ts.map +1 -1
  68. package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
  69. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  70. package/types/runtime/native-prelude.d.ts.map +1 -1
  71. package/types/types.d.ts +1 -1
  72. package/types/types.d.ts.map +1 -1
  73. package/types/utils/compileNativeDevBytecode.d.ts +2 -1
  74. package/types/utils/compileNativeDevBytecode.d.ts.map +1 -1
  75. package/types/utils/createNativeDevEngine.d.ts +11 -5
  76. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  77. package/types/utils/environmentUtils.d.ts.map +1 -1
  78. package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"native-prelude.native.js","names":[],"sources":["runtime/native-prelude.native.js"],"sourcesContent":["function getNativePrelude(options) {\n\treturn `\nvar __BUNDLE_START_TIME__ = globalThis.nativePerformanceNow ? nativePerformanceNow() : Date.now();\n\nvar global = typeof globalThis !== 'undefined' ? globalThis\n : typeof global !== 'undefined' ? global\n : typeof window !== 'undefined' ? window\n : this;\n\nglobalThis.global = global;\nglobalThis.__DEV__ = ${options.dev};\n\n// react native polyfills\nglobal.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__ = false;\nglobal.Event = global.Event || function() { return this; };\nglobal.dispatchEvent = global.dispatchEvent || function() {};\nglobal.window = global.window || global;\nglobal.self = global.self || global;\nglobal.navigator = global.navigator || { product: 'ReactNative', userAgent: '' };\nglobal.performance = global.performance || { now: function() { return Date.now(); } };\n\n// hermes can expose addEventListener without the matching removal API. browser\n// libraries use addEventListener as their capability check, then crash during\n// cleanup. keep the incomplete host API from advertising browser event support.\nif (typeof global.addEventListener === 'function' && typeof global.removeEventListener !== 'function') {\n global.addEventListener = undefined;\n}\n\n// ErrorUtils - used by RN's error handling system\nif (!global.ErrorUtils) {\n var _handler = null;\n global.ErrorUtils = {\n setGlobalHandler: function(h) { _handler = h; },\n getGlobalHandler: function() { return _handler; },\n reportFatalError: function(e) { if (_handler) _handler(e, true); else throw e; },\n reportError: function(e) { if (_handler) _handler(e, false); },\n applyWithGuard: function(fn, ctx, args) { try { return fn.apply(ctx, args); } catch(e) { this.reportError(e); } },\n };\n}\n\nif (typeof process === 'undefined') {\n globalThis.process = { env: {} };\n}\nprocess.env.NODE_ENV = ${JSON.stringify(options.dev ? \"development\" : \"production\")};\nprocess.env.ONE_PLATFORM = ${JSON.stringify(options.platform)};\nprocess.env.EXPO_OS = ${JSON.stringify(options.platform)};\nprocess.env.TAMAGUI_TARGET = 'native';\n${options.serverUrl ? `process.env.ONE_SERVER_URL = ${JSON.stringify(options.serverUrl)};` : \"\"}\n\n// polyfill setImmediate (used by react-native internals)\nif (typeof globalThis.setImmediate === 'undefined') {\n globalThis.setImmediate = function(fn) { return setTimeout(fn, 0); };\n globalThis.clearImmediate = function(id) { clearTimeout(id); };\n}\n\n// polyfill URLSearchParams early (before whatwg-fetch checks for it)\n// RN's polyfillGlobal sets this up later but some modules check at import time\nif (typeof globalThis.URLSearchParams === 'undefined') {\n // minimal URLSearchParams polyfill - will be overridden by RN's proper one\n globalThis.URLSearchParams = function URLSearchParams(init) {\n this._params = {};\n if (typeof init === 'string') {\n init.replace(/^\\\\?/, '').split('&').forEach(function(p) {\n var kv = p.split('=');\n if (kv[0]) this._params[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1] || '');\n }.bind(this));\n }\n };\n globalThis.URLSearchParams.prototype.get = function(k) { return this._params[k] || null; };\n globalThis.URLSearchParams.prototype.toString = function() {\n return Object.keys(this._params).map(function(k) { return encodeURIComponent(k) + '=' + encodeURIComponent(this._params[k]); }.bind(this)).join('&');\n };\n}\n\n// ensure console exists before any library prelude touches it in release bundles\nglobalThis.console = globalThis.console || {};\nvar console = globalThis.console;\nconsole.log = console.log || function() {};\nconsole.info = console.info || function() {};\nconsole.warn = console.warn || function() {};\nconsole.error = console.error || function() {};\nconsole.debug = console.debug || function() {};\nconsole.trace = console.trace || function() {};\n\n// reanimated compat - these console methods must exist to avoid EXC_BAD_ACCESS crash\nconsole.assert = console.assert || function() {};\nconsole.clear = console.clear || function() {};\nconsole.dir = console.dir || function() {};\nconsole.dirxml = console.dirxml || function() {};\nconsole.profile = console.profile || function() {};\nconsole.profileEnd = console.profileEnd || function() {};\nconsole.table = console.table || function() {};\n\n// react refresh stubs (overridden by react-refresh plugin in dev)\n${options.dev ? `\nvar $RefreshReg$ = function() {};\nvar $RefreshSig$ = function() { return function(v) { return v; }; };\n` : \"\"}\n`.trim();\n}\n\nexport { getNativePrelude };"],"mappings":";AAAA,SAAS,iBAAiB,SAAS;CAClC,OAAO;;;;;;;;;uBASe,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAiCV,KAAK,UAAU,QAAQ,MAAM,gBAAgB,YAAY,EAAE;6BACvD,KAAK,UAAU,QAAQ,QAAQ,EAAE;wBACtC,KAAK,UAAU,QAAQ,QAAQ,EAAE;;EAEvD,QAAQ,YAAY,gCAAgC,KAAK,UAAU,QAAQ,SAAS,EAAE,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+C9F,QAAQ,MAAM;;;IAGZ,GAAG;EACL,KAAK;AACP"}
1
+ {"version":3,"file":"native-prelude.native.js","names":[],"sources":["runtime/native-prelude.native.js"],"sourcesContent":["function getNativePrelude(options) {\n\treturn `\nvar __BUNDLE_START_TIME__ = globalThis.nativePerformanceNow ? nativePerformanceNow() : Date.now();\n\nvar global = typeof globalThis !== 'undefined' ? globalThis\n : typeof global !== 'undefined' ? global\n : typeof window !== 'undefined' ? window\n : this;\n\nglobalThis.global = global;\nglobalThis.__DEV__ = ${options.dev};\n\n// react native polyfills\nglobal.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__ = false;\nglobal.Event = global.Event || function() { return this; };\nglobal.dispatchEvent = global.dispatchEvent || function() {};\nglobal.window = global.window || global;\nglobal.self = global.self || global;\nglobal.navigator = global.navigator || { product: 'ReactNative', userAgent: '' };\nglobal.performance = global.performance || { now: function() { return Date.now(); } };\n\n// hermes can expose addEventListener without the matching removal API. browser\n// libraries use addEventListener as their capability check, then crash during\n// cleanup. keep the incomplete host API from advertising browser event support.\n// the bundle runs at script scope, so a module's own top-level\n// function addEventListener declaration is also this global; only a native host function is cleared.\nif (\n typeof global.addEventListener === 'function' &&\n typeof global.removeEventListener !== 'function' &&\n Function.prototype.toString.call(global.addEventListener).indexOf('[native code]') !== -1\n) {\n global.addEventListener = undefined;\n}\n\n// ErrorUtils - used by RN's error handling system\nif (!global.ErrorUtils) {\n var _handler = null;\n global.ErrorUtils = {\n setGlobalHandler: function(h) { _handler = h; },\n getGlobalHandler: function() { return _handler; },\n reportFatalError: function(e) { if (_handler) _handler(e, true); else throw e; },\n reportError: function(e) { if (_handler) _handler(e, false); },\n applyWithGuard: function(fn, ctx, args) { try { return fn.apply(ctx, args); } catch(e) { this.reportError(e); } },\n };\n}\n\nif (typeof process === 'undefined') {\n globalThis.process = { env: {} };\n}\nprocess.env.NODE_ENV = ${JSON.stringify(options.dev ? \"development\" : \"production\")};\nprocess.env.ONE_PLATFORM = ${JSON.stringify(options.platform)};\nprocess.env.EXPO_OS = ${JSON.stringify(options.platform)};\nprocess.env.TAMAGUI_TARGET = 'native';\n${options.serverUrl ? `process.env.ONE_SERVER_URL = ${JSON.stringify(options.serverUrl)};` : \"\"}\n\n// polyfill setImmediate (used by react-native internals)\nif (typeof globalThis.setImmediate === 'undefined') {\n globalThis.setImmediate = function(fn) { return setTimeout(fn, 0); };\n globalThis.clearImmediate = function(id) { clearTimeout(id); };\n}\n\n// polyfill URLSearchParams early (before whatwg-fetch checks for it)\n// RN's polyfillGlobal sets this up later but some modules check at import time\nif (typeof globalThis.URLSearchParams === 'undefined') {\n // minimal URLSearchParams polyfill - will be overridden by RN's proper one\n globalThis.URLSearchParams = function URLSearchParams(init) {\n this._params = {};\n if (typeof init === 'string') {\n init.replace(/^\\\\?/, '').split('&').forEach(function(p) {\n var kv = p.split('=');\n if (kv[0]) this._params[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1] || '');\n }.bind(this));\n }\n };\n globalThis.URLSearchParams.prototype.get = function(k) { return this._params[k] || null; };\n globalThis.URLSearchParams.prototype.toString = function() {\n return Object.keys(this._params).map(function(k) { return encodeURIComponent(k) + '=' + encodeURIComponent(this._params[k]); }.bind(this)).join('&');\n };\n}\n\n// ensure console exists before any library prelude touches it in release bundles\nglobalThis.console = globalThis.console || {};\nvar console = globalThis.console;\nconsole.log = console.log || function() {};\nconsole.info = console.info || function() {};\nconsole.warn = console.warn || function() {};\nconsole.error = console.error || function() {};\nconsole.debug = console.debug || function() {};\nconsole.trace = console.trace || function() {};\n\n// reanimated compat - these console methods must exist to avoid EXC_BAD_ACCESS crash\nconsole.assert = console.assert || function() {};\nconsole.clear = console.clear || function() {};\nconsole.dir = console.dir || function() {};\nconsole.dirxml = console.dirxml || function() {};\nconsole.profile = console.profile || function() {};\nconsole.profileEnd = console.profileEnd || function() {};\nconsole.table = console.table || function() {};\n\n// react refresh stubs (overridden by react-refresh plugin in dev)\n${options.dev ? `\nvar $RefreshReg$ = function() {};\nvar $RefreshSig$ = function() { return function(v) { return v; }; };\n` : \"\"}\n`.trim();\n}\n\nexport { getNativePrelude };"],"mappings":";AAAA,SAAS,iBAAiB,SAAS;CAClC,OAAO;;;;;;;;;uBASe,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuCV,KAAK,UAAU,QAAQ,MAAM,gBAAgB,YAAY,EAAE;6BACvD,KAAK,UAAU,QAAQ,QAAQ,EAAE;wBACtC,KAAK,UAAU,QAAQ,QAAQ,EAAE;;EAEvD,QAAQ,YAAY,gCAAgC,KAAK,UAAU,QAAQ,SAAS,EAAE,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+C9F,QAAQ,MAAM;;;IAGZ,GAAG;EACL,KAAK;AACP"}
@@ -1,5 +1,6 @@
1
1
  import { accessSync, constants, readFileSync, statSync } from "node:fs";
2
2
  import { execFile } from "node:child_process";
3
+ import { createRequire } from "node:module";
3
4
  import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
4
5
  import { tmpdir } from "node:os";
5
6
  import { dirname, join } from "node:path";
@@ -47,8 +48,17 @@ function resolvePodHermesc(root) {
47
48
  }
48
49
  return cliPath.replace(/\$\(PODS_ROOT\)|\$\{PODS_ROOT\}/g, pods);
49
50
  }
50
- function nativeDevBytecodeCompiler(root) {
51
- const compiler = useHermescOverride() ?? resolvePodHermesc(root);
51
+ function resolveNpmHermesc(root) {
52
+ const require2 = createRequire(join(root, "package.json"));
53
+ const reactNativeJson = require2.resolve("react-native/package.json");
54
+ const nested = createRequire(reactNativeJson);
55
+ const compilerJson = nested.resolve("hermes-compiler/package.json");
56
+ const dir = compilerJson.slice(0, -"package.json".length);
57
+ const bin = process.platform === "darwin" ? "osx-bin" : process.platform === "win32" ? "win64-bin" : "linux64-bin";
58
+ return join(dir, "hermesc", bin, process.platform === "win32" ? "hermesc.exe" : "hermesc");
59
+ }
60
+ function nativeDevBytecodeCompiler(root, platform) {
61
+ const compiler = useHermescOverride() ?? (platform === "ios" ? resolvePodHermesc(root) : resolveNpmHermesc(root));
52
62
  const compiled = /* @__PURE__ */ new WeakMap();
53
63
  return (bundle, sourceURL) => {
54
64
  let urls = compiled.get(bundle);
@@ -89,5 +99,5 @@ function nativeDevBytecodeCompiler(root) {
89
99
  };
90
100
  }
91
101
 
92
- export { nativeDevBytecodeCompiler };
102
+ export { nativeDevBytecodeCompiler, resolveNpmHermesc };
93
103
  //# sourceMappingURL=compileNativeDevBytecode.mjs.map
@@ -1 +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,KA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O,UAAU;GACpB,KAAK,OAAO,SAAS;GACrB,MAAM;EACR,CAAC;EACD,KAAK,IAAI,WAAW,MAAM;EAC1B,OAAO;CACT;AACF"}
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 { createRequire } from \"node:module\";\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 resolveNpmHermesc(root) {\n const require2 = createRequire(join(root, \"package.json\"));\n const reactNativeJson = require2.resolve(\"react-native/package.json\");\n const nested = createRequire(reactNativeJson);\n const compilerJson = nested.resolve(\"hermes-compiler/package.json\");\n const dir = compilerJson.slice(0, -\"package.json\".length);\n const bin = process.platform === \"darwin\" ? \"osx-bin\" : process.platform === \"win32\" ? \"win64-bin\" : \"linux64-bin\";\n return join(dir, \"hermesc\", bin, process.platform === \"win32\" ? \"hermesc.exe\" : \"hermesc\");\n}\nfunction nativeDevBytecodeCompiler(root, platform) {\n const compiler = useHermescOverride() ?? (platform === \"ios\" ? resolvePodHermesc(root) : resolveNpmHermesc(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 resolveNpmHermesc\n};\n//# sourceMappingURL=compileNativeDevBytecode.js.map\n"],"mappings":";;;;;;;;;AAOA,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,kBA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E,CAAC,CAAC,OAAO,UAAU;GACpB,KAAK,OAAO,SAAS;GACrB,MAAM;EACR,CAAC;EACD,KAAK,IAAI,WAAW,MAAM;EAC1B,OAAO;CACT;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { accessSync, constants, readFileSync, statSync } from "fs";
2
2
  import { execFile } from "child_process";
3
+ import { createRequire } from "module";
3
4
  import { mkdir, mkdtemp, readFile, rm, writeFile } from "fs/promises";
4
5
  import { tmpdir } from "os";
5
6
  import { dirname, join } from "path";
@@ -51,9 +52,18 @@ function resolvePodHermesc(root) {
51
52
  }
52
53
  return cliPath.replace(/\$\(PODS_ROOT\)|\$\{PODS_ROOT\}/g, pods);
53
54
  }
54
- function nativeDevBytecodeCompiler(root) {
55
+ function resolveNpmHermesc(root) {
56
+ var require2 = createRequire(join(root, "package.json"));
57
+ var reactNativeJson = require2.resolve("react-native/package.json");
58
+ var nested = createRequire(reactNativeJson);
59
+ var compilerJson = nested.resolve("hermes-compiler/package.json");
60
+ var dir = compilerJson.slice(0, -"package.json".length);
61
+ var bin = process.platform === "darwin" ? "osx-bin" : process.platform === "win32" ? "win64-bin" : "linux64-bin";
62
+ return join(dir, "hermesc", bin, process.platform === "win32" ? "hermesc.exe" : "hermesc");
63
+ }
64
+ function nativeDevBytecodeCompiler(root, platform) {
55
65
  var _useHermescOverride;
56
- var compiler = (_useHermescOverride = useHermescOverride()) !== null && _useHermescOverride !== void 0 ? _useHermescOverride : resolvePodHermesc(root);
66
+ var compiler = (_useHermescOverride = useHermescOverride()) !== null && _useHermescOverride !== void 0 ? _useHermescOverride : platform === "ios" ? resolvePodHermesc(root) : resolveNpmHermesc(root);
57
67
  var compiled = /* @__PURE__ */ new WeakMap();
58
68
  return function(bundle, sourceURL) {
59
69
  var urls = compiled.get(bundle);
@@ -94,5 +104,5 @@ function nativeDevBytecodeCompiler(root) {
94
104
  };
95
105
  }
96
106
 
97
- export { nativeDevBytecodeCompiler };
107
+ export { nativeDevBytecodeCompiler, resolveNpmHermesc };
98
108
  //# sourceMappingURL=compileNativeDevBytecode.native.js.map
@@ -1 +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;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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"}
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 { createRequire } from \"module\";\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 resolveNpmHermesc(root) {\n var require2 = createRequire(join(root, \"package.json\"));\n var reactNativeJson = require2.resolve(\"react-native/package.json\");\n var nested = createRequire(reactNativeJson);\n var compilerJson = nested.resolve(\"hermes-compiler/package.json\");\n var dir = compilerJson.slice(0, -\"package.json\".length);\n var bin = process.platform === \"darwin\" ? \"osx-bin\" : process.platform === \"win32\" ? \"win64-bin\" : \"linux64-bin\";\n return join(dir, \"hermesc\", bin, process.platform === \"win32\" ? \"hermesc.exe\" : \"hermesc\");\n}\nfunction nativeDevBytecodeCompiler(root, platform) {\n var _useHermescOverride;\n var compiler = (_useHermescOverride = useHermescOverride()) !== null && _useHermescOverride !== void 0 ? _useHermescOverride : platform === \"ios\" ? resolvePodHermesc(root) : resolveNpmHermesc(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 {\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