binding-B4m_2rFW.mjs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. import { createRequire } from "node:module";
  2. //#region \0rolldown/runtime.js
  3. var __create = Object.create;
  4. var __defProp = Object.defineProperty;
  5. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  6. var __getOwnPropNames = Object.getOwnPropertyNames;
  7. var __getProtoOf = Object.getPrototypeOf;
  8. var __hasOwnProp = Object.prototype.hasOwnProperty;
  9. var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
  12. key = keys[i];
  13. if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
  14. get: ((k) => from[k]).bind(null, key),
  15. enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
  16. });
  17. }
  18. return to;
  19. };
  20. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
  21. value: mod,
  22. enumerable: true
  23. }) : target, mod));
  24. var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
  25. //#endregion
  26. //#region src/webcontainer-fallback.cjs
  27. var require_webcontainer_fallback = /* @__PURE__ */ __commonJSMin(((exports, module) => {
  28. const fs = __require("node:fs");
  29. const childProcess = __require("node:child_process");
  30. const version = JSON.parse(fs.readFileSync(__require.resolve("rolldown/package.json"), "utf-8")).version;
  31. const baseDir = `/tmp/rolldown-${version}`;
  32. const bindingEntry = `${baseDir}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;
  33. if (!fs.existsSync(bindingEntry)) {
  34. const bindingPkg = `@rolldown/binding-wasm32-wasi@${version}`;
  35. fs.rmSync(baseDir, {
  36. recursive: true,
  37. force: true
  38. });
  39. fs.mkdirSync(baseDir, { recursive: true });
  40. console.log(`[rolldown] Downloading ${bindingPkg} on WebContainer...`);
  41. childProcess.execFileSync("pnpm", ["i", bindingPkg], {
  42. cwd: baseDir,
  43. stdio: "inherit"
  44. });
  45. }
  46. module.exports = __require(bindingEntry);
  47. }));
  48. //#endregion
  49. //#region src/binding.cjs
  50. var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
  51. const { readFileSync } = __require("fs");
  52. let nativeBinding = null;
  53. let __napiLoadedBindingTarget = "native";
  54. const loadErrors = [];
  55. const isMusl = () => {
  56. let musl = false;
  57. if (process.platform === "linux") {
  58. musl = isMuslFromFilesystem();
  59. if (musl === null) musl = isMuslFromReport();
  60. if (musl === null) musl = isMuslFromChildProcess();
  61. }
  62. return musl;
  63. };
  64. const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
  65. const isMuslFromFilesystem = () => {
  66. try {
  67. return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
  68. } catch {
  69. return null;
  70. }
  71. };
  72. const isMuslFromReport = () => {
  73. let report = null;
  74. if (process.report && typeof process.report.getReport === "function") {
  75. process.report.excludeNetwork = true;
  76. report = process.report.getReport();
  77. }
  78. if (!report) return null;
  79. if (report.header && report.header.glibcVersionRuntime) return false;
  80. if (Array.isArray(report.sharedObjects)) {
  81. if (report.sharedObjects.some(isFileMusl)) return true;
  82. }
  83. return false;
  84. };
  85. const isMuslFromChildProcess = () => {
  86. try {
  87. return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
  88. } catch (e) {
  89. return false;
  90. }
  91. };
  92. function requireNative() {
  93. if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
  94. const overrideBinding = __require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
  95. __napiLoadedBindingTarget = overrideBinding && typeof overrideBinding.__napiBindingTarget === "string" ? overrideBinding.__napiBindingTarget : "native";
  96. return overrideBinding;
  97. } catch (err) {
  98. loadErrors.push(err);
  99. }
  100. else if (process.platform === "android") {
  101. if (process.arch === "arm64") {
  102. try {
  103. return __require("./rolldown-binding.android-arm64.node");
  104. } catch (e) {
  105. loadErrors.push(e);
  106. }
  107. try {
  108. const binding = __require("@rolldown/binding-android-arm64");
  109. const bindingPackageVersion = __require("@rolldown/binding-android-arm64/package.json").version;
  110. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  111. return binding;
  112. } catch (e) {
  113. loadErrors.push(e);
  114. }
  115. } else if (process.arch === "arm") {
  116. try {
  117. return __require("./rolldown-binding.android-arm-eabi.node");
  118. } catch (e) {
  119. loadErrors.push(e);
  120. }
  121. try {
  122. const binding = __require("@rolldown/binding-android-arm-eabi");
  123. const bindingPackageVersion = __require("@rolldown/binding-android-arm-eabi/package.json").version;
  124. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  125. return binding;
  126. } catch (e) {
  127. loadErrors.push(e);
  128. }
  129. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
  130. } else if (process.platform === "win32") {
  131. if (process.arch === "x64") {
  132. if (process.config && process.config.variables && process.config.variables.shlib_suffix === "dll.a" || process.config && process.config.variables && process.config.variables.node_target_type === "shared_library") {
  133. try {
  134. return __require("./rolldown-binding.win32-x64-gnu.node");
  135. } catch (e) {
  136. loadErrors.push(e);
  137. }
  138. try {
  139. const binding = __require("@rolldown/binding-win32-x64-gnu");
  140. const bindingPackageVersion = __require("@rolldown/binding-win32-x64-gnu/package.json").version;
  141. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  142. return binding;
  143. } catch (e) {
  144. loadErrors.push(e);
  145. }
  146. } else {
  147. try {
  148. return __require("./rolldown-binding.win32-x64-msvc.node");
  149. } catch (e) {
  150. loadErrors.push(e);
  151. }
  152. try {
  153. const binding = __require("@rolldown/binding-win32-x64-msvc");
  154. const bindingPackageVersion = __require("@rolldown/binding-win32-x64-msvc/package.json").version;
  155. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  156. return binding;
  157. } catch (e) {
  158. loadErrors.push(e);
  159. }
  160. }
  161. } else if (process.arch === "ia32") {
  162. try {
  163. return __require("./rolldown-binding.win32-ia32-msvc.node");
  164. } catch (e) {
  165. loadErrors.push(e);
  166. }
  167. try {
  168. const binding = __require("@rolldown/binding-win32-ia32-msvc");
  169. const bindingPackageVersion = __require("@rolldown/binding-win32-ia32-msvc/package.json").version;
  170. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  171. return binding;
  172. } catch (e) {
  173. loadErrors.push(e);
  174. }
  175. } else if (process.arch === "arm64") {
  176. try {
  177. return __require("./rolldown-binding.win32-arm64-msvc.node");
  178. } catch (e) {
  179. loadErrors.push(e);
  180. }
  181. try {
  182. const binding = __require("@rolldown/binding-win32-arm64-msvc");
  183. const bindingPackageVersion = __require("@rolldown/binding-win32-arm64-msvc/package.json").version;
  184. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  185. return binding;
  186. } catch (e) {
  187. loadErrors.push(e);
  188. }
  189. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
  190. } else if (process.platform === "darwin") {
  191. try {
  192. return __require("./rolldown-binding.darwin-universal.node");
  193. } catch (e) {
  194. loadErrors.push(e);
  195. }
  196. try {
  197. const binding = __require("@rolldown/binding-darwin-universal");
  198. const bindingPackageVersion = __require("@rolldown/binding-darwin-universal/package.json").version;
  199. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  200. return binding;
  201. } catch (e) {
  202. loadErrors.push(e);
  203. }
  204. if (process.arch === "x64") {
  205. try {
  206. return __require("./rolldown-binding.darwin-x64.node");
  207. } catch (e) {
  208. loadErrors.push(e);
  209. }
  210. try {
  211. const binding = __require("@rolldown/binding-darwin-x64");
  212. const bindingPackageVersion = __require("@rolldown/binding-darwin-x64/package.json").version;
  213. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  214. return binding;
  215. } catch (e) {
  216. loadErrors.push(e);
  217. }
  218. } else if (process.arch === "arm64") {
  219. try {
  220. return __require("./rolldown-binding.darwin-arm64.node");
  221. } catch (e) {
  222. loadErrors.push(e);
  223. }
  224. try {
  225. const binding = __require("@rolldown/binding-darwin-arm64");
  226. const bindingPackageVersion = __require("@rolldown/binding-darwin-arm64/package.json").version;
  227. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  228. return binding;
  229. } catch (e) {
  230. loadErrors.push(e);
  231. }
  232. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
  233. } else if (process.platform === "freebsd") {
  234. if (process.arch === "x64") {
  235. try {
  236. return __require("./rolldown-binding.freebsd-x64.node");
  237. } catch (e) {
  238. loadErrors.push(e);
  239. }
  240. try {
  241. const binding = __require("@rolldown/binding-freebsd-x64");
  242. const bindingPackageVersion = __require("@rolldown/binding-freebsd-x64/package.json").version;
  243. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  244. return binding;
  245. } catch (e) {
  246. loadErrors.push(e);
  247. }
  248. } else if (process.arch === "arm64") {
  249. try {
  250. return __require("./rolldown-binding.freebsd-arm64.node");
  251. } catch (e) {
  252. loadErrors.push(e);
  253. }
  254. try {
  255. const binding = __require("@rolldown/binding-freebsd-arm64");
  256. const bindingPackageVersion = __require("@rolldown/binding-freebsd-arm64/package.json").version;
  257. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  258. return binding;
  259. } catch (e) {
  260. loadErrors.push(e);
  261. }
  262. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
  263. } else if (process.platform === "linux") {
  264. if (process.arch === "x64") {
  265. if (isMusl()) {
  266. try {
  267. return __require("./rolldown-binding.linux-x64-musl.node");
  268. } catch (e) {
  269. loadErrors.push(e);
  270. }
  271. try {
  272. const binding = __require("@rolldown/binding-linux-x64-musl");
  273. const bindingPackageVersion = __require("@rolldown/binding-linux-x64-musl/package.json").version;
  274. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  275. return binding;
  276. } catch (e) {
  277. loadErrors.push(e);
  278. }
  279. } else {
  280. try {
  281. return __require("../rolldown-binding.linux-x64-gnu.node");
  282. } catch (e) {
  283. loadErrors.push(e);
  284. }
  285. try {
  286. const binding = __require("@rolldown/binding-linux-x64-gnu");
  287. const bindingPackageVersion = __require("@rolldown/binding-linux-x64-gnu/package.json").version;
  288. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  289. return binding;
  290. } catch (e) {
  291. loadErrors.push(e);
  292. }
  293. }
  294. } else if (process.arch === "arm64") {
  295. if (isMusl()) {
  296. try {
  297. return __require("./rolldown-binding.linux-arm64-musl.node");
  298. } catch (e) {
  299. loadErrors.push(e);
  300. }
  301. try {
  302. const binding = __require("@rolldown/binding-linux-arm64-musl");
  303. const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-musl/package.json").version;
  304. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  305. return binding;
  306. } catch (e) {
  307. loadErrors.push(e);
  308. }
  309. } else {
  310. try {
  311. return __require("./rolldown-binding.linux-arm64-gnu.node");
  312. } catch (e) {
  313. loadErrors.push(e);
  314. }
  315. try {
  316. const binding = __require("@rolldown/binding-linux-arm64-gnu");
  317. const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-gnu/package.json").version;
  318. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  319. return binding;
  320. } catch (e) {
  321. loadErrors.push(e);
  322. }
  323. }
  324. } else if (process.arch === "arm") {
  325. if (isMusl()) {
  326. try {
  327. return __require("./rolldown-binding.linux-arm-musleabihf.node");
  328. } catch (e) {
  329. loadErrors.push(e);
  330. }
  331. try {
  332. const binding = __require("@rolldown/binding-linux-arm-musleabihf");
  333. const bindingPackageVersion = __require("@rolldown/binding-linux-arm-musleabihf/package.json").version;
  334. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  335. return binding;
  336. } catch (e) {
  337. loadErrors.push(e);
  338. }
  339. } else {
  340. try {
  341. return __require("./rolldown-binding.linux-arm-gnueabihf.node");
  342. } catch (e) {
  343. loadErrors.push(e);
  344. }
  345. try {
  346. const binding = __require("@rolldown/binding-linux-arm-gnueabihf");
  347. const bindingPackageVersion = __require("@rolldown/binding-linux-arm-gnueabihf/package.json").version;
  348. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  349. return binding;
  350. } catch (e) {
  351. loadErrors.push(e);
  352. }
  353. }
  354. } else if (process.arch === "loong64") {
  355. if (isMusl()) {
  356. try {
  357. return __require("./rolldown-binding.linux-loong64-musl.node");
  358. } catch (e) {
  359. loadErrors.push(e);
  360. }
  361. try {
  362. const binding = __require("@rolldown/binding-linux-loong64-musl");
  363. const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-musl/package.json").version;
  364. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  365. return binding;
  366. } catch (e) {
  367. loadErrors.push(e);
  368. }
  369. } else {
  370. try {
  371. return __require("./rolldown-binding.linux-loong64-gnu.node");
  372. } catch (e) {
  373. loadErrors.push(e);
  374. }
  375. try {
  376. const binding = __require("@rolldown/binding-linux-loong64-gnu");
  377. const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-gnu/package.json").version;
  378. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  379. return binding;
  380. } catch (e) {
  381. loadErrors.push(e);
  382. }
  383. }
  384. } else if (process.arch === "riscv64") {
  385. if (isMusl()) {
  386. try {
  387. return __require("./rolldown-binding.linux-riscv64-musl.node");
  388. } catch (e) {
  389. loadErrors.push(e);
  390. }
  391. try {
  392. const binding = __require("@rolldown/binding-linux-riscv64-musl");
  393. const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-musl/package.json").version;
  394. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  395. return binding;
  396. } catch (e) {
  397. loadErrors.push(e);
  398. }
  399. } else {
  400. try {
  401. return __require("./rolldown-binding.linux-riscv64-gnu.node");
  402. } catch (e) {
  403. loadErrors.push(e);
  404. }
  405. try {
  406. const binding = __require("@rolldown/binding-linux-riscv64-gnu");
  407. const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-gnu/package.json").version;
  408. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  409. return binding;
  410. } catch (e) {
  411. loadErrors.push(e);
  412. }
  413. }
  414. } else if (process.arch === "ppc64") {
  415. try {
  416. return __require("./rolldown-binding.linux-ppc64-gnu.node");
  417. } catch (e) {
  418. loadErrors.push(e);
  419. }
  420. try {
  421. const binding = __require("@rolldown/binding-linux-ppc64-gnu");
  422. const bindingPackageVersion = __require("@rolldown/binding-linux-ppc64-gnu/package.json").version;
  423. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  424. return binding;
  425. } catch (e) {
  426. loadErrors.push(e);
  427. }
  428. } else if (process.arch === "s390x") {
  429. try {
  430. return __require("./rolldown-binding.linux-s390x-gnu.node");
  431. } catch (e) {
  432. loadErrors.push(e);
  433. }
  434. try {
  435. const binding = __require("@rolldown/binding-linux-s390x-gnu");
  436. const bindingPackageVersion = __require("@rolldown/binding-linux-s390x-gnu/package.json").version;
  437. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  438. return binding;
  439. } catch (e) {
  440. loadErrors.push(e);
  441. }
  442. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
  443. } else if (process.platform === "openharmony") {
  444. if (process.arch === "arm64") {
  445. try {
  446. return __require("./rolldown-binding.openharmony-arm64.node");
  447. } catch (e) {
  448. loadErrors.push(e);
  449. }
  450. try {
  451. const binding = __require("@rolldown/binding-openharmony-arm64");
  452. const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm64/package.json").version;
  453. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  454. return binding;
  455. } catch (e) {
  456. loadErrors.push(e);
  457. }
  458. } else if (process.arch === "x64") {
  459. try {
  460. return __require("./rolldown-binding.openharmony-x64.node");
  461. } catch (e) {
  462. loadErrors.push(e);
  463. }
  464. try {
  465. const binding = __require("@rolldown/binding-openharmony-x64");
  466. const bindingPackageVersion = __require("@rolldown/binding-openharmony-x64/package.json").version;
  467. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  468. return binding;
  469. } catch (e) {
  470. loadErrors.push(e);
  471. }
  472. } else if (process.arch === "arm") {
  473. try {
  474. return __require("./rolldown-binding.openharmony-arm.node");
  475. } catch (e) {
  476. loadErrors.push(e);
  477. }
  478. try {
  479. const binding = __require("@rolldown/binding-openharmony-arm");
  480. const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm/package.json").version;
  481. if (bindingPackageVersion !== "1.2.12" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  482. return binding;
  483. } catch (e) {
  484. loadErrors.push(e);
  485. }
  486. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
  487. } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
  488. }
  489. function createLoadErrorChain(errors) {
  490. return errors.reduce((previous, current) => {
  491. let message;
  492. try {
  493. message = current && typeof current.message === "string" ? current.message : String(current);
  494. } catch {
  495. message = "Unknown error";
  496. }
  497. const error = new Error(message);
  498. error.cause = previous;
  499. return error;
  500. }, null);
  501. }
  502. const __napiWasiFlavors = ["wasm32-wasi"];
  503. const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR;
  504. const __napiWasiFlavorRequested = typeof __napiWasiFlavor === "string" && __napiWasiFlavor.length > 0;
  505. if (__napiWasiFlavorRequested && __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1) throw new Error("Unsupported WASI flavor \"" + __napiWasiFlavor + "\". Available flavors: " + __napiWasiFlavors.join(", "));
  506. const forceWasiError = process.env.NAPI_RS_FORCE_WASI === "error";
  507. const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || forceWasiError || __napiWasiFlavorRequested;
  508. if (!forceWasi) nativeBinding = requireNative();
  509. if (!nativeBinding || forceWasi) {
  510. let wasiBinding = null;
  511. let wasiBindingLoaded = false;
  512. const wasiBindingErrors = [];
  513. const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
  514. try {
  515. __require.resolve(specifier);
  516. } catch (resolveError) {
  517. if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
  518. if (isPackage) {
  519. try {
  520. __require.resolve(specifier + "/package.json");
  521. } catch (packageError) {
  522. if (packageError && packageError.code === "MODULE_NOT_FOUND") return resolveError;
  523. throw resolveError;
  524. }
  525. throw resolveError;
  526. }
  527. return resolveError;
  528. }
  529. if (localArtifacts) {
  530. let artifactError = null;
  531. for (let i = 0; i < localArtifacts.length; i++) try {
  532. __require.resolve(localArtifacts[i]);
  533. return null;
  534. } catch (resolveError) {
  535. if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
  536. artifactError = resolveError;
  537. }
  538. return artifactError;
  539. }
  540. return null;
  541. };
  542. if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
  543. let candidateError = null;
  544. let candidateFailed = false;
  545. try {
  546. candidateError = __napiWasiResolveCandidate("./rolldown-binding.wasi.cjs", false, ["./rolldown-binding.wasm32-wasi.debug.wasm", "./rolldown-binding.wasm32-wasi.wasm"]);
  547. candidateFailed = candidateError !== null;
  548. if (!candidateFailed) {
  549. wasiBinding = __require("../rolldown-binding.wasi.cjs");
  550. nativeBinding = wasiBinding;
  551. __napiLoadedBindingTarget = "wasm32-wasi";
  552. wasiBindingLoaded = true;
  553. }
  554. } catch (err) {
  555. candidateError = err;
  556. candidateFailed = true;
  557. }
  558. if (candidateFailed) {
  559. wasiBindingErrors.push(candidateError);
  560. loadErrors.push(candidateError);
  561. }
  562. }
  563. if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
  564. let candidateError = null;
  565. let candidateFailed = false;
  566. try {
  567. candidateError = __napiWasiResolveCandidate("@rolldown/binding-wasm32-wasi", true, void 0);
  568. candidateFailed = candidateError !== null;
  569. if (!candidateFailed) {
  570. if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
  571. const bindingPackageVersion = __require("@rolldown/binding-wasm32-wasi/package.json").version;
  572. if (bindingPackageVersion !== "1.2.12") throw new Error(`WASI binding package version mismatch, expected 1.2.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
  573. }
  574. wasiBinding = __require("@rolldown/binding-wasm32-wasi");
  575. nativeBinding = wasiBinding;
  576. __napiLoadedBindingTarget = "wasm32-wasi";
  577. wasiBindingLoaded = true;
  578. }
  579. } catch (err) {
  580. candidateError = err;
  581. candidateFailed = true;
  582. }
  583. if (candidateFailed) {
  584. wasiBindingErrors.push(candidateError);
  585. loadErrors.push(candidateError);
  586. }
  587. }
  588. if (!wasiBindingLoaded && forceWasi && !forceWasiError && !__napiWasiFlavorRequested) nativeBinding = requireNative();
  589. if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
  590. const error = /* @__PURE__ */ new Error(__napiWasiFlavorRequested ? "WASI binding for flavor \"" + __napiWasiFlavor + "\" not found" : "WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
  591. error.cause = createLoadErrorChain(wasiBindingErrors);
  592. throw error;
  593. }
  594. }
  595. if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) try {
  596. nativeBinding = require_webcontainer_fallback();
  597. __napiLoadedBindingTarget = "wasm32-wasi";
  598. } catch (err) {
  599. loadErrors.push(err);
  600. }
  601. if (!nativeBinding) {
  602. if (loadErrors.length > 0) {
  603. const error = /* @__PURE__ */ new Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.");
  604. error.cause = createLoadErrorChain(loadErrors);
  605. throw error;
  606. }
  607. throw new Error(`Failed to load native binding`);
  608. }
  609. function __napiStampBindingTarget(exportsObject, target) {
  610. if (Object.prototype.hasOwnProperty.call(exportsObject, "__napiBindingTarget")) {
  611. if (exportsObject.__napiBindingTarget === target) return target;
  612. const error = /* @__PURE__ */ new Error("`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = \"...\")].");
  613. error.code = "ERR_NAPI_BINDING_TARGET_CONFLICT";
  614. throw error;
  615. }
  616. if (!Object.isExtensible(exportsObject)) return target;
  617. try {
  618. Object.defineProperty(exportsObject, "__napiBindingTarget", {
  619. configurable: true,
  620. enumerable: true,
  621. value: target,
  622. writable: true
  623. });
  624. } catch {}
  625. return target;
  626. }
  627. module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget);
  628. module.exports = nativeBinding;
  629. module.exports.LegalCommentsMode = nativeBinding.LegalCommentsMode;
  630. module.exports.minify = nativeBinding.minify;
  631. module.exports.minifySync = nativeBinding.minifySync;
  632. module.exports.Severity = nativeBinding.Severity;
  633. module.exports.ParseResult = nativeBinding.ParseResult;
  634. module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
  635. module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
  636. module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
  637. module.exports.ImportNameKind = nativeBinding.ImportNameKind;
  638. module.exports.parse = nativeBinding.parse;
  639. module.exports.parseSync = nativeBinding.parseSync;
  640. module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
  641. module.exports.ResolverFactory = nativeBinding.ResolverFactory;
  642. module.exports.EnforceExtension = nativeBinding.EnforceExtension;
  643. module.exports.ModuleType = nativeBinding.ModuleType;
  644. module.exports.sync = nativeBinding.sync;
  645. module.exports.HelperMode = nativeBinding.HelperMode;
  646. module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
  647. module.exports.isolatedDeclarationSync = nativeBinding.isolatedDeclarationSync;
  648. module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
  649. module.exports.moduleRunnerTransformSync = nativeBinding.moduleRunnerTransformSync;
  650. module.exports.transform = nativeBinding.transform;
  651. module.exports.transformSync = nativeBinding.transformSync;
  652. module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
  653. module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
  654. module.exports.BindingBundler = nativeBinding.BindingBundler;
  655. module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
  656. module.exports.BindingChunkingContext = nativeBinding.BindingChunkingContext;
  657. module.exports.BindingDecodedMap = nativeBinding.BindingDecodedMap;
  658. module.exports.BindingDevEngine = nativeBinding.BindingDevEngine;
  659. module.exports.BindingLoadPluginContext = nativeBinding.BindingLoadPluginContext;
  660. module.exports.BindingMagicString = nativeBinding.BindingMagicString;
  661. module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
  662. module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
  663. module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
  664. module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
  665. module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
  666. module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
  667. module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
  668. module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
  669. module.exports.BindingSourceMap = nativeBinding.BindingSourceMap;
  670. module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
  671. module.exports.BindingWatcher = nativeBinding.BindingWatcher;
  672. module.exports.BindingWatcherBundler = nativeBinding.BindingWatcherBundler;
  673. module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
  674. module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
  675. module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
  676. module.exports.TraceSubscriberGuard = nativeBinding.TraceSubscriberGuard;
  677. module.exports.TsconfigCache = nativeBinding.TsconfigCache;
  678. module.exports.BindingAttachDebugInfo = nativeBinding.BindingAttachDebugInfo;
  679. module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
  680. module.exports.BindingChunkModuleOrderBy = nativeBinding.BindingChunkModuleOrderBy;
  681. module.exports.BindingErrorStage = nativeBinding.BindingErrorStage;
  682. module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
  683. module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
  684. module.exports.BindingPropertyReadSideEffects = nativeBinding.BindingPropertyReadSideEffects;
  685. module.exports.BindingPropertyWriteSideEffects = nativeBinding.BindingPropertyWriteSideEffects;
  686. module.exports.BindingRebuildStrategy = nativeBinding.BindingRebuildStrategy;
  687. module.exports.collapseSourcemaps = nativeBinding.collapseSourcemaps;
  688. module.exports.enhancedTransform = nativeBinding.enhancedTransform;
  689. module.exports.enhancedTransformSync = nativeBinding.enhancedTransformSync;
  690. module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
  691. module.exports.getNativeMemoryStats = nativeBinding.getNativeMemoryStats;
  692. module.exports.initTraceSubscriber = nativeBinding.initTraceSubscriber;
  693. module.exports.registerPlugins = nativeBinding.registerPlugins;
  694. module.exports.resetNativeMemoryStats = nativeBinding.resetNativeMemoryStats;
  695. module.exports.resolveTsconfig = nativeBinding.resolveTsconfig;
  696. module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
  697. module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
  698. }));
  699. //#endregion
  700. export { __toESM as n, require_binding as t };