@kubb/plugin-ts 5.0.14 → 5.0.15
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/dist/index.cjs +21 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +21 -23
- package/dist/index.js.map +1 -1
- package/docs/guides/customization.md +2 -2
- package/kubb-extension.json +14 -0
- package/package.json +7 -5
package/dist/index.cjs
CHANGED
|
@@ -31,12 +31,23 @@ let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
|
31
31
|
*
|
|
32
32
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
33
33
|
*/
|
|
34
|
-
function
|
|
34
|
+
function convert(text, pascal) {
|
|
35
35
|
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
36
36
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
37
37
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
38
38
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
39
39
|
}
|
|
40
|
+
const cache = /* @__PURE__ */ new Map();
|
|
41
|
+
const cacheLimit = 1e4;
|
|
42
|
+
function toCamelOrPascal(text, pascal) {
|
|
43
|
+
const key = `${pascal ? "P" : "c"}${text}`;
|
|
44
|
+
const cached = cache.get(key);
|
|
45
|
+
if (cached !== void 0) return cached;
|
|
46
|
+
const result = convert(text, pascal);
|
|
47
|
+
if (cache.size >= cacheLimit) cache.clear();
|
|
48
|
+
cache.set(key, result);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
40
51
|
/**
|
|
41
52
|
* Converts `text` to camelCase.
|
|
42
53
|
*
|
|
@@ -261,29 +272,16 @@ function stringify(value) {
|
|
|
261
272
|
return `'${JSON.stringify(trimQuotes(value.toString())).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
|
|
262
273
|
}
|
|
263
274
|
/**
|
|
264
|
-
* Escapes
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
|
275
|
+
* Escapes an `@` at the start of a line, so a multi-line description can't start a new JSDoc tag.
|
|
276
|
+
* Editors render `\@` as `@` in hovers.
|
|
268
277
|
*
|
|
269
278
|
* @example
|
|
270
279
|
* ```ts
|
|
271
|
-
*
|
|
280
|
+
* jsDocEscape('intro\n@example value') // 'intro\n\\@example value'
|
|
272
281
|
* ```
|
|
273
282
|
*/
|
|
274
|
-
function
|
|
275
|
-
return `${input}`.replace(
|
|
276
|
-
switch (character) {
|
|
277
|
-
case "\"":
|
|
278
|
-
case "'":
|
|
279
|
-
case "\\": return `\\${character}`;
|
|
280
|
-
case "\n": return "\\n";
|
|
281
|
-
case "\r": return "\\r";
|
|
282
|
-
case "\u2028": return "\\u2028";
|
|
283
|
-
case "\u2029": return "\\u2029";
|
|
284
|
-
default: return "";
|
|
285
|
-
}
|
|
286
|
-
});
|
|
283
|
+
function jsDocEscape(input) {
|
|
284
|
+
return `${input}`.replace(/^(\s*)@/gm, "$1\\@");
|
|
287
285
|
}
|
|
288
286
|
//#endregion
|
|
289
287
|
//#region ../../internals/utils/src/fs.ts
|
|
@@ -340,7 +338,7 @@ var factory_exports = /* @__PURE__ */ __exportAll({
|
|
|
340
338
|
* Loaded with `require`, not `import`. When ESM imports a CommonJS package, Node keeps a second
|
|
341
339
|
* copy of its source to detect named exports, and for TypeScript that copy is about 9 MB.
|
|
342
340
|
*/
|
|
343
|
-
const typescript = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("typescript");
|
|
341
|
+
const typescript = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@typescript/typescript6");
|
|
344
342
|
const { SyntaxKind, factory } = typescript;
|
|
345
343
|
function isNumber(value) {
|
|
346
344
|
return typeof value === "number" && !Number.isNaN(value);
|
|
@@ -438,7 +436,7 @@ function createPropertySignature({ readOnly, modifiers = [], name, questionToken
|
|
|
438
436
|
function appendJSDocToNode({ node, comments }) {
|
|
439
437
|
const filteredComments = comments.filter(Boolean);
|
|
440
438
|
if (!filteredComments.length) return node;
|
|
441
|
-
const text = filteredComments.reduce((acc = "", comment = "") => {
|
|
439
|
+
const text = filteredComments.flatMap((comment = "") => comment.split(/\r?\n/)).reduce((acc = "", comment = "") => {
|
|
442
440
|
return `${acc}\n * ${comment.replaceAll("*/", "*\\/")}`;
|
|
443
441
|
}, "*");
|
|
444
442
|
return typescript.addSyntheticLeadingComment(node, typescript.SyntaxKind.MultiLineCommentTrivia, `${text || "*"}\n`, true);
|
|
@@ -1119,7 +1117,7 @@ function buildPropertyJSDocComments(schema, optional) {
|
|
|
1119
1117
|
const formatComment = meta && "format" in meta && meta.format ? hasDescription ? [" ", `Format: \`${meta.format}\``] : ["@description", `Format: \`${meta.format}\``] : [];
|
|
1120
1118
|
const exampleValues = meta?.examples ?? [];
|
|
1121
1119
|
const comments = [
|
|
1122
|
-
hasDescription ? `@description ${
|
|
1120
|
+
hasDescription ? `@description ${jsDocEscape(meta.description)}` : null,
|
|
1123
1121
|
...formatComment,
|
|
1124
1122
|
meta && "deprecated" in meta && meta.deprecated ? "@deprecated" : null,
|
|
1125
1123
|
!isArray && meta && "min" in meta && meta.min !== void 0 ? `@minLength ${meta.min}` : null,
|
|
@@ -1644,7 +1642,7 @@ var compatibility = {
|
|
|
1644
1642
|
};
|
|
1645
1643
|
//#endregion
|
|
1646
1644
|
//#region package.json
|
|
1647
|
-
var version = "5.0.
|
|
1645
|
+
var version = "5.0.15";
|
|
1648
1646
|
//#endregion
|
|
1649
1647
|
//#region src/resolvers/resolverTs.ts
|
|
1650
1648
|
/**
|