V86Wrapper.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (C) 2024-present Puter Technologies Inc.
  3. *
  4. * This file is part of Puter.
  5. *
  6. * Puter is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. let V86;
  20. if (typeof window !== 'undefined') {
  21. V86 = window.V86;
  22. } else {
  23. try {
  24. const { createRequire } = await import('module');
  25. const require = createRequire(import.meta.url);
  26. const NodeV86 = require("../third-party/libv86.js");
  27. V86 = NodeV86.V86;
  28. } catch (error) {
  29. console.error('Failed to load V86 in Node.js environment:', error);
  30. }
  31. }
  32. export { V86 };