@opensteer/browser-core 0.7.0 → 0.7.2

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
@@ -1132,4 +1132,48 @@ interface VisualStabilityOptions {
1132
1132
  }
1133
1133
  declare function waitForCdpVisualStability(cdp: CdpSessionLike, options?: VisualStabilityOptions): Promise<void>;
1134
1134
 
1135
- export { type BodyPayload, type BodyPayloadEncoding, type Brand, type BrowserCapabilities, type BrowserCapabilityPath, type BrowserCoreEngine, BrowserCoreError, type BrowserCoreErrorCode, type BrowserCoreErrorOptions, type BrowserExecutor, type BrowserInitScriptInput, type BrowserInitScriptRegistration, type BrowserInspector, type BrowserInstrumentation, type BrowserRouteFetchResult, type BrowserRouteHandlerResult, type BrowserRouteRegistration, type BrowserRouteRegistrationInput, type BrowserRouteRequest, type CapturedCdpDomSnapshot, type CdpDomSnapshotDocument, type CdpDomTreeNode, type CdpRareIntegerData, type CdpRareStringData, type CdpShadowBoundaryInfo, type ChooserOpenedStepEvent, type ChooserRef, type ConsoleLevel, type ConsoleStepEvent, type CookiePriority, type CookieRecord, type CookieSameSite, type CoordinateSpace, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, type DevicePixelRatio, type DialogOpenedStepEvent, type DialogRef, type DocumentEpoch, type DocumentRef, type DomSnapshot, type DomSnapshotNode, type DownloadFinishedStepEvent, type DownloadRef, type DownloadStartedStepEvent, type EventStreamMessageStepEvent, FakeBrowserCoreEngine, type FakeBrowserCoreEngineOptions, type FakeBrowserCorePageSeed, type FrameInfo, type FrameRef, type FrozenStepEvent, type GetNetworkRecordsInput, type HeaderEntry, type HitTestResult, type HtmlSnapshot, type IndexedDbDatabaseSnapshot, type IndexedDbIndexSnapshot, type IndexedDbObjectStoreSnapshot, type IndexedDbRecord, type KeyModifier, type LayoutViewport, type MouseButton, type NetworkCaptureState, type NetworkInitiator, type NetworkInitiatorType, type NetworkRecord, type NetworkRecordFilterInput, type NetworkRecordKind, type NetworkRequestId, type NetworkResourceType, type NetworkSourceMetadata, type NetworkTiming, type NetworkTransferSizes, type NodeLocator, type NodeRef, type PageClosedStepEvent, type PageCreatedStepEvent, type PageErrorStepEvent, type PageInfo, type PageLifecycleState, type PageRef, type PageScaleFactor, type PageZoomFactor, type PartialBrowserCapabilities, type PausedStepEvent, type Point, type PopupOpenedStepEvent, type Quad, type Rect, type ResumedStepEvent, type ScreenshotArtifact, type ScreenshotFormat, type ScrollOffset, type SessionRef, type SessionStorageSnapshot, type SessionTransportExecutor, type SessionTransportRequest, type SessionTransportResponse, type ShadowDomSnapshotMode, type Size, type StepEvent, type StepResult, type StorageEntry, type StorageOriginSnapshot, type StorageSnapshot, type ViewportMetrics, type VisualStabilityScope, type VisualViewport, type WebSocketClosedStepEvent, type WebSocketFrameStepEvent, type WebSocketOpenedStepEvent, type WorkerCreatedStepEvent, type WorkerDestroyedStepEvent, type WorkerRef, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, parseCdpStringTable, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForCdpVisualStability };
1135
+ declare const DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS = 400;
1136
+ declare const DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS = 100;
1137
+ interface PostLoadTrackerState {
1138
+ readonly installedAt: number;
1139
+ readonly lastMutationAt: number;
1140
+ readonly lastNetworkActivityAt: number;
1141
+ readonly now: number;
1142
+ readonly pendingFetches: number;
1143
+ readonly pendingTimeouts: number;
1144
+ readonly pendingXhrs: number;
1145
+ readonly readyState: string;
1146
+ }
1147
+ declare function normalizePostLoadTrackerState(value: unknown): PostLoadTrackerState | undefined;
1148
+ declare function buildPostLoadTrackerInstallScript(): string;
1149
+ declare function buildPostLoadTrackerReadExpression(): string;
1150
+ declare function postLoadTrackerIsSettled(tracker: PostLoadTrackerState | undefined, quietWindowMs?: number): boolean;
1151
+
1152
+ declare const CROSS_DOCUMENT_INTERACTION_TIMEOUT_MS = 30000;
1153
+ declare const CROSS_DOCUMENT_DETECTION_WINDOW_MS = 500;
1154
+ interface ActionBoundarySnapshot {
1155
+ readonly pageRef: PageRef;
1156
+ readonly documentRef: DocumentRef;
1157
+ }
1158
+ type ActionBoundarySettleTrigger = "dom-action" | "navigation";
1159
+ type ActionBoundaryTimedOutPhase = "bootstrap";
1160
+ interface ActionBoundaryOutcome {
1161
+ readonly trigger: ActionBoundarySettleTrigger;
1162
+ readonly crossDocument: boolean;
1163
+ readonly bootstrapSettled: boolean;
1164
+ readonly timedOutPhase?: ActionBoundaryTimedOutPhase;
1165
+ }
1166
+ interface WaitForActionBoundaryInput {
1167
+ readonly timeoutMs: number;
1168
+ readonly signal?: AbortSignal;
1169
+ readonly snapshot?: ActionBoundarySnapshot;
1170
+ readonly pollIntervalMs?: number;
1171
+ getCurrentMainFrameDocumentRef(): DocumentRef | undefined;
1172
+ waitForNavigationContentLoaded(timeoutMs: number): Promise<void>;
1173
+ readTrackerState(): Promise<PostLoadTrackerState | undefined>;
1174
+ throwBackgroundError(): void;
1175
+ isPageClosed(): boolean;
1176
+ }
1177
+ declare function waitForActionBoundary(input: WaitForActionBoundaryInput): Promise<ActionBoundaryOutcome>;
1178
+
1179
+ export { type ActionBoundaryOutcome, type ActionBoundarySettleTrigger, type ActionBoundarySnapshot, type ActionBoundaryTimedOutPhase, type BodyPayload, type BodyPayloadEncoding, type Brand, type BrowserCapabilities, type BrowserCapabilityPath, type BrowserCoreEngine, BrowserCoreError, type BrowserCoreErrorCode, type BrowserCoreErrorOptions, type BrowserExecutor, type BrowserInitScriptInput, type BrowserInitScriptRegistration, type BrowserInspector, type BrowserInstrumentation, type BrowserRouteFetchResult, type BrowserRouteHandlerResult, type BrowserRouteRegistration, type BrowserRouteRegistrationInput, type BrowserRouteRequest, CROSS_DOCUMENT_DETECTION_WINDOW_MS, CROSS_DOCUMENT_INTERACTION_TIMEOUT_MS, type CapturedCdpDomSnapshot, type CdpDomSnapshotDocument, type CdpDomTreeNode, type CdpRareIntegerData, type CdpRareStringData, type CdpShadowBoundaryInfo, type ChooserOpenedStepEvent, type ChooserRef, type ConsoleLevel, type ConsoleStepEvent, type CookiePriority, type CookieRecord, type CookieSameSite, type CoordinateSpace, DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS, DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, type DevicePixelRatio, type DialogOpenedStepEvent, type DialogRef, type DocumentEpoch, type DocumentRef, type DomSnapshot, type DomSnapshotNode, type DownloadFinishedStepEvent, type DownloadRef, type DownloadStartedStepEvent, type EventStreamMessageStepEvent, FakeBrowserCoreEngine, type FakeBrowserCoreEngineOptions, type FakeBrowserCorePageSeed, type FrameInfo, type FrameRef, type FrozenStepEvent, type GetNetworkRecordsInput, type HeaderEntry, type HitTestResult, type HtmlSnapshot, type IndexedDbDatabaseSnapshot, type IndexedDbIndexSnapshot, type IndexedDbObjectStoreSnapshot, type IndexedDbRecord, type KeyModifier, type LayoutViewport, type MouseButton, type NetworkCaptureState, type NetworkInitiator, type NetworkInitiatorType, type NetworkRecord, type NetworkRecordFilterInput, type NetworkRecordKind, type NetworkRequestId, type NetworkResourceType, type NetworkSourceMetadata, type NetworkTiming, type NetworkTransferSizes, type NodeLocator, type NodeRef, type PageClosedStepEvent, type PageCreatedStepEvent, type PageErrorStepEvent, type PageInfo, type PageLifecycleState, type PageRef, type PageScaleFactor, type PageZoomFactor, type PartialBrowserCapabilities, type PausedStepEvent, type Point, type PopupOpenedStepEvent, type PostLoadTrackerState, type Quad, type Rect, type ResumedStepEvent, type ScreenshotArtifact, type ScreenshotFormat, type ScrollOffset, type SessionRef, type SessionStorageSnapshot, type SessionTransportExecutor, type SessionTransportRequest, type SessionTransportResponse, type ShadowDomSnapshotMode, type Size, type StepEvent, type StepResult, type StorageEntry, type StorageOriginSnapshot, type StorageSnapshot, type ViewportMetrics, type VisualStabilityScope, type VisualViewport, type WaitForActionBoundaryInput, type WebSocketClosedStepEvent, type WebSocketFrameStepEvent, type WebSocketOpenedStepEvent, type WorkerCreatedStepEvent, type WorkerDestroyedStepEvent, type WorkerRef, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, buildPostLoadTrackerInstallScript, buildPostLoadTrackerReadExpression, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, normalizePostLoadTrackerState, parseCdpStringTable, postLoadTrackerIsSettled, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForActionBoundary, waitForCdpVisualStability };
package/dist/index.d.ts CHANGED
@@ -1132,4 +1132,48 @@ interface VisualStabilityOptions {
1132
1132
  }
1133
1133
  declare function waitForCdpVisualStability(cdp: CdpSessionLike, options?: VisualStabilityOptions): Promise<void>;
1134
1134
 
1135
- export { type BodyPayload, type BodyPayloadEncoding, type Brand, type BrowserCapabilities, type BrowserCapabilityPath, type BrowserCoreEngine, BrowserCoreError, type BrowserCoreErrorCode, type BrowserCoreErrorOptions, type BrowserExecutor, type BrowserInitScriptInput, type BrowserInitScriptRegistration, type BrowserInspector, type BrowserInstrumentation, type BrowserRouteFetchResult, type BrowserRouteHandlerResult, type BrowserRouteRegistration, type BrowserRouteRegistrationInput, type BrowserRouteRequest, type CapturedCdpDomSnapshot, type CdpDomSnapshotDocument, type CdpDomTreeNode, type CdpRareIntegerData, type CdpRareStringData, type CdpShadowBoundaryInfo, type ChooserOpenedStepEvent, type ChooserRef, type ConsoleLevel, type ConsoleStepEvent, type CookiePriority, type CookieRecord, type CookieSameSite, type CoordinateSpace, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, type DevicePixelRatio, type DialogOpenedStepEvent, type DialogRef, type DocumentEpoch, type DocumentRef, type DomSnapshot, type DomSnapshotNode, type DownloadFinishedStepEvent, type DownloadRef, type DownloadStartedStepEvent, type EventStreamMessageStepEvent, FakeBrowserCoreEngine, type FakeBrowserCoreEngineOptions, type FakeBrowserCorePageSeed, type FrameInfo, type FrameRef, type FrozenStepEvent, type GetNetworkRecordsInput, type HeaderEntry, type HitTestResult, type HtmlSnapshot, type IndexedDbDatabaseSnapshot, type IndexedDbIndexSnapshot, type IndexedDbObjectStoreSnapshot, type IndexedDbRecord, type KeyModifier, type LayoutViewport, type MouseButton, type NetworkCaptureState, type NetworkInitiator, type NetworkInitiatorType, type NetworkRecord, type NetworkRecordFilterInput, type NetworkRecordKind, type NetworkRequestId, type NetworkResourceType, type NetworkSourceMetadata, type NetworkTiming, type NetworkTransferSizes, type NodeLocator, type NodeRef, type PageClosedStepEvent, type PageCreatedStepEvent, type PageErrorStepEvent, type PageInfo, type PageLifecycleState, type PageRef, type PageScaleFactor, type PageZoomFactor, type PartialBrowserCapabilities, type PausedStepEvent, type Point, type PopupOpenedStepEvent, type Quad, type Rect, type ResumedStepEvent, type ScreenshotArtifact, type ScreenshotFormat, type ScrollOffset, type SessionRef, type SessionStorageSnapshot, type SessionTransportExecutor, type SessionTransportRequest, type SessionTransportResponse, type ShadowDomSnapshotMode, type Size, type StepEvent, type StepResult, type StorageEntry, type StorageOriginSnapshot, type StorageSnapshot, type ViewportMetrics, type VisualStabilityScope, type VisualViewport, type WebSocketClosedStepEvent, type WebSocketFrameStepEvent, type WebSocketOpenedStepEvent, type WorkerCreatedStepEvent, type WorkerDestroyedStepEvent, type WorkerRef, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, parseCdpStringTable, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForCdpVisualStability };
1135
+ declare const DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS = 400;
1136
+ declare const DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS = 100;
1137
+ interface PostLoadTrackerState {
1138
+ readonly installedAt: number;
1139
+ readonly lastMutationAt: number;
1140
+ readonly lastNetworkActivityAt: number;
1141
+ readonly now: number;
1142
+ readonly pendingFetches: number;
1143
+ readonly pendingTimeouts: number;
1144
+ readonly pendingXhrs: number;
1145
+ readonly readyState: string;
1146
+ }
1147
+ declare function normalizePostLoadTrackerState(value: unknown): PostLoadTrackerState | undefined;
1148
+ declare function buildPostLoadTrackerInstallScript(): string;
1149
+ declare function buildPostLoadTrackerReadExpression(): string;
1150
+ declare function postLoadTrackerIsSettled(tracker: PostLoadTrackerState | undefined, quietWindowMs?: number): boolean;
1151
+
1152
+ declare const CROSS_DOCUMENT_INTERACTION_TIMEOUT_MS = 30000;
1153
+ declare const CROSS_DOCUMENT_DETECTION_WINDOW_MS = 500;
1154
+ interface ActionBoundarySnapshot {
1155
+ readonly pageRef: PageRef;
1156
+ readonly documentRef: DocumentRef;
1157
+ }
1158
+ type ActionBoundarySettleTrigger = "dom-action" | "navigation";
1159
+ type ActionBoundaryTimedOutPhase = "bootstrap";
1160
+ interface ActionBoundaryOutcome {
1161
+ readonly trigger: ActionBoundarySettleTrigger;
1162
+ readonly crossDocument: boolean;
1163
+ readonly bootstrapSettled: boolean;
1164
+ readonly timedOutPhase?: ActionBoundaryTimedOutPhase;
1165
+ }
1166
+ interface WaitForActionBoundaryInput {
1167
+ readonly timeoutMs: number;
1168
+ readonly signal?: AbortSignal;
1169
+ readonly snapshot?: ActionBoundarySnapshot;
1170
+ readonly pollIntervalMs?: number;
1171
+ getCurrentMainFrameDocumentRef(): DocumentRef | undefined;
1172
+ waitForNavigationContentLoaded(timeoutMs: number): Promise<void>;
1173
+ readTrackerState(): Promise<PostLoadTrackerState | undefined>;
1174
+ throwBackgroundError(): void;
1175
+ isPageClosed(): boolean;
1176
+ }
1177
+ declare function waitForActionBoundary(input: WaitForActionBoundaryInput): Promise<ActionBoundaryOutcome>;
1178
+
1179
+ export { type ActionBoundaryOutcome, type ActionBoundarySettleTrigger, type ActionBoundarySnapshot, type ActionBoundaryTimedOutPhase, type BodyPayload, type BodyPayloadEncoding, type Brand, type BrowserCapabilities, type BrowserCapabilityPath, type BrowserCoreEngine, BrowserCoreError, type BrowserCoreErrorCode, type BrowserCoreErrorOptions, type BrowserExecutor, type BrowserInitScriptInput, type BrowserInitScriptRegistration, type BrowserInspector, type BrowserInstrumentation, type BrowserRouteFetchResult, type BrowserRouteHandlerResult, type BrowserRouteRegistration, type BrowserRouteRegistrationInput, type BrowserRouteRequest, CROSS_DOCUMENT_DETECTION_WINDOW_MS, CROSS_DOCUMENT_INTERACTION_TIMEOUT_MS, type CapturedCdpDomSnapshot, type CdpDomSnapshotDocument, type CdpDomTreeNode, type CdpRareIntegerData, type CdpRareStringData, type CdpShadowBoundaryInfo, type ChooserOpenedStepEvent, type ChooserRef, type ConsoleLevel, type ConsoleStepEvent, type CookiePriority, type CookieRecord, type CookieSameSite, type CoordinateSpace, DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS, DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, type DevicePixelRatio, type DialogOpenedStepEvent, type DialogRef, type DocumentEpoch, type DocumentRef, type DomSnapshot, type DomSnapshotNode, type DownloadFinishedStepEvent, type DownloadRef, type DownloadStartedStepEvent, type EventStreamMessageStepEvent, FakeBrowserCoreEngine, type FakeBrowserCoreEngineOptions, type FakeBrowserCorePageSeed, type FrameInfo, type FrameRef, type FrozenStepEvent, type GetNetworkRecordsInput, type HeaderEntry, type HitTestResult, type HtmlSnapshot, type IndexedDbDatabaseSnapshot, type IndexedDbIndexSnapshot, type IndexedDbObjectStoreSnapshot, type IndexedDbRecord, type KeyModifier, type LayoutViewport, type MouseButton, type NetworkCaptureState, type NetworkInitiator, type NetworkInitiatorType, type NetworkRecord, type NetworkRecordFilterInput, type NetworkRecordKind, type NetworkRequestId, type NetworkResourceType, type NetworkSourceMetadata, type NetworkTiming, type NetworkTransferSizes, type NodeLocator, type NodeRef, type PageClosedStepEvent, type PageCreatedStepEvent, type PageErrorStepEvent, type PageInfo, type PageLifecycleState, type PageRef, type PageScaleFactor, type PageZoomFactor, type PartialBrowserCapabilities, type PausedStepEvent, type Point, type PopupOpenedStepEvent, type PostLoadTrackerState, type Quad, type Rect, type ResumedStepEvent, type ScreenshotArtifact, type ScreenshotFormat, type ScrollOffset, type SessionRef, type SessionStorageSnapshot, type SessionTransportExecutor, type SessionTransportRequest, type SessionTransportResponse, type ShadowDomSnapshotMode, type Size, type StepEvent, type StepResult, type StorageEntry, type StorageOriginSnapshot, type StorageSnapshot, type ViewportMetrics, type VisualStabilityScope, type VisualViewport, type WaitForActionBoundaryInput, type WebSocketClosedStepEvent, type WebSocketFrameStepEvent, type WebSocketOpenedStepEvent, type WorkerCreatedStepEvent, type WorkerDestroyedStepEvent, type WorkerRef, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, buildPostLoadTrackerInstallScript, buildPostLoadTrackerReadExpression, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, normalizePostLoadTrackerState, parseCdpStringTable, postLoadTrackerIsSettled, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForActionBoundary, waitForCdpVisualStability };
package/dist/index.js CHANGED
@@ -2841,6 +2841,282 @@ function sleep(ms) {
2841
2841
  return new Promise((resolve) => setTimeout(resolve, ms));
2842
2842
  }
2843
2843
 
2844
- export { BrowserCoreError, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, FakeBrowserCoreEngine, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, parseCdpStringTable, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForCdpVisualStability };
2844
+ // src/post-load-tracker.ts
2845
+ var DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS = 400;
2846
+ var DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS = 100;
2847
+ function isRecord(value) {
2848
+ return typeof value === "object" && value !== null;
2849
+ }
2850
+ function readFiniteNumber(value) {
2851
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
2852
+ }
2853
+ function readNonNegativeNumber(value) {
2854
+ const parsed = readFiniteNumber(value);
2855
+ return parsed === void 0 || parsed < 0 ? 0 : parsed;
2856
+ }
2857
+ function normalizePostLoadTrackerState(value) {
2858
+ if (!isRecord(value)) {
2859
+ return void 0;
2860
+ }
2861
+ const installedAt = readFiniteNumber(value.installedAt);
2862
+ const lastMutationAt = readFiniteNumber(value.lastMutationAt);
2863
+ const lastNetworkActivityAt = readFiniteNumber(value.lastNetworkActivityAt);
2864
+ const now = readFiniteNumber(value.now);
2865
+ const readyState = typeof value.readyState === "string" ? value.readyState : void 0;
2866
+ if (installedAt === void 0 || lastMutationAt === void 0 || lastNetworkActivityAt === void 0 || now === void 0 || readyState === void 0) {
2867
+ return void 0;
2868
+ }
2869
+ return {
2870
+ installedAt,
2871
+ lastMutationAt,
2872
+ lastNetworkActivityAt,
2873
+ now,
2874
+ pendingFetches: readNonNegativeNumber(value.pendingFetches),
2875
+ pendingTimeouts: readNonNegativeNumber(value.pendingTimeouts),
2876
+ pendingXhrs: readNonNegativeNumber(value.pendingXhrs),
2877
+ readyState
2878
+ };
2879
+ }
2880
+ function buildPostLoadTrackerInstallScript() {
2881
+ return `(() => {
2882
+ const globalObject = globalThis;
2883
+ if (globalObject.__opensteerActionBoundaryTrackerInstalled) {
2884
+ return true;
2885
+ }
2886
+
2887
+ const tracker = {
2888
+ installedAt: performance.now(),
2889
+ lastMutationAt: performance.now(),
2890
+ lastNetworkActivityAt: performance.now(),
2891
+ pendingFetches: 0,
2892
+ pendingTimeouts: 0,
2893
+ pendingXhrs: 0,
2894
+ readyState: document.readyState,
2895
+ timeoutIds: new Set(),
2896
+ };
2897
+ globalObject.__opensteerActionBoundaryTrackerInstalled = true;
2898
+ globalObject.__opensteerActionBoundaryTracker = tracker;
2899
+
2900
+ const markMutation = () => {
2901
+ tracker.lastMutationAt = performance.now();
2902
+ tracker.readyState = document.readyState;
2903
+ };
2904
+ const markNetwork = () => {
2905
+ tracker.lastNetworkActivityAt = performance.now();
2906
+ tracker.readyState = document.readyState;
2907
+ };
2908
+
2909
+ const startObserver = () => {
2910
+ const target = document.documentElement ?? document;
2911
+ if (!(target instanceof Node)) {
2912
+ return;
2913
+ }
2914
+ const observer = new MutationObserver(markMutation);
2915
+ observer.observe(target, {
2916
+ subtree: true,
2917
+ childList: true,
2918
+ characterData: true,
2919
+ attributes: true,
2920
+ });
2921
+ markMutation();
2922
+ };
2923
+
2924
+ if (document.documentElement) {
2925
+ startObserver();
2926
+ } else {
2927
+ document.addEventListener("DOMContentLoaded", startObserver, { once: true });
2928
+ }
2929
+
2930
+ document.addEventListener("readystatechange", markMutation);
2931
+ addEventListener("load", markMutation, { once: true });
2932
+
2933
+ const nativeSetTimeout = globalObject.setTimeout.bind(globalObject);
2934
+ const nativeClearTimeout = globalObject.clearTimeout.bind(globalObject);
2935
+ globalObject.setTimeout = function(callback, delay, ...args) {
2936
+ tracker.pendingTimeouts += 1;
2937
+ markNetwork();
2938
+ let handle;
2939
+ const wrapped =
2940
+ typeof callback === "function"
2941
+ ? (...callbackArgs) => {
2942
+ if (tracker.timeoutIds.delete(handle)) {
2943
+ tracker.pendingTimeouts = Math.max(0, tracker.pendingTimeouts - 1);
2944
+ }
2945
+ try {
2946
+ return callback(...callbackArgs);
2947
+ } finally {
2948
+ markMutation();
2949
+ }
2950
+ }
2951
+ : callback;
2952
+ handle = nativeSetTimeout(wrapped, delay, ...args);
2953
+ tracker.timeoutIds.add(handle);
2954
+ return handle;
2955
+ };
2956
+ globalObject.clearTimeout = function(handle) {
2957
+ if (tracker.timeoutIds.delete(handle)) {
2958
+ tracker.pendingTimeouts = Math.max(0, tracker.pendingTimeouts - 1);
2959
+ }
2960
+ return nativeClearTimeout(handle);
2961
+ };
2962
+
2963
+ if (typeof globalObject.fetch === "function") {
2964
+ const nativeFetch = globalObject.fetch.bind(globalObject);
2965
+ globalObject.fetch = (...args) => {
2966
+ tracker.pendingFetches += 1;
2967
+ markNetwork();
2968
+ return nativeFetch(...args)
2969
+ .finally(() => {
2970
+ tracker.pendingFetches = Math.max(0, tracker.pendingFetches - 1);
2971
+ markNetwork();
2972
+ });
2973
+ };
2974
+ }
2975
+
2976
+ if (typeof globalObject.XMLHttpRequest === "function") {
2977
+ const NativeXMLHttpRequest = globalObject.XMLHttpRequest;
2978
+ const nativeSend = NativeXMLHttpRequest.prototype.send;
2979
+ NativeXMLHttpRequest.prototype.send = function(...args) {
2980
+ tracker.pendingXhrs += 1;
2981
+ markNetwork();
2982
+ const finalize = () => {
2983
+ this.removeEventListener("loadend", finalize);
2984
+ tracker.pendingXhrs = Math.max(0, tracker.pendingXhrs - 1);
2985
+ markNetwork();
2986
+ };
2987
+ this.addEventListener("loadend", finalize, { once: true });
2988
+ return nativeSend.apply(this, args);
2989
+ };
2990
+ }
2991
+
2992
+ return true;
2993
+ })()`;
2994
+ }
2995
+ function buildPostLoadTrackerReadExpression() {
2996
+ return `(() => {
2997
+ const tracker = globalThis.__opensteerActionBoundaryTracker;
2998
+ if (!tracker) {
2999
+ return null;
3000
+ }
3001
+
3002
+ return {
3003
+ installedAt: Number(tracker.installedAt ?? 0),
3004
+ lastMutationAt: Number(tracker.lastMutationAt ?? 0),
3005
+ lastNetworkActivityAt: Number(tracker.lastNetworkActivityAt ?? 0),
3006
+ now: Number(performance.now()),
3007
+ pendingFetches: Number(tracker.pendingFetches ?? 0),
3008
+ pendingTimeouts: Number(tracker.pendingTimeouts ?? 0),
3009
+ pendingXhrs: Number(tracker.pendingXhrs ?? 0),
3010
+ readyState: String(document.readyState),
3011
+ };
3012
+ })()`;
3013
+ }
3014
+ function postLoadTrackerIsSettled(tracker, quietWindowMs = DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS) {
3015
+ if (!tracker) {
3016
+ return false;
3017
+ }
3018
+ if (tracker.readyState !== "complete") {
3019
+ return false;
3020
+ }
3021
+ if (tracker.pendingFetches > 0 || tracker.pendingTimeouts > 0 || tracker.pendingXhrs > 0) {
3022
+ return false;
3023
+ }
3024
+ const lastActivityAt = Math.max(
3025
+ tracker.installedAt,
3026
+ tracker.lastMutationAt,
3027
+ tracker.lastNetworkActivityAt
3028
+ );
3029
+ return tracker.now - lastActivityAt >= quietWindowMs;
3030
+ }
3031
+
3032
+ // src/action-boundary.ts
3033
+ var CROSS_DOCUMENT_INTERACTION_TIMEOUT_MS = 3e4;
3034
+ var CROSS_DOCUMENT_DETECTION_WINDOW_MS = 500;
3035
+ async function waitForActionBoundary(input) {
3036
+ if (input.timeoutMs <= 0) {
3037
+ return {
3038
+ trigger: "dom-action",
3039
+ crossDocument: false,
3040
+ bootstrapSettled: false,
3041
+ timedOutPhase: "bootstrap"
3042
+ };
3043
+ }
3044
+ const deadline = Date.now() + input.timeoutMs;
3045
+ const crossDocumentDetectionDeadline = input.snapshot === void 0 ? void 0 : Math.min(deadline, Date.now() + CROSS_DOCUMENT_DETECTION_WINDOW_MS);
3046
+ const pollIntervalMs = input.pollIntervalMs ?? DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS;
3047
+ let trigger = "dom-action";
3048
+ let crossDocument = false;
3049
+ let waitedForNavigationContentLoaded = false;
3050
+ while (Date.now() < deadline) {
3051
+ input.throwBackgroundError();
3052
+ if (input.isPageClosed()) {
3053
+ return {
3054
+ trigger,
3055
+ crossDocument,
3056
+ bootstrapSettled: true
3057
+ };
3058
+ }
3059
+ if (input.signal?.aborted) {
3060
+ if (isTimeoutAbort(input.signal.reason) && Date.now() >= deadline) {
3061
+ return {
3062
+ trigger,
3063
+ crossDocument,
3064
+ bootstrapSettled: false,
3065
+ timedOutPhase: "bootstrap"
3066
+ };
3067
+ }
3068
+ throw abortError(input.signal);
3069
+ }
3070
+ const currentDocumentRef = input.getCurrentMainFrameDocumentRef();
3071
+ if (input.snapshot !== void 0 && currentDocumentRef !== void 0 && currentDocumentRef !== input.snapshot.documentRef) {
3072
+ trigger = "navigation";
3073
+ crossDocument = true;
3074
+ if (!waitedForNavigationContentLoaded) {
3075
+ waitedForNavigationContentLoaded = true;
3076
+ const remaining = Math.max(0, deadline - Date.now());
3077
+ if (remaining > 0) {
3078
+ await input.waitForNavigationContentLoaded(remaining);
3079
+ }
3080
+ }
3081
+ }
3082
+ if (!crossDocument && crossDocumentDetectionDeadline !== void 0 && Date.now() >= crossDocumentDetectionDeadline) {
3083
+ return {
3084
+ trigger,
3085
+ crossDocument,
3086
+ bootstrapSettled: true
3087
+ };
3088
+ }
3089
+ if (crossDocument && postLoadTrackerIsSettled(await input.readTrackerState())) {
3090
+ return {
3091
+ trigger,
3092
+ crossDocument,
3093
+ bootstrapSettled: true
3094
+ };
3095
+ }
3096
+ await delay(Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
3097
+ }
3098
+ return {
3099
+ trigger,
3100
+ crossDocument,
3101
+ bootstrapSettled: false,
3102
+ timedOutPhase: "bootstrap"
3103
+ };
3104
+ }
3105
+ function abortError(signal) {
3106
+ return signal.reason ?? new DOMException("The operation was aborted", "AbortError");
3107
+ }
3108
+ async function delay(ms) {
3109
+ if (ms <= 0) {
3110
+ return;
3111
+ }
3112
+ await new Promise((resolve) => {
3113
+ setTimeout(resolve, ms);
3114
+ });
3115
+ }
3116
+ function isTimeoutAbort(reason) {
3117
+ return typeof reason === "object" && reason !== null && "code" in reason && reason.code === "timeout";
3118
+ }
3119
+
3120
+ export { BrowserCoreError, CROSS_DOCUMENT_DETECTION_WINDOW_MS, CROSS_DOCUMENT_INTERACTION_TIMEOUT_MS, DEFAULT_ACTION_BOUNDARY_POLL_INTERVAL_MS, DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, FakeBrowserCoreEngine, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, buildPostLoadTrackerInstallScript, buildPostLoadTrackerReadExpression, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, normalizePostLoadTrackerState, parseCdpStringTable, postLoadTrackerIsSettled, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForActionBoundary, waitForCdpVisualStability };
2845
3121
  //# sourceMappingURL=index.js.map
2846
3122
  //# sourceMappingURL=index.js.map