| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 |
- import { createRequire } from "node:module";
- //#region \0rolldown/runtime.js
- var __create = Object.create;
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __getProtoOf = Object.getPrototypeOf;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
- key = keys[i];
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
- get: ((k) => from[k]).bind(null, key),
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
- });
- }
- return to;
- };
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
- value: mod,
- enumerable: true
- }) : target, mod));
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
- //#endregion
- //#region src/webcontainer-fallback.cjs
- var require_webcontainer_fallback = /* @__PURE__ */ __commonJSMin(((exports, module) => {
- const fs = __require("node:fs");
- const childProcess = __require("node:child_process");
- const version = JSON.parse(fs.readFileSync(__require.resolve("rolldown/package.json"), "utf-8")).version;
- const baseDir = `/tmp/rolldown-${version}`;
- const bindingEntry = `${baseDir}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;
- if (!fs.existsSync(bindingEntry)) {
- const bindingPkg = `@rolldown/binding-wasm32-wasi@${version}`;
- fs.rmSync(baseDir, {
- recursive: true,
- force: true
- });
- fs.mkdirSync(baseDir, { recursive: true });
- console.log(`[rolldown] Downloading ${bindingPkg} on WebContainer...`);
- childProcess.execFileSync("pnpm", ["i", bindingPkg], {
- cwd: baseDir,
- stdio: "inherit"
- });
- }
- module.exports = __require(bindingEntry);
- }));
- //#endregion
- //#region src/binding.cjs
- var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
- const { readFileSync } = __require("fs");
- let nativeBinding = null;
- let __napiLoadedBindingTarget = "native";
- const loadErrors = [];
- const isMusl = () => {
- let musl = false;
- if (process.platform === "linux") {
- musl = isMuslFromFilesystem();
- if (musl === null) musl = isMuslFromReport();
- if (musl === null) musl = isMuslFromChildProcess();
- }
- return musl;
- };
- const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
- const isMuslFromFilesystem = () => {
- try {
- return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
- } catch {
- return null;
- }
- };
- const isMuslFromReport = () => {
- let report = null;
- if (process.report && typeof process.report.getReport === "function") {
- process.report.excludeNetwork = true;
- report = process.report.getReport();
- }
- if (!report) return null;
- if (report.header && report.header.glibcVersionRuntime) return false;
- if (Array.isArray(report.sharedObjects)) {
- if (report.sharedObjects.some(isFileMusl)) return true;
- }
- return false;
- };
- const isMuslFromChildProcess = () => {
- try {
- return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
- } catch (e) {
- return false;
- }
- };
- function requireNative() {
- if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
- const overrideBinding = __require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
- __napiLoadedBindingTarget = overrideBinding && typeof overrideBinding.__napiBindingTarget === "string" ? overrideBinding.__napiBindingTarget : "native";
- return overrideBinding;
- } catch (err) {
- loadErrors.push(err);
- }
- else if (process.platform === "android") {
- if (process.arch === "arm64") {
- try {
- return __require("./rolldown-binding.android-arm64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-android-arm64");
- const bindingPackageVersion = __require("@rolldown/binding-android-arm64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "arm") {
- try {
- return __require("./rolldown-binding.android-arm-eabi.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-android-arm-eabi");
- const bindingPackageVersion = __require("@rolldown/binding-android-arm-eabi/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
- } else if (process.platform === "win32") {
- if (process.arch === "x64") {
- 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") {
- try {
- return __require("./rolldown-binding.win32-x64-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-win32-x64-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-win32-x64-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else {
- try {
- return __require("./rolldown-binding.win32-x64-msvc.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-win32-x64-msvc");
- const bindingPackageVersion = __require("@rolldown/binding-win32-x64-msvc/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- }
- } else if (process.arch === "ia32") {
- try {
- return __require("./rolldown-binding.win32-ia32-msvc.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-win32-ia32-msvc");
- const bindingPackageVersion = __require("@rolldown/binding-win32-ia32-msvc/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "arm64") {
- try {
- return __require("./rolldown-binding.win32-arm64-msvc.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-win32-arm64-msvc");
- const bindingPackageVersion = __require("@rolldown/binding-win32-arm64-msvc/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
- } else if (process.platform === "darwin") {
- try {
- return __require("./rolldown-binding.darwin-universal.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-darwin-universal");
- const bindingPackageVersion = __require("@rolldown/binding-darwin-universal/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- if (process.arch === "x64") {
- try {
- return __require("./rolldown-binding.darwin-x64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-darwin-x64");
- const bindingPackageVersion = __require("@rolldown/binding-darwin-x64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "arm64") {
- try {
- return __require("./rolldown-binding.darwin-arm64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-darwin-arm64");
- const bindingPackageVersion = __require("@rolldown/binding-darwin-arm64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
- } else if (process.platform === "freebsd") {
- if (process.arch === "x64") {
- try {
- return __require("./rolldown-binding.freebsd-x64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-freebsd-x64");
- const bindingPackageVersion = __require("@rolldown/binding-freebsd-x64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "arm64") {
- try {
- return __require("./rolldown-binding.freebsd-arm64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-freebsd-arm64");
- const bindingPackageVersion = __require("@rolldown/binding-freebsd-arm64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
- } else if (process.platform === "linux") {
- if (process.arch === "x64") {
- if (isMusl()) {
- try {
- return __require("./rolldown-binding.linux-x64-musl.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-x64-musl");
- const bindingPackageVersion = __require("@rolldown/binding-linux-x64-musl/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else {
- try {
- return __require("../rolldown-binding.linux-x64-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-x64-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-linux-x64-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- }
- } else if (process.arch === "arm64") {
- if (isMusl()) {
- try {
- return __require("./rolldown-binding.linux-arm64-musl.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-arm64-musl");
- const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-musl/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else {
- try {
- return __require("./rolldown-binding.linux-arm64-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-arm64-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- }
- } else if (process.arch === "arm") {
- if (isMusl()) {
- try {
- return __require("./rolldown-binding.linux-arm-musleabihf.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-arm-musleabihf");
- const bindingPackageVersion = __require("@rolldown/binding-linux-arm-musleabihf/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else {
- try {
- return __require("./rolldown-binding.linux-arm-gnueabihf.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-arm-gnueabihf");
- const bindingPackageVersion = __require("@rolldown/binding-linux-arm-gnueabihf/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- }
- } else if (process.arch === "loong64") {
- if (isMusl()) {
- try {
- return __require("./rolldown-binding.linux-loong64-musl.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-loong64-musl");
- const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-musl/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else {
- try {
- return __require("./rolldown-binding.linux-loong64-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-loong64-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- }
- } else if (process.arch === "riscv64") {
- if (isMusl()) {
- try {
- return __require("./rolldown-binding.linux-riscv64-musl.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-riscv64-musl");
- const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-musl/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else {
- try {
- return __require("./rolldown-binding.linux-riscv64-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-riscv64-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- }
- } else if (process.arch === "ppc64") {
- try {
- return __require("./rolldown-binding.linux-ppc64-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-ppc64-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-linux-ppc64-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "s390x") {
- try {
- return __require("./rolldown-binding.linux-s390x-gnu.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-linux-s390x-gnu");
- const bindingPackageVersion = __require("@rolldown/binding-linux-s390x-gnu/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
- } else if (process.platform === "openharmony") {
- if (process.arch === "arm64") {
- try {
- return __require("./rolldown-binding.openharmony-arm64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-openharmony-arm64");
- const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "x64") {
- try {
- return __require("./rolldown-binding.openharmony-x64.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-openharmony-x64");
- const bindingPackageVersion = __require("@rolldown/binding-openharmony-x64/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else if (process.arch === "arm") {
- try {
- return __require("./rolldown-binding.openharmony-arm.node");
- } catch (e) {
- loadErrors.push(e);
- }
- try {
- const binding = __require("@rolldown/binding-openharmony-arm");
- const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm/package.json").version;
- 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.`);
- return binding;
- } catch (e) {
- loadErrors.push(e);
- }
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
- } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
- }
- function createLoadErrorChain(errors) {
- return errors.reduce((previous, current) => {
- let message;
- try {
- message = current && typeof current.message === "string" ? current.message : String(current);
- } catch {
- message = "Unknown error";
- }
- const error = new Error(message);
- error.cause = previous;
- return error;
- }, null);
- }
- const __napiWasiFlavors = ["wasm32-wasi"];
- const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR;
- const __napiWasiFlavorRequested = typeof __napiWasiFlavor === "string" && __napiWasiFlavor.length > 0;
- if (__napiWasiFlavorRequested && __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1) throw new Error("Unsupported WASI flavor \"" + __napiWasiFlavor + "\". Available flavors: " + __napiWasiFlavors.join(", "));
- const forceWasiError = process.env.NAPI_RS_FORCE_WASI === "error";
- const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || forceWasiError || __napiWasiFlavorRequested;
- if (!forceWasi) nativeBinding = requireNative();
- if (!nativeBinding || forceWasi) {
- let wasiBinding = null;
- let wasiBindingLoaded = false;
- const wasiBindingErrors = [];
- const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
- try {
- __require.resolve(specifier);
- } catch (resolveError) {
- if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
- if (isPackage) {
- try {
- __require.resolve(specifier + "/package.json");
- } catch (packageError) {
- if (packageError && packageError.code === "MODULE_NOT_FOUND") return resolveError;
- throw resolveError;
- }
- throw resolveError;
- }
- return resolveError;
- }
- if (localArtifacts) {
- let artifactError = null;
- for (let i = 0; i < localArtifacts.length; i++) try {
- __require.resolve(localArtifacts[i]);
- return null;
- } catch (resolveError) {
- if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") throw resolveError;
- artifactError = resolveError;
- }
- return artifactError;
- }
- return null;
- };
- if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
- let candidateError = null;
- let candidateFailed = false;
- try {
- candidateError = __napiWasiResolveCandidate("./rolldown-binding.wasi.cjs", false, ["./rolldown-binding.wasm32-wasi.debug.wasm", "./rolldown-binding.wasm32-wasi.wasm"]);
- candidateFailed = candidateError !== null;
- if (!candidateFailed) {
- wasiBinding = __require("../rolldown-binding.wasi.cjs");
- nativeBinding = wasiBinding;
- __napiLoadedBindingTarget = "wasm32-wasi";
- wasiBindingLoaded = true;
- }
- } catch (err) {
- candidateError = err;
- candidateFailed = true;
- }
- if (candidateFailed) {
- wasiBindingErrors.push(candidateError);
- loadErrors.push(candidateError);
- }
- }
- if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
- let candidateError = null;
- let candidateFailed = false;
- try {
- candidateError = __napiWasiResolveCandidate("@rolldown/binding-wasm32-wasi", true, void 0);
- candidateFailed = candidateError !== null;
- if (!candidateFailed) {
- if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
- const bindingPackageVersion = __require("@rolldown/binding-wasm32-wasi/package.json").version;
- 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.`);
- }
- wasiBinding = __require("@rolldown/binding-wasm32-wasi");
- nativeBinding = wasiBinding;
- __napiLoadedBindingTarget = "wasm32-wasi";
- wasiBindingLoaded = true;
- }
- } catch (err) {
- candidateError = err;
- candidateFailed = true;
- }
- if (candidateFailed) {
- wasiBindingErrors.push(candidateError);
- loadErrors.push(candidateError);
- }
- }
- if (!wasiBindingLoaded && forceWasi && !forceWasiError && !__napiWasiFlavorRequested) nativeBinding = requireNative();
- if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
- 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");
- error.cause = createLoadErrorChain(wasiBindingErrors);
- throw error;
- }
- }
- if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) try {
- nativeBinding = require_webcontainer_fallback();
- __napiLoadedBindingTarget = "wasm32-wasi";
- } catch (err) {
- loadErrors.push(err);
- }
- if (!nativeBinding) {
- if (loadErrors.length > 0) {
- 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.");
- error.cause = createLoadErrorChain(loadErrors);
- throw error;
- }
- throw new Error(`Failed to load native binding`);
- }
- function __napiStampBindingTarget(exportsObject, target) {
- if (Object.prototype.hasOwnProperty.call(exportsObject, "__napiBindingTarget")) {
- if (exportsObject.__napiBindingTarget === target) return target;
- 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 = \"...\")].");
- error.code = "ERR_NAPI_BINDING_TARGET_CONFLICT";
- throw error;
- }
- if (!Object.isExtensible(exportsObject)) return target;
- try {
- Object.defineProperty(exportsObject, "__napiBindingTarget", {
- configurable: true,
- enumerable: true,
- value: target,
- writable: true
- });
- } catch {}
- return target;
- }
- module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget);
- module.exports = nativeBinding;
- module.exports.LegalCommentsMode = nativeBinding.LegalCommentsMode;
- module.exports.minify = nativeBinding.minify;
- module.exports.minifySync = nativeBinding.minifySync;
- module.exports.Severity = nativeBinding.Severity;
- module.exports.ParseResult = nativeBinding.ParseResult;
- module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
- module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
- module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
- module.exports.ImportNameKind = nativeBinding.ImportNameKind;
- module.exports.parse = nativeBinding.parse;
- module.exports.parseSync = nativeBinding.parseSync;
- module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
- module.exports.ResolverFactory = nativeBinding.ResolverFactory;
- module.exports.EnforceExtension = nativeBinding.EnforceExtension;
- module.exports.ModuleType = nativeBinding.ModuleType;
- module.exports.sync = nativeBinding.sync;
- module.exports.HelperMode = nativeBinding.HelperMode;
- module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
- module.exports.isolatedDeclarationSync = nativeBinding.isolatedDeclarationSync;
- module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
- module.exports.moduleRunnerTransformSync = nativeBinding.moduleRunnerTransformSync;
- module.exports.transform = nativeBinding.transform;
- module.exports.transformSync = nativeBinding.transformSync;
- module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
- module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
- module.exports.BindingBundler = nativeBinding.BindingBundler;
- module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
- module.exports.BindingChunkingContext = nativeBinding.BindingChunkingContext;
- module.exports.BindingDecodedMap = nativeBinding.BindingDecodedMap;
- module.exports.BindingDevEngine = nativeBinding.BindingDevEngine;
- module.exports.BindingLoadPluginContext = nativeBinding.BindingLoadPluginContext;
- module.exports.BindingMagicString = nativeBinding.BindingMagicString;
- module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
- module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
- module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
- module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
- module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
- module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
- module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
- module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
- module.exports.BindingSourceMap = nativeBinding.BindingSourceMap;
- module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
- module.exports.BindingWatcher = nativeBinding.BindingWatcher;
- module.exports.BindingWatcherBundler = nativeBinding.BindingWatcherBundler;
- module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
- module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
- module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
- module.exports.TraceSubscriberGuard = nativeBinding.TraceSubscriberGuard;
- module.exports.TsconfigCache = nativeBinding.TsconfigCache;
- module.exports.BindingAttachDebugInfo = nativeBinding.BindingAttachDebugInfo;
- module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
- module.exports.BindingChunkModuleOrderBy = nativeBinding.BindingChunkModuleOrderBy;
- module.exports.BindingErrorStage = nativeBinding.BindingErrorStage;
- module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
- module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
- module.exports.BindingPropertyReadSideEffects = nativeBinding.BindingPropertyReadSideEffects;
- module.exports.BindingPropertyWriteSideEffects = nativeBinding.BindingPropertyWriteSideEffects;
- module.exports.BindingRebuildStrategy = nativeBinding.BindingRebuildStrategy;
- module.exports.collapseSourcemaps = nativeBinding.collapseSourcemaps;
- module.exports.enhancedTransform = nativeBinding.enhancedTransform;
- module.exports.enhancedTransformSync = nativeBinding.enhancedTransformSync;
- module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
- module.exports.getNativeMemoryStats = nativeBinding.getNativeMemoryStats;
- module.exports.initTraceSubscriber = nativeBinding.initTraceSubscriber;
- module.exports.registerPlugins = nativeBinding.registerPlugins;
- module.exports.resetNativeMemoryStats = nativeBinding.resetNativeMemoryStats;
- module.exports.resolveTsconfig = nativeBinding.resolveTsconfig;
- module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
- module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
- }));
- //#endregion
- export { __toESM as n, require_binding as t };
|