UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

221 lines (216 loc) • 6.88 kB
import CJS_COMPAT_NODE_URL_q99y7iqlbzn from 'node:url'; import CJS_COMPAT_NODE_PATH_q99y7iqlbzn from 'node:path'; import CJS_COMPAT_NODE_MODULE_q99y7iqlbzn from "node:module"; var __filename = CJS_COMPAT_NODE_URL_q99y7iqlbzn.fileURLToPath(import.meta.url); var __dirname = CJS_COMPAT_NODE_PATH_q99y7iqlbzn.dirname(__filename); var require = CJS_COMPAT_NODE_MODULE_q99y7iqlbzn.createRequire(import.meta.url); // ------------------------------------------------------------ // end of CJS compatibility banner, injected by Storybook's esbuild configuration // ------------------------------------------------------------ import { __name } from "./chunk-MB5KTO7X.js"; // ../node_modules/pathe/dist/shared/pathe.ff20891b.mjs var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//; function normalizeWindowsPath(input = "") { if (!input) { return input; } return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase()); } __name(normalizeWindowsPath, "normalizeWindowsPath"); var _UNC_REGEX = /^[/\\]{2}/; var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/; var _DRIVE_LETTER_RE = /^[A-Za-z]:$/; var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/; var normalize = /* @__PURE__ */ __name(function(path2) { if (path2.length === 0) { return "."; } path2 = normalizeWindowsPath(path2); const isUNCPath = path2.match(_UNC_REGEX); const isPathAbsolute = isAbsolute(path2); const trailingSeparator = path2[path2.length - 1] === "/"; path2 = normalizeString(path2, !isPathAbsolute); if (path2.length === 0) { if (isPathAbsolute) { return "/"; } return trailingSeparator ? "./" : "."; } if (trailingSeparator) { path2 += "/"; } if (_DRIVE_LETTER_RE.test(path2)) { path2 += "/"; } if (isUNCPath) { if (!isPathAbsolute) { return `//./${path2}`; } return `//${path2}`; } return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2; }, "normalize"); var join = /* @__PURE__ */ __name(function(...arguments_) { if (arguments_.length === 0) { return "."; } let joined; for (const argument of arguments_) { if (argument && argument.length > 0) { if (joined === void 0) { joined = argument; } else { joined += `/${argument}`; } } } if (joined === void 0) { return "."; } return normalize(joined.replace(/\/\/+/g, "/")); }, "join"); function cwd() { if (typeof process !== "undefined" && typeof process.cwd === "function") { return process.cwd().replace(/\\/g, "/"); } return "/"; } __name(cwd, "cwd"); var resolve = /* @__PURE__ */ __name(function(...arguments_) { arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument)); let resolvedPath = ""; let resolvedAbsolute = false; for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) { const path2 = index >= 0 ? arguments_[index] : cwd(); if (!path2 || path2.length === 0) { continue; } resolvedPath = `${path2}/${resolvedPath}`; resolvedAbsolute = isAbsolute(path2); } resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute); if (resolvedAbsolute && !isAbsolute(resolvedPath)) { return `/${resolvedPath}`; } return resolvedPath.length > 0 ? resolvedPath : "."; }, "resolve"); function normalizeString(path2, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; let lastSlash = -1; let dots = 0; let char = null; for (let index = 0; index <= path2.length; ++index) { if (index < path2.length) { char = path2[index]; } else if (char === "/") { break; } else { char = "/"; } if (char === "/") { if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) { if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") { if (res.length > 2) { const lastSlashIndex = res.lastIndexOf("/"); if (lastSlashIndex === -1) { res = ""; lastSegmentLength = 0; } else { res = res.slice(0, lastSlashIndex); lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); } lastSlash = index; dots = 0; continue; } else if (res.length > 0) { res = ""; lastSegmentLength = 0; lastSlash = index; dots = 0; continue; } } if (allowAboveRoot) { res += res.length > 0 ? "/.." : ".."; lastSegmentLength = 2; } } else { if (res.length > 0) { res += `/${path2.slice(lastSlash + 1, index)}`; } else { res = path2.slice(lastSlash + 1, index); } lastSegmentLength = index - lastSlash - 1; } lastSlash = index; dots = 0; } else if (char === "." && dots !== -1) { ++dots; } else { dots = -1; } } return res; } __name(normalizeString, "normalizeString"); var isAbsolute = /* @__PURE__ */ __name(function(p) { return _IS_ABSOLUTE_RE.test(p); }, "isAbsolute"); var _EXTNAME_RE = /.(\.[^./]+)$/; var extname = /* @__PURE__ */ __name(function(p) { const match = _EXTNAME_RE.exec(normalizeWindowsPath(p)); return match && match[1] || ""; }, "extname"); var relative = /* @__PURE__ */ __name(function(from, to) { const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/"); const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/"); if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) { return _to.join("/"); } const _fromCopy = [..._from]; for (const segment of _fromCopy) { if (_to[0] !== segment) { break; } _from.shift(); _to.shift(); } return [..._from.map(() => ".."), ..._to].join("/"); }, "relative"); var dirname = /* @__PURE__ */ __name(function(p) { const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1); if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) { segments[0] += "/"; } return segments.join("/") || (isAbsolute(p) ? "/" : "."); }, "dirname"); var basename = /* @__PURE__ */ __name(function(p, extension) { const lastSegment = normalizeWindowsPath(p).split("/").pop(); return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment; }, "basename"); var parse = /* @__PURE__ */ __name(function(p) { const root = normalizeWindowsPath(p).split("/").shift() || "/"; const base = basename(p); const extension = extname(base); return { root, dir: dirname(p), base, ext: extension, name: base.slice(0, base.length - extension.length) }; }, "parse"); export { normalize, join, resolve, isAbsolute, relative, dirname, basename, parse };