@kubb/core 5.0.0-alpha.9 → 5.0.0-beta.10
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 +13 -40
- package/dist/PluginDriver-Cu1Kj9S-.cjs +1075 -0
- package/dist/PluginDriver-Cu1Kj9S-.cjs.map +1 -0
- package/dist/PluginDriver-D8Z0Htid.js +978 -0
- package/dist/PluginDriver-D8Z0Htid.js.map +1 -0
- package/dist/createKubb-ALdb8lmq.d.ts +2082 -0
- package/dist/index.cjs +747 -1667
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +175 -269
- package/dist/index.js +734 -1638
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +145 -0
- package/dist/mocks.cjs.map +1 -0
- package/dist/mocks.d.ts +80 -0
- package/dist/mocks.js +140 -0
- package/dist/mocks.js.map +1 -0
- package/package.json +47 -60
- package/src/FileManager.ts +115 -0
- package/src/FileProcessor.ts +86 -0
- package/src/PluginDriver.ts +355 -561
- package/src/constants.ts +21 -48
- package/src/createAdapter.ts +88 -5
- package/src/createKubb.ts +1266 -0
- package/src/createRenderer.ts +57 -0
- package/src/createStorage.ts +13 -1
- package/src/defineGenerator.ts +160 -119
- package/src/defineLogger.ts +46 -5
- package/src/defineMiddleware.ts +62 -0
- package/src/defineParser.ts +44 -0
- package/src/definePlugin.ts +379 -0
- package/src/defineResolver.ts +548 -25
- package/src/devtools.ts +22 -15
- package/src/index.ts +13 -15
- package/src/mocks.ts +177 -0
- package/src/storages/fsStorage.ts +13 -8
- package/src/storages/memoryStorage.ts +4 -2
- package/src/types.ts +40 -547
- package/dist/PluginDriver-BkFepPdm.d.ts +0 -1054
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/hooks.cjs +0 -103
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -77
- package/dist/hooks.js +0 -98
- package/dist/hooks.js.map +0 -1
- package/src/Kubb.ts +0 -224
- package/src/build.ts +0 -418
- package/src/config.ts +0 -56
- package/src/createPlugin.ts +0 -28
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useKubb.ts +0 -143
- package/src/hooks/useMode.ts +0 -11
- package/src/hooks/usePlugin.ts +0 -11
- package/src/hooks/usePluginDriver.ts +0 -11
- package/src/utils/FunctionParams.ts +0 -155
- package/src/utils/TreeNode.ts +0 -215
- package/src/utils/diagnostics.ts +0 -15
- package/src/utils/executeStrategies.ts +0 -81
- package/src/utils/formatters.ts +0 -56
- package/src/utils/getBarrelFiles.ts +0 -141
- package/src/utils/getConfigs.ts +0 -12
- package/src/utils/linters.ts +0 -25
- package/src/utils/packageJSON.ts +0 -61
package/dist/chunk-ByKO4r7w.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
5
|
-
value,
|
|
6
|
-
configurable: true
|
|
7
|
-
});
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
-
key = keys[i];
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: ((k) => from[k]).bind(null, key),
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
//#endregion
|
|
27
|
-
Object.defineProperty(exports, "__name", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function() {
|
|
30
|
-
return __name;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports, "__toESM", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function() {
|
|
36
|
-
return __toESM;
|
|
37
|
-
}
|
|
38
|
-
});
|
package/dist/hooks.cjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
node_path = require_chunk.__toESM(node_path);
|
|
5
|
-
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
6
|
-
//#region src/hooks/useKubb.ts
|
|
7
|
-
/**
|
|
8
|
-
* Generates the default "Generated by Kubb" banner from node metadata.
|
|
9
|
-
*/
|
|
10
|
-
function buildDefaultBanner({ title, description, version, config }) {
|
|
11
|
-
try {
|
|
12
|
-
let source = "";
|
|
13
|
-
if (Array.isArray(config.input)) {
|
|
14
|
-
const first = config.input[0];
|
|
15
|
-
if (first && "path" in first) source = node_path.default.basename(first.path);
|
|
16
|
-
} else if ("path" in config.input) source = node_path.default.basename(config.input.path);
|
|
17
|
-
else if ("data" in config.input) source = "text content";
|
|
18
|
-
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
19
|
-
if (config.output.defaultBanner === "simple") {
|
|
20
|
-
banner += "*/\n";
|
|
21
|
-
return banner;
|
|
22
|
-
}
|
|
23
|
-
if (source) banner += `* Source: ${source}\n`;
|
|
24
|
-
if (title) banner += `* Title: ${title}\n`;
|
|
25
|
-
if (description) {
|
|
26
|
-
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
27
|
-
banner += `* Description: ${formattedDescription}\n`;
|
|
28
|
-
}
|
|
29
|
-
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
30
|
-
banner += "*/\n";
|
|
31
|
-
return banner;
|
|
32
|
-
} catch (_error) {
|
|
33
|
-
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function useKubb() {
|
|
37
|
-
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
|
38
|
-
const config = meta.driver.config;
|
|
39
|
-
const defaultPluginName = meta.plugin.name;
|
|
40
|
-
const output = meta.plugin.options?.output;
|
|
41
|
-
return {
|
|
42
|
-
plugin: meta.plugin,
|
|
43
|
-
mode: meta.mode,
|
|
44
|
-
config,
|
|
45
|
-
getPluginByName: (pluginName = defaultPluginName) => meta.driver.getPluginByName.call(meta.driver, pluginName),
|
|
46
|
-
getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.getFile.call(meta.driver, {
|
|
47
|
-
pluginName,
|
|
48
|
-
...rest
|
|
49
|
-
}),
|
|
50
|
-
resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolveName.call(meta.driver, {
|
|
51
|
-
pluginName,
|
|
52
|
-
...rest
|
|
53
|
-
}),
|
|
54
|
-
resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolvePath.call(meta.driver, {
|
|
55
|
-
pluginName,
|
|
56
|
-
...rest
|
|
57
|
-
}),
|
|
58
|
-
resolveBanner: (node) => {
|
|
59
|
-
if (typeof output?.banner === "function") return node ? output.banner(node) : buildDefaultBanner({ config });
|
|
60
|
-
if (typeof output?.banner === "string") return output.banner;
|
|
61
|
-
if (config.output.defaultBanner === false) return;
|
|
62
|
-
return buildDefaultBanner({ config });
|
|
63
|
-
},
|
|
64
|
-
resolveFooter: (node) => {
|
|
65
|
-
if (typeof output?.footer === "function") return node ? output.footer(node) : void 0;
|
|
66
|
-
if (typeof output?.footer === "string") return output.footer;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/hooks/useMode.ts
|
|
72
|
-
/**
|
|
73
|
-
* @deprecated use `useKubb` instead
|
|
74
|
-
*/
|
|
75
|
-
function useMode() {
|
|
76
|
-
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
|
77
|
-
return meta.mode;
|
|
78
|
-
}
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region src/hooks/usePlugin.ts
|
|
81
|
-
/**
|
|
82
|
-
* @deprecated use useKubb instead
|
|
83
|
-
*/
|
|
84
|
-
function usePlugin() {
|
|
85
|
-
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
|
86
|
-
return meta.plugin;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/hooks/usePluginDriver.ts
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated use `useKubb` instead
|
|
92
|
-
*/
|
|
93
|
-
function usePluginDriver() {
|
|
94
|
-
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
|
95
|
-
return meta.driver;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
exports.useKubb = useKubb;
|
|
99
|
-
exports.useMode = useMode;
|
|
100
|
-
exports.usePlugin = usePlugin;
|
|
101
|
-
exports.usePluginDriver = usePluginDriver;
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":["path"],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginDriver.ts"],"sourcesContent":["import path from 'node:path'\nimport type { RootNode } from '@kubb/ast/types'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\nimport type { GetFileOptions, PluginDriver } from '../PluginDriver.ts'\nimport type { Config, Plugin, PluginFactoryOptions, ResolveNameParams, ResolvePathParams } from '../types.ts'\n\ntype ResolvePathOptions = {\n pluginName?: string\n group?: {\n tag?: string\n path?: string\n }\n type?: ResolveNameParams['type']\n}\n\ntype UseKubbReturn<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n config: Config\n /**\n * Returns the plugin whose `name` matches `pluginName`, defaulting to the current plugin.\n */\n getPluginByName: (pluginName?: string) => Plugin | undefined\n /**\n * Resolves a file reference, defaulting `pluginName` to the current plugin.\n */\n getFile: (params: Omit<GetFileOptions<ResolvePathOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.File<{ pluginName: string }>\n /**\n * Resolves a name, defaulting `pluginName` to the current plugin.\n */\n resolveName: (params: Omit<ResolveNameParams, 'pluginName'> & { pluginName?: string }) => string\n /**\n * Resolves a path, defaulting `pluginName` to the current plugin.\n */\n resolvePath: <TPathOptions = object>(params: Omit<ResolvePathParams<TPathOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.Path\n /**\n * Resolves the banner using the plugin's `output.banner` option.\n * Falls back to the default \"Generated by Kubb\" banner when `output.banner` is unset.\n * When `output.banner` is a function and no node is provided, returns the default banner.\n */\n resolveBanner: (node?: RootNode) => string | undefined\n /**\n * Resolves the footer using the plugin's `output.footer` option.\n * Returns `undefined` when no footer is configured.\n * When `output.footer` is a function and no node is provided, returns `undefined`.\n */\n resolveFooter: (node?: RootNode) => string | undefined\n}\n\n/**\n * Generates the default \"Generated by Kubb\" banner from node metadata.\n */\nfunction buildDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if (Array.isArray(config.input)) {\n const first = config.input[0]\n if (first && 'path' in first) {\n source = path.basename(first.path)\n }\n } else if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): UseKubbReturn<TOptions> {\n const { meta } = useFabric<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n driver: PluginDriver\n }>()\n\n const config = meta.driver.config\n const defaultPluginName = meta.plugin.name\n\n const output = (\n meta.plugin.options as { output?: { banner?: string | ((node: RootNode) => string); footer?: string | ((node: RootNode) => string) } } | undefined\n )?.output\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config,\n getPluginByName: (pluginName = defaultPluginName) => meta.driver.getPluginByName.call(meta.driver, pluginName),\n getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.getFile.call(meta.driver, { pluginName, ...rest }),\n resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolveName.call(meta.driver, { pluginName, ...rest }),\n resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolvePath.call(meta.driver, { pluginName, ...rest }),\n resolveBanner: (node?: RootNode) => {\n if (typeof output?.banner === 'function') {\n return node ? output.banner(node) : buildDefaultBanner({ config })\n }\n if (typeof output?.banner === 'string') {\n return output.banner\n }\n if (config.output.defaultBanner === false) {\n return undefined\n }\n return buildDefaultBanner({ config })\n },\n resolveFooter: (node?: RootNode) => {\n if (typeof output?.footer === 'function') {\n return node ? output.footer(node) : undefined\n }\n if (typeof output?.footer === 'string') {\n return output.footer\n }\n return undefined\n },\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useFabric<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useKubb instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useFabric<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n"],"mappings":";;;;;;;;;AAqDA,SAAS,mBAAmB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACvJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,MAAM,QAAQ,OAAO,MAAM,EAAE;GAC/B,MAAM,QAAQ,OAAO,MAAM;AAC3B,OAAI,SAAS,UAAU,MACrB,UAASA,UAAAA,QAAK,SAAS,MAAM,KAAK;aAE3B,UAAU,OAAO,MAC1B,UAASA,UAAAA,QAAK,SAAS,OAAO,MAAM,KAAK;WAChC,UAAU,OAAO,MAC1B,UAAS;EAGX,IAAI,SAAS;AAEb,MAAI,OAAO,OAAO,kBAAkB,UAAU;AAC5C,aAAU;AACV,UAAO;;AAGT,MAAI,OACF,WAAU,aAAa,OAAO;AAGhC,MAAI,MACF,WAAU,YAAY,MAAM;AAG9B,MAAI,aAAa;GACf,MAAM,uBAAuB,YAAY,QAAQ,QAAQ,OAAO;AAChE,aAAU,kBAAkB,qBAAqB;;AAGnD,MAAI,QACF,WAAU,2BAA2B,QAAQ;AAG/C,YAAU;AACV,SAAO;UACA,QAAQ;AACf,SAAO;;;AAIX,SAAgB,UAAiG;CAC/G,MAAM,EAAE,UAAA,GAAA,mBAAA,YAIJ;CAEJ,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,oBAAoB,KAAK,OAAO;CAEtC,MAAM,SACJ,KAAK,OAAO,SACX;AAEH,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX;EACA,kBAAkB,aAAa,sBAAsB,KAAK,OAAO,gBAAgB,KAAK,KAAK,QAAQ,WAAW;EAC9G,UAAU,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,OAAO,QAAQ,KAAK,KAAK,QAAQ;GAAE;GAAY,GAAG;GAAM,CAAC;EACxH,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,OAAO,YAAY,KAAK,KAAK,QAAQ;GAAE;GAAY,GAAG;GAAM,CAAC;EAChI,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,OAAO,YAAY,KAAK,KAAK,QAAQ;GAAE;GAAY,GAAG;GAAM,CAAC;EAChI,gBAAgB,SAAoB;AAClC,OAAI,OAAO,QAAQ,WAAW,WAC5B,QAAO,OAAO,OAAO,OAAO,KAAK,GAAG,mBAAmB,EAAE,QAAQ,CAAC;AAEpE,OAAI,OAAO,QAAQ,WAAW,SAC5B,QAAO,OAAO;AAEhB,OAAI,OAAO,OAAO,kBAAkB,MAClC;AAEF,UAAO,mBAAmB,EAAE,QAAQ,CAAC;;EAEvC,gBAAgB,SAAoB;AAClC,OAAI,OAAO,QAAQ,WAAW,WAC5B,QAAO,OAAO,OAAO,OAAO,KAAK,GAAG,KAAA;AAEtC,OAAI,OAAO,QAAQ,WAAW,SAC5B,QAAO,OAAO;;EAInB;;;;;;;ACvIH,SAAgB,UAAyB;CACvC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA6C;AAErD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,YAAkD;AAE1D,QAAO,KAAK;;;;;;;ACHd,SAAgB,kBAAgC;CAC9C,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA8C;AAEtD,QAAO,KAAK"}
|
package/dist/hooks.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { E as ResolveNameParams, O as ResolvePathParams, _ as Plugin, c as Config, n as PluginDriver, t as GetFileOptions, y as PluginFactoryOptions } from "./PluginDriver-BkFepPdm.js";
|
|
3
|
-
import { RootNode } from "@kubb/ast/types";
|
|
4
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
5
|
-
|
|
6
|
-
//#region src/hooks/useKubb.d.ts
|
|
7
|
-
type ResolvePathOptions = {
|
|
8
|
-
pluginName?: string;
|
|
9
|
-
group?: {
|
|
10
|
-
tag?: string;
|
|
11
|
-
path?: string;
|
|
12
|
-
};
|
|
13
|
-
type?: ResolveNameParams['type'];
|
|
14
|
-
};
|
|
15
|
-
type UseKubbReturn<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
16
|
-
plugin: Plugin<TOptions>;
|
|
17
|
-
mode: KubbFile.Mode;
|
|
18
|
-
config: Config;
|
|
19
|
-
/**
|
|
20
|
-
* Returns the plugin whose `name` matches `pluginName`, defaulting to the current plugin.
|
|
21
|
-
*/
|
|
22
|
-
getPluginByName: (pluginName?: string) => Plugin | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Resolves a file reference, defaulting `pluginName` to the current plugin.
|
|
25
|
-
*/
|
|
26
|
-
getFile: (params: Omit<GetFileOptions<ResolvePathOptions>, 'pluginName'> & {
|
|
27
|
-
pluginName?: string;
|
|
28
|
-
}) => KubbFile.File<{
|
|
29
|
-
pluginName: string;
|
|
30
|
-
}>;
|
|
31
|
-
/**
|
|
32
|
-
* Resolves a name, defaulting `pluginName` to the current plugin.
|
|
33
|
-
*/
|
|
34
|
-
resolveName: (params: Omit<ResolveNameParams, 'pluginName'> & {
|
|
35
|
-
pluginName?: string;
|
|
36
|
-
}) => string;
|
|
37
|
-
/**
|
|
38
|
-
* Resolves a path, defaulting `pluginName` to the current plugin.
|
|
39
|
-
*/
|
|
40
|
-
resolvePath: <TPathOptions = object>(params: Omit<ResolvePathParams<TPathOptions>, 'pluginName'> & {
|
|
41
|
-
pluginName?: string;
|
|
42
|
-
}) => KubbFile.Path;
|
|
43
|
-
/**
|
|
44
|
-
* Resolves the banner using the plugin's `output.banner` option.
|
|
45
|
-
* Falls back to the default "Generated by Kubb" banner when `output.banner` is unset.
|
|
46
|
-
* When `output.banner` is a function and no node is provided, returns the default banner.
|
|
47
|
-
*/
|
|
48
|
-
resolveBanner: (node?: RootNode) => string | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Resolves the footer using the plugin's `output.footer` option.
|
|
51
|
-
* Returns `undefined` when no footer is configured.
|
|
52
|
-
* When `output.footer` is a function and no node is provided, returns `undefined`.
|
|
53
|
-
*/
|
|
54
|
-
resolveFooter: (node?: RootNode) => string | undefined;
|
|
55
|
-
};
|
|
56
|
-
declare function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): UseKubbReturn<TOptions>;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/hooks/useMode.d.ts
|
|
59
|
-
/**
|
|
60
|
-
* @deprecated use `useKubb` instead
|
|
61
|
-
*/
|
|
62
|
-
declare function useMode(): KubbFile.Mode;
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/hooks/usePlugin.d.ts
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated use useKubb instead
|
|
67
|
-
*/
|
|
68
|
-
declare function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions>;
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/hooks/usePluginDriver.d.ts
|
|
71
|
-
/**
|
|
72
|
-
* @deprecated use `useKubb` instead
|
|
73
|
-
*/
|
|
74
|
-
declare function usePluginDriver(): PluginDriver;
|
|
75
|
-
//#endregion
|
|
76
|
-
export { useKubb, useMode, usePlugin, usePluginDriver };
|
|
77
|
-
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/hooks.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { useFabric } from "@kubb/react-fabric";
|
|
4
|
-
//#region src/hooks/useKubb.ts
|
|
5
|
-
/**
|
|
6
|
-
* Generates the default "Generated by Kubb" banner from node metadata.
|
|
7
|
-
*/
|
|
8
|
-
function buildDefaultBanner({ title, description, version, config }) {
|
|
9
|
-
try {
|
|
10
|
-
let source = "";
|
|
11
|
-
if (Array.isArray(config.input)) {
|
|
12
|
-
const first = config.input[0];
|
|
13
|
-
if (first && "path" in first) source = path.basename(first.path);
|
|
14
|
-
} else if ("path" in config.input) source = path.basename(config.input.path);
|
|
15
|
-
else if ("data" in config.input) source = "text content";
|
|
16
|
-
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
17
|
-
if (config.output.defaultBanner === "simple") {
|
|
18
|
-
banner += "*/\n";
|
|
19
|
-
return banner;
|
|
20
|
-
}
|
|
21
|
-
if (source) banner += `* Source: ${source}\n`;
|
|
22
|
-
if (title) banner += `* Title: ${title}\n`;
|
|
23
|
-
if (description) {
|
|
24
|
-
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
25
|
-
banner += `* Description: ${formattedDescription}\n`;
|
|
26
|
-
}
|
|
27
|
-
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
28
|
-
banner += "*/\n";
|
|
29
|
-
return banner;
|
|
30
|
-
} catch (_error) {
|
|
31
|
-
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function useKubb() {
|
|
35
|
-
const { meta } = useFabric();
|
|
36
|
-
const config = meta.driver.config;
|
|
37
|
-
const defaultPluginName = meta.plugin.name;
|
|
38
|
-
const output = meta.plugin.options?.output;
|
|
39
|
-
return {
|
|
40
|
-
plugin: meta.plugin,
|
|
41
|
-
mode: meta.mode,
|
|
42
|
-
config,
|
|
43
|
-
getPluginByName: (pluginName = defaultPluginName) => meta.driver.getPluginByName.call(meta.driver, pluginName),
|
|
44
|
-
getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.getFile.call(meta.driver, {
|
|
45
|
-
pluginName,
|
|
46
|
-
...rest
|
|
47
|
-
}),
|
|
48
|
-
resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolveName.call(meta.driver, {
|
|
49
|
-
pluginName,
|
|
50
|
-
...rest
|
|
51
|
-
}),
|
|
52
|
-
resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolvePath.call(meta.driver, {
|
|
53
|
-
pluginName,
|
|
54
|
-
...rest
|
|
55
|
-
}),
|
|
56
|
-
resolveBanner: (node) => {
|
|
57
|
-
if (typeof output?.banner === "function") return node ? output.banner(node) : buildDefaultBanner({ config });
|
|
58
|
-
if (typeof output?.banner === "string") return output.banner;
|
|
59
|
-
if (config.output.defaultBanner === false) return;
|
|
60
|
-
return buildDefaultBanner({ config });
|
|
61
|
-
},
|
|
62
|
-
resolveFooter: (node) => {
|
|
63
|
-
if (typeof output?.footer === "function") return node ? output.footer(node) : void 0;
|
|
64
|
-
if (typeof output?.footer === "string") return output.footer;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/hooks/useMode.ts
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated use `useKubb` instead
|
|
72
|
-
*/
|
|
73
|
-
function useMode() {
|
|
74
|
-
const { meta } = useFabric();
|
|
75
|
-
return meta.mode;
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/hooks/usePlugin.ts
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated use useKubb instead
|
|
81
|
-
*/
|
|
82
|
-
function usePlugin() {
|
|
83
|
-
const { meta } = useFabric();
|
|
84
|
-
return meta.plugin;
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/hooks/usePluginDriver.ts
|
|
88
|
-
/**
|
|
89
|
-
* @deprecated use `useKubb` instead
|
|
90
|
-
*/
|
|
91
|
-
function usePluginDriver() {
|
|
92
|
-
const { meta } = useFabric();
|
|
93
|
-
return meta.driver;
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
export { useKubb, useMode, usePlugin, usePluginDriver };
|
|
97
|
-
|
|
98
|
-
//# sourceMappingURL=hooks.js.map
|
package/dist/hooks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginDriver.ts"],"sourcesContent":["import path from 'node:path'\nimport type { RootNode } from '@kubb/ast/types'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\nimport type { GetFileOptions, PluginDriver } from '../PluginDriver.ts'\nimport type { Config, Plugin, PluginFactoryOptions, ResolveNameParams, ResolvePathParams } from '../types.ts'\n\ntype ResolvePathOptions = {\n pluginName?: string\n group?: {\n tag?: string\n path?: string\n }\n type?: ResolveNameParams['type']\n}\n\ntype UseKubbReturn<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n config: Config\n /**\n * Returns the plugin whose `name` matches `pluginName`, defaulting to the current plugin.\n */\n getPluginByName: (pluginName?: string) => Plugin | undefined\n /**\n * Resolves a file reference, defaulting `pluginName` to the current plugin.\n */\n getFile: (params: Omit<GetFileOptions<ResolvePathOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.File<{ pluginName: string }>\n /**\n * Resolves a name, defaulting `pluginName` to the current plugin.\n */\n resolveName: (params: Omit<ResolveNameParams, 'pluginName'> & { pluginName?: string }) => string\n /**\n * Resolves a path, defaulting `pluginName` to the current plugin.\n */\n resolvePath: <TPathOptions = object>(params: Omit<ResolvePathParams<TPathOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.Path\n /**\n * Resolves the banner using the plugin's `output.banner` option.\n * Falls back to the default \"Generated by Kubb\" banner when `output.banner` is unset.\n * When `output.banner` is a function and no node is provided, returns the default banner.\n */\n resolveBanner: (node?: RootNode) => string | undefined\n /**\n * Resolves the footer using the plugin's `output.footer` option.\n * Returns `undefined` when no footer is configured.\n * When `output.footer` is a function and no node is provided, returns `undefined`.\n */\n resolveFooter: (node?: RootNode) => string | undefined\n}\n\n/**\n * Generates the default \"Generated by Kubb\" banner from node metadata.\n */\nfunction buildDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if (Array.isArray(config.input)) {\n const first = config.input[0]\n if (first && 'path' in first) {\n source = path.basename(first.path)\n }\n } else if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): UseKubbReturn<TOptions> {\n const { meta } = useFabric<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n driver: PluginDriver\n }>()\n\n const config = meta.driver.config\n const defaultPluginName = meta.plugin.name\n\n const output = (\n meta.plugin.options as { output?: { banner?: string | ((node: RootNode) => string); footer?: string | ((node: RootNode) => string) } } | undefined\n )?.output\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config,\n getPluginByName: (pluginName = defaultPluginName) => meta.driver.getPluginByName.call(meta.driver, pluginName),\n getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.getFile.call(meta.driver, { pluginName, ...rest }),\n resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolveName.call(meta.driver, { pluginName, ...rest }),\n resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.driver.resolvePath.call(meta.driver, { pluginName, ...rest }),\n resolveBanner: (node?: RootNode) => {\n if (typeof output?.banner === 'function') {\n return node ? output.banner(node) : buildDefaultBanner({ config })\n }\n if (typeof output?.banner === 'string') {\n return output.banner\n }\n if (config.output.defaultBanner === false) {\n return undefined\n }\n return buildDefaultBanner({ config })\n },\n resolveFooter: (node?: RootNode) => {\n if (typeof output?.footer === 'function') {\n return node ? output.footer(node) : undefined\n }\n if (typeof output?.footer === 'string') {\n return output.footer\n }\n return undefined\n },\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useFabric<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useKubb instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useFabric<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n"],"mappings":";;;;;;;AAqDA,SAAS,mBAAmB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACvJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,MAAM,QAAQ,OAAO,MAAM,EAAE;GAC/B,MAAM,QAAQ,OAAO,MAAM;AAC3B,OAAI,SAAS,UAAU,MACrB,UAAS,KAAK,SAAS,MAAM,KAAK;aAE3B,UAAU,OAAO,MAC1B,UAAS,KAAK,SAAS,OAAO,MAAM,KAAK;WAChC,UAAU,OAAO,MAC1B,UAAS;EAGX,IAAI,SAAS;AAEb,MAAI,OAAO,OAAO,kBAAkB,UAAU;AAC5C,aAAU;AACV,UAAO;;AAGT,MAAI,OACF,WAAU,aAAa,OAAO;AAGhC,MAAI,MACF,WAAU,YAAY,MAAM;AAG9B,MAAI,aAAa;GACf,MAAM,uBAAuB,YAAY,QAAQ,QAAQ,OAAO;AAChE,aAAU,kBAAkB,qBAAqB;;AAGnD,MAAI,QACF,WAAU,2BAA2B,QAAQ;AAG/C,YAAU;AACV,SAAO;UACA,QAAQ;AACf,SAAO;;;AAIX,SAAgB,UAAiG;CAC/G,MAAM,EAAE,SAAS,WAIb;CAEJ,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,oBAAoB,KAAK,OAAO;CAEtC,MAAM,SACJ,KAAK,OAAO,SACX;AAEH,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX;EACA,kBAAkB,aAAa,sBAAsB,KAAK,OAAO,gBAAgB,KAAK,KAAK,QAAQ,WAAW;EAC9G,UAAU,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,OAAO,QAAQ,KAAK,KAAK,QAAQ;GAAE;GAAY,GAAG;GAAM,CAAC;EACxH,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,OAAO,YAAY,KAAK,KAAK,QAAQ;GAAE;GAAY,GAAG;GAAM,CAAC;EAChI,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,OAAO,YAAY,KAAK,KAAK,QAAQ;GAAE;GAAY,GAAG;GAAM,CAAC;EAChI,gBAAgB,SAAoB;AAClC,OAAI,OAAO,QAAQ,WAAW,WAC5B,QAAO,OAAO,OAAO,OAAO,KAAK,GAAG,mBAAmB,EAAE,QAAQ,CAAC;AAEpE,OAAI,OAAO,QAAQ,WAAW,SAC5B,QAAO,OAAO;AAEhB,OAAI,OAAO,OAAO,kBAAkB,MAClC;AAEF,UAAO,mBAAmB,EAAE,QAAQ,CAAC;;EAEvC,gBAAgB,SAAoB;AAClC,OAAI,OAAO,QAAQ,WAAW,WAC5B,QAAO,OAAO,OAAO,OAAO,KAAK,GAAG,KAAA;AAEtC,OAAI,OAAO,QAAQ,WAAW,SAC5B,QAAO,OAAO;;EAInB;;;;;;;ACvIH,SAAgB,UAAyB;CACvC,MAAM,EAAE,SAAS,WAAoC;AAErD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,WAAyC;AAE1D,QAAO,KAAK;;;;;;;ACHd,SAAgB,kBAAgC;CAC9C,MAAM,EAAE,SAAS,WAAqC;AAEtD,QAAO,KAAK"}
|
package/src/Kubb.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
2
|
-
import type { Strategy } from './PluginDriver.ts'
|
|
3
|
-
import type { Config, Plugin, PluginLifecycleHooks } from './types'
|
|
4
|
-
|
|
5
|
-
type DebugInfo = {
|
|
6
|
-
date: Date
|
|
7
|
-
logs: Array<string>
|
|
8
|
-
fileName?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type HookProgress<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
12
|
-
hookName: H
|
|
13
|
-
plugins: Array<Plugin>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type HookExecution<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
17
|
-
strategy: Strategy
|
|
18
|
-
hookName: H
|
|
19
|
-
plugin: Plugin
|
|
20
|
-
parameters?: Array<unknown>
|
|
21
|
-
output?: unknown
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type HookResult<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
25
|
-
duration: number
|
|
26
|
-
strategy: Strategy
|
|
27
|
-
hookName: H
|
|
28
|
-
plugin: Plugin
|
|
29
|
-
parameters?: Array<unknown>
|
|
30
|
-
output?: unknown
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Events emitted during the Kubb code generation lifecycle.
|
|
35
|
-
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* import type { AsyncEventEmitter } from '@internals/utils'
|
|
40
|
-
* import type { KubbEvents } from '@kubb/core'
|
|
41
|
-
*
|
|
42
|
-
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
43
|
-
*
|
|
44
|
-
* events.on('lifecycle:start', () => {
|
|
45
|
-
* console.log('Starting Kubb generation')
|
|
46
|
-
* })
|
|
47
|
-
*
|
|
48
|
-
* events.on('plugin:end', (plugin, { duration }) => {
|
|
49
|
-
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
50
|
-
* })
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export interface KubbEvents {
|
|
54
|
-
/**
|
|
55
|
-
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
56
|
-
*/
|
|
57
|
-
'lifecycle:start': [version: string]
|
|
58
|
-
/**
|
|
59
|
-
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
60
|
-
*/
|
|
61
|
-
'lifecycle:end': []
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Emitted when configuration loading starts.
|
|
65
|
-
*/
|
|
66
|
-
'config:start': []
|
|
67
|
-
/**
|
|
68
|
-
* Emitted when configuration loading is complete.
|
|
69
|
-
*/
|
|
70
|
-
'config:end': [configs: Array<Config>]
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Emitted when code generation phase starts.
|
|
74
|
-
*/
|
|
75
|
-
'generation:start': [config: Config]
|
|
76
|
-
/**
|
|
77
|
-
* Emitted when code generation phase completes.
|
|
78
|
-
*/
|
|
79
|
-
'generation:end': [config: Config, files: Array<KubbFile.ResolvedFile>, sources: Map<KubbFile.Path, string>]
|
|
80
|
-
/**
|
|
81
|
-
* Emitted with a summary of the generation results.
|
|
82
|
-
* Contains summary lines, title, and success status.
|
|
83
|
-
*/
|
|
84
|
-
'generation:summary': [
|
|
85
|
-
config: Config,
|
|
86
|
-
{
|
|
87
|
-
failedPlugins: Set<{ plugin: Plugin; error: Error }>
|
|
88
|
-
status: 'success' | 'failed'
|
|
89
|
-
hrStart: [number, number]
|
|
90
|
-
filesCreated: number
|
|
91
|
-
pluginTimings?: Map<Plugin['name'], number>
|
|
92
|
-
},
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
97
|
-
*/
|
|
98
|
-
'format:start': []
|
|
99
|
-
/**
|
|
100
|
-
* Emitted when code formatting completes.
|
|
101
|
-
*/
|
|
102
|
-
'format:end': []
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Emitted when linting starts.
|
|
106
|
-
*/
|
|
107
|
-
'lint:start': []
|
|
108
|
-
/**
|
|
109
|
-
* Emitted when linting completes.
|
|
110
|
-
*/
|
|
111
|
-
'lint:end': []
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Emitted when plugin hooks execution starts.
|
|
115
|
-
*/
|
|
116
|
-
'hooks:start': []
|
|
117
|
-
/**
|
|
118
|
-
* Emitted when plugin hooks execution completes.
|
|
119
|
-
*/
|
|
120
|
-
'hooks:end': []
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Emitted when a single hook execution starts (e.g., format or lint).
|
|
124
|
-
* The callback should be invoked when the command completes.
|
|
125
|
-
*/
|
|
126
|
-
'hook:start': [{ id?: string; command: string; args?: readonly string[] }]
|
|
127
|
-
/**
|
|
128
|
-
* Emitted when a single hook execution completes.
|
|
129
|
-
*/
|
|
130
|
-
'hook:end': [{ id?: string; command: string; args?: readonly string[]; success: boolean; error: Error | null }]
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Emitted when a new version of Kubb is available.
|
|
134
|
-
*/
|
|
135
|
-
'version:new': [currentVersion: string, latestVersion: string]
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Informational message event.
|
|
139
|
-
*/
|
|
140
|
-
info: [message: string, info?: string]
|
|
141
|
-
/**
|
|
142
|
-
* Error event. Emitted when an error occurs during code generation.
|
|
143
|
-
*/
|
|
144
|
-
error: [error: Error, meta?: Record<string, unknown>]
|
|
145
|
-
/**
|
|
146
|
-
* Success message event.
|
|
147
|
-
*/
|
|
148
|
-
success: [message: string, info?: string]
|
|
149
|
-
/**
|
|
150
|
-
* Warning message event.
|
|
151
|
-
*/
|
|
152
|
-
warn: [message: string, info?: string]
|
|
153
|
-
/**
|
|
154
|
-
* Debug event for detailed logging.
|
|
155
|
-
* Contains timestamp, log messages, and optional filename.
|
|
156
|
-
*/
|
|
157
|
-
debug: [info: DebugInfo]
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Emitted when file processing starts.
|
|
161
|
-
* Contains the list of files to be processed.
|
|
162
|
-
*/
|
|
163
|
-
'files:processing:start': [files: Array<KubbFile.ResolvedFile>]
|
|
164
|
-
/**
|
|
165
|
-
* Emitted for each file being processed, providing progress updates.
|
|
166
|
-
* Contains processed count, total count, percentage, and file details.
|
|
167
|
-
*/
|
|
168
|
-
'file:processing:update': [
|
|
169
|
-
{
|
|
170
|
-
/** Number of files processed so far. */
|
|
171
|
-
processed: number
|
|
172
|
-
/** Total number of files to process. */
|
|
173
|
-
total: number
|
|
174
|
-
/** Processing percentage (0–100). */
|
|
175
|
-
percentage: number
|
|
176
|
-
/** Optional source identifier. */
|
|
177
|
-
source?: string
|
|
178
|
-
/** The file being processed. */
|
|
179
|
-
file: KubbFile.ResolvedFile
|
|
180
|
-
/**
|
|
181
|
-
* Kubb configuration (not present in Fabric).
|
|
182
|
-
* Provides access to the current config during file processing.
|
|
183
|
-
*/
|
|
184
|
-
config: Config
|
|
185
|
-
},
|
|
186
|
-
]
|
|
187
|
-
/**
|
|
188
|
-
* Emitted when file processing completes.
|
|
189
|
-
* Contains the list of processed files.
|
|
190
|
-
*/
|
|
191
|
-
'files:processing:end': [files: Array<KubbFile.ResolvedFile>]
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Emitted when a plugin starts executing.
|
|
195
|
-
*/
|
|
196
|
-
'plugin:start': [plugin: Plugin]
|
|
197
|
-
/**
|
|
198
|
-
* Emitted when a plugin completes execution.
|
|
199
|
-
* Duration in ms.
|
|
200
|
-
*/
|
|
201
|
-
'plugin:end': [plugin: Plugin, result: { duration: number; success: boolean; error?: Error }]
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Emitted when plugin hook progress tracking starts.
|
|
205
|
-
* Contains the hook name and list of plugins to execute.
|
|
206
|
-
*/
|
|
207
|
-
'plugins:hook:progress:start': [progress: HookProgress]
|
|
208
|
-
/**
|
|
209
|
-
* Emitted when plugin hook progress tracking ends.
|
|
210
|
-
* Contains the hook name that completed.
|
|
211
|
-
*/
|
|
212
|
-
'plugins:hook:progress:end': [{ hookName: PluginLifecycleHooks }]
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Emitted when a plugin hook starts processing.
|
|
216
|
-
* Contains strategy, hook name, plugin, parameters, and output.
|
|
217
|
-
*/
|
|
218
|
-
'plugins:hook:processing:start': [execution: HookExecution]
|
|
219
|
-
/**
|
|
220
|
-
* Emitted when a plugin hook completes processing.
|
|
221
|
-
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
222
|
-
*/
|
|
223
|
-
'plugins:hook:processing:end': [result: HookResult]
|
|
224
|
-
}
|