@kubb/plugin-ts 5.0.12 → 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.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { n as __name } from "./rolldown-runtime-CthDji9g.js";
2
- import { KubbReactNode } from "kubb/jsx";
3
1
  import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
4
- import ts from "typescript";
2
+ import { KubbReactNode } from "kubb/jsx";
3
+ import ts from "@typescript/typescript6";
5
4
  //#region src/printers/printerTs.d.ts
6
5
  /**
7
6
  * Partial map of node-type overrides for the TypeScript printer.
@@ -389,7 +388,7 @@ type Options = OutputOptions & {
389
388
  *
390
389
  * @example Use the JavaScript `Date` object for date schemas
391
390
  * ```ts
392
- * import ts from 'typescript'
391
+ * import ts from '@typescript/typescript6'
393
392
  * pluginTs({
394
393
  * printer: {
395
394
  * nodes: {
@@ -763,7 +762,7 @@ type FunctionPrinterOptions = {
763
762
  * ```
764
763
  */
765
764
  export declare function functionPrinter(options: FunctionPrinterOptions): {
766
- name: "functionParameters";
765
+ name: 'functionParameters';
767
766
  options: FunctionPrinterOptions;
768
767
  print(node: FunctionParametersNode): string;
769
768
  };
package/dist/index.js CHANGED
@@ -1,9 +1,24 @@
1
- import { n as __name, t as __exportAll } from "./rolldown-runtime-CthDji9g.js";
2
1
  import { createRequire } from "node:module";
3
2
  import { parserTs } from "@kubb/parser-ts";
4
3
  import { File, jsxRenderer } from "kubb/jsx";
5
4
  import { Resolver, addGenerator, assertPluginOption, ast, createResolver, defineExtension, defineGenerator, isStringType, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
6
5
  import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
6
+ //#region \0rolldown/runtime.js
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", {
9
+ value,
10
+ configurable: true
11
+ });
12
+ var __exportAll = (all, no_symbols) => {
13
+ let target = {};
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return target;
20
+ };
21
+ //#endregion
7
22
  //#region ../../internals/utils/src/casing.ts
8
23
  /**
9
24
  * Shared implementation for camelCase and PascalCase conversion.
@@ -12,12 +27,23 @@ import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
12
27
  *
13
28
  * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
14
29
  */
15
- function toCamelOrPascal(text, pascal) {
30
+ function convert(text, pascal) {
16
31
  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) => {
17
32
  if (word.length > 1 && word === word.toUpperCase()) return word;
18
33
  return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
19
34
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
20
35
  }
36
+ const cache = /* @__PURE__ */ new Map();
37
+ const cacheLimit = 1e4;
38
+ function toCamelOrPascal(text, pascal) {
39
+ const key = `${pascal ? "P" : "c"}${text}`;
40
+ const cached = cache.get(key);
41
+ if (cached !== void 0) return cached;
42
+ const result = convert(text, pascal);
43
+ if (cache.size >= cacheLimit) cache.clear();
44
+ cache.set(key, result);
45
+ return result;
46
+ }
21
47
  /**
22
48
  * Converts `text` to camelCase.
23
49
  *
@@ -242,29 +268,16 @@ function stringify(value) {
242
268
  return `'${JSON.stringify(trimQuotes(value.toString())).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
243
269
  }
244
270
  /**
245
- * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,
246
- * and the Unicode line terminators U+2028 and U+2029.
247
- *
248
- * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
271
+ * Escapes an `@` at the start of a line, so a multi-line description can't start a new JSDoc tag.
272
+ * Editors render `\@` as `@` in hovers.
249
273
  *
250
274
  * @example
251
275
  * ```ts
252
- * jsStringEscape('say "hi"\nbye') // 'say \\"hi\\"\\nbye'
276
+ * jsDocEscape('intro\n@example value') // 'intro\n\\@example value'
253
277
  * ```
254
278
  */
255
- function jsStringEscape(input) {
256
- return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
257
- switch (character) {
258
- case "\"":
259
- case "'":
260
- case "\\": return `\\${character}`;
261
- case "\n": return "\\n";
262
- case "\r": return "\\r";
263
- case "\u2028": return "\\u2028";
264
- case "\u2029": return "\\u2029";
265
- default: return "";
266
- }
267
- });
279
+ function jsDocEscape(input) {
280
+ return `${input}`.replace(/^(\s*)@/gm, "$1\\@");
268
281
  }
269
282
  //#endregion
270
283
  //#region ../../internals/utils/src/fs.ts
@@ -321,7 +334,7 @@ var factory_exports = /* @__PURE__ */ __exportAll({
321
334
  * Loaded with `require`, not `import`. When ESM imports a CommonJS package, Node keeps a second
322
335
  * copy of its source to detect named exports, and for TypeScript that copy is about 9 MB.
323
336
  */
324
- const typescript = createRequire(import.meta.url)("typescript");
337
+ const typescript = createRequire(import.meta.url)("@typescript/typescript6");
325
338
  const { SyntaxKind, factory } = typescript;
326
339
  function isNumber(value) {
327
340
  return typeof value === "number" && !Number.isNaN(value);
@@ -419,7 +432,7 @@ function createPropertySignature({ readOnly, modifiers = [], name, questionToken
419
432
  function appendJSDocToNode({ node, comments }) {
420
433
  const filteredComments = comments.filter(Boolean);
421
434
  if (!filteredComments.length) return node;
422
- const text = filteredComments.reduce((acc = "", comment = "") => {
435
+ const text = filteredComments.flatMap((comment = "") => comment.split(/\r?\n/)).reduce((acc = "", comment = "") => {
423
436
  return `${acc}\n * ${comment.replaceAll("*/", "*\\/")}`;
424
437
  }, "*");
425
438
  return typescript.addSyntheticLeadingComment(node, typescript.SyntaxKind.MultiLineCommentTrivia, `${text || "*"}\n`, true);
@@ -1100,7 +1113,7 @@ function buildPropertyJSDocComments(schema, optional) {
1100
1113
  const formatComment = meta && "format" in meta && meta.format ? hasDescription ? [" ", `Format: \`${meta.format}\``] : ["@description", `Format: \`${meta.format}\``] : [];
1101
1114
  const exampleValues = meta?.examples ?? [];
1102
1115
  const comments = [
1103
- hasDescription ? `@description ${jsStringEscape(meta.description)}` : null,
1116
+ hasDescription ? `@description ${jsDocEscape(meta.description)}` : null,
1104
1117
  ...formatComment,
1105
1118
  meta && "deprecated" in meta && meta.deprecated ? "@deprecated" : null,
1106
1119
  !isArray && meta && "min" in meta && meta.min !== void 0 ? `@minLength ${meta.min}` : null,
@@ -1621,11 +1634,11 @@ const typeGenerator = defineGenerator({
1621
1634
  //#region kubb-extension.json
1622
1635
  var compatibility = {
1623
1636
  "kubb": ">=5.8.3",
1624
- "node": ">=22"
1637
+ "node": ">=22.12"
1625
1638
  };
1626
1639
  //#endregion
1627
1640
  //#region package.json
1628
- var version = "5.0.12";
1641
+ var version = "5.0.15";
1629
1642
  //#endregion
1630
1643
  //#region src/resolvers/resolverTs.ts
1631
1644
  /**