{"version":3,"sources":["path.ts"],"sourcesContent":["// deno-lint-ignore-file no-namespace\nimport { client_type } from \"datex-core-legacy/utils/constants.ts\";\nimport { getCallerFile } from \"datex-core-legacy/utils/caller_metadata.ts\";\n\nconst relative = client_type === \"deno\" ? (await import(\"https://deno.land/std@0.172.0/path/mod.ts\")).relative : null;\n\n/**\n * @deprecated - Please use import from datex-core-legacy/utils/path.ts. Will get removed soon!\n */\nexport class Path<P extends Path.protocol = Path.protocol, IsDir extends boolean = boolean> extends URL {\n\n\tdeclare protocol: P\n\n\n\tconstructor(path:Path.representation = \"./\", base?:string|URL) {\n\t\tpath = Path.#formatPath(path, !base);\n\t\tif (!base && !Path.pathIsURL(path)) base = getCallerFile() // resolve path relative to caller file\n\t\tif (typeof base == \"string\" && base.match(/^\\w:(\\\\|\\/)/)) base = 'file:///' + base;\n\t\tsuper(path, base);\n\t}\n\n\t// convert to dir/ path\n\tstatic dir<P extends Path.protocol = Path.protocol>(path?:Path.representation, base?:Path<P, boolean>): Path<P, true>\n\tstatic dir(path?:Path.representation, base?:string|URL): Path<Path.protocol, true>\n\tstatic dir(path:Path.representation = \"./\", base?:string|URL) {\n\t\tpath = Path.#formatPath(path, !base);\n\t\tif (!base && !Path.pathIsURL(path)) base = getCallerFile() // resolve path relative to caller file\n\t\t\n\t\tif (!path.toString().endsWith(\"/\")) path = path.toString() + \"/\"; // make sure its a dir path\n\t\treturn new Path<Path.protocol, true>(path, base);\n\t}\n\n\t// convert to file/ path\n\tstatic file<P extends Path.protocol = Path.protocol>(path?:Path.representation, base?:Path<P, boolean>): Path<P, false>\n\tstatic file(path?:Path.representation, base?:string|URL): Path<Path.protocol, false>\n\tstatic file(path:Path.representation = \"./\", base?:string|URL) {\n\t\tpath = Path.#formatPath(path, !base);\n\t\tif (!base && !Path.pathIsURL(path)) base = getCallerFile() // resolve path relative to caller file\n\n\t\tif (path.toString().endsWith(\"/\")) path = path.toString().slice(0, -1); // make sure its a file path\n\t\treturn new Path<Path.protocol, false>(path, base);\n\t}\n\n\t// get path for current working directory\n\tstatic cwd(){\n\t\treturn new Path(client_type === \"deno\" ? Deno.cwd() : globalThis.location.href);\n\t}\n\n\t/**\n\t * returns true if the two routes are exactly equal\n\t * @param routeA\n\t * @param routeB \n\t */\n\tstatic routesAreEqual(routeA: Path.route_representation, routeB: Path.route_representation) {\n\t\trouteA = routeA instanceof Path ? routeA : Path.Route(routeA);\n\t\trouteB = routeB instanceof Path ? routeB : Path.Route(routeB);\n\t\t// check if all route sections are the same\n\t\treturn JSON.stringify(routeA.route) === JSON.stringify(routeB.route)\n\t}\n\n\t/**\n\t * @returns true if both paths are equal\n\t */\n\tstatic equals(a: URL, b: Path) {\n\t\treturn a.toString() === b.toString()\n\t}\n\n\t/**\n\t * converts Path.representation to URL for absolute paths, or string for relative paths\n\t * @param path \n\t * @returns \n\t */\n\tstatic #formatPath(path:Path.representation, abs_path_as_file_path = true) {\n\t\t// wIndoWs\n\t\tif (typeof path == \"string\" && path.match(/^\\w:(\\\\|\\/)/)) path = 'file:///' + path;\n\n\t\t// absolute url\n\t\tif (path instanceof URL) return path;\n\t\telse if (typeof path == \"string\" && path.match(/^[A-Za-z]+\\:/)) return new URL(path);\n\n\t\t// string, string []\n\t\tif (path instanceof Array) path = './'+path.join('/').replace(/^\\//,''); // join, make relative and remove duplicate / at beginning\n\t\t// for deno: absolute path becomes file path, not relative to origin\n\t\tif (abs_path_as_file_path && client_type === \"deno\") {\n\t\t\tif (typeof path == \"string\" && path.startsWith(\"/\")) path = new URL(Path.DEFAULT_PROTOCOL + (Path.ProtocolDefaultPrefixes[<keyof typeof Path.ProtocolDefaultPrefixes>Path.DEFAULT_PROTOCOL]??'') + path); // default to DEFAULT_PROTOCOL for absolute paths\n\t\t}\n\t\tif (typeof path == \"string\" && !(path.startsWith(\"/\") || path.startsWith(\"./\") || path.startsWith(\"../\"))) path = \"./\" + path // assume file relative path without ./\n\t\treturn path;\n\t}\n\t// returns true if the path is a URL or an url string\n\tstatic pathIsURL(path:string|URL) {\n\t\treturn path instanceof URL || path?.match(/^[A-Za-z0-9]+\\:/);\n\t}\n\n\n\t// returns true if protocol is http(s)\n\tget is_web() {\n\t\treturn this.protocol == <P>\"http:\" || this.protocol == <P>\"https:\"\n\t}\n\n\tisWeb(): this is Path<'https:'|'http:'> {\n\t\treturn this.protocol == <P>\"http:\" || this.protocol == <P>\"https:\"\n\t}\n\n\t// returns true if pathname ends with /\n\tget is_dir(): IsDir {\n\t\treturn <IsDir> this.pathname.endsWith(\"/\")\n\t}\n\n\tisDir(): this is Path<P, true> {\n\t\treturn this.pathname.endsWith(\"/\")\n\t}\n\n\t/**\n\t * get the root path (e.g. file://)\n\t */\n\tget root(){\n\t\treturn this.protocol + \"//\"\n\t}\n\n\t/**\n\t * is true if the path is an actual directory in the file system\n\t */\n\tget fs_is_dir() {\n\t\tif (this.is_web) return false;\n\t\tif (client_type !== \"deno\") throw new Error(\"filesystem operations not supported\");\n\t\tif (!this.fs_exists) return false;\n\t\treturn Deno.statSync(this.normal_pathname).isDirectory;\n\t}\n\n\t/**\n\t * returns true if the path is an actual directory in the file system\n\t */\n\tasync fsIsDir() {\n\t\tif (this.is_web) return false;\n\t\tif (client_type !== \"deno\") throw new Error(\"filesystem operations not supported\");\n\t\tif (!await this.fsExists()) return false;\n\t\treturn (await Deno.stat(this.normal_pathname)).isDirectory;\n\t}\n\n\t/**\n\t * path sections as array\n\t */\n\tget path(){\n\t\tconst path = this.pathname.slice(1).split(\"/\");\n\t\tif (path.at(-1) === \"\") path.pop();\n\t\treturn path\n\t}\n\n\t/**\n\t * route sections (path + hash) as array\n\t */\n\tget route(){\n\t\tconst route = this.routename.slice(1).split(\"/\");\n\t\tif (route.at(-1) === \"\") route.pop();\n\t\treturn route\n\t}\n\n\t/**\n\t * filename extracted from pathname\n\t */\n\tget filename() {\n\t\tif (this.is_dir) throw new Error(\"path is directory\");\n\t\tconst path = this.path\n\t\treturn path[path.length-1];\n\t}\n\n\t/**\n\t * directory name extracted from pathname\n\t */\n\tget dirname() {\n\t\tif (!this.is_dir) throw new Error(\"path is file\");\n\t\tconst path = this.path\n\t\treturn path[path.length-1];\n\t}\n\n\t/**\n\t * filename or directory name\n\t */\n\tget name(){\n\t\tif (this.is_dir) return this.dirname;\n\t\telse return this.filename\n\t}\n\n\t/**\n\t * full path + hash\n\t */\n\tget routename() {\n\t\treturn this.getRoutename(true)\n\t}\n\n\tgetRoutename(includeSearch = true) {\n\t\treturn this.pathname + (includeSearch ? this.search : \"\") + this.hash;\n\t}\n\n\t/**\n\t * the last extension (everything after the last '.')\n\t */\n\tget ext(){\n\t\treturn this.pathname.match(/\\.([^\\.\\/\\\\]+)$/)?.[1]\n\t}\n\n\t/**\n\t * an array of all extensions, sorted from last to first\n\t */\n\tget exts(){\n\t\treturn this.pathname.match(/(\\.([^\\.\\/\\\\]+))+$/)?.[0].split(\".\").slice(1).reverse()\n\t}\n\n\t/**\n\t * parent directory\n\t */\n\tget parent_dir(): Path {\n\t\treturn this.is_dir ? new Path('../', this) : new Path('./', this);\n\t}\n\n\t/**\n\t * get pathname for filesystems, not encoded for URLs\n\t * also handles windows absolute paths (e.g. C:/)\n\t */\n\tget normal_pathname() {\n\t\tconst path = decodeURIComponent(this.pathname);\n\t\tif (path.match(/^\\/.\\:\\//)) return path.slice(1)\n\t\treturn path\n\t}\n\n\t/**\n\t * is true if file/directory exists in filesystem\n\t */\n\tget fs_exists() {\n\t\tif (this.is_web) return false;\n\t\tif (client_type !== \"deno\") throw new Error(\"filesystem operations not supported\");\n\t\ttry {\n\t\t\tDeno.statSync(this.normal_pathname);\n\t\t\treturn true\n        } \n        catch {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * returns true if web path returns OK status\n\t * @returns \n\t */\n\tasync webExists() {\n\t\tif (!this.is_web) return false;\n\t\ttry {\n\t\t\treturn (await fetch(this)).ok\n        } \n        catch {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * return true if file/directory exists in filesystem\n\t */\n\tasync fsExists() {\n\t\tif (this.is_web) return false;\n\t\tif (client_type !== \"deno\") throw new Error(\"filesystem operations not supported\");\n\t\ttry {\n\t\t\tawait Deno.stat(this.normal_pathname);\n\t\t\treturn true\n\t\t} \n\t\tcatch {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * returns true if path exists on filesystem or web\n\t * @returns \n\t */\n\tasync exists() {\n\t\treturn await this.fsExists() || await this.webExists();\n\t}\n\n\t/**\n\t * Returns the path content as an ArrayBuffer.\n\t * Fetches from web if http[s]:// url, loads local file content (in deno), if file:// url\n\t */\n\tasync getContent() {\n\t\tif (this.is_web) {\n\t\t\treturn (await fetch(this)).arrayBuffer()\n\t\t}\n\t\telse {\n\t\t\treturn Deno.readFile(this.normal_pathname);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the path content as a string.\n\t * Fetches from web if http[s]:// url, loads local file content (in deno), if file:// url\n\t */\n\tasync getTextContent() {\n\t\tif (this.is_web) {\n\t\t\tconst res = await fetch(this);\n\t\t\tif (res.ok) return res.text()\n\t\t\telse throw res.text();\n\t\t}\n\t\telse {\n\t\t\treturn Deno.readTextFile(this.normal_pathname);\n\t\t}\n\t}\n\n\n\t/**\n\t * Returns the first extension from the given extensions that matches the current path\n\t * @param extensions list of file extensions (without a leading \".\")\n\t * @returns \n\t */\n\thasFileExtension(...extensions:string[]) {\n\t\tfor (const extension of extensions) {\n\t\t\tif (this.pathname.endsWith(\".\" + extension)) return extension;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Returns a new Path without the file extension\n\t * @param remove_all remove all extensions (e.g .tar.gz)\n\t * @returns \n\t */\n\tgetWithoutFileExtension(remove_all = false): Path<P, IsDir> {\n\t\tif (remove_all) return new Path(this.toString().replace(/(\\.[^\\.\\/\\\\]+)+$/, \"\"))\n\t\telse return new Path(this.toString().replace(/\\.[^\\.\\/\\\\]+$/, \"\"))\n\t}\n\n\t/**\n\t * Returns a new Path with a different file extension\n\t * @param ext the new file extension\n\t * @param replace_all replace  all extensions (e.g .tar.gz)\n\t * @returns \n\t */\n\tgetWithFileExtension(ext:string, replace_all = false): Path<P, IsDir> {\n\t\tif (this.ext) {\n\t\t\tif (replace_all) return new Path(this.toString().replace(/(\\.[^\\.\\/\\\\]+)+$/, \".\" + ext))\n\t\t\telse return new Path(this.toString().replace(/\\.[^\\.\\/\\\\]+$/, \".\" + ext))\n\t\t}\n\t\telse {\n\t\t\tif (this.is_dir) return new Path(this.toString().slice(0, -1) + \".\" + ext + \"/\");\n\t\t\telse return new Path(this.toString() + \".\" + ext);\n\t\t}\n\t}\n\n\t/**\n\t * Replaces a given file extension with a different extension and returns a new Path\n\t * @param prev\n\t * @param ext \n\t * @returns \n\t */\n\treplaceFileExtension(prev:string, ext:string): Path<P, IsDir> {\n\t\treturn new Path(this.toString().replace(new RegExp('\\\\.' + prev.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\") /* escape string for regex */ + '$'), \".\" + ext))\n\t}\n\n\t/**\n\t * Gets child path, existing hash is lost\n\t * throws an error if the current path is not a directory path\n\t * @param child child path representation (must be relative or Path with route protocol type)\n\t * @returns \n\t */\n\tgetChildPath(child: string|string[]|Path.Route):Path<P, boolean> {\n\t\tif (!this.is_dir) throw new Error(\"cannot get child path of non-directory path\");\n\t\t// make sure it is a relative path\n\t\tlet formatted_child = Path.#formatPath(child, false);\n\t\tif (typeof formatted_child == \"string\" && formatted_child.startsWith(\"/\")) formatted_child = formatted_child.slice(1);\n\t\t// invalid - child is absolute url\n\t\tif (formatted_child instanceof URL) {\n\t\t\tif (formatted_child.protocol === Path.RouteProtocol) formatted_child = \".\" + formatted_child.pathname + formatted_child.hash;\n\t\t\telse throw new Error(\"invalid child path: \" + child + \" - cannot be an absolute URL\");\n\t\t} \n\t\treturn new Path(formatted_child, this);\n\t}\n\n\t/**\n\t * Gets child route, keep hash routes\n\t * @param child child route\n\t */\n\tgetChildRoute(child: string|string[]|Path.Route) {\n\t\tlet formatted_child = Path.#formatPath(child, false);\n\t\t// invalid - child is absolute url\n\t\tif (formatted_child instanceof URL) {\n\t\t\tif (formatted_child.protocol === Path.RouteProtocol) formatted_child = formatted_child.pathname + formatted_child.hash;\n\t\t\telse throw new Error(\"invalid child path: \" + child + \" - cannot be an absolute URL\");\n\t\t} \n\t\tlet current_path = this.toString();\n\t\tif (!current_path.endsWith(\"/\")) current_path += \"/\";\n\t\tif (formatted_child.startsWith(\"/\")) formatted_child = formatted_child.slice(1);\n\t\telse if (formatted_child.startsWith(\"./\")) formatted_child = formatted_child.slice(2);\n\t\telse if (formatted_child.startsWith(\"../\")) throw new Error(\"cannot resolve child route \" + formatted_child);\n\n\t\treturn new Path(current_path + formatted_child);\n\t}\n\n\tgetWithChangedParent<P extends Path.protocol>(from:string|URL, to:Path<P>): Path<P, IsDir>\n\tgetWithChangedParent(from:string|URL, to:string|URL): Path<Path.protocol, IsDir>\n\tgetWithChangedParent(from:string|URL, to:string|URL) {\n\t\tconst from_path = new Path(from);\n\t\tconst to_path = new Path(to);\n\t\treturn new Path(this.toString().replace(from_path.toString(), to_path.toString()))\n\t}\n\n\tgetAsRelativeFrom(path:string|URL) {\n\t\tlet _path = new Path(path);\n\t\tif (!_path.is_dir) _path = _path.parent_dir;\n\n\t\tif (!relative) throw new Error(\"relative path utils only supported in deno\")\n\t\tlet rel = relative(_path.pathname, this.pathname);\n\t\tif (!(rel.startsWith(\"./\") || rel.startsWith(\"../\"))) rel = \"./\" + rel;\n\t\tif (rel.startsWith(\"./../\")) rel = rel.replace(\"./../\", \"../\")\n\t\tif (rel.startsWith(\"./..\\\\\")) rel = rel.replace(\"./..\\\\\", \"../\")\n\t\tif (this.is_dir && !rel.endsWith(\"/\")) rel += \"/\";\n\n\t\t// re-add query params\n\t\tif (this.search) rel += this.search;\n\t\t\n\t\treturn rel;\n\t}\n\n\tasDir(): Path<P, true> {\n\t\treturn Path.dir(this);\n\t}\n\n\t// convert to dir if fs dir, otherwise file\n\tasFSPath(): Path<P, boolean> {\n\t\tif (this.fs_is_dir) return Path.dir(this);\n\t\telse return Path.file(this);\n\t}\n\n\tisChildOf (parent_path:string|URL) {\n\t\tparent_path = new Path(parent_path);\n\t\treturn this.parent_dir.toString().startsWith(parent_path.toString())\n\t}\n\n\t// filesystem utils - create dir\n\tfsCreateIfNotExists(){\n\t\tif (client_type !== \"deno\") throw new Error(\"filesystem operations not supported\");\n\t\tif (!this.is_dir) throw new Error(\"cannot create directory for non-directory path\");\n\n\t\ttry {\n\t\t\tDeno.statSync(this)\n\t\t}\n\t\tcatch {\n\t\t\tDeno.mkdirSync(this, {recursive: true});\n\t\t}\n\t\treturn this;\n\t}\n\n}\n\nexport namespace Path {\n\n\texport type representation = string|string[]|URL;\n\texport type route_representation = string[]|Path.Route;\n\n\texport type protocol = `${string}:`\n\n\texport enum Protocol {\n\t\tHTTP = 'http:',\n\t\tHTTPS = 'https:',\n\t\tFile = 'file:',\n\t}\n\n\texport const DEFAULT_PROTOCOL:Path.protocol = Protocol.File;\n\n\texport const ProtocolDefaultPrefixes = {\n\t\t[Protocol.HTTP]: '//unknown',\n\t\t[Protocol.HTTPS]: '//unknown',\n\t\t[Protocol.File]: '//',\n\t} as const\n\n\texport const RouteProtocol = 'route:' satisfies protocol;\n\n\tfunction getPathWithProtocol<T extends protocol>(path: representation|undefined, protocol: T) {\n\t\t// change protocol\n\t\tif ((path instanceof URL || typeof path == \"string\") && Path.pathIsURL(path) && !path.toString().startsWith(protocol)) {\n\t\t\tpath = new Path(path.toString()).routename;\n\t\t}\n\t\treturn new Path<T>(path, protocol + (ProtocolDefaultPrefixes[<keyof typeof ProtocolDefaultPrefixes>protocol]??'/'))\n\t}\n\n\texport function HTTP(path?: representation) {\n\t\t// relative path\n\t\tif (typeof path == \"string\" && !path.startsWith(\"/\")) path = new Path(path, getCallerFile())\n\t\treturn getPathWithProtocol(path, Protocol.HTTP)\n\t}\n\texport function HTTPS(path?: representation) {\n\t\t// relative path\n\t\tif (typeof path == \"string\" && !path.startsWith(\"/\")) path = new Path(path, getCallerFile())\n\t\treturn getPathWithProtocol(path, Protocol.HTTPS)\n\t}\n\texport function File(path?: representation) {\n\t\t// relative path\n\t\tif (typeof path == \"string\" && !path.startsWith(\"/\")) path = new Path(path, getCallerFile())\n\t\treturn getPathWithProtocol(path, Protocol.File)\n\t}\n\texport function Route(path?: representation) {\n\t\treturn getPathWithProtocol(path, RouteProtocol)\n\t}\n\n\texport type HTTP = ReturnType<typeof HTTP>\n\texport type HTTPS = ReturnType<typeof HTTPS>\n\texport type File = ReturnType<typeof File>\n\texport type Route = ReturnType<typeof Route>\n\n}"],"names":["client_type","getCallerFile","relative","Path","URL","constructor","path","base","pathIsURL","match","dir","toString","endsWith","file","slice","cwd","Deno","globalThis","location","href","routesAreEqual","routeA","routeB","Route","JSON","stringify","route","equals","a","b","abs_path_as_file_path","Array","join","replace","startsWith","DEFAULT_PROTOCOL","ProtocolDefaultPrefixes","is_web","protocol","isWeb","is_dir","pathname","isDir","root","fs_is_dir","Error","fs_exists","statSync","normal_pathname","isDirectory","fsIsDir","fsExists","stat","split","at","pop","routename","filename","length","dirname","name","getRoutename","includeSearch","search","hash","ext","exts","reverse","parent_dir","decodeURIComponent","webExists","fetch","ok","exists","getContent","arrayBuffer","readFile","getTextContent","readTextFile","res","text","hasFileExtension","extensions","extension","getWithoutFileExtension","remove_all","getWithFileExtension","replace_all","replaceFileExtension","prev","RegExp","getChildPath","child","formatted_child","RouteProtocol","getChildRoute","current_path","getWithChangedParent","from","to","from_path","to_path","getAsRelativeFrom","_path","rel","asDir","asFSPath","isChildOf","parent_path","fsCreateIfNotExists","mkdirSync","recursive","Protocol","getPathWithProtocol","HTTP","HTTPS","File"],"mappings":"AACA,SAASA,WAAW,QAAQ,uCAAuC;AACnE,SAASC,aAAa,QAAQ,6CAA6C;AAE3E,IAAMC,WAAWF,AAAgB,WAAhBA,cAAyB,AAAC,CAAA,MAAM,MAAM,CAAC,4CAA2C,EAAGE,QAAQ,GAAG;AAKjH,OAAO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