@kosdev-code/kos-ui-plugin 2.1.17 → 2.1.19

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.
Files changed (58) hide show
  1. package/documentation-generator-CAlVz5vA.cjs +266 -0
  2. package/documentation-generator-CAlVz5vA.cjs.map +1 -0
  3. package/documentation-generator-Di4c9D9P.js +2337 -0
  4. package/documentation-generator-Di4c9D9P.js.map +1 -0
  5. package/index.cjs +69 -69
  6. package/index.cjs.map +1 -1
  7. package/index.d.ts +1 -0
  8. package/index.d.ts.map +1 -1
  9. package/index.js +817 -753
  10. package/index.js.map +1 -1
  11. package/lib/components/dynamic-component/dynamic-component.d.ts +69 -0
  12. package/lib/components/dynamic-component/dynamic-component.d.ts.map +1 -1
  13. package/lib/contexts/index.d.ts +1 -0
  14. package/lib/contexts/index.d.ts.map +1 -1
  15. package/lib/contexts/plugins-provider/plugins-provider.d.ts.map +1 -1
  16. package/lib/contexts/reactive-extension-registry-context.d.ts +10 -0
  17. package/lib/contexts/reactive-extension-registry-context.d.ts.map +1 -0
  18. package/lib/hooks/index.d.ts +4 -2
  19. package/lib/hooks/index.d.ts.map +1 -1
  20. package/lib/hooks/use-dynamic-component.d.ts +12 -1
  21. package/lib/hooks/use-dynamic-component.d.ts.map +1 -1
  22. package/lib/hooks/use-extension-point.d.ts +95 -0
  23. package/lib/hooks/use-extension-point.d.ts.map +1 -0
  24. package/lib/hooks/use-reactive-extension-registry.d.ts +20 -0
  25. package/lib/hooks/use-reactive-extension-registry.d.ts.map +1 -0
  26. package/lib/hooks/use-typed-extensions.d.ts.map +1 -1
  27. package/lib/utils/contribution-registry.d.ts +170 -0
  28. package/lib/utils/contribution-registry.d.ts.map +1 -0
  29. package/lib/utils/extension-points/extension-point-registry.d.ts.map +1 -1
  30. package/lib/utils/extension-points/extension-point-schemas.d.ts +4 -4
  31. package/lib/utils/index.d.ts +3 -0
  32. package/lib/utils/index.d.ts.map +1 -1
  33. package/lib/utils/plugin-system/plugin-extension-manager.d.ts.map +1 -1
  34. package/lib/utils/processors/initialize-plugins.d.ts.map +1 -1
  35. package/lib/utils/reactive-extension-registry.d.ts +140 -0
  36. package/lib/utils/reactive-extension-registry.d.ts.map +1 -0
  37. package/lib/webpack/index.d.ts +2 -0
  38. package/lib/webpack/index.d.ts.map +1 -1
  39. package/lib/webpack/with-plugin-dev-aggregator.d.ts +94 -0
  40. package/lib/webpack/with-plugin-dev-aggregator.d.ts.map +1 -0
  41. package/lib/webpack/with-plugin-dev-server.d.ts +113 -0
  42. package/lib/webpack/with-plugin-dev-server.d.ts.map +1 -0
  43. package/package.json +2 -2
  44. package/types/contribution-enablement.d.ts +293 -0
  45. package/types/contribution-enablement.d.ts.map +1 -0
  46. package/types/plugins.d.ts +8 -0
  47. package/utils.cjs +1 -1
  48. package/utils.cjs.map +1 -1
  49. package/utils.js +29 -291
  50. package/utils.js.map +1 -1
  51. package/webpack.cjs +3 -12
  52. package/webpack.cjs.map +1 -1
  53. package/webpack.js +455 -727
  54. package/webpack.js.map +1 -1
  55. package/documentation-generator-DFaIDo0E.cjs +0 -266
  56. package/documentation-generator-DFaIDo0E.cjs.map +0 -1
  57. package/documentation-generator-auruIa_o.js +0 -1560
  58. package/documentation-generator-auruIa_o.js.map +0 -1
package/webpack.js CHANGED
@@ -1,795 +1,523 @@
1
- var he = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
- function me(e) {
3
- if (e.__esModule)
4
- return e;
5
- var r = e.default;
6
- if (typeof r == "function") {
7
- var t = function o() {
8
- return this instanceof o ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
9
- };
10
- t.prototype = r.prototype;
11
- } else
12
- t = {};
13
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(o) {
14
- var u = Object.getOwnPropertyDescriptor(e, o);
15
- Object.defineProperty(t, o, u.get ? u : {
16
- enumerable: !0,
17
- get: function() {
18
- return e[o];
19
- }
20
- });
21
- }), t;
22
- }
23
- var S = { exports: {} };
24
- const be = {}, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
25
- __proto__: null,
26
- default: be
27
- }, Symbol.toStringTag, { value: "Module" })), Z = /* @__PURE__ */ me(Ee);
28
- var V = { exports: {} }, ne = {}, we = function(r) {
29
- return r && typeof r == "object" && typeof r.copy == "function" && typeof r.fill == "function" && typeof r.readUInt8 == "function";
30
- }, G = { exports: {} };
31
- typeof Object.create == "function" ? G.exports = function(r, t) {
32
- r.super_ = t, r.prototype = Object.create(t.prototype, {
33
- constructor: {
34
- value: r,
35
- enumerable: !1,
36
- writable: !0,
37
- configurable: !0
38
- }
39
- });
40
- } : G.exports = function(r, t) {
41
- r.super_ = t;
42
- var o = function() {
43
- };
44
- o.prototype = t.prototype, r.prototype = new o(), r.prototype.constructor = r;
45
- };
46
- var _e = G.exports;
47
- (function(e) {
48
- var r = /%[sdj%]/g;
49
- e.format = function(n) {
50
- if (!z(n)) {
51
- for (var i = [], s = 0; s < arguments.length; s++)
52
- i.push(u(arguments[s]));
53
- return i.join(" ");
54
- }
55
- for (var s = 1, p = arguments, _ = p.length, g = String(n).replace(r, function(d) {
56
- if (d === "%%")
57
- return "%";
58
- if (s >= _)
59
- return d;
60
- switch (d) {
61
- case "%s":
62
- return String(p[s++]);
63
- case "%d":
64
- return Number(p[s++]);
65
- case "%j":
66
- try {
67
- return JSON.stringify(p[s++]);
68
- } catch {
69
- return "[Circular]";
70
- }
71
- default:
72
- return d;
73
- }
74
- }), c = p[s]; s < _; c = p[++s])
75
- I(c) || !T(c) ? g += " " + c : g += " " + u(c);
76
- return g;
77
- }, e.deprecate = function(n, i) {
78
- if (N(he.process))
79
- return function() {
80
- return e.deprecate(n, i).apply(this, arguments);
81
- };
82
- if (process.noDeprecation === !0)
83
- return n;
84
- var s = !1;
85
- function p() {
86
- if (!s) {
87
- if (process.throwDeprecation)
88
- throw new Error(i);
89
- process.traceDeprecation ? console.trace(i) : console.error(i), s = !0;
90
- }
91
- return n.apply(this, arguments);
92
- }
93
- return p;
94
- };
95
- var t = {}, o;
96
- e.debuglog = function(n) {
97
- if (N(o) && (o = process.env.NODE_DEBUG || ""), n = n.toUpperCase(), !t[n])
98
- if (new RegExp("\\b" + n + "\\b", "i").test(o)) {
99
- var i = process.pid;
100
- t[n] = function() {
101
- var s = e.format.apply(e, arguments);
102
- console.error("%s %d: %s", n, i, s);
103
- };
104
- } else
105
- t[n] = function() {
106
- };
107
- return t[n];
108
- };
109
- function u(n, i) {
110
- var s = {
111
- seen: [],
112
- stylize: l
113
- };
114
- return arguments.length >= 3 && (s.depth = arguments[2]), arguments.length >= 4 && (s.colors = arguments[3]), M(i) ? s.showHidden = i : i && e._extend(s, i), N(s.showHidden) && (s.showHidden = !1), N(s.depth) && (s.depth = 2), N(s.colors) && (s.colors = !1), N(s.customInspect) && (s.customInspect = !0), s.colors && (s.stylize = a), v(s, n, s.depth);
115
- }
116
- e.inspect = u, u.colors = {
117
- bold: [1, 22],
118
- italic: [3, 23],
119
- underline: [4, 24],
120
- inverse: [7, 27],
121
- white: [37, 39],
122
- grey: [90, 39],
123
- black: [30, 39],
124
- blue: [34, 39],
125
- cyan: [36, 39],
126
- green: [32, 39],
127
- magenta: [35, 39],
128
- red: [31, 39],
129
- yellow: [33, 39]
130
- }, u.styles = {
131
- special: "cyan",
132
- number: "yellow",
133
- boolean: "yellow",
134
- undefined: "grey",
135
- null: "bold",
136
- string: "green",
137
- date: "magenta",
138
- // "name": intentionally not styling
139
- regexp: "red"
140
- };
141
- function a(n, i) {
142
- var s = u.styles[i];
143
- return s ? "\x1B[" + u.colors[s][0] + "m" + n + "\x1B[" + u.colors[s][1] + "m" : n;
144
- }
145
- function l(n, i) {
146
- return n;
147
- }
148
- function f(n) {
149
- var i = {};
150
- return n.forEach(function(s, p) {
151
- i[s] = !0;
152
- }), i;
153
- }
154
- function v(n, i, s) {
155
- if (n.customInspect && i && L(i.inspect) && // Filter out the util module, it's inspect function is special
156
- i.inspect !== e.inspect && // Also filter out any prototype objects using the circular check.
157
- !(i.constructor && i.constructor.prototype === i)) {
158
- var p = i.inspect(s, n);
159
- return z(p) || (p = v(n, p, s)), p;
160
- }
161
- var _ = h(n, i);
162
- if (_)
163
- return _;
164
- var g = Object.keys(i), c = f(g);
165
- if (n.showHidden && (g = Object.getOwnPropertyNames(i)), R(i) && (g.indexOf("message") >= 0 || g.indexOf("description") >= 0))
166
- return y(i);
167
- if (g.length === 0) {
168
- if (L(i)) {
169
- var d = i.name ? ": " + i.name : "";
170
- return n.stylize("[Function" + d + "]", "special");
171
- }
172
- if (k(i))
173
- return n.stylize(RegExp.prototype.toString.call(i), "regexp");
174
- if (F(i))
175
- return n.stylize(Date.prototype.toString.call(i), "date");
176
- if (R(i))
177
- return y(i);
178
- }
179
- var w = "", A = !1, U = ["{", "}"];
180
- if (x(i) && (A = !0, U = ["[", "]"]), L(i)) {
181
- var ve = i.name ? ": " + i.name : "";
182
- w = " [Function" + ve + "]";
183
- }
184
- if (k(i) && (w = " " + RegExp.prototype.toString.call(i)), F(i) && (w = " " + Date.prototype.toUTCString.call(i)), R(i) && (w = " " + y(i)), g.length === 0 && (!A || i.length == 0))
185
- return U[0] + w + U[1];
186
- if (s < 0)
187
- return k(i) ? n.stylize(RegExp.prototype.toString.call(i), "regexp") : n.stylize("[Object]", "special");
188
- n.seen.push(i);
189
- var W;
190
- return A ? W = $(n, i, s, c, g) : W = g.map(function(ye) {
191
- return O(n, i, s, c, ye, A);
192
- }), n.seen.pop(), le(W, w, U);
193
- }
194
- function h(n, i) {
195
- if (N(i))
196
- return n.stylize("undefined", "undefined");
197
- if (z(i)) {
198
- var s = "'" + JSON.stringify(i).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
199
- return n.stylize(s, "string");
200
- }
201
- if (ee(i))
202
- return n.stylize("" + i, "number");
203
- if (M(i))
204
- return n.stylize("" + i, "boolean");
205
- if (I(i))
206
- return n.stylize("null", "null");
207
- }
208
- function y(n) {
209
- return "[" + Error.prototype.toString.call(n) + "]";
210
- }
211
- function $(n, i, s, p, _) {
212
- for (var g = [], c = 0, d = i.length; c < d; ++c)
213
- re(i, String(c)) ? g.push(O(
214
- n,
215
- i,
216
- s,
217
- p,
218
- String(c),
219
- !0
220
- )) : g.push("");
221
- return _.forEach(function(w) {
222
- w.match(/^\d+$/) || g.push(O(
223
- n,
224
- i,
225
- s,
226
- p,
227
- w,
228
- !0
229
- ));
230
- }), g;
231
- }
232
- function O(n, i, s, p, _, g) {
233
- var c, d, w;
234
- if (w = Object.getOwnPropertyDescriptor(i, _) || { value: i[_] }, w.get ? w.set ? d = n.stylize("[Getter/Setter]", "special") : d = n.stylize("[Getter]", "special") : w.set && (d = n.stylize("[Setter]", "special")), re(p, _) || (c = "[" + _ + "]"), d || (n.seen.indexOf(w.value) < 0 ? (I(s) ? d = v(n, w.value, null) : d = v(n, w.value, s - 1), d.indexOf(`
235
- `) > -1 && (g ? d = d.split(`
236
- `).map(function(A) {
237
- return " " + A;
238
- }).join(`
239
- `).substr(2) : d = `
240
- ` + d.split(`
241
- `).map(function(A) {
242
- return " " + A;
243
- }).join(`
244
- `))) : d = n.stylize("[Circular]", "special")), N(c)) {
245
- if (g && _.match(/^\d+$/))
246
- return d;
247
- c = JSON.stringify("" + _), c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (c = c.substr(1, c.length - 2), c = n.stylize(c, "name")) : (c = c.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), c = n.stylize(c, "string"));
248
- }
249
- return c + ": " + d;
250
- }
251
- function le(n, i, s) {
252
- var p = n.reduce(function(_, g) {
253
- return g.indexOf(`
254
- `) >= 0, _ + g.replace(/\u001b\[\d\d?m/g, "").length + 1;
255
- }, 0);
256
- return p > 60 ? s[0] + (i === "" ? "" : i + `
257
- `) + " " + n.join(`,
258
- `) + " " + s[1] : s[0] + i + " " + n.join(", ") + " " + s[1];
259
- }
260
- function x(n) {
261
- return Array.isArray(n);
262
- }
263
- e.isArray = x;
264
- function M(n) {
265
- return typeof n == "boolean";
266
- }
267
- e.isBoolean = M;
268
- function I(n) {
269
- return n === null;
270
- }
271
- e.isNull = I;
272
- function fe(n) {
273
- return n == null;
274
- }
275
- e.isNullOrUndefined = fe;
276
- function ee(n) {
277
- return typeof n == "number";
278
- }
279
- e.isNumber = ee;
280
- function z(n) {
281
- return typeof n == "string";
282
- }
283
- e.isString = z;
284
- function ce(n) {
285
- return typeof n == "symbol";
286
- }
287
- e.isSymbol = ce;
288
- function N(n) {
289
- return n === void 0;
290
- }
291
- e.isUndefined = N;
292
- function k(n) {
293
- return T(n) && J(n) === "[object RegExp]";
294
- }
295
- e.isRegExp = k;
296
- function T(n) {
297
- return typeof n == "object" && n !== null;
298
- }
299
- e.isObject = T;
300
- function F(n) {
301
- return T(n) && J(n) === "[object Date]";
302
- }
303
- e.isDate = F;
304
- function R(n) {
305
- return T(n) && (J(n) === "[object Error]" || n instanceof Error);
306
- }
307
- e.isError = R;
308
- function L(n) {
309
- return typeof n == "function";
310
- }
311
- e.isFunction = L;
312
- function pe(n) {
313
- return n === null || typeof n == "boolean" || typeof n == "number" || typeof n == "string" || typeof n == "symbol" || // ES6 symbol
314
- typeof n > "u";
315
- }
316
- e.isPrimitive = pe, e.isBuffer = we;
317
- function J(n) {
318
- return Object.prototype.toString.call(n);
319
- }
320
- function q(n) {
321
- return n < 10 ? "0" + n.toString(10) : n.toString(10);
322
- }
323
- var ge = [
324
- "Jan",
325
- "Feb",
326
- "Mar",
327
- "Apr",
328
- "May",
329
- "Jun",
330
- "Jul",
331
- "Aug",
332
- "Sep",
333
- "Oct",
334
- "Nov",
335
- "Dec"
336
- ];
337
- function de() {
338
- var n = /* @__PURE__ */ new Date(), i = [
339
- q(n.getHours()),
340
- q(n.getMinutes()),
341
- q(n.getSeconds())
342
- ].join(":");
343
- return [n.getDate(), ge[n.getMonth()], i].join(" ");
344
- }
345
- e.log = function() {
346
- console.log("%s - %s", de(), e.format.apply(e, arguments));
347
- }, e.inherits = _e, e._extend = function(n, i) {
348
- if (!i || !T(i))
349
- return n;
350
- for (var s = Object.keys(i), p = s.length; p--; )
351
- n[s[p]] = i[s[p]];
352
- return n;
353
- };
354
- function re(n, i) {
355
- return Object.prototype.hasOwnProperty.call(n, i);
356
- }
357
- })(ne);
358
- var De = process.platform === "win32", D = ne;
359
- function C(e, r) {
360
- for (var t = [], o = 0; o < e.length; o++) {
361
- var u = e[o];
362
- !u || u === "." || (u === ".." ? t.length && t[t.length - 1] !== ".." ? t.pop() : r && t.push("..") : t.push(u));
363
- }
364
- return t;
365
- }
366
- function j(e) {
367
- for (var r = e.length - 1, t = 0; t <= r && !e[t]; t++)
368
- ;
369
- for (var o = r; o >= 0 && !e[o]; o--)
370
- ;
371
- return t === 0 && o === r ? e : t > o ? [] : e.slice(t, o + 1);
372
- }
373
- var oe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/, Ne = /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/, m = {};
374
- function Y(e) {
375
- var r = oe.exec(e), t = (r[1] || "") + (r[2] || ""), o = r[3] || "", u = Ne.exec(o), a = u[1], l = u[2], f = u[3];
376
- return [t, a, l, f];
377
- }
378
- function Q(e) {
379
- var r = oe.exec(e), t = r[1] || "", o = !!t && t[1] !== ":";
380
- return {
381
- device: t,
382
- isUnc: o,
383
- isAbsolute: o || !!r[2],
384
- // UNC paths are always absolute
385
- tail: r[3]
386
- };
387
- }
388
- function ie(e) {
389
- return "\\\\" + e.replace(/^[\\\/]+/, "").replace(/[\\\/]+/g, "\\");
390
- }
391
- m.resolve = function() {
392
- for (var e = "", r = "", t = !1, o = arguments.length - 1; o >= -1; o--) {
393
- var u;
394
- if (o >= 0 ? u = arguments[o] : e ? (u = process.env["=" + e], (!u || u.substr(0, 3).toLowerCase() !== e.toLowerCase() + "\\") && (u = e + "\\")) : u = process.cwd(), D.isString(u)) {
395
- if (!u)
396
- continue;
397
- } else
398
- throw new TypeError("Arguments to path.resolve must be strings");
399
- var a = Q(u), l = a.device, f = a.isUnc, v = a.isAbsolute, h = a.tail;
400
- if (!(l && e && l.toLowerCase() !== e.toLowerCase()) && (e || (e = l), t || (r = h + "\\" + r, t = v), e && t))
401
- break;
402
- }
403
- return f && (e = ie(e)), r = C(
404
- r.split(/[\\\/]+/),
405
- !t
406
- ).join("\\"), e + (t ? "\\" : "") + r || ".";
407
- };
408
- m.normalize = function(e) {
409
- var r = Q(e), t = r.device, o = r.isUnc, u = r.isAbsolute, a = r.tail, l = /[\\\/]$/.test(a);
410
- return a = C(a.split(/[\\\/]+/), !u).join("\\"), !a && !u && (a = "."), a && l && (a += "\\"), o && (t = ie(t)), t + (u ? "\\" : "") + a;
411
- };
412
- m.isAbsolute = function(e) {
413
- return Q(e).isAbsolute;
414
- };
415
- m.join = function() {
416
- for (var e = [], r = 0; r < arguments.length; r++) {
417
- var t = arguments[r];
418
- if (!D.isString(t))
419
- throw new TypeError("Arguments to path.join must be strings");
420
- t && e.push(t);
421
- }
422
- var o = e.join("\\");
423
- return /^[\\\/]{2}[^\\\/]/.test(e[0]) || (o = o.replace(/^[\\\/]{2,}/, "\\")), m.normalize(o);
424
- };
425
- m.relative = function(e, r) {
426
- e = m.resolve(e), r = m.resolve(r);
427
- for (var t = e.toLowerCase(), o = r.toLowerCase(), u = j(r.split("\\")), a = j(t.split("\\")), l = j(o.split("\\")), f = Math.min(a.length, l.length), v = f, h = 0; h < f; h++)
428
- if (a[h] !== l[h]) {
429
- v = h;
430
- break;
431
- }
432
- if (v == 0)
433
- return r;
434
- for (var y = [], h = v; h < a.length; h++)
435
- y.push("..");
436
- return y = y.concat(u.slice(v)), y.join("\\");
437
- };
438
- m._makeLong = function(e) {
439
- if (!D.isString(e))
440
- return e;
441
- if (!e)
442
- return "";
443
- var r = m.resolve(e);
444
- return /^[a-zA-Z]\:\\/.test(r) ? "\\\\?\\" + r : /^\\\\[^?.]/.test(r) ? "\\\\?\\UNC\\" + r.substring(2) : e;
445
- };
446
- m.dirname = function(e) {
447
- var r = Y(e), t = r[0], o = r[1];
448
- return !t && !o ? "." : (o && (o = o.substr(0, o.length - 1)), t + o);
449
- };
450
- m.basename = function(e, r) {
451
- var t = Y(e)[2];
452
- return r && t.substr(-1 * r.length) === r && (t = t.substr(0, t.length - r.length)), t;
453
- };
454
- m.extname = function(e) {
455
- return Y(e)[3];
456
- };
457
- m.format = function(e) {
458
- if (!D.isObject(e))
459
- throw new TypeError(
460
- "Parameter 'pathObject' must be an object, not " + typeof e
461
- );
462
- var r = e.root || "";
463
- if (!D.isString(r))
464
- throw new TypeError(
465
- "'pathObject.root' must be a string or undefined, not " + typeof e.root
466
- );
467
- var t = e.dir, o = e.base || "";
468
- return t ? t[t.length - 1] === m.sep ? t + o : t + m.sep + o : o;
469
- };
470
- m.parse = function(e) {
471
- if (!D.isString(e))
472
- throw new TypeError(
473
- "Parameter 'pathString' must be a string, not " + typeof e
474
- );
475
- var r = Y(e);
476
- if (!r || r.length !== 4)
477
- throw new TypeError("Invalid path '" + e + "'");
478
- return {
479
- root: r[0],
480
- dir: r[0] + r[1].slice(0, -1),
481
- base: r[2],
482
- ext: r[3],
483
- name: r[2].slice(0, r[2].length - r[3].length)
484
- };
485
- };
486
- m.sep = "\\";
487
- m.delimiter = ";";
488
- var Oe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/, b = {};
489
- function B(e) {
490
- return Oe.exec(e).slice(1);
491
- }
492
- b.resolve = function() {
493
- for (var e = "", r = !1, t = arguments.length - 1; t >= -1 && !r; t--) {
494
- var o = t >= 0 ? arguments[t] : process.cwd();
495
- if (D.isString(o)) {
496
- if (!o)
497
- continue;
498
- } else
499
- throw new TypeError("Arguments to path.resolve must be strings");
500
- e = o + "/" + e, r = o[0] === "/";
501
- }
502
- return e = C(
503
- e.split("/"),
504
- !r
505
- ).join("/"), (r ? "/" : "") + e || ".";
506
- };
507
- b.normalize = function(e) {
508
- var r = b.isAbsolute(e), t = e && e[e.length - 1] === "/";
509
- return e = C(e.split("/"), !r).join("/"), !e && !r && (e = "."), e && t && (e += "/"), (r ? "/" : "") + e;
510
- };
511
- b.isAbsolute = function(e) {
512
- return e.charAt(0) === "/";
513
- };
514
- b.join = function() {
515
- for (var e = "", r = 0; r < arguments.length; r++) {
516
- var t = arguments[r];
517
- if (!D.isString(t))
518
- throw new TypeError("Arguments to path.join must be strings");
519
- t && (e ? e += "/" + t : e += t);
520
- }
521
- return b.normalize(e);
522
- };
523
- b.relative = function(e, r) {
524
- e = b.resolve(e).substr(1), r = b.resolve(r).substr(1);
525
- for (var t = j(e.split("/")), o = j(r.split("/")), u = Math.min(t.length, o.length), a = u, l = 0; l < u; l++)
526
- if (t[l] !== o[l]) {
527
- a = l;
528
- break;
529
- }
530
- for (var f = [], l = a; l < t.length; l++)
531
- f.push("..");
532
- return f = f.concat(o.slice(a)), f.join("/");
533
- };
534
- b._makeLong = function(e) {
535
- return e;
536
- };
537
- b.dirname = function(e) {
538
- var r = B(e), t = r[0], o = r[1];
539
- return !t && !o ? "." : (o && (o = o.substr(0, o.length - 1)), t + o);
540
- };
541
- b.basename = function(e, r) {
542
- var t = B(e)[2];
543
- return r && t.substr(-1 * r.length) === r && (t = t.substr(0, t.length - r.length)), t;
544
- };
545
- b.extname = function(e) {
546
- return B(e)[3];
547
- };
548
- b.format = function(e) {
549
- if (!D.isObject(e))
550
- throw new TypeError(
551
- "Parameter 'pathObject' must be an object, not " + typeof e
552
- );
553
- var r = e.root || "";
554
- if (!D.isString(r))
555
- throw new TypeError(
556
- "'pathObject.root' must be a string or undefined, not " + typeof e.root
557
- );
558
- var t = e.dir ? e.dir + b.sep : "", o = e.base || "";
559
- return t + o;
560
- };
561
- b.parse = function(e) {
562
- if (!D.isString(e))
563
- throw new TypeError(
564
- "Parameter 'pathString' must be a string, not " + typeof e
565
- );
566
- var r = B(e);
567
- if (!r || r.length !== 4)
568
- throw new TypeError("Invalid path '" + e + "'");
569
- return r[1] = r[1] || "", r[2] = r[2] || "", r[3] = r[3] || "", {
570
- root: r[0],
571
- dir: r[0] + r[1].slice(0, -1),
572
- base: r[2],
573
- ext: r[3],
574
- name: r[2].slice(0, r[2].length - r[3].length)
575
- };
576
- };
577
- b.sep = "/";
578
- b.delimiter = ":";
579
- De ? V.exports = m : V.exports = b;
580
- V.exports.posix = b;
581
- V.exports.win32 = m;
582
- var Ae = V.exports;
583
- const Se = "16.6.1", Te = {
584
- version: Se
585
- }, H = Z, K = Ae, je = Z, Pe = Z, Ve = Te, X = Ve.version, $e = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
586
- function Ie(e) {
1
+ import * as U from "fs";
2
+ import ee, { readFileSync as te } from "fs";
3
+ import * as W from "path";
4
+ import re, { join as Q } from "path";
5
+ import oe from "os";
6
+ import ne from "crypto";
7
+ import { v4 as C } from "uuid";
8
+ var b = { exports: {} };
9
+ const se = "16.6.1", ae = {
10
+ version: se
11
+ }, J = ee, Y = re, ie = oe, le = ne, ce = ae, B = ce.version, ue = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
12
+ function ge(e) {
587
13
  const r = {};
588
- let t = e.toString();
589
- t = t.replace(/\r\n?/mg, `
14
+ let s = e.toString();
15
+ s = s.replace(/\r\n?/mg, `
590
16
  `);
591
- let o;
592
- for (; (o = $e.exec(t)) != null; ) {
593
- const u = o[1];
594
- let a = o[2] || "";
595
- a = a.trim();
596
- const l = a[0];
597
- a = a.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), l === '"' && (a = a.replace(/\\n/g, `
598
- `), a = a.replace(/\\r/g, "\r")), r[u] = a;
17
+ let i;
18
+ for (; (i = ue.exec(s)) != null; ) {
19
+ const u = i[1];
20
+ let t = i[2] || "";
21
+ t = t.trim();
22
+ const n = t[0];
23
+ t = t.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), n === '"' && (t = t.replace(/\\n/g, `
24
+ `), t = t.replace(/\\r/g, "\r")), r[u] = t;
599
25
  }
600
26
  return r;
601
27
  }
602
- function ze(e) {
28
+ function de(e) {
603
29
  e = e || {};
604
- const r = ue(e);
30
+ const r = X(e);
605
31
  e.path = r;
606
- const t = E.configDotenv(e);
607
- if (!t.parsed) {
608
- const l = new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);
609
- throw l.code = "MISSING_DATA", l;
32
+ const s = p.configDotenv(e);
33
+ if (!s.parsed) {
34
+ const n = new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);
35
+ throw n.code = "MISSING_DATA", n;
610
36
  }
611
- const o = ae(e).split(","), u = o.length;
612
- let a;
613
- for (let l = 0; l < u; l++)
37
+ const i = z(e).split(","), u = i.length;
38
+ let t;
39
+ for (let n = 0; n < u; n++)
614
40
  try {
615
- const f = o[l].trim(), v = Re(t, f);
616
- a = E.decrypt(v.ciphertext, v.key);
41
+ const o = i[n].trim(), l = fe(s, o);
42
+ t = p.decrypt(l.ciphertext, l.key);
617
43
  break;
618
- } catch (f) {
619
- if (l + 1 >= u)
620
- throw f;
44
+ } catch (o) {
45
+ if (n + 1 >= u)
46
+ throw o;
621
47
  }
622
- return E.parse(a);
48
+ return p.parse(t);
623
49
  }
624
- function ke(e) {
625
- console.log(`[dotenv@${X}][WARN] ${e}`);
50
+ function pe(e) {
51
+ console.log(`[dotenv@${B}][WARN] ${e}`);
626
52
  }
627
- function P(e) {
628
- console.log(`[dotenv@${X}][DEBUG] ${e}`);
53
+ function R(e) {
54
+ console.log(`[dotenv@${B}][DEBUG] ${e}`);
629
55
  }
630
- function se(e) {
631
- console.log(`[dotenv@${X}] ${e}`);
56
+ function G(e) {
57
+ console.log(`[dotenv@${B}] ${e}`);
632
58
  }
633
- function ae(e) {
59
+ function z(e) {
634
60
  return e && e.DOTENV_KEY && e.DOTENV_KEY.length > 0 ? e.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
635
61
  }
636
- function Re(e, r) {
637
- let t;
62
+ function fe(e, r) {
63
+ let s;
638
64
  try {
639
- t = new URL(r);
640
- } catch (f) {
641
- if (f.code === "ERR_INVALID_URL") {
642
- const v = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
643
- throw v.code = "INVALID_DOTENV_KEY", v;
65
+ s = new URL(r);
66
+ } catch (o) {
67
+ if (o.code === "ERR_INVALID_URL") {
68
+ const l = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
69
+ throw l.code = "INVALID_DOTENV_KEY", l;
644
70
  }
645
- throw f;
71
+ throw o;
646
72
  }
647
- const o = t.password;
648
- if (!o) {
649
- const f = new Error("INVALID_DOTENV_KEY: Missing key part");
650
- throw f.code = "INVALID_DOTENV_KEY", f;
73
+ const i = s.password;
74
+ if (!i) {
75
+ const o = new Error("INVALID_DOTENV_KEY: Missing key part");
76
+ throw o.code = "INVALID_DOTENV_KEY", o;
651
77
  }
652
- const u = t.searchParams.get("environment");
78
+ const u = s.searchParams.get("environment");
653
79
  if (!u) {
654
- const f = new Error("INVALID_DOTENV_KEY: Missing environment part");
655
- throw f.code = "INVALID_DOTENV_KEY", f;
80
+ const o = new Error("INVALID_DOTENV_KEY: Missing environment part");
81
+ throw o.code = "INVALID_DOTENV_KEY", o;
656
82
  }
657
- const a = `DOTENV_VAULT_${u.toUpperCase()}`, l = e.parsed[a];
658
- if (!l) {
659
- const f = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);
660
- throw f.code = "NOT_FOUND_DOTENV_ENVIRONMENT", f;
83
+ const t = `DOTENV_VAULT_${u.toUpperCase()}`, n = e.parsed[t];
84
+ if (!n) {
85
+ const o = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${t} in your .env.vault file.`);
86
+ throw o.code = "NOT_FOUND_DOTENV_ENVIRONMENT", o;
661
87
  }
662
- return { ciphertext: l, key: o };
88
+ return { ciphertext: n, key: i };
663
89
  }
664
- function ue(e) {
90
+ function X(e) {
665
91
  let r = null;
666
92
  if (e && e.path && e.path.length > 0)
667
93
  if (Array.isArray(e.path))
668
- for (const t of e.path)
669
- H.existsSync(t) && (r = t.endsWith(".vault") ? t : `${t}.vault`);
94
+ for (const s of e.path)
95
+ J.existsSync(s) && (r = s.endsWith(".vault") ? s : `${s}.vault`);
670
96
  else
671
97
  r = e.path.endsWith(".vault") ? e.path : `${e.path}.vault`;
672
98
  else
673
- r = K.resolve(process.cwd(), ".env.vault");
674
- return H.existsSync(r) ? r : null;
99
+ r = Y.resolve(process.cwd(), ".env.vault");
100
+ return J.existsSync(r) ? r : null;
675
101
  }
676
- function te(e) {
677
- return e[0] === "~" ? K.join(je.homedir(), e.slice(1)) : e;
102
+ function H(e) {
103
+ return e[0] === "~" ? Y.join(ie.homedir(), e.slice(1)) : e;
678
104
  }
679
- function Le(e) {
680
- const r = !!(e && e.debug), t = e && "quiet" in e ? e.quiet : !0;
681
- (r || !t) && se("Loading env from encrypted .env.vault");
682
- const o = E._parseVault(e);
105
+ function he(e) {
106
+ const r = !!(e && e.debug), s = e && "quiet" in e ? e.quiet : !0;
107
+ (r || !s) && G("Loading env from encrypted .env.vault");
108
+ const i = p._parseVault(e);
683
109
  let u = process.env;
684
- return e && e.processEnv != null && (u = e.processEnv), E.populate(u, o, e), { parsed: o };
110
+ return e && e.processEnv != null && (u = e.processEnv), p.populate(u, i, e), { parsed: i };
685
111
  }
686
- function Ue(e) {
687
- const r = K.resolve(process.cwd(), ".env");
688
- let t = "utf8";
689
- const o = !!(e && e.debug), u = e && "quiet" in e ? e.quiet : !0;
690
- e && e.encoding ? t = e.encoding : o && P("No encoding is specified. UTF-8 is used by default");
691
- let a = [r];
112
+ function ve(e) {
113
+ const r = Y.resolve(process.cwd(), ".env");
114
+ let s = "utf8";
115
+ const i = !!(e && e.debug), u = e && "quiet" in e ? e.quiet : !0;
116
+ e && e.encoding ? s = e.encoding : i && R("No encoding is specified. UTF-8 is used by default");
117
+ let t = [r];
692
118
  if (e && e.path)
693
119
  if (!Array.isArray(e.path))
694
- a = [te(e.path)];
120
+ t = [H(e.path)];
695
121
  else {
696
- a = [];
697
- for (const h of e.path)
698
- a.push(te(h));
122
+ t = [];
123
+ for (const d of e.path)
124
+ t.push(H(d));
699
125
  }
700
- let l;
701
- const f = {};
702
- for (const h of a)
126
+ let n;
127
+ const o = {};
128
+ for (const d of t)
703
129
  try {
704
- const y = E.parse(H.readFileSync(h, { encoding: t }));
705
- E.populate(f, y, e);
706
- } catch (y) {
707
- o && P(`Failed to load ${h} ${y.message}`), l = y;
130
+ const g = p.parse(J.readFileSync(d, { encoding: s }));
131
+ p.populate(o, g, e);
132
+ } catch (g) {
133
+ i && R(`Failed to load ${d} ${g.message}`), n = g;
708
134
  }
709
- let v = process.env;
710
- if (e && e.processEnv != null && (v = e.processEnv), E.populate(v, f, e), o || !u) {
711
- const h = Object.keys(f).length, y = [];
712
- for (const $ of a)
135
+ let l = process.env;
136
+ if (e && e.processEnv != null && (l = e.processEnv), p.populate(l, o, e), i || !u) {
137
+ const d = Object.keys(o).length, g = [];
138
+ for (const y of t)
713
139
  try {
714
- const O = K.relative(process.cwd(), $);
715
- y.push(O);
716
- } catch (O) {
717
- o && P(`Failed to load ${$} ${O.message}`), l = O;
140
+ const h = Y.relative(process.cwd(), y);
141
+ g.push(h);
142
+ } catch (h) {
143
+ i && R(`Failed to load ${y} ${h.message}`), n = h;
718
144
  }
719
- se(`injecting env (${h}) from ${y.join(",")}`);
145
+ G(`injecting env (${d}) from ${g.join(",")}`);
720
146
  }
721
- return l ? { parsed: f, error: l } : { parsed: f };
147
+ return n ? { parsed: o, error: n } : { parsed: o };
722
148
  }
723
- function Ke(e) {
724
- if (ae(e).length === 0)
725
- return E.configDotenv(e);
726
- const r = ue(e);
727
- return r ? E._configVault(e) : (ke(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`), E.configDotenv(e));
149
+ function Ee(e) {
150
+ if (z(e).length === 0)
151
+ return p.configDotenv(e);
152
+ const r = X(e);
153
+ return r ? p._configVault(e) : (pe(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`), p.configDotenv(e));
728
154
  }
729
- function Ce(e, r) {
730
- const t = Buffer.from(r.slice(-64), "hex");
731
- let o = Buffer.from(e, "base64");
732
- const u = o.subarray(0, 12), a = o.subarray(-16);
733
- o = o.subarray(12, -16);
155
+ function ke(e, r) {
156
+ const s = Buffer.from(r.slice(-64), "hex");
157
+ let i = Buffer.from(e, "base64");
158
+ const u = i.subarray(0, 12), t = i.subarray(-16);
159
+ i = i.subarray(12, -16);
734
160
  try {
735
- const l = Pe.createDecipheriv("aes-256-gcm", t, u);
736
- return l.setAuthTag(a), `${l.update(o)}${l.final()}`;
737
- } catch (l) {
738
- const f = l instanceof RangeError, v = l.message === "Invalid key length", h = l.message === "Unsupported state or unable to authenticate data";
739
- if (f || v) {
740
- const y = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
741
- throw y.code = "INVALID_DOTENV_KEY", y;
742
- } else if (h) {
743
- const y = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
744
- throw y.code = "DECRYPTION_FAILED", y;
161
+ const n = le.createDecipheriv("aes-256-gcm", s, u);
162
+ return n.setAuthTag(t), `${n.update(i)}${n.final()}`;
163
+ } catch (n) {
164
+ const o = n instanceof RangeError, l = n.message === "Invalid key length", d = n.message === "Unsupported state or unable to authenticate data";
165
+ if (o || l) {
166
+ const g = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
167
+ throw g.code = "INVALID_DOTENV_KEY", g;
168
+ } else if (d) {
169
+ const g = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
170
+ throw g.code = "DECRYPTION_FAILED", g;
745
171
  } else
746
- throw l;
172
+ throw n;
747
173
  }
748
174
  }
749
- function Ye(e, r, t = {}) {
750
- const o = !!(t && t.debug), u = !!(t && t.override);
175
+ function De(e, r, s = {}) {
176
+ const i = !!(s && s.debug), u = !!(s && s.override);
751
177
  if (typeof r != "object") {
752
- const a = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
753
- throw a.code = "OBJECT_REQUIRED", a;
178
+ const t = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
179
+ throw t.code = "OBJECT_REQUIRED", t;
754
180
  }
755
- for (const a of Object.keys(r))
756
- Object.prototype.hasOwnProperty.call(e, a) ? (u === !0 && (e[a] = r[a]), o && P(u === !0 ? `"${a}" is already defined and WAS overwritten` : `"${a}" is already defined and was NOT overwritten`)) : e[a] = r[a];
181
+ for (const t of Object.keys(r))
182
+ Object.prototype.hasOwnProperty.call(e, t) ? (u === !0 && (e[t] = r[t]), i && R(u === !0 ? `"${t}" is already defined and WAS overwritten` : `"${t}" is already defined and was NOT overwritten`)) : e[t] = r[t];
757
183
  }
758
- const E = {
759
- configDotenv: Ue,
760
- _configVault: Le,
761
- _parseVault: ze,
762
- config: Ke,
763
- decrypt: Ce,
764
- parse: Ie,
765
- populate: Ye
184
+ const p = {
185
+ configDotenv: ve,
186
+ _configVault: he,
187
+ _parseVault: de,
188
+ config: Ee,
189
+ decrypt: ke,
190
+ parse: ge,
191
+ populate: De
766
192
  };
767
- S.exports.configDotenv = E.configDotenv;
768
- S.exports._configVault = E._configVault;
769
- S.exports._parseVault = E._parseVault;
770
- var Be = S.exports.config = E.config;
771
- S.exports.decrypt = E.decrypt;
772
- S.exports.parse = E.parse;
773
- S.exports.populate = E.populate;
774
- S.exports = E;
775
- function Me() {
193
+ b.exports.configDotenv = p.configDotenv;
194
+ b.exports._configVault = p._configVault;
195
+ b.exports._parseVault = p._parseVault;
196
+ var we = b.exports.config = p.config;
197
+ b.exports.decrypt = p.decrypt;
198
+ b.exports.parse = p.parse;
199
+ b.exports.populate = p.populate;
200
+ b.exports = p;
201
+ function me() {
776
202
  return Object.keys(process.env).filter(
777
203
  (r) => r.startsWith("KOS_")
778
204
  );
779
205
  }
780
- Be({
206
+ we({
781
207
  path: ".env"
782
208
  });
783
- const Fe = (e) => (r) => {
784
- var t;
209
+ const $e = (e) => (r) => {
210
+ var s;
785
211
  return r && (r.resolve = r.resolve || {}, r.resolve.fallback = {
786
212
  ...r.resolve.fallback,
787
213
  path: !1
788
- }), r.mode = process.env.NODE_ENV || r.mode, (t = r == null ? void 0 : r.plugins) == null || t.push(
789
- new e.EnvironmentPlugin(["NODE_ENV", ...Me()])
214
+ }), r.mode = process.env.NODE_ENV || r.mode, (s = r == null ? void 0 : r.plugins) == null || s.push(
215
+ new e.EnvironmentPlugin(["NODE_ENV", ...me()])
790
216
  ), r;
217
+ }, Ae = (e = {}) => {
218
+ const {
219
+ kosJsonPath: r = ".kos.json",
220
+ projectRoot: s,
221
+ defaultContext: i = "kosdev.ddk",
222
+ verbose: u = !1
223
+ } = e;
224
+ return (t, n) => {
225
+ var g, y;
226
+ if (!t.devServer)
227
+ return u && console.log(
228
+ "[withPluginDevServer] No devServer config found, skipping middleware"
229
+ ), t;
230
+ let o = s || process.cwd();
231
+ s || (t != null && t.context && typeof t.context == "string" ? o = t.context : (g = n == null ? void 0 : n.options) != null && g.root && ((y = n == null ? void 0 : n.options) != null && y.projectRoot) && (o = W.join(
232
+ n.options.root,
233
+ n.options.projectRoot
234
+ )));
235
+ const l = W.resolve(o, r);
236
+ u && console.log("[withPluginDevServer] Configuration:", {
237
+ kosJsonPath: l,
238
+ projectRoot: o,
239
+ defaultContext: i
240
+ });
241
+ const d = t.devServer.setupMiddlewares;
242
+ return t.devServer.setupMiddlewares = (h, V) => (d && (h = d(h, V)), V.app.get(
243
+ "/api/kos/ui/plugins/contexts",
244
+ (L, _) => {
245
+ var O, M, k, S;
246
+ try {
247
+ if (!U.existsSync(l)) {
248
+ const N = `.kos.json not found at ${l}`;
249
+ return console.error(`[withPluginDevServer] ${N}`), _.status(404).json({
250
+ status: 404,
251
+ error: N,
252
+ hint: "Ensure .kos.json exists in your plugin project root"
253
+ });
254
+ }
255
+ const D = U.readFileSync(
256
+ l,
257
+ "utf-8"
258
+ ), I = JSON.parse(D), P = (M = (O = I.kos) == null ? void 0 : O.ui) == null ? void 0 : M.plugin;
259
+ if (!P) {
260
+ const N = "kos.ui.plugin section not found in .kos.json";
261
+ return console.error(`[withPluginDevServer] ${N}`), _.status(400).json({
262
+ status: 400,
263
+ error: N,
264
+ hint: "Ensure .kos.json has kos.ui.plugin section defined"
265
+ });
266
+ }
267
+ const A = (k = I.test) == null ? void 0 : k.plugin, T = (A == null ? void 0 : A.context) || i, K = C(), $ = {
268
+ status: 200,
269
+ version: { major: 1, minor: 0 },
270
+ data: [
271
+ {
272
+ name: T,
273
+ plugins: [
274
+ {
275
+ descriptor: P,
276
+ id: K,
277
+ path: "/"
278
+ // Simple identifier - actual URL comes from overrides
279
+ }
280
+ ]
281
+ }
282
+ ]
283
+ };
284
+ u && console.log("[withPluginDevServer] Serving plugin metadata:", {
285
+ pluginId: P.id,
286
+ context: T,
287
+ extensionsCount: ((S = P.extensions) == null ? void 0 : S.length) || 0
288
+ }), _.json($);
289
+ } catch (D) {
290
+ console.error(
291
+ "[withPluginDevServer] Error serving plugin metadata:",
292
+ D
293
+ ), _.status(500).json({
294
+ status: 500,
295
+ error: "Failed to serve plugin metadata",
296
+ details: D instanceof Error ? D.message : String(D)
297
+ });
298
+ }
299
+ }
300
+ ), u && console.log(
301
+ "[withPluginDevServer] Plugin metadata endpoint registered at /api/kos/ui/plugins/contexts"
302
+ ), h), t;
303
+ };
304
+ }, je = (e) => {
305
+ const {
306
+ pluginServers: r,
307
+ includeHostPlugins: s = !0,
308
+ kosJsonPath: i = ".kos.json",
309
+ mergeWithBackend: u = !1,
310
+ fallbackToBackend: t = !0,
311
+ backendUrl: n = "http://localhost:8081",
312
+ verbose: o = !1
313
+ } = e;
314
+ return (l, d) => {
315
+ var V, L;
316
+ let g = process.cwd();
317
+ l != null && l.context && typeof l.context == "string" ? g = l.context : (V = d == null ? void 0 : d.options) != null && V.root && ((L = d == null ? void 0 : d.options) != null && L.projectRoot) && (g = Q(
318
+ d.options.root,
319
+ d.options.projectRoot
320
+ ));
321
+ const y = Q(g, i);
322
+ if (!l.devServer)
323
+ return o && console.log(
324
+ "[withPluginDevAggregator] No devServer config found, skipping middleware"
325
+ ), l;
326
+ o && console.log("[withPluginDevAggregator] Configuration:", {
327
+ pluginServers: r,
328
+ fallbackToBackend: t,
329
+ backendUrl: n,
330
+ projectRoot: g,
331
+ kosJsonPath: y
332
+ });
333
+ const h = l.devServer.setupMiddlewares;
334
+ return l.devServer.setupMiddlewares = (_, O) => (h && (_ = h(_, O)), O.app.get(
335
+ "/api/kos/ui/plugins/contexts",
336
+ async (M, k) => {
337
+ var S, D, I, P, A, T, K;
338
+ try {
339
+ if (r.length === 0)
340
+ if (t) {
341
+ o && console.log(
342
+ "[withPluginDevAggregator] No plugin servers, proxying to backend:",
343
+ n
344
+ );
345
+ const c = await (await fetch(
346
+ `${n}/api/kos/ui/plugins/contexts`
347
+ )).json();
348
+ return k.json(c);
349
+ } else
350
+ return k.status(404).json({
351
+ status: 404,
352
+ error: "No plugin servers configured",
353
+ hint: "Add plugin server URLs to withPluginDevAggregator options or enable fallbackToBackend"
354
+ });
355
+ const N = (await Promise.all(
356
+ r.map(async (a) => {
357
+ try {
358
+ const c = await fetch(
359
+ `${a}/api/kos/ui/plugins/contexts`
360
+ );
361
+ if (!c.ok)
362
+ return o && console.warn(
363
+ `[withPluginDevAggregator] Failed to fetch from ${a}: ${c.status}`
364
+ ), null;
365
+ const f = await c.json();
366
+ return { serverUrl: a, data: f };
367
+ } catch (c) {
368
+ return o && console.warn(
369
+ `[withPluginDevAggregator] Error fetching from ${a}:`,
370
+ c
371
+ ), null;
372
+ }
373
+ })
374
+ )).filter(
375
+ (a) => a && a.data && a.data.status === 200
376
+ );
377
+ if (N.length === 0 && t) {
378
+ o && console.log(
379
+ "[withPluginDevAggregator] No plugin servers responded, falling back to backend"
380
+ );
381
+ try {
382
+ const c = await (await fetch(
383
+ `${n}/api/kos/ui/plugins/contexts`
384
+ )).json();
385
+ return k.json(c);
386
+ } catch (a) {
387
+ return k.status(503).json({
388
+ status: 503,
389
+ error: "No plugin servers available and backend unreachable",
390
+ details: a instanceof Error ? a.message : String(a)
391
+ });
392
+ }
393
+ }
394
+ const E = {}, F = {};
395
+ if (u)
396
+ try {
397
+ o && console.log(
398
+ "[withPluginDevAggregator] Fetching backend plugins from:",
399
+ n
400
+ );
401
+ const a = await fetch(
402
+ `${n}/api/kos/ui/plugins/contexts`
403
+ );
404
+ if (a.ok) {
405
+ const c = await a.json();
406
+ c.status === 200 && c.data && (c.data.forEach((f) => {
407
+ const w = f.name;
408
+ E[w] || (E[w] = []), f.plugins.forEach((m) => {
409
+ var v;
410
+ E[w].push(m), o && console.log(
411
+ `[withPluginDevAggregator] Added backend plugin: ${(v = m.descriptor) == null ? void 0 : v.id} (no override)`
412
+ );
413
+ });
414
+ }), o && console.log(
415
+ "[withPluginDevAggregator] Successfully merged backend plugins"
416
+ ));
417
+ } else
418
+ o && console.warn(
419
+ `[withPluginDevAggregator] Backend fetch failed: ${a.status}`
420
+ );
421
+ } catch (a) {
422
+ o && console.warn(
423
+ "[withPluginDevAggregator] Error fetching backend plugins:",
424
+ a
425
+ );
426
+ }
427
+ if (s)
428
+ try {
429
+ const a = te(
430
+ y,
431
+ "utf-8"
432
+ ), c = JSON.parse(a), f = (D = (S = c.kos) == null ? void 0 : S.ui) == null ? void 0 : D.plugin, w = (A = (P = (I = c.kosdev) == null ? void 0 : I.ddk) == null ? void 0 : P.ncui) == null ? void 0 : A.plugin, m = [];
433
+ f && m.push({
434
+ name: ((K = (T = c.test) == null ? void 0 : T.plugin) == null ? void 0 : K.context) || "kos.ui",
435
+ plugin: {
436
+ descriptor: f,
437
+ id: C(),
438
+ path: "/"
439
+ // Host app plugins are served locally
440
+ }
441
+ }), w && m.push({
442
+ name: "kosdev.ddk",
443
+ plugin: {
444
+ descriptor: w,
445
+ id: C(),
446
+ path: "/"
447
+ // Host app plugins are served locally
448
+ }
449
+ }), m.forEach(({ name: v, plugin: j }) => {
450
+ E[v] || (E[v] = []), E[v].push(j), o && console.log(
451
+ `[withPluginDevAggregator] Added host plugin: ${j.descriptor.id} to context ${v}`
452
+ );
453
+ });
454
+ } catch (a) {
455
+ o && console.warn(
456
+ "[withPluginDevAggregator] Failed to read host .kos.json:",
457
+ a
458
+ );
459
+ }
460
+ N.forEach((a) => {
461
+ var w;
462
+ if (!a)
463
+ return;
464
+ const { serverUrl: c, data: f } = a;
465
+ (w = f.data) == null || w.forEach((m) => {
466
+ const v = m.name;
467
+ E[v] || (E[v] = []), m.plugins.forEach((j) => {
468
+ var q;
469
+ E[v].push(j), F[j.id] = `${c}/`, o && console.log(
470
+ `[withPluginDevAggregator] Added local dev plugin: ${(q = j.descriptor) == null ? void 0 : q.id} with override to ${c}/`
471
+ );
472
+ });
473
+ });
474
+ });
475
+ const x = Object.entries(E).map(
476
+ ([a, c]) => ({
477
+ name: a,
478
+ plugins: c
479
+ })
480
+ ), Z = {
481
+ status: 200,
482
+ version: { major: 1, minor: 0 },
483
+ data: x,
484
+ // Include overrides map for dev mode
485
+ // This allows the host app to pass these to KosPluginProvider
486
+ overrides: F
487
+ };
488
+ o && console.log("[withPluginDevAggregator] Aggregated plugins:", {
489
+ contexts: x.length,
490
+ totalPlugins: x.reduce(
491
+ (a, c) => a + c.plugins.length,
492
+ 0
493
+ ),
494
+ pluginIds: x.flatMap(
495
+ (a) => a.plugins.map((c) => {
496
+ var f;
497
+ return (f = c.descriptor) == null ? void 0 : f.id;
498
+ })
499
+ ),
500
+ overrides: F
501
+ }), k.json(Z);
502
+ } catch ($) {
503
+ console.error(
504
+ "[withPluginDevAggregator] Error aggregating plugins:",
505
+ $
506
+ ), k.status(500).json({
507
+ status: 500,
508
+ error: "Failed to aggregate plugin metadata",
509
+ details: $ instanceof Error ? $.message : String($)
510
+ });
511
+ }
512
+ }
513
+ ), o && console.log(
514
+ "[withPluginDevAggregator] Plugin aggregation endpoint registered at /api/kos/ui/plugins/contexts"
515
+ ), _), l;
516
+ };
791
517
  };
792
518
  export {
793
- Fe as withKosConfig
519
+ $e as withKosConfig,
520
+ je as withPluginDevAggregator,
521
+ Ae as withPluginDevServer
794
522
  };
795
523
  //# sourceMappingURL=webpack.js.map