@kosdev-code/kos-ui-plugin 2.1.7 → 2.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,266 @@
1
+ "use strict";var ee=Object.defineProperty;var te=(n,t,e)=>t in n?ee(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var R=(n,t,e)=>(te(n,typeof t!="symbol"?t+"":t,e),e);const v=require("zod");function ne(n,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var $={},E={};Object.defineProperty(E,"__esModule",{value:!0});E.loadRemoteModule=E.setRemoteDefinitions=E.setRemoteUrlResolver=void 0;let I,D;const T=new Map,U=new Map;let V=!1;function ie(n){D=n}E.setRemoteUrlResolver=ie;function se(n){I=n}E.setRemoteDefinitions=se;async function oe(n,t){const e=`${n}:${t}`;if(T.has(e))return T.get(e);const o=(await(U.has(n)?U.get(n):await ae(n)).get(t))();return T.set(e,o),o}E.loadRemoteModule=oe;const re=(n,t)=>new Promise((e,i)=>{const s=document.createElement("script");s.src=n,s.type="text/javascript",s.async=!0,s.onload=()=>{e({get:a=>window[t].get(a),init:a=>{try{window[t].init(a)}catch(r){console.error(`Failed to initialize remote ${t}`,r),i(r)}}})},s.onerror=()=>i(new Error(`Remote ${t} not found`)),document.head.appendChild(s)});async function ae(n){if(!D&&!I)throw new Error("Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.");V||(V=!0,await __webpack_init_sharing__("default"));const t=I?I[n]:await D(n);let e=t;!t.endsWith(".mjs")&&!t.endsWith(".js")&&(e=`${t}${t.endsWith("/")?"":"/"}remoteEntry.js`);const i=await re(e,n);return await i.init(__webpack_share_scopes__.default),U.set(n,i),i}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.setRemoteUrlResolver=n.setRemoteDefinitions=n.loadRemoteModule=void 0;var t=E;Object.defineProperty(n,"loadRemoteModule",{enumerable:!0,get:function(){return t.loadRemoteModule}}),Object.defineProperty(n,"setRemoteDefinitions",{enumerable:!0,get:function(){return t.setRemoteDefinitions}}),Object.defineProperty(n,"setRemoteUrlResolver",{enumerable:!0,get:function(){return t.setRemoteUrlResolver}})})($);const ce=ne({__proto__:null},[$]);function le(n){var t;try{if("shape"in n){const e=n,i=[];for(const[s,o]of Object.entries(e.shape)){const a=o,r={name:s,required:!a.isOptional()};if(a._def&&a._def.description&&(r.description=a._def.description),a._def){let c=a._def.typeName||"unknown";c==="ZodOptional"&&a._def.innerType&&(c=((t=a._def.innerType._def)==null?void 0:t.typeName)||"unknown"),r.type=c.replace("Zod","").toLowerCase()}i.push(r)}return i}return[]}catch(e){return console.warn("Failed to extract schema field info:",e),[]}}class ue{constructor(){R(this,"issues",[])}addError(t){this.issues.push({type:"error",message:t})}addWarning(t){this.issues.push({type:"warning",message:t})}addInfo(t){this.issues.push({type:"info",message:t})}hasErrors(){return this.issues.some(t=>t.type==="error")}hasIssues(){return this.issues.length>0}getIssues(){return[...this.issues]}}class de{constructor(){R(this,"cache",new Map)}set(t,e){this.cache.set(t,e)}get(t){return this.cache.get(t)||[]}clear(){this.cache.clear()}}const S=new de;function pe(n){return S.get(n)}const M=[];function fe(n){M.push(n)}function me(n,t,e){return M.reduce((i,s)=>s(i,t,e),n)}class ge{constructor(){R(this,"extensionPoints",new Map)}define(t){if(this.extensionPoints.has(t.id))return console.warn(`Extension point ${t.id} is already defined`),this.extensionPoints.get(t.id);const e={config:t,id:t.id,isRegistered:!1,getExtensions:i=>i[t.id]||{},register:()=>{if(e.isRegistered){console.warn(`Extension point ${t.id} is already registered`);return}const i=this.createReducer(t);fe(i),e.isRegistered=!0}};return t.schema&&(e.getSchemaFieldInfo=()=>le(t.schema)),this.extensionPoints.set(t.id,e),e}createReducer(t){return(e,i,s)=>{const o=i[t.contributionKey];return!o||typeof o!="object"||Object.entries(o).forEach(([a,r])=>{var f,h;if(!r)return;const c={remote:r.remote||"",sectionId:r.sectionId||a,experiences:s,contributions:i};if(t.validate){const d=new ue;if(t.validate(r,d)==="skip"){S.set(a,[{type:"warning",message:"Plugin marked to skip processing"}]);return}if(d.hasIssues()){const x=d.getIssues().map(m=>({...m,message:`Extension point validation: ${m.message}`}));if(S.set(a,x),d.hasErrors()){console.error(`Validation failed for ${t.id} contribution "${a}":`,x.filter(m=>m.type==="error").map(m=>m.message).join(", "));return}}else S.set(a,[])}const l=t.transform?t.transform(r,c):r;e[t.id]||(e[t.id]={});const u={id:a,type:t.contributionKey,data:l,remote:c.remote,sectionId:c.sectionId};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)){const d=r.experienceId,p=s==null?void 0:s[d];p&&(e[t.relatedPoints.view]||(e[t.relatedPoints.view]={}),e[t.relatedPoints.view][a]={id:a,type:`${t.contributionKey}.view`,data:p,remote:c.remote,sectionId:c.sectionId})}(h=t.relatedPoints)!=null&&h.definition&&(e[t.relatedPoints.definition]||(e[t.relatedPoints.definition]={}),e[t.relatedPoints.definition][a]={id:a,type:`${t.contributionKey}.definition`,data:l,remote:c.remote,sectionId:c.sectionId})}),e}}getAllExtensionPoints(){return Array.from(this.extensionPoints.values()).filter(t=>t.isRegistered)}getAllDefinedExtensionPoints(){return Array.from(this.extensionPoints.values())}getExtensionPoint(t){return this.extensionPoints.get(t)}hasExtensionPoint(t){return this.extensionPoints.has(t)}}const A=new ge;function y(){return A}function L(n={}){const{experienceIdProperty:t="experienceId",flattenComponentProperties:e=!0,customTransform:i}=n;return(s,o)=>{var l;const a=s[t],r=a?((l=o.experiences)==null?void 0:l[a])||{}:{};let c={...s,view:r};return e&&r&&(r.component&&(c.component=r.component),r.location&&(c.location=r.location)),i&&(c=i(s,r,o)||c),c}}function q(n){return A.define(n)}const he={$timestamp:()=>Date.now(),$date:()=>new Date().toISOString(),$packageVersion:()=>process.env.npm_package_version||"0.0.0",$env:()=>process.env.NODE_ENV||"development"};function ye(n){const t={id:n.id,displayName:n.displayName,description:n.description,contributionKey:n.contributionKey,hasView:n.hasView,isRankable:n.isRankable,relatedPoints:n.relatedPoints,metadata:n.metadata?{...n.metadata,exportName:n.metadata.exportName||be(n.id)}:void 0};return n.schema&&(t.schema=xe(n.schema,{hasView:n.hasView,isRankable:n.isRankable})),n.validation&&(t.validate=Pe(n.validation)),n.transform?t.transform=Se(n.transform):n.hasView&&(t.transform=L()),t}function be(n){return n.split(".").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")+"Extension"}function xe(n,t){try{const{z:e}=require("zod");if(n.properties){const i={};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());for(const[o,a]of Object.entries(n.properties))i[o]=Ee(a,e);let s=e.object(i);return n.additionalProperties||(s=s.strict()),s}return e.any()}catch(e){console.warn("Zod not available for JSON schema conversion:",e);return}}function Ee(n,t){let e;switch(n.type){case"string":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));break;case"number":e=t.number(),n.minimum!==void 0&&(e=e.min(n.minimum)),n.maximum!==void 0&&(e=e.max(n.maximum));break;case"boolean":e=t.boolean();break;case"array":e=t.array(t.any());break;case"object":e=t.object({});break;default:e=t.any()}return n.description&&(e=e.describe(n.description)),n.default!==void 0&&(e=e.default(n.default)),e}function Pe(n){return n.module?Ie(n.module):(t,e)=>{if(!n.rules)return;const i=t;for(const s of n.rules)ve(s,i,e)}}function ve(n,t,e){switch(n.type){case"required":we(n,t,e);break;case"range":$e(n,t,e);break;case"pattern":ke(n,t,e);break;case"dependency":Ce(n,t,e);break;case"custom":Re(n,t,e);break}}function we(n,t,e){n.field&&!t[n.field]&&e.addError(n.message||`Field '${n.field}' is required`)}function $e(n,t,e){if(n.field&&typeof t[n.field]=="number"){const i=t[n.field];n.min!==void 0&&i<n.min&&e.addError(n.message||`Field '${n.field}' must be at least ${n.min}`),n.max!==void 0&&i>n.max&&e.addError(n.message||`Field '${n.field}' must be at most ${n.max}`)}}function ke(n,t,e){n.field&&n.pattern&&typeof t[n.field]=="string"&&(new RegExp(n.pattern).test(t[n.field])||e.addError(n.message||`Field '${n.field}' does not match pattern ${n.pattern}`))}function Ce(n,t,e){if(n.field&&n.dependsOn&&n.expression)try{_(n.expression,t)||e.addError(n.message||`Field '${n.field}' dependency validation failed`)}catch(i){e.addWarning(`Failed to evaluate dependency expression: ${i}`)}}function Re(n,t,e){if(n.expression)try{_(n.expression,t)||e.addError(n.message||"Custom validation failed")}catch(i){e.addWarning(`Failed to evaluate custom expression: ${i}`)}}function Ie(n){return(t,e)=>{console.warn(`External validation module not implemented: ${n}`),e.addWarning(`External validation module not yet supported: ${n}`)}}function Se(n){return n.module?Fe(n.module):(t,e)=>{const i={...t};if(n.addFields)for(const[s,o]of Object.entries(n.addFields))i[s]=_e(o);if(n.removeFields)for(const s of n.removeFields)delete i[s];if(n.renameFields)for(const[s,o]of Object.entries(n.renameFields))s in i&&(i[o]=i[s],delete i[s]);if(n.normalizeFields)for(const{field:s,operation:o}of n.normalizeFields)s in i&&typeof i[s]=="string"&&(i[s]=Oe(i[s],o));return i}}function Fe(n){return(t,e)=>(console.warn(`External transform module not implemented: ${n}`),t)}function _e(n){if(typeof n=="string"&&n.startsWith("$")){const t=he[n];if(t)return t()}return n}function Oe(n,t){switch(t){case"trim":return n.trim();case"lowercase":return n.toLowerCase();case"uppercase":return n.toUpperCase();case"camelCase":return Te(n);case"kebabCase":return De(n);default:return n}}function Te(n){return n.replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^./,t=>t.toLowerCase())}function De(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function _(n,t){try{let e=n;for(const[i,s]of Object.entries(t)){const o=typeof s=="string"?`"${s}"`:String(s);e=e.replace(new RegExp(`\\b${i}\\b`,"g"),o)}if(e.includes("!==")){const[i,s]=e.split("!==").map(o=>o.trim());return i!==s}if(e.includes("===")){const[i,s]=e.split("===").map(o=>o.trim());return i===s}return e.includes("||")?e.split("||").map(s=>s.trim()).some(s=>_(s,t)):e.includes("&&")?e.split("&&").map(s=>s.trim()).every(s=>_(s,t)):!1}catch(e){return console.error("Expression evaluation failed:",e),!1}}const B=n=>(t,e)=>{var c;const i=n[e].remote,s=e,o=((c=n[e].contributes)==null?void 0:c.experiences)??{};return Object.keys(o).forEach(l=>{const u=o[l];t.experiences[l]={...u,remote:i,sectionId:s}}),y().getAllExtensionPoints().forEach(l=>{var h;const{contributionKey:u}=l.config,f=(h=n[e].contributes)==null?void 0:h[u];f&&(t[u]||(t[u]={}),Array.isArray(f)?f.forEach(d=>{d&&d.id&&(t[u][d.id]={...d,remote:i,sectionId:s})}):typeof f=="object"&&Object.entries(f).forEach(([d,p])=>{t[u][d]={...p,id:d,remote:i,sectionId:s}}))}),t};async function z(n){const t=n??window.KosPlugins.__dynamicRemotes;if(window.KosPlugins.extensions){const o=window.KosPlugins.extensions;return{extensionPoints:o,getExtensions:a=>o[a]||[],remotes:t,extensions:window.KosPlugins.__extensions}}const e=window.KosPlugins.__extensions??await W(t),i={};if(e)for(const o of Object.keys(e))i[o]=Object.values(e[o]||{});return window.KosPlugins.extensions=i,{extensionPoints:i,getExtensions:o=>i[o]||[],remotes:t,extensions:e}}const K={controlPourDefinitions:{},experiences:{}};function H(n){return n?Object.keys(n).reduce(B(n),{...K}):K}async function W(n){if(!n)return window.KosPlugins=window.KosPlugins||{},{};for(const o of Object.values(n)){try{if(o.extensions&&Array.isArray(o.extensions)){const a=o.extensions.filter(r=>r&&typeof r=="object"&&"id"in r).map(r=>ye(r));if(a.length>0){console.info(`Registering ${a.length} JSON extension point(s) from ${o.remote}`);for(const r of a)try{q(r).register(),console.debug(`Registered JSON extension point: ${r.id}`)}catch(c){console.error(`Failed to register JSON extension point '${r.id}' from ${o.remote}:`,c)}}}}catch(a){console.warn(`Failed to parse JSON extension points from ${o.remote}:`,a)}if(o.init)try{const a=await $.loadRemoteModule(o.remote,"./InitPlugin");if(a.default){const r=new a.default;r==null||r.register()}}catch(a){console.warn(`Failed to load InitPlugin from ${o.remote}:`,a)}}const t=H(n),e=t.experiences,s=me({},t,e);return window.KosPlugins=window.KosPlugins||{},window.KosPlugins.__extensions=s,s}async function Ue(n){const{getExtensions:t}=await z();return t(n)}const Ae=(n=null)=>(n||window.location.search.replace("?","")).split("&").map(t=>{const[e,i]=t.split("=");return[e,decodeURIComponent(i||"")]}).reduce((t,[e,i])=>(t[e]=i,t),{}),je=()=>{const n=window.location.origin,t=Ae();return(t==null?void 0:t.host)||n},Ne=async n=>{var x;const t=je(),e=n??{},{pluginBaseUrl:i=t,pluginApiPath:s,overrides:o={},pluginContext:a}=e,r=s?`${i}${s}`:`${i}/api/kos/ui/plugins/contexts`;console.log(`initialize-plugins: Using Plugin Framework. Fetching plugins from ${r}`);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(m=>m.plugins))??[],h=a==null?void 0:a.group,d=f==null?void 0:f.reduce((m,g)=>{const O=(o==null?void 0:o[g.id])??`${i}${g.path}`;if(g.descriptor){const N=(g.descriptor.extensions||[]).reduce((P,b)=>{const C=b.groups||[];return(!h||C.includes(h))&&P.push(b),P},[]),w=g.descriptor.contributes||{};let k=!1;const Z=Object.keys(w).reduce((P,b)=>{if(Array.isArray(w[b])){const C=(w[b]||[]).filter(Q=>{const X=Q.groups||[];return!h||X.includes(h)});k=k||C.length>0,P[b]=C}else P[b]=w[b],k=Object.keys(w[b]).length>0;return P},{}),Y=!!g.descriptor.init&&(N.length>0||k);m[g.id]={basePath:`${O}remoteEntry.js`,extensions:N,contributes:Z,remote:g.descriptor.id,init:Y}}else console.error(`initialize-plugins: Plugin ${g.id} does not have a descriptor`);return m},{});window.KosPlugins=window.KosPlugins||{},window.KosPlugins.__dynamicRemotes=d;const p=Object.keys(d).reduce((m,g)=>{const O=d[g].remote;return m[O]=d[g].basePath,m},{});return $.setRemoteDefinitions(p),p};function Ve(n,t,e=!1){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)=>{const a=typeof s.rank=="number"?s.rank:1/0,r=typeof o.rank=="number"?o.rank:1/0;if(a===r){const c=s.id??"",l=o.id??"";return c.localeCompare(l)}return a-r})[0]??null}const j=v.z.object({id:v.z.string().min(1,"ID is required").describe("Unique identifier for this extension"),title:v.z.string().min(1,"Title is required").describe("Display title shown in the interface"),namespace:v.z.string().min(1,"Namespace is required").describe("Namespace for organizing related extensions"),experienceId:v.z.string().min(1,"Experience ID is required").describe("Reference to the UI component experience for rendering")}),G=j.extend({rank:v.z.number().int().min(0).optional().describe("Optional ranking for ordering (higher = preferred)")});function Ke(n,t,e){const i=n.safeParse(t);return i.success?!0:(i.error.errors.forEach(s=>{e.addError(`${s.path.join(".")}: ${s.message}`)}),!1)}function Me(n,t,e){t&&!t.includes(".")&&e.addWarning(`${n} '${t}' should typically include dot notation (e.g., 'category.item')`)}function J(n,t,e=1e3){n!==void 0&&n>e&&t.addWarning(`Rank ${n} seems unusually high - consider using lower values for better ordering`)}function Le(n,t={}){return(t.rankable?G:j).extend(n)}function qe(n,t,e=1e3){typeof n=="object"&&n!==null&&"rank"in n&&J(n.rank,t,e)}class F{static getExtensionPoints(t,e={}){const{includeLegacyExtensions:i=!0,includeEmptyExtensionPoints:s=!0}=e,a=y().getAllExtensionPoints(),r=[];return a.forEach(c=>{const l=Object.values((t==null?void 0:t[c.id])||{});!s&&l.length===0||r.push({id:c.id,displayName:c.config.displayName,description:c.config.description,source:"simplified",metadata:c.config.metadata,pluginCount:l.length,plugins:l})}),i&&t&&Object.entries(t).forEach(([c,l])=>{if(r.some(f=>f.id===c))return;const u=Object.values(l||{});!s&&u.length===0||r.push({id:c,source:"legacy",pluginCount:u.length,plugins:u})}),r.sort((c,l)=>c.id.localeCompare(l.id))}static filterExtensionPoints(t,e){if(!e.trim())return t;const i=e.toLowerCase();return t.filter(s=>{var o,a,r,c,l,u;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)))})}static calculateHealthStats(t){const e=t.length,i=t.filter(c=>c.pluginCount>0).length,s=t.reduce((c,l)=>c+l.pluginCount,0),o=t.filter(c=>c.source==="simplified").length,a=t.filter(c=>c.source==="legacy").length,r=t.filter(c=>{var l;return(l=c.metadata)==null?void 0:l.deprecated}).length;return{totalExtensionPoints:e,extensionPointsWithPlugins:i,totalPlugins:s,simplifiedExtensionPoints:o,legacyExtensionPoints:a,deprecatedExtensionPoints:r}}static analyzePlugin(t){const e=!!t.component,i=typeof t.rank=="number",s=t.rank||0,o=[];if(e?o.push("UI Component"):o.push("Background Service"),i&&o.push(`Rank: ${s}`),t.namespace){const r=t.namespace;r.includes("kos")||r.includes("ddk")?o.push("First-party"):o.push("Third-party")}t.modalMode&&o.push(`Modal: ${t.modalMode}`);let a="healthy";return t.remote||(a="warning"),{hasComponent:e,hasRank:i,healthStatus:a,capabilities:o}}static getExtensionPointById(t,e){return t.find(i=>i.id===e)}static validateExtensionPointId(t){const e=[],i=[];t.includes(".")||(e.push("Extension point ID should contain at least one dot (namespace.feature)"),i.push('Use format like "ddk.myFeature" or "app.myFeature"'));const s=t.split(".");s.length<2&&e.push("Extension point ID should have at least 2 parts (namespace.feature)");const o=s[0];return o&&!["ddk","cui","app"].includes(o)&&!o.endsWith("app")&&i.push("Consider using standard namespaces: ddk, cui, or [appname]app"),s.some(r=>/[A-Z]/.test(r))&&(e.push("Extension point ID parts should be lowercase"),i.push('Use kebab-case or dot notation: "my.feature" not "my.myFeature"')),{isValid:e.length===0,issues:e,suggestions:i}}static validatePluginDescriptor(t){const e=[],i=[],s=[],o=[];if(t.id?t.id.match(/^[a-z0-9-]+$/)||o.push("Plugin ID convention: use lowercase letters, numbers, and hyphens (e.g., 'my-awesome-plugin')"):(s.push("id"),e.push("Plugin descriptor must have an 'id' field")),!t.contributes)i.push("Plugin has no contributions - it won't extend any functionality"),o.push("Add a 'contributes' section with plugin contributions");else{const a=Object.keys(t.contributes);a.length===0&&i.push("Plugin contributes section is empty"),a.forEach(r=>{const c=t.contributes[r];if(!Array.isArray(c)){e.push(`Contribution '${r}' must be an array`);return}c.forEach((l,u)=>{l.id||e.push(`Contribution ${r}[${u}] missing required 'id' field`),r==="experiences"&&l.component&&!l.location&&(e.push(`Experience '${l.id}' has component but no location`),o.push("Add 'location' field pointing to the component file")),["cui","utilities","settings","setup"].includes(r)&&(l.title||i.push(`${r} contribution '${l.id}' missing 'title' field`),l.namespace||i.push(`${r} contribution '${l.id}' missing 'namespace' field`),l.experienceId||e.push(`${r} contribution '${l.id}' missing required 'experienceId' field`))})})}return t.init!==void 0&&typeof t.init!="boolean"&&e.push("'init' field must be a boolean value"),{isValid:e.length===0&&s.length===0,errors:e,warnings:i,missingRequired:s,suggestions:o}}static checkPluginCompatibility(t,e){const i=[],s=[],o=[],a=[];if(!t.contributes)return{isCompatible:!0,issues:["Plugin has no contributions to check"],missingExtensionPoints:[],incompatibleTypes:[],suggestions:[]};const r=y(),c=new Set(e.map(l=>l.id));return Object.entries(t.contributes).forEach(([l,u])=>{this.getExpectedExtensionPoints(l).forEach(p=>{c.has(p)||(s.push(p),i.push(`Extension point '${p}' not available for '${l}' contributions`),a.push(`Ensure the extension point '${p}' is registered`))});const d=r.getAllExtensionPoints().find(p=>p.config.contributionKey===l);d&&u.length>0&&u.forEach((p,x)=>{d.config.isRankable&&typeof p.rank!="number"&&(i.push(`${l}[${x}]: Extension point '${d.id}' expects 'rank' property`),a.push("Add 'rank' property with numeric value for ordering")),d.config.hasView&&!p.experienceId&&(i.push(`${l}[${x}]: Extension point '${d.id}' expects 'experienceId' for view-based contributions`),a.push("Add 'experienceId' property linking to an experience definition"))})}),{isCompatible:i.length===0,issues:i,missingExtensionPoints:s,incompatibleTypes:o,suggestions:a}}static getExpectedExtensionPoints(t){return{cui:["ddk.cui","ddk.cui.view","ddk.cui.settings.config"],utilities:["ddk.utility","ddk.utility.view","ddk.utilities"],setup:["ddk.setup","ddk.setup.view"],settings:["ddk.settings","ddk.settings.view"],troubleActions:["ddk.troubleAction","ddk.troubleAction.view"],navViews:["ddk.nav","ddk.nav.view"],controlPour:["ddk.controlPour","ddk.controlPour.view"],experiences:[],views:[]}[t]||[]}static analyzePluginDescriptor(t,e){const i=this.validatePluginDescriptor(t),s=this.checkPluginCompatibility(t,e),o=[];return i.warnings.length>0&&o.push("Address validation warnings to improve plugin quality"),s.isCompatible||o.push("Resolve compatibility issues before deploying plugin"),t.contributes&&Object.keys(t.contributes).length===1&&o.push("Consider adding more contribution types to increase plugin value"),{validation:i,compatibility:s,recommendations:o}}}class Be{static generateFullDocumentation(t,e={}){const{includeUsageExamples:i=!0,includeTypeDefinitions:s=!0,includeLegacyExtensions:o=!0,includePluginHealth:a=!0}=e,r=F.getExtensionPoints(t,{includeLegacyExtensions:o,includeEmptyExtensionPoints:!0}),c=F.calculateHealthStats(r);let l=this.generateHeader(c);return l+=this.generateTableOfContents(r),l+=this.generateOverviewSection(r,c),r.forEach(u=>{l+=this.generateExtensionPointSection(u,{includeUsageExamples:i,includePluginHealth:a})}),s&&(l+=this.generateTypeDefinitionsSection(r)),l+=this.generateContributionGuide(),l+=this.generateTroubleshootingSection(),{content:l,metadata:{generatedAt:new Date().toISOString(),totalExtensionPoints:c.totalExtensionPoints,totalPlugins:c.totalPlugins,simplifiedExtensionPoints:c.simplifiedExtensionPoints,legacyExtensionPoints:c.legacyExtensionPoints}}}static generateHeader(t){return`# KOS Plugin Extension Points Reference
2
+
3
+ **Generated**: ${new Date().toLocaleString()}
4
+
5
+ ## System Overview
6
+
7
+ - **Total Extension Points**: ${t.totalExtensionPoints}
8
+ - **Extension Points with Plugins**: ${t.extensionPointsWithPlugins}
9
+ - **Total Active Plugins**: ${t.totalPlugins}
10
+ - **Simplified Extension Points**: ${t.simplifiedExtensionPoints}
11
+ - **Legacy Extension Points**: ${t.legacyExtensionPoints}
12
+
13
+ ---
14
+
15
+ `}static generateTableOfContents(t){let e=`## Table of Contents
16
+
17
+ `;return e+=`- [Overview](#overview)
18
+ `,e+=`- [Extension Points](#extension-points)
19
+ `,t.forEach(i=>{const s=i.id.toLowerCase().replace(/\./g,"");e+=` - [${i.id}](#${s}) (${i.pluginCount} plugins)
20
+ `}),e+=`- [Type Definitions](#type-definitions)
21
+ `,e+=`- [Contribution Guide](#contribution-guide)
22
+ `,e+=`- [Troubleshooting](#troubleshooting)
23
+
24
+ `,e}static generateOverviewSection(t,e){let i=`## Overview
25
+
26
+ `;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.
27
+
28
+ `,i+=`### Extension Point Types
29
+
30
+ `,i+="- ** Simplified Extension Points**: Use the new simplified API from `defineExtensionPoint`\n",i+=`- ** Legacy Extension Points**: Use the traditional reducer-based system
31
+
32
+ `,e.deprecatedExtensionPoints>0&&(i+=`### ⚠️ Deprecated Extension Points
33
+
34
+ `,i+=`${e.deprecatedExtensionPoints} extension points are marked as deprecated. `,i+=`Consider migrating to newer alternatives.
35
+
36
+ `),i+`---
37
+
38
+ `}static generateExtensionPointSection(t,e){var a;const{includeUsageExamples:i=!0,includePluginHealth:s=!0}=e;let o=`## ${t.id}
39
+
40
+ `;if(t.displayName&&(o+=`**Display Name**: ${t.displayName}
41
+
42
+ `),t.description&&(o+=`**Description**: ${t.description}
43
+
44
+ `),o+=`**Source**: ${t.source}
45
+ `,o+=`**Active Plugins**: ${t.pluginCount}
46
+
47
+ `,t.metadata){o+=`### Metadata
48
+
49
+ `;const r=t.metadata;r.category&&(o+=`- **Category**: ${r.category}
50
+ `),r.owner&&(o+=`- **Owner**: ${r.owner}
51
+ `),r.since&&(o+=`- **Since**: ${r.since}
52
+ `),(a=r.tags)!=null&&a.length&&(o+=`- **Tags**: ${r.tags.join(", ")}
53
+ `),r.deprecated&&(o+=`- **⚠️ Status**: Deprecated
54
+ `),o+=`
55
+ `}return i&&(o+=this.generateUsageExamples(t)),t.plugins.length>0?o+=this.generatePluginList(t.plugins,s):o+=`### Plugins
56
+
57
+ No plugins currently registered for this extension point.
58
+
59
+ `,o+=this.generateSchemaFieldsSection(t),o+=this.generateContributionStructure(t),o+`---
60
+
61
+ `}static generateUsageExamples(t){let e=`### Usage Examples
62
+
63
+ `;return t.source==="simplified"&&(e+=`#### Using Simplified API
64
+
65
+ `,e+="```typescript\n",e+=`// Import the extension point
66
+ `,e+=`import { ${this.getExtensionPointImportName(t.id)} } from './extension-points';
67
+
68
+ `,e+=`// Use extension component hook
69
+ `,e+=`import { useExtensionComponent } from '@kosdev-code/kos-ui-plugin';
70
+
71
+ `,e+=`const Component = useExtensionComponent(${this.getExtensionPointImportName(t.id)});
72
+
73
+ `,e+=`if (Component) {
74
+ `,e+=` return (
75
+ `,e+=` <Component
76
+ `,e+=` customProp="value"
77
+ `,e+=` onComplete={handleComplete}
78
+ `,e+=` />
79
+ `,e+=` );
80
+ `,e+=`}
81
+
82
+ `,e+=`// Or use with dynamic component
83
+ `,e+=`const [Component] = useDynamicComponent({
84
+ `,e+=` extension: ${this.getExtensionPointImportName(t.id)}.id
85
+ `,e+=`});
86
+ `,e+="```\n\n",e+=`#### Using Typed Hooks
87
+
88
+ `,e+="```typescript\n",e+=`// Get all extensions with type safety
89
+ `,e+=`const extensions = useExtensions(${this.getExtensionPointImportName(t.id)});
90
+
91
+ `,e+=`// Get best extension
92
+ `,e+=`const bestExtension = useBest(${this.getExtensionPointImportName(t.id)});
93
+
94
+ `,e+=`// Check availability
95
+ `,e+=`const hasExtensions = useHasExtensions(${this.getExtensionPointImportName(t.id)});
96
+ `,e+="```\n\n"),e+=`#### Using DynamicComponent
97
+
98
+ `,e+="```typescript\n",e+=`import { DynamicComponent } from '@kosdev-code/kos-ui-plugin';
99
+ `,e+=`import { ${this.getExtensionPointImportName(t.id)} } from './extension-points';
100
+
101
+ `,e+=`<DynamicComponent
102
+ `,e+=` extension={${this.getExtensionPointImportName(t.id)}.id}
103
+ `,e+=` props={{ customData: "value" }}
104
+ `,e+=` fallback={<div>Loading...</div>}
105
+ `,e+=`/>
106
+ `,e+="```\n\n",e+=`#### Using Context
107
+
108
+ `,e+="```typescript\n",e+=`import { useKosPluginsContext } from '@kosdev-code/kos-ui-plugin';
109
+ `,e+=`import { ${this.getExtensionPointImportName(t.id)} } from './extension-points';
110
+
111
+ `,e+=`const { getExtensions } = useKosPluginsContext();
112
+ `,e+=`const extensions = getExtensions(${this.getExtensionPointImportName(t.id)}.id);
113
+ `,e+="```\n\n",e}static generatePluginList(t,e){let i=`### Active Plugins
114
+
115
+ `;return t.forEach(s=>{if(i+=`#### ${s.id}
116
+
117
+ `,s.remote&&(i+=`- **Remote**: ${s.remote}
118
+ `),s.sectionId&&(i+=`- **Section**: ${s.sectionId}
119
+ `),s.rank!==void 0&&(i+=`- **Rank**: ${s.rank}
120
+ `),e){const o=F.analyzePlugin(s);i+=`- **Health**: ${this.getHealthEmoji(o.healthStatus)} ${o.healthStatus}
121
+ `,o.capabilities.length>0&&(i+=`- **Capabilities**: ${o.capabilities.join(", ")}
122
+ `)}i+=`
123
+ `}),i}static generateSchemaFieldsSection(t){if(t.source!=="simplified")return"";const i=y().getExtensionPoint(t.id);if(!(i!=null&&i.getSchemaFieldInfo))return"";const s=i.getSchemaFieldInfo();if(s.length===0)return"";let o=`### Schema Fields
124
+
125
+ `;return o+=`The following fields are defined in the schema for this extension point:
126
+
127
+ `,o+=`| Field | Type | Required | Description |
128
+ `,o+=`|-------|------|----------|-------------|
129
+ `,s.forEach(a=>{const r=a.name,c=a.type||"unknown",l=a.required?"✅":"⭕",u=a.description||"-";o+=`| \`${r}\` | ${c} | ${l} | ${u} |
130
+ `}),o+=`
131
+ `,o}static generateContributionStructure(t){let e=`### Contribution Structure
132
+
133
+ `;e+=`To contribute to this extension point, add the following to your plugin descriptor:
134
+
135
+ `,e+="```json\n",e+=`{
136
+ `,e+=` "id": "your-plugin-id",
137
+ `,e+=` "contributes": {
138
+ `;const i=this.inferContributionKey(t);e+=` "${i}": [
139
+ `,e+=` {
140
+ `;const s=this.getSchemaFieldsForContribution(t);if(s.length>0){const a=[];s.forEach(r=>{let c;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}`)}),e+=a.join(`,
141
+ `)}else{e+=` "id": "your-contribution-id",
142
+ `,e+=` "title": "Your Contribution Title",
143
+ `,e+=' "namespace": "your-namespace"',this.isViewBasedExtensionPoint(t)&&(e+=`,
144
+ "experienceId": "your-experience-id"`),this.isRankableExtensionPoint(t)&&(e+=`,
145
+ "rank": 10`);const a=this.getSpecificFields(t);a.length>0&&(e+=`,
146
+ ${a.join(`,
147
+ `)}`)}return e+=`
148
+ }
149
+ `,e+=" ]",(s.some(a=>a.name==="experienceId")||this.isViewBasedExtensionPoint(t))&&(e+=`,
150
+ "experiences": {
151
+ `,e+=` "your-experience-id": {
152
+ `,e+=` "id": "your-experience-id",
153
+ `,e+=` "component": "YourComponent",
154
+ `,e+=` "location": "./src/components/YourComponent.tsx"
155
+ `,e+=` }
156
+ `,e+=" }"),e+=`
157
+ }
158
+ `,e+=`}
159
+ `,e+="```\n\n",e}static generateTypeDefinitionsSection(t){let e=`## Type Definitions
160
+
161
+ `;return e+=`### Extension Point Types
162
+
163
+ `,e+="```typescript\n",t.forEach(i=>{i.source==="simplified"&&(e+=`// ${i.id}
164
+ `,e+=`interface ${this.getExtensionPointTypeName(i.id)} {
165
+ `,e+=` id: "${i.id}";
166
+ `,e+=` displayName?: "${i.displayName||""}";
167
+ `,e+=` description?: "${i.description||""}";
168
+ `,e+=`}
169
+
170
+ `)}),e+="```\n\n",e+=`### Plugin Contribution Types
171
+
172
+ `,e+="```typescript\n",e+=`interface BaseContribution {
173
+ `,e+=` id: string;
174
+ `,e+=` title: string;
175
+ `,e+=` namespace: string;
176
+ `,e+=`}
177
+
178
+ `,e+=`interface ViewBasedContribution extends BaseContribution {
179
+ `,e+=` experienceId: string;
180
+ `,e+=`}
181
+
182
+ `,e+=`interface RankableContribution extends BaseContribution {
183
+ `,e+=` rank: number;
184
+ `,e+=`}
185
+ `,e+="```\n\n",e}static generateContributionGuide(){return`## Contribution Guide
186
+
187
+ ### Creating a Plugin
188
+
189
+ 1. **Create Plugin Project**
190
+ \`\`\`bash
191
+ kosui plugin-project --name my-plugin
192
+ \`\`\`
193
+
194
+ 2. **Add Components**
195
+ \`\`\`bash
196
+ kosui component --name MyComponent --pluginType utility --project my-plugin
197
+ \`\`\`
198
+
199
+ 3. **Update Plugin Descriptor**
200
+ Add contributions to your \`kosdev-plugin.json\` file following the structure examples above.
201
+
202
+ 4. **Test Integration**
203
+ Use the Plugin Explorer (Ctrl+Shift+P) to validate your plugin registration.
204
+
205
+ ### Best Practices
206
+
207
+ - **Use descriptive IDs**: Plugin and contribution IDs should be clear and unique
208
+ - **Follow naming conventions**: Use kebab-case for IDs, PascalCase for components
209
+ - **Provide meaningful titles**: Titles are shown to users in the interface
210
+ - **Set appropriate ranks**: Higher numbers = higher priority for rankable contributions
211
+ - **Include proper metadata**: Namespace helps organize plugins by owner
212
+
213
+ ### Validation
214
+
215
+ Use the Plugin Discovery Service to validate your plugin descriptor:
216
+
217
+ \`\`\`typescript
218
+ import { PluginDiscoveryService } from '@kosdev-code/kos-ui-plugin';
219
+
220
+ const validation = PluginDiscoveryService.validatePluginDescriptor(yourDescriptor);
221
+ console.log(validation.errors); // Check for errors
222
+ console.log(validation.warnings); // Check for warnings
223
+ \`\`\`
224
+
225
+ `}static generateTroubleshootingSection(){return`## Troubleshooting
226
+
227
+ ### Common Issues
228
+
229
+ **Plugin not appearing in extension point**
230
+ - Check plugin descriptor syntax
231
+ - Verify contribution key matches extension point requirements
232
+ - Ensure experienceId references exist in experiences section
233
+
234
+ **Component fails to load**
235
+ - Verify component path in experience location
236
+ - Check module federation configuration
237
+ - Use Plugin Explorer to see detailed error messages
238
+
239
+ **Type errors with simplified extension points**
240
+ - Ensure extension point is properly imported
241
+ - Check that component props match expected interface
242
+ - Verify extension point is registered before use
243
+
244
+ ### Debugging Tools
245
+
246
+ **Plugin Explorer**
247
+ - Press Ctrl+Shift+P in development mode
248
+ - View all extension points and their plugins
249
+ - See plugin health status and capabilities
250
+ - Test component rendering with error boundaries
251
+
252
+ **Validation Service**
253
+ - Use \`PluginDiscoveryService.validatePluginDescriptor()\`
254
+ - Check \`PluginDiscoveryService.checkPluginCompatibility()\`
255
+ - Run \`PluginDiscoveryService.analyzePluginDescriptor()\` for full analysis
256
+
257
+ **Browser DevTools**
258
+ - Check \`window.KosPlugins.extensions\` for runtime state
259
+ - Look for module federation errors in Network tab
260
+ - Use React DevTools to inspect component loading
261
+
262
+ ---
263
+
264
+ *Generated by KOS Plugin Documentation Generator*
265
+ `}static getExtensionPointImportName(t){var a;const i=y().getExtensionPoint(t);if((a=i==null?void 0:i.config.metadata)!=null&&a.exportName)return i.config.metadata.exportName;const s=t.split(".");return(s.length>1?s.slice(1):s).map(r=>r.split("-").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("")).join("")+"Extension"}static getExtensionPointTypeName(t){return this.getExtensionPointImportName(t)+"Type"}static getHealthEmoji(t){switch(t){case"healthy":return"✅";case"warning":return"⚠️";case"error":return"❌";default:return"❓"}}static inferContributionKey(t){if(t.source==="simplified"){const a=y().getExtensionPoint(t.id);if(a!=null&&a.config.contributionKey)return a.config.contributionKey}const e=t.id.split("."),i=e[e.length-1];return{cui:"cui",utility:"utilities",utilities:"utilities",setup:"setupStep",settings:"settings",nav:"navViews",troubleAction:"troubleActions",controlPour:"controlPour"}[i]||i+"s"}static isViewBasedExtensionPoint(t){if(t.source==="simplified"){const i=y().getExtensionPoint(t.id);return(i==null?void 0:i.config.hasView)||!1}return t.plugins.some(e=>e.experienceId)}static isRankableExtensionPoint(t){if(t.source==="simplified"){const i=y().getExtensionPoint(t.id);return(i==null?void 0:i.config.isRankable)||!1}return t.plugins.some(e=>typeof e.rank=="number")}static getSchemaFieldsForContribution(t){if(t.source!=="simplified")return[];const i=y().getExtensionPoint(t.id);return i!=null&&i.getSchemaFieldInfo?i.getSchemaFieldInfo():[]}static getSpecificFields(t){const e=[];switch(this.inferContributionKey(t)){case"utilities":e.push('"utilDescriptor": "your-util-descriptor"');break;case"setupStep":e.push('"setupDescriptor": "your-setup-descriptor"');break;case"settings":e.push('"settingsGroup": "your-settings-group"');break;case"navViews":e.push('"navDescriptor": "your-nav-descriptor"');break;case"troubleActions":e.push('"troubleType": "your-trouble-type"');break;case"cui":e.push('"cuiDescriptor": "your-cui-descriptor"');break}return e}}exports.BaseViewExtensionSchema=j;exports.DocumentationGenerator=Be;exports.PluginDiscoveryService=F;exports.RankableViewExtensionSchema=G;exports.contributionReducer=B;exports.createExtensionSchema=Le;exports.createViewAwareTransform=L;exports.defineExtensionPoint=q;exports.getContributions=H;exports.getExtensionPointRegistry=y;exports.getExtensions=Ue;exports.getValidationResults=pe;exports.index=ce;exports.initPluginManager=z;exports.initializeKosPlugins=Ne;exports.loadExtensions=W;exports.mf=$;exports.registry=A;exports.resolveBestExtension=Ve;exports.validateDescriptorFormat=Me;exports.validateRank=J;exports.validateRankIfPresent=qe;exports.validateWithSchema=Ke;
266
+ //# sourceMappingURL=documentation-generator-hrRc6NVI.cjs.map