@stryke/url 0.3.15 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +1 -0
  3. package/dist/helpers.cjs +1 -1
  4. package/dist/helpers.mjs +2 -1
  5. package/dist/helpers.mjs.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +2 -2
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.mjs +1 -1
  10. package/dist/json/src/storm-json.cjs +1 -0
  11. package/dist/json/src/storm-json.mjs +2 -0
  12. package/dist/json/src/storm-json.mjs.map +1 -0
  13. package/dist/json/src/utils/code-frames.cjs +3 -0
  14. package/dist/json/src/utils/code-frames.mjs +4 -0
  15. package/dist/json/src/utils/code-frames.mjs.map +1 -0
  16. package/dist/json/src/utils/parse-error.cjs +1 -0
  17. package/dist/json/src/utils/parse-error.mjs +2 -0
  18. package/dist/json/src/utils/parse-error.mjs.map +1 -0
  19. package/dist/json/src/utils/parse.cjs +1 -0
  20. package/dist/json/src/utils/parse.mjs +2 -0
  21. package/dist/json/src/utils/parse.mjs.map +1 -0
  22. package/dist/json/src/utils/stringify.cjs +1 -0
  23. package/dist/json/src/utils/stringify.mjs +2 -0
  24. package/dist/json/src/utils/stringify.mjs.map +1 -0
  25. package/dist/json/src/utils/strip-comments.cjs +4 -0
  26. package/dist/json/src/utils/strip-comments.mjs +5 -0
  27. package/dist/json/src/utils/strip-comments.mjs.map +1 -0
  28. package/dist/path/src/is-type.cjs +1 -0
  29. package/dist/path/src/is-type.mjs +2 -0
  30. package/dist/path/src/is-type.mjs.map +1 -0
  31. package/dist/path/src/join-paths.cjs +1 -0
  32. package/dist/path/src/join-paths.mjs +2 -0
  33. package/dist/path/src/join-paths.mjs.map +1 -0
  34. package/dist/path/src/regex.cjs +1 -0
  35. package/dist/path/src/regex.mjs +2 -0
  36. package/dist/path/src/regex.mjs.map +1 -0
  37. package/dist/path/src/slash.cjs +1 -0
  38. package/dist/path/src/slash.mjs +2 -0
  39. package/dist/path/src/slash.mjs.map +1 -0
  40. package/dist/storm-url.cjs +1 -1
  41. package/dist/storm-url.d.cts +61 -2
  42. package/dist/storm-url.d.cts.map +1 -0
  43. package/dist/storm-url.d.mts +61 -2
  44. package/dist/storm-url.d.mts.map +1 -0
  45. package/dist/storm-url.mjs +2 -1
  46. package/dist/storm-url.mjs.map +1 -0
  47. package/dist/type-checks/src/get-object-tag.cjs +1 -0
  48. package/dist/type-checks/src/get-object-tag.mjs +2 -0
  49. package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
  50. package/dist/type-checks/src/is-empty.cjs +1 -0
  51. package/dist/type-checks/src/is-empty.mjs +2 -0
  52. package/dist/type-checks/src/is-empty.mjs.map +1 -0
  53. package/dist/type-checks/src/is-integer.cjs +1 -0
  54. package/dist/type-checks/src/is-integer.mjs +2 -0
  55. package/dist/type-checks/src/is-integer.mjs.map +1 -0
  56. package/dist/type-checks/src/is-null.cjs +1 -0
  57. package/dist/type-checks/src/is-null.mjs +2 -0
  58. package/dist/type-checks/src/is-null.mjs.map +1 -0
  59. package/dist/type-checks/src/is-number.cjs +1 -0
  60. package/dist/type-checks/src/is-number.mjs +2 -0
  61. package/dist/type-checks/src/is-number.mjs.map +1 -0
  62. package/dist/type-checks/src/is-object.cjs +1 -0
  63. package/dist/type-checks/src/is-object.mjs +2 -0
  64. package/dist/type-checks/src/is-object.mjs.map +1 -0
  65. package/dist/type-checks/src/is-plain-object.cjs +1 -0
  66. package/dist/type-checks/src/is-plain-object.mjs +2 -0
  67. package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
  68. package/dist/type-checks/src/is-set-string.cjs +1 -0
  69. package/dist/type-checks/src/is-set-string.mjs +2 -0
  70. package/dist/type-checks/src/is-set-string.mjs.map +1 -0
  71. package/dist/type-checks/src/is-set.cjs +1 -0
  72. package/dist/type-checks/src/is-set.mjs +2 -0
  73. package/dist/type-checks/src/is-set.mjs.map +1 -0
  74. package/dist/type-checks/src/is-string.cjs +1 -0
  75. package/dist/type-checks/src/is-string.mjs +2 -0
  76. package/dist/type-checks/src/is-string.mjs.map +1 -0
  77. package/dist/type-checks/src/is-undefined.cjs +1 -0
  78. package/dist/type-checks/src/is-undefined.mjs +2 -0
  79. package/dist/type-checks/src/is-undefined.mjs.map +1 -0
  80. package/dist/types/src/base.cjs +1 -0
  81. package/dist/types/src/base.mjs +2 -0
  82. package/dist/types/src/base.mjs.map +1 -0
  83. package/dist/types.cjs +1 -1
  84. package/dist/types.d.cts +94 -2
  85. package/dist/types.d.cts.map +1 -0
  86. package/dist/types.d.mts +94 -2
  87. package/dist/types.d.mts.map +1 -0
  88. package/dist/types.mjs +2 -1
  89. package/dist/types.mjs.map +1 -0
  90. package/package.json +3 -3
  91. package/dist/helpers-C8s0XHG1.cjs +0 -1
  92. package/dist/helpers-CcGiwVAN.mjs +0 -2
  93. package/dist/helpers-CcGiwVAN.mjs.map +0 -1
  94. package/dist/storm-url-BeaSjjni.d.cts +0 -61
  95. package/dist/storm-url-BeaSjjni.d.cts.map +0 -1
  96. package/dist/storm-url-C44M08EF.d.mts +0 -61
  97. package/dist/storm-url-C44M08EF.d.mts.map +0 -1
  98. package/dist/storm-url-DQn2usO1.mjs +0 -7
  99. package/dist/storm-url-DQn2usO1.mjs.map +0 -1
  100. package/dist/storm-url-t7pdfQNU.cjs +0 -6
  101. package/dist/types-CHTfZzkO.d.cts +0 -94
  102. package/dist/types-CHTfZzkO.d.cts.map +0 -1
  103. package/dist/types-CxnefvtE.cjs +0 -1
  104. package/dist/types-DL1n5nYV.mjs +0 -2
  105. package/dist/types-DL1n5nYV.mjs.map +0 -1
  106. package/dist/types-wUi0ilxL.d.mts +0 -94
  107. package/dist/types-wUi0ilxL.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-number.mjs","names":[],"sources":["../../../../type-checks/src/is-number.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AnyNumber } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Check if the provided value's type is `number`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `number`\n */\nexport const isNumber = (value: unknown): value is number => {\n try {\n return (\n value instanceof Number ||\n typeof value === \"number\" ||\n Number(value) === value\n );\n } catch {\n return false;\n }\n};\n\n/**\n * Check if the provided value's type is `AnyNumber`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `AnyNumber`\n */\nexport function isAnyNumber(value?: any): value is AnyNumber {\n return isNumber(value) || getObjectTag(value) === \"[object Number]\";\n}\n"],"mappings":"AA2BA,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OACE,aAAiB,QACjB,OAAO,GAAU,UACjB,OAAO,EAAM,GAAK,OAEd,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-plain-object.cjs`),t=t=>{try{return typeof t==`object`||!!t&&t?.constructor===Object||e.isPlainObject(t)}catch{return!1}};exports.isObject=t;
@@ -0,0 +1,2 @@
1
+ import{isPlainObject as e}from"./is-plain-object.mjs";const t=t=>{try{return typeof t==`object`||!!t&&t?.constructor===Object||e(t)}catch{return!1}};export{t as isObject};
2
+ //# sourceMappingURL=is-object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-object.mjs","names":[],"sources":["../../../../type-checks/src/is-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-unsafe-function-type */\n/* eslint-disable ts/no-unsafe-call */\n\nimport type { NativeClass } from \"@stryke/types/base\";\nimport { isPlainObject } from \"./is-plain-object\";\n\n// Prepare\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n\n/** Is ES6+ class */\nexport function isNativeClass(value?: any): value is NativeClass {\n // NOTE TO DEVELOPER: If any of this changes, isClass must also be updated\n return (\n typeof value === \"function\" && isNativeClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is a conventional class\n *\n * @remarks\n * Is Conventional Class\n * Looks for function with capital first letter MyClass\n * First letter is the 9th character\n * If changed, isClass must also be updated\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is a conventional class\n */\nexport function isConventionalClass(value?: any): value is Function {\n return (\n typeof value === \"function\" &&\n isConventionalClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport function isClass(value?: any): value is Function | NativeClass; // only guarantee of truth type, not of validity\nexport function isClass(value?: any): boolean {\n return typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport const isObject = (value: unknown): value is object => {\n try {\n return (\n typeof value === \"object\" ||\n (Boolean(value) && value?.constructor === Object) ||\n isPlainObject(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":"sDAyEA,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OACE,OAAO,GAAU,UAChB,EAAQ,GAAU,GAAO,cAAgB,QAC1C,EAAc,EAAM,MAEhB,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=require(`./get-object-tag.cjs`),t=e=>typeof e==`object`&&!!e,n=n=>{if(!t(n)||e.getObjectTag(n)!==`[object Object]`)return!1;if(Object.getPrototypeOf(n)===null)return!0;let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r};exports.isPlainObject=n;
@@ -0,0 +1,2 @@
1
+ import{getObjectTag as e}from"./get-object-tag.mjs";const t=e=>typeof e==`object`&&!!e,n=n=>{if(!t(n)||e(n)!==`[object Object]`)return!1;if(Object.getPrototypeOf(n)===null)return!0;let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r};export{n as isPlainObject};
2
+ //# sourceMappingURL=is-plain-object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":"oDA2CA,MAAa,EAAgB,GACpB,OAAO,GAAQ,YAAY,EA4BvB,EAAiB,GAAqC,CACjE,GAAI,CAAC,EAAa,EAAI,EAAI,EAAa,EAAI,GAAK,kBAC9C,MAAO,GAET,GAAI,OAAO,eAAe,EAAI,GAAK,KACjC,MAAO,GAET,IAAI,EAAQ,EACZ,KAAO,OAAO,eAAe,EAAM,GAAK,MACtC,EAAQ,OAAO,eAAe,EAAM,CAEtC,OAAO,OAAO,eAAe,EAAI,GAAK"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-string.cjs`),t=require(`./is-set.cjs`),n=n=>{try{return t.isSet(n)&&e.isString(n)&&n.length>0}catch{return!1}};exports.isSetString=n;
@@ -0,0 +1,2 @@
1
+ import{isString as e}from"./is-string.mjs";import{isSet as t}from"./is-set.mjs";const n=n=>{try{return t(n)&&e(n)&&n.length>0}catch{return!1}};export{n as isSetString};
2
+ //# sourceMappingURL=is-set-string.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-set-string.mjs","names":[],"sources":["../../../../type-checks/src/is-set-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSet } from \"./is-set\";\nimport { isString } from \"./is-string\";\n\n/**\n * Determine if the type is string and is not empty (length greater than zero)\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `string` and length greater than zero\n */\nexport const isSetString = (value: unknown): value is NonNullable<string> => {\n try {\n return isSet(value) && isString(value) && value.length > 0;\n } catch {\n return false;\n }\n};\n"],"mappings":"gFA2BA,MAAa,EAAe,GAAiD,CAC3E,GAAI,CACF,OAAO,EAAM,EAAM,EAAI,EAAS,EAAM,EAAI,EAAM,OAAS,OACnD,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-empty.cjs`),t=t=>{try{return!e.isEmpty(t)}catch{return!1}};exports.isSet=t;
@@ -0,0 +1,2 @@
1
+ import{isEmpty as e}from"./is-empty.mjs";const t=t=>{try{return!e(t)}catch{return!1}};export{t as isSet};
2
+ //# sourceMappingURL=is-set.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-set.mjs","names":[],"sources":["../../../../type-checks/src/is-set.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":"yCA0BA,MAAa,EAAS,GAAkD,CACtE,GAAI,CACF,MAAO,CAAC,EAAQ,EAAM,MAChB,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=e=>{try{return typeof e==`string`}catch{return!1}};exports.isString=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>{try{return typeof e==`string`}catch{return!1}};export{e as isString};
2
+ //# sourceMappingURL=is-string.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":"AAkBA,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OAAO,OAAO,GAAU,cAClB,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=e=>e===void 0;exports.isUndefined=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>e===void 0;export{e as isUndefined};
2
+ //# sourceMappingURL=is-undefined.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n"],"mappings":"AAkBA,MAAa,EAAe,GACnB,IAAU,IAAA"}
@@ -0,0 +1 @@
1
+ const e=``;exports.EMPTY_STRING=``;
@@ -0,0 +1,2 @@
1
+ const e=``;export{e as EMPTY_STRING};
2
+ //# sourceMappingURL=base.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.mjs","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { TypedArray } from \"./array\";\n\nexport type SerializablePrimitive =\n | null\n | undefined\n | string\n | number\n | boolean\n | bigint;\nexport type Primitive = SerializablePrimitive | symbol;\n\n/**\n * Matches any primitive, `void`, `Date`, or `RegExp` value.\n */\nexport type BuiltIns = Primitive | void | Date | RegExp;\n\n/**\n * Matches any non-primitive object\n */\n// eslint-disable-next-line ts/no-unsafe-function-type\nexport type AtomicObject = Function | Promise<any> | Date | RegExp;\n\n/** Determines if the passed value is of a specific type */\nexport type TypeTester = (value: any) => boolean;\n\n/**\n * The interface for a type mapping (key =\\> function) to use for {@link getType}.\n * export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.\n * The map should be ordered by testing preference, with more specific tests first.\n * If a test returns true, it is selected, and the key is returned as the type.\n */\nexport type TypeMap = Record<string, TypeTester>;\n\ndeclare const emptyObjectSymbol: unique symbol;\n\nexport type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\n/**\n * A [[List]]\n *\n * @example\n * ```ts\n * type list0 = [1, 2, 3]\n * type list1 = number[]\n * ```\n *\n * @param A - its type\n * @returns [[List]]\n */\nexport type List<A = any> = ReadonlyArray<A>;\n\n/**\n * Alias to create a [[Function]]\n *\n * @example\n * ```ts\n * import { FunctionLike } from '@stryke/types'\n *\n * type test0 = FunctionLike<[string, number], boolean>\n * /// (args_0: string, args_1: number) => boolean\n * ```\n *\n * @param P - parameters\n * @param R - return type\n * @returns [[Function]]\n */\nexport type FunctionLike<P extends List = any, R = any> = (...args: P) => R;\n\nexport type AnyFunction = FunctionLike<any, any>;\nexport type Nullish = undefined | null;\nexport type Nullishable<T> = T | Nullish;\nexport type NonNullishObject = object; // not null/undefined which are Object\nexport type NativeClass = abstract new (...args: any) => any;\nexport type AnyNumber = number | number;\nexport type AnyString = string | string;\nexport type AnyBoolean = boolean | boolean;\nexport type AnyArray = any[];\nexport type PlainObject = Record<any, object>; // https://stackoverflow.com/a/75052315/130638\nexport type AnyMap = Map<any, any>;\nexport type AnyWeakMap = WeakMap<WeakKey, any>;\nexport type EmptyArray = [];\nexport interface EmptyObject {\n [emptyObjectSymbol]?: never;\n}\n\nexport type Any =\n | boolean\n | number\n | bigint\n | string\n | null\n | undefined\n | void\n | symbol\n | object\n | PlainObject\n | AnyArray\n | AnyMap\n | AnyWeakMap;\n\n/**\n * The valid types of the index for an `Indexable` type object\n */\nexport type IndexType = string | number | symbol;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type TypedIndexable<T> = Record<IndexType, T>;\n\n/**\n * The declaration of a ***dictionary-type*** object\n *\n * @see {@link TypedIndexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type Indexable = TypedIndexable<any>;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link TypedIndexable}\n */\nexport type Dictionary<T> = Record<string, T>;\n\nexport const EMPTY_STRING = \"\";\nexport const NEWLINE_STRING = \"\\r\\n\";\nexport const EMPTY_OBJECT = {};\n\nexport type AnyCase<T extends IndexType> = string extends T\n ? string\n : T extends `${infer F1}${infer F2}${infer R}`\n ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`\n : T extends `${infer F}${infer R}`\n ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`\n : typeof EMPTY_STRING;\n\nexport type Newable<T> = new (..._args: never[]) => T;\n\nexport interface Abstract<T> {\n prototype: T;\n}\n\nexport interface Clonable<T> {\n clone: () => T;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type ReducerFunction<TState, TAction> = (\n state: TState,\n action: TAction\n) => TState;\n\n// NOTE: for the file size optimization\nexport const TYPE_ARGUMENTS = \"Arguments\";\nexport const TYPE_ARRAY = \"Array\";\nexport const TYPE_OBJECT = \"Object\";\nexport const TYPE_MAP = \"Map\";\nexport const TYPE_SET = \"Set\";\n\nexport type Collection =\n | IArguments\n | unknown[]\n | Map<unknown, unknown>\n | Record<string | number | symbol, unknown>\n | Set<unknown>;\n\nexport type NonUndefined<T> = T extends undefined ? never : T;\n\nexport type BrowserNativeObject = Date | File;\n\nexport type DeepPartial<T> = T extends BrowserNativeObject | NestedValue\n ? T\n : {\n [K in keyof T]?: DeepPartial<T[K]>;\n };\n\nexport type Rollback = Record<\n string,\n (initialValue: any, currentValue: any) => any\n>;\n\n/**\n * Extract all required keys from the given type.\n *\n * @remarks\n * This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...\n */\nexport type RequiredKeysOf<BaseType extends object> = Exclude<\n {\n [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>\n ? Key\n : never;\n }[keyof BaseType],\n undefined\n>;\n\n/**\n * Returns a boolean for whether the two given types are equal.\n *\n * @remarks\n * Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.\n *\n * @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650\n * @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796\n */\nexport type IsEqual<A, B> =\n (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2\n ? true\n : false;\n\nexport type Filter<KeyType, ExcludeType> =\n IsEqual<KeyType, ExcludeType> extends true\n ? never\n : KeyType extends ExcludeType\n ? never\n : KeyType;\n\ninterface ExceptOptions {\n /**\n Disallow assigning non-specified properties.\n\n Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.\n\n @defaultValue false\n */\n requireExactProps?: boolean;\n}\n\n/**\n * Create a type from an object type without certain keys.\n *\n * @remarks\n * We recommend setting the `requireExactProps` option to `true`.\n *\n * This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.\n *\n * This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).\n */\nexport type Except<\n ObjectType,\n KeysType extends keyof ObjectType,\n Options extends ExceptOptions = { requireExactProps: false }\n> = {\n [KeyType in keyof ObjectType as Filter<\n KeyType,\n KeysType\n >]: ObjectType[KeyType];\n} & (Options[\"requireExactProps\"] extends true\n ? Partial<Record<KeysType, never>>\n : Record<string, never>);\n\n/**\n * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n *\n * @remarks\n * Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.\n *\n * If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.\n *\n * @see https://github.com/microsoft/TypeScript/issues/15300\n */\nexport type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};\n\n/**\n * Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.\n *\n * @remarks\n * Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.\n */\nexport type SetRequired<\n BaseType,\n Keys extends keyof BaseType\n> = BaseType extends unknown // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). // union into a [distributive conditional // `extends unknown` is always going to be the case and is used to convert any\n ? Simplify<\n // Pick just the keys that are optional from the base type.\n Except<BaseType, Keys> &\n // Pick the keys that should be required from the base type and make them required.\n Required<Pick<BaseType, Keys>>\n >\n : never;\n\nexport const $NestedValue: unique symbol = Symbol(\"NestedValue\");\n\nexport type NestedValue<TValue extends object = object> = {\n [$NestedValue]: never;\n} & TValue;\n\nexport interface RefObject<T> {\n current: T;\n}\n\nexport interface Identity<T = string> {\n id: T;\n}\n\nexport interface Versioned {\n version: number;\n}\n\nexport interface Sequenced {\n /**\n * The sequence number (version, or event counter, etc.) of the record\n */\n sequence: number;\n}\n\nexport interface Typed {\n /**\n * The type of the record\n */\n __type: string;\n}\n\nexport interface ClassTypeCheckable<T> extends Typed {\n /**\n * Run type check on the given value\n * @param value - The value to check\n * @returns True if the value is of the type of the class\n */\n isTypeOf: (value: unknown) => value is T;\n}\n\n/**\n * Matches non-recursive types.\n */\nexport type NonRecursiveType =\n | BuiltIns\n // eslint-disable-next-line ts/no-unsafe-function-type\n | Function\n | (new (...arguments_: any[]) => unknown);\n\nexport type IsPrimitive<T> = [T] extends [Primitive] ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type IsNull<T> = [T] extends [null] ? true : false;\nexport type IsUndefined<T> = T extends undefined ? true : false;\nexport type IsUnknown<T> = unknown extends T // `T` can be `unknown` or `any`\n ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be\n ? true\n : false\n : false;\nexport type IsNullish<T> = IsNull<T> & IsUndefined<T>;\nexport type IsFunction<T> = T extends AnyFunction ? true : false;\n\n/**\n * Declare locally scoped properties on `globalThis`.\n *\n * When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.\n *\n * Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.\n *\n * @example\n * ```\n * import type { GlobalThis } from '@stryke/types';\n *\n * type ExtraGlobals = GlobalThis & {\n * readonly GLOBAL_TOKEN: string;\n * };\n *\n * (globalThis as ExtraGlobals).GLOBAL_TOKEN;\n * ```\n */\nexport type GlobalThis = typeof globalThis;\n\n/**\n * Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport interface Class<T, Arguments extends unknown[] = any[]> {\n prototype: Pick<T, keyof T>;\n new (...arguments_: Arguments): T;\n}\n\n/**\n * Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport type Constructor<T, Arguments extends unknown[] = any[]> = new (\n ...arguments_: Arguments\n) => T;\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).\n *\n * @privateRemarks\n * We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)\n */\n\nexport interface AbstractClass<\n T,\n Arguments extends unknown[] = any[]\n> extends AbstractConstructor<T, Arguments> {\n prototype: Pick<T, keyof T>;\n}\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.\n */\nexport type AbstractConstructor<\n T,\n Arguments extends unknown[] = any[]\n> = abstract new (...arguments_: Arguments) => T;\n\n/**\n * Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.\n *\n * If `<Fill>` is not provided, it will default to `unknown`.\n *\n * @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f\n */\nexport type BuildTuple<\n L extends number,\n Fill = unknown,\n T extends readonly unknown[] = []\n> = T[\"length\"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;\n\n/**\n * Test if the given function has multiple call signatures.\n *\n * Needed to handle the case of a single call signature with properties.\n *\n * Multiple call signatures cannot currently be supported due to a TypeScript limitation.\n * @see https://github.com/microsoft/TypeScript/issues/29732\n */\nexport type HasMultipleCallSignatures<\n T extends (...arguments_: any[]) => unknown\n> = T extends {\n (...arguments_: infer A): unknown;\n (...arguments_: infer B): unknown;\n}\n ? B extends A\n ? A extends B\n ? false\n : true\n : true\n : false;\n\ntype StructuredCloneablePrimitive =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | boolean\n | number\n | string;\n\ntype StructuredCloneableData =\n | ArrayBuffer\n | DataView\n | Date\n | Error\n | RegExp\n | TypedArray\n | Blob\n | File;\n\n// DOM exclusive types\n// | AudioData\n// | CropTarget\n// | CryptoKey\n// | DOMException\n// | DOMMatrix\n// | DOMMatrixReadOnly\n// | DOMPoint\n// | DOMPointReadOnly\n// | DOMQuad\n// | DOMRect\n// | DOMRectReadOnly\n// | FileList\n// | FileSystemDirectoryHandle\n// | FileSystemFileHandle\n// | FileSystemHandle\n// | GPUCompilationInfo\n// | GPUCompilationMessage\n// | ImageBitmap\n// | ImageData\n// | RTCCertificate\n// | VideoFrame\n\ntype StructuredCloneableCollection =\n | readonly StructuredCloneable[]\n | {\n readonly [key: string]: StructuredCloneable;\n readonly [key: number]: StructuredCloneable;\n }\n | ReadonlyMap<StructuredCloneable, StructuredCloneable>\n | ReadonlySet<StructuredCloneable>;\n\n/**\n * Matches a value that can be losslessly cloned using `structuredClone`.\n *\n * Note:\n * - Custom error types will be cloned as the base `Error` type\n * - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n *\n * @example\n * ```\n * import type { StructuredCloneable } from '@stryke/types';\n *\n * class CustomClass {}\n *\n * // @ts-expect-error\n * const error: StructuredCloneable = {\n * custom: new CustomClass(),\n * };\n *\n * structuredClone(error);\n * //=> {custom: {}}\n *\n * const good: StructuredCloneable = {\n * number: 3,\n * date: new Date(),\n * map: new Map<string, number>(),\n * }\n *\n * good.map.set('key', 1);\n *\n * structuredClone(good);\n * //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}\n * ```\n */\nexport type StructuredCloneable =\n | StructuredCloneablePrimitive\n | StructuredCloneableData\n | StructuredCloneableCollection;\n"],"mappings":"AAsJA,MAAa,EAAe"}
package/dist/types.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./types-CxnefvtE.cjs`);exports.PROTOCOL_RELATIVE_SYMBOL=e.t;
1
+ const e=Symbol(`protocol-relative`);exports.PROTOCOL_RELATIVE_SYMBOL=e;
package/dist/types.d.cts CHANGED
@@ -1,2 +1,94 @@
1
- import { n as StormURLInterface, r as StormURLOptions, t as PROTOCOL_RELATIVE_SYMBOL } from "./types-CHTfZzkO.cjs";
2
- export { PROTOCOL_RELATIVE_SYMBOL, StormURLInterface, StormURLOptions };
1
+ //#region src/types.d.ts
2
+ interface StormURLOptions {
3
+ /**
4
+ * Should the URL be decoded
5
+ *
6
+ * @defaultValue `true`
7
+ */
8
+ decode?: boolean;
9
+ /**
10
+ * Should the URL include a locale path segment
11
+ */
12
+ locale?: string | true;
13
+ /**
14
+ * The default protocol to use
15
+ *
16
+ * @defaultValue "https"
17
+ */
18
+ defaultProtocol?: string;
19
+ }
20
+ declare const PROTOCOL_RELATIVE_SYMBOL: unique symbol;
21
+ interface StormURLInterface extends URL {
22
+ /**
23
+ * A string containing the username and password specified before the domain name.
24
+ */
25
+ auth: string;
26
+ /**
27
+ * A string containing the username specified before the domain name.
28
+ */
29
+ username: string;
30
+ /**
31
+ * A string containing the password specified before the domain name.
32
+ */
33
+ password: string;
34
+ /**
35
+ * A string containing the domain (that is the hostname) followed by (if a port was specified) a `:` and the port of the URL.
36
+ */
37
+ host: string;
38
+ /**
39
+ * A string containing the domain of the URL.
40
+ */
41
+ hostname: string;
42
+ /**
43
+ * A string containing the port number of the URL.
44
+ */
45
+ port: string;
46
+ /**
47
+ * A string containing the protocol scheme of the URL, including the final `:`.
48
+ */
49
+ protocol: string;
50
+ /**
51
+ * A stringified value that returns the whole URL.
52
+ */
53
+ href: string;
54
+ /**
55
+ * A string containing an initial `/` followed by the path of the URL, not including the query string or fragment.
56
+ */
57
+ pathname: string;
58
+ /**
59
+ * The paths of the URL
60
+ */
61
+ paths: any[];
62
+ /**
63
+ * A string containing a `#` followed by the fragment identifier of the URL.
64
+ */
65
+ hash: string;
66
+ /**
67
+ * A string indicating the URL's parameter string; if any parameters are provided, this string includes all of them, beginning with the leading `?` character.
68
+ */
69
+ search: string;
70
+ /**
71
+ * The search parameters of the URL
72
+ *
73
+ * @remarks
74
+ * This is a `URLSearchParams` object that contains the search parameters of the URL.
75
+ */
76
+ searchParams: URLSearchParams;
77
+ /**
78
+ * The search parameters of the URL
79
+ *
80
+ * @remarks
81
+ * This is a Record\<string, any\> object that contains the search parameters of the URL.
82
+ */
83
+ params: Record<string, any>;
84
+ /**
85
+ * An optional symbol to indicate that the URL is protocol-relative
86
+ *
87
+ * @remarks
88
+ * This is used when the URL is protocol-relative (e.g. //example.com)
89
+ */
90
+ [PROTOCOL_RELATIVE_SYMBOL]?: boolean;
91
+ }
92
+ //#endregion
93
+ export { PROTOCOL_RELATIVE_SYMBOL, StormURLInterface, StormURLOptions };
94
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";UAkBiB,eAAA;EAAA;AAqBjB;AAGA;;;EAmFG,MAAA,CAAA,EAAA,OAAA;EAnFwC;;;;;;;;;;;cAH9B;UAGI,iBAAA,SAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAmE3B;;;;;;;UAQN;;;;;;;GAQP,wBAAA"}
package/dist/types.d.mts CHANGED
@@ -1,2 +1,94 @@
1
- import { n as StormURLInterface, r as StormURLOptions, t as PROTOCOL_RELATIVE_SYMBOL } from "./types-wUi0ilxL.mjs";
2
- export { PROTOCOL_RELATIVE_SYMBOL, StormURLInterface, StormURLOptions };
1
+ //#region src/types.d.ts
2
+ interface StormURLOptions {
3
+ /**
4
+ * Should the URL be decoded
5
+ *
6
+ * @defaultValue `true`
7
+ */
8
+ decode?: boolean;
9
+ /**
10
+ * Should the URL include a locale path segment
11
+ */
12
+ locale?: string | true;
13
+ /**
14
+ * The default protocol to use
15
+ *
16
+ * @defaultValue "https"
17
+ */
18
+ defaultProtocol?: string;
19
+ }
20
+ declare const PROTOCOL_RELATIVE_SYMBOL: unique symbol;
21
+ interface StormURLInterface extends URL {
22
+ /**
23
+ * A string containing the username and password specified before the domain name.
24
+ */
25
+ auth: string;
26
+ /**
27
+ * A string containing the username specified before the domain name.
28
+ */
29
+ username: string;
30
+ /**
31
+ * A string containing the password specified before the domain name.
32
+ */
33
+ password: string;
34
+ /**
35
+ * A string containing the domain (that is the hostname) followed by (if a port was specified) a `:` and the port of the URL.
36
+ */
37
+ host: string;
38
+ /**
39
+ * A string containing the domain of the URL.
40
+ */
41
+ hostname: string;
42
+ /**
43
+ * A string containing the port number of the URL.
44
+ */
45
+ port: string;
46
+ /**
47
+ * A string containing the protocol scheme of the URL, including the final `:`.
48
+ */
49
+ protocol: string;
50
+ /**
51
+ * A stringified value that returns the whole URL.
52
+ */
53
+ href: string;
54
+ /**
55
+ * A string containing an initial `/` followed by the path of the URL, not including the query string or fragment.
56
+ */
57
+ pathname: string;
58
+ /**
59
+ * The paths of the URL
60
+ */
61
+ paths: any[];
62
+ /**
63
+ * A string containing a `#` followed by the fragment identifier of the URL.
64
+ */
65
+ hash: string;
66
+ /**
67
+ * A string indicating the URL's parameter string; if any parameters are provided, this string includes all of them, beginning with the leading `?` character.
68
+ */
69
+ search: string;
70
+ /**
71
+ * The search parameters of the URL
72
+ *
73
+ * @remarks
74
+ * This is a `URLSearchParams` object that contains the search parameters of the URL.
75
+ */
76
+ searchParams: URLSearchParams;
77
+ /**
78
+ * The search parameters of the URL
79
+ *
80
+ * @remarks
81
+ * This is a Record\<string, any\> object that contains the search parameters of the URL.
82
+ */
83
+ params: Record<string, any>;
84
+ /**
85
+ * An optional symbol to indicate that the URL is protocol-relative
86
+ *
87
+ * @remarks
88
+ * This is used when the URL is protocol-relative (e.g. //example.com)
89
+ */
90
+ [PROTOCOL_RELATIVE_SYMBOL]?: boolean;
91
+ }
92
+ //#endregion
93
+ export { PROTOCOL_RELATIVE_SYMBOL, StormURLInterface, StormURLOptions };
94
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";UAkBiB,eAAA;EAAA;AAqBjB;AAGA;;;EAmFG,MAAA,CAAA,EAAA,OAAA;EAnFwC;;;;;;;;;;;cAH9B;UAGI,iBAAA,SAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAmE3B;;;;;;;UAQN;;;;;;;GAQP,wBAAA"}
package/dist/types.mjs CHANGED
@@ -1 +1,2 @@
1
- import{t as e}from"./types-DL1n5nYV.mjs";export{e as PROTOCOL_RELATIVE_SYMBOL};
1
+ const e=Symbol(`protocol-relative`);export{e as PROTOCOL_RELATIVE_SYMBOL};
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","names":["PROTOCOL_RELATIVE_SYMBOL: unique symbol"],"sources":["../src/types.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport interface StormURLOptions {\n /**\n * Should the URL be decoded\n *\n * @defaultValue `true`\n */\n decode?: boolean;\n\n /**\n * Should the URL include a locale path segment\n */\n locale?: string | true;\n\n /**\n * The default protocol to use\n *\n * @defaultValue \"https\"\n */\n defaultProtocol?: string;\n}\n\nexport const PROTOCOL_RELATIVE_SYMBOL: unique symbol =\n Symbol(\"protocol-relative\");\n\nexport interface StormURLInterface extends URL {\n /**\n * A string containing the username and password specified before the domain name.\n */\n auth: string;\n\n /**\n * A string containing the username specified before the domain name.\n */\n username: string;\n\n /**\n * A string containing the password specified before the domain name.\n */\n password: string;\n\n /**\n * A string containing the domain (that is the hostname) followed by (if a port was specified) a `:` and the port of the URL.\n */\n host: string;\n\n /**\n * A string containing the domain of the URL.\n */\n hostname: string;\n\n /**\n * A string containing the port number of the URL.\n */\n port: string;\n\n /**\n * A string containing the protocol scheme of the URL, including the final `:`.\n */\n protocol: string;\n\n /**\n * A stringified value that returns the whole URL.\n */\n href: string;\n\n /**\n * A string containing an initial `/` followed by the path of the URL, not including the query string or fragment.\n */\n pathname: string;\n\n /**\n * The paths of the URL\n */\n paths: any[];\n\n /**\n * A string containing a `#` followed by the fragment identifier of the URL.\n */\n hash: string;\n\n /**\n * A string indicating the URL's parameter string; if any parameters are provided, this string includes all of them, beginning with the leading `?` character.\n */\n search: string;\n\n /**\n * The search parameters of the URL\n *\n * @remarks\n * This is a `URLSearchParams` object that contains the search parameters of the URL.\n */\n searchParams: URLSearchParams;\n\n /**\n * The search parameters of the URL\n *\n * @remarks\n * This is a Record\\<string, any\\> object that contains the search parameters of the URL.\n */\n params: Record<string, any>;\n\n /**\n * An optional symbol to indicate that the URL is protocol-relative\n *\n * @remarks\n * This is used when the URL is protocol-relative (e.g. //example.com)\n */\n [PROTOCOL_RELATIVE_SYMBOL]?: boolean;\n}\n"],"mappings":"AAuCA,MAAaA,EACX,OAAO,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/url",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "type": "module",
5
5
  "description": "A package containing the `StormURL` class, which is used to parse and manipulate URLs.",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "types": "./dist/index.d.cts",
28
28
  "dependencies": { "ufo": "^1.6.1" },
29
- "devDependencies": { "@types/node": "^24.10.1", "tsdown": "^0.17.1" },
29
+ "devDependencies": { "@types/node": "^24.10.4", "tsdown": "^0.17.2" },
30
30
  "publishConfig": { "access": "public" },
31
- "gitHead": "fd38508c876b697a52a0e27df1478b41ae011583"
31
+ "gitHead": "afcd140cfb0555b3dacd5ece701909f66c174068"
32
32
  }
@@ -1 +0,0 @@
1
- function e(e){let t=e;if(t.includes(`_`)&&(t=t.replace(/_/g,`-`)),t.includes(`-`)){let e=t.split(`-`);if(e.length>1){let n=e[0],r=e[1];n&&r&&(t=`${n}-${r}`)}}return t.toLowerCase()}function t(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
@@ -1,2 +0,0 @@
1
- function e(e){let t=e;if(t.includes(`_`)&&(t=t.replace(/_/g,`-`)),t.includes(`-`)){let e=t.split(`-`);if(e.length>1){let n=e[0],r=e[1];n&&r&&(t=`${n}-${r}`)}}return t.toLowerCase()}function t(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}export{t as n,e as t};
2
- //# sourceMappingURL=helpers-CcGiwVAN.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers-CcGiwVAN.mjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport function formatLocalePath(locale: string) {\n let result = locale;\n if (result.includes(\"_\")) {\n result = result.replace(/_/g, \"-\");\n }\n\n if (result.includes(\"-\")) {\n const parts = result.split(\"-\");\n if (parts.length > 1) {\n const lang = parts[0];\n const region = parts[1];\n if (lang && region) {\n result = `${lang}-${region}`;\n }\n }\n }\n\n return result.toLowerCase();\n}\n\n/**\n * Check if a string has a valid URL format.\n *\n * @param str - The string to check.\n * @returns `true` if the string is a valid URL, otherwise `false`.\n */\nexport function isValidURL(str: string): boolean {\n return /(?:https?:\\/\\/.)?(?:www\\.)?[-\\w@:%.+~#=]{2,256}\\.[a-z]{2,6}\\b[-\\w@:%+.~#?&/=]*/.test(\n str\n );\n}\n"],"mappings":"AAkBA,SAAgB,EAAiB,EAAgB,CAC/C,IAAI,EAAS,EAKb,GAJI,EAAO,SAAS,IAAI,GACtB,EAAS,EAAO,QAAQ,KAAM,IAAI,EAGhC,EAAO,SAAS,IAAI,CAAE,CACxB,IAAM,EAAQ,EAAO,MAAM,IAAI,CAC/B,GAAI,EAAM,OAAS,EAAG,CACpB,IAAM,EAAO,EAAM,GACb,EAAS,EAAM,GACjB,GAAQ,IACV,EAAS,GAAG,EAAK,GAAG,MAK1B,OAAO,EAAO,aAAa,CAS7B,SAAgB,EAAW,EAAsB,CAC/C,MAAO,iFAAiF,KACtF,EACD"}
@@ -1,61 +0,0 @@
1
- import { n as StormURLInterface, r as StormURLOptions } from "./types-CHTfZzkO.cjs";
2
- import { ParsedURL } from "ufo";
3
-
4
- //#region src/storm-url.d.ts
5
-
6
- /**
7
- * A class used to build URLs
8
- *
9
- * @remarks
10
- * This class is used to build URLs with a fluent API.
11
- *
12
- * The [UFO](https://github.com/unjs/ufo) library is used under the hood to parse and stringify URLs.
13
- */
14
- declare class StormURL implements StormURLInterface, URL {
15
- #private;
16
- constructor(initialURL: string, options?: StormURLOptions);
17
- set params(value: Record<string, any>);
18
- get params(): Record<string, any>;
19
- get searchParams(): URLSearchParams;
20
- set searchParams(value: URLSearchParams);
21
- set search(value: string);
22
- get search(): string;
23
- set hash(value: string);
24
- get hash(): string;
25
- set port(value: string | number);
26
- get port(): string;
27
- set username(value: string);
28
- get username(): string;
29
- set password(value: string);
30
- get password(): string;
31
- set auth(value: string | undefined);
32
- get auth(): string;
33
- set protocol(value: string);
34
- get protocol(): string;
35
- set hostname(value: string);
36
- get hostname(): string;
37
- set host(value: string | undefined);
38
- get host(): string;
39
- set paths(value: any[]);
40
- get paths(): any[];
41
- set pathname(value: string);
42
- get pathname(): string;
43
- set path(value: string);
44
- get path(): string;
45
- get href(): string;
46
- set href(value: string);
47
- get origin(): string;
48
- get isScriptProtocol(): boolean;
49
- get isRelative(): boolean;
50
- get isNonEmptyURL(): boolean;
51
- get __typename(): string;
52
- isSamePath(path: string): boolean;
53
- isEqual(url: string | ParsedURL | StormURL): boolean;
54
- toParsed(): ParsedURL;
55
- toString(): string;
56
- toEncoded(): string;
57
- toJSON(): string;
58
- }
59
- //#endregion
60
- export { StormURL as t };
61
- //# sourceMappingURL=storm-url-BeaSjjni.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storm-url-BeaSjjni.d.cts","names":[],"sources":["../src/storm-url.ts"],"sourcesContent":[],"mappings":";;;;;;;AAoDA;;;;;;AAyQ+B,cAzQlB,QAAA,YAAoB,iBAyQF,EAzQqB,GAyQrB,CAAA;EAAY,CAAA,OAAA;EAWtB,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAzOsB,eAyOtB;EApRY,IAAA,MAAA,CAAA,KAAA,EAgFN,MAhFM,CAAA,MAAA,EAAA,GAAA,CAAA;EAAmB,IAAA,MAAA,CAAA,CAAA,EAoF7B,MApF6B,CAAA,MAAA,EAAA,GAAA,CAAA;EAAG,IAAA,YAAA,CAAA,CAAA,EAwF1B,eAxF0B;0BAgGtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyKF,YAAY;cAWtB"}
@@ -1,61 +0,0 @@
1
- import { n as StormURLInterface, r as StormURLOptions } from "./types-wUi0ilxL.mjs";
2
- import { ParsedURL } from "ufo";
3
-
4
- //#region src/storm-url.d.ts
5
-
6
- /**
7
- * A class used to build URLs
8
- *
9
- * @remarks
10
- * This class is used to build URLs with a fluent API.
11
- *
12
- * The [UFO](https://github.com/unjs/ufo) library is used under the hood to parse and stringify URLs.
13
- */
14
- declare class StormURL implements StormURLInterface, URL {
15
- #private;
16
- constructor(initialURL: string, options?: StormURLOptions);
17
- set params(value: Record<string, any>);
18
- get params(): Record<string, any>;
19
- get searchParams(): URLSearchParams;
20
- set searchParams(value: URLSearchParams);
21
- set search(value: string);
22
- get search(): string;
23
- set hash(value: string);
24
- get hash(): string;
25
- set port(value: string | number);
26
- get port(): string;
27
- set username(value: string);
28
- get username(): string;
29
- set password(value: string);
30
- get password(): string;
31
- set auth(value: string | undefined);
32
- get auth(): string;
33
- set protocol(value: string);
34
- get protocol(): string;
35
- set hostname(value: string);
36
- get hostname(): string;
37
- set host(value: string | undefined);
38
- get host(): string;
39
- set paths(value: any[]);
40
- get paths(): any[];
41
- set pathname(value: string);
42
- get pathname(): string;
43
- set path(value: string);
44
- get path(): string;
45
- get href(): string;
46
- set href(value: string);
47
- get origin(): string;
48
- get isScriptProtocol(): boolean;
49
- get isRelative(): boolean;
50
- get isNonEmptyURL(): boolean;
51
- get __typename(): string;
52
- isSamePath(path: string): boolean;
53
- isEqual(url: string | ParsedURL | StormURL): boolean;
54
- toParsed(): ParsedURL;
55
- toString(): string;
56
- toEncoded(): string;
57
- toJSON(): string;
58
- }
59
- //#endregion
60
- export { StormURL as t };
61
- //# sourceMappingURL=storm-url-C44M08EF.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storm-url-C44M08EF.d.mts","names":[],"sources":["../src/storm-url.ts"],"sourcesContent":[],"mappings":";;;;;;;AAoDA;;;;;;AAyQ+B,cAzQlB,QAAA,YAAoB,iBAyQF,EAzQqB,GAyQrB,CAAA;EAAY,CAAA,OAAA;EAWtB,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAzOsB,eAyOtB;EApRY,IAAA,MAAA,CAAA,KAAA,EAgFN,MAhFM,CAAA,MAAA,EAAA,GAAA,CAAA;EAAmB,IAAA,MAAA,CAAA,CAAA,EAoF7B,MApF6B,CAAA,MAAA,EAAA,GAAA,CAAA;EAAG,IAAA,YAAA,CAAA,CAAA,EAwF1B,eAxF0B;0BAgGtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyKF,YAAY;cAWtB"}
@@ -1,7 +0,0 @@
1
- import{n as e,t}from"./helpers-CcGiwVAN.mjs";import{parse as n,printParseErrorCode as r}from"jsonc-parser";import{Buffer as i}from"node:buffer";import a from"superjson";import{LinesAndColumns as o}from"lines-and-columns";import{cleanDoubleSlashes as s,decode as c,isEqual as l,isNonEmptyURL as u,isRelative as d,isSamePath as f,isScriptProtocol as p,normalizeURL as m,parseAuth as h,parseHost as g,parsePath as _,parseQuery as v,parseURL as y,stringifyParsedURL as b,stringifyQuery as x}from"ufo";const S=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e),C=e=>typeof e==`object`&&!!e,w=e=>{if(!C(e)||S(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},T=e=>{try{return typeof e==`object`||!!e&&e?.constructor===Object||w(e)}catch{return!1}},E=e=>{try{return typeof e==`string`}catch{return!1}},D=Symbol(`singleComment`),O=Symbol(`multiComment`);function ee(){return``}function te(e,t,n){return e.slice(t,n).replace(/\S/g,` `)}function k(e,t){let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)}function A(e,{whitespace:t=!0,trailingCommas:n=!1}={}){if(typeof e!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let r=t?te:ee,i=!1,a=!1,o=0,s=``,c=``,l=-1;for(let t=0;t<e.length;t++){let u=e[t],d=e[t+1];!a&&u===`"`&&(k(e,t)||(i=!i)),!i&&(!a&&u+(d??``)===`//`?(s+=e.slice(o,t),o=t,a=D,t++):a===D&&u+(d??``)===`\r
2
- `?(t++,a=!1,s+=r(e,o,t),o=t):a===D&&u===`
3
- `?(a=!1,s+=r(e,o,t),o=t):!a&&u+(d??``)===`/*`?(s+=e.slice(o,t),o=t,a=O,t++):a===O&&u+(d??``)===`*/`?(t++,a=!1,s+=r(e,o,t+1),o=t+1):n&&!a&&(l===-1?u===`,`&&(c+=s+e.slice(o,t),s=``,o=t,l=t):u===`}`||u===`]`?(s+=e.slice(o,t),c+=r(s,0,1)+s.slice(1),s=``,o=t,l=-1):u!==` `&&u!==` `&&u!==`\r`&&u!==`
4
- `&&(s+=e.slice(o,t),o=t,l=-1)))}return c+s+(a?r(e.slice(o)):e.slice(o))}const j=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,M=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,N=/^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;function P(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){console.warn(`Dropping "${e}" key to prevent prototype pollution.`);return}return t}function F(e,t={}){if(typeof e!=`string`)return e;let n=A(e);if(n[0]===`"`&&n[n.length-1]===`"`&&!n.includes(`\\`))return n.slice(1,-1);if(n=n.trim(),n.length<=9)switch(n.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!N.test(n)){if(t.strict)throw Error(`Invalid JSON`);return n}try{if(j.test(n)||M.test(n)){if(t.strict)throw Error(`Possible prototype pollution`);return JSON.parse(n,P)}return JSON.parse(n)}catch(n){if(t.strict)throw n;return e}}const I=/\r\n|[\n\r\u2028\u2029]/;function L(e,t,n={}){let r={column:0,line:-1,...e.start},i={...r,...e.end},{linesAbove:a=2,linesBelow:o=3}=n||{},s=r.line,c=r.column,l=i.line,u=i.column,d=Math.max(s-(a+1),0),f=Math.min(t.length,l+o);s===-1&&(d=0),l===-1&&(f=t.length);let p=l-s,m={};if(p)for(let e=0;e<=p;e++){let n=e+s;c?e===0?m[n]=[c,(t[n-1]?.length??0)-c+1]:e===p?m[n]=[0,u]:m[n]=[0,t[n-e]?.length??0]:m[n]=!0}else c===u?m[s]=c?[c,0]:!0:m[s]=[c,u-c];return{start:d,end:f,markerLines:m}}function R(e,t,n={}){let{start:r,end:i,markerLines:a}=L(t,e.split(I),n),o=String(i).length;return(n.highlight?n.highlight(e):e).split(I).slice(r,i).map((e,t)=>{let n=r+1+t,i=` ${` ${n}`.slice(-o)} | `,s=!!(a[n]??!1);if(s){let t=``;if(Array.isArray(s)){let n=e.slice(0,Math.max(s[0]-1,0)).replace(/[^\t]/g,` `),r=s[1]||1;t=[`
5
- `,i.replace(/\d/g,` `),n,`^`.repeat(r)].join(``)}return[`>`,i,e,t].join(``)}return` ${i}${e}`}).join(`
6
- `)}function z(e,t){let{error:n,offset:i,length:a}=t,s=new o(e).locationForIndex(i),c=s?.line??0,l=s?.column??0;return c++,l++,`${r(n)} in JSON at ${c}:${l}\n${R(e,{start:{line:c,column:l},end:{line:c,column:l+a}})}\n`}const B=e=>{try{return e instanceof Number||typeof e==`number`||Number(e)===e}catch{return!1}},V=e=>e===void 0,H=`@/#$ :;,.!?&=+-*%^~|\\"'\`{}[]()<>`.split(``),U=(e,t=2)=>{let n=B(t)?` `.repeat(t):t;switch(e){case null:return`null`;case void 0:return`"undefined"`;case!0:return`true`;case!1:return`false`;case 1/0:return`infinity`;case-1/0:return`-infinity`}if(Array.isArray(e))return`[${n}${e.map(e=>U(e,n)).join(`,${n}`)}${n}]`;if(e instanceof Uint8Array)return e.toString();switch(typeof e){case`number`:return`${e}`;case`string`:return JSON.stringify(e);case`object`:return`{${n}${Object.keys(e).filter(t=>!V(e[t])).map(t=>`${H.some(e=>t.includes(e))?`"${t}"`:t}: ${n}${U(e[t],n)}`).join(`,${n}`)}${n}}`;default:return`null`}};var W=class e extends a{static#e;static get instance(){return e.#e||=new e,e.#e}static deserialize(t){return e.instance.deserialize(t)}static serialize(t){return e.instance.serialize(t)}static parse(e){return F(e)}static stringify(t,n){let r=e.instance.customTransformerRegistry.findApplicable(t),i=t;return r&&r.isApplicable(t)&&(i=r.serialize(i)),U(i)}static parseJson(t,r){try{if(r?.expectComments===!1)return e.instance.parse(t)}catch{}let i=[],a=n(t,i,{allowTrailingComma:!0,...r});if(i.length>0&&i[0])throw Error(z(t,i[0]));return a}static register(t,n,r,i){e.instance.registerCustom({isApplicable:i,serialize:n,deserialize:r},t)}static registerClass(t,n){e.instance.registerClass(t,{identifier:E(n)?n:n?.identifier||t.name,allowProps:n&&T(n)&&n?.allowProps&&Array.isArray(n.allowProps)?n.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};W.instance.registerCustom({isApplicable:e=>i.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>i.from(e,`base64`)},`Bytes`);const ne=/^[A-Z]:\//i,G=/^[A-Z]:$/i,K=/^[/\\]{2}/,q=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;function J(e){return e.startsWith(`\\\\?\\`)?e:e.replace(/\\/g,`/`)}function Y(e){return q.test(J(e))}function X(e){return Y(e)}function Z(e=``){return e&&e.replace(/\\/g,`/`).replace(ne,e=>e.toUpperCase())}function re(e){if(!e||e.length===0)return`.`;e=Z(e);let t=e.match(K),n=X(e),r=e[e.length-1]===`/`;return e=ae(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),G.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!X(e)?`/${e}`:e)}function ie(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return re(t)}function ae(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const oe=e=>!E(e)&&B(e)&&e%1==0,se=e=>{try{return e===null}catch{return!1}},Q=e=>{try{return V(e)||se(e)}catch{return!1}},ce=e=>{try{return!Q(e)}catch{return!1}},le=e=>{try{return ce(e)&&E(e)&&e.length>0}catch{return!1}};var $=class n{#e;#t;#n;#r;#i;#a;#o=[];#s;#c;constructor(n,r={decode:!0}){if(n&&!e(n))throw TypeError(`Invalid URL: ${n}`);this.#e=r;let i=y(this.#e.decode?c(n):n),a=h(i.auth);this.#t=a.username,this.#n=a.password;let o=g(i.host);this.#r=o.hostname,this.#i=o.port,this.#a=i.protocol,this.#s=i.hash||``,this.#c=v(i.search),this.#o=i.pathname?i.pathname.split(`/`).filter(Boolean):[],r.locale&&this.#o.unshift(t((le(r.locale)?r.locale:process.env.DEFAULT_LOCALE)||`en-us`))}set params(e){this.#c=e}get params(){return this.#c}get searchParams(){let e=new URLSearchParams;for(let[t,n]of Object.entries(this.params))e.append(t,n);return e}set searchParams(e){this.params=Object.fromEntries(e.entries())}set search(e){this.params=v(e)}get search(){let e=x(this.params);return e?e.startsWith(`?`)?e:`?${e}`:``}set hash(e){this.#s=e.startsWith(`#`)?e:`#${e}`}get hash(){return this.#s}set port(e){this.#i=!V(e)&&oe(e)?`${e}`:``}get port(){return this.#i||``}set username(e){this.auth=`${e}:${this.#n}`}get username(){return this.#t||``}set password(e){this.auth=`${this.#t}:${e}`}get password(){return this.#n||``}set auth(e){let t=h(e);this.#t=t.username,this.#n=t.password}get auth(){return this.#t&&this.#n?`${this.#t}:${this.#n}`:this.#t?this.#t:this.#n?this.#n:``}set protocol(e){this.#a=e.endsWith(`:`)?e:e.endsWith(`://`)?e.slice(0,-2):`${e}:`}get protocol(){return this.#a||this.#e.defaultProtocol||`https:`}set hostname(e){this.#r=e}get hostname(){return this.#r}set host(e){let t=g(e);this.#r=t.hostname,this.#i=t.port}get host(){return this.#r&&this.#i?`${this.#r}:${this.#i}`:this.#r?this.#r:this.#i?this.#i:``}set paths(e){this.#o=e.filter(Boolean)}get paths(){return this.#o}set pathname(e){this.paths=s(e).split(`/`)}get pathname(){return`/${this.paths?ie(...this.paths.map(e=>W.stringify(e))):``}`}set path(e){let t=_(e);this.pathname=t.pathname,this.search=t.search,this.#s=t.hash}get path(){return b({pathname:this.pathname,search:this.search,hash:this.hash})}get href(){return this.toString()}set href(e){let t=y(e);this.protocol=t.protocol||this.protocol,this.auth=t.auth||this.auth,this.host=t.host||this.host,this.pathname=t.pathname||this.pathname,this.search=t.search||this.search,this.hash=t.hash||this.hash}get origin(){return`${this.protocol}//${this.host}`}get isScriptProtocol(){return p(this.protocol)}get isRelative(){return d(this.toString())}get isNonEmptyURL(){return u(this.toString())}get __typename(){return`StormURL`}isSamePath(e){return f(this.path,e)}isEqual(e){return l(this.toString(),typeof e==`string`?e:e instanceof n?e.toString():b(e))}toParsed(){return{protocol:this.protocol,auth:this.auth,host:this.host,pathname:this.pathname,search:this.search,hash:this.hash}}toString(){return b(this.toParsed())}toEncoded(){return m(this.toString())}toJSON(){return W.stringify(this.toParsed())}};W.instance.registerCustom({isApplicable:e=>e.__typename===`StormURL`,serialize:e=>e.toEncoded(),deserialize:e=>new $(e,{decode:!0})},`StormURL`);export{$ as t};
7
- //# sourceMappingURL=storm-url-DQn2usO1.mjs.map