You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update FileSystemObserver explainer
This commit renames some FileSystemChangeType values, adds a section about interactions with Back/forward Cache, and updates API position by Gecko.
@@ -264,7 +264,7 @@ async function handleChanges(records) {
264
264
constchangedHandle=record.changedHandle;
265
265
266
266
// Take advantage of file-level notifications, if available.
267
-
if (changedHandle.kind==='file'&&record.type==='created') {
267
+
if (changedHandle.kind==='file'&&record.type==='appeared') {
268
268
sawFileCreatedRecord =true;
269
269
readNewFile(changedHandle);
270
270
}
@@ -304,6 +304,10 @@ Likewise, changes which occur before an observer is created should not be report
304
304
305
305
A `FileSystemObserver` is not [serializable](https://html.spec.whatwg.org/multipage/structured-data.html#serializable) and therefore cannot be persisted across browsing sessions. Websites which wish to watch the same files on each session may store serializable `FileSystemHandle` and `FileSystemObserverObserveOptions` objects in IndexedDB, then create a `FileSystemObserver` and configure it from these objects on page reload.
306
306
307
+
### Interactions with Back/forward Cache
308
+
309
+
If changes occurred while the page was not fully active, and the page becomes active again (i.e. back/forward cache), then user agents may use the `"unknown"``FileSystemChangeType` to indicate that _changes_ have occurred. Specific types and ordering of changes should not be exposed but indicating that some changes have occurred could be useful to the website to perform any special handling.
310
+
307
311
### Signaling Changes Made via a `FileSystemSyncAccessHandle`
308
312
309
313
It is assumed that a user agent’s implementation of the `FileSystemObserver` interface will involve coordinating with a centralized browser process. However, unlike most web storage APIs, reading and writing files with a `FileSystemSyncAccessHandle` is commonly implemented largely without coordinating with a centralized browser process. This is critical to the exceptional performance characteristics of this interface. `write()` or `truncate()` operations on a `FileSystemSyncAccessHandle` should trigger a file system change record, but requiring round-trip IPC to complete before synchronously returning would be detrimental to performance.
@@ -343,8 +347,8 @@ However, given the cross-platform differences, this proposal does not attempt to
343
347
```javascript
344
348
constcallback= (records, observer) => {
345
349
// What change record will be triggered when the file is created?
User agents should attempt to include the most precise information as it can reasonably obtain in the file system change record. In this example, the change record is most useful if it details that a specific file has been added (i.e. option 1) as opposed to mentioning just that the parent directory’s contents were modified - which would require the website to iterate through the directory to figure out which file has changed, and how.
357
361
358
-
All changes to a Bucket File System should deterministically map to a precise file system change record. In this example, the `getFileHandle()` call should result in a change record with a `”create”` change type and describe the change as occurring on the created file.
362
+
All changes to a Bucket File System should deterministically map to a precise file system change record. In this example, the `getFileHandle()` call should result in a change record with a `”appeared”` change type and describe the change as occurring on the created file.
359
363
360
-
However, this level of detail is not realistic on all platforms for local file system changes. For example, Linux has no native support for recursive watches. As such, the details of a file system change record for a given change to the local file system should be regarded as best-effort. In the example below, the user agent may report either a `”create”` change type describing the created file, a `”create”` change type describing a creation within the observed directory, or a `”modified”` change type describing that the directory contents were modified.
364
+
However, this level of detail is not realistic on all platforms for local file system changes. For example, Linux has no native support for recursive watches. As such, the details of a file system change record for a given change to the local file system should be regarded as best-effort. In the example below, the user agent may report either a `”appeared”` change type describing the created file, a `”appeared”` change type describing a creation within the observed directory, or a `”modified”` change type describing that the directory contents were modified.
361
365
362
366
```javascript
363
367
constcallback= (records, observer) => {
364
368
// What change record will be triggered when the file is created?
0 commit comments