UNPKG

@modern-js/utils

Version:

A Progressive React Framework for modern web development.

112 lines (111 loc) 4.61 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.n = (module)=>{ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module; __webpack_require__.d(getter, { a: getter }); return getter; }; })(); (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { formatImportPath: ()=>formatImportPath, getRealTemporaryDirectory: ()=>getRealTemporaryDirectory, getTemplatePath: ()=>getTemplatePath, isPathString: ()=>isPathString, isRelativePath: ()=>isRelativePath, normalizeOutputPath: ()=>normalizeOutputPath, normalizeToPosixPath: ()=>normalizeToPosixPath, removeLeadingSlash: ()=>removeLeadingSlash, removeSlash: ()=>removeSlash, removeTailSlash: ()=>removeTailSlash, splitPathString: ()=>splitPathString }); const external_fs_namespaceObject = require("fs"); var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject); const external_os_namespaceObject = require("os"); var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject); const external_path_namespaceObject = require("path"); var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject); const external_compiled_js_namespaceObject = require("../compiled.js"); const isPathString = (test)=>external_path_default().posix.basename(test) !== test || external_path_default().win32.basename(test) !== test; const isRelativePath = (test)=>/^\.\.?($|[\\/])/.test(test); const normalizeOutputPath = (s)=>s.replace(/\\/g, '\\\\'); const normalizeToPosixPath = (p)=>external_compiled_js_namespaceObject.upath.normalizeSafe(external_path_default().normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`); const getTemplatePath = (prefix)=>{ const tmpRoot = external_fs_default().realpathSync(external_os_default().tmpdir()); const parts = [ tmpRoot ]; prefix && parts.push(prefix); parts.push((0, external_compiled_js_namespaceObject.nanoid)()); return external_path_default().resolve(...parts); }; function getRealTemporaryDirectory() { let ret = null; try { ret = external_os_default().tmpdir(); ret = external_fs_default().realpathSync(ret); } catch {} return ret; } function splitPathString(str) { return str.split(/[\\/]/); } const removeLeadingSlash = (s)=>s.replace(/^\/+/, ''); const removeTailSlash = (s)=>s.replace(/\/+$/, ''); const removeSlash = (s)=>removeLeadingSlash(removeTailSlash(s)); function formatImportPath(str) { return str.replace(/\\/g, '/'); } exports.formatImportPath = __webpack_exports__.formatImportPath; exports.getRealTemporaryDirectory = __webpack_exports__.getRealTemporaryDirectory; exports.getTemplatePath = __webpack_exports__.getTemplatePath; exports.isPathString = __webpack_exports__.isPathString; exports.isRelativePath = __webpack_exports__.isRelativePath; exports.normalizeOutputPath = __webpack_exports__.normalizeOutputPath; exports.normalizeToPosixPath = __webpack_exports__.normalizeToPosixPath; exports.removeLeadingSlash = __webpack_exports__.removeLeadingSlash; exports.removeSlash = __webpack_exports__.removeSlash; exports.removeTailSlash = __webpack_exports__.removeTailSlash; exports.splitPathString = __webpack_exports__.splitPathString; for(var __rspack_i in __webpack_exports__)if (-1 === [ "formatImportPath", "getRealTemporaryDirectory", "getTemplatePath", "isPathString", "isRelativePath", "normalizeOutputPath", "normalizeToPosixPath", "removeLeadingSlash", "removeSlash", "removeTailSlash", "splitPathString" ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i]; Object.defineProperty(exports, '__esModule', { value: true });