full site update
This commit is contained in:
121
node_modules/unstorage/dist/shared/unstorage.Ca7R4QL2.d.cts
generated
vendored
Normal file
121
node_modules/unstorage/dist/shared/unstorage.Ca7R4QL2.d.cts
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
type StorageValue = null | string | number | boolean | object;
|
||||
type WatchEvent = "update" | "remove";
|
||||
type WatchCallback = (event: WatchEvent, key: string) => any;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type MaybeDefined<T> = T extends any ? T : any;
|
||||
type Unwatch = () => MaybePromise<void>;
|
||||
interface StorageMeta {
|
||||
atime?: Date;
|
||||
mtime?: Date;
|
||||
ttl?: number;
|
||||
[key: string]: StorageValue | Date | undefined;
|
||||
}
|
||||
type TransactionOptions = Record<string, any>;
|
||||
type GetKeysOptions = TransactionOptions & {
|
||||
maxDepth?: number;
|
||||
};
|
||||
interface DriverFlags {
|
||||
maxDepth?: boolean;
|
||||
ttl?: boolean;
|
||||
}
|
||||
interface Driver<OptionsT = any, InstanceT = any> {
|
||||
name?: string;
|
||||
flags?: DriverFlags;
|
||||
options?: OptionsT;
|
||||
getInstance?: () => InstanceT;
|
||||
hasItem: (key: string, opts: TransactionOptions) => MaybePromise<boolean>;
|
||||
getItem: (key: string, opts?: TransactionOptions) => MaybePromise<StorageValue>;
|
||||
/** @experimental */
|
||||
getItems?: (items: {
|
||||
key: string;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => MaybePromise<{
|
||||
key: string;
|
||||
value: StorageValue;
|
||||
}[]>;
|
||||
/** @experimental */
|
||||
getItemRaw?: (key: string, opts: TransactionOptions) => MaybePromise<unknown>;
|
||||
setItem?: (key: string, value: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
/** @experimental */
|
||||
setItems?: (items: {
|
||||
key: string;
|
||||
value: string;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => MaybePromise<void>;
|
||||
/** @experimental */
|
||||
setItemRaw?: (key: string, value: any, opts: TransactionOptions) => MaybePromise<void>;
|
||||
removeItem?: (key: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
getMeta?: (key: string, opts: TransactionOptions) => MaybePromise<StorageMeta | null>;
|
||||
getKeys: (base: string, opts: GetKeysOptions) => MaybePromise<string[]>;
|
||||
clear?: (base: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
dispose?: () => MaybePromise<void>;
|
||||
watch?: (callback: WatchCallback) => MaybePromise<Unwatch>;
|
||||
}
|
||||
type StorageDefinition = {
|
||||
items: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type StorageItemMap<T> = T extends StorageDefinition ? T["items"] : T;
|
||||
type StorageItemType<T, K> = K extends keyof StorageItemMap<T> ? StorageItemMap<T>[K] : T extends StorageDefinition ? StorageValue : T;
|
||||
interface Storage<T extends StorageValue = StorageValue> {
|
||||
hasItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, opts?: TransactionOptions): Promise<boolean>;
|
||||
hasItem(key: string, opts?: TransactionOptions): Promise<boolean>;
|
||||
getItem<U extends Extract<T, StorageDefinition>, K extends string & keyof StorageItemMap<U>>(key: K, ops?: TransactionOptions): Promise<StorageItemType<T, K> | null>;
|
||||
getItem<R = StorageItemType<T, string>>(key: string, opts?: TransactionOptions): Promise<R | null>;
|
||||
/** @experimental */
|
||||
getItems: <U extends T>(items: (string | {
|
||||
key: string;
|
||||
options?: TransactionOptions;
|
||||
})[], commonOptions?: TransactionOptions) => Promise<{
|
||||
key: string;
|
||||
value: U;
|
||||
}[]>;
|
||||
/** @experimental See https://github.com/unjs/unstorage/issues/142 */
|
||||
getItemRaw: <T = any>(key: string, opts?: TransactionOptions) => Promise<MaybeDefined<T> | null>;
|
||||
setItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, value: StorageItemType<T, K>, opts?: TransactionOptions): Promise<void>;
|
||||
setItem<U extends T>(key: string, value: U, opts?: TransactionOptions): Promise<void>;
|
||||
/** @experimental */
|
||||
setItems: <U extends T>(items: {
|
||||
key: string;
|
||||
value: U;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => Promise<void>;
|
||||
/** @experimental See https://github.com/unjs/unstorage/issues/142 */
|
||||
setItemRaw: <T = any>(key: string, value: MaybeDefined<T>, opts?: TransactionOptions) => Promise<void>;
|
||||
removeItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, opts?: (TransactionOptions & {
|
||||
removeMeta?: boolean;
|
||||
}) | boolean): Promise<void>;
|
||||
removeItem(key: string, opts?: (TransactionOptions & {
|
||||
removeMeta?: boolean;
|
||||
}) | boolean): Promise<void>;
|
||||
getMeta: (key: string, opts?: (TransactionOptions & {
|
||||
nativeOnly?: boolean;
|
||||
}) | boolean) => MaybePromise<StorageMeta>;
|
||||
setMeta: (key: string, value: StorageMeta, opts?: TransactionOptions) => Promise<void>;
|
||||
removeMeta: (key: string, opts?: TransactionOptions) => Promise<void>;
|
||||
getKeys: (base?: string, opts?: GetKeysOptions) => Promise<string[]>;
|
||||
clear: (base?: string, opts?: TransactionOptions) => Promise<void>;
|
||||
dispose: () => Promise<void>;
|
||||
watch: (callback: WatchCallback) => Promise<Unwatch>;
|
||||
unwatch: () => Promise<void>;
|
||||
mount: (base: string, driver: Driver) => Storage;
|
||||
unmount: (base: string, dispose?: boolean) => Promise<void>;
|
||||
getMount: (key?: string) => {
|
||||
base: string;
|
||||
driver: Driver;
|
||||
};
|
||||
getMounts: (base?: string, options?: {
|
||||
parents?: boolean;
|
||||
}) => {
|
||||
base: string;
|
||||
driver: Driver;
|
||||
}[];
|
||||
keys: Storage["getKeys"];
|
||||
get: Storage<T>["getItem"];
|
||||
set: Storage<T>["setItem"];
|
||||
has: Storage<T>["hasItem"];
|
||||
del: Storage<T>["removeItem"];
|
||||
remove: Storage<T>["removeItem"];
|
||||
}
|
||||
|
||||
export type { Driver as D, GetKeysOptions as G, StorageValue as S, TransactionOptions as T, Unwatch as U, WatchEvent as W, Storage as a, WatchCallback as b, StorageMeta as c, DriverFlags as d };
|
121
node_modules/unstorage/dist/shared/unstorage.Ca7R4QL2.d.mts
generated
vendored
Normal file
121
node_modules/unstorage/dist/shared/unstorage.Ca7R4QL2.d.mts
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
type StorageValue = null | string | number | boolean | object;
|
||||
type WatchEvent = "update" | "remove";
|
||||
type WatchCallback = (event: WatchEvent, key: string) => any;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type MaybeDefined<T> = T extends any ? T : any;
|
||||
type Unwatch = () => MaybePromise<void>;
|
||||
interface StorageMeta {
|
||||
atime?: Date;
|
||||
mtime?: Date;
|
||||
ttl?: number;
|
||||
[key: string]: StorageValue | Date | undefined;
|
||||
}
|
||||
type TransactionOptions = Record<string, any>;
|
||||
type GetKeysOptions = TransactionOptions & {
|
||||
maxDepth?: number;
|
||||
};
|
||||
interface DriverFlags {
|
||||
maxDepth?: boolean;
|
||||
ttl?: boolean;
|
||||
}
|
||||
interface Driver<OptionsT = any, InstanceT = any> {
|
||||
name?: string;
|
||||
flags?: DriverFlags;
|
||||
options?: OptionsT;
|
||||
getInstance?: () => InstanceT;
|
||||
hasItem: (key: string, opts: TransactionOptions) => MaybePromise<boolean>;
|
||||
getItem: (key: string, opts?: TransactionOptions) => MaybePromise<StorageValue>;
|
||||
/** @experimental */
|
||||
getItems?: (items: {
|
||||
key: string;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => MaybePromise<{
|
||||
key: string;
|
||||
value: StorageValue;
|
||||
}[]>;
|
||||
/** @experimental */
|
||||
getItemRaw?: (key: string, opts: TransactionOptions) => MaybePromise<unknown>;
|
||||
setItem?: (key: string, value: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
/** @experimental */
|
||||
setItems?: (items: {
|
||||
key: string;
|
||||
value: string;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => MaybePromise<void>;
|
||||
/** @experimental */
|
||||
setItemRaw?: (key: string, value: any, opts: TransactionOptions) => MaybePromise<void>;
|
||||
removeItem?: (key: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
getMeta?: (key: string, opts: TransactionOptions) => MaybePromise<StorageMeta | null>;
|
||||
getKeys: (base: string, opts: GetKeysOptions) => MaybePromise<string[]>;
|
||||
clear?: (base: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
dispose?: () => MaybePromise<void>;
|
||||
watch?: (callback: WatchCallback) => MaybePromise<Unwatch>;
|
||||
}
|
||||
type StorageDefinition = {
|
||||
items: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type StorageItemMap<T> = T extends StorageDefinition ? T["items"] : T;
|
||||
type StorageItemType<T, K> = K extends keyof StorageItemMap<T> ? StorageItemMap<T>[K] : T extends StorageDefinition ? StorageValue : T;
|
||||
interface Storage<T extends StorageValue = StorageValue> {
|
||||
hasItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, opts?: TransactionOptions): Promise<boolean>;
|
||||
hasItem(key: string, opts?: TransactionOptions): Promise<boolean>;
|
||||
getItem<U extends Extract<T, StorageDefinition>, K extends string & keyof StorageItemMap<U>>(key: K, ops?: TransactionOptions): Promise<StorageItemType<T, K> | null>;
|
||||
getItem<R = StorageItemType<T, string>>(key: string, opts?: TransactionOptions): Promise<R | null>;
|
||||
/** @experimental */
|
||||
getItems: <U extends T>(items: (string | {
|
||||
key: string;
|
||||
options?: TransactionOptions;
|
||||
})[], commonOptions?: TransactionOptions) => Promise<{
|
||||
key: string;
|
||||
value: U;
|
||||
}[]>;
|
||||
/** @experimental See https://github.com/unjs/unstorage/issues/142 */
|
||||
getItemRaw: <T = any>(key: string, opts?: TransactionOptions) => Promise<MaybeDefined<T> | null>;
|
||||
setItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, value: StorageItemType<T, K>, opts?: TransactionOptions): Promise<void>;
|
||||
setItem<U extends T>(key: string, value: U, opts?: TransactionOptions): Promise<void>;
|
||||
/** @experimental */
|
||||
setItems: <U extends T>(items: {
|
||||
key: string;
|
||||
value: U;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => Promise<void>;
|
||||
/** @experimental See https://github.com/unjs/unstorage/issues/142 */
|
||||
setItemRaw: <T = any>(key: string, value: MaybeDefined<T>, opts?: TransactionOptions) => Promise<void>;
|
||||
removeItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, opts?: (TransactionOptions & {
|
||||
removeMeta?: boolean;
|
||||
}) | boolean): Promise<void>;
|
||||
removeItem(key: string, opts?: (TransactionOptions & {
|
||||
removeMeta?: boolean;
|
||||
}) | boolean): Promise<void>;
|
||||
getMeta: (key: string, opts?: (TransactionOptions & {
|
||||
nativeOnly?: boolean;
|
||||
}) | boolean) => MaybePromise<StorageMeta>;
|
||||
setMeta: (key: string, value: StorageMeta, opts?: TransactionOptions) => Promise<void>;
|
||||
removeMeta: (key: string, opts?: TransactionOptions) => Promise<void>;
|
||||
getKeys: (base?: string, opts?: GetKeysOptions) => Promise<string[]>;
|
||||
clear: (base?: string, opts?: TransactionOptions) => Promise<void>;
|
||||
dispose: () => Promise<void>;
|
||||
watch: (callback: WatchCallback) => Promise<Unwatch>;
|
||||
unwatch: () => Promise<void>;
|
||||
mount: (base: string, driver: Driver) => Storage;
|
||||
unmount: (base: string, dispose?: boolean) => Promise<void>;
|
||||
getMount: (key?: string) => {
|
||||
base: string;
|
||||
driver: Driver;
|
||||
};
|
||||
getMounts: (base?: string, options?: {
|
||||
parents?: boolean;
|
||||
}) => {
|
||||
base: string;
|
||||
driver: Driver;
|
||||
}[];
|
||||
keys: Storage["getKeys"];
|
||||
get: Storage<T>["getItem"];
|
||||
set: Storage<T>["setItem"];
|
||||
has: Storage<T>["hasItem"];
|
||||
del: Storage<T>["removeItem"];
|
||||
remove: Storage<T>["removeItem"];
|
||||
}
|
||||
|
||||
export type { Driver as D, GetKeysOptions as G, StorageValue as S, TransactionOptions as T, Unwatch as U, WatchEvent as W, Storage as a, WatchCallback as b, StorageMeta as c, DriverFlags as d };
|
121
node_modules/unstorage/dist/shared/unstorage.Ca7R4QL2.d.ts
generated
vendored
Normal file
121
node_modules/unstorage/dist/shared/unstorage.Ca7R4QL2.d.ts
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
type StorageValue = null | string | number | boolean | object;
|
||||
type WatchEvent = "update" | "remove";
|
||||
type WatchCallback = (event: WatchEvent, key: string) => any;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type MaybeDefined<T> = T extends any ? T : any;
|
||||
type Unwatch = () => MaybePromise<void>;
|
||||
interface StorageMeta {
|
||||
atime?: Date;
|
||||
mtime?: Date;
|
||||
ttl?: number;
|
||||
[key: string]: StorageValue | Date | undefined;
|
||||
}
|
||||
type TransactionOptions = Record<string, any>;
|
||||
type GetKeysOptions = TransactionOptions & {
|
||||
maxDepth?: number;
|
||||
};
|
||||
interface DriverFlags {
|
||||
maxDepth?: boolean;
|
||||
ttl?: boolean;
|
||||
}
|
||||
interface Driver<OptionsT = any, InstanceT = any> {
|
||||
name?: string;
|
||||
flags?: DriverFlags;
|
||||
options?: OptionsT;
|
||||
getInstance?: () => InstanceT;
|
||||
hasItem: (key: string, opts: TransactionOptions) => MaybePromise<boolean>;
|
||||
getItem: (key: string, opts?: TransactionOptions) => MaybePromise<StorageValue>;
|
||||
/** @experimental */
|
||||
getItems?: (items: {
|
||||
key: string;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => MaybePromise<{
|
||||
key: string;
|
||||
value: StorageValue;
|
||||
}[]>;
|
||||
/** @experimental */
|
||||
getItemRaw?: (key: string, opts: TransactionOptions) => MaybePromise<unknown>;
|
||||
setItem?: (key: string, value: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
/** @experimental */
|
||||
setItems?: (items: {
|
||||
key: string;
|
||||
value: string;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => MaybePromise<void>;
|
||||
/** @experimental */
|
||||
setItemRaw?: (key: string, value: any, opts: TransactionOptions) => MaybePromise<void>;
|
||||
removeItem?: (key: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
getMeta?: (key: string, opts: TransactionOptions) => MaybePromise<StorageMeta | null>;
|
||||
getKeys: (base: string, opts: GetKeysOptions) => MaybePromise<string[]>;
|
||||
clear?: (base: string, opts: TransactionOptions) => MaybePromise<void>;
|
||||
dispose?: () => MaybePromise<void>;
|
||||
watch?: (callback: WatchCallback) => MaybePromise<Unwatch>;
|
||||
}
|
||||
type StorageDefinition = {
|
||||
items: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type StorageItemMap<T> = T extends StorageDefinition ? T["items"] : T;
|
||||
type StorageItemType<T, K> = K extends keyof StorageItemMap<T> ? StorageItemMap<T>[K] : T extends StorageDefinition ? StorageValue : T;
|
||||
interface Storage<T extends StorageValue = StorageValue> {
|
||||
hasItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, opts?: TransactionOptions): Promise<boolean>;
|
||||
hasItem(key: string, opts?: TransactionOptions): Promise<boolean>;
|
||||
getItem<U extends Extract<T, StorageDefinition>, K extends string & keyof StorageItemMap<U>>(key: K, ops?: TransactionOptions): Promise<StorageItemType<T, K> | null>;
|
||||
getItem<R = StorageItemType<T, string>>(key: string, opts?: TransactionOptions): Promise<R | null>;
|
||||
/** @experimental */
|
||||
getItems: <U extends T>(items: (string | {
|
||||
key: string;
|
||||
options?: TransactionOptions;
|
||||
})[], commonOptions?: TransactionOptions) => Promise<{
|
||||
key: string;
|
||||
value: U;
|
||||
}[]>;
|
||||
/** @experimental See https://github.com/unjs/unstorage/issues/142 */
|
||||
getItemRaw: <T = any>(key: string, opts?: TransactionOptions) => Promise<MaybeDefined<T> | null>;
|
||||
setItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, value: StorageItemType<T, K>, opts?: TransactionOptions): Promise<void>;
|
||||
setItem<U extends T>(key: string, value: U, opts?: TransactionOptions): Promise<void>;
|
||||
/** @experimental */
|
||||
setItems: <U extends T>(items: {
|
||||
key: string;
|
||||
value: U;
|
||||
options?: TransactionOptions;
|
||||
}[], commonOptions?: TransactionOptions) => Promise<void>;
|
||||
/** @experimental See https://github.com/unjs/unstorage/issues/142 */
|
||||
setItemRaw: <T = any>(key: string, value: MaybeDefined<T>, opts?: TransactionOptions) => Promise<void>;
|
||||
removeItem<U extends Extract<T, StorageDefinition>, K extends keyof StorageItemMap<U>>(key: K, opts?: (TransactionOptions & {
|
||||
removeMeta?: boolean;
|
||||
}) | boolean): Promise<void>;
|
||||
removeItem(key: string, opts?: (TransactionOptions & {
|
||||
removeMeta?: boolean;
|
||||
}) | boolean): Promise<void>;
|
||||
getMeta: (key: string, opts?: (TransactionOptions & {
|
||||
nativeOnly?: boolean;
|
||||
}) | boolean) => MaybePromise<StorageMeta>;
|
||||
setMeta: (key: string, value: StorageMeta, opts?: TransactionOptions) => Promise<void>;
|
||||
removeMeta: (key: string, opts?: TransactionOptions) => Promise<void>;
|
||||
getKeys: (base?: string, opts?: GetKeysOptions) => Promise<string[]>;
|
||||
clear: (base?: string, opts?: TransactionOptions) => Promise<void>;
|
||||
dispose: () => Promise<void>;
|
||||
watch: (callback: WatchCallback) => Promise<Unwatch>;
|
||||
unwatch: () => Promise<void>;
|
||||
mount: (base: string, driver: Driver) => Storage;
|
||||
unmount: (base: string, dispose?: boolean) => Promise<void>;
|
||||
getMount: (key?: string) => {
|
||||
base: string;
|
||||
driver: Driver;
|
||||
};
|
||||
getMounts: (base?: string, options?: {
|
||||
parents?: boolean;
|
||||
}) => {
|
||||
base: string;
|
||||
driver: Driver;
|
||||
}[];
|
||||
keys: Storage["getKeys"];
|
||||
get: Storage<T>["getItem"];
|
||||
set: Storage<T>["setItem"];
|
||||
has: Storage<T>["hasItem"];
|
||||
del: Storage<T>["removeItem"];
|
||||
remove: Storage<T>["removeItem"];
|
||||
}
|
||||
|
||||
export type { Driver as D, GetKeysOptions as G, StorageValue as S, TransactionOptions as T, Unwatch as U, WatchEvent as W, Storage as a, WatchCallback as b, StorageMeta as c, DriverFlags as d };
|
151
node_modules/unstorage/dist/shared/unstorage.CoCt7NXC.mjs
generated
vendored
Normal file
151
node_modules/unstorage/dist/shared/unstorage.CoCt7NXC.mjs
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
function wrapToPromise(value) {
|
||||
if (!value || typeof value.then !== "function") {
|
||||
return Promise.resolve(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function asyncCall(function_, ...arguments_) {
|
||||
try {
|
||||
return wrapToPromise(function_(...arguments_));
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
function isPrimitive(value) {
|
||||
const type = typeof value;
|
||||
return value === null || type !== "object" && type !== "function";
|
||||
}
|
||||
function isPureObject(value) {
|
||||
const proto = Object.getPrototypeOf(value);
|
||||
return !proto || proto.isPrototypeOf(Object);
|
||||
}
|
||||
function stringify(value) {
|
||||
if (isPrimitive(value)) {
|
||||
return String(value);
|
||||
}
|
||||
if (isPureObject(value) || Array.isArray(value)) {
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
if (typeof value.toJSON === "function") {
|
||||
return stringify(value.toJSON());
|
||||
}
|
||||
throw new Error("[unstorage] Cannot stringify value!");
|
||||
}
|
||||
const BASE64_PREFIX = "base64:";
|
||||
function serializeRaw(value) {
|
||||
if (typeof value === "string") {
|
||||
return value;
|
||||
}
|
||||
return BASE64_PREFIX + base64Encode(value);
|
||||
}
|
||||
function deserializeRaw(value) {
|
||||
if (typeof value !== "string") {
|
||||
return value;
|
||||
}
|
||||
if (!value.startsWith(BASE64_PREFIX)) {
|
||||
return value;
|
||||
}
|
||||
return base64Decode(value.slice(BASE64_PREFIX.length));
|
||||
}
|
||||
function base64Decode(input) {
|
||||
if (globalThis.Buffer) {
|
||||
return Buffer.from(input, "base64");
|
||||
}
|
||||
return Uint8Array.from(
|
||||
globalThis.atob(input),
|
||||
(c) => c.codePointAt(0)
|
||||
);
|
||||
}
|
||||
function base64Encode(input) {
|
||||
if (globalThis.Buffer) {
|
||||
return Buffer.from(input).toString("base64");
|
||||
}
|
||||
return globalThis.btoa(String.fromCodePoint(...input));
|
||||
}
|
||||
|
||||
const storageKeyProperties = [
|
||||
"has",
|
||||
"hasItem",
|
||||
"get",
|
||||
"getItem",
|
||||
"getItemRaw",
|
||||
"set",
|
||||
"setItem",
|
||||
"setItemRaw",
|
||||
"del",
|
||||
"remove",
|
||||
"removeItem",
|
||||
"getMeta",
|
||||
"setMeta",
|
||||
"removeMeta",
|
||||
"getKeys",
|
||||
"clear",
|
||||
"mount",
|
||||
"unmount"
|
||||
];
|
||||
function prefixStorage(storage, base) {
|
||||
base = normalizeBaseKey(base);
|
||||
if (!base) {
|
||||
return storage;
|
||||
}
|
||||
const nsStorage = { ...storage };
|
||||
for (const property of storageKeyProperties) {
|
||||
nsStorage[property] = (key = "", ...args) => (
|
||||
// @ts-ignore
|
||||
storage[property](base + key, ...args)
|
||||
);
|
||||
}
|
||||
nsStorage.getKeys = (key = "", ...arguments_) => storage.getKeys(base + key, ...arguments_).then((keys) => keys.map((key2) => key2.slice(base.length)));
|
||||
nsStorage.getItems = async (items, commonOptions) => {
|
||||
const prefixedItems = items.map(
|
||||
(item) => typeof item === "string" ? base + item : { ...item, key: base + item.key }
|
||||
);
|
||||
const results = await storage.getItems(prefixedItems, commonOptions);
|
||||
return results.map((entry) => ({
|
||||
key: entry.key.slice(base.length),
|
||||
value: entry.value
|
||||
}));
|
||||
};
|
||||
nsStorage.setItems = async (items, commonOptions) => {
|
||||
const prefixedItems = items.map((item) => ({
|
||||
key: base + item.key,
|
||||
value: item.value,
|
||||
options: item.options
|
||||
}));
|
||||
return storage.setItems(prefixedItems, commonOptions);
|
||||
};
|
||||
return nsStorage;
|
||||
}
|
||||
function normalizeKey(key) {
|
||||
if (!key) {
|
||||
return "";
|
||||
}
|
||||
return key.split("?")[0]?.replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") || "";
|
||||
}
|
||||
function joinKeys(...keys) {
|
||||
return normalizeKey(keys.join(":"));
|
||||
}
|
||||
function normalizeBaseKey(base) {
|
||||
base = normalizeKey(base);
|
||||
return base ? base + ":" : "";
|
||||
}
|
||||
function filterKeyByDepth(key, depth) {
|
||||
if (depth === void 0) {
|
||||
return true;
|
||||
}
|
||||
let substrCount = 0;
|
||||
let index = key.indexOf(":");
|
||||
while (index > -1) {
|
||||
substrCount++;
|
||||
index = key.indexOf(":", index + 1);
|
||||
}
|
||||
return substrCount <= depth;
|
||||
}
|
||||
function filterKeyByBase(key, base) {
|
||||
if (base) {
|
||||
return key.startsWith(base) && key[key.length - 1] !== "$";
|
||||
}
|
||||
return key[key.length - 1] !== "$";
|
||||
}
|
||||
|
||||
export { normalizeKey as a, asyncCall as b, filterKeyByBase as c, stringify as d, deserializeRaw as e, filterKeyByDepth as f, joinKeys as j, normalizeBaseKey as n, prefixStorage as p, serializeRaw as s };
|
162
node_modules/unstorage/dist/shared/unstorage.DgtRghtF.cjs
generated
vendored
Normal file
162
node_modules/unstorage/dist/shared/unstorage.DgtRghtF.cjs
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
'use strict';
|
||||
|
||||
function wrapToPromise(value) {
|
||||
if (!value || typeof value.then !== "function") {
|
||||
return Promise.resolve(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function asyncCall(function_, ...arguments_) {
|
||||
try {
|
||||
return wrapToPromise(function_(...arguments_));
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
function isPrimitive(value) {
|
||||
const type = typeof value;
|
||||
return value === null || type !== "object" && type !== "function";
|
||||
}
|
||||
function isPureObject(value) {
|
||||
const proto = Object.getPrototypeOf(value);
|
||||
return !proto || proto.isPrototypeOf(Object);
|
||||
}
|
||||
function stringify(value) {
|
||||
if (isPrimitive(value)) {
|
||||
return String(value);
|
||||
}
|
||||
if (isPureObject(value) || Array.isArray(value)) {
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
if (typeof value.toJSON === "function") {
|
||||
return stringify(value.toJSON());
|
||||
}
|
||||
throw new Error("[unstorage] Cannot stringify value!");
|
||||
}
|
||||
const BASE64_PREFIX = "base64:";
|
||||
function serializeRaw(value) {
|
||||
if (typeof value === "string") {
|
||||
return value;
|
||||
}
|
||||
return BASE64_PREFIX + base64Encode(value);
|
||||
}
|
||||
function deserializeRaw(value) {
|
||||
if (typeof value !== "string") {
|
||||
return value;
|
||||
}
|
||||
if (!value.startsWith(BASE64_PREFIX)) {
|
||||
return value;
|
||||
}
|
||||
return base64Decode(value.slice(BASE64_PREFIX.length));
|
||||
}
|
||||
function base64Decode(input) {
|
||||
if (globalThis.Buffer) {
|
||||
return Buffer.from(input, "base64");
|
||||
}
|
||||
return Uint8Array.from(
|
||||
globalThis.atob(input),
|
||||
(c) => c.codePointAt(0)
|
||||
);
|
||||
}
|
||||
function base64Encode(input) {
|
||||
if (globalThis.Buffer) {
|
||||
return Buffer.from(input).toString("base64");
|
||||
}
|
||||
return globalThis.btoa(String.fromCodePoint(...input));
|
||||
}
|
||||
|
||||
const storageKeyProperties = [
|
||||
"has",
|
||||
"hasItem",
|
||||
"get",
|
||||
"getItem",
|
||||
"getItemRaw",
|
||||
"set",
|
||||
"setItem",
|
||||
"setItemRaw",
|
||||
"del",
|
||||
"remove",
|
||||
"removeItem",
|
||||
"getMeta",
|
||||
"setMeta",
|
||||
"removeMeta",
|
||||
"getKeys",
|
||||
"clear",
|
||||
"mount",
|
||||
"unmount"
|
||||
];
|
||||
function prefixStorage(storage, base) {
|
||||
base = normalizeBaseKey(base);
|
||||
if (!base) {
|
||||
return storage;
|
||||
}
|
||||
const nsStorage = { ...storage };
|
||||
for (const property of storageKeyProperties) {
|
||||
nsStorage[property] = (key = "", ...args) => (
|
||||
// @ts-ignore
|
||||
storage[property](base + key, ...args)
|
||||
);
|
||||
}
|
||||
nsStorage.getKeys = (key = "", ...arguments_) => storage.getKeys(base + key, ...arguments_).then((keys) => keys.map((key2) => key2.slice(base.length)));
|
||||
nsStorage.getItems = async (items, commonOptions) => {
|
||||
const prefixedItems = items.map(
|
||||
(item) => typeof item === "string" ? base + item : { ...item, key: base + item.key }
|
||||
);
|
||||
const results = await storage.getItems(prefixedItems, commonOptions);
|
||||
return results.map((entry) => ({
|
||||
key: entry.key.slice(base.length),
|
||||
value: entry.value
|
||||
}));
|
||||
};
|
||||
nsStorage.setItems = async (items, commonOptions) => {
|
||||
const prefixedItems = items.map((item) => ({
|
||||
key: base + item.key,
|
||||
value: item.value,
|
||||
options: item.options
|
||||
}));
|
||||
return storage.setItems(prefixedItems, commonOptions);
|
||||
};
|
||||
return nsStorage;
|
||||
}
|
||||
function normalizeKey(key) {
|
||||
if (!key) {
|
||||
return "";
|
||||
}
|
||||
return key.split("?")[0]?.replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") || "";
|
||||
}
|
||||
function joinKeys(...keys) {
|
||||
return normalizeKey(keys.join(":"));
|
||||
}
|
||||
function normalizeBaseKey(base) {
|
||||
base = normalizeKey(base);
|
||||
return base ? base + ":" : "";
|
||||
}
|
||||
function filterKeyByDepth(key, depth) {
|
||||
if (depth === void 0) {
|
||||
return true;
|
||||
}
|
||||
let substrCount = 0;
|
||||
let index = key.indexOf(":");
|
||||
while (index > -1) {
|
||||
substrCount++;
|
||||
index = key.indexOf(":", index + 1);
|
||||
}
|
||||
return substrCount <= depth;
|
||||
}
|
||||
function filterKeyByBase(key, base) {
|
||||
if (base) {
|
||||
return key.startsWith(base) && key[key.length - 1] !== "$";
|
||||
}
|
||||
return key[key.length - 1] !== "$";
|
||||
}
|
||||
|
||||
exports.asyncCall = asyncCall;
|
||||
exports.deserializeRaw = deserializeRaw;
|
||||
exports.filterKeyByBase = filterKeyByBase;
|
||||
exports.filterKeyByDepth = filterKeyByDepth;
|
||||
exports.joinKeys = joinKeys;
|
||||
exports.normalizeBaseKey = normalizeBaseKey;
|
||||
exports.normalizeKey = normalizeKey;
|
||||
exports.prefixStorage = prefixStorage;
|
||||
exports.serializeRaw = serializeRaw;
|
||||
exports.stringify = stringify;
|
Reference in New Issue
Block a user