Add opt-in complete console export snapshots#149
Open
zzanzifeng wants to merge 1 commit into
Open
Conversation
zzanzifeng
force-pushed
the
feat/complete-console-export
branch
from
June 3, 2026 02:15
d3a55f6 to
181b05a
Compare
Add an original-by-default consoleExportMode option so apps can export common console values as getter-safe log-time snapshots without changing existing lazy atom behavior. Complete mode now falls back to original atom previews when a console argument contains values that cannot be fully snapshotted, such as DOM nodes or opaque host objects.
Constraint: object expansion is lazy across PageSpy platforms, and complete export must not invoke getters or require debugger-side hydration.
Rejected: making complete snapshots the default | it changes payload size and legacy console behavior for existing users.
Rejected: representing unsupported host objects as `{ "__type": "..." }` JSON | it hides the useful original atom preview for DOM and other opaque runtime values.
Confidence: high
Scope-risk: moderate
Directive: keep original mode as the default, use ConsoleExportMode instead of repeated string literals, and preserve getter-safe serialization semantics across browser, MP, React Native, and Harmony paths.
Related: HuolalaTech/page-spy-web#407
Tested: yarn workspace @huolala-tech/page-spy-base build; yarn workspace @huolala-tech/page-spy-browser build; yarn workspace @huolala-tech/page-spy-mp-base build; yarn workspace @huolala-tech/page-spy-react-native build; yarn jest packages/page-spy-base/tests/atom.test.ts packages/page-spy-browser/tests/plugins/console.test.ts --runInBand; targeted eslint for modified SDK files; git diff --check; real headless Chrome check for DOM fallback and array object JSON snapshot
Not-tested: full SDK lint/typecheck because existing unrelated Harmony/path issues are outside this change
zzanzifeng
force-pushed
the
feat/complete-console-export
branch
from
June 3, 2026 03:09
181b05a to
adca81e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
consoleExportMode?: 'original' | 'complete'withoriginalas the defaultConsoleExportModeenum/helper internally instead of repeating mode string literalscompleteis enabled and the value can be fully snapshottedoriginalmodeSerialization scope
completemode is intended to make exported logs useful for common serializable/reference values. It does not try to be a full Chrome DevTools remote-object mirror or astructuredClonereplacement.Covered common cases include:
Map/SetDate/RegExpArrayBuffer, typed arrays, andDataViewURL/URLSearchParamswhere availableError, functions, symbols, bigint,undefined[Circular][Getter]/[Setter]without invoking gettersFallback behavior:
document.bodyreadable asHTMLBodyElementinstead of{"__type":"HTMLBodyElement"}Known limitations:
WeakMap/WeakSetcontents are not enumerablePromisevalues are not synchronously expandedBlob,File,FormData,Headers, class private fields/internal slots, Proxies, and platform-specific host objects are not guaranteed to export complete internalsCompanion Web PR
This SDK PR is intended to work with the Web UI export PR:
The Web PR makes the debugger export click-time snapshots as JSON/Markdown. This SDK PR supplies log-time snapshots for common console values so Markdown/JSON exports do not stay limited to lazy atom previews when
completeis enabled. Unsupported complete-mode values intentionally remain atom previews so the Web export can mark them as preview-only instead of emitting misleading JSON markers.Validation
yarn workspace @huolala-tech/page-spy-base buildyarn workspace @huolala-tech/page-spy-browser buildyarn workspace @huolala-tech/page-spy-mp-base buildyarn workspace @huolala-tech/page-spy-react-native buildyarn jest packages/page-spy-base/tests/atom.test.ts packages/page-spy-browser/tests/plugins/console.test.ts --runInBandgit diff --checkconsoleExportMode: 'complete'emits an atom preview fordocument.bodyand still emits a JSON snapshot for an array of objectsconsoleExportMode: 'complete', caches complete object/array snapshots, and falls back DOM values toHTMLBodyElementatom previewsNotes
originalremains the default to avoid changing payload size and legacy lazy expansion behavior. Apps that need complete export should opt in with: