metro-cache
Advanced tools
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {CacheStore} from './types'; | ||
| /** | ||
| * Main cache class. Receives an array of cache instances, and sequentially | ||
| * traverses them to return a previously stored value. It also ensures setting | ||
| * the value in all instances. | ||
| * | ||
| * All get/set operations are logged via Metro's logger. | ||
| */ | ||
| declare class Cache<T> { | ||
| constructor(stores: ReadonlyArray<CacheStore<T>>); | ||
| get(key: Buffer): Promise<null | undefined | T>; | ||
| set(key: Buffer, value: T): Promise<void>; | ||
| get isDisabled(): boolean; | ||
| } | ||
| export default Cache; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import Cache from './Cache'; | ||
| import stableHash from './stableHash'; | ||
| import AutoCleanFileStore from './stores/AutoCleanFileStore'; | ||
| import FileStore from './stores/FileStore'; | ||
| import HttpGetStore from './stores/HttpGetStore'; | ||
| import HttpStore from './stores/HttpStore'; | ||
| export type {Options as FileOptions} from './stores/FileStore'; | ||
| export type {Options as HttpOptions} from './stores/HttpStore'; | ||
| export type {CacheStore} from './types'; | ||
| export { | ||
| AutoCleanFileStore, | ||
| Cache, | ||
| FileStore, | ||
| HttpGetStore, | ||
| HttpStore, | ||
| stableHash, | ||
| }; | ||
| export interface MetroCache { | ||
| readonly AutoCleanFileStore: typeof AutoCleanFileStore; | ||
| readonly Cache: typeof Cache; | ||
| readonly FileStore: typeof FileStore; | ||
| readonly HttpGetStore: typeof HttpGetStore; | ||
| readonly HttpStore: typeof HttpStore; | ||
| readonly stableHash: typeof stableHash; | ||
| } | ||
| /** | ||
| * Backwards-compatibility with CommonJS consumers using interopRequireDefault. | ||
| * Do not add to this list. | ||
| * | ||
| * @deprecated Default import from 'metro-cache' is deprecated, use named exports. | ||
| */ | ||
| declare const $$EXPORT_DEFAULT_DECLARATION$$: MetroCache; | ||
| declare type $$EXPORT_DEFAULT_DECLARATION$$ = | ||
| typeof $$EXPORT_DEFAULT_DECLARATION$$; | ||
| export default $$EXPORT_DEFAULT_DECLARATION$$; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| declare function stableHash(value: unknown): Buffer; | ||
| export default stableHash; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {Options} from './FileStore'; | ||
| import FileStore from './FileStore'; | ||
| type CleanOptions = Readonly< | ||
| Omit<Options, keyof {intervalMs?: number; cleanupThresholdMs?: number}> & { | ||
| intervalMs?: number; | ||
| cleanupThresholdMs?: number; | ||
| } | ||
| >; | ||
| /** | ||
| * A FileStore that, at a given interval, stats the content of the cache root | ||
| * and deletes any file last modified a set threshold in the past. | ||
| * | ||
| * @deprecated This is not efficiently implemented and may cause significant | ||
| * redundant I/O when caches are large. Prefer your own cleanup scripts, or a | ||
| * custom Metro cache that uses watches, hooks get/set, and/or implements LRU. | ||
| */ | ||
| declare class AutoCleanFileStore<T> extends FileStore<T> { | ||
| constructor(opts: CleanOptions); | ||
| } | ||
| export default AutoCleanFileStore; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| export type Options = Readonly<{root: string}>; | ||
| declare class FileStore<T> { | ||
| constructor(options: Options); | ||
| get(key: Buffer): Promise<null | undefined | T>; | ||
| set(key: Buffer, value: T): Promise<void>; | ||
| clear(): void; | ||
| } | ||
| export default FileStore; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| */ | ||
| declare class HttpError extends Error { | ||
| code: number; | ||
| constructor(message: string, code: number); | ||
| } | ||
| export default HttpError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import type {Options as HttpOptions} from './HttpStore'; | ||
| import HttpStore from './HttpStore'; | ||
| declare class HttpGetStore<T> extends HttpStore<T> { | ||
| constructor(options: HttpOptions); | ||
| get(key: Buffer): Promise<null | undefined | T>; | ||
| set(_key: Buffer, _value: T): Promise<void>; | ||
| } | ||
| export default HttpGetStore; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| import HttpError from './HttpError'; | ||
| import NetworkError from './NetworkError'; | ||
| export type Options = | ||
| | EndpointOptions | ||
| | {getOptions: EndpointOptions; setOptions: EndpointOptions}; | ||
| type EndpointOptions = { | ||
| endpoint: string; | ||
| family?: 4 | 6; | ||
| timeout?: number; | ||
| key?: string | ReadonlyArray<string> | Buffer | ReadonlyArray<Buffer>; | ||
| cert?: string | ReadonlyArray<string> | Buffer | ReadonlyArray<Buffer>; | ||
| ca?: string | ReadonlyArray<string> | Buffer | ReadonlyArray<Buffer>; | ||
| params?: URLSearchParams; | ||
| headers?: {[$$Key$$: string]: string}; | ||
| additionalSuccessStatuses?: ReadonlyArray<number>; | ||
| /** | ||
| * Whether to include additional debug information in error messages. | ||
| */ | ||
| debug?: boolean; | ||
| /** | ||
| * Retry configuration | ||
| */ | ||
| maxAttempts?: number; | ||
| retryNetworkErrors?: boolean; | ||
| retryStatuses?: ReadonlySet<number>; | ||
| socketPath?: string; | ||
| proxy?: string; | ||
| }; | ||
| declare class HttpStore<T> { | ||
| static HttpError: typeof HttpError; | ||
| static NetworkError: typeof NetworkError; | ||
| constructor(options: Options); | ||
| get(key: Buffer): Promise<null | undefined | T>; | ||
| set(key: Buffer, value: T): Promise<void>; | ||
| clear(): void; | ||
| } | ||
| export default HttpStore; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| */ | ||
| declare class NetworkError extends Error { | ||
| code: string; | ||
| constructor(message: string, code: string); | ||
| } | ||
| export default NetworkError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @oncall react_native | ||
| */ | ||
| export interface CacheStore<T> { | ||
| name?: string; | ||
| get(key: Buffer): (null | undefined | T) | Promise<null | undefined | T>; | ||
| set(key: Buffer, value: T): void | Promise<void>; | ||
| clear(): void | Promise<void>; | ||
| } |
+4
-3
| { | ||
| "name": "metro-cache", | ||
| "version": "0.83.4", | ||
| "version": "0.83.5", | ||
| "description": "🚇 Cache layers for Metro.", | ||
@@ -13,3 +13,4 @@ "main": "src/index.js", | ||
| "type": "git", | ||
| "url": "git@github.com:facebook/metro.git" | ||
| "url": "git+https://github.com/facebook/metro.git", | ||
| "directory": "packages/metro-cache" | ||
| }, | ||
@@ -24,3 +25,3 @@ "scripts": { | ||
| "https-proxy-agent": "^7.0.5", | ||
| "metro-core": "0.83.4" | ||
| "metro-core": "0.83.5" | ||
| }, | ||
@@ -27,0 +28,0 @@ "devDependencies": { |
+1
-5
@@ -52,7 +52,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -59,0 +55,0 @@ var _default = (exports.default = { |
@@ -12,7 +12,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -19,0 +15,0 @@ function stableHash(value) { |
@@ -11,7 +11,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -18,0 +14,0 @@ class AutoCleanFileStore extends _FileStore.default { |
@@ -10,7 +10,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -17,0 +13,0 @@ const NULL_BYTE = 0x00; |
@@ -10,7 +10,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -17,0 +13,0 @@ class HttpGetStore extends _HttpStore.default { |
@@ -15,7 +15,3 @@ "use strict"; | ||
| function _interopRequireDefault(e) { | ||
| return e && e.__esModule | ||
| ? e | ||
| : { | ||
| default: e, | ||
| }; | ||
| return e && e.__esModule ? e : { default: e }; | ||
| } | ||
@@ -22,0 +18,0 @@ const ZLIB_OPTIONS = { |
52298
15.4%31
47.62%920
28.67%+ Added
+ Added
- Removed
- Removed
Updated