Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add comprehensive FileSystem observer API types with full MDN spec compliance#1171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge3 commits intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-1170

Conversation

Copy link
Contributor

CopilotAI commentedAug 22, 2025
edited
Loading

Added complete TypeScript type definitions for the File System Access API observer interfaces tosrc/fsa/types.ts, implementing the full MDN specification.

New Types Added

FileSystemChangeRecord

Represents a file system change event with comprehensive properties:

  • changedHandle: IFileSystemHandle | IFileSystemSyncAccessHandle | null - The changed file system handle (null for "disappeared", "errored", or "unknown" types)
  • relativePathComponents: string[] - Path components from the observed directory to the changed handle
  • relativePathMovedFrom: string[] | null - Former location path for "moved" type events
  • root: IFileSystemHandle | IFileSystemSyncAccessHandle - Reference to the root handle passed to observe()
  • type: 'appeared' | 'disappeared' | 'modified' | 'moved' | 'errored' | 'unknown' - Complete set of change types

IFileSystemObserver

Observer interface with constructor signature and methods:

  • Constructor with callback function(records, observer) => void
  • observe(handle, options?) - Start observing changes to a directory handle
  • unobserve(handle) - Stop observing changes to a specific directory handle
  • disconnect() - Disconnect and stop all observations

FileSystemObserverObserveOptions

Options interface for theobserve method:

  • recursive?: boolean - Whether to observe changes recursively in subdirectories

Implementation Details

  • Full compliance withMDN File System Access API specification
  • Support for both user-observable file system and Origin Private File System (OPFS) withIFileSystemSyncAccessHandle
  • Proper nullable types for handles based on event types
  • Complete JSDoc documentation with MDN references
  • Constructor typing enables proper instantiation:new FileSystemObserver(callback)

These types enable future implementation of file system watching functionality for thewatchFile,unwatchFile, andwatch methods inFsaNodeFs.

Fixes#1170.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
CopilotAI changed the title[WIP] Add File System (FS) API observer API typesfeat: add FileSystem observer API typesAug 22, 2025
CopilotAI requested a review fromstreamichAugust 22, 2025 16:44
Copilot finished work on behalf ofstreamichAugust 22, 2025 16:44
/**
*@see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver
*/
exportinterfaceFileSystemObserver{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Prefix it withI

Suggested change
exportinterfaceFileSystemObserver{
exportinterfaceIFileSystemObserver{

The observer also needs itsconstructor to be typed:

jsCopyconst observer = new FileSystemObserver(callback);The [callback function](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver/FileSystemObserver#callback) body can be specified to return and process file change observations in any way you want:jsCopyconst callback = (records, observer) => {  for (const record of records) {    console.log("Change detected:", record);    const reportContent = `Change observed to ${record.changedHandle.kind} ${record.changedHandle.name}. Type: ${record.type}.`;    sendReport(reportContent); // Some kind of user-defined reporting function  }  observer.disconnect();};

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Updated interface name toIFileSystemObserver and added constructor signature with callback function as specified in the MDN documentation. Changes implemented in commit38e2f13.

/**
*@see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord
*/
exportinterfaceFileSystemChangeRecord{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This interface is lacking types, see docs:

[Instance properties](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#instance_properties)[changedHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#changedhandle)A reference to the file system handle that the change was observed on.For the user-observable file system, this can be a [FileSystemFileHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle) or a [FileSystemDirectoryHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle).For the [Origin Private File System](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (OPFS), it can be a [FileSystemFileHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle), a [FileSystemDirectoryHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle), or a [FileSystemSyncAccessHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle).This property will be null for records with a "disappeared", "errored", or "unknown" type.[relativePathComponents](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#relativepathcomponents)An array containing the path components that make up the relative file path from the root to the changedHandle, including the changedHandle filename.[relativePathMovedFrom](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#relativepathmovedfrom)An array containing the path components that make up the relative file path from the root to the changedHandle's former location, in the case of observations with a "moved" type. If the type is not "moved", this property will be null.[root](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#root)A reference to the root file system handle, that is, the one passed to the observe() call that started the observation. Again, this can be a [FileSystemFileHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle), [FileSystemDirectoryHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle), or [FileSystemSyncAccessHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle).[type](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#type)A string representing the type of change that was observed. Possible values are:[appeared](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#appeared)The file or directory was created or moved into the root file structure.[disappeared](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#disappeared)The file or directory was deleted or moved out of the root file structure. To find out which file or directory disappeared, you can query the relativePathComponents property.[errored](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#errored)An error state occurred in the observed directory. This can result when:The observation is no longer valid. This can occur when the observed handle (that is, the root of the observation) is deleted or moved. In this case, a "disappeared" observation will be recorded, followed by an "errored" observation. In such cases, you may wish to stop observing the file system using [FileSystemObserver.disconnect()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver/disconnect).The maximum limit of per-origin observations is reached. This limit is dependent on the operating system and not known beforehand. If this happens, the site may decide to retry, though there's no guarantee that the operating system will have freed up enough resources.Permission to access the directory or file handle is removed.[modified](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#modified)The file or directory was modified.[moved](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#moved)The file or directory was moved within the root file structure.Note: On Windows, "moved" observations aren't supported between directories. They are reported as a "disappeared" observation in the source directory and an "appeared" observation in the destination directory.[unknown](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord#unknown)Indicates that some observations were missed. If you wish to find out information on what changed in the missed observations, you could fall back to polling the observed directory.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Added all missing properties from the MDN spec:relativePathMovedFrom,root, nullablechangedHandle, and completetype values including "errored", "moved", and "unknown". Also added support forIFileSystemSyncAccessHandle for OPFS compatibility. Changes implemented in commit38e2f13.

@streamich
Copy link
Owner

@copilot pls

Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
CopilotAI changed the titlefeat: add FileSystem observer API typesfeat: add comprehensive FileSystem observer API types with full MDN spec complianceAug 22, 2025
CopilotAI requested a review fromstreamichAugust 22, 2025 21:06
Copilot finished work on behalf ofstreamichAugust 22, 2025 21:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@streamichstreamichAwaiting requested review from streamich

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add File System (FS) API observer API types

2 participants

@streamich

[8]ページ先頭

©2009-2025 Movatter.jp