@kubb/plugin-ts 5.0.0-beta.36 → 5.0.0-beta.42
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/README.md +11 -15
- package/dist/index.cjs +16 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/factory.ts +31 -5
- package/src/printers/functionPrinter.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { t as __name } from "./chunk-C0LytTxp.js";
|
|
|
2
2
|
import { parserTs } from "@kubb/parser-ts";
|
|
3
3
|
import { File, jsxRendererSync } from "@kubb/renderer-jsx";
|
|
4
4
|
import { ast, defineGenerator, definePlugin, defineResolver } from "@kubb/core";
|
|
5
|
-
import { isNumber } from "remeda";
|
|
6
5
|
import ts from "typescript";
|
|
7
6
|
import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
|
|
8
7
|
//#region ../../internals/utils/src/casing.ts
|
|
@@ -309,6 +308,9 @@ const PARAM_RANK = {
|
|
|
309
308
|
//#endregion
|
|
310
309
|
//#region src/factory.ts
|
|
311
310
|
const { SyntaxKind, factory } = ts;
|
|
311
|
+
function isNumber(value) {
|
|
312
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
313
|
+
}
|
|
312
314
|
/**
|
|
313
315
|
* TypeScript AST modifiers for common keywords (async, export, const, static).
|
|
314
316
|
*/
|
|
@@ -332,8 +334,13 @@ function isNonNullable$1(value) {
|
|
|
332
334
|
__name(isNonNullable$1, "isNonNullable");
|
|
333
335
|
function isValidIdentifier(str) {
|
|
334
336
|
if (!str.length || str.trim() !== str) return false;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
+
let ch = str.codePointAt(0);
|
|
338
|
+
if (!ts.isIdentifierStart(ch, ts.ScriptTarget.Latest)) return false;
|
|
339
|
+
for (let i = ch > 65535 ? 2 : 1; i < str.length; i += ch > 65535 ? 2 : 1) {
|
|
340
|
+
ch = str.codePointAt(i);
|
|
341
|
+
if (!ts.isIdentifierPart(ch, ts.ScriptTarget.Latest)) return false;
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
337
344
|
}
|
|
338
345
|
function propertyName(name) {
|
|
339
346
|
if (typeof name === "string") return isValidIdentifier(name) ? factory.createIdentifier(name) : factory.createStringLiteral(name);
|
|
@@ -1623,10 +1630,10 @@ function rank(param) {
|
|
|
1623
1630
|
return param.optional ? PARAM_RANK.optional : PARAM_RANK.required;
|
|
1624
1631
|
}
|
|
1625
1632
|
function sortParams(params) {
|
|
1626
|
-
return
|
|
1633
|
+
return params.toSorted((a, b) => rank(a) - rank(b));
|
|
1627
1634
|
}
|
|
1628
1635
|
function sortChildParams(params) {
|
|
1629
|
-
return
|
|
1636
|
+
return params.toSorted((a, b) => rank(a) - rank(b));
|
|
1630
1637
|
}
|
|
1631
1638
|
/**
|
|
1632
1639
|
* Default function-signature printer.
|