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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/documentation-generator-CAlVz5vA.cjs +266 -0
  2. package/documentation-generator-CAlVz5vA.cjs.map +1 -0
  3. package/documentation-generator-Di4c9D9P.js +2337 -0
  4. package/documentation-generator-Di4c9D9P.js.map +1 -0
  5. package/index.cjs +69 -69
  6. package/index.cjs.map +1 -1
  7. package/index.d.ts +1 -0
  8. package/index.d.ts.map +1 -1
  9. package/index.js +817 -753
  10. package/index.js.map +1 -1
  11. package/lib/components/dynamic-component/dynamic-component.d.ts +69 -0
  12. package/lib/components/dynamic-component/dynamic-component.d.ts.map +1 -1
  13. package/lib/contexts/index.d.ts +1 -0
  14. package/lib/contexts/index.d.ts.map +1 -1
  15. package/lib/contexts/plugins-provider/plugins-provider.d.ts.map +1 -1
  16. package/lib/contexts/reactive-extension-registry-context.d.ts +10 -0
  17. package/lib/contexts/reactive-extension-registry-context.d.ts.map +1 -0
  18. package/lib/hooks/index.d.ts +4 -2
  19. package/lib/hooks/index.d.ts.map +1 -1
  20. package/lib/hooks/use-dynamic-component.d.ts +12 -1
  21. package/lib/hooks/use-dynamic-component.d.ts.map +1 -1
  22. package/lib/hooks/use-extension-point.d.ts +95 -0
  23. package/lib/hooks/use-extension-point.d.ts.map +1 -0
  24. package/lib/hooks/use-reactive-extension-registry.d.ts +20 -0
  25. package/lib/hooks/use-reactive-extension-registry.d.ts.map +1 -0
  26. package/lib/hooks/use-typed-extensions.d.ts.map +1 -1
  27. package/lib/utils/contribution-registry.d.ts +170 -0
  28. package/lib/utils/contribution-registry.d.ts.map +1 -0
  29. package/lib/utils/extension-points/extension-point-registry.d.ts.map +1 -1
  30. package/lib/utils/extension-points/extension-point-schemas.d.ts +4 -4
  31. package/lib/utils/index.d.ts +3 -0
  32. package/lib/utils/index.d.ts.map +1 -1
  33. package/lib/utils/plugin-system/plugin-extension-manager.d.ts.map +1 -1
  34. package/lib/utils/processors/initialize-plugins.d.ts.map +1 -1
  35. package/lib/utils/reactive-extension-registry.d.ts +140 -0
  36. package/lib/utils/reactive-extension-registry.d.ts.map +1 -0
  37. package/lib/webpack/index.d.ts +2 -0
  38. package/lib/webpack/index.d.ts.map +1 -1
  39. package/lib/webpack/with-plugin-dev-aggregator.d.ts +94 -0
  40. package/lib/webpack/with-plugin-dev-aggregator.d.ts.map +1 -0
  41. package/lib/webpack/with-plugin-dev-server.d.ts +113 -0
  42. package/lib/webpack/with-plugin-dev-server.d.ts.map +1 -0
  43. package/package.json +2 -2
  44. package/types/contribution-enablement.d.ts +293 -0
  45. package/types/contribution-enablement.d.ts.map +1 -0
  46. package/types/plugins.d.ts +8 -0
  47. package/utils.cjs +1 -1
  48. package/utils.cjs.map +1 -1
  49. package/utils.js +29 -291
  50. package/utils.js.map +1 -1
  51. package/webpack.cjs +3 -12
  52. package/webpack.cjs.map +1 -1
  53. package/webpack.js +455 -727
  54. package/webpack.js.map +1 -1
  55. package/documentation-generator-DFaIDo0E.cjs +0 -266
  56. package/documentation-generator-DFaIDo0E.cjs.map +0 -1
  57. package/documentation-generator-auruIa_o.js +0 -1560
  58. package/documentation-generator-auruIa_o.js.map +0 -1
@@ -1,1560 +0,0 @@
1
- var W = Object.defineProperty;
2
- var G = (n, t, e) => t in n ? W(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var C = (n, t, e) => (G(n, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { z as w } from "zod";
5
- function z(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 F = {}, E = {};
22
- Object.defineProperty(E, "__esModule", { value: !0 });
23
- E.loadRemoteModule = E.setRemoteDefinitions = E.setRemoteUrlResolver = void 0;
24
- let R, D;
25
- const O = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map();
26
- let N = !1;
27
- function J(n) {
28
- D = n;
29
- }
30
- E.setRemoteUrlResolver = J;
31
- function Z(n) {
32
- R = n;
33
- }
34
- E.setRemoteDefinitions = Z;
35
- async function Y(n, t) {
36
- const e = `${n}:${t}`;
37
- if (O.has(e))
38
- return O.get(e);
39
- const o = (await (U.has(n) ? U.get(n) : await X(n)).get(t))();
40
- return O.set(e, o), o;
41
- }
42
- E.loadRemoteModule = Y;
43
- const Q = (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 X(n) {
59
- if (!D && !R)
60
- throw new Error("Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.");
61
- N || (N = !0, await __webpack_init_sharing__("default"));
62
- const t = R ? R[n] : await D(n);
63
- let e = t;
64
- !t.endsWith(".mjs") && !t.endsWith(".js") && (e = `${t}${t.endsWith("/") ? "" : "/"}remoteEntry.js`);
65
- const i = await Q(e, n);
66
- return await i.init(__webpack_share_scopes__.default), U.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 = E;
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
- })(F);
79
- const Ne = /* @__PURE__ */ z({
80
- __proto__: null
81
- }, [F]), V = [];
82
- function ee(n) {
83
- V.push(n);
84
- }
85
- function te(n, t, e) {
86
- return V.reduce(
87
- (i, s) => s(i, t, e),
88
- n
89
- );
90
- }
91
- function ne(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 ie {
117
- constructor() {
118
- C(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 se {
140
- constructor() {
141
- C(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 I = new se();
154
- function Ke(n) {
155
- return I.get(n);
156
- }
157
- class oe {
158
- constructor() {
159
- C(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
- ee(i), e.isRegistered = !0;
176
- }
177
- };
178
- return t.schema && (e.getSchemaFieldInfo = () => ne(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 f, h;
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 ie();
196
- if (t.validate(
197
- r,
198
- d
199
- ) === "skip") {
200
- I.set(a, [
201
- {
202
- type: "warning",
203
- message: "Plugin marked to skip processing"
204
- }
205
- ]);
206
- return;
207
- }
208
- if (d.hasIssues()) {
209
- const x = d.getIssues().map((m) => ({
210
- ...m,
211
- message: `Extension point validation: ${m.message}`
212
- }));
213
- if (I.set(a, x), d.hasErrors()) {
214
- console.error(
215
- `Validation failed for ${t.id} contribution "${a}":`,
216
- x.filter((m) => m.type === "error").map((m) => m.message).join(", ")
217
- );
218
- return;
219
- }
220
- } else
221
- I.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 && ((f = t.relatedPoints) != null && f.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
- (h = t.relatedPoints) != null && h.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 A = new oe();
289
- function b() {
290
- return A;
291
- }
292
- function Ve(n) {
293
- return A.getExtensionPointSchema(n);
294
- }
295
- function re(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 ae(n) {
312
- return A.define(n);
313
- }
314
- const ce = {
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 le(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 || ue(n.id)
332
- } : void 0
333
- };
334
- return n.schema && (t.schema = de(n.schema, {
335
- hasView: n.hasView,
336
- isRankable: n.isRankable
337
- })), n.validation && (t.validate = fe(n.validation)), n.transform ? t.transform = Pe(n.transform) : n.hasView && (t.transform = re()), t;
338
- }
339
- function ue(n) {
340
- return n.split(".").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join("") + "Extension";
341
- }
342
- function de(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] = pe(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 pe(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 fe(n) {
383
- return n.module ? Ee(n.module) : (t, e) => {
384
- if (!n.rules)
385
- return;
386
- const i = t;
387
- for (const s of n.rules)
388
- me(s, i, e);
389
- };
390
- }
391
- function me(n, t, e) {
392
- switch (n.type) {
393
- case "required":
394
- ge(n, t, e);
395
- break;
396
- case "range":
397
- he(n, t, e);
398
- break;
399
- case "pattern":
400
- ye(n, t, e);
401
- break;
402
- case "dependency":
403
- be(n, t, e);
404
- break;
405
- case "custom":
406
- xe(n, t, e);
407
- break;
408
- }
409
- }
410
- function ge(n, t, e) {
411
- n.field && !t[n.field] && e.addError(n.message || `Field '${n.field}' is required`);
412
- }
413
- function he(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 ye(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 be(n, t, e) {
429
- if (n.field && n.dependsOn && n.expression)
430
- try {
431
- S(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 xe(n, t, e) {
439
- if (n.expression)
440
- try {
441
- S(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 Ee(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 Pe(n) {
454
- return n.module ? we(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] = ve(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] = $e(
470
- i[s],
471
- o
472
- ));
473
- return i;
474
- };
475
- }
476
- function we(n) {
477
- return (t, e) => (console.warn(`External transform module not implemented: ${n}`), t);
478
- }
479
- function ve(n) {
480
- if (typeof n == "string" && n.startsWith("$")) {
481
- const t = ce[n];
482
- if (t)
483
- return t();
484
- }
485
- return n;
486
- }
487
- function $e(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 ke(n);
497
- case "kebabCase":
498
- return Ce(n);
499
- default:
500
- return n;
501
- }
502
- }
503
- function ke(n) {
504
- return n.replace(/[-_\s]+(.)?/g, (t, e) => e ? e.toUpperCase() : "").replace(/^./, (t) => t.toLowerCase());
505
- }
506
- function Ce(n) {
507
- return n.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
508
- }
509
- function S(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) => S(s, t)) : e.includes("&&") ? e.split("&&").map((s) => s.trim()).every((s) => S(s, t)) : !1;
528
- } catch (e) {
529
- return console.error("Expression evaluation failed:", e), !1;
530
- }
531
- }
532
- const Re = (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
- }), b().getAllExtensionPoints().forEach((l) => {
543
- var h;
544
- const { contributionKey: u } = l.config, f = (h = n[e].contributes) == null ? void 0 : h[u];
545
- f && (t[u] || (t[u] = {}), Array.isArray(f) ? f.forEach((d) => {
546
- d && d.id && (t[u][d.id] = {
547
- ...d,
548
- remote: i,
549
- sectionId: s
550
- });
551
- }) : typeof f == "object" && Object.entries(f).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 Ie(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 Fe(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 K = {
581
- controlPourDefinitions: {},
582
- experiences: {}
583
- };
584
- function Se(n) {
585
- return n ? Object.keys(n).reduce(Re(n), {
586
- ...K
587
- }) : K;
588
- }
589
- async function Fe(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) => le(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
- ae(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 F.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 = Se(n), e = t.experiences, s = te(
632
- {},
633
- t,
634
- e
635
- );
636
- return window.KosPlugins = window.KosPlugins || {}, window.KosPlugins.__extensions = s, s;
637
- }
638
- async function Me(n) {
639
- const { getExtensions: t } = await Ie();
640
- return t(n);
641
- }
642
- const _e = (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), {}), Oe = () => {
646
- const n = window.location.origin, t = _e();
647
- return (t == null ? void 0 : t.host) || n;
648
- }, Le = async (n) => {
649
- var x;
650
- const t = Oe(), e = n ?? {}, {
651
- pluginBaseUrl: i = t,
652
- pluginApiPath: s,
653
- overrides: o = {},
654
- pluginContext: a
655
- } = e, r = s ? `${i}${s}` : `${i}/api/kos/ui/plugins/contexts`;
656
- console.log(
657
- `initialize-plugins: Using Plugin Framework. Fetching plugins from ${r}`
658
- );
659
- const l = await (await fetch(r)).json(), u = typeof (a == null ? void 0 : a.context) == "string" ? [a.context] : (a == null ? void 0 : a.context) || [], f = (x = l.data) == null ? void 0 : x.filter((m) => u.length === 0 || u.includes(m.name)).flatMap(
660
- (m) => m.plugins.map((g) => ({ ...g, name: m.name })) ?? []
661
- ), h = a == null ? void 0 : a.group, d = f == null ? void 0 : f.reduce((m, g) => {
662
- const _ = (o == null ? void 0 : o[g.id]) ?? `${i}${g.path}`;
663
- if (g.descriptor) {
664
- const j = (g.descriptor.extensions || []).reduce((P, y) => {
665
- const k = y.groups || [];
666
- return (!h || k.includes(h)) && P.push(y), P;
667
- }, []), v = g.descriptor.contributes || {};
668
- let $ = !1;
669
- const L = Object.keys(v).reduce(
670
- (P, y) => {
671
- if (Array.isArray(v[y])) {
672
- const k = (v[y] || []).filter((B) => {
673
- const H = B.groups || [];
674
- return !h || H.includes(h);
675
- });
676
- $ = $ || k.length > 0, P[y] = k;
677
- } else
678
- P[y] = v[y], $ = Object.keys(v[y]).length > 0;
679
- return P;
680
- },
681
- {}
682
- ), q = !!g.descriptor.init && (j.length > 0 || $);
683
- m[g.id] = {
684
- section: g.name,
685
- basePath: `${_}remoteEntry.js`,
686
- extensions: j,
687
- contributes: L,
688
- remote: g.descriptor.id,
689
- init: q
690
- };
691
- } else
692
- console.error(
693
- `initialize-plugins: Plugin ${g.id} does not have a descriptor`
694
- );
695
- return m;
696
- }, {});
697
- window.KosPlugins = window.KosPlugins || {}, window.KosPlugins.__dynamicRemotes = d;
698
- const p = Object.keys(d).reduce((m, g) => {
699
- const _ = d[g].remote;
700
- return m[_] = d[g].basePath, m;
701
- }, {});
702
- return F.setRemoteDefinitions(p), p;
703
- };
704
- function qe(n, t, e = !1) {
705
- 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) => {
706
- const a = typeof s.rank == "number" ? s.rank : 1 / 0, r = typeof o.rank == "number" ? o.rank : 1 / 0;
707
- if (a === r) {
708
- const c = s.id ?? "", l = o.id ?? "";
709
- return c.localeCompare(l);
710
- }
711
- return a - r;
712
- })[0] ?? null;
713
- }
714
- const M = w.object({
715
- id: w.string().min(1, "ID is required").describe("Unique identifier for this extension"),
716
- title: w.string().min(1, "Title is required").describe("Display title shown in the interface"),
717
- namespace: w.string().min(1, "Namespace is required").describe("Namespace for organizing related extensions"),
718
- experienceId: w.string().min(1, "Experience ID is required").describe("Reference to the UI component experience for rendering")
719
- }), Te = M.extend({
720
- rank: w.number().int().min(0).optional().describe("Optional ranking for ordering (higher = preferred)")
721
- });
722
- function Be(n, t, e) {
723
- const i = n.safeParse(t);
724
- return i.success ? !0 : (i.error.errors.forEach((s) => {
725
- e.addError(`${s.path.join(".")}: ${s.message}`);
726
- }), !1);
727
- }
728
- function He(n, t, e) {
729
- t && !t.includes(".") && e.addWarning(
730
- `${n} '${t}' should typically include dot notation (e.g., 'category.item')`
731
- );
732
- }
733
- function De(n, t, e = 1e3) {
734
- n !== void 0 && n > e && t.addWarning(
735
- `Rank ${n} seems unusually high - consider using lower values for better ordering`
736
- );
737
- }
738
- function We(n, t = {}) {
739
- return (t.rankable ? Te : M).extend(n);
740
- }
741
- function Ge(n, t, e = 1e3) {
742
- typeof n == "object" && n !== null && "rank" in n && De(n.rank, t, e);
743
- }
744
- class T {
745
- /**
746
- * Get all extension points with their plugin information
747
- */
748
- static getExtensionPoints(t, e = {}) {
749
- const {
750
- includeLegacyExtensions: i = !0,
751
- includeEmptyExtensionPoints: s = !0
752
- } = e, a = b().getAllExtensionPoints(), r = [];
753
- return a.forEach((c) => {
754
- const l = Object.values((t == null ? void 0 : t[c.id]) || {});
755
- !s && l.length === 0 || r.push({
756
- id: c.id,
757
- displayName: c.config.displayName,
758
- description: c.config.description,
759
- source: "simplified",
760
- metadata: c.config.metadata,
761
- pluginCount: l.length,
762
- plugins: l
763
- });
764
- }), i && t && Object.entries(t).forEach(([c, l]) => {
765
- if (r.some((f) => f.id === c))
766
- return;
767
- const u = Object.values(l || {});
768
- !s && u.length === 0 || r.push({
769
- id: c,
770
- source: "legacy",
771
- pluginCount: u.length,
772
- plugins: u
773
- });
774
- }), r.sort((c, l) => c.id.localeCompare(l.id));
775
- }
776
- /**
777
- * Filter extension points based on search criteria
778
- */
779
- static filterExtensionPoints(t, e) {
780
- if (!e.trim())
781
- return t;
782
- const i = e.toLowerCase();
783
- return t.filter(
784
- (s) => {
785
- var o, a, r, c, l, u;
786
- 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)));
787
- }
788
- );
789
- }
790
- /**
791
- * Calculate health statistics for the plugin system
792
- */
793
- static calculateHealthStats(t) {
794
- const e = t.length, i = t.filter(
795
- (c) => c.pluginCount > 0
796
- ).length, s = t.reduce(
797
- (c, l) => c + l.pluginCount,
798
- 0
799
- ), o = t.filter(
800
- (c) => c.source === "simplified"
801
- ).length, a = t.filter(
802
- (c) => c.source === "legacy"
803
- ).length, r = t.filter(
804
- (c) => {
805
- var l;
806
- return (l = c.metadata) == null ? void 0 : l.deprecated;
807
- }
808
- ).length;
809
- return {
810
- totalExtensionPoints: e,
811
- extensionPointsWithPlugins: i,
812
- totalPlugins: s,
813
- simplifiedExtensionPoints: o,
814
- legacyExtensionPoints: a,
815
- deprecatedExtensionPoints: r
816
- };
817
- }
818
- /**
819
- * Analyze a specific plugin for health and capabilities
820
- */
821
- static analyzePlugin(t) {
822
- const e = !!t.component, i = typeof t.rank == "number", s = t.rank || 0, o = [];
823
- if (e ? o.push("UI Component") : o.push("Background Service"), i && o.push(`Rank: ${s}`), t.namespace) {
824
- const r = t.namespace;
825
- r.includes("kos") || r.includes("ddk") ? o.push("First-party") : o.push("Third-party");
826
- }
827
- t.modalMode && o.push(`Modal: ${t.modalMode}`);
828
- let a = "healthy";
829
- return t.remote || (a = "warning"), {
830
- hasComponent: e,
831
- hasRank: i,
832
- healthStatus: a,
833
- capabilities: o
834
- };
835
- }
836
- /**
837
- * Get extension point by ID with detailed information
838
- */
839
- static getExtensionPointById(t, e) {
840
- return t.find((i) => i.id === e);
841
- }
842
- /**
843
- * Validate if an extension point ID follows conventions
844
- */
845
- static validateExtensionPointId(t) {
846
- const e = [], i = [];
847
- t.includes(".") || (e.push(
848
- "Extension point ID should contain at least one dot (namespace.feature)"
849
- ), i.push('Use format like "ddk.myFeature" or "app.myFeature"'));
850
- const s = t.split(".");
851
- s.length < 2 && e.push(
852
- "Extension point ID should have at least 2 parts (namespace.feature)"
853
- );
854
- const o = s[0];
855
- return o && !["ddk", "cui", "app"].includes(o) && !o.endsWith("app") && i.push(
856
- "Consider using standard namespaces: ddk, cui, or [appname]app"
857
- ), s.some((r) => /[A-Z]/.test(r)) && (e.push("Extension point ID parts should be lowercase"), i.push(
858
- 'Use kebab-case or dot notation: "my.feature" not "my.myFeature"'
859
- )), {
860
- isValid: e.length === 0,
861
- issues: e,
862
- suggestions: i
863
- };
864
- }
865
- /**
866
- * Validate a plugin descriptor structure and content
867
- */
868
- static validatePluginDescriptor(t) {
869
- const e = [], i = [], s = [], o = [];
870
- if (t.id ? t.id.match(/^[a-z0-9-]+$/) || o.push(
871
- "Plugin ID convention: use lowercase letters, numbers, and hyphens (e.g., 'my-awesome-plugin')"
872
- ) : (s.push("id"), e.push("Plugin descriptor must have an 'id' field")), !t.contributes)
873
- i.push(
874
- "Plugin has no contributions - it won't extend any functionality"
875
- ), o.push("Add a 'contributes' section with plugin contributions");
876
- else {
877
- const a = Object.keys(t.contributes);
878
- a.length === 0 && i.push("Plugin contributes section is empty"), a.forEach((r) => {
879
- const c = t.contributes[r];
880
- if (!Array.isArray(c)) {
881
- e.push(`Contribution '${r}' must be an array`);
882
- return;
883
- }
884
- c.forEach((l, u) => {
885
- l.id || e.push(
886
- `Contribution ${r}[${u}] missing required 'id' field`
887
- ), r === "experiences" && l.component && !l.location && (e.push(
888
- `Experience '${l.id}' has component but no location`
889
- ), o.push(
890
- "Add 'location' field pointing to the component file"
891
- )), ["cui", "utilities", "settings", "setup"].includes(r) && (l.title || i.push(
892
- `${r} contribution '${l.id}' missing 'title' field`
893
- ), l.namespace || i.push(
894
- `${r} contribution '${l.id}' missing 'namespace' field`
895
- ), l.experienceId || e.push(
896
- `${r} contribution '${l.id}' missing required 'experienceId' field`
897
- ));
898
- });
899
- });
900
- }
901
- return t.init !== void 0 && typeof t.init != "boolean" && e.push("'init' field must be a boolean value"), {
902
- isValid: e.length === 0 && s.length === 0,
903
- errors: e,
904
- warnings: i,
905
- missingRequired: s,
906
- suggestions: o
907
- };
908
- }
909
- /**
910
- * Check compatibility between plugin contributions and available extension points
911
- */
912
- static checkPluginCompatibility(t, e) {
913
- const i = [], s = [], o = [], a = [];
914
- if (!t.contributes)
915
- return {
916
- isCompatible: !0,
917
- issues: ["Plugin has no contributions to check"],
918
- missingExtensionPoints: [],
919
- incompatibleTypes: [],
920
- suggestions: []
921
- };
922
- const r = b(), c = new Set(
923
- e.map((l) => l.id)
924
- );
925
- return Object.entries(t.contributes).forEach(
926
- ([l, u]) => {
927
- this.getExpectedExtensionPoints(l).forEach((p) => {
928
- c.has(p) || (s.push(p), i.push(
929
- `Extension point '${p}' not available for '${l}' contributions`
930
- ), a.push(
931
- `Ensure the extension point '${p}' is registered`
932
- ));
933
- });
934
- const d = r.getAllExtensionPoints().find(
935
- (p) => p.config.contributionKey === l
936
- );
937
- d && u.length > 0 && u.forEach((p, x) => {
938
- d.config.isRankable && typeof p.rank != "number" && (i.push(
939
- `${l}[${x}]: Extension point '${d.id}' expects 'rank' property`
940
- ), a.push(
941
- "Add 'rank' property with numeric value for ordering"
942
- )), d.config.hasView && !p.experienceId && (i.push(
943
- `${l}[${x}]: Extension point '${d.id}' expects 'experienceId' for view-based contributions`
944
- ), a.push(
945
- "Add 'experienceId' property linking to an experience definition"
946
- ));
947
- });
948
- }
949
- ), {
950
- isCompatible: i.length === 0,
951
- issues: i,
952
- missingExtensionPoints: s,
953
- incompatibleTypes: o,
954
- suggestions: a
955
- };
956
- }
957
- /**
958
- * Map contribution keys to their expected extension point IDs
959
- */
960
- static getExpectedExtensionPoints(t) {
961
- return {
962
- cui: ["ddk.cui", "ddk.cui.view", "ddk.cui.settings.config"],
963
- utilities: ["ddk.utility", "ddk.utility.view", "ddk.utilities"],
964
- setup: ["ddk.setup", "ddk.setup.view"],
965
- settings: ["ddk.settings", "ddk.settings.view"],
966
- troubleActions: ["ddk.troubleAction", "ddk.troubleAction.view"],
967
- navViews: ["ddk.nav", "ddk.nav.view"],
968
- controlPour: ["ddk.controlPour", "ddk.controlPour.view"],
969
- experiences: [],
970
- // Experiences don't directly map to extension points
971
- views: []
972
- // Views are mapped by their extension point ID keys
973
- }[t] || [];
974
- }
975
- /**
976
- * Get comprehensive plugin analysis including validation and compatibility
977
- */
978
- static analyzePluginDescriptor(t, e) {
979
- const i = this.validatePluginDescriptor(t), s = this.checkPluginCompatibility(
980
- t,
981
- e
982
- ), o = [];
983
- return i.warnings.length > 0 && o.push(
984
- "Address validation warnings to improve plugin quality"
985
- ), s.isCompatible || o.push(
986
- "Resolve compatibility issues before deploying plugin"
987
- ), t.contributes && Object.keys(t.contributes).length === 1 && o.push(
988
- "Consider adding more contribution types to increase plugin value"
989
- ), {
990
- validation: i,
991
- compatibility: s,
992
- recommendations: o
993
- };
994
- }
995
- }
996
- class ze {
997
- /**
998
- * Generate complete documentation for all extension points
999
- */
1000
- static generateFullDocumentation(t, e = {}) {
1001
- const {
1002
- includeUsageExamples: i = !0,
1003
- includeTypeDefinitions: s = !0,
1004
- includeLegacyExtensions: o = !0,
1005
- includePluginHealth: a = !0
1006
- } = e, r = T.getExtensionPoints(
1007
- t,
1008
- {
1009
- includeLegacyExtensions: o,
1010
- includeEmptyExtensionPoints: !0
1011
- }
1012
- ), c = T.calculateHealthStats(r);
1013
- let l = this.generateHeader(c);
1014
- return l += this.generateTableOfContents(r), l += this.generateOverviewSection(r, c), r.forEach((u) => {
1015
- l += this.generateExtensionPointSection(u, {
1016
- includeUsageExamples: i,
1017
- includePluginHealth: a
1018
- });
1019
- }), s && (l += this.generateTypeDefinitionsSection(r)), l += this.generateContributionGuide(), l += this.generateTroubleshootingSection(), {
1020
- content: l,
1021
- metadata: {
1022
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1023
- totalExtensionPoints: c.totalExtensionPoints,
1024
- totalPlugins: c.totalPlugins,
1025
- simplifiedExtensionPoints: c.simplifiedExtensionPoints,
1026
- legacyExtensionPoints: c.legacyExtensionPoints
1027
- }
1028
- };
1029
- }
1030
- /**
1031
- * Generate documentation header with metadata
1032
- */
1033
- static generateHeader(t) {
1034
- return `# KOS Plugin Extension Points Reference
1035
-
1036
- **Generated**: ${(/* @__PURE__ */ new Date()).toLocaleString()}
1037
-
1038
- ## System Overview
1039
-
1040
- - **Total Extension Points**: ${t.totalExtensionPoints}
1041
- - **Extension Points with Plugins**: ${t.extensionPointsWithPlugins}
1042
- - **Total Active Plugins**: ${t.totalPlugins}
1043
- - **Simplified Extension Points**: ${t.simplifiedExtensionPoints}
1044
- - **Legacy Extension Points**: ${t.legacyExtensionPoints}
1045
-
1046
- ---
1047
-
1048
- `;
1049
- }
1050
- /**
1051
- * Generate table of contents
1052
- */
1053
- static generateTableOfContents(t) {
1054
- let e = `## Table of Contents
1055
-
1056
- `;
1057
- return e += `- [Overview](#overview)
1058
- `, e += `- [Extension Points](#extension-points)
1059
- `, t.forEach((i) => {
1060
- const s = i.id.toLowerCase().replace(/\./g, "");
1061
- e += ` - [${i.id}](#${s}) (${i.pluginCount} plugins)
1062
- `;
1063
- }), e += `- [Type Definitions](#type-definitions)
1064
- `, e += `- [Contribution Guide](#contribution-guide)
1065
- `, e += `- [Troubleshooting](#troubleshooting)
1066
-
1067
- `, e;
1068
- }
1069
- /**
1070
- * Generate overview section with health statistics
1071
- */
1072
- static generateOverviewSection(t, e) {
1073
- let i = `## Overview
1074
-
1075
- `;
1076
- 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.
1077
-
1078
- `, i += `### Extension Point Types
1079
-
1080
- `, i += "- ** Simplified Extension Points**: Use the new simplified API from `defineExtensionPoint`\n", i += `- ** Legacy Extension Points**: Use the traditional reducer-based system
1081
-
1082
- `, e.deprecatedExtensionPoints > 0 && (i += `### ⚠️ Deprecated Extension Points
1083
-
1084
- `, i += `${e.deprecatedExtensionPoints} extension points are marked as deprecated. `, i += `Consider migrating to newer alternatives.
1085
-
1086
- `), i + `---
1087
-
1088
- `;
1089
- }
1090
- /**
1091
- * Generate documentation section for a single extension point
1092
- */
1093
- static generateExtensionPointSection(t, e) {
1094
- var a;
1095
- const { includeUsageExamples: i = !0, includePluginHealth: s = !0 } = e;
1096
- let o = `## ${t.id}
1097
-
1098
- `;
1099
- if (t.displayName && (o += `**Display Name**: ${t.displayName}
1100
-
1101
- `), t.description && (o += `**Description**: ${t.description}
1102
-
1103
- `), o += `**Source**: ${t.source}
1104
- `, o += `**Active Plugins**: ${t.pluginCount}
1105
-
1106
- `, t.metadata) {
1107
- o += `### Metadata
1108
-
1109
- `;
1110
- const r = t.metadata;
1111
- r.category && (o += `- **Category**: ${r.category}
1112
- `), r.owner && (o += `- **Owner**: ${r.owner}
1113
- `), r.since && (o += `- **Since**: ${r.since}
1114
- `), (a = r.tags) != null && a.length && (o += `- **Tags**: ${r.tags.join(", ")}
1115
- `), r.deprecated && (o += `- **⚠️ Status**: Deprecated
1116
- `), o += `
1117
- `;
1118
- }
1119
- return i && (o += this.generateUsageExamples(t)), t.plugins.length > 0 ? o += this.generatePluginList(
1120
- t.plugins,
1121
- s
1122
- ) : o += `### Plugins
1123
-
1124
- No plugins currently registered for this extension point.
1125
-
1126
- `, o += this.generateSchemaFieldsSection(t), o += this.generateContributionStructure(t), o + `---
1127
-
1128
- `;
1129
- }
1130
- /**
1131
- * Generate usage examples for an extension point
1132
- */
1133
- static generateUsageExamples(t) {
1134
- let e = `### Usage Examples
1135
-
1136
- `;
1137
- return t.source === "simplified" && (e += `#### Using Simplified API
1138
-
1139
- `, e += "```typescript\n", e += `// Import the extension point
1140
- `, e += `import { ${this.getExtensionPointImportName(
1141
- t.id
1142
- )} } from './extension-points';
1143
-
1144
- `, e += `// Use extension component hook
1145
- `, e += `import { useExtensionComponent } from '@kosdev-code/kos-ui-plugin';
1146
-
1147
- `, e += `const Component = useExtensionComponent(${this.getExtensionPointImportName(
1148
- t.id
1149
- )});
1150
-
1151
- `, e += `if (Component) {
1152
- `, e += ` return (
1153
- `, e += ` <Component
1154
- `, e += ` customProp="value"
1155
- `, e += ` onComplete={handleComplete}
1156
- `, e += ` />
1157
- `, e += ` );
1158
- `, e += `}
1159
-
1160
- `, e += `// Or use with dynamic component
1161
- `, e += `const [Component] = useDynamicComponent({
1162
- `, e += ` extension: ${this.getExtensionPointImportName(
1163
- t.id
1164
- )}.id
1165
- `, e += `});
1166
- `, e += "```\n\n", e += `#### Using Typed Hooks
1167
-
1168
- `, e += "```typescript\n", e += `// Get all extensions with type safety
1169
- `, e += `const extensions = useExtensions(${this.getExtensionPointImportName(
1170
- t.id
1171
- )});
1172
-
1173
- `, e += `// Get best extension
1174
- `, e += `const bestExtension = useBest(${this.getExtensionPointImportName(
1175
- t.id
1176
- )});
1177
-
1178
- `, e += `// Check availability
1179
- `, e += `const hasExtensions = useHasExtensions(${this.getExtensionPointImportName(
1180
- t.id
1181
- )});
1182
- `, e += "```\n\n"), e += `#### Using DynamicComponent
1183
-
1184
- `, e += "```typescript\n", e += `import { DynamicComponent } from '@kosdev-code/kos-ui-plugin';
1185
- `, e += `import { ${this.getExtensionPointImportName(
1186
- t.id
1187
- )} } from './extension-points';
1188
-
1189
- `, e += `<DynamicComponent
1190
- `, e += ` extension={${this.getExtensionPointImportName(
1191
- t.id
1192
- )}.id}
1193
- `, e += ` props={{ customData: "value" }}
1194
- `, e += ` fallback={<div>Loading...</div>}
1195
- `, e += `/>
1196
- `, e += "```\n\n", e += `#### Using Context
1197
-
1198
- `, e += "```typescript\n", e += `import { useKosPluginsContext } from '@kosdev-code/kos-ui-plugin';
1199
- `, e += `import { ${this.getExtensionPointImportName(
1200
- t.id
1201
- )} } from './extension-points';
1202
-
1203
- `, e += `const { getExtensions } = useKosPluginsContext();
1204
- `, e += `const extensions = getExtensions(${this.getExtensionPointImportName(
1205
- t.id
1206
- )}.id);
1207
- `, e += "```\n\n", e;
1208
- }
1209
- /**
1210
- * Generate plugin list with health information
1211
- */
1212
- static generatePluginList(t, e) {
1213
- let i = `### Active Plugins
1214
-
1215
- `;
1216
- return t.forEach((s) => {
1217
- if (i += `#### ${s.id}
1218
-
1219
- `, s.remote && (i += `- **Remote**: ${s.remote}
1220
- `), s.sectionId && (i += `- **Section**: ${s.sectionId}
1221
- `), s.rank !== void 0 && (i += `- **Rank**: ${s.rank}
1222
- `), e) {
1223
- const o = T.analyzePlugin(s);
1224
- i += `- **Health**: ${this.getHealthEmoji(o.healthStatus)} ${o.healthStatus}
1225
- `, o.capabilities.length > 0 && (i += `- **Capabilities**: ${o.capabilities.join(", ")}
1226
- `);
1227
- }
1228
- i += `
1229
- `;
1230
- }), i;
1231
- }
1232
- /**
1233
- * Generate schema fields documentation
1234
- */
1235
- static generateSchemaFieldsSection(t) {
1236
- if (t.source !== "simplified")
1237
- return "";
1238
- const i = b().getExtensionPoint(t.id);
1239
- if (!(i != null && i.getSchemaFieldInfo))
1240
- return "";
1241
- const s = i.getSchemaFieldInfo();
1242
- if (s.length === 0)
1243
- return "";
1244
- let o = `### Schema Fields
1245
-
1246
- `;
1247
- return o += `The following fields are defined in the schema for this extension point:
1248
-
1249
- `, o += `| Field | Type | Required | Description |
1250
- `, o += `|-------|------|----------|-------------|
1251
- `, s.forEach((a) => {
1252
- const r = a.name, c = a.type || "unknown", l = a.required ? "✅" : "⭕", u = a.description || "-";
1253
- o += `| \`${r}\` | ${c} | ${l} | ${u} |
1254
- `;
1255
- }), o += `
1256
- `, o;
1257
- }
1258
- /**
1259
- * Generate contribution structure documentation
1260
- */
1261
- static generateContributionStructure(t) {
1262
- let e = `### Contribution Structure
1263
-
1264
- `;
1265
- e += `To contribute to this extension point, add the following to your plugin descriptor:
1266
-
1267
- `, e += "```json\n", e += `{
1268
- `, e += ` "id": "your-plugin-id",
1269
- `, e += ` "contributes": {
1270
- `;
1271
- const i = this.inferContributionKey(t);
1272
- e += ` "${i}": [
1273
- `, e += ` {
1274
- `;
1275
- const s = this.getSchemaFieldsForContribution(t);
1276
- if (s.length > 0) {
1277
- const a = [];
1278
- s.forEach((r) => {
1279
- let c;
1280
- 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}`);
1281
- }), e += a.join(`,
1282
- `);
1283
- } else {
1284
- e += ` "id": "your-contribution-id",
1285
- `, e += ` "title": "Your Contribution Title",
1286
- `, e += ' "namespace": "your-namespace"', this.isViewBasedExtensionPoint(t) && (e += `,
1287
- "experienceId": "your-experience-id"`), this.isRankableExtensionPoint(t) && (e += `,
1288
- "rank": 10`);
1289
- const a = this.getSpecificFields(t);
1290
- a.length > 0 && (e += `,
1291
- ${a.join(`,
1292
- `)}`);
1293
- }
1294
- return e += `
1295
- }
1296
- `, e += " ]", (s.some((a) => a.name === "experienceId") || this.isViewBasedExtensionPoint(t)) && (e += `,
1297
- "experiences": {
1298
- `, e += ` "your-experience-id": {
1299
- `, e += ` "id": "your-experience-id",
1300
- `, e += ` "component": "YourComponent",
1301
- `, e += ` "location": "./src/components/YourComponent.tsx"
1302
- `, e += ` }
1303
- `, e += " }"), e += `
1304
- }
1305
- `, e += `}
1306
- `, e += "```\n\n", e;
1307
- }
1308
- /**
1309
- * Generate TypeScript definitions section
1310
- */
1311
- static generateTypeDefinitionsSection(t) {
1312
- let e = `## Type Definitions
1313
-
1314
- `;
1315
- return e += `### Extension Point Types
1316
-
1317
- `, e += "```typescript\n", t.forEach((i) => {
1318
- i.source === "simplified" && (e += `// ${i.id}
1319
- `, e += `interface ${this.getExtensionPointTypeName(i.id)} {
1320
- `, e += ` id: "${i.id}";
1321
- `, e += ` displayName?: "${i.displayName || ""}";
1322
- `, e += ` description?: "${i.description || ""}";
1323
- `, e += `}
1324
-
1325
- `);
1326
- }), e += "```\n\n", e += `### Plugin Contribution Types
1327
-
1328
- `, e += "```typescript\n", e += `interface BaseContribution {
1329
- `, e += ` id: string;
1330
- `, e += ` title: string;
1331
- `, e += ` namespace: string;
1332
- `, e += `}
1333
-
1334
- `, e += `interface ViewBasedContribution extends BaseContribution {
1335
- `, e += ` experienceId: string;
1336
- `, e += `}
1337
-
1338
- `, e += `interface RankableContribution extends BaseContribution {
1339
- `, e += ` rank: number;
1340
- `, e += `}
1341
- `, e += "```\n\n", e;
1342
- }
1343
- /**
1344
- * Generate contribution guide
1345
- */
1346
- static generateContributionGuide() {
1347
- return `## Contribution Guide
1348
-
1349
- ### Creating a Plugin
1350
-
1351
- 1. **Create Plugin Project**
1352
- \`\`\`bash
1353
- kosui plugin-project --name my-plugin
1354
- \`\`\`
1355
-
1356
- 2. **Add Components**
1357
- \`\`\`bash
1358
- kosui component --name MyComponent --pluginType utility --project my-plugin
1359
- \`\`\`
1360
-
1361
- 3. **Update Plugin Descriptor**
1362
- Add contributions to your \`kosdev-plugin.json\` file following the structure examples above.
1363
-
1364
- 4. **Test Integration**
1365
- Use the Plugin Explorer (Ctrl+Shift+P) to validate your plugin registration.
1366
-
1367
- ### Best Practices
1368
-
1369
- - **Use descriptive IDs**: Plugin and contribution IDs should be clear and unique
1370
- - **Follow naming conventions**: Use kebab-case for IDs, PascalCase for components
1371
- - **Provide meaningful titles**: Titles are shown to users in the interface
1372
- - **Set appropriate ranks**: Higher numbers = higher priority for rankable contributions
1373
- - **Include proper metadata**: Namespace helps organize plugins by owner
1374
-
1375
- ### Validation
1376
-
1377
- Use the Plugin Discovery Service to validate your plugin descriptor:
1378
-
1379
- \`\`\`typescript
1380
- import { PluginDiscoveryService } from '@kosdev-code/kos-ui-plugin';
1381
-
1382
- const validation = PluginDiscoveryService.validatePluginDescriptor(yourDescriptor);
1383
- console.log(validation.errors); // Check for errors
1384
- console.log(validation.warnings); // Check for warnings
1385
- \`\`\`
1386
-
1387
- `;
1388
- }
1389
- /**
1390
- * Generate troubleshooting section
1391
- */
1392
- static generateTroubleshootingSection() {
1393
- return `## Troubleshooting
1394
-
1395
- ### Common Issues
1396
-
1397
- **Plugin not appearing in extension point**
1398
- - Check plugin descriptor syntax
1399
- - Verify contribution key matches extension point requirements
1400
- - Ensure experienceId references exist in experiences section
1401
-
1402
- **Component fails to load**
1403
- - Verify component path in experience location
1404
- - Check module federation configuration
1405
- - Use Plugin Explorer to see detailed error messages
1406
-
1407
- **Type errors with simplified extension points**
1408
- - Ensure extension point is properly imported
1409
- - Check that component props match expected interface
1410
- - Verify extension point is registered before use
1411
-
1412
- ### Debugging Tools
1413
-
1414
- **Plugin Explorer**
1415
- - Press Ctrl+Shift+P in development mode
1416
- - View all extension points and their plugins
1417
- - See plugin health status and capabilities
1418
- - Test component rendering with error boundaries
1419
-
1420
- **Validation Service**
1421
- - Use \`PluginDiscoveryService.validatePluginDescriptor()\`
1422
- - Check \`PluginDiscoveryService.checkPluginCompatibility()\`
1423
- - Run \`PluginDiscoveryService.analyzePluginDescriptor()\` for full analysis
1424
-
1425
- **Browser DevTools**
1426
- - Check \`window.KosPlugins.extensions\` for runtime state
1427
- - Look for module federation errors in Network tab
1428
- - Use React DevTools to inspect component loading
1429
-
1430
- ---
1431
-
1432
- *Generated by KOS Plugin Documentation Generator*
1433
- `;
1434
- }
1435
- // Helper methods
1436
- static getExtensionPointImportName(t) {
1437
- var a;
1438
- const i = b().getExtensionPoint(t);
1439
- if ((a = i == null ? void 0 : i.config.metadata) != null && a.exportName)
1440
- return i.config.metadata.exportName;
1441
- const s = t.split(".");
1442
- return (s.length > 1 ? s.slice(1) : s).map(
1443
- (r) => (
1444
- // Handle hyphenated parts (e.g., "pump-detail" -> "PumpDetail")
1445
- r.split("-").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join("")
1446
- )
1447
- ).join("") + "Extension";
1448
- }
1449
- static getExtensionPointTypeName(t) {
1450
- return this.getExtensionPointImportName(t) + "Type";
1451
- }
1452
- static getHealthEmoji(t) {
1453
- switch (t) {
1454
- case "healthy":
1455
- return "✅";
1456
- case "warning":
1457
- return "⚠️";
1458
- case "error":
1459
- return "❌";
1460
- default:
1461
- return "❓";
1462
- }
1463
- }
1464
- static inferContributionKey(t) {
1465
- if (t.source === "simplified") {
1466
- const a = b().getExtensionPoint(t.id);
1467
- if (a != null && a.config.contributionKey)
1468
- return a.config.contributionKey;
1469
- }
1470
- const e = t.id.split("."), i = e[e.length - 1];
1471
- return {
1472
- cui: "cui",
1473
- utility: "utilities",
1474
- utilities: "utilities",
1475
- setup: "setupStep",
1476
- settings: "settings",
1477
- nav: "navViews",
1478
- troubleAction: "troubleActions",
1479
- controlPour: "controlPour"
1480
- }[i] || i + "s";
1481
- }
1482
- static isViewBasedExtensionPoint(t) {
1483
- if (t.source === "simplified") {
1484
- const i = b().getExtensionPoint(t.id);
1485
- return (i == null ? void 0 : i.config.hasView) || !1;
1486
- }
1487
- return t.plugins.some(
1488
- (e) => e.experienceId
1489
- );
1490
- }
1491
- static isRankableExtensionPoint(t) {
1492
- if (t.source === "simplified") {
1493
- const i = b().getExtensionPoint(t.id);
1494
- return (i == null ? void 0 : i.config.isRankable) || !1;
1495
- }
1496
- return t.plugins.some(
1497
- (e) => typeof e.rank == "number"
1498
- );
1499
- }
1500
- /**
1501
- * Get schema fields for contribution structure generation
1502
- */
1503
- static getSchemaFieldsForContribution(t) {
1504
- if (t.source !== "simplified")
1505
- return [];
1506
- const i = b().getExtensionPoint(t.id);
1507
- return i != null && i.getSchemaFieldInfo ? i.getSchemaFieldInfo() : [];
1508
- }
1509
- static getSpecificFields(t) {
1510
- const e = [];
1511
- switch (this.inferContributionKey(t)) {
1512
- case "utilities":
1513
- e.push('"utilDescriptor": "your-util-descriptor"');
1514
- break;
1515
- case "setupStep":
1516
- e.push('"setupDescriptor": "your-setup-descriptor"');
1517
- break;
1518
- case "settings":
1519
- e.push('"settingsGroup": "your-settings-group"');
1520
- break;
1521
- case "navViews":
1522
- e.push('"navDescriptor": "your-nav-descriptor"');
1523
- break;
1524
- case "troubleActions":
1525
- e.push('"troubleType": "your-trouble-type"');
1526
- break;
1527
- case "cui":
1528
- e.push('"cuiDescriptor": "your-cui-descriptor"');
1529
- break;
1530
- }
1531
- return e;
1532
- }
1533
- }
1534
- export {
1535
- M as B,
1536
- ze as D,
1537
- T as P,
1538
- Te as R,
1539
- Le as a,
1540
- Ie as b,
1541
- b as c,
1542
- Re as d,
1543
- Se as e,
1544
- Me as f,
1545
- Ke as g,
1546
- ae as h,
1547
- Ne as i,
1548
- Ve as j,
1549
- A as k,
1550
- Fe as l,
1551
- F as m,
1552
- re as n,
1553
- He as o,
1554
- De as p,
1555
- We as q,
1556
- qe as r,
1557
- Ge as s,
1558
- Be as v
1559
- };
1560
- //# sourceMappingURL=documentation-generator-auruIa_o.js.map