wreq-js 2.2.0 → 2.2.1

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
@@ -80,6 +80,24 @@ function detectLibc() {
80
80
  }
81
81
  }
82
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
+ function requirePlatformBinary(platformArch) {
84
+ switch (platformArch) {
85
+ case "darwin-x64":
86
+ return require2("../rust/wreq-js.darwin-x64.node");
87
+ case "darwin-arm64":
88
+ return require2("../rust/wreq-js.darwin-arm64.node");
89
+ case "linux-x64-gnu":
90
+ return require2("../rust/wreq-js.linux-x64-gnu.node");
91
+ case "linux-x64-musl":
92
+ return require2("../rust/wreq-js.linux-x64-musl.node");
93
+ case "linux-arm64-gnu":
94
+ return require2("../rust/wreq-js.linux-arm64-gnu.node");
95
+ case "win32-x64-msvc":
96
+ return require2("../rust/wreq-js.win32-x64-msvc.node");
97
+ default:
98
+ return void 0;
99
+ }
100
+ }
83
101
  function loadNativeBinding() {
84
102
  const platform = process.platform;
85
103
  const arch = process.arch;
@@ -101,15 +119,18 @@ function loadNativeBinding() {
101
119
  }
102
120
  const binaryName = `wreq-js.${platformArch}.node`;
103
121
  try {
104
- return require2(`../rust/${binaryName}`);
105
- } catch {
106
- try {
107
- return require2("../rust/wreq-js.node");
108
- } 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
- );
122
+ const platformBinding = requirePlatformBinary(platformArch);
123
+ if (platformBinding) {
124
+ return platformBinding;
112
125
  }
126
+ } catch {
127
+ }
128
+ try {
129
+ return require2("../rust/wreq-js.node");
130
+ } catch {
131
+ throw new Error(
132
+ `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.`
133
+ );
113
134
  }
114
135
  }
115
136
  nativeBinding = loadNativeBinding();