{{ message }}
feat(storageState): add OPFS support#41420
Draft
gwennlbh wants to merge 2 commits into
Draft
Conversation
6f6684c to
18b71cc
Compare
gwennlbh
commented
Jun 23, 2026
gwennlbh
commented
Jun 23, 2026
gwennlbh
commented
Jun 23, 2026
gwennlbh
commented
Jun 23, 2026
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| }; | ||
|
|
||
| type OPFSTree = Array< | ||
| [name: string, contents: Extract<SerializedValue, {f: any}> | OPFSTree] |
Member
There was a problem hiding this comment.
Let's use conservative types:
type FSEntry {
type: 'file' | 'folder';
name: string;
lastModified: number;
}
type File = FSEntry & {
type: 'file';
base64: string;
}
type Folder = FSEntry & {
type: 'folder';
entries: (File | Folder)[];
}| { ta: { b: string, k: TypedArrayKind } } | | ||
| { ab: { b: string } }; | ||
| { ab: { b: string } } | | ||
| { f: { b: string, n: string, t: string, m: number } }; |
Member
There was a problem hiding this comment.
You should be able to serialize and restore opfs without this.
| return base64ToTypedArray(value.ta.b, typedArrayConstructors[value.ta.k]); | ||
| if ('ab' in value) | ||
| return base64ToTypedArray(value.ab.b, Uint8Array).buffer; | ||
| if ('f' in value) { |
Contributor
Author
There was a problem hiding this comment.
I did it like this so that we would get File object support in IndexedDB as a side effect of the PR, but yeah it's not strictly necessary
|
|
||
| async storageState(params: channels.BrowserContextStorageStateParams, progress: Progress): Promise<channels.BrowserContextStorageStateResult> { | ||
| return await this._context.storageState(progress, params.indexedDB, params.credentials); | ||
| return await this._context.storageState(progress, params.indexedDB, params.credentials, params.opfs); |
bac24d8 to
e9d3564
Compare
e9d3564 to
2040049
Compare
Contributor
Author
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.

Closes #41400