@stryke/trpc-next 0.5.48 → 0.5.49

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 (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  3. package/dist/action-handler.cjs +20 -1
  4. package/dist/action-handler.mjs +18 -1
  5. package/dist/action-handler.mjs.map +1 -1
  6. package/dist/client.cjs +39 -1
  7. package/dist/client.mjs +37 -1
  8. package/dist/client.mjs.map +1 -1
  9. package/dist/env/src/ci-checks.cjs +13 -1
  10. package/dist/env/src/ci-checks.mjs +12 -1
  11. package/dist/env/src/ci-checks.mjs.map +1 -1
  12. package/dist/env/src/environment-checks.cjs +87 -1
  13. package/dist/env/src/environment-checks.mjs +87 -1
  14. package/dist/env/src/environment-checks.mjs.map +1 -1
  15. package/dist/index.cjs +30 -1
  16. package/dist/index.mjs +8 -1
  17. package/dist/path/src/is-type.cjs +28 -1
  18. package/dist/path/src/is-type.mjs +28 -1
  19. package/dist/path/src/is-type.mjs.map +1 -1
  20. package/dist/path/src/join-paths.cjs +106 -1
  21. package/dist/path/src/join-paths.mjs +106 -1
  22. package/dist/path/src/join-paths.mjs.map +1 -1
  23. package/dist/path/src/regex.cjs +12 -1
  24. package/dist/path/src/regex.mjs +8 -1
  25. package/dist/path/src/regex.mjs.map +1 -1
  26. package/dist/path/src/slash.cjs +15 -1
  27. package/dist/path/src/slash.mjs +14 -1
  28. package/dist/path/src/slash.mjs.map +1 -1
  29. package/dist/server.cjs +46 -1
  30. package/dist/server.mjs +33 -1
  31. package/dist/server.mjs.map +1 -1
  32. package/dist/shared.cjs +43 -1
  33. package/dist/shared.mjs +38 -1
  34. package/dist/shared.mjs.map +1 -1
  35. package/dist/shield/constructors.cjs +86 -1
  36. package/dist/shield/constructors.mjs +79 -1
  37. package/dist/shield/constructors.mjs.map +1 -1
  38. package/dist/shield/generator.cjs +28 -1
  39. package/dist/shield/generator.mjs +27 -1
  40. package/dist/shield/generator.mjs.map +1 -1
  41. package/dist/shield/index.cjs +12 -1
  42. package/dist/shield/index.mjs +4 -1
  43. package/dist/shield/rules.cjs +200 -1
  44. package/dist/shield/rules.mjs +191 -1
  45. package/dist/shield/rules.mjs.map +1 -1
  46. package/dist/shield/shield.cjs +31 -1
  47. package/dist/shield/shield.mjs +31 -1
  48. package/dist/shield/shield.mjs.map +1 -1
  49. package/dist/shield/utils.cjs +56 -1
  50. package/dist/shield/utils.mjs +51 -1
  51. package/dist/shield/utils.mjs.map +1 -1
  52. package/dist/shield/validation.cjs +59 -1
  53. package/dist/shield/validation.mjs +58 -1
  54. package/dist/shield/validation.mjs.map +1 -1
  55. package/dist/tanstack-query/client.cjs +42 -1
  56. package/dist/tanstack-query/client.mjs +41 -1
  57. package/dist/tanstack-query/client.mjs.map +1 -1
  58. package/dist/tanstack-query/server.cjs +54 -1
  59. package/dist/tanstack-query/server.mjs +51 -1
  60. package/dist/tanstack-query/server.mjs.map +1 -1
  61. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.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 { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":"sFA2BA,SAAgB,EAAe,EAAuB,CACpD,OAAO,EAAoB,KAAK,EAAM,EAAK,CAAC,CAY9C,SAAgB,EAAW,EAAuB,CAChD,OAAO,EAAe,EAAK"}
1
+ {"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.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 { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,eAAe,MAAuB;AACpD,QAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;;;;;;;;;;;AAY9C,SAAgB,WAAW,MAAuB;AAChD,QAAO,eAAe,KAAK"}
@@ -1 +1,106 @@
1
- const e=require(`./regex.cjs`),t=require(`./is-type.cjs`);function n(t=``){return t&&t.replace(/\\/g,`/`).replace(e.DRIVE_LETTER_START_REGEX,e=>e.toUpperCase())}function r(r){if(!r||r.length===0)return`.`;r=n(r);let i=r.match(e.UNC_REGEX),o=t.isAbsolute(r),s=r[r.length-1]===`/`;return r=a(r,!o),r.length===0?o?`/`:s?`./`:`.`:(s&&(r+=`/`),e.DRIVE_LETTER_REGEX.test(r)&&(r+=`/`),i?o?`//${r}`:`//./${r}`:o&&!t.isAbsolute(r)?`/${r}`:r)}function i(...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 r(t)}function a(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}exports.joinPaths=i;
1
+ const require_regex = require('./regex.cjs');
2
+ const require_is_type = require('./is-type.cjs');
3
+
4
+ //#region ../path/src/join-paths.ts
5
+ function normalizeWindowsPath(input = "") {
6
+ if (!input) return input;
7
+ return input.replace(/\\/g, "/").replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
8
+ }
9
+ function correctPaths(path) {
10
+ if (!path || path.length === 0) return ".";
11
+ path = normalizeWindowsPath(path);
12
+ const isUNCPath = path.match(require_regex.UNC_REGEX);
13
+ const isPathAbsolute = require_is_type.isAbsolute(path);
14
+ const trailingSeparator = path[path.length - 1] === "/";
15
+ path = normalizeString(path, !isPathAbsolute);
16
+ if (path.length === 0) {
17
+ if (isPathAbsolute) return "/";
18
+ return trailingSeparator ? "./" : ".";
19
+ }
20
+ if (trailingSeparator) path += "/";
21
+ if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
22
+ if (isUNCPath) {
23
+ if (!isPathAbsolute) return `//./${path}`;
24
+ return `//${path}`;
25
+ }
26
+ return isPathAbsolute && !require_is_type.isAbsolute(path) ? `/${path}` : path;
27
+ }
28
+ /**
29
+ * Joins all given path segments together using the platform-specific separator as a delimiter.
30
+ * The resulting path is normalized to remove any redundant or unnecessary segments.
31
+ *
32
+ * @param segments - The path segments to join.
33
+ * @returns The joined and normalized path string.
34
+ */
35
+ function joinPaths(...segments) {
36
+ let path = "";
37
+ for (const seg of segments) {
38
+ if (!seg) continue;
39
+ if (path.length > 0) {
40
+ const pathTrailing = path[path.length - 1] === "/";
41
+ const segLeading = seg[0] === "/";
42
+ if (pathTrailing && segLeading) path += seg.slice(1);
43
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
44
+ } else path += seg;
45
+ }
46
+ return correctPaths(path);
47
+ }
48
+ /**
49
+ * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
50
+ *
51
+ * @param path - The path to normalize.
52
+ * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
53
+ * @returns the normalized path string.
54
+ */
55
+ function normalizeString(path, allowAboveRoot) {
56
+ let res = "";
57
+ let lastSegmentLength = 0;
58
+ let lastSlash = -1;
59
+ let dots = 0;
60
+ let char = null;
61
+ for (let index = 0; index <= path.length; ++index) {
62
+ if (index < path.length) char = path[index];
63
+ else if (char === "/") break;
64
+ else char = "/";
65
+ if (char === "/") {
66
+ if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
67
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
68
+ if (res.length > 2) {
69
+ const lastSlashIndex = res.lastIndexOf("/");
70
+ if (lastSlashIndex === -1) {
71
+ res = "";
72
+ lastSegmentLength = 0;
73
+ } else {
74
+ res = res.slice(0, lastSlashIndex);
75
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
76
+ }
77
+ lastSlash = index;
78
+ dots = 0;
79
+ continue;
80
+ } else if (res.length > 0) {
81
+ res = "";
82
+ lastSegmentLength = 0;
83
+ lastSlash = index;
84
+ dots = 0;
85
+ continue;
86
+ }
87
+ }
88
+ if (allowAboveRoot) {
89
+ res += res.length > 0 ? "/.." : "..";
90
+ lastSegmentLength = 2;
91
+ }
92
+ } else {
93
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
94
+ else res = path.slice(lastSlash + 1, index);
95
+ lastSegmentLength = index - lastSlash - 1;
96
+ }
97
+ lastSlash = index;
98
+ dots = 0;
99
+ } else if (char === "." && dots !== -1) ++dots;
100
+ else dots = -1;
101
+ }
102
+ return res;
103
+ }
104
+
105
+ //#endregion
106
+ exports.joinPaths = joinPaths;
@@ -1,2 +1,107 @@
1
- import{DRIVE_LETTER_REGEX as e,DRIVE_LETTER_START_REGEX as t,UNC_REGEX as n}from"./regex.mjs";import{isAbsolute as r}from"./is-type.mjs";function i(e=``){return e&&e.replace(/\\/g,`/`).replace(t,e=>e.toUpperCase())}function a(t){if(!t||t.length===0)return`.`;t=i(t);let a=t.match(n),o=r(t),c=t[t.length-1]===`/`;return t=s(t,!o),t.length===0?o?`/`:c?`./`:`.`:(c&&(t+=`/`),e.test(t)&&(t+=`/`),a?o?`//${t}`:`//./${t}`:o&&!r(t)?`/${t}`:t)}function o(...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 a(t)}function s(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}export{o as joinPaths};
1
+ import { DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX } from "./regex.mjs";
2
+ import { isAbsolute } from "./is-type.mjs";
3
+
4
+ //#region ../path/src/join-paths.ts
5
+ function normalizeWindowsPath(input = "") {
6
+ if (!input) return input;
7
+ return input.replace(/\\/g, "/").replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
8
+ }
9
+ function correctPaths(path) {
10
+ if (!path || path.length === 0) return ".";
11
+ path = normalizeWindowsPath(path);
12
+ const isUNCPath = path.match(UNC_REGEX);
13
+ const isPathAbsolute = isAbsolute(path);
14
+ const trailingSeparator = path[path.length - 1] === "/";
15
+ path = normalizeString(path, !isPathAbsolute);
16
+ if (path.length === 0) {
17
+ if (isPathAbsolute) return "/";
18
+ return trailingSeparator ? "./" : ".";
19
+ }
20
+ if (trailingSeparator) path += "/";
21
+ if (DRIVE_LETTER_REGEX.test(path)) path += "/";
22
+ if (isUNCPath) {
23
+ if (!isPathAbsolute) return `//./${path}`;
24
+ return `//${path}`;
25
+ }
26
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
27
+ }
28
+ /**
29
+ * Joins all given path segments together using the platform-specific separator as a delimiter.
30
+ * The resulting path is normalized to remove any redundant or unnecessary segments.
31
+ *
32
+ * @param segments - The path segments to join.
33
+ * @returns The joined and normalized path string.
34
+ */
35
+ function joinPaths(...segments) {
36
+ let path = "";
37
+ for (const seg of segments) {
38
+ if (!seg) continue;
39
+ if (path.length > 0) {
40
+ const pathTrailing = path[path.length - 1] === "/";
41
+ const segLeading = seg[0] === "/";
42
+ if (pathTrailing && segLeading) path += seg.slice(1);
43
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
44
+ } else path += seg;
45
+ }
46
+ return correctPaths(path);
47
+ }
48
+ /**
49
+ * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
50
+ *
51
+ * @param path - The path to normalize.
52
+ * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
53
+ * @returns the normalized path string.
54
+ */
55
+ function normalizeString(path, allowAboveRoot) {
56
+ let res = "";
57
+ let lastSegmentLength = 0;
58
+ let lastSlash = -1;
59
+ let dots = 0;
60
+ let char = null;
61
+ for (let index = 0; index <= path.length; ++index) {
62
+ if (index < path.length) char = path[index];
63
+ else if (char === "/") break;
64
+ else char = "/";
65
+ if (char === "/") {
66
+ if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
67
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
68
+ if (res.length > 2) {
69
+ const lastSlashIndex = res.lastIndexOf("/");
70
+ if (lastSlashIndex === -1) {
71
+ res = "";
72
+ lastSegmentLength = 0;
73
+ } else {
74
+ res = res.slice(0, lastSlashIndex);
75
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
76
+ }
77
+ lastSlash = index;
78
+ dots = 0;
79
+ continue;
80
+ } else if (res.length > 0) {
81
+ res = "";
82
+ lastSegmentLength = 0;
83
+ lastSlash = index;
84
+ dots = 0;
85
+ continue;
86
+ }
87
+ }
88
+ if (allowAboveRoot) {
89
+ res += res.length > 0 ? "/.." : "..";
90
+ lastSegmentLength = 2;
91
+ }
92
+ } else {
93
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
94
+ else res = path.slice(lastSlash + 1, index);
95
+ lastSegmentLength = index - lastSlash - 1;
96
+ }
97
+ lastSlash = index;
98
+ dots = 0;
99
+ } else if (char === "." && dots !== -1) ++dots;
100
+ else dots = -1;
101
+ }
102
+ return res;
103
+ }
104
+
105
+ //#endregion
106
+ export { joinPaths };
2
107
  //# sourceMappingURL=join-paths.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"join-paths.mjs","names":["char: string | null"],"sources":["../../../../path/src/join-paths.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 { isAbsolute } from \"./is-type\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\n\n// Util to normalize windows paths to posix\nfunction normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n return input\n .replace(/\\\\/g, \"/\")\n .replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\nfunction correctPaths(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolute(path);\n const trailingSeparator = path[path.length - 1] === \"/\";\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;\n}\n\n/**\n * Joins all given path segments together using the platform-specific separator as a delimiter.\n * The resulting path is normalized to remove any redundant or unnecessary segments.\n *\n * @param segments - The path segments to join.\n * @returns The joined and normalized path string.\n */\nexport function joinPaths(...segments: string[]): string {\n let path = \"\";\n\n for (const seg of segments) {\n if (!seg) {\n continue;\n }\n if (path.length > 0) {\n const pathTrailing = path[path.length - 1] === \"/\";\n const segLeading = seg[0] === \"/\";\n const both = pathTrailing && segLeading;\n if (both) {\n path += seg.slice(1);\n } else {\n path += pathTrailing || segLeading ? seg : `/${seg}`;\n }\n } else {\n path += seg;\n }\n }\n\n return correctPaths(path);\n}\n\nexport const join = joinPaths;\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalized path string.\n */\nfunction normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n"],"mappings":"yIA0BA,SAAS,EAAqB,EAAQ,GAAI,CAIxC,OAHK,GAGE,EACJ,QAAQ,MAAO,IAAI,CACnB,QAAQ,EAA0B,GAAK,EAAE,aAAa,CAAC,CAG5D,SAAS,EAAa,EAAe,CACnC,GAAI,CAAC,GAAQ,EAAK,SAAW,EAC3B,MAAO,IAIT,EAAO,EAAqB,EAAK,CAEjC,IAAM,EAAY,EAAK,MAAM,EAAU,CACjC,EAAiB,EAAW,EAAK,CACjC,EAAoB,EAAK,EAAK,OAAS,KAAO,IAyBpD,MAtBA,GAAO,EAAgB,EAAM,CAAC,EAAe,CAEzC,EAAK,SAAW,EACd,EACK,IAEF,EAAoB,KAAO,KAEhC,IACF,GAAQ,KAEN,EAAmB,KAAK,EAAK,GAC/B,GAAQ,KAGN,EACG,EAGE,KAAK,IAFH,OAAO,IAKX,GAAkB,CAAC,EAAW,EAAK,CAAG,IAAI,IAAS,GAU5D,SAAgB,EAAU,GAAG,EAA4B,CACvD,IAAI,EAAO,GAEX,IAAK,IAAM,KAAO,EACX,KAGL,GAAI,EAAK,OAAS,EAAG,CACnB,IAAM,EAAe,EAAK,EAAK,OAAS,KAAO,IACzC,EAAa,EAAI,KAAO,IACjB,GAAgB,EAE3B,GAAQ,EAAI,MAAM,EAAE,CAEpB,GAAQ,GAAgB,EAAa,EAAM,IAAI,SAGjD,GAAQ,EAIZ,OAAO,EAAa,EAAK,CAY3B,SAAS,EAAgB,EAAc,EAAyB,CAC9D,IAAI,EAAM,GACN,EAAoB,EACpB,EAAY,GACZ,EAAO,EACPA,EAAsB,KAC1B,IAAK,IAAI,EAAQ,EAAG,GAAS,EAAK,OAAQ,EAAE,EAAO,CACjD,GAAI,EAAQ,EAAK,OAEf,EAAO,EAAK,WACH,IAAS,IAClB,WAEA,EAAO,IAET,GAAI,IAAS,IAAK,CAChB,GAAI,MAAc,EAAQ,GAAK,IAAS,GAAG,GAEhC,IAAS,EAAG,CACrB,GACE,EAAI,OAAS,GACb,IAAsB,GACtB,EAAI,EAAI,OAAS,KAAO,KACxB,EAAI,EAAI,OAAS,KAAO,QAEpB,EAAI,OAAS,EAAG,CAClB,IAAM,EAAiB,EAAI,YAAY,IAAI,CACvC,IAAmB,IACrB,EAAM,GACN,EAAoB,IAEpB,EAAM,EAAI,MAAM,EAAG,EAAe,CAClC,EAAoB,EAAI,OAAS,EAAI,EAAI,YAAY,IAAI,EAE3D,EAAY,EACZ,EAAO,EACP,iBACS,EAAI,OAAS,EAAG,CACzB,EAAM,GACN,EAAoB,EACpB,EAAY,EACZ,EAAO,EACP,UAGA,IACF,GAAO,EAAI,OAAS,EAAI,MAAQ,KAChC,EAAoB,QAGlB,EAAI,OAAS,EACf,GAAO,IAAI,EAAK,MAAM,EAAY,EAAG,EAAM,GAE3C,EAAM,EAAK,MAAM,EAAY,EAAG,EAAM,CAExC,EAAoB,EAAQ,EAAY,EAE1C,EAAY,EACZ,EAAO,OACE,IAAS,KAAO,IAAS,GAClC,EAAE,EAEF,EAAO,GAGX,OAAO"}
1
+ {"version":3,"file":"join-paths.mjs","names":["char: string | null"],"sources":["../../../../path/src/join-paths.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 { isAbsolute } from \"./is-type\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\n\n// Util to normalize windows paths to posix\nfunction normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n return input\n .replace(/\\\\/g, \"/\")\n .replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\nfunction correctPaths(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolute(path);\n const trailingSeparator = path[path.length - 1] === \"/\";\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;\n}\n\n/**\n * Joins all given path segments together using the platform-specific separator as a delimiter.\n * The resulting path is normalized to remove any redundant or unnecessary segments.\n *\n * @param segments - The path segments to join.\n * @returns The joined and normalized path string.\n */\nexport function joinPaths(...segments: string[]): string {\n let path = \"\";\n\n for (const seg of segments) {\n if (!seg) {\n continue;\n }\n if (path.length > 0) {\n const pathTrailing = path[path.length - 1] === \"/\";\n const segLeading = seg[0] === \"/\";\n const both = pathTrailing && segLeading;\n if (both) {\n path += seg.slice(1);\n } else {\n path += pathTrailing || segLeading ? seg : `/${seg}`;\n }\n } else {\n path += seg;\n }\n }\n\n return correctPaths(path);\n}\n\nexport const join = joinPaths;\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalized path string.\n */\nfunction normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n"],"mappings":";;;;AA0BA,SAAS,qBAAqB,QAAQ,IAAI;AACxC,KAAI,CAAC,MACH,QAAO;AAET,QAAO,MACJ,QAAQ,OAAO,IAAI,CACnB,QAAQ,2BAA0B,MAAK,EAAE,aAAa,CAAC;;AAG5D,SAAS,aAAa,MAAe;AACnC,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAIT,QAAO,qBAAqB,KAAK;CAEjC,MAAM,YAAY,KAAK,MAAM,UAAU;CACvC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,oBAAoB,KAAK,KAAK,SAAS,OAAO;AAGpD,QAAO,gBAAgB,MAAM,CAAC,eAAe;AAE7C,KAAI,KAAK,WAAW,GAAG;AACrB,MAAI,eACF,QAAO;AAET,SAAO,oBAAoB,OAAO;;AAEpC,KAAI,kBACF,SAAQ;AAEV,KAAI,mBAAmB,KAAK,KAAK,CAC/B,SAAQ;AAGV,KAAI,WAAW;AACb,MAAI,CAAC,eACH,QAAO,OAAO;AAEhB,SAAO,KAAK;;AAGd,QAAO,kBAAkB,CAAC,WAAW,KAAK,GAAG,IAAI,SAAS;;;;;;;;;AAU5D,SAAgB,UAAU,GAAG,UAA4B;CACvD,IAAI,OAAO;AAEX,MAAK,MAAM,OAAO,UAAU;AAC1B,MAAI,CAAC,IACH;AAEF,MAAI,KAAK,SAAS,GAAG;GACnB,MAAM,eAAe,KAAK,KAAK,SAAS,OAAO;GAC/C,MAAM,aAAa,IAAI,OAAO;AAE9B,OADa,gBAAgB,WAE3B,SAAQ,IAAI,MAAM,EAAE;OAEpB,SAAQ,gBAAgB,aAAa,MAAM,IAAI;QAGjD,SAAQ;;AAIZ,QAAO,aAAa,KAAK;;;;;;;;;AAY3B,SAAS,gBAAgB,MAAc,gBAAyB;CAC9D,IAAI,MAAM;CACV,IAAI,oBAAoB;CACxB,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAIA,OAAsB;AAC1B,MAAK,IAAI,QAAQ,GAAG,SAAS,KAAK,QAAQ,EAAE,OAAO;AACjD,MAAI,QAAQ,KAAK,OAEf,QAAO,KAAK;WACH,SAAS,IAClB;MAEA,QAAO;AAET,MAAI,SAAS,KAAK;AAChB,OAAI,cAAc,QAAQ,KAAK,SAAS,GAAG,YAEhC,SAAS,GAAG;AACrB,QACE,IAAI,SAAS,KACb,sBAAsB,KACtB,IAAI,IAAI,SAAS,OAAO,OACxB,IAAI,IAAI,SAAS,OAAO,KAExB;SAAI,IAAI,SAAS,GAAG;MAClB,MAAM,iBAAiB,IAAI,YAAY,IAAI;AAC3C,UAAI,mBAAmB,IAAI;AACzB,aAAM;AACN,2BAAoB;aACf;AACL,aAAM,IAAI,MAAM,GAAG,eAAe;AAClC,2BAAoB,IAAI,SAAS,IAAI,IAAI,YAAY,IAAI;;AAE3D,kBAAY;AACZ,aAAO;AACP;gBACS,IAAI,SAAS,GAAG;AACzB,YAAM;AACN,0BAAoB;AACpB,kBAAY;AACZ,aAAO;AACP;;;AAGJ,QAAI,gBAAgB;AAClB,YAAO,IAAI,SAAS,IAAI,QAAQ;AAChC,yBAAoB;;UAEjB;AACL,QAAI,IAAI,SAAS,EACf,QAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM;QAE3C,OAAM,KAAK,MAAM,YAAY,GAAG,MAAM;AAExC,wBAAoB,QAAQ,YAAY;;AAE1C,eAAY;AACZ,UAAO;aACE,SAAS,OAAO,SAAS,GAClC,GAAE;MAEF,QAAO;;AAGX,QAAO"}
@@ -1 +1,12 @@
1
- const e=/^[A-Z]:\//i,t=/^[A-Z]:$/i,n=/^[/\\]{2}/,r=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;exports.ABSOLUTE_PATH_REGEX=r,exports.DRIVE_LETTER_REGEX=t,exports.DRIVE_LETTER_START_REGEX=e,exports.UNC_REGEX=n;
1
+
2
+ //#region ../path/src/regex.ts
3
+ const DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
4
+ const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
5
+ const UNC_REGEX = /^[/\\]{2}/;
6
+ const ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
7
+
8
+ //#endregion
9
+ exports.ABSOLUTE_PATH_REGEX = ABSOLUTE_PATH_REGEX;
10
+ exports.DRIVE_LETTER_REGEX = DRIVE_LETTER_REGEX;
11
+ exports.DRIVE_LETTER_START_REGEX = DRIVE_LETTER_START_REGEX;
12
+ exports.UNC_REGEX = UNC_REGEX;
@@ -1,2 +1,9 @@
1
- const e=/^[A-Z]:\//i,t=/^[A-Z]:$/i,n=/^[/\\]{2}/,r=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;export{r as ABSOLUTE_PATH_REGEX,t as DRIVE_LETTER_REGEX,e as DRIVE_LETTER_START_REGEX,n as UNC_REGEX};
1
+ //#region ../path/src/regex.ts
2
+ const DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
3
+ const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
4
+ const UNC_REGEX = /^[/\\]{2}/;
5
+ const ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
6
+
7
+ //#endregion
8
+ export { ABSOLUTE_PATH_REGEX, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX };
2
9
  //# sourceMappingURL=regex.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"regex.mjs","names":[],"sources":["../../../../path/src/regex.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 DRIVE_LETTER_START_REGEX = /^[A-Z]:\\//i;\nexport const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;\n\nexport const UNC_REGEX = /^[/\\\\]{2}/;\n\nexport const ABSOLUTE_PATH_REGEX =\n /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^~[/\\\\]|^[A-Z]:[/\\\\]/i;\n\nexport const ROOT_FOLDER_REGEX = /^\\/([A-Z]:)?$/i;\n\nexport const FILE_EXTENSION_REGEX = /\\.[0-9a-z]+$/i;\n\nexport const PACKAGE_PATH_REGEX = /^@\\w+\\/.*$/;\nexport const NPM_SCOPED_PACKAGE_REGEX = /^(?:@[\\w-]+\\/)?[\\w-]+$/;\n"],"mappings":"AAkBA,MAAa,EAA2B,aAC3B,EAAqB,YAErB,EAAY,YAEZ,EACX"}
1
+ {"version":3,"file":"regex.mjs","names":[],"sources":["../../../../path/src/regex.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 DRIVE_LETTER_START_REGEX = /^[A-Z]:\\//i;\nexport const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;\n\nexport const UNC_REGEX = /^[/\\\\]{2}/;\n\nexport const ABSOLUTE_PATH_REGEX =\n /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^~[/\\\\]|^[A-Z]:[/\\\\]/i;\n\nexport const ROOT_FOLDER_REGEX = /^\\/([A-Z]:)?$/i;\n\nexport const FILE_EXTENSION_REGEX = /\\.[0-9a-z]+$/i;\n\nexport const PACKAGE_PATH_REGEX = /^@\\w+\\/.*$/;\nexport const NPM_SCOPED_PACKAGE_REGEX = /^(?:@[\\w-]+\\/)?[\\w-]+$/;\n"],"mappings":";AAkBA,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAElC,MAAa,YAAY;AAEzB,MAAa,sBACX"}
@@ -1 +1,15 @@
1
- function e(e){return e.startsWith(`\\\\?\\`)?e:e.replace(/\\/g,`/`)}exports.slash=e;
1
+
2
+ //#region ../path/src/slash.ts
3
+ /**
4
+ * Replace backslash to slash
5
+ *
6
+ * @param path - The string to replace
7
+ * @returns The string with replaced backslashes
8
+ */
9
+ function slash(path) {
10
+ if (path.startsWith("\\\\?\\")) return path;
11
+ return path.replace(/\\/g, "/");
12
+ }
13
+
14
+ //#endregion
15
+ exports.slash = slash;
@@ -1,2 +1,15 @@
1
- function e(e){return e.startsWith(`\\\\?\\`)?e:e.replace(/\\/g,`/`)}export{e as slash};
1
+ //#region ../path/src/slash.ts
2
+ /**
3
+ * Replace backslash to slash
4
+ *
5
+ * @param path - The string to replace
6
+ * @returns The string with replaced backslashes
7
+ */
8
+ function slash(path) {
9
+ if (path.startsWith("\\\\?\\")) return path;
10
+ return path.replace(/\\/g, "/");
11
+ }
12
+
13
+ //#endregion
14
+ export { slash };
2
15
  //# sourceMappingURL=slash.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"slash.mjs","names":[],"sources":["../../../../path/src/slash.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 { isAbsolutePath } from \"./is-type\";\n\n/**\n * Replace backslash to slash\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function slash(path: string) {\n if (path.startsWith(\"\\\\\\\\?\\\\\")) {\n return path;\n }\n\n return path.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Replace backslash to slash and remove unneeded leading and trailing slashes\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function formatSlash(path: string) {\n const formatted = slash(path);\n\n return isAbsolutePath(formatted)\n ? formatted.replace(/\\/+$/g, \"\")\n : formatted.replace(/^\\.\\//g, \"\").replace(/\\/+$/g, \"\");\n}\n"],"mappings":"AA0BA,SAAgB,EAAM,EAAc,CAKlC,OAJI,EAAK,WAAW,UAAU,CACrB,EAGF,EAAK,QAAQ,MAAO,IAAI"}
1
+ {"version":3,"file":"slash.mjs","names":[],"sources":["../../../../path/src/slash.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 { isAbsolutePath } from \"./is-type\";\n\n/**\n * Replace backslash to slash\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function slash(path: string) {\n if (path.startsWith(\"\\\\\\\\?\\\\\")) {\n return path;\n }\n\n return path.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Replace backslash to slash and remove unneeded leading and trailing slashes\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function formatSlash(path: string) {\n const formatted = slash(path);\n\n return isAbsolutePath(formatted)\n ? formatted.replace(/\\/+$/g, \"\")\n : formatted.replace(/^\\.\\//g, \"\").replace(/\\/+$/g, \"\");\n}\n"],"mappings":";;;;;;;AA0BA,SAAgB,MAAM,MAAc;AAClC,KAAI,KAAK,WAAW,UAAU,CAC5B,QAAO;AAGT,QAAO,KAAK,QAAQ,OAAO,IAAI"}
package/dist/server.cjs CHANGED
@@ -1 +1,46 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./shared.cjs`);let n=require(`@trpc/next/app-dir/server`),r=require(`@trpc/client`),i=require(`@trpc/next/app-dir/links/nextCache`),a=require(`@trpc/server/adapters/next-app-dir`);function o(e,a,o=()=>({})){return(0,n.experimental_createTRPCNextAppDirServer)({config(){return{links:[(0,r.loggerLink)({enabled:e=>!0}),(0,i.experimental_nextCacheLink)({revalidate:5,router:a,transformer:t.transformer,createContext:async()=>{let t=await Promise.resolve(o());return t.headers??={},t.headers[`x-trpc-source`]=`rsc-invoke`,t.headers.cookie=(await e()).toString(),t}})]}}})}exports.createTRPCServer=o,Object.defineProperty(exports,`notFound`,{enumerable:!0,get:function(){return a.experimental_notFound}}),Object.defineProperty(exports,`redirect`,{enumerable:!0,get:function(){return a.experimental_redirect}});
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_shared = require('./shared.cjs');
3
+ let __trpc_next_app_dir_server = require("@trpc/next/app-dir/server");
4
+ let __trpc_client = require("@trpc/client");
5
+ let __trpc_next_app_dir_links_nextCache = require("@trpc/next/app-dir/links/nextCache");
6
+ let __trpc_server_adapters_next_app_dir = require("@trpc/server/adapters/next-app-dir");
7
+
8
+ //#region src/server.ts
9
+ /**
10
+ * This client invokes procedures directly on the server without fetching over HTTP.
11
+ *
12
+ * @param cookies - A function that returns the cookies
13
+ * @param router - The router created by the user
14
+ * @param createContext - An optional function to generate a context
15
+ */
16
+ function createTRPCServer(cookies, router, createContext = () => ({})) {
17
+ return (0, __trpc_next_app_dir_server.experimental_createTRPCNextAppDirServer)({ config() {
18
+ return { links: [(0, __trpc_client.loggerLink)({ enabled: (_op) => true }), (0, __trpc_next_app_dir_links_nextCache.experimental_nextCacheLink)({
19
+ revalidate: 5,
20
+ router,
21
+ transformer: require_shared.transformer,
22
+ createContext: async () => {
23
+ const context = await Promise.resolve(createContext());
24
+ context.headers ??= {};
25
+ context.headers["x-trpc-source"] = "rsc-invoke";
26
+ context.headers.cookie = (await cookies()).toString();
27
+ return context;
28
+ }
29
+ })] };
30
+ } });
31
+ }
32
+
33
+ //#endregion
34
+ exports.createTRPCServer = createTRPCServer;
35
+ Object.defineProperty(exports, 'notFound', {
36
+ enumerable: true,
37
+ get: function () {
38
+ return __trpc_server_adapters_next_app_dir.experimental_notFound;
39
+ }
40
+ });
41
+ Object.defineProperty(exports, 'redirect', {
42
+ enumerable: true,
43
+ get: function () {
44
+ return __trpc_server_adapters_next_app_dir.experimental_redirect;
45
+ }
46
+ });
package/dist/server.mjs CHANGED
@@ -1,2 +1,34 @@
1
- import{transformer as e}from"./shared.mjs";import{experimental_createTRPCNextAppDirServer as t}from"@trpc/next/app-dir/server";import{loggerLink as n}from"@trpc/client";import{experimental_nextCacheLink as r}from"@trpc/next/app-dir/links/nextCache";import{experimental_notFound as i,experimental_redirect as a}from"@trpc/server/adapters/next-app-dir";function o(i,a,o=()=>({})){return t({config(){return{links:[n({enabled:e=>!0}),r({revalidate:5,router:a,transformer:e,createContext:async()=>{let e=await Promise.resolve(o());return e.headers??={},e.headers[`x-trpc-source`]=`rsc-invoke`,e.headers.cookie=(await i()).toString(),e}})]}}})}export{o as createTRPCServer,i as notFound,a as redirect};
1
+ import { transformer } from "./shared.mjs";
2
+ import { experimental_createTRPCNextAppDirServer } from "@trpc/next/app-dir/server";
3
+ import { loggerLink } from "@trpc/client";
4
+ import { experimental_nextCacheLink } from "@trpc/next/app-dir/links/nextCache";
5
+ import { experimental_notFound as notFound, experimental_redirect as redirect } from "@trpc/server/adapters/next-app-dir";
6
+
7
+ //#region src/server.ts
8
+ /**
9
+ * This client invokes procedures directly on the server without fetching over HTTP.
10
+ *
11
+ * @param cookies - A function that returns the cookies
12
+ * @param router - The router created by the user
13
+ * @param createContext - An optional function to generate a context
14
+ */
15
+ function createTRPCServer(cookies, router, createContext = () => ({})) {
16
+ return experimental_createTRPCNextAppDirServer({ config() {
17
+ return { links: [loggerLink({ enabled: (_op) => true }), experimental_nextCacheLink({
18
+ revalidate: 5,
19
+ router,
20
+ transformer,
21
+ createContext: async () => {
22
+ const context = await Promise.resolve(createContext());
23
+ context.headers ??= {};
24
+ context.headers["x-trpc-source"] = "rsc-invoke";
25
+ context.headers.cookie = (await cookies()).toString();
26
+ return context;
27
+ }
28
+ })] };
29
+ } });
30
+ }
31
+
32
+ //#endregion
33
+ export { createTRPCServer, notFound, redirect };
2
34
  //# sourceMappingURL=server.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.mjs","names":[],"sources":["../src/server.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 camelcase */\n\n/* -------------------------------------------------------------------\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.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { MaybePromise } from \"@stryke/types\";\nimport type { Resolver } from \"@trpc/client\";\nimport { loggerLink } from \"@trpc/client\";\nimport { experimental_nextCacheLink } from \"@trpc/next/app-dir/links/nextCache\";\nimport { experimental_createTRPCNextAppDirServer } from \"@trpc/next/app-dir/server\";\nimport type { AnyTRPCRouter, inferRouterContext } from \"@trpc/server\";\nimport type {\n AnyProcedure,\n AnyRootTypes,\n inferProcedureInput,\n inferTransformedProcedureOutput,\n ProcedureType,\n RouterRecord\n} from \"@trpc/server/unstable-core-do-not-import\";\nimport type { FeatureFlags, ResolverDef } from \"@trpc/tanstack-react-query\";\nimport type { ReadonlyRequestCookies } from \"next/dist/server/web/spec-extension/adapters/request-cookies\";\nimport { transformer } from \"./shared\";\n\nexport type DecorateProcedureServer<\n TType extends ProcedureType,\n TDef extends ResolverDef\n> = TType extends \"query\"\n ? {\n query: Resolver<TDef>;\n revalidate: (\n input?: TDef[\"input\"]\n ) => Promise<\n { revalidated: false; error: string } | { revalidated: true }\n >;\n }\n : TType extends \"mutation\"\n ? {\n mutate: Resolver<TDef>;\n }\n : TType extends \"subscription\"\n ? {\n subscribe: Resolver<TDef>;\n }\n : never;\n\nexport type NextAppDirDecorateRouterRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedureServer<\n $Value[\"_def\"][\"type\"],\n {\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput<TRoot, $Value>;\n errorShape: TRoot[\"errorShape\"];\n transformer: TRoot[\"transformer\"];\n featureFlags: FeatureFlags;\n }\n >\n : $Value extends RouterRecord\n ? NextAppDirDecorateRouterRecord<TRoot, $Value>\n : never\n : never;\n};\n\n/**\n * This client invokes procedures directly on the server without fetching over HTTP.\n *\n * @param cookies - A function that returns the cookies\n * @param router - The router created by the user\n * @param createContext - An optional function to generate a context\n */\nexport function createTRPCServer<\n TRouter extends AnyTRPCRouter,\n TContext extends inferRouterContext<TRouter> = inferRouterContext<TRouter>\n>(\n cookies: () => Promise<ReadonlyRequestCookies>,\n router: TRouter,\n createContext: () => MaybePromise<TContext> = () => ({}) as TContext\n) {\n return experimental_createTRPCNextAppDirServer<TRouter>({\n config() {\n return {\n links: [\n loggerLink({\n enabled: _op => true\n }),\n experimental_nextCacheLink({\n // requests are cached for 5 seconds\n revalidate: 5,\n router,\n transformer,\n createContext: async () => {\n const context = await Promise.resolve(createContext());\n\n context.headers ??= {};\n context.headers[\"x-trpc-source\"] = \"rsc-invoke\";\n context.headers.cookie = (await cookies()).toString();\n\n return context;\n }\n })\n ]\n };\n }\n }) as NextAppDirDecorateRouterRecord<\n TRouter[\"_def\"][\"_config\"][\"$types\"],\n TRouter[\"_def\"][\"record\"]\n >;\n}\n\nexport {\n experimental_notFound as notFound,\n experimental_redirect as redirect\n} from \"@trpc/server/adapters/next-app-dir\";\n"],"mappings":"+VA0GA,SAAgB,EAId,EACA,EACA,OAAqD,EAAE,EACvD,CACA,OAAO,EAAiD,CACtD,QAAS,CACP,MAAO,CACL,MAAO,CACL,EAAW,CACT,QAAS,GAAO,GACjB,CAAC,CACF,EAA2B,CAEzB,WAAY,EACZ,SACA,cACA,cAAe,SAAY,CACzB,IAAM,EAAU,MAAM,QAAQ,QAAQ,GAAe,CAAC,CAMtD,MAJA,GAAQ,UAAY,EAAE,CACtB,EAAQ,QAAQ,iBAAmB,aACnC,EAAQ,QAAQ,QAAU,MAAM,GAAS,EAAE,UAAU,CAE9C,GAEV,CAAC,CACH,CACF,EAEJ,CAAC"}
1
+ {"version":3,"file":"server.mjs","names":[],"sources":["../src/server.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 camelcase */\n\n/* -------------------------------------------------------------------\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.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nimport type { MaybePromise } from \"@stryke/types\";\nimport type { Resolver } from \"@trpc/client\";\nimport { loggerLink } from \"@trpc/client\";\nimport { experimental_nextCacheLink } from \"@trpc/next/app-dir/links/nextCache\";\nimport { experimental_createTRPCNextAppDirServer } from \"@trpc/next/app-dir/server\";\nimport type { AnyTRPCRouter, inferRouterContext } from \"@trpc/server\";\nimport type {\n AnyProcedure,\n AnyRootTypes,\n inferProcedureInput,\n inferTransformedProcedureOutput,\n ProcedureType,\n RouterRecord\n} from \"@trpc/server/unstable-core-do-not-import\";\nimport type { FeatureFlags, ResolverDef } from \"@trpc/tanstack-react-query\";\nimport type { ReadonlyRequestCookies } from \"next/dist/server/web/spec-extension/adapters/request-cookies\";\nimport { transformer } from \"./shared\";\n\nexport type DecorateProcedureServer<\n TType extends ProcedureType,\n TDef extends ResolverDef\n> = TType extends \"query\"\n ? {\n query: Resolver<TDef>;\n revalidate: (\n input?: TDef[\"input\"]\n ) => Promise<\n { revalidated: false; error: string } | { revalidated: true }\n >;\n }\n : TType extends \"mutation\"\n ? {\n mutate: Resolver<TDef>;\n }\n : TType extends \"subscription\"\n ? {\n subscribe: Resolver<TDef>;\n }\n : never;\n\nexport type NextAppDirDecorateRouterRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedureServer<\n $Value[\"_def\"][\"type\"],\n {\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput<TRoot, $Value>;\n errorShape: TRoot[\"errorShape\"];\n transformer: TRoot[\"transformer\"];\n featureFlags: FeatureFlags;\n }\n >\n : $Value extends RouterRecord\n ? NextAppDirDecorateRouterRecord<TRoot, $Value>\n : never\n : never;\n};\n\n/**\n * This client invokes procedures directly on the server without fetching over HTTP.\n *\n * @param cookies - A function that returns the cookies\n * @param router - The router created by the user\n * @param createContext - An optional function to generate a context\n */\nexport function createTRPCServer<\n TRouter extends AnyTRPCRouter,\n TContext extends inferRouterContext<TRouter> = inferRouterContext<TRouter>\n>(\n cookies: () => Promise<ReadonlyRequestCookies>,\n router: TRouter,\n createContext: () => MaybePromise<TContext> = () => ({}) as TContext\n) {\n return experimental_createTRPCNextAppDirServer<TRouter>({\n config() {\n return {\n links: [\n loggerLink({\n enabled: _op => true\n }),\n experimental_nextCacheLink({\n // requests are cached for 5 seconds\n revalidate: 5,\n router,\n transformer,\n createContext: async () => {\n const context = await Promise.resolve(createContext());\n\n context.headers ??= {};\n context.headers[\"x-trpc-source\"] = \"rsc-invoke\";\n context.headers.cookie = (await cookies()).toString();\n\n return context;\n }\n })\n ]\n };\n }\n }) as NextAppDirDecorateRouterRecord<\n TRouter[\"_def\"][\"_config\"][\"$types\"],\n TRouter[\"_def\"][\"record\"]\n >;\n}\n\nexport {\n experimental_notFound as notFound,\n experimental_redirect as redirect\n} from \"@trpc/server/adapters/next-app-dir\";\n"],"mappings":";;;;;;;;;;;;;;AA0GA,SAAgB,iBAId,SACA,QACA,uBAAqD,EAAE,GACvD;AACA,QAAO,wCAAiD,EACtD,SAAS;AACP,SAAO,EACL,OAAO,CACL,WAAW,EACT,UAAS,QAAO,MACjB,CAAC,EACF,2BAA2B;GAEzB,YAAY;GACZ;GACA;GACA,eAAe,YAAY;IACzB,MAAM,UAAU,MAAM,QAAQ,QAAQ,eAAe,CAAC;AAEtD,YAAQ,YAAY,EAAE;AACtB,YAAQ,QAAQ,mBAAmB;AACnC,YAAQ,QAAQ,UAAU,MAAM,SAAS,EAAE,UAAU;AAErD,WAAO;;GAEV,CAAC,CACH,EACF;IAEJ,CAAC"}
package/dist/shared.cjs CHANGED
@@ -1 +1,43 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/join-paths.cjs`);let n=require(`defu`);n=e.__toESM(n);let r=require(`@js-temporal/polyfill`),i=require(`@tanstack/react-query`),a=require(`superjson`);a=e.__toESM(a);function o(e,n=1){return t.joinPaths(typeof e==`string`?e:e.host||``,`api`,n?`v${n}`:``,`trpc`)}a.default.registerCustom({isApplicable:e=>e instanceof r.Temporal.PlainDate,serialize:e=>e.toJSON(),deserialize:e=>r.Temporal.PlainDate.from(e)},`Temporal.PlainDate`),a.default.registerCustom({isApplicable:e=>e instanceof r.Temporal.PlainDateTime,serialize:e=>e.toJSON(),deserialize:e=>r.Temporal.PlainDateTime.from(e)},`Temporal.PlainDateTime`);const s=a.default,c=(e={})=>new i.QueryClient((0,n.default)(e,{defaultOptions:{queries:{staleTime:1e3*30},dehydrate:{shouldDehydrateQuery:e=>(0,i.defaultShouldDehydrateQuery)(e)||e.state.status===`pending`,serializeData:s.serialize},hydrate:{deserializeData:s.deserialize}}}));exports.createQueryClient=c,exports.getTRPCServerUrl=o,exports.transformer=s;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_join_paths = require('./path/src/join-paths.cjs');
3
+ let defu = require("defu");
4
+ defu = require_rolldown_runtime.__toESM(defu);
5
+ let __js_temporal_polyfill = require("@js-temporal/polyfill");
6
+ let __tanstack_react_query = require("@tanstack/react-query");
7
+ let superjson = require("superjson");
8
+ superjson = require_rolldown_runtime.__toESM(superjson);
9
+
10
+ //#region src/shared.ts
11
+ function getTRPCServerUrl(baseUrl, version = 1) {
12
+ return require_join_paths.joinPaths(typeof baseUrl === "string" ? baseUrl : baseUrl.host || "", "api", version ? `v${version}` : "", "trpc");
13
+ }
14
+ superjson.default.registerCustom({
15
+ isApplicable: (v) => v instanceof __js_temporal_polyfill.Temporal.PlainDate,
16
+ serialize: (v) => v.toJSON(),
17
+ deserialize: (v) => __js_temporal_polyfill.Temporal.PlainDate.from(v)
18
+ }, "Temporal.PlainDate");
19
+ superjson.default.registerCustom({
20
+ isApplicable: (v) => v instanceof __js_temporal_polyfill.Temporal.PlainDateTime,
21
+ serialize: (v) => v.toJSON(),
22
+ deserialize: (v) => __js_temporal_polyfill.Temporal.PlainDateTime.from(v)
23
+ }, "Temporal.PlainDateTime");
24
+ const transformer = superjson.default;
25
+ /**
26
+ * Create a TRPC Tanstack Query client.
27
+ *
28
+ * @param queryClientConfig - The query client config
29
+ * @returns The TRPC Tanstack Query client
30
+ */
31
+ const createQueryClient = (queryClientConfig = {}) => new __tanstack_react_query.QueryClient((0, defu.default)(queryClientConfig, { defaultOptions: {
32
+ queries: { staleTime: 1e3 * 30 },
33
+ dehydrate: {
34
+ shouldDehydrateQuery: (query) => (0, __tanstack_react_query.defaultShouldDehydrateQuery)(query) || query.state.status === "pending",
35
+ serializeData: transformer.serialize
36
+ },
37
+ hydrate: { deserializeData: transformer.deserialize }
38
+ } }));
39
+
40
+ //#endregion
41
+ exports.createQueryClient = createQueryClient;
42
+ exports.getTRPCServerUrl = getTRPCServerUrl;
43
+ exports.transformer = transformer;
package/dist/shared.mjs CHANGED
@@ -1,2 +1,39 @@
1
- import{joinPaths as e}from"./path/src/join-paths.mjs";import t from"defu";import{Temporal as n}from"@js-temporal/polyfill";import{QueryClient as r,defaultShouldDehydrateQuery as i}from"@tanstack/react-query";import a from"superjson";function o(t,n=1){return e(typeof t==`string`?t:t.host||``,`api`,n?`v${n}`:``,`trpc`)}a.registerCustom({isApplicable:e=>e instanceof n.PlainDate,serialize:e=>e.toJSON(),deserialize:e=>n.PlainDate.from(e)},`Temporal.PlainDate`),a.registerCustom({isApplicable:e=>e instanceof n.PlainDateTime,serialize:e=>e.toJSON(),deserialize:e=>n.PlainDateTime.from(e)},`Temporal.PlainDateTime`);const s=a,c=(e={})=>new r(t(e,{defaultOptions:{queries:{staleTime:1e3*30},dehydrate:{shouldDehydrateQuery:e=>i(e)||e.state.status===`pending`,serializeData:s.serialize},hydrate:{deserializeData:s.deserialize}}}));export{c as createQueryClient,o as getTRPCServerUrl,s as transformer};
1
+ import { joinPaths } from "./path/src/join-paths.mjs";
2
+ import defu from "defu";
3
+ import { Temporal } from "@js-temporal/polyfill";
4
+ import { QueryClient, defaultShouldDehydrateQuery } from "@tanstack/react-query";
5
+ import superjson from "superjson";
6
+
7
+ //#region src/shared.ts
8
+ function getTRPCServerUrl(baseUrl, version = 1) {
9
+ return joinPaths(typeof baseUrl === "string" ? baseUrl : baseUrl.host || "", "api", version ? `v${version}` : "", "trpc");
10
+ }
11
+ superjson.registerCustom({
12
+ isApplicable: (v) => v instanceof Temporal.PlainDate,
13
+ serialize: (v) => v.toJSON(),
14
+ deserialize: (v) => Temporal.PlainDate.from(v)
15
+ }, "Temporal.PlainDate");
16
+ superjson.registerCustom({
17
+ isApplicable: (v) => v instanceof Temporal.PlainDateTime,
18
+ serialize: (v) => v.toJSON(),
19
+ deserialize: (v) => Temporal.PlainDateTime.from(v)
20
+ }, "Temporal.PlainDateTime");
21
+ const transformer = superjson;
22
+ /**
23
+ * Create a TRPC Tanstack Query client.
24
+ *
25
+ * @param queryClientConfig - The query client config
26
+ * @returns The TRPC Tanstack Query client
27
+ */
28
+ const createQueryClient = (queryClientConfig = {}) => new QueryClient(defu(queryClientConfig, { defaultOptions: {
29
+ queries: { staleTime: 1e3 * 30 },
30
+ dehydrate: {
31
+ shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === "pending",
32
+ serializeData: transformer.serialize
33
+ },
34
+ hydrate: { deserializeData: transformer.deserialize }
35
+ } }));
36
+
37
+ //#endregion
38
+ export { createQueryClient, getTRPCServerUrl, transformer };
2
39
  //# sourceMappingURL=shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.mjs","names":[],"sources":["../src/shared.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 { Temporal } from \"@js-temporal/polyfill\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { StormURLInterface } from \"@stryke/url/types\";\nimport type { QueryClientConfig } from \"@tanstack/react-query\";\nimport {\n defaultShouldDehydrateQuery,\n QueryClient\n} from \"@tanstack/react-query\";\nimport type { DataTransformer } from \"@trpc/server/unstable-core-do-not-import\";\nimport defu from \"defu\";\nimport superjson from \"superjson\";\n\nexport function getTRPCServerUrl(\n baseUrl: string | StormURLInterface,\n version: number | null = 1\n) {\n return joinPaths(\n typeof baseUrl === \"string\" ? baseUrl : baseUrl.host || \"\",\n \"api\",\n version ? `v${version}` : \"\",\n \"trpc\"\n );\n}\n\nsuperjson.registerCustom(\n {\n isApplicable: (v): v is Temporal.PlainDate =>\n v instanceof Temporal.PlainDate,\n serialize: v => v.toJSON(),\n deserialize: v => Temporal.PlainDate.from(v)\n },\n \"Temporal.PlainDate\"\n);\n\nsuperjson.registerCustom(\n {\n isApplicable: (v): v is Temporal.PlainDateTime =>\n v instanceof Temporal.PlainDateTime,\n serialize: v => v.toJSON(),\n deserialize: v => Temporal.PlainDateTime.from(v)\n },\n \"Temporal.PlainDateTime\"\n);\n\nexport const transformer = superjson as DataTransformer;\n\n/**\n * Create a TRPC Tanstack Query client.\n *\n * @param queryClientConfig - The query client config\n * @returns The TRPC Tanstack Query client\n */\nexport const createQueryClient = (\n queryClientConfig: Partial<QueryClientConfig> = {}\n) =>\n new QueryClient(\n defu(queryClientConfig, {\n defaultOptions: {\n queries: {\n // Since queries are prefetched on the server, we set a stale time so that\n // queries aren't immediately re-fetched on the client\n staleTime: 1000 * 30\n },\n dehydrate: {\n // include pending queries in dehydration\n // this allows us to prefetch in RSC and\n // send promises over the RSC boundary\n shouldDehydrateQuery: (query: any) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === \"pending\",\n serializeData: transformer.serialize\n },\n hydrate: {\n deserializeData: transformer.deserialize\n }\n }\n })\n );\n"],"mappings":"yOA8BA,SAAgB,EACd,EACA,EAAyB,EACzB,CACA,OAAO,EACL,OAAO,GAAY,SAAW,EAAU,EAAQ,MAAQ,GACxD,MACA,EAAU,IAAI,IAAY,GAC1B,OACD,CAGH,EAAU,eACR,CACE,aAAe,GACb,aAAa,EAAS,UACxB,UAAW,GAAK,EAAE,QAAQ,CAC1B,YAAa,GAAK,EAAS,UAAU,KAAK,EAAE,CAC7C,CACD,qBACD,CAED,EAAU,eACR,CACE,aAAe,GACb,aAAa,EAAS,cACxB,UAAW,GAAK,EAAE,QAAQ,CAC1B,YAAa,GAAK,EAAS,cAAc,KAAK,EAAE,CACjD,CACD,yBACD,CAED,MAAa,EAAc,EAQd,GACX,EAAgD,EAAE,GAElD,IAAI,EACF,EAAK,EAAmB,CACtB,eAAgB,CACd,QAAS,CAGP,UAAW,IAAO,GACnB,CACD,UAAW,CAIT,qBAAuB,GACrB,EAA4B,EAAM,EAClC,EAAM,MAAM,SAAW,UACzB,cAAe,EAAY,UAC5B,CACD,QAAS,CACP,gBAAiB,EAAY,YAC9B,CACF,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"shared.mjs","names":[],"sources":["../src/shared.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 { Temporal } from \"@js-temporal/polyfill\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { StormURLInterface } from \"@stryke/url/types\";\nimport type { QueryClientConfig } from \"@tanstack/react-query\";\nimport {\n defaultShouldDehydrateQuery,\n QueryClient\n} from \"@tanstack/react-query\";\nimport type { DataTransformer } from \"@trpc/server/unstable-core-do-not-import\";\nimport defu from \"defu\";\nimport superjson from \"superjson\";\n\nexport function getTRPCServerUrl(\n baseUrl: string | StormURLInterface,\n version: number | null = 1\n) {\n return joinPaths(\n typeof baseUrl === \"string\" ? baseUrl : baseUrl.host || \"\",\n \"api\",\n version ? `v${version}` : \"\",\n \"trpc\"\n );\n}\n\nsuperjson.registerCustom(\n {\n isApplicable: (v): v is Temporal.PlainDate =>\n v instanceof Temporal.PlainDate,\n serialize: v => v.toJSON(),\n deserialize: v => Temporal.PlainDate.from(v)\n },\n \"Temporal.PlainDate\"\n);\n\nsuperjson.registerCustom(\n {\n isApplicable: (v): v is Temporal.PlainDateTime =>\n v instanceof Temporal.PlainDateTime,\n serialize: v => v.toJSON(),\n deserialize: v => Temporal.PlainDateTime.from(v)\n },\n \"Temporal.PlainDateTime\"\n);\n\nexport const transformer = superjson as DataTransformer;\n\n/**\n * Create a TRPC Tanstack Query client.\n *\n * @param queryClientConfig - The query client config\n * @returns The TRPC Tanstack Query client\n */\nexport const createQueryClient = (\n queryClientConfig: Partial<QueryClientConfig> = {}\n) =>\n new QueryClient(\n defu(queryClientConfig, {\n defaultOptions: {\n queries: {\n // Since queries are prefetched on the server, we set a stale time so that\n // queries aren't immediately re-fetched on the client\n staleTime: 1000 * 30\n },\n dehydrate: {\n // include pending queries in dehydration\n // this allows us to prefetch in RSC and\n // send promises over the RSC boundary\n shouldDehydrateQuery: (query: any) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === \"pending\",\n serializeData: transformer.serialize\n },\n hydrate: {\n deserializeData: transformer.deserialize\n }\n }\n })\n );\n"],"mappings":";;;;;;;AA8BA,SAAgB,iBACd,SACA,UAAyB,GACzB;AACA,QAAO,UACL,OAAO,YAAY,WAAW,UAAU,QAAQ,QAAQ,IACxD,OACA,UAAU,IAAI,YAAY,IAC1B,OACD;;AAGH,UAAU,eACR;CACE,eAAe,MACb,aAAa,SAAS;CACxB,YAAW,MAAK,EAAE,QAAQ;CAC1B,cAAa,MAAK,SAAS,UAAU,KAAK,EAAE;CAC7C,EACD,qBACD;AAED,UAAU,eACR;CACE,eAAe,MACb,aAAa,SAAS;CACxB,YAAW,MAAK,EAAE,QAAQ;CAC1B,cAAa,MAAK,SAAS,cAAc,KAAK,EAAE;CACjD,EACD,yBACD;AAED,MAAa,cAAc;;;;;;;AAQ3B,MAAa,qBACX,oBAAgD,EAAE,KAElD,IAAI,YACF,KAAK,mBAAmB,EACtB,gBAAgB;CACd,SAAS,EAGP,WAAW,MAAO,IACnB;CACD,WAAW;EAIT,uBAAuB,UACrB,4BAA4B,MAAM,IAClC,MAAM,MAAM,WAAW;EACzB,eAAe,YAAY;EAC5B;CACD,SAAS,EACP,iBAAiB,YAAY,aAC9B;CACF,EACF,CAAC,CACH"}