full site update
This commit is contained in:
31
node_modules/unstorage/drivers/utils/cloudflare.cjs
generated
vendored
Normal file
31
node_modules/unstorage/drivers/utils/cloudflare.cjs
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getBinding = getBinding;
|
||||
exports.getKVBinding = getKVBinding;
|
||||
exports.getR2Binding = getR2Binding;
|
||||
var _index = require("./index.cjs");
|
||||
function getBinding(binding) {
|
||||
let bindingName = "[binding]";
|
||||
if (typeof binding === "string") {
|
||||
bindingName = binding;
|
||||
binding = globalThis[bindingName] || globalThis.__env__?.[bindingName];
|
||||
}
|
||||
if (!binding) {
|
||||
throw (0, _index.createError)("cloudflare", `Invalid binding \`${bindingName}\`: \`${binding}\``);
|
||||
}
|
||||
for (const key of ["get", "put", "delete"]) {
|
||||
if (!(key in binding)) {
|
||||
throw (0, _index.createError)("cloudflare", `Invalid binding \`${bindingName}\`: \`${key}\` key is missing`);
|
||||
}
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
function getKVBinding(binding = "STORAGE") {
|
||||
return getBinding(binding);
|
||||
}
|
||||
function getR2Binding(binding = "BUCKET") {
|
||||
return getBinding(binding);
|
||||
}
|
3
node_modules/unstorage/drivers/utils/cloudflare.d.ts
generated
vendored
Normal file
3
node_modules/unstorage/drivers/utils/cloudflare.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare function getBinding(binding: KVNamespace | R2Bucket | string): KVNamespace<string> | R2Bucket;
|
||||
export declare function getKVBinding(binding?: KVNamespace | string): KVNamespace;
|
||||
export declare function getR2Binding(binding?: R2Bucket | string): R2Bucket;
|
29
node_modules/unstorage/drivers/utils/cloudflare.mjs
generated
vendored
Normal file
29
node_modules/unstorage/drivers/utils/cloudflare.mjs
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createError } from "./index.mjs";
|
||||
export function getBinding(binding) {
|
||||
let bindingName = "[binding]";
|
||||
if (typeof binding === "string") {
|
||||
bindingName = binding;
|
||||
binding = globalThis[bindingName] || globalThis.__env__?.[bindingName];
|
||||
}
|
||||
if (!binding) {
|
||||
throw createError(
|
||||
"cloudflare",
|
||||
`Invalid binding \`${bindingName}\`: \`${binding}\``
|
||||
);
|
||||
}
|
||||
for (const key of ["get", "put", "delete"]) {
|
||||
if (!(key in binding)) {
|
||||
throw createError(
|
||||
"cloudflare",
|
||||
`Invalid binding \`${bindingName}\`: \`${key}\` key is missing`
|
||||
);
|
||||
}
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
export function getKVBinding(binding = "STORAGE") {
|
||||
return getBinding(binding);
|
||||
}
|
||||
export function getR2Binding(binding = "BUCKET") {
|
||||
return getBinding(binding);
|
||||
}
|
35
node_modules/unstorage/drivers/utils/index.cjs
generated
vendored
Normal file
35
node_modules/unstorage/drivers/utils/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createError = createError;
|
||||
exports.createRequiredError = createRequiredError;
|
||||
exports.defineDriver = defineDriver;
|
||||
exports.joinKeys = joinKeys;
|
||||
exports.normalizeKey = normalizeKey;
|
||||
function defineDriver(factory) {
|
||||
return factory;
|
||||
}
|
||||
function normalizeKey(key, sep = ":") {
|
||||
if (!key) {
|
||||
return "";
|
||||
}
|
||||
return key.replace(/[:/\\]/g, sep).replace(/^[:/\\]|[:/\\]$/g, "");
|
||||
}
|
||||
function joinKeys(...keys) {
|
||||
return keys.map(key => normalizeKey(key)).filter(Boolean).join(":");
|
||||
}
|
||||
function createError(driver, message, opts) {
|
||||
const err = new Error(`[unstorage] [${driver}] ${message}`, opts);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(err, createError);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
function createRequiredError(driver, name) {
|
||||
if (Array.isArray(name)) {
|
||||
return createError(driver, `Missing some of the required options ${name.map(n => "`" + n + "`").join(", ")}`);
|
||||
}
|
||||
return createError(driver, `Missing required option \`${name}\`.`);
|
||||
}
|
10
node_modules/unstorage/drivers/utils/index.d.ts
generated
vendored
Normal file
10
node_modules/unstorage/drivers/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Driver } from "../..";
|
||||
type DriverFactory<OptionsT, InstanceT> = (opts: OptionsT) => Driver<OptionsT, InstanceT>;
|
||||
interface ErrorOptions {
|
||||
}
|
||||
export declare function defineDriver<OptionsT = any, InstanceT = never>(factory: DriverFactory<OptionsT, InstanceT>): DriverFactory<OptionsT, InstanceT>;
|
||||
export declare function normalizeKey(key: string | undefined, sep?: ":" | "/"): string;
|
||||
export declare function joinKeys(...keys: string[]): string;
|
||||
export declare function createError(driver: string, message: string, opts?: ErrorOptions): Error;
|
||||
export declare function createRequiredError(driver: string, name: string | string[]): Error;
|
||||
export {};
|
28
node_modules/unstorage/drivers/utils/index.mjs
generated
vendored
Normal file
28
node_modules/unstorage/drivers/utils/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
export function defineDriver(factory) {
|
||||
return factory;
|
||||
}
|
||||
export function normalizeKey(key, sep = ":") {
|
||||
if (!key) {
|
||||
return "";
|
||||
}
|
||||
return key.replace(/[:/\\]/g, sep).replace(/^[:/\\]|[:/\\]$/g, "");
|
||||
}
|
||||
export function joinKeys(...keys) {
|
||||
return keys.map((key) => normalizeKey(key)).filter(Boolean).join(":");
|
||||
}
|
||||
export function createError(driver, message, opts) {
|
||||
const err = new Error(`[unstorage] [${driver}] ${message}`, opts);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(err, createError);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
export function createRequiredError(driver, name) {
|
||||
if (Array.isArray(name)) {
|
||||
return createError(
|
||||
driver,
|
||||
`Missing some of the required options ${name.map((n) => "`" + n + "`").join(", ")}`
|
||||
);
|
||||
}
|
||||
return createError(driver, `Missing required option \`${name}\`.`);
|
||||
}
|
78
node_modules/unstorage/drivers/utils/node-fs.cjs
generated
vendored
Normal file
78
node_modules/unstorage/drivers/utils/node-fs.cjs
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ensuredir = ensuredir;
|
||||
exports.readFile = readFile;
|
||||
exports.readdir = readdir;
|
||||
exports.readdirRecursive = readdirRecursive;
|
||||
exports.rmRecursive = rmRecursive;
|
||||
exports.stat = stat;
|
||||
exports.unlink = unlink;
|
||||
exports.writeFile = writeFile;
|
||||
var _nodeFs = require("node:fs");
|
||||
var _nodePath = require("node:path");
|
||||
function ignoreNotfound(err) {
|
||||
return err.code === "ENOENT" || err.code === "EISDIR" ? null : err;
|
||||
}
|
||||
function ignoreExists(err) {
|
||||
return err.code === "EEXIST" ? null : err;
|
||||
}
|
||||
async function writeFile(path, data, encoding) {
|
||||
await ensuredir((0, _nodePath.dirname)(path));
|
||||
return _nodeFs.promises.writeFile(path, data, encoding);
|
||||
}
|
||||
function readFile(path, encoding) {
|
||||
return _nodeFs.promises.readFile(path, encoding).catch(ignoreNotfound);
|
||||
}
|
||||
function stat(path) {
|
||||
return _nodeFs.promises.stat(path).catch(ignoreNotfound);
|
||||
}
|
||||
function unlink(path) {
|
||||
return _nodeFs.promises.unlink(path).catch(ignoreNotfound);
|
||||
}
|
||||
function readdir(dir) {
|
||||
return _nodeFs.promises.readdir(dir, {
|
||||
withFileTypes: true
|
||||
}).catch(ignoreNotfound).then(r => r || []);
|
||||
}
|
||||
async function ensuredir(dir) {
|
||||
if ((0, _nodeFs.existsSync)(dir)) {
|
||||
return;
|
||||
}
|
||||
await ensuredir((0, _nodePath.dirname)(dir)).catch(ignoreExists);
|
||||
await _nodeFs.promises.mkdir(dir).catch(ignoreExists);
|
||||
}
|
||||
async function readdirRecursive(dir, ignore, maxDepth) {
|
||||
if (ignore && ignore(dir)) {
|
||||
return [];
|
||||
}
|
||||
const entries = await readdir(dir);
|
||||
const files = [];
|
||||
await Promise.all(entries.map(async entry => {
|
||||
const entryPath = (0, _nodePath.resolve)(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (maxDepth === void 0 || maxDepth > 0) {
|
||||
const dirFiles = await readdirRecursive(entryPath, ignore, maxDepth === void 0 ? void 0 : maxDepth - 1);
|
||||
files.push(...dirFiles.map(f => entry.name + "/" + f));
|
||||
}
|
||||
} else {
|
||||
if (!(ignore && ignore(entry.name))) {
|
||||
files.push(entry.name);
|
||||
}
|
||||
}
|
||||
}));
|
||||
return files;
|
||||
}
|
||||
async function rmRecursive(dir) {
|
||||
const entries = await readdir(dir);
|
||||
await Promise.all(entries.map(entry => {
|
||||
const entryPath = (0, _nodePath.resolve)(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
return rmRecursive(entryPath).then(() => _nodeFs.promises.rmdir(entryPath));
|
||||
} else {
|
||||
return _nodeFs.promises.unlink(entryPath);
|
||||
}
|
||||
}));
|
||||
}
|
11
node_modules/unstorage/drivers/utils/node-fs.d.ts
generated
vendored
Normal file
11
node_modules/unstorage/drivers/utils/node-fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Dirent, promises as fsPromises } from "node:fs";
|
||||
type WriteFileData = Parameters<typeof fsPromises.writeFile>[1];
|
||||
export declare function writeFile(path: string, data: WriteFileData, encoding?: BufferEncoding): Promise<void>;
|
||||
export declare function readFile(path: string, encoding?: BufferEncoding): Promise<any>;
|
||||
export declare function stat(path: string): Promise<any>;
|
||||
export declare function unlink(path: string): Promise<any>;
|
||||
export declare function readdir(dir: string): Promise<Dirent[]>;
|
||||
export declare function ensuredir(dir: string): Promise<void>;
|
||||
export declare function readdirRecursive(dir: string, ignore?: (p: string) => boolean, maxDepth?: number): Promise<string[]>;
|
||||
export declare function rmRecursive(dir: string): Promise<void>;
|
||||
export {};
|
71
node_modules/unstorage/drivers/utils/node-fs.mjs
generated
vendored
Normal file
71
node_modules/unstorage/drivers/utils/node-fs.mjs
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { existsSync, promises as fsPromises } from "node:fs";
|
||||
import { resolve, dirname } from "node:path";
|
||||
function ignoreNotfound(err) {
|
||||
return err.code === "ENOENT" || err.code === "EISDIR" ? null : err;
|
||||
}
|
||||
function ignoreExists(err) {
|
||||
return err.code === "EEXIST" ? null : err;
|
||||
}
|
||||
export async function writeFile(path, data, encoding) {
|
||||
await ensuredir(dirname(path));
|
||||
return fsPromises.writeFile(path, data, encoding);
|
||||
}
|
||||
export function readFile(path, encoding) {
|
||||
return fsPromises.readFile(path, encoding).catch(ignoreNotfound);
|
||||
}
|
||||
export function stat(path) {
|
||||
return fsPromises.stat(path).catch(ignoreNotfound);
|
||||
}
|
||||
export function unlink(path) {
|
||||
return fsPromises.unlink(path).catch(ignoreNotfound);
|
||||
}
|
||||
export function readdir(dir) {
|
||||
return fsPromises.readdir(dir, { withFileTypes: true }).catch(ignoreNotfound).then((r) => r || []);
|
||||
}
|
||||
export async function ensuredir(dir) {
|
||||
if (existsSync(dir)) {
|
||||
return;
|
||||
}
|
||||
await ensuredir(dirname(dir)).catch(ignoreExists);
|
||||
await fsPromises.mkdir(dir).catch(ignoreExists);
|
||||
}
|
||||
export async function readdirRecursive(dir, ignore, maxDepth) {
|
||||
if (ignore && ignore(dir)) {
|
||||
return [];
|
||||
}
|
||||
const entries = await readdir(dir);
|
||||
const files = [];
|
||||
await Promise.all(
|
||||
entries.map(async (entry) => {
|
||||
const entryPath = resolve(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (maxDepth === void 0 || maxDepth > 0) {
|
||||
const dirFiles = await readdirRecursive(
|
||||
entryPath,
|
||||
ignore,
|
||||
maxDepth === void 0 ? void 0 : maxDepth - 1
|
||||
);
|
||||
files.push(...dirFiles.map((f) => entry.name + "/" + f));
|
||||
}
|
||||
} else {
|
||||
if (!(ignore && ignore(entry.name))) {
|
||||
files.push(entry.name);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
return files;
|
||||
}
|
||||
export async function rmRecursive(dir) {
|
||||
const entries = await readdir(dir);
|
||||
await Promise.all(
|
||||
entries.map((entry) => {
|
||||
const entryPath = resolve(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
return rmRecursive(entryPath).then(() => fsPromises.rmdir(entryPath));
|
||||
} else {
|
||||
return fsPromises.unlink(entryPath);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user