@koine/i18n 2.0.0-beta.30 → 2.0.0-beta.32
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/{i18nGenerateSummary.d.ts → generate/generateSummary.d.ts} +1 -1
- package/{i18nGenerateSummary.js → generate/generateSummary.js} +26 -19
- package/{i18nGenerateTypes.d.ts → generate/generateTypes.d.ts} +1 -1
- package/{i18nGenerateTypes.js → generate/generateTypes.js} +1 -1
- package/{i18nGetFsData.d.ts → generate/getFsData.d.ts} +1 -1
- package/{i18nGetFsData.js → generate/getFsData.js} +3 -3
- package/{i18nGetLocalesFolders.d.ts → generate/getLocalesFolders.d.ts} +1 -1
- package/{i18nGetLocalesFolders.js → generate/getLocalesFolders.js} +1 -1
- package/generate/index.d.ts +7 -0
- package/generate/index.js +7 -0
- package/generate/types.d.ts +14 -0
- package/generate/types.js +1 -0
- package/{i18nWriteSummary.d.ts → generate/writeSummary.d.ts} +2 -2
- package/{i18nWriteSummary.js → generate/writeSummary.js} +5 -5
- package/{i18nWriteTypes.d.ts → generate/writeTypes.d.ts} +1 -1
- package/{i18nWriteTypes.js → generate/writeTypes.js} +5 -5
- package/index.d.ts +3 -6
- package/index.js +3 -6
- package/isDynamicRouteId.d.ts +3 -0
- package/isDynamicRouteId.js +5 -0
- package/isStaticRouteId.d.ts +3 -0
- package/isStaticRouteId.js +5 -0
- package/package.json +30 -15
- package/routeHasDynamicPortion.d.ts +2 -0
- package/routeHasDynamicPortion.js +4 -0
- package/types.d.ts +4 -17
- package/_helpers.d.ts +0 -4
- package/_helpers.js +0 -9
|
@@ -21,7 +21,7 @@ type I18nSummaryFile = {
|
|
|
21
21
|
words: number;
|
|
22
22
|
characters: number;
|
|
23
23
|
};
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function generateSummary(options: I18nGenerateSummaryOptions): Promise<{
|
|
25
25
|
data: I18nSummary;
|
|
26
26
|
md: string;
|
|
27
27
|
}>;
|
|
@@ -20,42 +20,47 @@ function getWords(value, options) {
|
|
|
20
20
|
}
|
|
21
21
|
return out;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function getSummaryDataEntry(options, file) {
|
|
24
24
|
var locale = file.locale, path = file.path;
|
|
25
25
|
var url = "".concat(options.sourceUrl, "/").concat(locale, "/").concat(path);
|
|
26
26
|
var words = getWords(file.data);
|
|
27
27
|
var wordsCount = words.split(" ").filter(Boolean).length;
|
|
28
28
|
var characters = words.split(" ").filter(Boolean).join("").length;
|
|
29
29
|
return {
|
|
30
|
+
characters: characters,
|
|
30
31
|
locale: locale,
|
|
31
32
|
path: path,
|
|
32
33
|
url: url,
|
|
33
34
|
words: wordsCount,
|
|
34
|
-
characters: characters,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function getSummaryData(options) {
|
|
38
38
|
var files = options.files, defaultLocale = options.defaultLocale;
|
|
39
39
|
var data = {};
|
|
40
40
|
for (var i = 0; i < files.length; i++) {
|
|
41
41
|
var file = files[i];
|
|
42
42
|
var locale = file.locale;
|
|
43
|
-
var entry =
|
|
43
|
+
var entry = getSummaryDataEntry(options, file);
|
|
44
44
|
data[locale] = data[locale] || {};
|
|
45
45
|
data[locale].files = data[locale].files || [];
|
|
46
46
|
data[locale].files.push(entry);
|
|
47
47
|
}
|
|
48
|
-
data = Object.fromEntries(Object.entries(data).sort(function (_a) {
|
|
49
|
-
var
|
|
50
|
-
|
|
48
|
+
data = Object.fromEntries(Object.entries(data).sort(function (_a, _b) {
|
|
49
|
+
var _c = __read(_a, 1), a = _c[0];
|
|
50
|
+
var _d = __read(_b, 1), b = _d[0];
|
|
51
|
+
return a === defaultLocale ? -1 : a.localeCompare(b);
|
|
51
52
|
}));
|
|
52
53
|
forin(data, function (locale, dataPerLocale) {
|
|
53
|
-
data[locale].words = arraySum(dataPerLocale.files.map(function (f) { return f.words; }));
|
|
54
54
|
data[locale].characters = arraySum(dataPerLocale.files.map(function (f) { return f.characters; }));
|
|
55
|
+
data[locale].files = data[locale].files.sort(function (a, b) {
|
|
56
|
+
return a.path.localeCompare(b.path);
|
|
57
|
+
});
|
|
58
|
+
data[locale].words = arraySum(dataPerLocale.files.map(function (f) { return f.words; }));
|
|
59
|
+
data[locale] = Object.fromEntries(Object.entries(data[locale]).sort());
|
|
55
60
|
});
|
|
56
61
|
return data;
|
|
57
62
|
}
|
|
58
|
-
function
|
|
63
|
+
function getSummaryDataByPath(data) {
|
|
59
64
|
var out = {};
|
|
60
65
|
forin(data, function (locale, dataPerLocale) {
|
|
61
66
|
var files = dataPerLocale.files;
|
|
@@ -69,8 +74,8 @@ function i18nSummaryGetDataByPath(data) {
|
|
|
69
74
|
out = Object.fromEntries(Object.entries(out).sort());
|
|
70
75
|
return out;
|
|
71
76
|
}
|
|
72
|
-
function
|
|
73
|
-
var dataByPath =
|
|
77
|
+
function generateSummaryMarkdownByPath(_options, data) {
|
|
78
|
+
var dataByPath = getSummaryDataByPath(data);
|
|
74
79
|
var output = "";
|
|
75
80
|
var body = "";
|
|
76
81
|
var locales = [];
|
|
@@ -90,11 +95,13 @@ function i18nGenerateSummaryMarkdownByPath(_options, data) {
|
|
|
90
95
|
});
|
|
91
96
|
output += "<table><thead><tr>";
|
|
92
97
|
output += "<th ".concat(styleBorder, ">file path</th>");
|
|
93
|
-
output += locales
|
|
98
|
+
output += locales
|
|
99
|
+
.map(function () { return "<th>lang</th><th>words</th><th ".concat(styleBorder, ">chars</th>"); })
|
|
100
|
+
.join("");
|
|
94
101
|
output += "</tr></thead><tbody>".concat(body, "</tbody></table>\n");
|
|
95
102
|
return output;
|
|
96
103
|
}
|
|
97
|
-
function
|
|
104
|
+
function generateSummaryMarkdownByLocale(options, data) {
|
|
98
105
|
var output = "";
|
|
99
106
|
var body = "";
|
|
100
107
|
forin(data, function (locale, dataPerLocale) {
|
|
@@ -112,20 +119,20 @@ function i18nGenerateSummaryMarkdownByLocale(options, data) {
|
|
|
112
119
|
output += "</tr></thead><tbody>".concat(body, "</tbody></table>\n");
|
|
113
120
|
return output;
|
|
114
121
|
}
|
|
115
|
-
function
|
|
122
|
+
function generateSummaryMarkdown(options, data) {
|
|
116
123
|
var output = "# Summary\n";
|
|
117
124
|
output += "\n### By locale\n\n";
|
|
118
|
-
output +=
|
|
125
|
+
output += generateSummaryMarkdownByLocale(options, data);
|
|
119
126
|
output += "\n### By file path\n\n";
|
|
120
|
-
output +=
|
|
127
|
+
output += generateSummaryMarkdownByPath(options, data);
|
|
121
128
|
return output;
|
|
122
129
|
}
|
|
123
|
-
export function
|
|
130
|
+
export function generateSummary(options) {
|
|
124
131
|
return __awaiter(this, void 0, void 0, function () {
|
|
125
132
|
var data, md;
|
|
126
133
|
return __generator(this, function (_a) {
|
|
127
|
-
data =
|
|
128
|
-
md =
|
|
134
|
+
data = getSummaryData(options);
|
|
135
|
+
md = generateSummaryMarkdown(options, data);
|
|
129
136
|
return [2, { data: data, md: md }];
|
|
130
137
|
});
|
|
131
138
|
});
|
|
@@ -99,7 +99,7 @@ function getType(value) {
|
|
|
99
99
|
out = out.replace(/;+/g, ";");
|
|
100
100
|
return out;
|
|
101
101
|
}
|
|
102
|
-
export function
|
|
102
|
+
export function generateTypes(options) {
|
|
103
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
104
|
var defaultLocale, files, defaultLocaleFiles, header, footer, out, i, _a, path, data, namespace, format;
|
|
105
105
|
return __generator(this, function (_b) {
|
|
@@ -3,7 +3,7 @@ type I18nGetFsDataOutput = {
|
|
|
3
3
|
locales: I18nIndexedLocale[];
|
|
4
4
|
files: I18nIndexedFile[];
|
|
5
5
|
};
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getFsData(options: {
|
|
7
7
|
cwd: string;
|
|
8
8
|
onlyFilesForLocales?: string[];
|
|
9
9
|
}): Promise<I18nGetFsDataOutput>;
|
|
@@ -2,8 +2,8 @@ import { __awaiter, __generator } from "tslib";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { glob } from "glob";
|
|
5
|
-
import {
|
|
6
|
-
export function
|
|
5
|
+
import { getLocalesFolders } from "./getLocalesFolders.js";
|
|
6
|
+
export function getFsData(options) {
|
|
7
7
|
return __awaiter(this, void 0, void 0, function () {
|
|
8
8
|
var cwd, _a, onlyFilesForLocales, locales, dataOutput;
|
|
9
9
|
var _this = this;
|
|
@@ -11,7 +11,7 @@ export function i18nGetFsData(options) {
|
|
|
11
11
|
switch (_b.label) {
|
|
12
12
|
case 0:
|
|
13
13
|
cwd = options.cwd, _a = options.onlyFilesForLocales, onlyFilesForLocales = _a === void 0 ? [] : _a;
|
|
14
|
-
return [4,
|
|
14
|
+
return [4, getLocalesFolders({ cwd: cwd })];
|
|
15
15
|
case 1:
|
|
16
16
|
locales = _b.sent();
|
|
17
17
|
dataOutput = { locales: locales, files: [] };
|
|
@@ -2,7 +2,7 @@ import { __awaiter, __generator } from "tslib";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { glob } from "glob";
|
|
4
4
|
var ignoredFolderNames = ["node_modules"];
|
|
5
|
-
export function
|
|
5
|
+
export function getLocalesFolders(options) {
|
|
6
6
|
return __awaiter(this, void 0, void 0, function () {
|
|
7
7
|
var cwd, folders, output;
|
|
8
8
|
return __generator(this, function (_a) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { generateSummary } from "./generateSummary.js";
|
|
2
|
+
export { generateTypes } from "./generateTypes.js";
|
|
3
|
+
export { getFsData } from "./getFsData.js";
|
|
4
|
+
export { getLocalesFolders } from "./getLocalesFolders.js";
|
|
5
|
+
export { writeTypes } from "./writeTypes.js";
|
|
6
|
+
export { writeSummary } from "./writeSummary.js";
|
|
7
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { generateSummary } from "./generateSummary.js";
|
|
2
|
+
export { generateTypes } from "./generateTypes.js";
|
|
3
|
+
export { getFsData } from "./getFsData.js";
|
|
4
|
+
export { getLocalesFolders } from "./getLocalesFolders.js";
|
|
5
|
+
export { writeTypes } from "./writeTypes.js";
|
|
6
|
+
export { writeSummary } from "./writeSummary.js";
|
|
7
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type I18nLocale = string & {
|
|
2
|
+
branded: true;
|
|
3
|
+
};
|
|
4
|
+
export type I18nIndexedFile = {
|
|
5
|
+
path: string;
|
|
6
|
+
locale: I18nLocale;
|
|
7
|
+
data: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type I18nIndexedLocale = {
|
|
12
|
+
path: string;
|
|
13
|
+
code: I18nLocale;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type I18nGenerateSummaryConfig } from "./
|
|
2
|
-
export declare function
|
|
1
|
+
import { type I18nGenerateSummaryConfig } from "./generateSummary.js";
|
|
2
|
+
export declare function writeSummary(options: {
|
|
3
3
|
cwd: string;
|
|
4
4
|
outputJson: string;
|
|
5
5
|
outputMarkdown: string;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { __awaiter, __generator } from "tslib";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { fsWrite } from "@koine/node";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export function
|
|
4
|
+
import { generateSummary, } from "./generateSummary.js";
|
|
5
|
+
import { getFsData } from "./getFsData.js";
|
|
6
|
+
export function writeSummary(options) {
|
|
7
7
|
return __awaiter(this, void 0, void 0, function () {
|
|
8
8
|
var cwd, defaultLocale, outputJson, outputMarkdown, sourceUrl, data, summary;
|
|
9
9
|
return __generator(this, function (_a) {
|
|
10
10
|
switch (_a.label) {
|
|
11
11
|
case 0:
|
|
12
12
|
cwd = options.cwd, defaultLocale = options.defaultLocale, outputJson = options.outputJson, outputMarkdown = options.outputMarkdown, sourceUrl = options.sourceUrl;
|
|
13
|
-
return [4,
|
|
13
|
+
return [4, getFsData({
|
|
14
14
|
cwd: cwd,
|
|
15
15
|
})];
|
|
16
16
|
case 1:
|
|
17
17
|
data = _a.sent();
|
|
18
|
-
return [4,
|
|
18
|
+
return [4, generateSummary({
|
|
19
19
|
files: data.files,
|
|
20
20
|
defaultLocale: defaultLocale,
|
|
21
21
|
sourceUrl: sourceUrl,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { __awaiter, __generator } from "tslib";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { fsWrite } from "@koine/node";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export function
|
|
4
|
+
import { generateTypes } from "./generateTypes.js";
|
|
5
|
+
import { getFsData } from "./getFsData.js";
|
|
6
|
+
export function writeTypes(options) {
|
|
7
7
|
return __awaiter(this, void 0, void 0, function () {
|
|
8
8
|
var cwd, defaultLocale, outputTypes, data, types;
|
|
9
9
|
return __generator(this, function (_a) {
|
|
10
10
|
switch (_a.label) {
|
|
11
11
|
case 0:
|
|
12
12
|
cwd = options.cwd, defaultLocale = options.defaultLocale, outputTypes = options.outputTypes;
|
|
13
|
-
return [4,
|
|
13
|
+
return [4, getFsData({
|
|
14
14
|
cwd: cwd,
|
|
15
15
|
onlyFilesForLocales: [defaultLocale],
|
|
16
16
|
})];
|
|
17
17
|
case 1:
|
|
18
18
|
data = _a.sent();
|
|
19
|
-
return [4,
|
|
19
|
+
return [4, generateTypes({ files: data.files, defaultLocale: defaultLocale })];
|
|
20
20
|
case 2:
|
|
21
21
|
types = _a.sent();
|
|
22
22
|
return [4, fsWrite(join(cwd, outputTypes), types)];
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { createTo } from "./createTo.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { i18nGetLocalesFolders } from "./i18nGetLocalesFolders.js";
|
|
6
|
-
export { i18nWriteTypes } from "./i18nWriteTypes.js";
|
|
7
|
-
export { i18nWriteSummary } from "./i18nWriteSummary.js";
|
|
2
|
+
export { isDynamicRouteId } from "./isDynamicRouteId.js";
|
|
3
|
+
export { isStaticRouteId } from "./isStaticRouteId.js";
|
|
4
|
+
export { routeHasDynamicPortion } from "./routeHasDynamicPortion.js";
|
|
8
5
|
export * from "./types.js";
|
package/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { createTo } from "./createTo.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { i18nGetLocalesFolders } from "./i18nGetLocalesFolders.js";
|
|
6
|
-
export { i18nWriteTypes } from "./i18nWriteTypes.js";
|
|
7
|
-
export { i18nWriteSummary } from "./i18nWriteSummary.js";
|
|
2
|
+
export { isDynamicRouteId } from "./isDynamicRouteId.js";
|
|
3
|
+
export { isStaticRouteId } from "./isStaticRouteId.js";
|
|
4
|
+
export { routeHasDynamicPortion } from "./routeHasDynamicPortion.js";
|
|
8
5
|
export * from "./types.js";
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "@koine/i18n",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/node": "2.0.0-beta.
|
|
6
|
-
"@koine/utils": "2.0.0-beta.
|
|
5
|
+
"@koine/node": "2.0.0-beta.32",
|
|
6
|
+
"@koine/utils": "2.0.0-beta.32"
|
|
7
7
|
},
|
|
8
8
|
"peerDependenciesMeta": {
|
|
9
9
|
"prettier": {
|
|
@@ -22,23 +22,38 @@
|
|
|
22
22
|
"./createTo": {
|
|
23
23
|
"import": "./createTo.js"
|
|
24
24
|
},
|
|
25
|
-
"./
|
|
26
|
-
"import": "./
|
|
25
|
+
"./generate/generateSummary": {
|
|
26
|
+
"import": "./generate/generateSummary.js"
|
|
27
27
|
},
|
|
28
|
-
"./
|
|
29
|
-
"import": "./
|
|
28
|
+
"./generate/generateTypes": {
|
|
29
|
+
"import": "./generate/generateTypes.js"
|
|
30
30
|
},
|
|
31
|
-
"./
|
|
32
|
-
"import": "./
|
|
31
|
+
"./generate/getFsData": {
|
|
32
|
+
"import": "./generate/getFsData.js"
|
|
33
33
|
},
|
|
34
|
-
"./
|
|
35
|
-
"import": "./
|
|
34
|
+
"./generate/getLocalesFolders": {
|
|
35
|
+
"import": "./generate/getLocalesFolders.js"
|
|
36
36
|
},
|
|
37
|
-
"./
|
|
38
|
-
"import": "./
|
|
37
|
+
"./generate": {
|
|
38
|
+
"import": "./generate/index.js"
|
|
39
39
|
},
|
|
40
|
-
"./
|
|
41
|
-
"import": "./
|
|
40
|
+
"./generate/types": {
|
|
41
|
+
"import": "./generate/types.js"
|
|
42
|
+
},
|
|
43
|
+
"./generate/writeSummary": {
|
|
44
|
+
"import": "./generate/writeSummary.js"
|
|
45
|
+
},
|
|
46
|
+
"./generate/writeTypes": {
|
|
47
|
+
"import": "./generate/writeTypes.js"
|
|
48
|
+
},
|
|
49
|
+
"./isDynamicRouteId": {
|
|
50
|
+
"import": "./isDynamicRouteId.js"
|
|
51
|
+
},
|
|
52
|
+
"./isStaticRouteId": {
|
|
53
|
+
"import": "./isStaticRouteId.js"
|
|
54
|
+
},
|
|
55
|
+
"./routeHasDynamicPortion": {
|
|
56
|
+
"import": "./routeHasDynamicPortion.js"
|
|
42
57
|
},
|
|
43
58
|
"./types": {
|
|
44
59
|
"import": "./types.js"
|
|
@@ -48,5 +63,5 @@
|
|
|
48
63
|
"prettier": "^3.1.1",
|
|
49
64
|
"glob": "^10.3.10"
|
|
50
65
|
},
|
|
51
|
-
"version": "2.0.0-beta.
|
|
66
|
+
"version": "2.0.0-beta.32"
|
|
52
67
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import type { Split } from "@koine/utils";
|
|
2
|
-
export type I18nLocale = string & {
|
|
3
|
-
branded: true;
|
|
4
|
-
};
|
|
5
|
-
export type I18nIndexedFile = {
|
|
6
|
-
path: string;
|
|
7
|
-
locale: I18nLocale;
|
|
8
|
-
data: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export type I18nIndexedLocale = {
|
|
13
|
-
path: string;
|
|
14
|
-
code: I18nLocale;
|
|
15
|
-
};
|
|
16
2
|
type MergeDictionaries<T, K> = Omit<T, keyof K> & K;
|
|
17
3
|
type Join<A, Sep extends string = "", R extends string = ""> = A extends [
|
|
18
4
|
infer First,
|
|
@@ -60,9 +46,10 @@ export type TranslationOptions = undefined | TranslationShortcut | {
|
|
|
60
46
|
default?: string;
|
|
61
47
|
};
|
|
62
48
|
export type Translate<TNamespace extends TranslateNamespace | undefined = TranslateNamespace> = TNamespace extends TranslateNamespace ? TranslateNamespaced<TNamespace> : TranslateDefault;
|
|
63
|
-
export type TranslateDefault = <TPath extends TranslationsAllPaths
|
|
64
|
-
export type TranslateNamespaced<TNamespace extends TranslateNamespace> = <TPath extends TranslationsPaths<TranslationsDictionary[TNamespace]>>(s: TPath, q?: TranslationQuery, o?: TranslationOptions) =>
|
|
65
|
-
export type TranslateLoose = (s?: any, q?: TranslationQuery, o?: TranslationOptions) =>
|
|
49
|
+
export type TranslateDefault = <TPath extends TranslationsAllPaths, TReturn = TranslationAtPath<TPath>>(s: TPath, q?: TranslationQuery, o?: TranslationOptions) => TReturn;
|
|
50
|
+
export type TranslateNamespaced<TNamespace extends TranslateNamespace> = <TPath extends TranslationsPaths<TranslationsDictionary[TNamespace]>, TReturn = TranslationAtPathFromNamespace<TNamespace, TPath>>(s: TPath, q?: TranslationQuery, o?: TranslationOptions) => TReturn;
|
|
51
|
+
export type TranslateLoose<TReturn = string> = (s?: any, q?: TranslationQuery, o?: TranslationOptions) => TReturn;
|
|
52
|
+
export type TranslateLoosest<TReturn = any> = (s?: any, q?: TranslationQuery, o?: TranslationOptions) => TReturn;
|
|
66
53
|
export type TranslatedRoute = TranslationsPaths<TranslationsDictionary["~"], false>;
|
|
67
54
|
export type TranslatedRoutesChildrenOf<TStarts extends string, T extends string = TranslatedRoute> = T extends `${TStarts}.${infer First}.${infer Second}` ? First | `${First}.${Second}` : T extends `${TStarts}.${infer First}` ? First : never;
|
|
68
55
|
type OnlyStatic<T extends string> = T extends `${string}.[${string}].${string}` | `${string}.[${string}]` | `[${string}].${string}` | `[${string}]` ? never : T;
|
package/_helpers.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ToRoute, ToRouteDynamic, ToRouteStatic } from "./types.js";
|
|
2
|
-
export declare function routeHasDynamicPortion(routeIdOrPortion: string): boolean;
|
|
3
|
-
export declare function isStaticRouteId(routeId: ToRoute): routeId is ToRouteStatic;
|
|
4
|
-
export declare function isDynamicRouteId(routeId: ToRoute): routeId is ToRouteDynamic;
|
package/_helpers.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function routeHasDynamicPortion(routeIdOrPortion) {
|
|
2
|
-
return /\[/.test(routeIdOrPortion);
|
|
3
|
-
}
|
|
4
|
-
export function isStaticRouteId(routeId) {
|
|
5
|
-
return !routeHasDynamicPortion(routeId);
|
|
6
|
-
}
|
|
7
|
-
export function isDynamicRouteId(routeId) {
|
|
8
|
-
return routeHasDynamicPortion(routeId);
|
|
9
|
-
}
|