@npaw/forge-web 9.7.3 → 9.7.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.
- package/dist/forge_kernel_wasm_bg.wasm +0 -0
- package/dist/index.cjs +162 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -1
- package/dist/index.d.ts +114 -1
- package/dist/index.global.js +162 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +162 -3
- package/dist/index.js.map +1 -1
- package/dist/npaw-forge-web.iife.js +163 -4
- package/dist/npaw-forge-web.iife.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) NPAW - All Rights Reserved
|
|
3
|
+
*
|
|
4
|
+
* This source code is protected under international copyright law. All rights
|
|
5
|
+
* reserved and protected by the copyright holders.
|
|
6
|
+
* This file is confidential and only available to authorized individuals with the
|
|
7
|
+
* permission of the copyright holders. If you encounter this file and do not have
|
|
8
|
+
* permission, please contact the copyright holders and delete this file.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
|
+
* @description: Web device-insights collector answering the kernel's device sample requests with the few runtime health facts a browser can honestly read (Chromium JS heap, Battery Status API), everything else omitted.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The metric families the kernel can ask for (`di.m` in remote config).
|
|
16
|
+
*
|
|
17
|
+
* The kernel sends the family tokens with every request; a host reads only
|
|
18
|
+
* what was asked for and omits everything it cannot read.
|
|
19
|
+
*/
|
|
20
|
+
type ForgeDeviceMetricFamily = "cpu" | "mem" | "bat" | "thm" | "disk";
|
|
21
|
+
/**
|
|
22
|
+
* A device runtime health sample, the kernel's `DeviceSample` contract in its
|
|
23
|
+
* JSON spelling. Every metric field is optional and independently absent: an
|
|
24
|
+
* omitted field is an absent metric and the kernel then omits the metric on
|
|
25
|
+
* the wire — never send `0`, `-1`, `null` or a placeholder for "unknown".
|
|
26
|
+
*/
|
|
27
|
+
interface ForgeDeviceSample {
|
|
28
|
+
/**
|
|
29
|
+
* Wall clock at read time, milliseconds since the Unix epoch. Filled with
|
|
30
|
+
* the runtime clock (`Date.now()` by default) when omitted.
|
|
31
|
+
*/
|
|
32
|
+
sampledAtMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Cumulative process CPU time, user + system, in milliseconds, monotonic
|
|
35
|
+
* non-decreasing over the process lifetime. Must be supplied together with
|
|
36
|
+
* `cpuCores` on every sample for `dev_cpu` to be derived.
|
|
37
|
+
*/
|
|
38
|
+
cpuTimeMs?: number;
|
|
39
|
+
/** Logical cores available to the process, at least 1. */
|
|
40
|
+
cpuCores?: number;
|
|
41
|
+
/** Process resident / footprint memory, bytes. */
|
|
42
|
+
memUsedBytes?: number;
|
|
43
|
+
/** Memory available to the app, bytes. */
|
|
44
|
+
memAvailBytes?: number;
|
|
45
|
+
/** Battery level, integer percent 0..100. */
|
|
46
|
+
batteryLevelPct?: number;
|
|
47
|
+
/** Whether the device is charging. */
|
|
48
|
+
batteryCharging?: boolean;
|
|
49
|
+
/** Thermal state on the kernel's normalised ordinal: 0 nominal … 4 emergency. */
|
|
50
|
+
thermal?: 0 | 1 | 2 | 3 | 4;
|
|
51
|
+
/** Free storage on the app's volume, bytes. */
|
|
52
|
+
diskFreeBytes?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Answers a kernel device sample request. Receives the requested family
|
|
56
|
+
* tokens and returns a sample (or nothing). The kernel owns the cadence: this
|
|
57
|
+
* is called only while an operator enabled device insights, at the configured
|
|
58
|
+
* interval, so a collector must never schedule its own reads.
|
|
59
|
+
*/
|
|
60
|
+
type ForgeDeviceSampleCollector = (families: readonly string[]) => ForgeDeviceSample | undefined | Promise<ForgeDeviceSample | undefined>;
|
|
61
|
+
|
|
1
62
|
/**
|
|
2
63
|
* Copyright (C) NPAW - All Rights Reserved
|
|
3
64
|
*
|
|
@@ -11,6 +72,7 @@
|
|
|
11
72
|
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
73
|
* @description: Public and internal TypeScript contracts for the Forge Web facade.
|
|
13
74
|
*/
|
|
75
|
+
|
|
14
76
|
type ForgeParamValue = string | number | boolean | null | undefined;
|
|
15
77
|
type ForgeParams = Record<string, ForgeParamValue>;
|
|
16
78
|
type NormalizedParams = Record<string, string>;
|
|
@@ -135,6 +197,32 @@ interface ForgeCreateOptions extends ForgeRuntimeConfig {
|
|
|
135
197
|
* @defaultValue true
|
|
136
198
|
*/
|
|
137
199
|
autoLocation?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Disables the built-in device insights reader.
|
|
202
|
+
*
|
|
203
|
+
* Device insights are **off by default** and enabled per account from the
|
|
204
|
+
* Forge Console (`di` remote-config group); the kernel then asks the host
|
|
205
|
+
* for a sample at the configured cadence. On the Web the built-in reader
|
|
206
|
+
* answers with what a browser can honestly provide - the Chromium JS heap
|
|
207
|
+
* size (`performance.memory`) and the Battery Status API
|
|
208
|
+
* (`navigator.getBattery()`) - and omits everything else (CPU, thermal,
|
|
209
|
+
* free disk, available memory) rather than defaulting it. Browsers without
|
|
210
|
+
* those APIs (Safari, Firefox) answer nothing at all. Set this to `false`
|
|
211
|
+
* when your host supplies its own samples through `recordDeviceSample`, or
|
|
212
|
+
* to make Forge read nothing regardless of the remote switch.
|
|
213
|
+
*
|
|
214
|
+
* @defaultValue true
|
|
215
|
+
*/
|
|
216
|
+
autoDeviceInsights?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Answers the kernel's device sample requests instead of the built-in
|
|
219
|
+
* browser reader, for hosts that can read more than a browser can (Electron
|
|
220
|
+
* `process.cpuUsage()` / `process.memoryUsage()`, smart-TV device APIs).
|
|
221
|
+
* Called only while an operator enabled device insights, at the configured
|
|
222
|
+
* cadence, with the requested family tokens; return the fields you can read
|
|
223
|
+
* and omit the rest. Takes precedence over `autoDeviceInsights`.
|
|
224
|
+
*/
|
|
225
|
+
deviceSampleCollector?: ForgeDeviceSampleCollector;
|
|
138
226
|
startSessionOnInitialize?: boolean;
|
|
139
227
|
initialSessionParams?: ForgeParams;
|
|
140
228
|
capture?: ForgeCaptureOptions;
|
|
@@ -404,6 +492,14 @@ interface WasmCapturePlan {
|
|
|
404
492
|
* Omitted when empty.
|
|
405
493
|
*/
|
|
406
494
|
targetDataAttributes?: string[];
|
|
495
|
+
/**
|
|
496
|
+
* Device-insights metric families the kernel will request (`di.m`, canonical
|
|
497
|
+
* order); present only while the `DEVICE_INSIGHTS` bit is set. Lets a host
|
|
498
|
+
* pre-arm an observer a family needs; the Web reader needs none, so it is
|
|
499
|
+
* informational here. The `deviceSampleRequest` effect, not the plan, is
|
|
500
|
+
* what triggers a read.
|
|
501
|
+
*/
|
|
502
|
+
deviceInsightFamilies?: string[];
|
|
407
503
|
hash: string;
|
|
408
504
|
}
|
|
409
505
|
interface WasmCapturePlanFocus {
|
|
@@ -480,6 +576,11 @@ declare const CAPTURE_PLAN_BITS: {
|
|
|
480
576
|
readonly ATTRIBUTION: number;
|
|
481
577
|
/** The operator enabled a motion switch, so location may be observed. */
|
|
482
578
|
readonly LOCATION: number;
|
|
579
|
+
/**
|
|
580
|
+
* The operator enabled device insights (`di.en` with a non-empty family
|
|
581
|
+
* allowlist); the kernel will emit `deviceSampleRequest` effects.
|
|
582
|
+
*/
|
|
583
|
+
readonly DEVICE_INSIGHTS: number;
|
|
483
584
|
};
|
|
484
585
|
declare function isCapturePlanEnabled(bits: number, bit: number): boolean;
|
|
485
586
|
interface WasmTransportRequest extends ForgeTransportRequest {
|
|
@@ -1008,6 +1109,18 @@ declare class NPAWForge {
|
|
|
1008
1109
|
setAutoConnectionType(connectionType: string | undefined): Promise<ForgeResult>;
|
|
1009
1110
|
/** Forwards a location fix to the kernel, which owns every threshold. */
|
|
1010
1111
|
recordLocationFix(fix: ForgeLocationFix): Promise<ForgeResult>;
|
|
1112
|
+
/**
|
|
1113
|
+
* Forwards a device runtime health sample to the kernel, for hosts that can
|
|
1114
|
+
* read more than a browser can (Electron, smart-TV device APIs). Set only the
|
|
1115
|
+
* fields you can read; an omitted field is an absent metric, never a
|
|
1116
|
+
* default. `sampledAtMs` defaults to now. The kernel owns the cadence, the
|
|
1117
|
+
* `dev_*` keys and the diff, and refuses the sample (`ignored_invalid_state`)
|
|
1118
|
+
* while an operator has device insights off. Pair with
|
|
1119
|
+
* `autoDeviceInsights: false` so the built-in browser reader does not
|
|
1120
|
+
* overwrite your values between pushes, or answer the kernel's own requests
|
|
1121
|
+
* with `deviceSampleCollector` instead.
|
|
1122
|
+
*/
|
|
1123
|
+
recordDeviceSample(sample: ForgeDeviceSample): Promise<ForgeResult>;
|
|
1011
1124
|
/**
|
|
1012
1125
|
* Starts or stops location observation to match the capture plan. Nothing is
|
|
1013
1126
|
* observed - not even the permission state - until an operator enables one
|
|
@@ -2438,4 +2551,4 @@ declare function registerDefaultWebAdapters(target: Record<string, unknown>): vo
|
|
|
2438
2551
|
declare const create: typeof NPAWForge.create;
|
|
2439
2552
|
declare const adapters: Record<string, unknown>;
|
|
2440
2553
|
|
|
2441
|
-
export { AVPlayAdapter, AdAdapter, type AdAdapterClass, type AdAdapterHost, type AdEventName, type AdMetadata, type AdViewabilitySample, AkamaiAdapter, BaseWebAdAdapter, BaseWebPlayerAdapter, BitmovinAdapter, BitmovinNativeAdsAdapter, BrightcoveAdapter, BrightcoveAdsAdapter, BrightcoveFreeWheelAdsAdapter, BrightcoveFreewheelAdsAdapter, BrightcoveGenericAdsAdapter, BrightcoveImaAdsAdapter, BrowserForgeTransport, CAPTURE_PLAN_BITS, ChromecastAdapter, ChromecastCAFAdapter, ChromecastCAFAdsAdapter, ChromecastCafAdapter, ChromecastCafAdsAdapter, type ContentMetadata, type ContentType, DashJSAdapter, DashjsAdapter, type DeviceOverrides, FlvjsAdapter, type ForgeAttributionParams, type ForgeCaptureEnvironment, type ForgeCaptureHandle, type ForgeCaptureInstallOptions, type ForgeCaptureInstaller, type ForgeCaptureOptions, type ForgeCapturePlanListener, type ForgeCapturePrivacyOptions, type ForgeCaptureTimers, type ForgeClock, ForgeCreateError, type ForgeCreateOptions, type ForgeDiagnostic, type ForgeDiagnosticListener, type ForgeEventListener, type ForgeEventSnapshot, type ForgeFocusCaptureMode, type ForgeFormEventData, type ForgeFormEventKind, type ForgeHttpResponse, type ForgeIdentityEventKind, type ForgeIntersectionObserverCallback, type ForgeIntersectionObserverEntryLike, type ForgeIntersectionObserverFactory, type ForgeIntersectionObserverLike, type ForgeLogListener, type ForgeLoginFailedOptions, type ForgeLoginSuccessOptions, type ForgeLogoutOptions, type ForgeMutationObserverFactory, type ForgeMutationObserverLike, type ForgeNetworkCaptureOptions, type ForgeOutcome, type ForgeOutcomeKind, type ForgeParamValue, type ForgeParams, type ForgeProfileOptions, type ForgeRenderedLog, type ForgeResolvedSectionsCaptureOptions, type ForgeResult, type ForgeRuntimeConfig, type ForgeSearchResultClickOptions, type ForgeSectionsCaptureOptions, type ForgeStorage, type ForgeTransport, type ForgeTransportRequest, FreeWheelAdsAdapter, FreewheelAdsAdapter, HTML5Adapter, HbbTVAdapter, HbbTvAdapter, HbbtvAdapter, HlsjsAdapter, Html5Adapter, ImaAdapter, JWPlayerAdapter, JWPlayerGenericAdsAdapter, JwplayerAdapter, JwplayerGenericAdsAdapter, MediaKindMKPlayerAdapter, MediaKindMkplayerAdapter, MediaKindWMCAdapter, MediaKindWMCNativeAdsAdapter, MediaKindWmcAdapter, MediaKindWmcNativeAdsAdapter, MediaTailorAdsAdapter, MediatailorAdsAdapter, MemoryForgeStorage, type MetadataSnapshot, NPAWForge, NagraAdapter, NanoPlayerAdapter, NanoplayerAdapter, type NetworkObservation, type NormalizedParams, NowtilusAdsAdapter, type OverrideBundle, type OverrideControlOptions, PlayerAdapter, type PlayerAdapterClass, type PlayerAdapterHost, type QosSnapshot, STACK_TRACE_MAX_CHARS, ShakaAdapter, TCPlayerAdapter, THEOplayerAdapter, THEOplayerNativeAdsAdapter, TcplayerAdapter, TheoplayerAdapter, TheoplayerNativeAdsAdapter, TritonAdapter, ViaccessOrcaAdapter, ViaccessorcaAdapter, VideoAdapter, VideoBuilder, type VideoBuilderOptions, type VideoEventName, VideoJsAdapter, VideoJsGenericAdsAdapter, VideoJsImaAdsAdapter, type VideoOptions, VisualONAdapter, VisualOnAdapter, VisualonAdapter, type WasmCapturePlan, type WasmCapturePlanAttribution, type WasmCapturePlanBehavior, type WasmCapturePlanFocus, type WasmCapturePlanLimits, type WasmCapturePlanSections, type WasmHttpResponse, type WasmTransportRequest, type WebAdapterCapability, YospaceAdsAdapter, adapterCapabilities, adapters, autoBootstrapFromCurrentScript, bootstrapFromScriptTag, captureElementAttribution, create, createBrowserStorage, getDefaultInstancePromise, getLastBootstrapError, installCapture, isCapturePlanEnabled, isNetworkCaptureSuppressed, normalizeRouteTemplate, parseScriptTagConfig, registerDefaultWebAdapters, requestUrl, resolveCaptureOptions, sanitizeCaptureParams, sanitizeCaptureString, sanitizeCaptureUrl, sanitizeStackTrace, serializeOverrideBundle, withoutNetworkCapture };
|
|
2554
|
+
export { AVPlayAdapter, AdAdapter, type AdAdapterClass, type AdAdapterHost, type AdEventName, type AdMetadata, type AdViewabilitySample, AkamaiAdapter, BaseWebAdAdapter, BaseWebPlayerAdapter, BitmovinAdapter, BitmovinNativeAdsAdapter, BrightcoveAdapter, BrightcoveAdsAdapter, BrightcoveFreeWheelAdsAdapter, BrightcoveFreewheelAdsAdapter, BrightcoveGenericAdsAdapter, BrightcoveImaAdsAdapter, BrowserForgeTransport, CAPTURE_PLAN_BITS, ChromecastAdapter, ChromecastCAFAdapter, ChromecastCAFAdsAdapter, ChromecastCafAdapter, ChromecastCafAdsAdapter, type ContentMetadata, type ContentType, DashJSAdapter, DashjsAdapter, type DeviceOverrides, FlvjsAdapter, type ForgeAttributionParams, type ForgeCaptureEnvironment, type ForgeCaptureHandle, type ForgeCaptureInstallOptions, type ForgeCaptureInstaller, type ForgeCaptureOptions, type ForgeCapturePlanListener, type ForgeCapturePrivacyOptions, type ForgeCaptureTimers, type ForgeClock, ForgeCreateError, type ForgeCreateOptions, type ForgeDeviceMetricFamily, type ForgeDeviceSample, type ForgeDeviceSampleCollector, type ForgeDiagnostic, type ForgeDiagnosticListener, type ForgeEventListener, type ForgeEventSnapshot, type ForgeFocusCaptureMode, type ForgeFormEventData, type ForgeFormEventKind, type ForgeHttpResponse, type ForgeIdentityEventKind, type ForgeIntersectionObserverCallback, type ForgeIntersectionObserverEntryLike, type ForgeIntersectionObserverFactory, type ForgeIntersectionObserverLike, type ForgeLogListener, type ForgeLoginFailedOptions, type ForgeLoginSuccessOptions, type ForgeLogoutOptions, type ForgeMutationObserverFactory, type ForgeMutationObserverLike, type ForgeNetworkCaptureOptions, type ForgeOutcome, type ForgeOutcomeKind, type ForgeParamValue, type ForgeParams, type ForgeProfileOptions, type ForgeRenderedLog, type ForgeResolvedSectionsCaptureOptions, type ForgeResult, type ForgeRuntimeConfig, type ForgeSearchResultClickOptions, type ForgeSectionsCaptureOptions, type ForgeStorage, type ForgeTransport, type ForgeTransportRequest, FreeWheelAdsAdapter, FreewheelAdsAdapter, HTML5Adapter, HbbTVAdapter, HbbTvAdapter, HbbtvAdapter, HlsjsAdapter, Html5Adapter, ImaAdapter, JWPlayerAdapter, JWPlayerGenericAdsAdapter, JwplayerAdapter, JwplayerGenericAdsAdapter, MediaKindMKPlayerAdapter, MediaKindMkplayerAdapter, MediaKindWMCAdapter, MediaKindWMCNativeAdsAdapter, MediaKindWmcAdapter, MediaKindWmcNativeAdsAdapter, MediaTailorAdsAdapter, MediatailorAdsAdapter, MemoryForgeStorage, type MetadataSnapshot, NPAWForge, NagraAdapter, NanoPlayerAdapter, NanoplayerAdapter, type NetworkObservation, type NormalizedParams, NowtilusAdsAdapter, type OverrideBundle, type OverrideControlOptions, PlayerAdapter, type PlayerAdapterClass, type PlayerAdapterHost, type QosSnapshot, STACK_TRACE_MAX_CHARS, ShakaAdapter, TCPlayerAdapter, THEOplayerAdapter, THEOplayerNativeAdsAdapter, TcplayerAdapter, TheoplayerAdapter, TheoplayerNativeAdsAdapter, TritonAdapter, ViaccessOrcaAdapter, ViaccessorcaAdapter, VideoAdapter, VideoBuilder, type VideoBuilderOptions, type VideoEventName, VideoJsAdapter, VideoJsGenericAdsAdapter, VideoJsImaAdsAdapter, type VideoOptions, VisualONAdapter, VisualOnAdapter, VisualonAdapter, type WasmCapturePlan, type WasmCapturePlanAttribution, type WasmCapturePlanBehavior, type WasmCapturePlanFocus, type WasmCapturePlanLimits, type WasmCapturePlanSections, type WasmHttpResponse, type WasmTransportRequest, type WebAdapterCapability, YospaceAdsAdapter, adapterCapabilities, adapters, autoBootstrapFromCurrentScript, bootstrapFromScriptTag, captureElementAttribution, create, createBrowserStorage, getDefaultInstancePromise, getLastBootstrapError, installCapture, isCapturePlanEnabled, isNetworkCaptureSuppressed, normalizeRouteTemplate, parseScriptTagConfig, registerDefaultWebAdapters, requestUrl, resolveCaptureOptions, sanitizeCaptureParams, sanitizeCaptureString, sanitizeCaptureUrl, sanitizeStackTrace, serializeOverrideBundle, withoutNetworkCapture };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) NPAW - All Rights Reserved
|
|
3
|
+
*
|
|
4
|
+
* This source code is protected under international copyright law. All rights
|
|
5
|
+
* reserved and protected by the copyright holders.
|
|
6
|
+
* This file is confidential and only available to authorized individuals with the
|
|
7
|
+
* permission of the copyright holders. If you encounter this file and do not have
|
|
8
|
+
* permission, please contact the copyright holders and delete this file.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
|
+
* @description: Web device-insights collector answering the kernel's device sample requests with the few runtime health facts a browser can honestly read (Chromium JS heap, Battery Status API), everything else omitted.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The metric families the kernel can ask for (`di.m` in remote config).
|
|
16
|
+
*
|
|
17
|
+
* The kernel sends the family tokens with every request; a host reads only
|
|
18
|
+
* what was asked for and omits everything it cannot read.
|
|
19
|
+
*/
|
|
20
|
+
type ForgeDeviceMetricFamily = "cpu" | "mem" | "bat" | "thm" | "disk";
|
|
21
|
+
/**
|
|
22
|
+
* A device runtime health sample, the kernel's `DeviceSample` contract in its
|
|
23
|
+
* JSON spelling. Every metric field is optional and independently absent: an
|
|
24
|
+
* omitted field is an absent metric and the kernel then omits the metric on
|
|
25
|
+
* the wire — never send `0`, `-1`, `null` or a placeholder for "unknown".
|
|
26
|
+
*/
|
|
27
|
+
interface ForgeDeviceSample {
|
|
28
|
+
/**
|
|
29
|
+
* Wall clock at read time, milliseconds since the Unix epoch. Filled with
|
|
30
|
+
* the runtime clock (`Date.now()` by default) when omitted.
|
|
31
|
+
*/
|
|
32
|
+
sampledAtMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Cumulative process CPU time, user + system, in milliseconds, monotonic
|
|
35
|
+
* non-decreasing over the process lifetime. Must be supplied together with
|
|
36
|
+
* `cpuCores` on every sample for `dev_cpu` to be derived.
|
|
37
|
+
*/
|
|
38
|
+
cpuTimeMs?: number;
|
|
39
|
+
/** Logical cores available to the process, at least 1. */
|
|
40
|
+
cpuCores?: number;
|
|
41
|
+
/** Process resident / footprint memory, bytes. */
|
|
42
|
+
memUsedBytes?: number;
|
|
43
|
+
/** Memory available to the app, bytes. */
|
|
44
|
+
memAvailBytes?: number;
|
|
45
|
+
/** Battery level, integer percent 0..100. */
|
|
46
|
+
batteryLevelPct?: number;
|
|
47
|
+
/** Whether the device is charging. */
|
|
48
|
+
batteryCharging?: boolean;
|
|
49
|
+
/** Thermal state on the kernel's normalised ordinal: 0 nominal … 4 emergency. */
|
|
50
|
+
thermal?: 0 | 1 | 2 | 3 | 4;
|
|
51
|
+
/** Free storage on the app's volume, bytes. */
|
|
52
|
+
diskFreeBytes?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Answers a kernel device sample request. Receives the requested family
|
|
56
|
+
* tokens and returns a sample (or nothing). The kernel owns the cadence: this
|
|
57
|
+
* is called only while an operator enabled device insights, at the configured
|
|
58
|
+
* interval, so a collector must never schedule its own reads.
|
|
59
|
+
*/
|
|
60
|
+
type ForgeDeviceSampleCollector = (families: readonly string[]) => ForgeDeviceSample | undefined | Promise<ForgeDeviceSample | undefined>;
|
|
61
|
+
|
|
1
62
|
/**
|
|
2
63
|
* Copyright (C) NPAW - All Rights Reserved
|
|
3
64
|
*
|
|
@@ -11,6 +72,7 @@
|
|
|
11
72
|
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
73
|
* @description: Public and internal TypeScript contracts for the Forge Web facade.
|
|
13
74
|
*/
|
|
75
|
+
|
|
14
76
|
type ForgeParamValue = string | number | boolean | null | undefined;
|
|
15
77
|
type ForgeParams = Record<string, ForgeParamValue>;
|
|
16
78
|
type NormalizedParams = Record<string, string>;
|
|
@@ -135,6 +197,32 @@ interface ForgeCreateOptions extends ForgeRuntimeConfig {
|
|
|
135
197
|
* @defaultValue true
|
|
136
198
|
*/
|
|
137
199
|
autoLocation?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Disables the built-in device insights reader.
|
|
202
|
+
*
|
|
203
|
+
* Device insights are **off by default** and enabled per account from the
|
|
204
|
+
* Forge Console (`di` remote-config group); the kernel then asks the host
|
|
205
|
+
* for a sample at the configured cadence. On the Web the built-in reader
|
|
206
|
+
* answers with what a browser can honestly provide - the Chromium JS heap
|
|
207
|
+
* size (`performance.memory`) and the Battery Status API
|
|
208
|
+
* (`navigator.getBattery()`) - and omits everything else (CPU, thermal,
|
|
209
|
+
* free disk, available memory) rather than defaulting it. Browsers without
|
|
210
|
+
* those APIs (Safari, Firefox) answer nothing at all. Set this to `false`
|
|
211
|
+
* when your host supplies its own samples through `recordDeviceSample`, or
|
|
212
|
+
* to make Forge read nothing regardless of the remote switch.
|
|
213
|
+
*
|
|
214
|
+
* @defaultValue true
|
|
215
|
+
*/
|
|
216
|
+
autoDeviceInsights?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Answers the kernel's device sample requests instead of the built-in
|
|
219
|
+
* browser reader, for hosts that can read more than a browser can (Electron
|
|
220
|
+
* `process.cpuUsage()` / `process.memoryUsage()`, smart-TV device APIs).
|
|
221
|
+
* Called only while an operator enabled device insights, at the configured
|
|
222
|
+
* cadence, with the requested family tokens; return the fields you can read
|
|
223
|
+
* and omit the rest. Takes precedence over `autoDeviceInsights`.
|
|
224
|
+
*/
|
|
225
|
+
deviceSampleCollector?: ForgeDeviceSampleCollector;
|
|
138
226
|
startSessionOnInitialize?: boolean;
|
|
139
227
|
initialSessionParams?: ForgeParams;
|
|
140
228
|
capture?: ForgeCaptureOptions;
|
|
@@ -404,6 +492,14 @@ interface WasmCapturePlan {
|
|
|
404
492
|
* Omitted when empty.
|
|
405
493
|
*/
|
|
406
494
|
targetDataAttributes?: string[];
|
|
495
|
+
/**
|
|
496
|
+
* Device-insights metric families the kernel will request (`di.m`, canonical
|
|
497
|
+
* order); present only while the `DEVICE_INSIGHTS` bit is set. Lets a host
|
|
498
|
+
* pre-arm an observer a family needs; the Web reader needs none, so it is
|
|
499
|
+
* informational here. The `deviceSampleRequest` effect, not the plan, is
|
|
500
|
+
* what triggers a read.
|
|
501
|
+
*/
|
|
502
|
+
deviceInsightFamilies?: string[];
|
|
407
503
|
hash: string;
|
|
408
504
|
}
|
|
409
505
|
interface WasmCapturePlanFocus {
|
|
@@ -480,6 +576,11 @@ declare const CAPTURE_PLAN_BITS: {
|
|
|
480
576
|
readonly ATTRIBUTION: number;
|
|
481
577
|
/** The operator enabled a motion switch, so location may be observed. */
|
|
482
578
|
readonly LOCATION: number;
|
|
579
|
+
/**
|
|
580
|
+
* The operator enabled device insights (`di.en` with a non-empty family
|
|
581
|
+
* allowlist); the kernel will emit `deviceSampleRequest` effects.
|
|
582
|
+
*/
|
|
583
|
+
readonly DEVICE_INSIGHTS: number;
|
|
483
584
|
};
|
|
484
585
|
declare function isCapturePlanEnabled(bits: number, bit: number): boolean;
|
|
485
586
|
interface WasmTransportRequest extends ForgeTransportRequest {
|
|
@@ -1008,6 +1109,18 @@ declare class NPAWForge {
|
|
|
1008
1109
|
setAutoConnectionType(connectionType: string | undefined): Promise<ForgeResult>;
|
|
1009
1110
|
/** Forwards a location fix to the kernel, which owns every threshold. */
|
|
1010
1111
|
recordLocationFix(fix: ForgeLocationFix): Promise<ForgeResult>;
|
|
1112
|
+
/**
|
|
1113
|
+
* Forwards a device runtime health sample to the kernel, for hosts that can
|
|
1114
|
+
* read more than a browser can (Electron, smart-TV device APIs). Set only the
|
|
1115
|
+
* fields you can read; an omitted field is an absent metric, never a
|
|
1116
|
+
* default. `sampledAtMs` defaults to now. The kernel owns the cadence, the
|
|
1117
|
+
* `dev_*` keys and the diff, and refuses the sample (`ignored_invalid_state`)
|
|
1118
|
+
* while an operator has device insights off. Pair with
|
|
1119
|
+
* `autoDeviceInsights: false` so the built-in browser reader does not
|
|
1120
|
+
* overwrite your values between pushes, or answer the kernel's own requests
|
|
1121
|
+
* with `deviceSampleCollector` instead.
|
|
1122
|
+
*/
|
|
1123
|
+
recordDeviceSample(sample: ForgeDeviceSample): Promise<ForgeResult>;
|
|
1011
1124
|
/**
|
|
1012
1125
|
* Starts or stops location observation to match the capture plan. Nothing is
|
|
1013
1126
|
* observed - not even the permission state - until an operator enables one
|
|
@@ -2438,4 +2551,4 @@ declare function registerDefaultWebAdapters(target: Record<string, unknown>): vo
|
|
|
2438
2551
|
declare const create: typeof NPAWForge.create;
|
|
2439
2552
|
declare const adapters: Record<string, unknown>;
|
|
2440
2553
|
|
|
2441
|
-
export { AVPlayAdapter, AdAdapter, type AdAdapterClass, type AdAdapterHost, type AdEventName, type AdMetadata, type AdViewabilitySample, AkamaiAdapter, BaseWebAdAdapter, BaseWebPlayerAdapter, BitmovinAdapter, BitmovinNativeAdsAdapter, BrightcoveAdapter, BrightcoveAdsAdapter, BrightcoveFreeWheelAdsAdapter, BrightcoveFreewheelAdsAdapter, BrightcoveGenericAdsAdapter, BrightcoveImaAdsAdapter, BrowserForgeTransport, CAPTURE_PLAN_BITS, ChromecastAdapter, ChromecastCAFAdapter, ChromecastCAFAdsAdapter, ChromecastCafAdapter, ChromecastCafAdsAdapter, type ContentMetadata, type ContentType, DashJSAdapter, DashjsAdapter, type DeviceOverrides, FlvjsAdapter, type ForgeAttributionParams, type ForgeCaptureEnvironment, type ForgeCaptureHandle, type ForgeCaptureInstallOptions, type ForgeCaptureInstaller, type ForgeCaptureOptions, type ForgeCapturePlanListener, type ForgeCapturePrivacyOptions, type ForgeCaptureTimers, type ForgeClock, ForgeCreateError, type ForgeCreateOptions, type ForgeDiagnostic, type ForgeDiagnosticListener, type ForgeEventListener, type ForgeEventSnapshot, type ForgeFocusCaptureMode, type ForgeFormEventData, type ForgeFormEventKind, type ForgeHttpResponse, type ForgeIdentityEventKind, type ForgeIntersectionObserverCallback, type ForgeIntersectionObserverEntryLike, type ForgeIntersectionObserverFactory, type ForgeIntersectionObserverLike, type ForgeLogListener, type ForgeLoginFailedOptions, type ForgeLoginSuccessOptions, type ForgeLogoutOptions, type ForgeMutationObserverFactory, type ForgeMutationObserverLike, type ForgeNetworkCaptureOptions, type ForgeOutcome, type ForgeOutcomeKind, type ForgeParamValue, type ForgeParams, type ForgeProfileOptions, type ForgeRenderedLog, type ForgeResolvedSectionsCaptureOptions, type ForgeResult, type ForgeRuntimeConfig, type ForgeSearchResultClickOptions, type ForgeSectionsCaptureOptions, type ForgeStorage, type ForgeTransport, type ForgeTransportRequest, FreeWheelAdsAdapter, FreewheelAdsAdapter, HTML5Adapter, HbbTVAdapter, HbbTvAdapter, HbbtvAdapter, HlsjsAdapter, Html5Adapter, ImaAdapter, JWPlayerAdapter, JWPlayerGenericAdsAdapter, JwplayerAdapter, JwplayerGenericAdsAdapter, MediaKindMKPlayerAdapter, MediaKindMkplayerAdapter, MediaKindWMCAdapter, MediaKindWMCNativeAdsAdapter, MediaKindWmcAdapter, MediaKindWmcNativeAdsAdapter, MediaTailorAdsAdapter, MediatailorAdsAdapter, MemoryForgeStorage, type MetadataSnapshot, NPAWForge, NagraAdapter, NanoPlayerAdapter, NanoplayerAdapter, type NetworkObservation, type NormalizedParams, NowtilusAdsAdapter, type OverrideBundle, type OverrideControlOptions, PlayerAdapter, type PlayerAdapterClass, type PlayerAdapterHost, type QosSnapshot, STACK_TRACE_MAX_CHARS, ShakaAdapter, TCPlayerAdapter, THEOplayerAdapter, THEOplayerNativeAdsAdapter, TcplayerAdapter, TheoplayerAdapter, TheoplayerNativeAdsAdapter, TritonAdapter, ViaccessOrcaAdapter, ViaccessorcaAdapter, VideoAdapter, VideoBuilder, type VideoBuilderOptions, type VideoEventName, VideoJsAdapter, VideoJsGenericAdsAdapter, VideoJsImaAdsAdapter, type VideoOptions, VisualONAdapter, VisualOnAdapter, VisualonAdapter, type WasmCapturePlan, type WasmCapturePlanAttribution, type WasmCapturePlanBehavior, type WasmCapturePlanFocus, type WasmCapturePlanLimits, type WasmCapturePlanSections, type WasmHttpResponse, type WasmTransportRequest, type WebAdapterCapability, YospaceAdsAdapter, adapterCapabilities, adapters, autoBootstrapFromCurrentScript, bootstrapFromScriptTag, captureElementAttribution, create, createBrowserStorage, getDefaultInstancePromise, getLastBootstrapError, installCapture, isCapturePlanEnabled, isNetworkCaptureSuppressed, normalizeRouteTemplate, parseScriptTagConfig, registerDefaultWebAdapters, requestUrl, resolveCaptureOptions, sanitizeCaptureParams, sanitizeCaptureString, sanitizeCaptureUrl, sanitizeStackTrace, serializeOverrideBundle, withoutNetworkCapture };
|
|
2554
|
+
export { AVPlayAdapter, AdAdapter, type AdAdapterClass, type AdAdapterHost, type AdEventName, type AdMetadata, type AdViewabilitySample, AkamaiAdapter, BaseWebAdAdapter, BaseWebPlayerAdapter, BitmovinAdapter, BitmovinNativeAdsAdapter, BrightcoveAdapter, BrightcoveAdsAdapter, BrightcoveFreeWheelAdsAdapter, BrightcoveFreewheelAdsAdapter, BrightcoveGenericAdsAdapter, BrightcoveImaAdsAdapter, BrowserForgeTransport, CAPTURE_PLAN_BITS, ChromecastAdapter, ChromecastCAFAdapter, ChromecastCAFAdsAdapter, ChromecastCafAdapter, ChromecastCafAdsAdapter, type ContentMetadata, type ContentType, DashJSAdapter, DashjsAdapter, type DeviceOverrides, FlvjsAdapter, type ForgeAttributionParams, type ForgeCaptureEnvironment, type ForgeCaptureHandle, type ForgeCaptureInstallOptions, type ForgeCaptureInstaller, type ForgeCaptureOptions, type ForgeCapturePlanListener, type ForgeCapturePrivacyOptions, type ForgeCaptureTimers, type ForgeClock, ForgeCreateError, type ForgeCreateOptions, type ForgeDeviceMetricFamily, type ForgeDeviceSample, type ForgeDeviceSampleCollector, type ForgeDiagnostic, type ForgeDiagnosticListener, type ForgeEventListener, type ForgeEventSnapshot, type ForgeFocusCaptureMode, type ForgeFormEventData, type ForgeFormEventKind, type ForgeHttpResponse, type ForgeIdentityEventKind, type ForgeIntersectionObserverCallback, type ForgeIntersectionObserverEntryLike, type ForgeIntersectionObserverFactory, type ForgeIntersectionObserverLike, type ForgeLogListener, type ForgeLoginFailedOptions, type ForgeLoginSuccessOptions, type ForgeLogoutOptions, type ForgeMutationObserverFactory, type ForgeMutationObserverLike, type ForgeNetworkCaptureOptions, type ForgeOutcome, type ForgeOutcomeKind, type ForgeParamValue, type ForgeParams, type ForgeProfileOptions, type ForgeRenderedLog, type ForgeResolvedSectionsCaptureOptions, type ForgeResult, type ForgeRuntimeConfig, type ForgeSearchResultClickOptions, type ForgeSectionsCaptureOptions, type ForgeStorage, type ForgeTransport, type ForgeTransportRequest, FreeWheelAdsAdapter, FreewheelAdsAdapter, HTML5Adapter, HbbTVAdapter, HbbTvAdapter, HbbtvAdapter, HlsjsAdapter, Html5Adapter, ImaAdapter, JWPlayerAdapter, JWPlayerGenericAdsAdapter, JwplayerAdapter, JwplayerGenericAdsAdapter, MediaKindMKPlayerAdapter, MediaKindMkplayerAdapter, MediaKindWMCAdapter, MediaKindWMCNativeAdsAdapter, MediaKindWmcAdapter, MediaKindWmcNativeAdsAdapter, MediaTailorAdsAdapter, MediatailorAdsAdapter, MemoryForgeStorage, type MetadataSnapshot, NPAWForge, NagraAdapter, NanoPlayerAdapter, NanoplayerAdapter, type NetworkObservation, type NormalizedParams, NowtilusAdsAdapter, type OverrideBundle, type OverrideControlOptions, PlayerAdapter, type PlayerAdapterClass, type PlayerAdapterHost, type QosSnapshot, STACK_TRACE_MAX_CHARS, ShakaAdapter, TCPlayerAdapter, THEOplayerAdapter, THEOplayerNativeAdsAdapter, TcplayerAdapter, TheoplayerAdapter, TheoplayerNativeAdsAdapter, TritonAdapter, ViaccessOrcaAdapter, ViaccessorcaAdapter, VideoAdapter, VideoBuilder, type VideoBuilderOptions, type VideoEventName, VideoJsAdapter, VideoJsGenericAdsAdapter, VideoJsImaAdsAdapter, type VideoOptions, VisualONAdapter, VisualOnAdapter, VisualonAdapter, type WasmCapturePlan, type WasmCapturePlanAttribution, type WasmCapturePlanBehavior, type WasmCapturePlanFocus, type WasmCapturePlanLimits, type WasmCapturePlanSections, type WasmHttpResponse, type WasmTransportRequest, type WebAdapterCapability, YospaceAdsAdapter, adapterCapabilities, adapters, autoBootstrapFromCurrentScript, bootstrapFromScriptTag, captureElementAttribution, create, createBrowserStorage, getDefaultInstancePromise, getLastBootstrapError, installCapture, isCapturePlanEnabled, isNetworkCaptureSuppressed, normalizeRouteTemplate, parseScriptTagConfig, registerDefaultWebAdapters, requestUrl, resolveCaptureOptions, sanitizeCaptureParams, sanitizeCaptureString, sanitizeCaptureUrl, sanitizeStackTrace, serializeOverrideBundle, withoutNetworkCapture };
|
package/dist/index.global.js
CHANGED
|
@@ -141,7 +141,12 @@ var NPAWForge = (() => {
|
|
|
141
141
|
SECTIONS: 1 << 13,
|
|
142
142
|
ATTRIBUTION: 1 << 14,
|
|
143
143
|
/** The operator enabled a motion switch, so location may be observed. */
|
|
144
|
-
LOCATION: 1 << 15
|
|
144
|
+
LOCATION: 1 << 15,
|
|
145
|
+
/**
|
|
146
|
+
* The operator enabled device insights (`di.en` with a non-empty family
|
|
147
|
+
* allowlist); the kernel will emit `deviceSampleRequest` effects.
|
|
148
|
+
*/
|
|
149
|
+
DEVICE_INSIGHTS: 1 << 16
|
|
145
150
|
};
|
|
146
151
|
function isCapturePlanEnabled(bits, bit) {
|
|
147
152
|
return (bits & bit) !== 0;
|
|
@@ -3533,6 +3538,104 @@ var NPAWForge = (() => {
|
|
|
3533
3538
|
return `${random()}-${random().slice(0, 4)}-4${random().slice(0, 3)}-a${random().slice(0, 3)}-${random()}${random().slice(0, 4)}`;
|
|
3534
3539
|
}
|
|
3535
3540
|
|
|
3541
|
+
// src/device-insights.ts
|
|
3542
|
+
var METRIC_FIELDS = [
|
|
3543
|
+
"cpuTimeMs",
|
|
3544
|
+
"cpuCores",
|
|
3545
|
+
"memUsedBytes",
|
|
3546
|
+
"memAvailBytes",
|
|
3547
|
+
"batteryLevelPct",
|
|
3548
|
+
"batteryCharging",
|
|
3549
|
+
"thermal",
|
|
3550
|
+
"diskFreeBytes"
|
|
3551
|
+
];
|
|
3552
|
+
async function collectBrowserDeviceSample(families, environment = readBrowserDeviceInsightsEnvironment()) {
|
|
3553
|
+
const sample = {};
|
|
3554
|
+
if (families.includes("mem")) {
|
|
3555
|
+
const usedBytes = readUsedJsHeapBytes(environment);
|
|
3556
|
+
if (usedBytes !== void 0) {
|
|
3557
|
+
sample.memUsedBytes = usedBytes;
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
if (families.includes("bat")) {
|
|
3561
|
+
const battery = await readBattery(environment);
|
|
3562
|
+
if (battery.levelPct !== void 0) {
|
|
3563
|
+
sample.batteryLevelPct = battery.levelPct;
|
|
3564
|
+
}
|
|
3565
|
+
if (battery.charging !== void 0) {
|
|
3566
|
+
sample.batteryCharging = battery.charging;
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
return hasDeviceMetric(sample) ? sample : void 0;
|
|
3570
|
+
}
|
|
3571
|
+
function hasDeviceMetric(sample) {
|
|
3572
|
+
return METRIC_FIELDS.some((field) => sample[field] !== void 0);
|
|
3573
|
+
}
|
|
3574
|
+
function compactDeviceSample(sample) {
|
|
3575
|
+
const compact = {};
|
|
3576
|
+
if (sample.sampledAtMs !== void 0) {
|
|
3577
|
+
compact.sampledAtMs = sample.sampledAtMs;
|
|
3578
|
+
}
|
|
3579
|
+
for (const field of METRIC_FIELDS) {
|
|
3580
|
+
const value = sample[field];
|
|
3581
|
+
if (value !== void 0) {
|
|
3582
|
+
compact[field] = value;
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
return compact;
|
|
3586
|
+
}
|
|
3587
|
+
function readUsedJsHeapBytes(environment) {
|
|
3588
|
+
var _a;
|
|
3589
|
+
if (!environment.memory) {
|
|
3590
|
+
return void 0;
|
|
3591
|
+
}
|
|
3592
|
+
let used;
|
|
3593
|
+
try {
|
|
3594
|
+
used = (_a = environment.memory()) == null ? void 0 : _a.usedJSHeapSize;
|
|
3595
|
+
} catch (e2) {
|
|
3596
|
+
return void 0;
|
|
3597
|
+
}
|
|
3598
|
+
if (typeof used !== "number" || !Number.isFinite(used) || used <= 0) {
|
|
3599
|
+
return void 0;
|
|
3600
|
+
}
|
|
3601
|
+
return Math.floor(used);
|
|
3602
|
+
}
|
|
3603
|
+
async function readBattery(environment) {
|
|
3604
|
+
if (!environment.getBattery) {
|
|
3605
|
+
return {};
|
|
3606
|
+
}
|
|
3607
|
+
let manager;
|
|
3608
|
+
try {
|
|
3609
|
+
manager = await environment.getBattery();
|
|
3610
|
+
} catch (e2) {
|
|
3611
|
+
return {};
|
|
3612
|
+
}
|
|
3613
|
+
if (!manager) {
|
|
3614
|
+
return {};
|
|
3615
|
+
}
|
|
3616
|
+
const result = {};
|
|
3617
|
+
const level = manager.level;
|
|
3618
|
+
if (typeof level === "number" && Number.isFinite(level) && level >= 0 && level <= 1) {
|
|
3619
|
+
result.levelPct = Math.round(level * 100);
|
|
3620
|
+
}
|
|
3621
|
+
if (typeof manager.charging === "boolean") {
|
|
3622
|
+
result.charging = manager.charging;
|
|
3623
|
+
}
|
|
3624
|
+
return result;
|
|
3625
|
+
}
|
|
3626
|
+
function readBrowserDeviceInsightsEnvironment() {
|
|
3627
|
+
const environment = {};
|
|
3628
|
+
const performanceRef = globalThis.performance;
|
|
3629
|
+
if (performanceRef && typeof performanceRef.memory === "object" && performanceRef.memory !== null) {
|
|
3630
|
+
environment.memory = () => performanceRef.memory;
|
|
3631
|
+
}
|
|
3632
|
+
const navigatorRef = globalThis.navigator;
|
|
3633
|
+
if (navigatorRef && typeof navigatorRef.getBattery === "function") {
|
|
3634
|
+
environment.getBattery = () => navigatorRef.getBattery();
|
|
3635
|
+
}
|
|
3636
|
+
return environment;
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3536
3639
|
// src/utils.ts
|
|
3537
3640
|
function systemClock() {
|
|
3538
3641
|
return {
|
|
@@ -3627,6 +3730,7 @@ var NPAWForge = (() => {
|
|
|
3627
3730
|
this.transport = options.transport;
|
|
3628
3731
|
this.storage = options.storage;
|
|
3629
3732
|
this.submitCompletion = options.submitCompletion;
|
|
3733
|
+
this.deviceSampleCollector = options.deviceSampleCollector;
|
|
3630
3734
|
if (options.onEvent) {
|
|
3631
3735
|
this.eventListeners.add(options.onEvent);
|
|
3632
3736
|
}
|
|
@@ -3689,6 +3793,11 @@ var NPAWForge = (() => {
|
|
|
3689
3793
|
case "diagnostic":
|
|
3690
3794
|
this.emitDiagnostic(effect);
|
|
3691
3795
|
break;
|
|
3796
|
+
case "deviceSampleRequest":
|
|
3797
|
+
this.track(this.executeDeviceSampleRequest(effect.families));
|
|
3798
|
+
break;
|
|
3799
|
+
default:
|
|
3800
|
+
break;
|
|
3692
3801
|
}
|
|
3693
3802
|
}
|
|
3694
3803
|
}
|
|
@@ -3765,6 +3874,31 @@ var NPAWForge = (() => {
|
|
|
3765
3874
|
});
|
|
3766
3875
|
}
|
|
3767
3876
|
}
|
|
3877
|
+
/**
|
|
3878
|
+
* Answers a kernel device sample request through the collector. Nothing is
|
|
3879
|
+
* sent when the collector has nothing to report (a browser without the
|
|
3880
|
+
* APIs, or a host that read nothing): the kernel would accept an all-absent
|
|
3881
|
+
* sample and store nothing from it, so sending it would only cost the WASM
|
|
3882
|
+
* round trip. A collector that throws is a host bug worth surfacing, so it
|
|
3883
|
+
* becomes a diagnostic rather than a silent skip.
|
|
3884
|
+
*/
|
|
3885
|
+
async executeDeviceSampleRequest(families) {
|
|
3886
|
+
const collector = this.deviceSampleCollector;
|
|
3887
|
+
if (!collector) {
|
|
3888
|
+
return;
|
|
3889
|
+
}
|
|
3890
|
+
let sample;
|
|
3891
|
+
try {
|
|
3892
|
+
sample = await collector(families);
|
|
3893
|
+
} catch (error) {
|
|
3894
|
+
this.emitDiagnostic(diagnosticFromError(error, "device_sample_collector_failed"));
|
|
3895
|
+
return;
|
|
3896
|
+
}
|
|
3897
|
+
if (!sample || !hasDeviceMetric(sample)) {
|
|
3898
|
+
return;
|
|
3899
|
+
}
|
|
3900
|
+
this.submitCompletion({ type: "recordDeviceSample", sample: compactDeviceSample(sample) });
|
|
3901
|
+
}
|
|
3768
3902
|
scheduleTimer(timer) {
|
|
3769
3903
|
this.cancelTimer(timer.id);
|
|
3770
3904
|
const startedAtMs = this.clock.nowMs();
|
|
@@ -4075,7 +4209,8 @@ var NPAWForge = (() => {
|
|
|
4075
4209
|
},
|
|
4076
4210
|
onEvent: options.onEvent,
|
|
4077
4211
|
onDiagnostic: options.onDiagnostic,
|
|
4078
|
-
onLog: options.onLog
|
|
4212
|
+
onLog: options.onLog,
|
|
4213
|
+
deviceSampleCollector: options.deviceSampleCollector
|
|
4079
4214
|
});
|
|
4080
4215
|
}
|
|
4081
4216
|
static async create(options) {
|
|
@@ -4103,7 +4238,8 @@ var NPAWForge = (() => {
|
|
|
4103
4238
|
transport: (_c = options.transport) != null ? _c : new BrowserForgeTransport(),
|
|
4104
4239
|
onEvent: options.onEvent,
|
|
4105
4240
|
onDiagnostic: options.onDiagnostic,
|
|
4106
|
-
onLog: options.onLog
|
|
4241
|
+
onLog: options.onLog,
|
|
4242
|
+
deviceSampleCollector: deviceSampleCollector(options)
|
|
4107
4243
|
});
|
|
4108
4244
|
await bridge.process({ type: "start" });
|
|
4109
4245
|
return { bridge, module };
|
|
@@ -4212,6 +4348,8 @@ var NPAWForge = (() => {
|
|
|
4212
4348
|
timemarkMs: this.nowMs()
|
|
4213
4349
|
}
|
|
4214
4350
|
} : command;
|
|
4351
|
+
case "recordDeviceSample":
|
|
4352
|
+
return command.sample.sampledAtMs === void 0 ? { ...command, sample: { ...command.sample, sampledAtMs: this.nowMs() } } : command;
|
|
4215
4353
|
default:
|
|
4216
4354
|
return command;
|
|
4217
4355
|
}
|
|
@@ -4299,6 +4437,13 @@ var NPAWForge = (() => {
|
|
|
4299
4437
|
function isEffectCompletion(command) {
|
|
4300
4438
|
return command.type === "httpCompleted" || command.type === "httpFailed" || command.type === "storageReadCompleted" || command.type === "storageWriteCompleted" || command.type === "storageDeleteCompleted";
|
|
4301
4439
|
}
|
|
4440
|
+
function deviceSampleCollector(options) {
|
|
4441
|
+
var _a;
|
|
4442
|
+
if (options.deviceSampleCollector) {
|
|
4443
|
+
return options.deviceSampleCollector;
|
|
4444
|
+
}
|
|
4445
|
+
return ((_a = options.autoDeviceInsights) != null ? _a : true) ? (families) => collectBrowserDeviceSample(families) : void 0;
|
|
4446
|
+
}
|
|
4302
4447
|
function runtimeConfig(options) {
|
|
4303
4448
|
var _a, _b;
|
|
4304
4449
|
const config = {
|
|
@@ -5338,6 +5483,20 @@ var NPAWForge = (() => {
|
|
|
5338
5483
|
timestampMs: fix.timestampMs
|
|
5339
5484
|
});
|
|
5340
5485
|
}
|
|
5486
|
+
/**
|
|
5487
|
+
* Forwards a device runtime health sample to the kernel, for hosts that can
|
|
5488
|
+
* read more than a browser can (Electron, smart-TV device APIs). Set only the
|
|
5489
|
+
* fields you can read; an omitted field is an absent metric, never a
|
|
5490
|
+
* default. `sampledAtMs` defaults to now. The kernel owns the cadence, the
|
|
5491
|
+
* `dev_*` keys and the diff, and refuses the sample (`ignored_invalid_state`)
|
|
5492
|
+
* while an operator has device insights off. Pair with
|
|
5493
|
+
* `autoDeviceInsights: false` so the built-in browser reader does not
|
|
5494
|
+
* overwrite your values between pushes, or answer the kernel's own requests
|
|
5495
|
+
* with `deviceSampleCollector` instead.
|
|
5496
|
+
*/
|
|
5497
|
+
recordDeviceSample(sample) {
|
|
5498
|
+
return this.runtime.process({ type: "recordDeviceSample", sample: compactDeviceSample(sample) });
|
|
5499
|
+
}
|
|
5341
5500
|
/**
|
|
5342
5501
|
* Starts or stops location observation to match the capture plan. Nothing is
|
|
5343
5502
|
* observed - not even the permission state - until an operator enables one
|