@lynx-js/rspeedy 0.14.1 → 0.14.3

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.
@@ -160,7 +160,10 @@ async function findIp(family, isInternal = false) {
160
160
  import("node:os")
161
161
  ]);
162
162
  let host;
163
- const networks = Object.values(os.networkInterfaces()).flatMap((networks)=>networks ?? []).filter((network)=>{
163
+ const networks = Object.entries(os.networkInterfaces()).flatMap(([name, networks])=>(networks ?? []).map((network)=>({
164
+ name,
165
+ network
166
+ }))).filter(({ network })=>{
164
167
  if (!network || !network.address) return false;
165
168
  if (network.family !== `IP${family}`) return false;
166
169
  if (network.internal !== isInternal) return false;
@@ -168,13 +171,36 @@ async function findIp(family, isInternal = false) {
168
171
  const range = ipaddr.parse(network.address).range();
169
172
  if ('ipv4Mapped' !== range && 'uniqueLocal' !== range) return false;
170
173
  }
171
- return network.address;
172
- });
174
+ return true;
175
+ }).sort((left, right)=>getNetworkPriority(left.name, left.network.address) - getNetworkPriority(right.name, right.network.address));
173
176
  if (networks.length > 0) {
174
- host = networks[0].address;
177
+ host = networks[0].network.address;
175
178
  if (host.includes(':')) host = `[${host}]`;
176
179
  }
177
180
  if (!host) throw new Error("No valid IP found");
178
181
  return host;
179
182
  }
183
+ function getNetworkPriority(name, address) {
184
+ const normalizedName = name.toLowerCase();
185
+ if (isPreferredInterface(normalizedName) && !isLinkLocalIpv4(address)) return 0;
186
+ if (!isVirtualInterface(normalizedName) && !isLinkLocalIpv4(address)) return 1;
187
+ if (!isVirtualInterface(normalizedName)) return 2;
188
+ return 3;
189
+ }
190
+ function isPreferredInterface(name) {
191
+ return /^(?:en\d+|eth\d+|eno\d+|enp\w+|wl\w+)$/.test(name);
192
+ }
193
+ function isVirtualInterface(name) {
194
+ return [
195
+ 'utun',
196
+ 'tun',
197
+ 'tap',
198
+ 'awdl',
199
+ 'llw',
200
+ 'lo'
201
+ ].some((prefix)=>name.startsWith(prefix));
202
+ }
203
+ function isLinkLocalIpv4(address) {
204
+ return address.startsWith('169.254.');
205
+ }
180
206
  export { pluginDev };
@@ -14,6 +14,9 @@ function applyDefaultRspeedyConfig(config) {
14
14
  })(),
15
15
  output: {
16
16
  filename: getFilename(config.output?.filename),
17
+ sourceMap: {
18
+ css: true
19
+ },
17
20
  inlineScripts: !enableChunkSplitting,
18
21
  cssModules: {
19
22
  localIdentName: '[local]-[hash:base64:6]'