wreq-js 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wreq-js.cjs CHANGED
@@ -41,7 +41,6 @@ __export(wreq_js_exports, {
41
41
  module.exports = __toCommonJS(wreq_js_exports);
42
42
  var import_node_crypto = require("crypto");
43
43
  var import_node_http = require("http");
44
- var import_node_module = require("module");
45
44
  var import_node_stream = require("stream");
46
45
  var import_web = require("stream/web");
47
46
 
@@ -54,7 +53,6 @@ var RequestError = class extends TypeError {
54
53
  };
55
54
 
56
55
  // src/wreq-js.ts
57
- var import_meta = {};
58
56
  var nativeBinding;
59
57
  var cachedProfiles;
60
58
  var cachedProfileSet;
@@ -79,38 +77,91 @@ function detectLibc() {
79
77
  return "gnu";
80
78
  }
81
79
  }
82
- var require2 = typeof import_meta !== "undefined" && import_meta.url ? (0, import_node_module.createRequire)(import_meta.url) : (0, import_node_module.createRequire)(__filename);
83
80
  function loadNativeBinding() {
84
81
  const platform = process.platform;
85
82
  const arch = process.arch;
86
83
  const libc = detectLibc();
87
- const platformArchMap = {
88
- darwin: { x64: "darwin-x64", arm64: "darwin-arm64" },
89
- linux: {
90
- x64: { gnu: "linux-x64-gnu", musl: "linux-x64-musl" },
91
- arm64: "linux-arm64-gnu"
92
- },
93
- win32: { x64: "win32-x64-msvc" }
94
- };
95
- const platformArchMapEntry = platformArchMap[platform]?.[arch];
96
- const platformArch = typeof platformArchMapEntry === "string" ? platformArchMapEntry : platformArchMapEntry?.[libc ?? "gnu"];
97
- if (!platformArch) {
98
- throw new Error(
99
- `Unsupported platform: ${platform}-${arch}${libc ? `-${libc}` : ""}. Supported platforms: darwin-x64, darwin-arm64, linux-x64-gnu, linux-x64-musl, linux-arm64-gnu, win32-x64-msvc`
100
- );
84
+ if (platform === "darwin" && arch === "x64") {
85
+ try {
86
+ return require("../rust/wreq-js.darwin-x64.node");
87
+ } catch {
88
+ try {
89
+ return require("../rust/wreq-js.node");
90
+ } catch {
91
+ throw new Error(
92
+ "Failed to load native module for darwin-x64. Tried: ../rust/wreq-js.darwin-x64.node and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform."
93
+ );
94
+ }
95
+ }
101
96
  }
102
- const binaryName = `wreq-js.${platformArch}.node`;
103
- try {
104
- return require2(`../rust/${binaryName}`);
105
- } catch {
97
+ if (platform === "darwin" && arch === "arm64") {
106
98
  try {
107
- return require2("../rust/wreq-js.node");
99
+ return require("../rust/wreq-js.darwin-arm64.node");
108
100
  } catch {
109
- throw new Error(
110
- `Failed to load native module for ${platform}-${arch}. Tried: ../rust/${binaryName} and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform.`
111
- );
101
+ try {
102
+ return require("../rust/wreq-js.node");
103
+ } catch {
104
+ throw new Error(
105
+ "Failed to load native module for darwin-arm64. Tried: ../rust/wreq-js.darwin-arm64.node and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform."
106
+ );
107
+ }
112
108
  }
113
109
  }
110
+ if (platform === "linux" && arch === "x64") {
111
+ if (libc === "musl") {
112
+ try {
113
+ return require("../rust/wreq-js.linux-x64-musl.node");
114
+ } catch {
115
+ try {
116
+ return require("../rust/wreq-js.node");
117
+ } catch {
118
+ throw new Error(
119
+ "Failed to load native module for linux-x64-musl. Tried: ../rust/wreq-js.linux-x64-musl.node and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform."
120
+ );
121
+ }
122
+ }
123
+ }
124
+ try {
125
+ return require("../rust/wreq-js.linux-x64-gnu.node");
126
+ } catch {
127
+ try {
128
+ return require("../rust/wreq-js.node");
129
+ } catch {
130
+ throw new Error(
131
+ "Failed to load native module for linux-x64-gnu. Tried: ../rust/wreq-js.linux-x64-gnu.node and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform."
132
+ );
133
+ }
134
+ }
135
+ }
136
+ if (platform === "linux" && arch === "arm64") {
137
+ try {
138
+ return require("../rust/wreq-js.linux-arm64-gnu.node");
139
+ } catch {
140
+ try {
141
+ return require("../rust/wreq-js.node");
142
+ } catch {
143
+ throw new Error(
144
+ "Failed to load native module for linux-arm64-gnu. Tried: ../rust/wreq-js.linux-arm64-gnu.node and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform."
145
+ );
146
+ }
147
+ }
148
+ }
149
+ if (platform === "win32" && arch === "x64") {
150
+ try {
151
+ return require("../rust/wreq-js.win32-x64-msvc.node");
152
+ } catch {
153
+ try {
154
+ return require("../rust/wreq-js.node");
155
+ } catch {
156
+ throw new Error(
157
+ "Failed to load native module for win32-x64-msvc. Tried: ../rust/wreq-js.win32-x64-msvc.node and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform."
158
+ );
159
+ }
160
+ }
161
+ }
162
+ throw new Error(
163
+ `Unsupported platform: ${platform}-${arch}${libc ? `-${libc}` : ""}. Supported platforms: darwin-x64, darwin-arm64, linux-x64-gnu, linux-x64-musl, linux-arm64-gnu, win32-x64-msvc`
164
+ );
114
165
  }
115
166
  nativeBinding = loadNativeBinding();
116
167
  var websocketFinalizer = typeof FinalizationRegistry === "function" ? new FinalizationRegistry((connection) => {