FileSystemObserver implementation#1265
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Implements a working FileSystemObserver for the fs-fsa package, wiring @jsonjoy.com/fs-core’s watcher events into Web File System Access–style change records and extending the observer API to support stopping observations.
Changes:
- Add
unobserve()to theIFileSystemObserverinterface and implementobserve() / unobserve() / disconnect()inCoreFileSystemObserver. - Introduce a concrete
FileSystemChangeRecordimplementation and batch change delivery via microtasks. - Expand observer test coverage substantially (observation lifecycle, batching, terminal events, recursive behavior, sync access handles).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/fs-fsa/src/types.ts | Extends the observer interface with unobserve(). |
| packages/fs-fsa/src/CoreFileSystemSyncAccessHandle.ts | Exposes __path consistently for sync access handles (used by observer implementation). |
| packages/fs-fsa/src/CoreFileSystemObserver.ts | Implements observing/unobserving/disconnect, event translation, and record batching. |
| packages/fs-fsa/src/tests/CoreFileSystemObserver.test.ts | Adds comprehensive tests for the new observer behavior and change record semantics. |
Comment on lines
+50
to
+56
| const path = (handle as unknown as { __path?: unknown }).__path; | ||
| if (typeof path !== 'string') | ||
| throw new TypeError("Failed to execute 'observe' on 'FileSystemObserver': Invalid handle."); | ||
| const isDirectory = (handle as IFileSystemHandle).kind === 'directory'; | ||
| const last = path[path.length - 1]; | ||
| const target = path.length > 1 && (last === '/' || last === '\\') ? path.slice(0, -1) : path; | ||
| const ctx = ((handle as any).ctx ?? (handle as any)._ctx) as CoreFsaContext; |
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.
No description provided.