@lynx-js/rspeedy 0.14.2 → 0.14.4

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.
@@ -162,7 +162,10 @@ async function findIp(family, isInternal = false) {
162
162
  import("node:os")
163
163
  ]);
164
164
  let host;
165
- const networks = Object.values(os.networkInterfaces()).flatMap((networks)=>networks ?? []).filter((network)=>{
165
+ const networks = Object.entries(os.networkInterfaces()).flatMap(([name, networks])=>(networks ?? []).map((network)=>({
166
+ name,
167
+ network
168
+ }))).filter(({ network })=>{
166
169
  if (!network || !network.address) return false;
167
170
  if (network.family !== `IP${family}`) return false;
168
171
  if (network.internal !== isInternal) return false;
@@ -170,13 +173,36 @@ async function findIp(family, isInternal = false) {
170
173
  const range = ipaddr.parse(network.address).range();
171
174
  if ('ipv4Mapped' !== range && 'uniqueLocal' !== range) return false;
172
175
  }
173
- return network.address;
174
- });
176
+ return true;
177
+ }).sort((left, right)=>getNetworkPriority(left.name, left.network.address) - getNetworkPriority(right.name, right.network.address));
175
178
  if (networks.length > 0) {
176
- host = networks[0].address;
179
+ host = networks[0].network.address;
177
180
  if (host.includes(':')) host = `[${host}]`;
178
181
  }
179
182
  if (!host) throw new Error("No valid IP found");
180
183
  return host;
181
184
  }
185
+ function getNetworkPriority(name, address) {
186
+ const normalizedName = name.toLowerCase();
187
+ if (isPreferredInterface(normalizedName) && !isLinkLocalIpv4(address)) return 0;
188
+ if (!isVirtualInterface(normalizedName) && !isLinkLocalIpv4(address)) return 1;
189
+ if (!isVirtualInterface(normalizedName)) return 2;
190
+ return 3;
191
+ }
192
+ function isPreferredInterface(name) {
193
+ return /^(?:en\d+|eth\d+|eno\d+|enp\w+|wl\w+)$/.test(name);
194
+ }
195
+ function isVirtualInterface(name) {
196
+ return [
197
+ 'utun',
198
+ 'tun',
199
+ 'tap',
200
+ 'awdl',
201
+ 'llw',
202
+ 'lo'
203
+ ].some((prefix)=>name.startsWith(prefix));
204
+ }
205
+ function isLinkLocalIpv4(address) {
206
+ return address.startsWith('169.254.');
207
+ }
182
208
  export { pluginDev };
package/dist/index.d.ts CHANGED
@@ -20,16 +20,18 @@ import type { CreateRsbuildOptions } from '@rsbuild/core';
20
20
  import type { DataUriLimit } from '@rsbuild/core';
21
21
  import type { DistPathConfig } from '@rsbuild/core';
22
22
  import type { InlineChunkConfig } from '@rsbuild/core';
23
+ import type { Linter } from '@rsdoctor/types';
23
24
  import { logger } from '@rsbuild/core';
24
25
  import type { PerformanceConfig } from '@rsbuild/core';
26
+ import type { Plugin } from '@rsdoctor/types';
25
27
  import type { ProxyConfig } from '@rsbuild/core';
26
28
  import type { RsbuildConfig } from '@rsbuild/core';
29
+ import type { RsbuildEntry } from '@rsbuild/core';
27
30
  import type { RsbuildInstance } from '@rsbuild/core';
28
31
  import { RsbuildPlugin } from '@rsbuild/core';
29
32
  import { RsbuildPluginAPI } from '@rsbuild/core';
30
33
  import type { RsbuildPlugins } from '@rsbuild/core';
31
34
  import { version as rsbuildVersion } from '@rsbuild/core';
32
- import type { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
33
35
  import { Rspack } from '@rsbuild/core';
34
36
  import { rspack } from '@rsbuild/core';
35
37
  import type { ServerConfig } from '@rsbuild/core';
@@ -1543,6 +1545,10 @@ export declare interface ExposedAPI {
1543
1545
  * The version of Rspeedy.
1544
1546
  */
1545
1547
  version: string;
1548
+ /**
1549
+ * Used for plugin qrcode get entry points from self-defined environments rather than default lynx environment.
1550
+ */
1551
+ entries?: RsbuildEntry;
1546
1552
  }
1547
1553
 
1548
1554
  /**
@@ -2775,7 +2781,36 @@ export { RsbuildPluginAPI }
2775
2781
 
2776
2782
  export { rsbuildVersion }
2777
2783
 
2778
- export declare type RsdoctorRspackPluginOptions = ConstructorParameters<typeof RsdoctorRspackPlugin<[]>>[0];
2784
+ declare interface RsdoctorRspackPluginExperiments {
2785
+ /**
2786
+ * Whether to enable the native plugin to improve the performance.
2787
+ * @default true
2788
+ */
2789
+ enableNativePlugin?: boolean;
2790
+ }
2791
+
2792
+ /**
2793
+ * Simplified options type for `tools.rsdoctor`.
2794
+ *
2795
+ * Keep this type free of deeply nested/intersection utility types to ensure
2796
+ * typia can generate validators from `Config`.
2797
+ *
2798
+ * @public
2799
+ */
2800
+ export declare interface RsdoctorRspackPluginOptions extends Omit<RsdoctorRspackPluginOptions_2<[]>, 'linter'> {
2801
+ linter?: {
2802
+ rules?: Record<string, unknown>;
2803
+ level?: 'Ignore' | 'Warn' | 'Error';
2804
+ extends?: unknown[];
2805
+ };
2806
+ }
2807
+
2808
+ declare interface RsdoctorRspackPluginOptions_2<Rules extends Linter.ExtendRuleData[]> extends Plugin.RsdoctorWebpackPluginOptions<Rules> {
2809
+ /**
2810
+ * The experiments of the Rsdoctor Rspack plugin.
2811
+ */
2812
+ experiments?: RsdoctorRspackPluginExperiments;
2813
+ }
2779
2814
 
2780
2815
  export { Rspack }
2781
2816
 
@@ -3500,6 +3535,30 @@ export declare interface SourceMap {
3500
3535
  * ```
3501
3536
  */
3502
3537
  js?: Rspack.DevTool | undefined | `${Exclude<Rspack.DevTool, false | 'eval'>}-debugids`;
3538
+ /**
3539
+ * Whether to generate CSS source maps.
3540
+ *
3541
+ * @remarks
3542
+ *
3543
+ * Defaults to `true`.
3544
+ *
3545
+ * @example
3546
+ *
3547
+ * Disable CSS sourcemap.
3548
+ *
3549
+ * ```js
3550
+ * import { defineConfig } from '@lynx-js/rspeedy'
3551
+ *
3552
+ * export default defineConfig({
3553
+ * output: {
3554
+ * sourceMap: {
3555
+ * css: false,
3556
+ * },
3557
+ * },
3558
+ * })
3559
+ * ```
3560
+ */
3561
+ css?: boolean | undefined;
3503
3562
  }
3504
3563
 
3505
3564
  /**
@@ -192,7 +192,7 @@ async function exit_onExit(signal) {
192
192
  await Promise.allSettled(exitPromises);
193
193
  }
194
194
  var package_namespaceObject = {
195
- rE: "0.14.2"
195
+ rE: "0.14.4"
196
196
  };
197
197
  const version_version = package_namespaceObject.rE;
198
198
  const rspackVersion = rspack.rspackVersion;
@@ -104,6 +104,9 @@ function applyDefaultRspeedyConfig(config) {
104
104
  })(),
105
105
  output: {
106
106
  filename: getFilename(config.output?.filename),
107
+ sourceMap: {
108
+ css: true
109
+ },
107
110
  inlineScripts: !enableChunkSplitting,
108
111
  cssModules: {
109
112
  localIdentName: '[local]-[hash:base64:6]'
@@ -374,7 +377,7 @@ function isDeno() {
374
377
  return false;
375
378
  }
376
379
  var package_namespaceObject = {
377
- rE: "0.14.2"
380
+ rE: "0.14.4"
378
381
  };
379
382
  const version_version = package_namespaceObject.rE;
380
383
  const rspackVersion = rspack.rspackVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/rspeedy",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "A webpack/rspack-based frontend toolchain for Lynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -50,16 +50,17 @@
50
50
  "dependencies": {
51
51
  "@rsbuild/core": "1.7.5",
52
52
  "@rsbuild/plugin-css-minimizer": "1.1.1",
53
- "@rsdoctor/rspack-plugin": "1.2.3",
53
+ "@rsdoctor/rspack-plugin": "~1.5.6",
54
54
  "@lynx-js/cache-events-webpack-plugin": "^0.0.3",
55
- "@lynx-js/chunk-loading-webpack-plugin": "^0.3.3",
56
- "@lynx-js/web-rsbuild-server-middleware": "0.20.2",
55
+ "@lynx-js/chunk-loading-webpack-plugin": "^0.3.4",
56
+ "@lynx-js/web-rsbuild-server-middleware": "0.20.4",
57
57
  "@lynx-js/webpack-dev-transport": "^0.2.0",
58
58
  "@lynx-js/websocket": "^0.0.4"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@microsoft/api-extractor": "7.58.2",
62
62
  "@rollup/plugin-typescript": "^12.3.0",
63
+ "@rsdoctor/core": "~1.5.6",
63
64
  "chokidar": "^4.0.3",
64
65
  "commander": "^13.1.0",
65
66
  "eventemitter3": "^5.0.4",