the-forest/client/node_modules/.cache/babel-loader/850d577bf96d038dc4d54673e5f09f6cb31a2dcdfb8829e691cb83f2853bf3c7.json
2024-09-17 20:35:18 -04:00

1 line
14 KiB
JSON

{"ast":null,"code":"// URI parser based on RFC 3986\n// We can't use the standard `URL` object, because we want to support relative `file:` URLs like\n// `file:relative/path/database.db`, which are not correct according to RFC 8089, which standardizes the\n// `file` scheme.\nimport { LibsqlError } from \"./api.js\";\nexport function parseUri(text) {\n const match = URI_RE.exec(text);\n if (match === null) {\n throw new LibsqlError(`The URL '${text}' is not in a valid format`, \"URL_INVALID\");\n }\n const groups = match.groups;\n const scheme = groups[\"scheme\"];\n const authority = groups[\"authority\"] !== undefined ? parseAuthority(groups[\"authority\"]) : undefined;\n const path = percentDecode(groups[\"path\"]);\n const query = groups[\"query\"] !== undefined ? parseQuery(groups[\"query\"]) : undefined;\n const fragment = groups[\"fragment\"] !== undefined ? percentDecode(groups[\"fragment\"]) : undefined;\n return {\n scheme,\n authority,\n path,\n query,\n fragment\n };\n}\nconst URI_RE = (() => {\n const SCHEME = \"(?<scheme>[A-Za-z][A-Za-z.+-]*)\";\n const AUTHORITY = \"(?<authority>[^/?#]*)\";\n const PATH = \"(?<path>[^?#]*)\";\n const QUERY = \"(?<query>[^#]*)\";\n const FRAGMENT = \"(?<fragment>.*)\";\n return new RegExp(`^${SCHEME}:(//${AUTHORITY})?${PATH}(\\\\?${QUERY})?(#${FRAGMENT})?$`, \"su\");\n})();\nfunction parseAuthority(text) {\n const match = AUTHORITY_RE.exec(text);\n if (match === null) {\n throw new LibsqlError(\"The authority part of the URL is not in a valid format\", \"URL_INVALID\");\n }\n const groups = match.groups;\n const host = percentDecode(groups[\"host_br\"] ?? groups[\"host\"]);\n const port = groups[\"port\"] ? parseInt(groups[\"port\"], 10) : undefined;\n const userinfo = groups[\"username\"] !== undefined ? {\n username: percentDecode(groups[\"username\"]),\n password: groups[\"password\"] !== undefined ? percentDecode(groups[\"password\"]) : undefined\n } : undefined;\n return {\n host,\n port,\n userinfo\n };\n}\nconst AUTHORITY_RE = (() => {\n return new RegExp(`^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\\\[\\\\]]*)|(\\\\[(?<host_br>[^\\\\[\\\\]]*)\\\\]))(:(?<port>[0-9]*))?$`, \"su\");\n})();\n// Query string is parsed as application/x-www-form-urlencoded according to the Web URL standard:\n// https://url.spec.whatwg.org/#urlencoded-parsing\nfunction parseQuery(text) {\n const sequences = text.split(\"&\");\n const pairs = [];\n for (const sequence of sequences) {\n if (sequence === \"\") {\n continue;\n }\n let key;\n let value;\n const splitIdx = sequence.indexOf(\"=\");\n if (splitIdx < 0) {\n key = sequence;\n value = \"\";\n } else {\n key = sequence.substring(0, splitIdx);\n value = sequence.substring(splitIdx + 1);\n }\n pairs.push({\n key: percentDecode(key.replaceAll(\"+\", \" \")),\n value: percentDecode(value.replaceAll(\"+\", \" \"))\n });\n }\n return {\n pairs\n };\n}\nfunction percentDecode(text) {\n try {\n return decodeURIComponent(text);\n } catch (e) {\n if (e instanceof URIError) {\n throw new LibsqlError(`URL component has invalid percent encoding: ${e}`, \"URL_INVALID\", undefined, e);\n }\n throw e;\n }\n}\nexport function encodeBaseUrl(scheme, authority, path) {\n if (authority === undefined) {\n throw new LibsqlError(`URL with scheme ${JSON.stringify(scheme + \":\")} requires authority (the \"//\" part)`, \"URL_INVALID\");\n }\n const schemeText = `${scheme}:`;\n const hostText = encodeHost(authority.host);\n const portText = encodePort(authority.port);\n const userinfoText = encodeUserinfo(authority.userinfo);\n const authorityText = `//${userinfoText}${hostText}${portText}`;\n let pathText = path.split(\"/\").map(encodeURIComponent).join(\"/\");\n if (pathText !== \"\" && !pathText.startsWith(\"/\")) {\n pathText = \"/\" + pathText;\n }\n return new URL(`${schemeText}${authorityText}${pathText}`);\n}\nfunction encodeHost(host) {\n return host.includes(\":\") ? `[${encodeURI(host)}]` : encodeURI(host);\n}\nfunction encodePort(port) {\n return port !== undefined ? `:${port}` : \"\";\n}\nfunction encodeUserinfo(userinfo) {\n if (userinfo === undefined) {\n return \"\";\n }\n const usernameText = encodeURIComponent(userinfo.username);\n const passwordText = userinfo.password !== undefined ? `:${encodeURIComponent(userinfo.password)}` : \"\";\n return `${usernameText}${passwordText}@`;\n}","map":{"version":3,"names":["LibsqlError","parseUri","text","match","URI_RE","exec","groups","scheme","authority","undefined","parseAuthority","path","percentDecode","query","parseQuery","fragment","SCHEME","AUTHORITY","PATH","QUERY","FRAGMENT","RegExp","AUTHORITY_RE","host","port","parseInt","userinfo","username","password","sequences","split","pairs","sequence","key","value","splitIdx","indexOf","substring","push","replaceAll","decodeURIComponent","e","URIError","encodeBaseUrl","JSON","stringify","schemeText","hostText","encodeHost","portText","encodePort","userinfoText","encodeUserinfo","authorityText","pathText","map","encodeURIComponent","join","startsWith","URL","includes","encodeURI","usernameText","passwordText"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/core/lib-esm/uri.js"],"sourcesContent":["// URI parser based on RFC 3986\n// We can't use the standard `URL` object, because we want to support relative `file:` URLs like\n// `file:relative/path/database.db`, which are not correct according to RFC 8089, which standardizes the\n// `file` scheme.\nimport { LibsqlError } from \"./api.js\";\nexport function parseUri(text) {\n const match = URI_RE.exec(text);\n if (match === null) {\n throw new LibsqlError(`The URL '${text}' is not in a valid format`, \"URL_INVALID\");\n }\n const groups = match.groups;\n const scheme = groups[\"scheme\"];\n const authority = groups[\"authority\"] !== undefined\n ? parseAuthority(groups[\"authority\"])\n : undefined;\n const path = percentDecode(groups[\"path\"]);\n const query = groups[\"query\"] !== undefined ? parseQuery(groups[\"query\"]) : undefined;\n const fragment = groups[\"fragment\"] !== undefined\n ? percentDecode(groups[\"fragment\"])\n : undefined;\n return { scheme, authority, path, query, fragment };\n}\nconst URI_RE = (() => {\n const SCHEME = \"(?<scheme>[A-Za-z][A-Za-z.+-]*)\";\n const AUTHORITY = \"(?<authority>[^/?#]*)\";\n const PATH = \"(?<path>[^?#]*)\";\n const QUERY = \"(?<query>[^#]*)\";\n const FRAGMENT = \"(?<fragment>.*)\";\n return new RegExp(`^${SCHEME}:(//${AUTHORITY})?${PATH}(\\\\?${QUERY})?(#${FRAGMENT})?$`, \"su\");\n})();\nfunction parseAuthority(text) {\n const match = AUTHORITY_RE.exec(text);\n if (match === null) {\n throw new LibsqlError(\"The authority part of the URL is not in a valid format\", \"URL_INVALID\");\n }\n const groups = match.groups;\n const host = percentDecode(groups[\"host_br\"] ?? groups[\"host\"]);\n const port = groups[\"port\"] ? parseInt(groups[\"port\"], 10) : undefined;\n const userinfo = groups[\"username\"] !== undefined\n ? {\n username: percentDecode(groups[\"username\"]),\n password: groups[\"password\"] !== undefined\n ? percentDecode(groups[\"password\"])\n : undefined,\n }\n : undefined;\n return { host, port, userinfo };\n}\nconst AUTHORITY_RE = (() => {\n return new RegExp(`^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\\\[\\\\]]*)|(\\\\[(?<host_br>[^\\\\[\\\\]]*)\\\\]))(:(?<port>[0-9]*))?$`, \"su\");\n})();\n// Query string is parsed as application/x-www-form-urlencoded according to the Web URL standard:\n// https://url.spec.whatwg.org/#urlencoded-parsing\nfunction parseQuery(text) {\n const sequences = text.split(\"&\");\n const pairs = [];\n for (const sequence of sequences) {\n if (sequence === \"\") {\n continue;\n }\n let key;\n let value;\n const splitIdx = sequence.indexOf(\"=\");\n if (splitIdx < 0) {\n key = sequence;\n value = \"\";\n }\n else {\n key = sequence.substring(0, splitIdx);\n value = sequence.substring(splitIdx + 1);\n }\n pairs.push({\n key: percentDecode(key.replaceAll(\"+\", \" \")),\n value: percentDecode(value.replaceAll(\"+\", \" \")),\n });\n }\n return { pairs };\n}\nfunction percentDecode(text) {\n try {\n return decodeURIComponent(text);\n }\n catch (e) {\n if (e instanceof URIError) {\n throw new LibsqlError(`URL component has invalid percent encoding: ${e}`, \"URL_INVALID\", undefined, e);\n }\n throw e;\n }\n}\nexport function encodeBaseUrl(scheme, authority, path) {\n if (authority === undefined) {\n throw new LibsqlError(`URL with scheme ${JSON.stringify(scheme + \":\")} requires authority (the \"//\" part)`, \"URL_INVALID\");\n }\n const schemeText = `${scheme}:`;\n const hostText = encodeHost(authority.host);\n const portText = encodePort(authority.port);\n const userinfoText = encodeUserinfo(authority.userinfo);\n const authorityText = `//${userinfoText}${hostText}${portText}`;\n let pathText = path.split(\"/\").map(encodeURIComponent).join(\"/\");\n if (pathText !== \"\" && !pathText.startsWith(\"/\")) {\n pathText = \"/\" + pathText;\n }\n return new URL(`${schemeText}${authorityText}${pathText}`);\n}\nfunction encodeHost(host) {\n return host.includes(\":\") ? `[${encodeURI(host)}]` : encodeURI(host);\n}\nfunction encodePort(port) {\n return port !== undefined ? `:${port}` : \"\";\n}\nfunction encodeUserinfo(userinfo) {\n if (userinfo === undefined) {\n return \"\";\n }\n const usernameText = encodeURIComponent(userinfo.username);\n const passwordText = userinfo.password !== undefined\n ? `:${encodeURIComponent(userinfo.password)}`\n : \"\";\n return `${usernameText}${passwordText}@`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,UAAU;AACtC,OAAO,SAASC,QAAQA,CAACC,IAAI,EAAE;EAC3B,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC;EAC/B,IAAIC,KAAK,KAAK,IAAI,EAAE;IAChB,MAAM,IAAIH,WAAW,CAAC,YAAYE,IAAI,4BAA4B,EAAE,aAAa,CAAC;EACtF;EACA,MAAMI,MAAM,GAAGH,KAAK,CAACG,MAAM;EAC3B,MAAMC,MAAM,GAAGD,MAAM,CAAC,QAAQ,CAAC;EAC/B,MAAME,SAAS,GAAGF,MAAM,CAAC,WAAW,CAAC,KAAKG,SAAS,GAC7CC,cAAc,CAACJ,MAAM,CAAC,WAAW,CAAC,CAAC,GACnCG,SAAS;EACf,MAAME,IAAI,GAAGC,aAAa,CAACN,MAAM,CAAC,MAAM,CAAC,CAAC;EAC1C,MAAMO,KAAK,GAAGP,MAAM,C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