@kosdev-code/kos-ui-plugin 2.1.0 → 2.1.2

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.
@@ -0,0 +1,1523 @@
1
+ var A = Object.defineProperty;
2
+ var j = (n, e, t) => e in n ? A(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var P = (n, e, t) => (j(n, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { z as E } from "zod";
5
+ function N(n, e) {
6
+ for (var t = 0; t < e.length; t++) {
7
+ const i = e[t];
8
+ if (typeof i != "string" && !Array.isArray(i)) {
9
+ for (const s in i)
10
+ if (s !== "default" && !(s in n)) {
11
+ const o = Object.getOwnPropertyDescriptor(i, s);
12
+ o && Object.defineProperty(n, s, o.get ? o : {
13
+ enumerable: !0,
14
+ get: () => i[s]
15
+ });
16
+ }
17
+ }
18
+ }
19
+ return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
20
+ }
21
+ var k = {}, x = {};
22
+ Object.defineProperty(x, "__esModule", { value: !0 });
23
+ x.loadRemoteModule = x.setRemoteDefinitions = x.setRemoteUrlResolver = void 0;
24
+ let v, S;
25
+ const R = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
26
+ let _ = !1;
27
+ function K(n) {
28
+ S = n;
29
+ }
30
+ x.setRemoteUrlResolver = K;
31
+ function V(n) {
32
+ v = n;
33
+ }
34
+ x.setRemoteDefinitions = V;
35
+ async function M(n, e) {
36
+ const t = `${n}:${e}`;
37
+ if (R.has(t))
38
+ return R.get(t);
39
+ const o = (await (F.has(n) ? F.get(n) : await q(n)).get(e))();
40
+ return R.set(t, o), o;
41
+ }
42
+ x.loadRemoteModule = M;
43
+ const L = (n, e) => new Promise((t, i) => {
44
+ const s = document.createElement("script");
45
+ s.src = n, s.type = "text/javascript", s.async = !0, s.onload = () => {
46
+ t({
47
+ get: (a) => window[e].get(a),
48
+ init: (a) => {
49
+ try {
50
+ window[e].init(a);
51
+ } catch (r) {
52
+ console.error(`Failed to initialize remote ${e}`, r), i(r);
53
+ }
54
+ }
55
+ });
56
+ }, s.onerror = () => i(new Error(`Remote ${e} not found`)), document.head.appendChild(s);
57
+ });
58
+ async function q(n) {
59
+ if (!S && !v)
60
+ throw new Error("Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.");
61
+ _ || (_ = !0, await __webpack_init_sharing__("default"));
62
+ const e = v ? v[n] : await S(n);
63
+ let t = e;
64
+ !e.endsWith(".mjs") && !e.endsWith(".js") && (t = `${e}${e.endsWith("/") ? "" : "/"}remoteEntry.js`);
65
+ const i = await L(t, n);
66
+ return await i.init(__webpack_share_scopes__.default), F.set(n, i), i;
67
+ }
68
+ (function(n) {
69
+ Object.defineProperty(n, "__esModule", { value: !0 }), n.setRemoteUrlResolver = n.setRemoteDefinitions = n.loadRemoteModule = void 0;
70
+ var e = x;
71
+ Object.defineProperty(n, "loadRemoteModule", { enumerable: !0, get: function() {
72
+ return e.loadRemoteModule;
73
+ } }), Object.defineProperty(n, "setRemoteDefinitions", { enumerable: !0, get: function() {
74
+ return e.setRemoteDefinitions;
75
+ } }), Object.defineProperty(n, "setRemoteUrlResolver", { enumerable: !0, get: function() {
76
+ return e.setRemoteUrlResolver;
77
+ } });
78
+ })(k);
79
+ const Re = /* @__PURE__ */ N({
80
+ __proto__: null
81
+ }, [k]);
82
+ function B(n) {
83
+ var e;
84
+ try {
85
+ if ("shape" in n) {
86
+ const t = n, i = [];
87
+ for (const [s, o] of Object.entries(
88
+ t.shape
89
+ )) {
90
+ const a = o, r = {
91
+ name: s,
92
+ required: !a.isOptional()
93
+ };
94
+ if (a._def && a._def.description && (r.description = a._def.description), a._def) {
95
+ let c = a._def.typeName || "unknown";
96
+ c === "ZodOptional" && a._def.innerType && (c = ((e = a._def.innerType._def) == null ? void 0 : e.typeName) || "unknown"), r.type = c.replace("Zod", "").toLowerCase();
97
+ }
98
+ i.push(r);
99
+ }
100
+ return i;
101
+ }
102
+ return [];
103
+ } catch (t) {
104
+ return console.warn("Failed to extract schema field info:", t), [];
105
+ }
106
+ }
107
+ class H {
108
+ constructor() {
109
+ P(this, "issues", []);
110
+ }
111
+ addError(e) {
112
+ this.issues.push({ type: "error", message: e });
113
+ }
114
+ addWarning(e) {
115
+ this.issues.push({ type: "warning", message: e });
116
+ }
117
+ addInfo(e) {
118
+ this.issues.push({ type: "info", message: e });
119
+ }
120
+ hasErrors() {
121
+ return this.issues.some((e) => e.type === "error");
122
+ }
123
+ hasIssues() {
124
+ return this.issues.length > 0;
125
+ }
126
+ getIssues() {
127
+ return [...this.issues];
128
+ }
129
+ }
130
+ class W {
131
+ constructor() {
132
+ P(this, "cache", /* @__PURE__ */ new Map());
133
+ }
134
+ set(e, t) {
135
+ this.cache.set(e, t);
136
+ }
137
+ get(e) {
138
+ return this.cache.get(e) || [];
139
+ }
140
+ clear() {
141
+ this.cache.clear();
142
+ }
143
+ }
144
+ const w = new W();
145
+ function Ie(n) {
146
+ return w.get(n);
147
+ }
148
+ const U = [];
149
+ function z(n) {
150
+ U.push(n);
151
+ }
152
+ function G(n, e, t) {
153
+ return U.reduce(
154
+ (i, s) => s(i, e, t),
155
+ n
156
+ );
157
+ }
158
+ class J {
159
+ constructor() {
160
+ P(this, "extensionPoints", /* @__PURE__ */ new Map());
161
+ }
162
+ define(e) {
163
+ if (this.extensionPoints.has(e.id))
164
+ return console.warn(`Extension point ${e.id} is already defined`), this.extensionPoints.get(e.id);
165
+ const t = {
166
+ config: e,
167
+ id: e.id,
168
+ isRegistered: !1,
169
+ getExtensions: (i) => i[e.id] || {},
170
+ register: () => {
171
+ if (t.isRegistered) {
172
+ console.warn(`Extension point ${e.id} is already registered`);
173
+ return;
174
+ }
175
+ const i = this.createReducer(e);
176
+ z(i), t.isRegistered = !0;
177
+ }
178
+ };
179
+ return e.schema && (t.getSchemaFieldInfo = () => B(e.schema)), this.extensionPoints.set(e.id, t), t;
180
+ }
181
+ createReducer(e) {
182
+ return (t, i, s) => {
183
+ const o = i[e.contributionKey];
184
+ return !o || typeof o != "object" || Object.entries(o).forEach(
185
+ ([a, r]) => {
186
+ var f, h;
187
+ if (!r)
188
+ return;
189
+ const c = {
190
+ remote: r.remote || "",
191
+ sectionId: r.sectionId || a,
192
+ experiences: s,
193
+ contributions: i
194
+ };
195
+ if (e.validate) {
196
+ const d = new H();
197
+ if (e.validate(
198
+ r,
199
+ d
200
+ ) === "skip") {
201
+ w.set(a, [
202
+ {
203
+ type: "warning",
204
+ message: "Plugin marked to skip processing"
205
+ }
206
+ ]);
207
+ return;
208
+ }
209
+ if (d.hasIssues()) {
210
+ const b = d.getIssues().map((g) => ({
211
+ ...g,
212
+ message: `Extension point validation: ${g.message}`
213
+ }));
214
+ if (w.set(a, b), d.hasErrors()) {
215
+ console.error(
216
+ `Validation failed for ${e.id} contribution "${a}":`,
217
+ b.filter((g) => g.type === "error").map((g) => g.message).join(", ")
218
+ );
219
+ return;
220
+ }
221
+ } else
222
+ w.set(a, []);
223
+ }
224
+ const l = e.transform ? e.transform(r, c) : r;
225
+ t[e.id] || (t[e.id] = {});
226
+ const u = {
227
+ id: a,
228
+ type: e.contributionKey,
229
+ data: l,
230
+ remote: c.remote,
231
+ sectionId: c.sectionId
232
+ };
233
+ if (e.isRankable && typeof r.rank == "number" && (u.rank = r.rank), l && typeof l == "object" && ("component" in l && (u.component = l.component), "view" in l && (u.view = l.view), "location" in l && (u.location = l.location)), t[e.id][a] = u, e.hasView && ((f = e.relatedPoints) != null && f.view)) {
234
+ const d = r.experienceId, p = s == null ? void 0 : s[d];
235
+ p && (t[e.relatedPoints.view] || (t[e.relatedPoints.view] = {}), t[e.relatedPoints.view][a] = {
236
+ id: a,
237
+ type: `${e.contributionKey}.view`,
238
+ data: p,
239
+ remote: c.remote,
240
+ sectionId: c.sectionId
241
+ });
242
+ }
243
+ (h = e.relatedPoints) != null && h.definition && (t[e.relatedPoints.definition] || (t[e.relatedPoints.definition] = {}), t[e.relatedPoints.definition][a] = {
244
+ id: a,
245
+ type: `${e.contributionKey}.definition`,
246
+ data: l,
247
+ remote: c.remote,
248
+ sectionId: c.sectionId
249
+ });
250
+ }
251
+ ), t;
252
+ };
253
+ }
254
+ /**
255
+ * Get all registered extension points (for discovery/documentation)
256
+ */
257
+ getAllExtensionPoints() {
258
+ return Array.from(this.extensionPoints.values()).filter(
259
+ (e) => e.isRegistered
260
+ );
261
+ }
262
+ /**
263
+ * Get all defined extension points (registered and unregistered)
264
+ */
265
+ getAllDefinedExtensionPoints() {
266
+ return Array.from(this.extensionPoints.values());
267
+ }
268
+ /**
269
+ * Get a specific extension point definition
270
+ */
271
+ getExtensionPoint(e) {
272
+ return this.extensionPoints.get(e);
273
+ }
274
+ /**
275
+ * Check if an extension point is registered
276
+ */
277
+ hasExtensionPoint(e) {
278
+ return this.extensionPoints.has(e);
279
+ }
280
+ }
281
+ const O = new J();
282
+ function y() {
283
+ return O;
284
+ }
285
+ function Z(n = {}) {
286
+ const {
287
+ experienceIdProperty: e = "experienceId",
288
+ flattenComponentProperties: t = !0,
289
+ customTransform: i
290
+ } = n;
291
+ return (s, o) => {
292
+ var l;
293
+ const a = s[e], r = a ? ((l = o.experiences) == null ? void 0 : l[a]) || {} : {};
294
+ let c = {
295
+ ...s,
296
+ view: r
297
+ };
298
+ return t && r && (r.component && (c.component = r.component), r.location && (c.location = r.location)), i && (c = i(s, r, o) || c), c;
299
+ };
300
+ }
301
+ function Y(n) {
302
+ return O.define(n);
303
+ }
304
+ const Q = {
305
+ $timestamp: () => Date.now(),
306
+ $date: () => (/* @__PURE__ */ new Date()).toISOString(),
307
+ $packageVersion: () => process.env.npm_package_version || "0.0.0",
308
+ $env: () => process.env.NODE_ENV || "development"
309
+ };
310
+ function X(n) {
311
+ const e = {
312
+ id: n.id,
313
+ displayName: n.displayName,
314
+ description: n.description,
315
+ contributionKey: n.contributionKey,
316
+ hasView: n.hasView,
317
+ isRankable: n.isRankable,
318
+ relatedPoints: n.relatedPoints,
319
+ metadata: n.metadata ? {
320
+ ...n.metadata,
321
+ exportName: n.metadata.exportName || ee(n.id)
322
+ } : void 0
323
+ };
324
+ return n.schema && (e.schema = te(n.schema, {
325
+ hasView: n.hasView,
326
+ isRankable: n.isRankable
327
+ })), n.validation && (e.validate = ie(n.validation)), n.transform ? e.transform = de(n.transform) : n.hasView && (e.transform = Z()), e;
328
+ }
329
+ function ee(n) {
330
+ return n.split(".").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("") + "Extension";
331
+ }
332
+ function te(n, e) {
333
+ try {
334
+ const { z: t } = require("zod");
335
+ if (n.properties) {
336
+ const i = {};
337
+ i.id = t.string().min(1), i.title = t.string().min(1), i.namespace = t.string().min(1), e != null && e.hasView && (i.experienceId = t.string().min(1)), e != null && e.isRankable && (i.rank = t.number().min(0).max(1e3).optional());
338
+ for (const [o, a] of Object.entries(n.properties))
339
+ i[o] = ne(a, t);
340
+ let s = t.object(i);
341
+ return n.additionalProperties || (s = s.strict()), s;
342
+ }
343
+ return t.any();
344
+ } catch (t) {
345
+ console.warn("Zod not available for JSON schema conversion:", t);
346
+ return;
347
+ }
348
+ }
349
+ function ne(n, e) {
350
+ let t;
351
+ switch (n.type) {
352
+ case "string":
353
+ t = e.string(), n.minLength && (t = t.min(n.minLength)), n.maxLength && (t = t.max(n.maxLength)), n.pattern && (t = t.regex(new RegExp(n.pattern))), n.enum && (t = e.enum(n.enum));
354
+ break;
355
+ case "number":
356
+ t = e.number(), n.minimum !== void 0 && (t = t.min(n.minimum)), n.maximum !== void 0 && (t = t.max(n.maximum));
357
+ break;
358
+ case "boolean":
359
+ t = e.boolean();
360
+ break;
361
+ case "array":
362
+ t = e.array(e.any());
363
+ break;
364
+ case "object":
365
+ t = e.object({});
366
+ break;
367
+ default:
368
+ t = e.any();
369
+ }
370
+ return n.description && (t = t.describe(n.description)), n.default !== void 0 && (t = t.default(n.default)), t;
371
+ }
372
+ function ie(n) {
373
+ return n.module ? ue(n.module) : (e, t) => {
374
+ if (!n.rules)
375
+ return;
376
+ const i = e;
377
+ for (const s of n.rules)
378
+ se(s, i, t);
379
+ };
380
+ }
381
+ function se(n, e, t) {
382
+ switch (n.type) {
383
+ case "required":
384
+ oe(n, e, t);
385
+ break;
386
+ case "range":
387
+ re(n, e, t);
388
+ break;
389
+ case "pattern":
390
+ ae(n, e, t);
391
+ break;
392
+ case "dependency":
393
+ ce(n, e, t);
394
+ break;
395
+ case "custom":
396
+ le(n, e, t);
397
+ break;
398
+ }
399
+ }
400
+ function oe(n, e, t) {
401
+ n.field && !e[n.field] && t.addError(n.message || `Field '${n.field}' is required`);
402
+ }
403
+ function re(n, e, t) {
404
+ if (n.field && typeof e[n.field] == "number") {
405
+ const i = e[n.field];
406
+ n.min !== void 0 && i < n.min && t.addError(
407
+ n.message || `Field '${n.field}' must be at least ${n.min}`
408
+ ), n.max !== void 0 && i > n.max && t.addError(
409
+ n.message || `Field '${n.field}' must be at most ${n.max}`
410
+ );
411
+ }
412
+ }
413
+ function ae(n, e, t) {
414
+ n.field && n.pattern && typeof e[n.field] == "string" && (new RegExp(n.pattern).test(e[n.field]) || t.addError(
415
+ n.message || `Field '${n.field}' does not match pattern ${n.pattern}`
416
+ ));
417
+ }
418
+ function ce(n, e, t) {
419
+ if (n.field && n.dependsOn && n.expression)
420
+ try {
421
+ $(n.expression, e) || t.addError(
422
+ n.message || `Field '${n.field}' dependency validation failed`
423
+ );
424
+ } catch (i) {
425
+ t.addWarning(`Failed to evaluate dependency expression: ${i}`);
426
+ }
427
+ }
428
+ function le(n, e, t) {
429
+ if (n.expression)
430
+ try {
431
+ $(n.expression, e) || t.addError(n.message || "Custom validation failed");
432
+ } catch (i) {
433
+ t.addWarning(`Failed to evaluate custom expression: ${i}`);
434
+ }
435
+ }
436
+ function ue(n) {
437
+ return (e, t) => {
438
+ console.warn(`External validation module not implemented: ${n}`), t.addWarning(
439
+ `External validation module not yet supported: ${n}`
440
+ );
441
+ };
442
+ }
443
+ function de(n) {
444
+ return n.module ? pe(n.module) : (e, t) => {
445
+ const i = { ...e };
446
+ if (n.addFields)
447
+ for (const [s, o] of Object.entries(n.addFields))
448
+ i[s] = fe(o);
449
+ if (n.removeFields)
450
+ for (const s of n.removeFields)
451
+ delete i[s];
452
+ if (n.renameFields)
453
+ for (const [s, o] of Object.entries(
454
+ n.renameFields
455
+ ))
456
+ s in i && (i[o] = i[s], delete i[s]);
457
+ if (n.normalizeFields)
458
+ for (const { field: s, operation: o } of n.normalizeFields)
459
+ s in i && typeof i[s] == "string" && (i[s] = me(
460
+ i[s],
461
+ o
462
+ ));
463
+ return i;
464
+ };
465
+ }
466
+ function pe(n) {
467
+ return (e, t) => (console.warn(`External transform module not implemented: ${n}`), e);
468
+ }
469
+ function fe(n) {
470
+ if (typeof n == "string" && n.startsWith("$")) {
471
+ const e = Q[n];
472
+ if (e)
473
+ return e();
474
+ }
475
+ return n;
476
+ }
477
+ function me(n, e) {
478
+ switch (e) {
479
+ case "trim":
480
+ return n.trim();
481
+ case "lowercase":
482
+ return n.toLowerCase();
483
+ case "uppercase":
484
+ return n.toUpperCase();
485
+ case "camelCase":
486
+ return ge(n);
487
+ case "kebabCase":
488
+ return he(n);
489
+ default:
490
+ return n;
491
+ }
492
+ }
493
+ function ge(n) {
494
+ return n.replace(/[-_\s]+(.)?/g, (e, t) => t ? t.toUpperCase() : "").replace(/^./, (e) => e.toLowerCase());
495
+ }
496
+ function he(n) {
497
+ return n.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
498
+ }
499
+ function $(n, e) {
500
+ try {
501
+ let t = n;
502
+ for (const [i, s] of Object.entries(e)) {
503
+ const o = typeof s == "string" ? `"${s}"` : String(s);
504
+ t = t.replace(
505
+ new RegExp(`\\b${i}\\b`, "g"),
506
+ o
507
+ );
508
+ }
509
+ if (t.includes("!==")) {
510
+ const [i, s] = t.split("!==").map((o) => o.trim());
511
+ return i !== s;
512
+ }
513
+ if (t.includes("===")) {
514
+ const [i, s] = t.split("===").map((o) => o.trim());
515
+ return i === s;
516
+ }
517
+ return t.includes("||") ? t.split("||").map((s) => s.trim()).some((s) => $(s, e)) : t.includes("&&") ? t.split("&&").map((s) => s.trim()).every((s) => $(s, e)) : !1;
518
+ } catch (t) {
519
+ return console.error("Expression evaluation failed:", t), !1;
520
+ }
521
+ }
522
+ const ye = (n) => (e, t) => {
523
+ var c;
524
+ const i = n[t].remote, s = t, o = (c = n[t].contributes) == null ? void 0 : c.experiences;
525
+ return Object.keys(o).forEach((l) => {
526
+ const u = o[l];
527
+ e.experiences[l] = {
528
+ ...u,
529
+ remote: i,
530
+ sectionId: s
531
+ };
532
+ }), y().getAllExtensionPoints().forEach((l) => {
533
+ var h;
534
+ const { contributionKey: u } = l.config, f = (h = n[t].contributes) == null ? void 0 : h[u];
535
+ f && (e[u] || (e[u] = {}), Array.isArray(f) ? f.forEach((d) => {
536
+ d && d.id && (e[u][d.id] = {
537
+ ...d,
538
+ remote: i,
539
+ sectionId: s
540
+ });
541
+ }) : typeof f == "object" && Object.entries(f).forEach(([d, p]) => {
542
+ e[u][d] = {
543
+ ...p,
544
+ id: d,
545
+ remote: i,
546
+ sectionId: s
547
+ };
548
+ }));
549
+ }), e;
550
+ };
551
+ async function be(n) {
552
+ const e = n ?? window.KosPlugins.__dynamicRemotes;
553
+ if (window.KosPlugins.extensions) {
554
+ const o = window.KosPlugins.extensions;
555
+ return {
556
+ extensionPoints: o,
557
+ getExtensions: (a) => o[a] || [],
558
+ remotes: e,
559
+ extensions: window.KosPlugins.__extensions
560
+ };
561
+ }
562
+ const t = window.KosPlugins.__extensions ?? await Ee(e), i = {};
563
+ if (t)
564
+ for (const o of Object.keys(t))
565
+ i[o] = Object.values(
566
+ t[o] || {}
567
+ );
568
+ return window.KosPlugins.extensions = i, { extensionPoints: i, getExtensions: (o) => i[o] || [], remotes: e, extensions: t };
569
+ }
570
+ const T = {
571
+ controlPourDefinitions: {},
572
+ experiences: {}
573
+ };
574
+ function xe(n) {
575
+ return n ? Object.keys(n).reduce(ye(n), {
576
+ ...T
577
+ }) : T;
578
+ }
579
+ async function Ee(n) {
580
+ if (!n)
581
+ return window.KosPlugins = window.KosPlugins || {}, {};
582
+ for (const o of Object.values(n)) {
583
+ try {
584
+ if (o.extensions && Array.isArray(o.extensions)) {
585
+ const a = o.extensions.filter((r) => r && typeof r == "object" && "id" in r).map((r) => X(r));
586
+ if (a.length > 0) {
587
+ console.info(
588
+ `Registering ${a.length} JSON extension point(s) from ${o.remote}`
589
+ );
590
+ for (const r of a)
591
+ try {
592
+ Y(r).register(), console.debug(`Registered JSON extension point: ${r.id}`);
593
+ } catch (c) {
594
+ console.error(
595
+ `Failed to register JSON extension point '${r.id}' from ${o.remote}:`,
596
+ c
597
+ );
598
+ }
599
+ }
600
+ }
601
+ } catch (a) {
602
+ console.warn(
603
+ `Failed to parse JSON extension points from ${o.remote}:`,
604
+ a
605
+ );
606
+ }
607
+ if (o.init)
608
+ try {
609
+ const a = await k.loadRemoteModule(
610
+ o.remote,
611
+ "./InitPlugin"
612
+ );
613
+ if (a.default) {
614
+ const r = new a.default();
615
+ r == null || r.register();
616
+ }
617
+ } catch (a) {
618
+ console.warn(`Failed to load InitPlugin from ${o.remote}:`, a);
619
+ }
620
+ }
621
+ const e = xe(n), t = e.experiences, s = G(
622
+ {},
623
+ e,
624
+ t
625
+ );
626
+ return window.KosPlugins = window.KosPlugins || {}, window.KosPlugins.__extensions = s, s;
627
+ }
628
+ async function Se(n) {
629
+ const { getExtensions: e } = await be();
630
+ return e(n);
631
+ }
632
+ const Pe = (n = null) => (n || window.location.search.replace("?", "")).split("&").map((e) => {
633
+ const [t, i] = e.split("=");
634
+ return [t, decodeURIComponent(i || "")];
635
+ }).reduce((e, [t, i]) => (e[t] = i, e), {}), ve = () => {
636
+ const n = window.location.origin, e = Pe();
637
+ return (e == null ? void 0 : e.host) || n;
638
+ }, Fe = async (n) => {
639
+ var p, b;
640
+ const e = ve(), t = n ?? {}, {
641
+ pluginBaseUrl: i = e,
642
+ pluginApiPath: s = "/api/app/kosdev.ddk/ncui/plugins",
643
+ overrides: o = {},
644
+ pluginContext: a
645
+ } = t, r = !!a, c = r ? `${i}/api/kos/ui/plugins/context/${a.context}` : `${i}${s}`;
646
+ console.log(
647
+ `initialize-plugins: Using Plugin Framework: ${r}: Fetching plugins from ${c}`
648
+ );
649
+ const u = await (await fetch(c)).json(), f = r ? ((b = (p = u.data) == null ? void 0 : p.groups) == null ? void 0 : b[a.group]) ?? [] : u.data ?? [], h = f == null ? void 0 : f.reduce((g, m) => {
650
+ const C = (o == null ? void 0 : o[m.id]) ?? r ? `${i}${m.path}` : `${i}${m.baseUrl}`;
651
+ return m.descriptor ? g[m.id] = {
652
+ basePath: `${C}remoteEntry.js`,
653
+ extensions: m.descriptor.extensions || [],
654
+ contributes: m.descriptor.contributes,
655
+ remote: m.descriptor.id,
656
+ init: !!m.descriptor.init
657
+ } : console.error(
658
+ `initialize-plugins: Plugin ${m.id} does not have a descriptor`
659
+ ), g;
660
+ }, {});
661
+ window.KosPlugins = window.KosPlugins || {}, window.KosPlugins.__dynamicRemotes = h;
662
+ const d = Object.keys(h).reduce((g, m) => {
663
+ const C = h[m].remote;
664
+ return g[C] = h[m].basePath, g;
665
+ }, {});
666
+ return k.setRemoteDefinitions(d), d;
667
+ };
668
+ function _e(n, e, t = !1) {
669
+ return !n || Object.keys(n).length === 0 ? null : t ? e && n[e] ? n[e] : null : e && n[e] ? n[e] : Object.values(n).filter((s) => typeof s.id == "string").sort((s, o) => {
670
+ const a = typeof s.rank == "number" ? s.rank : 1 / 0, r = typeof o.rank == "number" ? o.rank : 1 / 0;
671
+ if (a === r) {
672
+ const c = s.id ?? "", l = o.id ?? "";
673
+ return c.localeCompare(l);
674
+ }
675
+ return a - r;
676
+ })[0] ?? null;
677
+ }
678
+ const D = E.object({
679
+ id: E.string().min(1, "ID is required").describe("Unique identifier for this extension"),
680
+ title: E.string().min(1, "Title is required").describe("Display title shown in the interface"),
681
+ namespace: E.string().min(1, "Namespace is required").describe("Namespace for organizing related extensions"),
682
+ experienceId: E.string().min(1, "Experience ID is required").describe("Reference to the UI component experience for rendering")
683
+ }), we = D.extend({
684
+ rank: E.number().int().min(0).optional().describe("Optional ranking for ordering (higher = preferred)")
685
+ });
686
+ function Te(n, e, t) {
687
+ const i = n.safeParse(e);
688
+ return i.success ? !0 : (i.error.errors.forEach((s) => {
689
+ t.addError(`${s.path.join(".")}: ${s.message}`);
690
+ }), !1);
691
+ }
692
+ function Ue(n, e, t) {
693
+ e && !e.includes(".") && t.addWarning(
694
+ `${n} '${e}' should typically include dot notation (e.g., 'category.item')`
695
+ );
696
+ }
697
+ function $e(n, e, t = 1e3) {
698
+ n !== void 0 && n > t && e.addWarning(
699
+ `Rank ${n} seems unusually high - consider using lower values for better ordering`
700
+ );
701
+ }
702
+ function Oe(n, e = {}) {
703
+ return (e.rankable ? we : D).extend(n);
704
+ }
705
+ function De(n, e, t = 1e3) {
706
+ typeof n == "object" && n !== null && "rank" in n && $e(n.rank, e, t);
707
+ }
708
+ class I {
709
+ /**
710
+ * Get all extension points with their plugin information
711
+ */
712
+ static getExtensionPoints(e, t = {}) {
713
+ const {
714
+ includeLegacyExtensions: i = !0,
715
+ includeEmptyExtensionPoints: s = !0
716
+ } = t, a = y().getAllExtensionPoints(), r = [];
717
+ return a.forEach((c) => {
718
+ const l = Object.values((e == null ? void 0 : e[c.id]) || {});
719
+ !s && l.length === 0 || r.push({
720
+ id: c.id,
721
+ displayName: c.config.displayName,
722
+ description: c.config.description,
723
+ source: "simplified",
724
+ metadata: c.config.metadata,
725
+ pluginCount: l.length,
726
+ plugins: l
727
+ });
728
+ }), i && e && Object.entries(e).forEach(([c, l]) => {
729
+ if (r.some((f) => f.id === c))
730
+ return;
731
+ const u = Object.values(l || {});
732
+ !s && u.length === 0 || r.push({
733
+ id: c,
734
+ source: "legacy",
735
+ pluginCount: u.length,
736
+ plugins: u
737
+ });
738
+ }), r.sort((c, l) => c.id.localeCompare(l.id));
739
+ }
740
+ /**
741
+ * Filter extension points based on search criteria
742
+ */
743
+ static filterExtensionPoints(e, t) {
744
+ if (!t.trim())
745
+ return e;
746
+ const i = t.toLowerCase();
747
+ return e.filter(
748
+ (s) => {
749
+ var o, a, r, c, l, u;
750
+ return s.id.toLowerCase().includes(i) || ((o = s.displayName) == null ? void 0 : o.toLowerCase().includes(i)) || ((a = s.description) == null ? void 0 : a.toLowerCase().includes(i)) || ((c = (r = s.metadata) == null ? void 0 : r.category) == null ? void 0 : c.toLowerCase().includes(i)) || ((u = (l = s.metadata) == null ? void 0 : l.tags) == null ? void 0 : u.some((f) => f.toLowerCase().includes(i)));
751
+ }
752
+ );
753
+ }
754
+ /**
755
+ * Calculate health statistics for the plugin system
756
+ */
757
+ static calculateHealthStats(e) {
758
+ const t = e.length, i = e.filter(
759
+ (c) => c.pluginCount > 0
760
+ ).length, s = e.reduce(
761
+ (c, l) => c + l.pluginCount,
762
+ 0
763
+ ), o = e.filter(
764
+ (c) => c.source === "simplified"
765
+ ).length, a = e.filter(
766
+ (c) => c.source === "legacy"
767
+ ).length, r = e.filter(
768
+ (c) => {
769
+ var l;
770
+ return (l = c.metadata) == null ? void 0 : l.deprecated;
771
+ }
772
+ ).length;
773
+ return {
774
+ totalExtensionPoints: t,
775
+ extensionPointsWithPlugins: i,
776
+ totalPlugins: s,
777
+ simplifiedExtensionPoints: o,
778
+ legacyExtensionPoints: a,
779
+ deprecatedExtensionPoints: r
780
+ };
781
+ }
782
+ /**
783
+ * Analyze a specific plugin for health and capabilities
784
+ */
785
+ static analyzePlugin(e) {
786
+ const t = !!e.component, i = typeof e.rank == "number", s = e.rank || 0, o = [];
787
+ if (t ? o.push("UI Component") : o.push("Background Service"), i && o.push(`Rank: ${s}`), e.namespace) {
788
+ const r = e.namespace;
789
+ r.includes("kos") || r.includes("ddk") ? o.push("First-party") : o.push("Third-party");
790
+ }
791
+ e.modalMode && o.push(`Modal: ${e.modalMode}`);
792
+ let a = "healthy";
793
+ return e.remote || (a = "warning"), {
794
+ hasComponent: t,
795
+ hasRank: i,
796
+ healthStatus: a,
797
+ capabilities: o
798
+ };
799
+ }
800
+ /**
801
+ * Get extension point by ID with detailed information
802
+ */
803
+ static getExtensionPointById(e, t) {
804
+ return e.find((i) => i.id === t);
805
+ }
806
+ /**
807
+ * Validate if an extension point ID follows conventions
808
+ */
809
+ static validateExtensionPointId(e) {
810
+ const t = [], i = [];
811
+ e.includes(".") || (t.push(
812
+ "Extension point ID should contain at least one dot (namespace.feature)"
813
+ ), i.push('Use format like "ddk.myFeature" or "app.myFeature"'));
814
+ const s = e.split(".");
815
+ s.length < 2 && t.push(
816
+ "Extension point ID should have at least 2 parts (namespace.feature)"
817
+ );
818
+ const o = s[0];
819
+ return o && !["ddk", "cui", "app"].includes(o) && !o.endsWith("app") && i.push(
820
+ "Consider using standard namespaces: ddk, cui, or [appname]app"
821
+ ), s.some((r) => /[A-Z]/.test(r)) && (t.push("Extension point ID parts should be lowercase"), i.push(
822
+ 'Use kebab-case or dot notation: "my.feature" not "my.myFeature"'
823
+ )), {
824
+ isValid: t.length === 0,
825
+ issues: t,
826
+ suggestions: i
827
+ };
828
+ }
829
+ /**
830
+ * Validate a plugin descriptor structure and content
831
+ */
832
+ static validatePluginDescriptor(e) {
833
+ const t = [], i = [], s = [], o = [];
834
+ if (e.id ? e.id.match(/^[a-z0-9-]+$/) || o.push(
835
+ "Plugin ID convention: use lowercase letters, numbers, and hyphens (e.g., 'my-awesome-plugin')"
836
+ ) : (s.push("id"), t.push("Plugin descriptor must have an 'id' field")), !e.contributes)
837
+ i.push(
838
+ "Plugin has no contributions - it won't extend any functionality"
839
+ ), o.push("Add a 'contributes' section with plugin contributions");
840
+ else {
841
+ const a = Object.keys(e.contributes);
842
+ a.length === 0 && i.push("Plugin contributes section is empty"), a.forEach((r) => {
843
+ const c = e.contributes[r];
844
+ if (!Array.isArray(c)) {
845
+ t.push(`Contribution '${r}' must be an array`);
846
+ return;
847
+ }
848
+ c.forEach((l, u) => {
849
+ l.id || t.push(
850
+ `Contribution ${r}[${u}] missing required 'id' field`
851
+ ), r === "experiences" && l.component && !l.location && (t.push(
852
+ `Experience '${l.id}' has component but no location`
853
+ ), o.push(
854
+ "Add 'location' field pointing to the component file"
855
+ )), ["cui", "utilities", "settings", "setup"].includes(r) && (l.title || i.push(
856
+ `${r} contribution '${l.id}' missing 'title' field`
857
+ ), l.namespace || i.push(
858
+ `${r} contribution '${l.id}' missing 'namespace' field`
859
+ ), l.experienceId || t.push(
860
+ `${r} contribution '${l.id}' missing required 'experienceId' field`
861
+ ));
862
+ });
863
+ });
864
+ }
865
+ return e.init !== void 0 && typeof e.init != "boolean" && t.push("'init' field must be a boolean value"), {
866
+ isValid: t.length === 0 && s.length === 0,
867
+ errors: t,
868
+ warnings: i,
869
+ missingRequired: s,
870
+ suggestions: o
871
+ };
872
+ }
873
+ /**
874
+ * Check compatibility between plugin contributions and available extension points
875
+ */
876
+ static checkPluginCompatibility(e, t) {
877
+ const i = [], s = [], o = [], a = [];
878
+ if (!e.contributes)
879
+ return {
880
+ isCompatible: !0,
881
+ issues: ["Plugin has no contributions to check"],
882
+ missingExtensionPoints: [],
883
+ incompatibleTypes: [],
884
+ suggestions: []
885
+ };
886
+ const r = y(), c = new Set(
887
+ t.map((l) => l.id)
888
+ );
889
+ return Object.entries(e.contributes).forEach(
890
+ ([l, u]) => {
891
+ this.getExpectedExtensionPoints(l).forEach((p) => {
892
+ c.has(p) || (s.push(p), i.push(
893
+ `Extension point '${p}' not available for '${l}' contributions`
894
+ ), a.push(
895
+ `Ensure the extension point '${p}' is registered`
896
+ ));
897
+ });
898
+ const d = r.getAllExtensionPoints().find(
899
+ (p) => p.config.contributionKey === l
900
+ );
901
+ d && u.length > 0 && u.forEach((p, b) => {
902
+ d.config.isRankable && typeof p.rank != "number" && (i.push(
903
+ `${l}[${b}]: Extension point '${d.id}' expects 'rank' property`
904
+ ), a.push(
905
+ "Add 'rank' property with numeric value for ordering"
906
+ )), d.config.hasView && !p.experienceId && (i.push(
907
+ `${l}[${b}]: Extension point '${d.id}' expects 'experienceId' for view-based contributions`
908
+ ), a.push(
909
+ "Add 'experienceId' property linking to an experience definition"
910
+ ));
911
+ });
912
+ }
913
+ ), {
914
+ isCompatible: i.length === 0,
915
+ issues: i,
916
+ missingExtensionPoints: s,
917
+ incompatibleTypes: o,
918
+ suggestions: a
919
+ };
920
+ }
921
+ /**
922
+ * Map contribution keys to their expected extension point IDs
923
+ */
924
+ static getExpectedExtensionPoints(e) {
925
+ return {
926
+ cui: ["ddk.cui", "ddk.cui.view", "ddk.cui.settings.config"],
927
+ utilities: ["ddk.utility", "ddk.utility.view", "ddk.utilities"],
928
+ setup: ["ddk.setup", "ddk.setup.view"],
929
+ settings: ["ddk.settings", "ddk.settings.view"],
930
+ troubleActions: ["ddk.troubleAction", "ddk.troubleAction.view"],
931
+ navViews: ["ddk.nav", "ddk.nav.view"],
932
+ controlPour: ["ddk.controlPour", "ddk.controlPour.view"],
933
+ experiences: [],
934
+ // Experiences don't directly map to extension points
935
+ views: []
936
+ // Views are mapped by their extension point ID keys
937
+ }[e] || [];
938
+ }
939
+ /**
940
+ * Get comprehensive plugin analysis including validation and compatibility
941
+ */
942
+ static analyzePluginDescriptor(e, t) {
943
+ const i = this.validatePluginDescriptor(e), s = this.checkPluginCompatibility(
944
+ e,
945
+ t
946
+ ), o = [];
947
+ return i.warnings.length > 0 && o.push(
948
+ "Address validation warnings to improve plugin quality"
949
+ ), s.isCompatible || o.push(
950
+ "Resolve compatibility issues before deploying plugin"
951
+ ), e.contributes && Object.keys(e.contributes).length === 1 && o.push(
952
+ "Consider adding more contribution types to increase plugin value"
953
+ ), {
954
+ validation: i,
955
+ compatibility: s,
956
+ recommendations: o
957
+ };
958
+ }
959
+ }
960
+ class Ae {
961
+ /**
962
+ * Generate complete documentation for all extension points
963
+ */
964
+ static generateFullDocumentation(e, t = {}) {
965
+ const {
966
+ includeUsageExamples: i = !0,
967
+ includeTypeDefinitions: s = !0,
968
+ includeLegacyExtensions: o = !0,
969
+ includePluginHealth: a = !0
970
+ } = t, r = I.getExtensionPoints(
971
+ e,
972
+ {
973
+ includeLegacyExtensions: o,
974
+ includeEmptyExtensionPoints: !0
975
+ }
976
+ ), c = I.calculateHealthStats(r);
977
+ let l = this.generateHeader(c);
978
+ return l += this.generateTableOfContents(r), l += this.generateOverviewSection(r, c), r.forEach((u) => {
979
+ l += this.generateExtensionPointSection(u, {
980
+ includeUsageExamples: i,
981
+ includePluginHealth: a
982
+ });
983
+ }), s && (l += this.generateTypeDefinitionsSection(r)), l += this.generateContributionGuide(), l += this.generateTroubleshootingSection(), {
984
+ content: l,
985
+ metadata: {
986
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
987
+ totalExtensionPoints: c.totalExtensionPoints,
988
+ totalPlugins: c.totalPlugins,
989
+ simplifiedExtensionPoints: c.simplifiedExtensionPoints,
990
+ legacyExtensionPoints: c.legacyExtensionPoints
991
+ }
992
+ };
993
+ }
994
+ /**
995
+ * Generate documentation header with metadata
996
+ */
997
+ static generateHeader(e) {
998
+ return `# KOS Plugin Extension Points Reference
999
+
1000
+ **Generated**: ${(/* @__PURE__ */ new Date()).toLocaleString()}
1001
+
1002
+ ## System Overview
1003
+
1004
+ - **Total Extension Points**: ${e.totalExtensionPoints}
1005
+ - **Extension Points with Plugins**: ${e.extensionPointsWithPlugins}
1006
+ - **Total Active Plugins**: ${e.totalPlugins}
1007
+ - **Simplified Extension Points**: ${e.simplifiedExtensionPoints}
1008
+ - **Legacy Extension Points**: ${e.legacyExtensionPoints}
1009
+
1010
+ ---
1011
+
1012
+ `;
1013
+ }
1014
+ /**
1015
+ * Generate table of contents
1016
+ */
1017
+ static generateTableOfContents(e) {
1018
+ let t = `## Table of Contents
1019
+
1020
+ `;
1021
+ return t += `- [Overview](#overview)
1022
+ `, t += `- [Extension Points](#extension-points)
1023
+ `, e.forEach((i) => {
1024
+ const s = i.id.toLowerCase().replace(/\./g, "");
1025
+ t += ` - [${i.id}](#${s}) (${i.pluginCount} plugins)
1026
+ `;
1027
+ }), t += `- [Type Definitions](#type-definitions)
1028
+ `, t += `- [Contribution Guide](#contribution-guide)
1029
+ `, t += `- [Troubleshooting](#troubleshooting)
1030
+
1031
+ `, t;
1032
+ }
1033
+ /**
1034
+ * Generate overview section with health statistics
1035
+ */
1036
+ static generateOverviewSection(e, t) {
1037
+ let i = `## Overview
1038
+
1039
+ `;
1040
+ return i += "This document provides a comprehensive reference for all available extension points in the KOS plugin system. ", i += `Extension points allow plugins to contribute functionality to the application.
1041
+
1042
+ `, i += `### Extension Point Types
1043
+
1044
+ `, i += "- **✨ Simplified Extension Points**: Use the new simplified API from `defineExtensionPoint`\n", i += `- **📚 Legacy Extension Points**: Use the traditional reducer-based system
1045
+
1046
+ `, t.deprecatedExtensionPoints > 0 && (i += `### ⚠️ Deprecated Extension Points
1047
+
1048
+ `, i += `${t.deprecatedExtensionPoints} extension points are marked as deprecated. `, i += `Consider migrating to newer alternatives.
1049
+
1050
+ `), i + `---
1051
+
1052
+ `;
1053
+ }
1054
+ /**
1055
+ * Generate documentation section for a single extension point
1056
+ */
1057
+ static generateExtensionPointSection(e, t) {
1058
+ var a;
1059
+ const { includeUsageExamples: i = !0, includePluginHealth: s = !0 } = t;
1060
+ let o = `## ${e.source === "simplified" ? "✨" : "📚"} ${e.id}
1061
+
1062
+ `;
1063
+ if (e.displayName && (o += `**Display Name**: ${e.displayName}
1064
+
1065
+ `), e.description && (o += `**Description**: ${e.description}
1066
+
1067
+ `), o += `**Source**: ${e.source}
1068
+ `, o += `**Active Plugins**: ${e.pluginCount}
1069
+
1070
+ `, e.metadata) {
1071
+ o += `### Metadata
1072
+
1073
+ `;
1074
+ const r = e.metadata;
1075
+ r.category && (o += `- **Category**: ${r.category}
1076
+ `), r.owner && (o += `- **Owner**: ${r.owner}
1077
+ `), r.since && (o += `- **Since**: ${r.since}
1078
+ `), (a = r.tags) != null && a.length && (o += `- **Tags**: ${r.tags.join(", ")}
1079
+ `), r.deprecated && (o += `- **⚠️ Status**: Deprecated
1080
+ `), o += `
1081
+ `;
1082
+ }
1083
+ return i && (o += this.generateUsageExamples(e)), e.plugins.length > 0 ? o += this.generatePluginList(
1084
+ e.plugins,
1085
+ s
1086
+ ) : o += `### Plugins
1087
+
1088
+ No plugins currently registered for this extension point.
1089
+
1090
+ `, o += this.generateSchemaFieldsSection(e), o += this.generateContributionStructure(e), o + `---
1091
+
1092
+ `;
1093
+ }
1094
+ /**
1095
+ * Generate usage examples for an extension point
1096
+ */
1097
+ static generateUsageExamples(e) {
1098
+ let t = `### Usage Examples
1099
+
1100
+ `;
1101
+ return e.source === "simplified" && (t += `#### Using Simplified API
1102
+
1103
+ `, t += "```typescript\n", t += `// Import the extension point
1104
+ `, t += `import { ${this.getExtensionPointImportName(
1105
+ e.id
1106
+ )} } from './extension-points';
1107
+
1108
+ `, t += `// Use extension component hook
1109
+ `, t += `import { useExtensionComponent } from '@kosdev-code/kos-ui-plugin';
1110
+
1111
+ `, t += `const Component = useExtensionComponent(${this.getExtensionPointImportName(
1112
+ e.id
1113
+ )});
1114
+
1115
+ `, t += `if (Component) {
1116
+ `, t += ` return (
1117
+ `, t += ` <Component
1118
+ `, t += ` customProp="value"
1119
+ `, t += ` onComplete={handleComplete}
1120
+ `, t += ` />
1121
+ `, t += ` );
1122
+ `, t += `}
1123
+
1124
+ `, t += `// Or use with dynamic component
1125
+ `, t += `const [Component] = useDynamicComponent({
1126
+ `, t += ` extension: ${this.getExtensionPointImportName(
1127
+ e.id
1128
+ )}.id
1129
+ `, t += `});
1130
+ `, t += "```\n\n", t += `#### Using Typed Hooks
1131
+
1132
+ `, t += "```typescript\n", t += `// Get all extensions with type safety
1133
+ `, t += `const extensions = useExtensions(${this.getExtensionPointImportName(
1134
+ e.id
1135
+ )});
1136
+
1137
+ `, t += `// Get best extension
1138
+ `, t += `const bestExtension = useBest(${this.getExtensionPointImportName(
1139
+ e.id
1140
+ )});
1141
+
1142
+ `, t += `// Check availability
1143
+ `, t += `const hasExtensions = useHasExtensions(${this.getExtensionPointImportName(
1144
+ e.id
1145
+ )});
1146
+ `, t += "```\n\n"), t += `#### Using DynamicComponent
1147
+
1148
+ `, t += "```typescript\n", t += `import { DynamicComponent } from '@kosdev-code/kos-ui-plugin';
1149
+ `, t += `import { ${this.getExtensionPointImportName(
1150
+ e.id
1151
+ )} } from './extension-points';
1152
+
1153
+ `, t += `<DynamicComponent
1154
+ `, t += ` extension={${this.getExtensionPointImportName(
1155
+ e.id
1156
+ )}.id}
1157
+ `, t += ` props={{ customData: "value" }}
1158
+ `, t += ` fallback={<div>Loading...</div>}
1159
+ `, t += `/>
1160
+ `, t += "```\n\n", t += `#### Using Context
1161
+
1162
+ `, t += "```typescript\n", t += `import { useKosPluginsContext } from '@kosdev-code/kos-ui-plugin';
1163
+ `, t += `import { ${this.getExtensionPointImportName(
1164
+ e.id
1165
+ )} } from './extension-points';
1166
+
1167
+ `, t += `const { getExtensions } = useKosPluginsContext();
1168
+ `, t += `const extensions = getExtensions(${this.getExtensionPointImportName(
1169
+ e.id
1170
+ )}.id);
1171
+ `, t += "```\n\n", t;
1172
+ }
1173
+ /**
1174
+ * Generate plugin list with health information
1175
+ */
1176
+ static generatePluginList(e, t) {
1177
+ let i = `### Active Plugins
1178
+
1179
+ `;
1180
+ return e.forEach((s) => {
1181
+ if (i += `#### ${s.id}
1182
+
1183
+ `, s.remote && (i += `- **Remote**: ${s.remote}
1184
+ `), s.sectionId && (i += `- **Section**: ${s.sectionId}
1185
+ `), s.rank !== void 0 && (i += `- **Rank**: ${s.rank}
1186
+ `), t) {
1187
+ const o = I.analyzePlugin(s);
1188
+ i += `- **Health**: ${this.getHealthEmoji(o.healthStatus)} ${o.healthStatus}
1189
+ `, o.capabilities.length > 0 && (i += `- **Capabilities**: ${o.capabilities.join(", ")}
1190
+ `);
1191
+ }
1192
+ i += `
1193
+ `;
1194
+ }), i;
1195
+ }
1196
+ /**
1197
+ * Generate schema fields documentation
1198
+ */
1199
+ static generateSchemaFieldsSection(e) {
1200
+ if (e.source !== "simplified")
1201
+ return "";
1202
+ const i = y().getExtensionPoint(e.id);
1203
+ if (!(i != null && i.getSchemaFieldInfo))
1204
+ return "";
1205
+ const s = i.getSchemaFieldInfo();
1206
+ if (s.length === 0)
1207
+ return "";
1208
+ let o = `### Schema Fields
1209
+
1210
+ `;
1211
+ return o += `The following fields are defined in the schema for this extension point:
1212
+
1213
+ `, o += `| Field | Type | Required | Description |
1214
+ `, o += `|-------|------|----------|-------------|
1215
+ `, s.forEach((a) => {
1216
+ const r = a.name, c = a.type || "unknown", l = a.required ? "✅" : "⭕", u = a.description || "-";
1217
+ o += `| \`${r}\` | ${c} | ${l} | ${u} |
1218
+ `;
1219
+ }), o += `
1220
+ `, o;
1221
+ }
1222
+ /**
1223
+ * Generate contribution structure documentation
1224
+ */
1225
+ static generateContributionStructure(e) {
1226
+ let t = `### Contribution Structure
1227
+
1228
+ `;
1229
+ t += `To contribute to this extension point, add the following to your plugin descriptor:
1230
+
1231
+ `, t += "```json\n", t += `{
1232
+ `, t += ` "id": "your-plugin-id",
1233
+ `, t += ` "contributes": {
1234
+ `;
1235
+ const i = this.inferContributionKey(e);
1236
+ t += ` "${i}": [
1237
+ `, t += ` {
1238
+ `;
1239
+ const s = this.getSchemaFieldsForContribution(e);
1240
+ if (s.length > 0) {
1241
+ const a = [];
1242
+ s.forEach((r) => {
1243
+ let c;
1244
+ r.name === "id" ? c = '"your-contribution-id"' : r.name === "title" ? c = '"Your Contribution Title"' : r.name === "namespace" ? c = '"your-namespace"' : r.name === "experienceId" ? c = '"your-experience-id"' : r.name === "dashboardKey" ? c = '"your-dashboard-key"' : r.name === "rank" ? c = "10" : r.type === "string" ? c = `"your-${r.name}"` : r.type === "number" ? c = "0" : r.type === "boolean" ? c = "false" : c = `"your-${r.name}"`, (r.required || ["experienceId", "rank", "dashboardKey"].includes(r.name)) && a.push(` "${r.name}": ${c}`);
1245
+ }), t += a.join(`,
1246
+ `);
1247
+ } else {
1248
+ t += ` "id": "your-contribution-id",
1249
+ `, t += ` "title": "Your Contribution Title",
1250
+ `, t += ' "namespace": "your-namespace"', this.isViewBasedExtensionPoint(e) && (t += `,
1251
+ "experienceId": "your-experience-id"`), this.isRankableExtensionPoint(e) && (t += `,
1252
+ "rank": 10`);
1253
+ const a = this.getSpecificFields(e);
1254
+ a.length > 0 && (t += `,
1255
+ ${a.join(`,
1256
+ `)}`);
1257
+ }
1258
+ return t += `
1259
+ }
1260
+ `, t += " ]", (s.some((a) => a.name === "experienceId") || this.isViewBasedExtensionPoint(e)) && (t += `,
1261
+ "experiences": {
1262
+ `, t += ` "your-experience-id": {
1263
+ `, t += ` "id": "your-experience-id",
1264
+ `, t += ` "component": "YourComponent",
1265
+ `, t += ` "location": "./src/components/YourComponent.tsx"
1266
+ `, t += ` }
1267
+ `, t += " }"), t += `
1268
+ }
1269
+ `, t += `}
1270
+ `, t += "```\n\n", t;
1271
+ }
1272
+ /**
1273
+ * Generate TypeScript definitions section
1274
+ */
1275
+ static generateTypeDefinitionsSection(e) {
1276
+ let t = `## Type Definitions
1277
+
1278
+ `;
1279
+ return t += `### Extension Point Types
1280
+
1281
+ `, t += "```typescript\n", e.forEach((i) => {
1282
+ i.source === "simplified" && (t += `// ${i.id}
1283
+ `, t += `interface ${this.getExtensionPointTypeName(i.id)} {
1284
+ `, t += ` id: "${i.id}";
1285
+ `, t += ` displayName?: "${i.displayName || ""}";
1286
+ `, t += ` description?: "${i.description || ""}";
1287
+ `, t += `}
1288
+
1289
+ `);
1290
+ }), t += "```\n\n", t += `### Plugin Contribution Types
1291
+
1292
+ `, t += "```typescript\n", t += `interface BaseContribution {
1293
+ `, t += ` id: string;
1294
+ `, t += ` title: string;
1295
+ `, t += ` namespace: string;
1296
+ `, t += `}
1297
+
1298
+ `, t += `interface ViewBasedContribution extends BaseContribution {
1299
+ `, t += ` experienceId: string;
1300
+ `, t += `}
1301
+
1302
+ `, t += `interface RankableContribution extends BaseContribution {
1303
+ `, t += ` rank: number;
1304
+ `, t += `}
1305
+ `, t += "```\n\n", t;
1306
+ }
1307
+ /**
1308
+ * Generate contribution guide
1309
+ */
1310
+ static generateContributionGuide() {
1311
+ return `## Contribution Guide
1312
+
1313
+ ### Creating a Plugin
1314
+
1315
+ 1. **Create Plugin Project**
1316
+ \`\`\`bash
1317
+ kosui plugin-project --name my-plugin
1318
+ \`\`\`
1319
+
1320
+ 2. **Add Components**
1321
+ \`\`\`bash
1322
+ kosui component --name MyComponent --pluginType utility --project my-plugin
1323
+ \`\`\`
1324
+
1325
+ 3. **Update Plugin Descriptor**
1326
+ Add contributions to your \`kosdev-plugin.json\` file following the structure examples above.
1327
+
1328
+ 4. **Test Integration**
1329
+ Use the Plugin Explorer (Ctrl+Shift+P) to validate your plugin registration.
1330
+
1331
+ ### Best Practices
1332
+
1333
+ - **Use descriptive IDs**: Plugin and contribution IDs should be clear and unique
1334
+ - **Follow naming conventions**: Use kebab-case for IDs, PascalCase for components
1335
+ - **Provide meaningful titles**: Titles are shown to users in the interface
1336
+ - **Set appropriate ranks**: Higher numbers = higher priority for rankable contributions
1337
+ - **Include proper metadata**: Namespace helps organize plugins by owner
1338
+
1339
+ ### Validation
1340
+
1341
+ Use the Plugin Discovery Service to validate your plugin descriptor:
1342
+
1343
+ \`\`\`typescript
1344
+ import { PluginDiscoveryService } from '@kosdev-code/kos-ui-plugin';
1345
+
1346
+ const validation = PluginDiscoveryService.validatePluginDescriptor(yourDescriptor);
1347
+ console.log(validation.errors); // Check for errors
1348
+ console.log(validation.warnings); // Check for warnings
1349
+ \`\`\`
1350
+
1351
+ `;
1352
+ }
1353
+ /**
1354
+ * Generate troubleshooting section
1355
+ */
1356
+ static generateTroubleshootingSection() {
1357
+ return `## Troubleshooting
1358
+
1359
+ ### Common Issues
1360
+
1361
+ **Plugin not appearing in extension point**
1362
+ - Check plugin descriptor syntax
1363
+ - Verify contribution key matches extension point requirements
1364
+ - Ensure experienceId references exist in experiences section
1365
+
1366
+ **Component fails to load**
1367
+ - Verify component path in experience location
1368
+ - Check module federation configuration
1369
+ - Use Plugin Explorer to see detailed error messages
1370
+
1371
+ **Type errors with simplified extension points**
1372
+ - Ensure extension point is properly imported
1373
+ - Check that component props match expected interface
1374
+ - Verify extension point is registered before use
1375
+
1376
+ ### Debugging Tools
1377
+
1378
+ **Plugin Explorer**
1379
+ - Press Ctrl+Shift+P in development mode
1380
+ - View all extension points and their plugins
1381
+ - See plugin health status and capabilities
1382
+ - Test component rendering with error boundaries
1383
+
1384
+ **Validation Service**
1385
+ - Use \`PluginDiscoveryService.validatePluginDescriptor()\`
1386
+ - Check \`PluginDiscoveryService.checkPluginCompatibility()\`
1387
+ - Run \`PluginDiscoveryService.analyzePluginDescriptor()\` for full analysis
1388
+
1389
+ **Browser DevTools**
1390
+ - Check \`window.KosPlugins.extensions\` for runtime state
1391
+ - Look for module federation errors in Network tab
1392
+ - Use React DevTools to inspect component loading
1393
+
1394
+ ---
1395
+
1396
+ *Generated by KOS Plugin Documentation Generator*
1397
+ `;
1398
+ }
1399
+ // Helper methods
1400
+ static getExtensionPointImportName(e) {
1401
+ var a;
1402
+ const i = y().getExtensionPoint(e);
1403
+ if ((a = i == null ? void 0 : i.config.metadata) != null && a.exportName)
1404
+ return i.config.metadata.exportName;
1405
+ const s = e.split(".");
1406
+ return (s.length > 1 ? s.slice(1) : s).map(
1407
+ (r) => (
1408
+ // Handle hyphenated parts (e.g., "pump-detail" -> "PumpDetail")
1409
+ r.split("-").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join("")
1410
+ )
1411
+ ).join("") + "Extension";
1412
+ }
1413
+ static getExtensionPointTypeName(e) {
1414
+ return this.getExtensionPointImportName(e) + "Type";
1415
+ }
1416
+ static getHealthEmoji(e) {
1417
+ switch (e) {
1418
+ case "healthy":
1419
+ return "✅";
1420
+ case "warning":
1421
+ return "⚠️";
1422
+ case "error":
1423
+ return "❌";
1424
+ default:
1425
+ return "❓";
1426
+ }
1427
+ }
1428
+ static inferContributionKey(e) {
1429
+ if (e.source === "simplified") {
1430
+ const a = y().getExtensionPoint(e.id);
1431
+ if (a != null && a.config.contributionKey)
1432
+ return a.config.contributionKey;
1433
+ }
1434
+ const t = e.id.split("."), i = t[t.length - 1];
1435
+ return {
1436
+ cui: "cui",
1437
+ utility: "utilities",
1438
+ utilities: "utilities",
1439
+ setup: "setupStep",
1440
+ settings: "settings",
1441
+ nav: "navViews",
1442
+ troubleAction: "troubleActions",
1443
+ controlPour: "controlPour"
1444
+ }[i] || i + "s";
1445
+ }
1446
+ static isViewBasedExtensionPoint(e) {
1447
+ if (e.source === "simplified") {
1448
+ const i = y().getExtensionPoint(e.id);
1449
+ return (i == null ? void 0 : i.config.hasView) || !1;
1450
+ }
1451
+ return e.plugins.some(
1452
+ (t) => t.experienceId
1453
+ );
1454
+ }
1455
+ static isRankableExtensionPoint(e) {
1456
+ if (e.source === "simplified") {
1457
+ const i = y().getExtensionPoint(e.id);
1458
+ return (i == null ? void 0 : i.config.isRankable) || !1;
1459
+ }
1460
+ return e.plugins.some(
1461
+ (t) => typeof t.rank == "number"
1462
+ );
1463
+ }
1464
+ /**
1465
+ * Get schema fields for contribution structure generation
1466
+ */
1467
+ static getSchemaFieldsForContribution(e) {
1468
+ if (e.source !== "simplified")
1469
+ return [];
1470
+ const i = y().getExtensionPoint(e.id);
1471
+ return i != null && i.getSchemaFieldInfo ? i.getSchemaFieldInfo() : [];
1472
+ }
1473
+ static getSpecificFields(e) {
1474
+ const t = [];
1475
+ switch (this.inferContributionKey(e)) {
1476
+ case "utilities":
1477
+ t.push('"utilDescriptor": "your-util-descriptor"');
1478
+ break;
1479
+ case "setupStep":
1480
+ t.push('"setupDescriptor": "your-setup-descriptor"');
1481
+ break;
1482
+ case "settings":
1483
+ t.push('"settingsGroup": "your-settings-group"');
1484
+ break;
1485
+ case "navViews":
1486
+ t.push('"navDescriptor": "your-nav-descriptor"');
1487
+ break;
1488
+ case "troubleActions":
1489
+ t.push('"troubleType": "your-trouble-type"');
1490
+ break;
1491
+ case "cui":
1492
+ t.push('"cuiDescriptor": "your-cui-descriptor"');
1493
+ break;
1494
+ }
1495
+ return t;
1496
+ }
1497
+ }
1498
+ export {
1499
+ D as B,
1500
+ Ae as D,
1501
+ I as P,
1502
+ we as R,
1503
+ Fe as a,
1504
+ be as b,
1505
+ y as c,
1506
+ ye as d,
1507
+ xe as e,
1508
+ Se as f,
1509
+ Ie as g,
1510
+ Y as h,
1511
+ Re as i,
1512
+ Z as j,
1513
+ O as k,
1514
+ Ee as l,
1515
+ k as m,
1516
+ Ue as n,
1517
+ $e as o,
1518
+ Oe as p,
1519
+ De as q,
1520
+ _e as r,
1521
+ Te as v
1522
+ };
1523
+ //# sourceMappingURL=documentation-generator-BVDETA08.js.map