@kubb/core 5.0.0-beta.16 → 5.0.0-beta.18
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/{PluginDriver-C5hyNJfM.cjs → PluginDriver-Bc-k8EUQ.cjs} +12 -3
- package/dist/{PluginDriver-C5hyNJfM.cjs.map → PluginDriver-Bc-k8EUQ.cjs.map} +1 -1
- package/dist/{PluginDriver-CT33kVoQ.js → PluginDriver-T4-THx8t.js} +12 -3
- package/dist/{PluginDriver-CT33kVoQ.js.map → PluginDriver-T4-THx8t.js.map} +1 -1
- package/dist/{createKubb-BncBLGm_.d.ts → createKubb-DajERI4b.d.ts} +28 -24
- package/dist/index.cjs +238 -179
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +238 -179
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +4 -4
- package/src/FileManager.ts +4 -0
- package/src/PluginDriver.ts +13 -3
- package/src/createKubb.ts +19 -10
- package/src/createRenderer.ts +24 -22
- package/src/defineGenerator.ts +1 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { $ as ResolverPathParams, A as isInputPath, B as KubbPluginSetupContext, C as KubbPluginsEndContext, Ct as logLevel, D as PossibleConfig, E as KubbWarnContext, F as FileManager, G as Plugin, H as NormalizedPlugin, I as Exclude, J as ResolveBannerContext, K as PluginFactoryOptions, L as Group, M as GeneratorContext, N as defineGenerator, O as UserConfig, P as PluginDriver, Q as ResolverFileParams, R as Include, S as KubbLifecycleStartContext, St as createAdapter, T as KubbVersionNewContext, U as Output, V as KubbPluginStartContext, W as Override, X as Resolver, Y as ResolveOptionsContext, Z as ResolverContext, _ as KubbGenerationSummaryContext, _t as RendererFactory, a as InputPath, at as LoggerOptions, b as KubbHooks, bt as AdapterFactoryOptions, c as KubbBuildStartContext, ct as FileProcessor, d as KubbErrorContext, dt as Parser, et as defineResolver, f as KubbFileProcessingUpdateContext, ft as defineParser, g as KubbGenerationStartContext, gt as Renderer, h as KubbGenerationEndContext, ht as createStorage, i as InputData, it as LoggerContext, j as Generator, k as createKubb, l as KubbConfigEndContext, lt as FileProcessorEvents, m as KubbFilesProcessingStartContext, mt as Storage, n as CLIOptions, nt as defineMiddleware, o as Kubb, ot as UserLogger, p as KubbFilesProcessingEndContext, pt as DevtoolsOptions, q as definePlugin, r as Config, rt as Logger, s as KubbBuildEndContext, st as defineLogger, t as BuildOutput, tt as Middleware, u as KubbDebugContext, ut as ParsedFile, v as KubbHookEndContext, vt as createRenderer, w as KubbSuccessContext, wt as AsyncEventEmitter, x as KubbInfoContext, xt as AdapterSource, y as KubbHookStartContext, yt as Adapter, z as KubbPluginEndContext } from "./createKubb-
|
|
2
|
+
import { $ as ResolverPathParams, A as isInputPath, B as KubbPluginSetupContext, C as KubbPluginsEndContext, Ct as logLevel, D as PossibleConfig, E as KubbWarnContext, F as FileManager, G as Plugin, H as NormalizedPlugin, I as Exclude, J as ResolveBannerContext, K as PluginFactoryOptions, L as Group, M as GeneratorContext, N as defineGenerator, O as UserConfig, P as PluginDriver, Q as ResolverFileParams, R as Include, S as KubbLifecycleStartContext, St as createAdapter, T as KubbVersionNewContext, U as Output, V as KubbPluginStartContext, W as Override, X as Resolver, Y as ResolveOptionsContext, Z as ResolverContext, _ as KubbGenerationSummaryContext, _t as RendererFactory, a as InputPath, at as LoggerOptions, b as KubbHooks, bt as AdapterFactoryOptions, c as KubbBuildStartContext, ct as FileProcessor, d as KubbErrorContext, dt as Parser, et as defineResolver, f as KubbFileProcessingUpdateContext, ft as defineParser, g as KubbGenerationStartContext, gt as Renderer, h as KubbGenerationEndContext, ht as createStorage, i as InputData, it as LoggerContext, j as Generator, k as createKubb, l as KubbConfigEndContext, lt as FileProcessorEvents, m as KubbFilesProcessingStartContext, mt as Storage, n as CLIOptions, nt as defineMiddleware, o as Kubb, ot as UserLogger, p as KubbFilesProcessingEndContext, pt as DevtoolsOptions, q as definePlugin, r as Config, rt as Logger, s as KubbBuildEndContext, st as defineLogger, t as BuildOutput, tt as Middleware, u as KubbDebugContext, ut as ParsedFile, v as KubbHookEndContext, vt as createRenderer, w as KubbSuccessContext, wt as AsyncEventEmitter, x as KubbInfoContext, xt as AdapterSource, y as KubbHookStartContext, yt as Adapter, z as KubbPluginEndContext } from "./createKubb-DajERI4b.js";
|
|
3
3
|
import * as ast from "@kubb/ast";
|
|
4
4
|
|
|
5
5
|
//#region ../../internals/utils/src/urlPath.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { a as definePlugin, c as DEFAULT_STUDIO_URL, i as defineResolver, l as logLevel, n as applyHookResult, o as DEFAULT_BANNER, r as FileManager, s as DEFAULT_EXTENSION, t as PluginDriver, u as camelCase } from "./PluginDriver-
|
|
2
|
+
import { a as definePlugin, c as DEFAULT_STUDIO_URL, i as defineResolver, l as logLevel, n as applyHookResult, o as DEFAULT_BANNER, r as FileManager, s as DEFAULT_EXTENSION, t as PluginDriver, u as camelCase } from "./PluginDriver-T4-THx8t.js";
|
|
3
3
|
import { EventEmitter } from "node:events";
|
|
4
4
|
import { access, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -525,7 +525,7 @@ function createAdapter(build) {
|
|
|
525
525
|
}
|
|
526
526
|
//#endregion
|
|
527
527
|
//#region package.json
|
|
528
|
-
var version$1 = "5.0.0-beta.
|
|
528
|
+
var version$1 = "5.0.0-beta.18";
|
|
529
529
|
//#endregion
|
|
530
530
|
//#region src/createStorage.ts
|
|
531
531
|
/**
|
|
@@ -693,6 +693,66 @@ const fsStorage = createStorage(() => ({
|
|
|
693
693
|
}
|
|
694
694
|
}));
|
|
695
695
|
//#endregion
|
|
696
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/usingCtx.js
|
|
697
|
+
function _usingCtx() {
|
|
698
|
+
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
699
|
+
var n = Error();
|
|
700
|
+
return n.name = "SuppressedError", n.error = r, n.suppressed = e, n;
|
|
701
|
+
};
|
|
702
|
+
var e = {};
|
|
703
|
+
var n = [];
|
|
704
|
+
function using(r, e) {
|
|
705
|
+
if (null != e) {
|
|
706
|
+
if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
707
|
+
if (r) var o = e[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
708
|
+
if (void 0 === o && (o = e[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r)) var t = o;
|
|
709
|
+
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
710
|
+
t && (o = function o() {
|
|
711
|
+
try {
|
|
712
|
+
t.call(e);
|
|
713
|
+
} catch (r) {
|
|
714
|
+
return Promise.reject(r);
|
|
715
|
+
}
|
|
716
|
+
}), n.push({
|
|
717
|
+
v: e,
|
|
718
|
+
d: o,
|
|
719
|
+
a: r
|
|
720
|
+
});
|
|
721
|
+
} else r && n.push({
|
|
722
|
+
d: e,
|
|
723
|
+
a: r
|
|
724
|
+
});
|
|
725
|
+
return e;
|
|
726
|
+
}
|
|
727
|
+
return {
|
|
728
|
+
e,
|
|
729
|
+
u: using.bind(null, !1),
|
|
730
|
+
a: using.bind(null, !0),
|
|
731
|
+
d: function d() {
|
|
732
|
+
var o;
|
|
733
|
+
var t = this.e;
|
|
734
|
+
var s = 0;
|
|
735
|
+
function next() {
|
|
736
|
+
for (; o = n.pop();) try {
|
|
737
|
+
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
738
|
+
if (o.d) {
|
|
739
|
+
var r = o.d.call(o.v);
|
|
740
|
+
if (o.a) return s |= 2, Promise.resolve(r).then(next, err);
|
|
741
|
+
} else s |= 1;
|
|
742
|
+
} catch (r) {
|
|
743
|
+
return err(r);
|
|
744
|
+
}
|
|
745
|
+
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
746
|
+
if (t !== e) throw t;
|
|
747
|
+
}
|
|
748
|
+
function err(n) {
|
|
749
|
+
return t = t !== e ? new r(n, t) : n, next();
|
|
750
|
+
}
|
|
751
|
+
return next();
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
//#endregion
|
|
696
756
|
//#region src/createKubb.ts
|
|
697
757
|
/**
|
|
698
758
|
* Builds a `Storage` view scoped to the file paths produced by the current build.
|
|
@@ -849,11 +909,13 @@ async function setup(userConfig, options = {}) {
|
|
|
849
909
|
hooks,
|
|
850
910
|
driver,
|
|
851
911
|
storage,
|
|
852
|
-
dispose
|
|
853
|
-
|
|
854
|
-
for (const [event, handler] of middlewareListeners) hooks.off(event, handler);
|
|
855
|
-
}
|
|
912
|
+
dispose,
|
|
913
|
+
[Symbol.dispose]: dispose
|
|
856
914
|
};
|
|
915
|
+
function dispose() {
|
|
916
|
+
driver.dispose();
|
|
917
|
+
for (const [event, handler] of middlewareListeners) hooks.off(event, handler);
|
|
918
|
+
}
|
|
857
919
|
}
|
|
858
920
|
/**
|
|
859
921
|
* Single-pass fan-out for streaming mode.
|
|
@@ -1029,7 +1091,9 @@ async function runPluginAstHooks(plugin, context) {
|
|
|
1029
1091
|
...generatorContext,
|
|
1030
1092
|
options
|
|
1031
1093
|
};
|
|
1032
|
-
await Promise.all(generators.filter((gen) => gen.schema).map(
|
|
1094
|
+
await Promise.all(generators.filter((gen) => gen.schema).map(async (gen) => {
|
|
1095
|
+
return applyHookResult(await gen.schema(transformedNode, ctx), driver, resolveRenderer(gen));
|
|
1096
|
+
}));
|
|
1033
1097
|
await driver.hooks.emit("kubb:generate:schema", transformedNode, ctx);
|
|
1034
1098
|
},
|
|
1035
1099
|
async operation(node) {
|
|
@@ -1046,7 +1110,9 @@ async function runPluginAstHooks(plugin, context) {
|
|
|
1046
1110
|
...generatorContext,
|
|
1047
1111
|
options
|
|
1048
1112
|
};
|
|
1049
|
-
await Promise.all(generators.filter((gen) => gen.operation).map(
|
|
1113
|
+
await Promise.all(generators.filter((gen) => gen.operation).map(async (gen) => {
|
|
1114
|
+
return applyHookResult(await gen.operation(transformedNode, ctx), driver, resolveRenderer(gen));
|
|
1115
|
+
}));
|
|
1050
1116
|
await driver.hooks.emit("kubb:generate:operation", transformedNode, ctx);
|
|
1051
1117
|
}
|
|
1052
1118
|
}
|
|
@@ -1064,78 +1130,111 @@ async function runPluginAstHooks(plugin, context) {
|
|
|
1064
1130
|
}
|
|
1065
1131
|
}
|
|
1066
1132
|
async function safeBuild(setupResult) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1133
|
+
try {
|
|
1134
|
+
var _usingCtx$1 = _usingCtx();
|
|
1135
|
+
_usingCtx$1.u(setupResult);
|
|
1136
|
+
const { driver, hooks, storage } = setupResult;
|
|
1137
|
+
const failedPlugins = /* @__PURE__ */ new Set();
|
|
1138
|
+
const pluginTimings = /* @__PURE__ */ new Map();
|
|
1139
|
+
const config = driver.config;
|
|
1140
|
+
const writtenPaths = /* @__PURE__ */ new Set();
|
|
1141
|
+
const parsersMap = /* @__PURE__ */ new Map();
|
|
1142
|
+
for (const parser of config.parsers) if (parser.extNames) for (const extname of parser.extNames) parsersMap.set(extname, parser);
|
|
1143
|
+
const fileProcessor = new FileProcessor();
|
|
1144
|
+
async function flushPendingFiles(snapshot) {
|
|
1145
|
+
const files = driver.fileManager.files.filter((f) => !writtenPaths.has(f.path) && (!snapshot || !snapshot.has(f.path)));
|
|
1146
|
+
if (files.length === 0) return;
|
|
1147
|
+
await hooks.emit("kubb:debug", {
|
|
1148
|
+
date: /* @__PURE__ */ new Date(),
|
|
1149
|
+
logs: [`Writing ${files.length} files...`]
|
|
1150
|
+
});
|
|
1151
|
+
await hooks.emit("kubb:files:processing:start", { files });
|
|
1152
|
+
const stream = fileProcessor.stream(files, {
|
|
1153
|
+
parsers: parsersMap,
|
|
1154
|
+
extension: config.output.extension
|
|
1155
|
+
});
|
|
1156
|
+
for await (const { file, source, processed, total, percentage } of stream) {
|
|
1157
|
+
await hooks.emit("kubb:file:processing:update", {
|
|
1158
|
+
file,
|
|
1159
|
+
source,
|
|
1160
|
+
processed,
|
|
1161
|
+
total,
|
|
1162
|
+
percentage,
|
|
1163
|
+
config
|
|
1164
|
+
});
|
|
1165
|
+
if (source) await storage.setItem(file.path, source);
|
|
1166
|
+
writtenPaths.add(file.path);
|
|
1167
|
+
}
|
|
1168
|
+
await hooks.emit("kubb:files:processing:end", { files });
|
|
1169
|
+
await hooks.emit("kubb:debug", {
|
|
1170
|
+
date: /* @__PURE__ */ new Date(),
|
|
1171
|
+
logs: [`✓ File write process completed for ${files.length} files`]
|
|
1095
1172
|
});
|
|
1096
|
-
if (source) await storage.setItem(file.path, source);
|
|
1097
|
-
writtenPaths.add(file.path);
|
|
1098
1173
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1174
|
+
try {
|
|
1175
|
+
await driver.emitSetupHooks();
|
|
1176
|
+
if (driver.adapter && (driver.inputNode || driver.inputStreamNode)) await hooks.emit("kubb:build:start", {
|
|
1177
|
+
config,
|
|
1178
|
+
adapter: driver.adapter,
|
|
1179
|
+
inputNode: driver.inputNode ?? {
|
|
1180
|
+
kind: "Input",
|
|
1181
|
+
schemas: [],
|
|
1182
|
+
operations: [],
|
|
1183
|
+
meta: driver.inputStreamNode?.meta
|
|
1184
|
+
},
|
|
1185
|
+
getPlugin: driver.getPlugin.bind(driver),
|
|
1186
|
+
get files() {
|
|
1187
|
+
return driver.fileManager.files;
|
|
1188
|
+
},
|
|
1189
|
+
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1190
|
+
});
|
|
1191
|
+
const inputStreamNode = driver.inputStreamNode;
|
|
1192
|
+
if (inputStreamNode) {
|
|
1193
|
+
const streamPluginEntries = [];
|
|
1194
|
+
for (const plugin of driver.plugins.values()) {
|
|
1195
|
+
const context = driver.getContext(plugin);
|
|
1196
|
+
const hrStart = process.hrtime();
|
|
1197
|
+
await hooks.emit("kubb:plugin:start", { plugin });
|
|
1198
|
+
await hooks.emit("kubb:debug", {
|
|
1199
|
+
date: /* @__PURE__ */ new Date(),
|
|
1200
|
+
logs: ["Starting plugin...", ` • Plugin Name: ${plugin.name}`]
|
|
1201
|
+
});
|
|
1202
|
+
if (plugin.generators?.length || driver.hasRegisteredGenerators(plugin.name)) streamPluginEntries.push({
|
|
1203
|
+
plugin,
|
|
1204
|
+
context,
|
|
1205
|
+
hrStart
|
|
1206
|
+
});
|
|
1207
|
+
else {
|
|
1208
|
+
const duration = getElapsedMs(hrStart);
|
|
1209
|
+
pluginTimings.set(plugin.name, duration);
|
|
1210
|
+
await hooks.emit("kubb:plugin:end", {
|
|
1211
|
+
plugin,
|
|
1212
|
+
duration,
|
|
1213
|
+
success: true,
|
|
1214
|
+
config,
|
|
1215
|
+
get files() {
|
|
1216
|
+
return driver.fileManager.files;
|
|
1217
|
+
},
|
|
1218
|
+
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1219
|
+
});
|
|
1220
|
+
await hooks.emit("kubb:debug", {
|
|
1221
|
+
date: /* @__PURE__ */ new Date(),
|
|
1222
|
+
logs: [`✓ Plugin started successfully (${formatMs(duration)})`]
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
if (streamPluginEntries.length > 0) await runPluginStreamHooks(inputStreamNode, streamPluginEntries, driver, hooks, config, pluginTimings, failedPlugins, flushPendingFiles);
|
|
1227
|
+
} else for (const plugin of driver.plugins.values()) {
|
|
1126
1228
|
const context = driver.getContext(plugin);
|
|
1127
1229
|
const hrStart = process.hrtime();
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
context
|
|
1136
|
-
hrStart
|
|
1137
|
-
});
|
|
1138
|
-
else {
|
|
1230
|
+
try {
|
|
1231
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
1232
|
+
await hooks.emit("kubb:plugin:start", { plugin });
|
|
1233
|
+
await hooks.emit("kubb:debug", {
|
|
1234
|
+
date: timestamp,
|
|
1235
|
+
logs: ["Starting plugin...", ` • Plugin Name: ${plugin.name}`]
|
|
1236
|
+
});
|
|
1237
|
+
if (plugin.generators?.length || driver.hasRegisteredGenerators(plugin.name)) await runPluginAstHooks(plugin, context);
|
|
1139
1238
|
const duration = getElapsedMs(hrStart);
|
|
1140
1239
|
pluginTimings.set(plugin.name, duration);
|
|
1141
1240
|
await hooks.emit("kubb:plugin:end", {
|
|
@@ -1152,100 +1251,73 @@ async function safeBuild(setupResult) {
|
|
|
1152
1251
|
date: /* @__PURE__ */ new Date(),
|
|
1153
1252
|
logs: [`✓ Plugin started successfully (${formatMs(duration)})`]
|
|
1154
1253
|
});
|
|
1254
|
+
} catch (caughtError) {
|
|
1255
|
+
const error = caughtError;
|
|
1256
|
+
const errorTimestamp = /* @__PURE__ */ new Date();
|
|
1257
|
+
const duration = getElapsedMs(hrStart);
|
|
1258
|
+
await hooks.emit("kubb:plugin:end", {
|
|
1259
|
+
plugin,
|
|
1260
|
+
duration,
|
|
1261
|
+
success: false,
|
|
1262
|
+
error,
|
|
1263
|
+
config,
|
|
1264
|
+
get files() {
|
|
1265
|
+
return driver.fileManager.files;
|
|
1266
|
+
},
|
|
1267
|
+
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1268
|
+
});
|
|
1269
|
+
await hooks.emit("kubb:debug", {
|
|
1270
|
+
date: errorTimestamp,
|
|
1271
|
+
logs: [
|
|
1272
|
+
"✗ Plugin start failed",
|
|
1273
|
+
` • Plugin Name: ${plugin.name}`,
|
|
1274
|
+
` • Error: ${error.constructor.name} - ${error.message}`,
|
|
1275
|
+
" • Stack Trace:",
|
|
1276
|
+
error.stack || "No stack trace available"
|
|
1277
|
+
]
|
|
1278
|
+
});
|
|
1279
|
+
failedPlugins.add({
|
|
1280
|
+
plugin,
|
|
1281
|
+
error
|
|
1282
|
+
});
|
|
1155
1283
|
}
|
|
1284
|
+
await flushPendingFiles();
|
|
1156
1285
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
await hooks.emit("kubb:debug", {
|
|
1165
|
-
date: timestamp,
|
|
1166
|
-
logs: ["Starting plugin...", ` • Plugin Name: ${plugin.name}`]
|
|
1167
|
-
});
|
|
1168
|
-
if (plugin.generators?.length || driver.hasRegisteredGenerators(plugin.name)) await runPluginAstHooks(plugin, context);
|
|
1169
|
-
const duration = getElapsedMs(hrStart);
|
|
1170
|
-
pluginTimings.set(plugin.name, duration);
|
|
1171
|
-
await hooks.emit("kubb:plugin:end", {
|
|
1172
|
-
plugin,
|
|
1173
|
-
duration,
|
|
1174
|
-
success: true,
|
|
1175
|
-
config,
|
|
1176
|
-
get files() {
|
|
1177
|
-
return driver.fileManager.files;
|
|
1178
|
-
},
|
|
1179
|
-
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1180
|
-
});
|
|
1181
|
-
await hooks.emit("kubb:debug", {
|
|
1182
|
-
date: /* @__PURE__ */ new Date(),
|
|
1183
|
-
logs: [`✓ Plugin started successfully (${formatMs(duration)})`]
|
|
1184
|
-
});
|
|
1185
|
-
} catch (caughtError) {
|
|
1186
|
-
const error = caughtError;
|
|
1187
|
-
const errorTimestamp = /* @__PURE__ */ new Date();
|
|
1188
|
-
const duration = getElapsedMs(hrStart);
|
|
1189
|
-
await hooks.emit("kubb:plugin:end", {
|
|
1190
|
-
plugin,
|
|
1191
|
-
duration,
|
|
1192
|
-
success: false,
|
|
1193
|
-
error,
|
|
1194
|
-
config,
|
|
1195
|
-
get files() {
|
|
1196
|
-
return driver.fileManager.files;
|
|
1197
|
-
},
|
|
1198
|
-
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1199
|
-
});
|
|
1200
|
-
await hooks.emit("kubb:debug", {
|
|
1201
|
-
date: errorTimestamp,
|
|
1202
|
-
logs: [
|
|
1203
|
-
"✗ Plugin start failed",
|
|
1204
|
-
` • Plugin Name: ${plugin.name}`,
|
|
1205
|
-
` • Error: ${error.constructor.name} - ${error.message}`,
|
|
1206
|
-
" • Stack Trace:",
|
|
1207
|
-
error.stack || "No stack trace available"
|
|
1208
|
-
]
|
|
1209
|
-
});
|
|
1210
|
-
failedPlugins.add({
|
|
1211
|
-
plugin,
|
|
1212
|
-
error
|
|
1213
|
-
});
|
|
1214
|
-
}
|
|
1286
|
+
await hooks.emit("kubb:plugins:end", {
|
|
1287
|
+
config,
|
|
1288
|
+
get files() {
|
|
1289
|
+
return driver.fileManager.files;
|
|
1290
|
+
},
|
|
1291
|
+
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1292
|
+
});
|
|
1215
1293
|
await flushPendingFiles();
|
|
1294
|
+
const files = driver.fileManager.files;
|
|
1295
|
+
await hooks.emit("kubb:build:end", {
|
|
1296
|
+
files,
|
|
1297
|
+
config,
|
|
1298
|
+
outputDir: resolve(config.root, config.output.path)
|
|
1299
|
+
});
|
|
1300
|
+
return {
|
|
1301
|
+
failedPlugins,
|
|
1302
|
+
files,
|
|
1303
|
+
driver,
|
|
1304
|
+
pluginTimings,
|
|
1305
|
+
storage
|
|
1306
|
+
};
|
|
1307
|
+
} catch (error) {
|
|
1308
|
+
return {
|
|
1309
|
+
failedPlugins,
|
|
1310
|
+
files: [],
|
|
1311
|
+
driver,
|
|
1312
|
+
pluginTimings,
|
|
1313
|
+
error,
|
|
1314
|
+
storage
|
|
1315
|
+
};
|
|
1216
1316
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
get files() {
|
|
1220
|
-
return driver.fileManager.files;
|
|
1221
|
-
},
|
|
1222
|
-
upsertFile: (...files) => driver.fileManager.upsert(...files)
|
|
1223
|
-
});
|
|
1224
|
-
await flushPendingFiles();
|
|
1225
|
-
const files = driver.fileManager.files;
|
|
1226
|
-
await hooks.emit("kubb:build:end", {
|
|
1227
|
-
files,
|
|
1228
|
-
config,
|
|
1229
|
-
outputDir: resolve(config.root, config.output.path)
|
|
1230
|
-
});
|
|
1231
|
-
return {
|
|
1232
|
-
failedPlugins,
|
|
1233
|
-
files,
|
|
1234
|
-
driver,
|
|
1235
|
-
pluginTimings,
|
|
1236
|
-
storage
|
|
1237
|
-
};
|
|
1238
|
-
} catch (error) {
|
|
1239
|
-
return {
|
|
1240
|
-
failedPlugins,
|
|
1241
|
-
files: [],
|
|
1242
|
-
driver,
|
|
1243
|
-
pluginTimings,
|
|
1244
|
-
error,
|
|
1245
|
-
storage
|
|
1246
|
-
};
|
|
1317
|
+
} catch (_) {
|
|
1318
|
+
_usingCtx$1.e = _;
|
|
1247
1319
|
} finally {
|
|
1248
|
-
|
|
1320
|
+
_usingCtx$1.d();
|
|
1249
1321
|
}
|
|
1250
1322
|
}
|
|
1251
1323
|
async function build(setupResult) {
|
|
@@ -1353,15 +1425,10 @@ function createKubb(userConfig, options = {}) {
|
|
|
1353
1425
|
//#endregion
|
|
1354
1426
|
//#region src/createRenderer.ts
|
|
1355
1427
|
/**
|
|
1356
|
-
*
|
|
1357
|
-
*
|
|
1358
|
-
* Wrap your renderer factory function with this helper to register it as the
|
|
1359
|
-
* renderer for a generator. Core will call this factory once per render cycle
|
|
1360
|
-
* to obtain a fresh renderer instance.
|
|
1428
|
+
* Wraps a renderer factory for use in generator definitions.
|
|
1361
1429
|
*
|
|
1362
1430
|
* @example
|
|
1363
1431
|
* ```ts
|
|
1364
|
-
* // packages/renderer-jsx/src/index.ts
|
|
1365
1432
|
* export const jsxRenderer = createRenderer(() => {
|
|
1366
1433
|
* const runtime = new Runtime()
|
|
1367
1434
|
* return {
|
|
@@ -1370,14 +1437,6 @@ function createKubb(userConfig, options = {}) {
|
|
|
1370
1437
|
* unmount(error) { runtime.unmount(error) },
|
|
1371
1438
|
* }
|
|
1372
1439
|
* })
|
|
1373
|
-
*
|
|
1374
|
-
* // packages/plugin-zod/src/generators/zodGenerator.tsx
|
|
1375
|
-
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
1376
|
-
* export const zodGenerator = defineGenerator<PluginZod>({
|
|
1377
|
-
* name: 'zod',
|
|
1378
|
-
* renderer: jsxRenderer,
|
|
1379
|
-
* schema(node, options) { return <File ...>...</File> },
|
|
1380
|
-
* })
|
|
1381
1440
|
* ```
|
|
1382
1441
|
*/
|
|
1383
1442
|
function createRenderer(factory) {
|