feat: 🎸 add event emission to fs-core#1262
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a filesystem-change event mechanism in fs-core (via Superblock.onchange) and routes several mutation operations through Superblock so that key write/metadata operations can consistently emit CREATE/DELETE/MODIFY/MOVE events across higher-level adapters.
Changes:
- Add
FsEvent/FsEventTypeand export them from@jsonjoy.com/fs-core. - Implement
Superblock.onchangeand emit events for create/delete/modify/move across multiple core operations (including newftruncate/fchmod/chmod/lchmod/fchown/chown/lchown/futimes/utimeshelpers). - Update
fs-nodeVolume andfs-fsaadapters to call the newSuperblockmutation helpers so event emission occurs centrally.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/fs-node/src/volume.ts | Routes several FD/path mutation ops through Superblock so they can emit events consistently. |
| packages/fs-fsa/src/CoreFileSystemWritableFileStream.ts | Switches truncate to operate via FD + Superblock.ftruncate to enable core-level event emission. |
| packages/fs-fsa/src/CoreFileSystemSyncAccessHandle.ts | Switches truncate to Superblock.ftruncate using the ensured-open FD. |
| packages/fs-core/src/watch/FsEvent.ts | Adds the event payload/type used by the new watcher hook. |
| packages/fs-core/src/Superblock.ts | Introduces onchange + emits FsEvents across core operations; adds helper APIs for metadata/time updates. |
| packages/fs-core/src/index.ts | Re-exports the new watcher event types from the package entrypoint. |
| .gitignore | Ignores .docs/ directory. |
Comment on lines
+10
to
+17
| export class FsEvent { | ||
| constructor( | ||
| public readonly type: FsEventType, | ||
| public readonly steps: string[], | ||
| public readonly node: Node, | ||
| public readonly oldSteps: string[] | undefined = void 0, | ||
| ) {} | ||
| } |
Comment on lines
+105
to
+109
| public onchange?: (event: FsEvent) => void; | ||
|
|
||
| protected emit(change: FsEvent) { | ||
| if (this.onchange) this.onchange(change); | ||
| } |
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.