Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

browser-fs-access

Package Overview
Dependencies
0
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.20.1 to 0.20.2

98

index.d.ts
/**
* Opens file(s) from disk.
* Properties shared by all `options` provided to file save and open operations
*/
export function fileOpen<M extends boolean | undefined = false>(options?: {
/** Acceptable MIME types. [] */
mimeTypes?: string[];
/** Acceptable file extensions. Defaults to "". */
export interface CoreFileOptions {
/** Acceptable file extensions. Defaults to [""]. */
extensions?: string[];
/** Suggested file description. Defaults to "". */
description?: string;
/** Allow multiple files to be selected. Defaults to false. */
multiple?: M;
/** Acceptable MIME types. [] */
mimeTypes?: string[];
}
/**
* Properties shared by the _first_ `options` object provided to file save and
* open operations (any additional options objects provided to those operations
* cannot have these properties)
*/
export interface FirstCoreFileOptions extends CoreFileOptions {
startIn?: WellKnownDirectory | FileSystemHandle;
/** By specifying an ID, the user agent can remember different directories for different IDs. */
id?: string;
}
/**
* The first `options` object passed to file save operations can also specify
* a filename
*/
export interface FirstFileSaveOptions extends FirstCoreFileOptions {
/** Suggested file name. Defaults to "Untitled". */
fileName?: string;
}
/**
* The first `options` object passed to file open operations can specify
* whether multiple files can be selected (the return type of the operation
* will be updated appropriately) and a way of handling cleanup and rejection
* for legacy open operations.
*/
export interface FirstFileOpenOptions<M extends boolean | undefined>
extends FirstCoreFileOptions {
/** Allow multiple files to be selected. Defaults to false. */
multiple?: M;
/**

@@ -47,3 +74,12 @@ * Configurable cleanup and `Promise` rejector usable with legacy API for

) => (reject: (reason?: any) => void) => void;
}): M extends false | undefined
}
/**
* Opens file(s) from disk.
*/
export function fileOpen<M extends boolean | undefined = false>(
options?: O extends any[]
? [FirstFileOpenOptions<M>, ...CoreFileOptions[]]
: FirstFileOpenOptions<M>
): M extends false | undefined
? Promise<FileWithHandle>

@@ -67,14 +103,5 @@ : Promise<FileWithHandle[]>;

blob: Blob,
options?: {
/** Suggested file name. Defaults to "Untitled". */
fileName?: string;
/** Suggested file extensions. Defaults to [""]. */
extensions?: string[];
/** Suggested file description. Defaults to "". */
description?: string;
/** Suggested directory in which the file picker opens. */
startIn?: WellKnownDirectory | FileSystemHandle;
/** By specifying an ID, the user agent can remember different directories for different IDs. */
id?: string;
},
options?: O extends any[]
? [FirstFileSaveOptions, ...CoreFileOptions[]]
: FirstFileSaveOptions,
/**

@@ -103,2 +130,33 @@ * A potentially existing file handle for a file to save to. Defaults to

id?: string;
/**
* Configurable cleanup and `Promise` rejector usable with legacy API for
* determining when (and reacting if) a user cancels the operation. The
* method will be passed a reference to the internal `rejectionHandler` that
* can, e.g., be attached to/removed from the window or called after a
* timeout. The method should return a function that will be called when
* either the user chooses to open a file or the `rejectionHandler` is
* called. In the latter case, the returned function will also be passed a
* reference to the `reject` callback for the `Promise` returned by
* `fileOpen`, so that developers may reject the `Promise` when desired at
* that time.
* Example rejector:
*
* const file = await directoryOpen({
* setupLegacyCleanupAndRejection: (rejectionHandler) => {
* const timeoutId = setTimeout(rejectionHandler, 10_000);
* return (reject) => {
* clearTimeout(timeoutId);
* if (reject) {
* reject('My error message here.');
* }
* };
* },
* });
*
* ToDo: Remove this workaround once
* https://github.com/whatwg/html/issues/6376 is specified and supported.
*/
setupLegacyCleanupAndRejection?: (
rejectionHandler?: () => void
) => (reject: (reason?: any) => void) => void;
}): Promise<FileWithDirectoryHandle[]>;

@@ -105,0 +163,0 @@

{
"name": "browser-fs-access",
"version": "0.20.1",
"version": "0.20.2",
"description": "File System Access API with legacy fallback in the browser.",

@@ -46,3 +46,3 @@ "browser": "./dist/index.js",

"eslint-config-prettier": "^8.3.0",
"http-server": "^0.12.3",
"http-server": "^13.0.0",
"prettier": "^2.3.2",

@@ -49,0 +49,0 @@ "shx": "^0.3.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc