@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.
- package/CHANGELOG.md +8 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/action-handler.cjs +20 -1
- package/dist/action-handler.mjs +18 -1
- package/dist/action-handler.mjs.map +1 -1
- package/dist/client.cjs +39 -1
- package/dist/client.mjs +37 -1
- package/dist/client.mjs.map +1 -1
- package/dist/env/src/ci-checks.cjs +13 -1
- package/dist/env/src/ci-checks.mjs +12 -1
- package/dist/env/src/ci-checks.mjs.map +1 -1
- package/dist/env/src/environment-checks.cjs +87 -1
- package/dist/env/src/environment-checks.mjs +87 -1
- package/dist/env/src/environment-checks.mjs.map +1 -1
- package/dist/index.cjs +30 -1
- package/dist/index.mjs +8 -1
- package/dist/path/src/is-type.cjs +28 -1
- package/dist/path/src/is-type.mjs +28 -1
- package/dist/path/src/is-type.mjs.map +1 -1
- package/dist/path/src/join-paths.cjs +106 -1
- package/dist/path/src/join-paths.mjs +106 -1
- package/dist/path/src/join-paths.mjs.map +1 -1
- package/dist/path/src/regex.cjs +12 -1
- package/dist/path/src/regex.mjs +8 -1
- package/dist/path/src/regex.mjs.map +1 -1
- package/dist/path/src/slash.cjs +15 -1
- package/dist/path/src/slash.mjs +14 -1
- package/dist/path/src/slash.mjs.map +1 -1
- package/dist/server.cjs +46 -1
- package/dist/server.mjs +33 -1
- package/dist/server.mjs.map +1 -1
- package/dist/shared.cjs +43 -1
- package/dist/shared.mjs +38 -1
- package/dist/shared.mjs.map +1 -1
- package/dist/shield/constructors.cjs +86 -1
- package/dist/shield/constructors.mjs +79 -1
- package/dist/shield/constructors.mjs.map +1 -1
- package/dist/shield/generator.cjs +28 -1
- package/dist/shield/generator.mjs +27 -1
- package/dist/shield/generator.mjs.map +1 -1
- package/dist/shield/index.cjs +12 -1
- package/dist/shield/index.mjs +4 -1
- package/dist/shield/rules.cjs +200 -1
- package/dist/shield/rules.mjs +191 -1
- package/dist/shield/rules.mjs.map +1 -1
- package/dist/shield/shield.cjs +31 -1
- package/dist/shield/shield.mjs +31 -1
- package/dist/shield/shield.mjs.map +1 -1
- package/dist/shield/utils.cjs +56 -1
- package/dist/shield/utils.mjs +51 -1
- package/dist/shield/utils.mjs.map +1 -1
- package/dist/shield/validation.cjs +59 -1
- package/dist/shield/validation.mjs +58 -1
- package/dist/shield/validation.mjs.map +1 -1
- package/dist/tanstack-query/client.cjs +42 -1
- package/dist/tanstack-query/client.mjs +41 -1
- package/dist/tanstack-query/client.mjs.map +1 -1
- package/dist/tanstack-query/server.cjs +54 -1
- package/dist/tanstack-query/server.mjs +51 -1
- package/dist/tanstack-query/server.mjs.map +1 -1
- 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":"
|
|
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
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/path/src/regex.cjs
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
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;
|
package/dist/path/src/regex.mjs
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
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,
|
|
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"}
|
package/dist/path/src/slash.cjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
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;
|
package/dist/path/src/slash.mjs
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
package/dist/server.mjs.map
CHANGED
|
@@ -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":"
|
|
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
|
|
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
|
|
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
|
package/dist/shared.mjs.map
CHANGED
|
@@ -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":"
|
|
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"}
|