scratch-storage
Version:
Load and store project and asset files for Scratch 3.0
54 lines (53 loc) • 1.72 kB
TypeScript
import { ScratchGetRequest, ScratchSendRequest, Tool } from './Tool';
/**
* @typedef {object} Request
* @property {string} url
* @property {*} body
* @property {string} method
* @property {boolean} withCredentials
*/
type ToolFilter = typeof ProxyTool.TOOL_FILTER[keyof typeof ProxyTool.TOOL_FILTER];
/**
* Get and send assets with other tools in sequence.
*/
export default class ProxyTool implements Tool {
tools: Tool[];
/**
* Constant values that filter the set of tools in a ProxyTool instance.
* @enum {string}
*/
static TOOL_FILTER: {
/**
* Use all tools.
*/
readonly ALL: "all";
/**
* Use tools that are ready right now.
*/
readonly READY: "ready";
};
constructor(filter?: ToolFilter);
/**
* Is get supported? false if all proxied tool return false.
* @returns {boolean} Is get supported?
*/
get isGetSupported(): boolean;
/**
* Request data from with one of the proxied tools.
* @param {Request} reqConfig - Request configuration for data to get.
* @returns {Promise.<Buffer>} Resolve to Buffer of data from server.
*/
get(reqConfig: ScratchGetRequest): Promise<Uint8Array | null>;
/**
* Is sending supported? false if all proxied tool return false.
* @returns {boolean} Is sending supported?
*/
get isSendSupported(): boolean;
/**
* Send data to a server with one of the proxied tools.
* @param {Request} reqConfig - Request configuration for data to send.
* @returns {Promise.<Buffer|string|object>} Server returned metadata.
*/
send(reqConfig: ScratchSendRequest): Promise<string>;
}
export {};