@npaw/forge-web 10.0.2 → 10.0.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.
package/dist/index.d.cts CHANGED
@@ -17,7 +17,7 @@
17
17
  * The kernel sends the family tokens with every request; a host reads only
18
18
  * what was asked for and omits everything it cannot read.
19
19
  */
20
- type ForgeDeviceMetricFamily = "cpu" | "mem" | "bat" | "thm" | "disk";
20
+ type ForgeDeviceMetricFamily = "cpu" | "mem" | "bat" | "thm" | "disk" | "net";
21
21
  /**
22
22
  * A device runtime health sample, the kernel's `DeviceSample` contract in its
23
23
  * JSON spelling. Every metric field is optional and independently absent: an
@@ -33,7 +33,7 @@ interface ForgeDeviceSample {
33
33
  /**
34
34
  * Cumulative process CPU time, user + system, in milliseconds, monotonic
35
35
  * non-decreasing over the process lifetime. Must be supplied together with
36
- * `cpuCores` on every sample for `dev_cpu` to be derived.
36
+ * `cpuCores` on every sample for the CPU rate to be derived.
37
37
  */
38
38
  cpuTimeMs?: number;
39
39
  /** Logical cores available to the process, at least 1. */
@@ -50,6 +50,20 @@ interface ForgeDeviceSample {
50
50
  thermal?: 0 | 1 | 2 | 3 | 4;
51
51
  /** Free storage on the app's volume, bytes. */
52
52
  diskFreeBytes?: number;
53
+ /** WiFi signal strength, dBm (negative). No browser API — hosts only. */
54
+ netSignalDbm?: number;
55
+ /** Negotiated WiFi PHY link rate, Mbps. No browser API — hosts only. */
56
+ netLinkMbps?: number;
57
+ /**
58
+ * Platform downstream-bandwidth estimate, integer kbps (the kernel emits
59
+ * the `netDownlink` param in Mbps). The browser source is
60
+ * `navigator.connection.downlink` — Chromium only, a privacy-shaped
61
+ * estimate rounded to 25 kbps steps and capped at 10 Mbps ("10" means
62
+ * "10 or more").
63
+ */
64
+ netDownlinkKbps?: number;
65
+ /** WiFi channel frequency, MHz. No browser API — hosts only. */
66
+ netFreqMhz?: number;
53
67
  }
54
68
  /**
55
69
  * Answers a kernel device sample request. Receives the requested family
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  * The kernel sends the family tokens with every request; a host reads only
18
18
  * what was asked for and omits everything it cannot read.
19
19
  */
20
- type ForgeDeviceMetricFamily = "cpu" | "mem" | "bat" | "thm" | "disk";
20
+ type ForgeDeviceMetricFamily = "cpu" | "mem" | "bat" | "thm" | "disk" | "net";
21
21
  /**
22
22
  * A device runtime health sample, the kernel's `DeviceSample` contract in its
23
23
  * JSON spelling. Every metric field is optional and independently absent: an
@@ -33,7 +33,7 @@ interface ForgeDeviceSample {
33
33
  /**
34
34
  * Cumulative process CPU time, user + system, in milliseconds, monotonic
35
35
  * non-decreasing over the process lifetime. Must be supplied together with
36
- * `cpuCores` on every sample for `dev_cpu` to be derived.
36
+ * `cpuCores` on every sample for the CPU rate to be derived.
37
37
  */
38
38
  cpuTimeMs?: number;
39
39
  /** Logical cores available to the process, at least 1. */
@@ -50,6 +50,20 @@ interface ForgeDeviceSample {
50
50
  thermal?: 0 | 1 | 2 | 3 | 4;
51
51
  /** Free storage on the app's volume, bytes. */
52
52
  diskFreeBytes?: number;
53
+ /** WiFi signal strength, dBm (negative). No browser API — hosts only. */
54
+ netSignalDbm?: number;
55
+ /** Negotiated WiFi PHY link rate, Mbps. No browser API — hosts only. */
56
+ netLinkMbps?: number;
57
+ /**
58
+ * Platform downstream-bandwidth estimate, integer kbps (the kernel emits
59
+ * the `netDownlink` param in Mbps). The browser source is
60
+ * `navigator.connection.downlink` — Chromium only, a privacy-shaped
61
+ * estimate rounded to 25 kbps steps and capped at 10 Mbps ("10" means
62
+ * "10 or more").
63
+ */
64
+ netDownlinkKbps?: number;
65
+ /** WiFi channel frequency, MHz. No browser API — hosts only. */
66
+ netFreqMhz?: number;
53
67
  }
54
68
  /**
55
69
  * Answers a kernel device sample request. Receives the requested family
@@ -2050,6 +2050,14 @@ var NPAWForge = (() => {
2050
2050
  hashElementIdentity: false,
2051
2051
  captureElementText: true
2052
2052
  };
2053
+ var CACHE_STATS_RESPONSE_HEADERS = [
2054
+ "cache-status",
2055
+ "cf-cache-status",
2056
+ "x-cache-status",
2057
+ "x-cache",
2058
+ "x-cache-remote"
2059
+ ];
2060
+ var CACHE_STATS_JOIN_KEYS = new Set(CACHE_STATS_RESPONSE_HEADERS);
2053
2061
  var networkCaptureSuppressionDepth = 0;
2054
2062
  var nextNetworkEventId = 1;
2055
2063
  var REMOTE_FOCUS_KEYS = /* @__PURE__ */ new Set([
@@ -3292,7 +3300,11 @@ var NPAWForge = (() => {
3292
3300
  if (Object.keys(requestHeaders).length > 0) {
3293
3301
  observation.requestHeaders = requestHeaders;
3294
3302
  }
3295
- const responseHeaders = result.response ? sanitizeHeaders(result.response.headers, this.options.privacy.allowedResponseHeaders) : sanitizeRawHeaders((_n = (_m = (_l = result.xhr) == null ? void 0 : _l.getAllResponseHeaders) == null ? void 0 : _m.call(_l)) != null ? _n : "", this.options.privacy.allowedResponseHeaders);
3303
+ const responseHeaderNames = [
3304
+ ...this.options.privacy.allowedResponseHeaders,
3305
+ ...CACHE_STATS_RESPONSE_HEADERS
3306
+ ];
3307
+ const responseHeaders = result.response ? sanitizeHeaders(result.response.headers, responseHeaderNames) : sanitizeRawHeaders((_n = (_m = (_l = result.xhr) == null ? void 0 : _l.getAllResponseHeaders) == null ? void 0 : _m.call(_l)) != null ? _n : "", responseHeaderNames);
3296
3308
  if (Object.keys(responseHeaders).length > 0) {
3297
3309
  observation.responseHeaders = responseHeaders;
3298
3310
  }
@@ -3717,8 +3729,14 @@ var NPAWForge = (() => {
3717
3729
  continue;
3718
3730
  }
3719
3731
  const key = line.slice(0, separator).trim().toLowerCase();
3720
- if (allowed.has(key)) {
3721
- output[key] = sanitizeCaptureString(line.slice(separator + 1).trim());
3732
+ if (!allowed.has(key)) {
3733
+ continue;
3734
+ }
3735
+ const value = sanitizeCaptureString(line.slice(separator + 1).trim());
3736
+ if (output[key] !== void 0 && CACHE_STATS_JOIN_KEYS.has(key)) {
3737
+ output[key] = `${output[key]}, ${value}`;
3738
+ } else {
3739
+ output[key] = value;
3722
3740
  }
3723
3741
  }
3724
3742
  return output;
@@ -3828,7 +3846,11 @@ var NPAWForge = (() => {
3828
3846
  "batteryLevelPct",
3829
3847
  "batteryCharging",
3830
3848
  "thermal",
3831
- "diskFreeBytes"
3849
+ "diskFreeBytes",
3850
+ "netSignalDbm",
3851
+ "netLinkMbps",
3852
+ "netDownlinkKbps",
3853
+ "netFreqMhz"
3832
3854
  ];
3833
3855
  async function collectBrowserDeviceSample(families, environment = readBrowserDeviceInsightsEnvironment()) {
3834
3856
  const sample = {};
@@ -3847,6 +3869,12 @@ var NPAWForge = (() => {
3847
3869
  sample.batteryCharging = battery.charging;
3848
3870
  }
3849
3871
  }
3872
+ if (families.includes("net")) {
3873
+ const downlinkKbps = readDownlinkKbps(environment);
3874
+ if (downlinkKbps !== void 0) {
3875
+ sample.netDownlinkKbps = downlinkKbps;
3876
+ }
3877
+ }
3850
3878
  return hasDeviceMetric(sample) ? sample : void 0;
3851
3879
  }
3852
3880
  function hasDeviceMetric(sample) {
@@ -3904,6 +3932,22 @@ var NPAWForge = (() => {
3904
3932
  }
3905
3933
  return result;
3906
3934
  }
3935
+ function readDownlinkKbps(environment) {
3936
+ var _a;
3937
+ if (!environment.connection) {
3938
+ return void 0;
3939
+ }
3940
+ let downlink;
3941
+ try {
3942
+ downlink = (_a = environment.connection()) == null ? void 0 : _a.downlink;
3943
+ } catch (e2) {
3944
+ return void 0;
3945
+ }
3946
+ if (typeof downlink !== "number" || !Number.isFinite(downlink) || downlink <= 0) {
3947
+ return void 0;
3948
+ }
3949
+ return Math.round(downlink * 1e3);
3950
+ }
3907
3951
  function readBrowserDeviceInsightsEnvironment() {
3908
3952
  const environment = {};
3909
3953
  const performanceRef = globalThis.performance;
@@ -3914,6 +3958,10 @@ var NPAWForge = (() => {
3914
3958
  if (navigatorRef && typeof navigatorRef.getBattery === "function") {
3915
3959
  environment.getBattery = () => navigatorRef.getBattery();
3916
3960
  }
3961
+ const connectionRef = navigatorRef == null ? void 0 : navigatorRef.connection;
3962
+ if (connectionRef && typeof connectionRef === "object") {
3963
+ environment.connection = () => connectionRef;
3964
+ }
3917
3965
  return environment;
3918
3966
  }
3919
3967