@kosdev-code/kos-ui-plugin 0.1.0-dev.5101 → 0.1.0-dev.5112

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