/** * get current working directory * @method cwd()string */ export declare const cwd: () => string; /** * convert to classic path, for: file:///d:/test/path.js => d:\test\path.js * @method classicPath(path:string)string */ export declare const classicPath: (url: string) => string; /** * path delimiter * @const delimiter:string */ export declare const delimiter: string; /** * normalizePath * @member normalizePath(path:string,retainUp?:boolean)string */ export declare function normalizePath(path: string, retainUp?: boolean): string; /** * file:///home/louis/test.txt * file:///d:/home/louis/test.txt * http://google.com/test.txt * return format path * @method resolve(path:string,partPath?string)string */ export declare function resolve(...args: string[]): string; /** * Is it an absolute path? */ export declare function isAbsolute(path: string): boolean; /** * Is it a local path? */ export declare function isLocal(path: string): boolean; export declare function isLocalZip(path: string): boolean; export declare function isHttp(path: string): boolean; /** * @class URL * * URL Processing Tool Type * * @example * * ```ts * // cwd: file:///var/data * // Prints: file:///var/data/index.js * var uri = new URL('index.js'); * console.log(uri.href); * // Prints: http://quarks.cc/index.html?args=0 * var uri2 = new URL('http://quarks.cc/home/../index.html?args=0') * console.log(uri2.href); * // Prints: * // Error: Parse uri error, Illegal URL * new URL('http://quarks.cc:').href * ``` */ export declare class URL { private _value; private _origin; private _filename; private _dirname; private _basename; private _extname; private _search; private _hash; private _hostname; private _port; private _protocol; private _params; private _hashParams; /** * @method constructor(path?:string) */ constructor(path?: string); /** * Get the complete URL, including parameters * * href: "http://xxxx.xxx:81/v1.1.0/quark/path.js?sasasas&asasasa#sdsdsd" * * @example * * ```ts * // Prints: http://quarks.cc/ * console.log(new URL('http://quarks.cc/').href); * ``` */ get href(): string; /** * Get full path name * * filename: "/D:/Documents/test.js" * * @example * * ```ts * // Prints: /aaa/bbbb/ccc/test.js * console.log(new URL('http://quarks.cc/aaa/bbbb/ccc/test.js').filename); * // Prints: /D:/Documents/test.js * console.log(new URL('file:///D:/Documents/test.js').filename); * ``` */ get filename(): string; /** * @get path:string /a/b/s/test.html?aaaaa=100 * * Get the path and include the parameter part * * @example * * ```ts * // Prints: /aaa/bbbb/ccc/test.js?asas=asas * console.log(new URL('http://quarks.cc/aaa/bbbb/ccc/test.js?asas=asas').path); * ``` */ get path(): string; /** * Full path dir * * dirname: "/D:/Documents" * * @example * * ```ts * // Prints: /aaa/bbbb/ccc * console.log(new URL('http://quarks.cc/aaa/bbbb/ccc/test.js').dirname); * ``` */ get dirname(): string; /** * Get url query parameters * * search: "?sasasas&asasasa" * * @example * * ```ts * // Prints: ?a=A&b=B * console.log(new URL('http://quarks.cc/?a=A&b=B').search); * ``` */ get search(): string; /** * hash: "#sdsdsd" * * Get hash parameters * * @example * * ```ts * // Prints: #c=C&d=D * console.log(new URL('http://quarks.cc/?a=A&b=B#c=C&d=D').hash); * ``` */ get hash(): string; /** * host: "quarks.cc:81" * * Gets the host name and returns the host name with the port number * * @example * * ```ts * // Prints: quarks.cc:80 * console.log(new URL('http://quarks.cc:81/').host); * ``` */ get host(): string; /** * hostname: "quarks.cc" * * Gets the host name, but does not return the port number * * @example * * ```ts * // Prints: quarks.cc * console.log(new URL('http://quarks.cc:81/').host); * ``` */ get hostname(): string; /** * origin: "http://quarks.cc:81" * * Get the uri origin, protocol+host * * @example * * ```ts * // Prints: http://quarks.cc:81 * console.log(new URL('http://quarks.cc:81/host/index.html').host); * // Prints: file:// * console.log(new URL('file:///var/data/index.html').host); * ``` */ get origin(): string; /** * Get path base name * * @example * * ```ts * // Prints: index.html * console.log(new URL('file:///var/data/index.html').basename); * ``` */ get basename(): string; /** * Get path extname * * @example * * ```ts * // Prints: .html * console.log(new URL('file:///var/data/index.html').extname); * ``` */ get extname(): string; /** * port: "81" * * Get the host port number. * If the port number is not defined in the URL, an empty string is returned. * * @example * * ```ts * // Prints: 81 * console.log(new URL('http://quarks.cc:81').port); * // Prints If there is no port number, an empty string will be returned: "" * console.log(new URL('http://quarks.cc').port); * ``` */ get port(): string; /** * Get the protocol type string of the URL, For: `'http:'`|`'https'`|`'ftp:'` */ get protocol(): string; /** * Returns a collection of query parameters as an object, or set * * @example * * ```ts * // Prints: * // { * // a: "100", * // b: "test" * // } * console.log(new URL('http://quarks.cc/?a=100&b=test').params); * ``` */ get params(): Dict; set params(value: Dict); /** * Returns a Hash parameter set as an object, or set * * @example * * ```ts * // Prints: * // { * // a: "200", * // b: "300" * // } * console.log(new URL('http://quarks.cc/#a=200&b=300').hashParams); * ``` */ get hashParams(): Dict; set hashParams(value: Dict); /** * Get path param * * @example * * ```ts * // Prints: ok * console.log(new URL('http://quarks.cc/?args=ok').getParam('args')); * ``` */ getParam(name: string): string; /** * Set the URL query parameter key-value pair and return self */ setParam(name: string, value: string): this; /** * Remove URL query parameters by name */ deleteParam(name: string): this; /** * Delete all of params in the URL */ clearParams(): this; /** * Get hash param by name */ getHash(name: string): string; /** * Set hash param by the key/value */ setHash(name: string, value: string): this; /** * Delete hash param by the name */ deleteHash(name: string): this; /** * Delete all of hash params in the URL */ clearHashs(): this; /** * Get relative path from fromPath to self * * @example * * ```ts * // Prints: ../A/B/C/test.js * var url = new URL('http://quarks.cc/A/B/C/test.js'); * console.log(url.relative('http://quarks.cc/home/')); * // Prints: file:///var/data/A/B/C/test.js * var url2 = new URL('file:///var/data/A/B/C/test.js'); * console.log(url2.relative('http://quarks.cc/home/')); * ``` */ relative(fromPath: string): string; /** */ toJSON(): string; } /** * @default */ declare const _default: { URL: typeof URL; /** * Get the executable file path * @method executable()string */ executable: () => string; /** * Get the documents directory path * @method documents(path?:string)string */ documents: (path?: string) => string; /** * Get the temporary directory path * @method temp(path?:string)string */ temp: (path?: string) => string; /** * Get the resources directory path * @method resources(path?:string)string */ resources: (path?: string) => string; /** * Get the current working directory * @method cwd()string */ cwd: () => string; /** * Set the current working directory and return `true` if successful * @method chdir(path:string)boolean */ chdir: (path: string) => boolean; /** * Format part path to normalize path * @method normalizePath(path:string,retain_up?:boolean)string */ normalizePath: typeof normalizePath; /** * Path delimiter * @get delimiter:string */ delimiter: string; /** * Restore the path to a path that the operating system can recognize. * Generally, you do not need to call this function unless you directly call * a Native/C/C++ function that is not provided by `Quark` * @method classicPath(path:string)string * @example * * ```ts * // Prints: /var/data/test.js * console.log(path.normalizePath('file:///var/data/test.js')); * ``` */ classicPath: (url: string) => string; /** * Format path to standard absolute path * @method resolve(path:string,partPath?string)string * @example * * ```ts * // Prints: http://quarks.cc/A/C/test.js * console.log(path.resolve('http://quarks.cc/home', "..", "A", "B", "..", "C", "test.js")); * // Prints: * // true * // file:///var/data/aaa/cc/ddd/kk.jpg * console.log(path.chdir('/var/data')); * console.log(path.resolve('aaa/bbb/../cc/.//!; /** Get params */ hashParams(path?: string): Dict; /** Get path param */ getParam(name: string, path?: string): string; /** Set path param */ setParam(name: string, value: string, path?: string): string; /** Delete path param */ deleteParam(name: string, path?: string): string; /** Delete all of hash params */ clearParams(path?: string): string; /** Get hash param */ getHash(name: string, path?: string): string; /** Set hash param */ setHash(name: string, value: string, path?: string): string; /** Delete hash param */ deleteHash(name: string, path?: string): string; /** Delete all of hash params */ clearHashs(path?: string): string; /** Get target path relative to the from path */ relative(from: string, target?: string): string; }; export default _default;