@kosdev-code/kos-ui-plugin 2.1.18 → 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.
- package/documentation-generator-CAlVz5vA.cjs +266 -0
- package/documentation-generator-CAlVz5vA.cjs.map +1 -0
- package/documentation-generator-Di4c9D9P.js +2337 -0
- package/documentation-generator-Di4c9D9P.js.map +1 -0
- package/index.cjs +69 -69
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +817 -753
- package/index.js.map +1 -1
- package/lib/components/dynamic-component/dynamic-component.d.ts +69 -0
- package/lib/components/dynamic-component/dynamic-component.d.ts.map +1 -1
- package/lib/contexts/index.d.ts +1 -0
- package/lib/contexts/index.d.ts.map +1 -1
- package/lib/contexts/plugins-provider/plugins-provider.d.ts.map +1 -1
- package/lib/contexts/reactive-extension-registry-context.d.ts +10 -0
- package/lib/contexts/reactive-extension-registry-context.d.ts.map +1 -0
- package/lib/hooks/index.d.ts +4 -2
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/use-dynamic-component.d.ts +12 -1
- package/lib/hooks/use-dynamic-component.d.ts.map +1 -1
- package/lib/hooks/use-extension-point.d.ts +95 -0
- package/lib/hooks/use-extension-point.d.ts.map +1 -0
- package/lib/hooks/use-reactive-extension-registry.d.ts +20 -0
- package/lib/hooks/use-reactive-extension-registry.d.ts.map +1 -0
- package/lib/hooks/use-typed-extensions.d.ts.map +1 -1
- package/lib/utils/contribution-registry.d.ts +170 -0
- package/lib/utils/contribution-registry.d.ts.map +1 -0
- package/lib/utils/extension-points/extension-point-registry.d.ts.map +1 -1
- package/lib/utils/extension-points/extension-point-schemas.d.ts +4 -4
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/plugin-system/plugin-extension-manager.d.ts.map +1 -1
- package/lib/utils/processors/initialize-plugins.d.ts.map +1 -1
- package/lib/utils/reactive-extension-registry.d.ts +140 -0
- package/lib/utils/reactive-extension-registry.d.ts.map +1 -0
- package/lib/webpack/index.d.ts +2 -0
- package/lib/webpack/index.d.ts.map +1 -1
- package/lib/webpack/with-plugin-dev-aggregator.d.ts +94 -0
- package/lib/webpack/with-plugin-dev-aggregator.d.ts.map +1 -0
- package/lib/webpack/with-plugin-dev-server.d.ts +113 -0
- package/lib/webpack/with-plugin-dev-server.d.ts.map +1 -0
- package/package.json +2 -2
- package/types/contribution-enablement.d.ts +293 -0
- package/types/contribution-enablement.d.ts.map +1 -0
- package/types/plugins.d.ts +8 -0
- package/utils.cjs +1 -1
- package/utils.cjs.map +1 -1
- package/utils.js +29 -291
- package/utils.js.map +1 -1
- package/webpack.cjs +3 -12
- package/webpack.cjs.map +1 -1
- package/webpack.js +455 -727
- package/webpack.js.map +1 -1
- package/documentation-generator-DFaIDo0E.cjs +0 -266
- package/documentation-generator-DFaIDo0E.cjs.map +0 -1
- package/documentation-generator-auruIa_o.js +0 -1560
- package/documentation-generator-auruIa_o.js.map +0 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";var ce=Object.defineProperty;var le=(n,e,t)=>e in n?ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var E=(n,e,t)=>(le(n,typeof e!="symbol"?e+"":e,t),t);const D=require("zod");function ue(n,e){for(var t=0;t<e.length;t++){const i=e[t];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 N={},R={};Object.defineProperty(R,"__esModule",{value:!0});R.loadRemoteModule=R.setRemoteDefinitions=R.setRemoteUrlResolver=void 0;let U,j;const K=new Map,L=new Map;let H=!1;function de(n){j=n}R.setRemoteUrlResolver=de;function fe(n){U=n}R.setRemoteDefinitions=fe;async function ge(n,e){const t=`${n}:${e}`;if(K.has(t))return K.get(t);const o=(await(L.has(n)?L.get(n):await me(n)).get(e))();return K.set(t,o),o}R.loadRemoteModule=ge;const pe=(n,e)=>new Promise((t,i)=>{const s=document.createElement("script");s.src=n,s.type="text/javascript",s.async=!0,s.onload=()=>{t({get:r=>window[e].get(r),init:r=>{try{window[e].init(r)}catch(a){console.error(`Failed to initialize remote ${e}`,a),i(a)}}})},s.onerror=()=>i(new Error(`Remote ${e} not found`)),document.head.appendChild(s)});async function me(n){if(!j&&!U)throw new Error("Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.");H||(H=!0,await __webpack_init_sharing__("default"));const e=U?U[n]:await j(n);let t=e;!e.endsWith(".mjs")&&!e.endsWith(".js")&&(t=`${e}${e.endsWith("/")?"":"/"}remoteEntry.js`);const i=await pe(t,n);return await i.init(__webpack_share_scopes__.default),L.set(n,i),i}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.setRemoteUrlResolver=n.setRemoteDefinitions=n.loadRemoteModule=void 0;var e=R;Object.defineProperty(n,"loadRemoteModule",{enumerable:!0,get:function(){return e.loadRemoteModule}}),Object.defineProperty(n,"setRemoteDefinitions",{enumerable:!0,get:function(){return e.setRemoteDefinitions}}),Object.defineProperty(n,"setRemoteUrlResolver",{enumerable:!0,get:function(){return e.setRemoteUrlResolver}})})(N);const he=ue({__proto__:null},[N]);function J(n,e,t=!1){return!n||Object.keys(n).length===0?null:t?e&&n[e]?n[e]:null:e&&n[e]?n[e]:Object.values(n).filter(s=>typeof s.id=="string").sort((s,o)=>{const r=typeof s.rank=="number"?s.rank:1/0,a=typeof o.rank=="number"?o.rank:1/0;if(r===a){const c=s.id??"",l=o.id??"";return c.localeCompare(l)}return r-a})[0]??null}class be{constructor(){E(this,"contributions",new Map);E(this,"extensionPointIndex",new Map);E(this,"globalListeners",new Set);E(this,"extensionPointListeners",new Map);E(this,"enablementContext",{extensions:{},contributions:{controlPourDefinitions:{},experiences:{}},context:{}})}register(e,t,i){const s={...i,enabled:!0,lastStateChange:Date.now()};this.contributions.set(e,s),this.extensionPointIndex.has(t)||this.extensionPointIndex.set(t,new Set),this.extensionPointIndex.get(t).add(e)}setContext(e){this.enablementContext={...this.enablementContext,...e}}setEnabled(e,t,i){const s=this.contributions.get(e);if(!s){console.warn(`ContributionRegistry.setEnabled: Contribution '${e}' not found. Ignoring.`);return}const o=s.enabled;o!==t&&(s.enabled=t,s.disabledReason=t?void 0:i,s.lastStateChange=Date.now(),this.emitStateChange({contributionId:e,extensionPoint:this.findExtensionPoint(e),enabled:t,previousState:o,reason:i,timestamp:s.lastStateChange}))}isEnabled(e){const t=this.contributions.get(e);if(!t)return!0;if(!t.enabled)return!1;if(t.enabledCondition)try{return t.enabledCondition(this.enablementContext)}catch(i){return console.error(`ContributionRegistry.isEnabled: Error evaluating enabledCondition for '${e}':`,i),!1}return!0}subscribe(e){if(typeof e!="function")throw new TypeError("ContributionRegistry.subscribe: listener must be a function");return this.globalListeners.add(e),()=>{this.globalListeners.delete(e)}}subscribeToExtensionPoint(e,t){if(typeof t!="function")throw new TypeError("ContributionRegistry.subscribeToExtensionPoint: listener must be a function");return this.extensionPointListeners.has(e)||this.extensionPointListeners.set(e,new Set),this.extensionPointListeners.get(e).add(t),()=>{var i,s;(i=this.extensionPointListeners.get(e))==null||i.delete(t),((s=this.extensionPointListeners.get(e))==null?void 0:s.size)===0&&this.extensionPointListeners.delete(e)}}batchUpdate(e){if(!Array.isArray(e))throw new TypeError("ContributionRegistry.batchUpdate: updates must be an array");const t=e.map(s=>{const o=this.contributions.get(s.contributionId);return o?o.enabled===s.enabled?null:{contribution:o,update:s,previousState:o.enabled}:(console.warn(`ContributionRegistry.batchUpdate: Contribution '${s.contributionId}' not found. Skipping.`),null)}),i=Date.now();t.forEach(s=>{if(!s)return;const{contribution:o,update:r}=s;o.enabled=r.enabled,o.disabledReason=r.enabled?void 0:r.reason,o.lastStateChange=i}),t.forEach(s=>{if(!s)return;const{update:o,previousState:r}=s;this.emitStateChange({contributionId:o.contributionId,extensionPoint:this.findExtensionPoint(o.contributionId),enabled:o.enabled,previousState:r,reason:o.reason,timestamp:i})})}getContributions(e,t=!1){const i=this.extensionPointIndex.get(e);if(!i||i.size===0)return[];const s=[];return i.forEach(o=>{const r=this.contributions.get(o);r&&(t||this.isEnabled(o))&&s.push(r)}),s}findExtensionPoint(e){for(const[t,i]of this.extensionPointIndex.entries())if(i.has(e))return t;return""}emitStateChange(e){this.globalListeners.forEach(i=>{try{i(e)}catch(s){console.error("ContributionRegistry: Error in global listener:",s)}});const t=this.extensionPointListeners.get(e.extensionPoint);t&&t.forEach(i=>{try{i(e)}catch(s){console.error(`ContributionRegistry: Error in extension point listener for '${e.extensionPoint}':`,s)}})}reset(){this.contributions.clear(),this.extensionPointIndex.clear(),this.globalListeners.clear(),this.extensionPointListeners.clear(),this.enablementContext={extensions:{},contributions:{controlPourDefinitions:{},experiences:{}},context:{}}}}const I=new be,Z=[];function ye(n){Z.push(n)}function xe(n,e,t){return Z.reduce((i,s)=>s(i,e,t),n)}function Ee(n){var e;try{if("shape"in n){const t=n,i=[];for(const[s,o]of Object.entries(t.shape)){const r=o,a={name:s,required:!r.isOptional()};if(r._def&&r._def.description&&(a.description=r._def.description),r._def){let c=r._def.typeName||"unknown";c==="ZodOptional"&&r._def.innerType&&(c=((e=r._def.innerType._def)==null?void 0:e.typeName)||"unknown"),a.type=c.replace("Zod","").toLowerCase()}i.push(a)}return i}return[]}catch(t){return console.warn("Failed to extract schema field info:",t),[]}}class ve{constructor(){E(this,"issues",[])}addError(e){this.issues.push({type:"error",message:e})}addWarning(e){this.issues.push({type:"warning",message:e})}addInfo(e){this.issues.push({type:"info",message:e})}hasErrors(){return this.issues.some(e=>e.type==="error")}hasIssues(){return this.issues.length>0}getIssues(){return[...this.issues]}}class Pe{constructor(){E(this,"cache",new Map)}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)||[]}clear(){this.cache.clear()}}const _=new Pe;function we(n){return _.get(n)}class Ce{constructor(){E(this,"extensionPoints",new Map)}define(e){if(this.extensionPoints.has(e.id))return console.warn(`Extension point ${e.id} is already defined`),this.extensionPoints.get(e.id);const t={config:e,id:e.id,isRegistered:!1,getExtensions:i=>i[e.id]||{},register:()=>{if(t.isRegistered){console.warn(`Extension point ${e.id} is already registered`);return}const i=this.createReducer(e);ye(i),t.isRegistered=!0}};return e.schema&&(t.getSchemaFieldInfo=()=>Ee(e.schema)),this.extensionPoints.set(e.id,t),t}createReducer(e){return(t,i,s)=>{const o=i[e.contributionKey];return!o||typeof o!="object"||Object.entries(o).forEach(([r,a])=>{var d,m;if(!a)return;const c={remote:a.remote||"",sectionId:a.sectionId||r,experiences:s,contributions:i};if(e.validate){const f=new ve;if(e.validate(a,f)==="skip"){_.set(r,[{type:"warning",message:"Plugin marked to skip processing"}]);return}if(f.hasIssues()){const P=f.getIssues().map(v=>({...v,message:`Extension point validation: ${v.message}`}));if(_.set(r,P),f.hasErrors()){console.error(`Validation failed for ${e.id} contribution "${r}":`,P.filter(v=>v.type==="error").map(v=>v.message).join(", "));return}}else _.set(r,[])}const l=e.transform?e.transform(a,c):a;t[e.id]||(t[e.id]={});const u={id:r,type:e.contributionKey,data:l,remote:c.remote,sectionId:c.sectionId};if(e.isRankable&&typeof a.rank=="number"&&(u.rank=a.rank),l&&typeof l=="object"&&("component"in l&&(u.component=l.component),"view"in l&&(u.view=l.view),"location"in l&&(u.location=l.location)),t[e.id][r]=u,I.register(r,e.id,{id:r,remote:c.remote,sectionId:c.sectionId}),e.hasView&&((d=e.relatedPoints)!=null&&d.view)){const f=a.experienceId,g=s==null?void 0:s[f];g&&(t[e.relatedPoints.view]||(t[e.relatedPoints.view]={}),t[e.relatedPoints.view][r]={id:r,type:`${e.contributionKey}.view`,data:g,remote:c.remote,sectionId:c.sectionId},I.register(r,e.relatedPoints.view,{id:r,remote:c.remote,sectionId:c.sectionId}))}(m=e.relatedPoints)!=null&&m.definition&&(t[e.relatedPoints.definition]||(t[e.relatedPoints.definition]={}),t[e.relatedPoints.definition][r]={id:r,type:`${e.contributionKey}.definition`,data:l,remote:c.remote,sectionId:c.sectionId},I.register(r,e.relatedPoints.definition,{id:r,remote:c.remote,sectionId:c.sectionId}))}),t}}getAllExtensionPoints(){return Array.from(this.extensionPoints.values()).filter(e=>e.isRegistered)}getAllDefinedExtensionPoints(){return Array.from(this.extensionPoints.values())}getExtensionPoint(e){return this.extensionPoints.get(e)}hasExtensionPoint(e){return this.extensionPoints.has(e)}getExtensionPointSchema(e){const t=this.extensionPoints.get(e);return t==null?void 0:t.config.schema}}const q=new Ce;function w(){return q}function $e(n){return q.getExtensionPointSchema(n)}function Y(n={}){const{experienceIdProperty:e="experienceId",flattenComponentProperties:t=!0,customTransform:i}=n;return(s,o)=>{var l;const r=s[e],a=r?((l=o.experiences)==null?void 0:l[r])||{}:{};let c={...s,view:a};return t&&a&&(a.component&&(c.component=a.component),a.location&&(c.location=a.location)),i&&(c=i(s,a,o)||c),c}}function Q(n){return q.define(n)}const ke={$timestamp:()=>Date.now(),$date:()=>new Date().toISOString(),$packageVersion:()=>process.env.npm_package_version||"0.0.0",$env:()=>process.env.NODE_ENV||"development"};function Re(n){const e={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||Ie(n.id)}:void 0};return n.schema&&(e.schema=Se(n.schema,{hasView:n.hasView,isRankable:n.isRankable})),n.validation&&(e.validate=De(n.validation)),n.transform?e.transform=qe(n.transform):n.hasView&&(e.transform=Y()),e}function Ie(n){return n.split(".").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")+"Extension"}function Se(n,e){try{const{z:t}=require("zod");if(n.properties){const i={};i.id=t.string().min(1),i.title=t.string().min(1),i.namespace=t.string().min(1),e!=null&&e.hasView&&(i.experienceId=t.string().min(1)),e!=null&&e.isRankable&&(i.rank=t.number().min(0).max(1e3).optional());for(const[o,r]of Object.entries(n.properties))i[o]=Ve(r,t);let s=t.object(i);return n.additionalProperties||(s=s.strict()),s}return t.any()}catch(t){console.warn("Zod not available for JSON schema conversion:",t);return}}function Ve(n,e){let t;switch(n.type){case"string":t=e.string(),n.minLength&&(t=t.min(n.minLength)),n.maxLength&&(t=t.max(n.maxLength)),n.pattern&&(t=t.regex(new RegExp(n.pattern))),n.enum&&(t=e.enum(n.enum));break;case"number":t=e.number(),n.minimum!==void 0&&(t=t.min(n.minimum)),n.maximum!==void 0&&(t=t.max(n.maximum));break;case"boolean":t=e.boolean();break;case"array":t=e.array(e.any());break;case"object":t=e.object({});break;default:t=e.any()}return n.description&&(t=t.describe(n.description)),n.default!==void 0&&(t=t.default(n.default)),t}function De(n){return n.module?Oe(n.module):(e,t)=>{if(!n.rules)return;const i=e;for(const s of n.rules)Ne(s,i,t)}}function Ne(n,e,t){switch(n.type){case"required":Fe(n,e,t);break;case"range":Te(n,e,t);break;case"pattern":Ue(n,e,t);break;case"dependency":_e(n,e,t);break;case"custom":Ae(n,e,t);break}}function Fe(n,e,t){n.field&&!e[n.field]&&t.addError(n.message||`Field '${n.field}' is required`)}function Te(n,e,t){if(n.field&&typeof e[n.field]=="number"){const i=e[n.field];n.min!==void 0&&i<n.min&&t.addError(n.message||`Field '${n.field}' must be at least ${n.min}`),n.max!==void 0&&i>n.max&&t.addError(n.message||`Field '${n.field}' must be at most ${n.max}`)}}function Ue(n,e,t){n.field&&n.pattern&&typeof e[n.field]=="string"&&(new RegExp(n.pattern).test(e[n.field])||t.addError(n.message||`Field '${n.field}' does not match pattern ${n.pattern}`))}function _e(n,e,t){if(n.field&&n.dependsOn&&n.expression)try{O(n.expression,e)||t.addError(n.message||`Field '${n.field}' dependency validation failed`)}catch(i){t.addWarning(`Failed to evaluate dependency expression: ${i}`)}}function Ae(n,e,t){if(n.expression)try{O(n.expression,e)||t.addError(n.message||"Custom validation failed")}catch(i){t.addWarning(`Failed to evaluate custom expression: ${i}`)}}function Oe(n){return(e,t)=>{console.warn(`External validation module not implemented: ${n}`),t.addWarning(`External validation module not yet supported: ${n}`)}}function qe(n){return n.module?Ke(n.module):(e,t)=>{const i={...e};if(n.addFields)for(const[s,o]of Object.entries(n.addFields))i[s]=je(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]=Le(i[s],o));return i}}function Ke(n){return(e,t)=>(console.warn(`External transform module not implemented: ${n}`),e)}function je(n){if(typeof n=="string"&&n.startsWith("$")){const e=ke[n];if(e)return e()}return n}function Le(n,e){switch(e){case"trim":return n.trim();case"lowercase":return n.toLowerCase();case"uppercase":return n.toUpperCase();case"camelCase":return Me(n);case"kebabCase":return ze(n);default:return n}}function Me(n){return n.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^./,e=>e.toLowerCase())}function ze(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function O(n,e){try{let t=n;for(const[i,s]of Object.entries(e)){const o=typeof s=="string"?`"${s}"`:String(s);t=t.replace(new RegExp(`\\b${i}\\b`,"g"),o)}if(t.includes("!==")){const[i,s]=t.split("!==").map(o=>o.trim());return i!==s}if(t.includes("===")){const[i,s]=t.split("===").map(o=>o.trim());return i===s}return t.includes("||")?t.split("||").map(s=>s.trim()).some(s=>O(s,e)):t.includes("&&")?t.split("&&").map(s=>s.trim()).every(s=>O(s,e)):!1}catch(t){return console.error("Expression evaluation failed:",t),!1}}const X=n=>(e,t)=>{var c;const i=n[t].remote,s=n[t].section||"default",o=((c=n[t].contributes)==null?void 0:c.experiences)??{};return Object.keys(o).forEach(l=>{const u=o[l];e.experiences[l]={...u,remote:i,sectionId:s}}),w().getAllExtensionPoints().forEach(l=>{var m;const{contributionKey:u}=l.config,d=(m=n[t].contributes)==null?void 0:m[u];d&&(e[u]||(e[u]={}),Array.isArray(d)?d.forEach(f=>{f&&f.id&&(e[u][f.id]={...f,remote:i,sectionId:s})}):typeof d=="object"&&Object.entries(d).forEach(([f,g])=>{e[u][f]={...g,id:f,remote:i,sectionId:s}}))}),e};async function ee(n){const e=n??window.KosPlugins.__dynamicRemotes;if(window.KosPlugins.extensions){const o=window.KosPlugins.extensions;return{extensionPoints:o,getExtensions:r=>o[r]||[],remotes:e,extensions:window.KosPlugins.__extensions}}const t=window.KosPlugins.__extensions??await ne(e),i={};if(t)for(const o of Object.keys(t))i[o]=Object.values(t[o]||{});return window.KosPlugins.extensions=i,{extensionPoints:i,getExtensions:o=>i[o]||[],remotes:e,extensions:t}}const W={controlPourDefinitions:{},experiences:{}};function te(n){return n?Object.keys(n).reduce(X(n),{...W}):W}async function ne(n){if(!n)return window.KosPlugins=window.KosPlugins||{},{};for(const o of Object.values(n)){try{if(o.extensions&&Array.isArray(o.extensions)){const r=o.extensions.filter(a=>a&&typeof a=="object"&&"id"in a).map(a=>Re(a));if(r.length>0){console.info(`Registering ${r.length} JSON extension point(s) from ${o.remote}`);for(const a of r)try{Q(a).register(),console.debug(`Registered JSON extension point: ${a.id}`)}catch(c){console.error(`Failed to register JSON extension point '${a.id}' from ${o.remote}:`,c)}}}}catch(r){console.warn(`Failed to parse JSON extension points from ${o.remote}:`,r)}if(o.init)try{const r=await N.loadRemoteModule(o.remote,"./InitPlugin");if(r.default){const a=new r.default;a==null||a.register()}}catch(r){console.warn(`Failed to load InitPlugin from ${o.remote}:`,r)}}const e=te(n),t=e.experiences,s=xe({},e,t);return I.setContext({extensions:s,contributions:e}),window.KosPlugins=window.KosPlugins||{},window.KosPlugins.__extensions=s,s}async function Be(n){const{getExtensions:e}=await ee();return e(n)}const ie=(n=null)=>(n||window.location.search.replace("?","")).split("&").map(e=>{const[t,i]=e.split("=");return[t,decodeURIComponent(i||"")]}).reduce((e,[t,i])=>(e[t]=i,e),{}),He=()=>{const n=window.location.origin,e=ie();return(e==null?void 0:e.host)||n},We=async n=>{var B;const e=He(),t=n??{},{pluginBaseUrl:i=e,pluginApiPath:s,overrides:o={},pluginContext:r}=t;console.log("[initialize-plugins] Config received:",{propsPluginBaseUrl:n==null?void 0:n.pluginBaseUrl,defaultHost:e,resolvedPluginBaseUrl:i,pluginApiPath:s});const a=s?`${i}${s}`:`${i}/api/kos/ui/plugins/contexts`;console.log(`initialize-plugins: Using Plugin Framework. Fetching plugins from ${a}`);const l=await(await fetch(a)).json(),u=ie(),d=u.pluginDevServers?u.pluginDevServers.split(",").map(b=>b.trim()):[];if(d.length>0){console.log("[initialize-plugins] Detected third-party plugin dev servers:",d);const p=(await Promise.all(d.map(async h=>{try{console.log(`[initialize-plugins] Fetching from dev server: ${h}`);const C=await fetch(`${h}/api/kos/ui/plugins/contexts`);if(!C.ok)return console.warn(`[initialize-plugins] Dev server ${h} returned ${C.status}`),null;const S=await C.json();return{serverUrl:h,data:S}}catch(C){return console.warn(`[initialize-plugins] Failed to fetch from dev server ${h}:`,C),null}}))).filter(h=>h!==null&&h.data&&h.data.status===200);if(p.length>0){console.log(`[initialize-plugins] Merging ${p.length} dev server plugin(s)`);const h={};p.forEach(({serverUrl:C,data:S})=>{var $;($=S.data)==null||$.forEach(k=>{var F;let V=(F=l.data)==null?void 0:F.find(y=>y.name===k.name);V||(V={name:k.name,plugins:[]},l.data=l.data||[],l.data.push(V)),k.plugins.forEach(y=>{var x;V.plugins.push(y),h[y.id]=`${C}/`,console.log(`[initialize-plugins] Added dev plugin: ${(x=y.descriptor)==null?void 0:x.id} from ${C}`)})})}),l.overrides={...l.overrides||{},...h},console.log("[initialize-plugins] Dev server overrides:",h)}}const m={...o,...l.overrides||{}};l.overrides&&console.log("[initialize-plugins] Using overrides from response:",l.overrides),Object.keys(m).length>0&&console.log("[initialize-plugins] Merged overrides:",m);const f=typeof(r==null?void 0:r.context)=="string"?[r.context]:(r==null?void 0:r.context)||[],g=(B=l.data)==null?void 0:B.filter(b=>f.length===0||f.includes(b.name)).flatMap(b=>b.plugins.map(p=>({...p,name:b.name}))??[]),P=r==null?void 0:r.group,v=g==null?void 0:g.reduce((b,p)=>{const h=(m==null?void 0:m[p.id])??`${i}${p.path}`;if(p.descriptor){const S=(p.descriptor.extensions||[]).reduce((y,x)=>{const T=x.groups||[];return(!P||T.includes(P))&&y.push(x),y},[]),$=p.descriptor.contributes||{};let k=!1;const V=Object.keys($).reduce((y,x)=>{if(Array.isArray($[x])){const T=($[x]||[]).filter(re=>{const ae=re.groups||[];return!P||ae.includes(P)});k=k||T.length>0,y[x]=T}else y[x]=$[x],k=Object.keys($[x]).length>0;return y},{}),F=!!p.descriptor.init&&(S.length>0||k);b[p.id]={section:p.name,basePath:`${h}remoteEntry.js`,extensions:S,contributes:V,remote:p.descriptor.id,init:F}}else console.error(`initialize-plugins: Plugin ${p.id} does not have a descriptor`);return b},{});window.KosPlugins=window.KosPlugins||{},window.KosPlugins.__dynamicRemotes=v;const z=Object.keys(v).reduce((b,p)=>{const h=v[p].remote;return b[h]=v[p].basePath,b},{});return N.setRemoteDefinitions(z),z};class Ge{constructor(e){E(this,"extensions");E(this,"listeners");E(this,"contributionUnsubscribe",null);this.extensions=e,this.listeners=new Map,this.subscribeToContributionChanges()}getExtensions(e,t=!1){const i=this.extensions[e]||{};return t?i:Object.entries(i).reduce((s,[o,r])=>(I.isEnabled(o)&&(s[o]=r),s),{})}subscribe(e,t){if(typeof t!="function")throw new TypeError("ReactiveExtensionRegistry.subscribe: listener must be a function");return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{var i,s;(i=this.listeners.get(e))==null||i.delete(t),((s=this.listeners.get(e))==null?void 0:s.size)===0&&this.listeners.delete(e)}}subscribeToContributionChanges(){this.contributionUnsubscribe=I.subscribe(e=>this.handleContributionChange(e))}handleContributionChange(e){const{contributionId:t,extensionPoint:i,enabled:s}=e;if(!this.listeners.has(i))return;this.extensions[i];const o=J(this.getExtensions(i)),r=s?"contribution-enabled":"contribution-disabled",a=this.listeners.get(i);if(a){const c={extensionPoint:i,changeType:r,affectedContribution:t,newBest:o==null?void 0:o.id,timestamp:e.timestamp};a.forEach(l=>{try{l(c)}catch(u){console.error(`ReactiveExtensionRegistry: Error in listener for '${i}':`,u)}})}}destroy(){var e;(e=this.contributionUnsubscribe)==null||e.call(this),this.contributionUnsubscribe=null,this.listeners.clear()}}function G(n){const e=n.match(/^(\d+)\.(\d+)\.\d+(?:-\S+)?$/);if(!e)throw new Error(`Invalid version format: ${n}`);const[t,i,s]=e;return`${i}.${s}.0`}function Je(n,e){var l,u;e!=null&&e.sdkVersion&&console.log("sdkVersion",e.sdkVersion),e!=null&&e.ddkVersion&&console.log("ddkVersion",e.ddkVersion);const t=G((e==null?void 0:e.sdkVersion)||"0.2.0"),i=G((e==null?void 0:e.ddkVersion)||"0.2.0");console.log(`Using DDK version: ${i}`),console.log(`Using SDK version: ${t}`);const s=n==null?void 0:n.name;if(!s)throw new Error("KOS Configuration should be added. Project name not found in config");const r=((e==null?void 0:e.pluginPath)||"kos.ui.plugin").split(".").reduce((d,m)=>(console.log(`Accessing key: ${m}`),d&&d[m]?d[m]:void 0),n),a=r==null?void 0:r.id;if(!a)throw new Error("KOS Configuration should be added. Plugin ID not found in config");const c=Object.keys(((l=r==null?void 0:r.contributes)==null?void 0:l.views)||{}).reduce((d,m)=>(r.contributes.views[m].forEach(g=>{d[`./${g.component}`]=g.location}),d),{});return Object.values(((u=r==null?void 0:r.contributes)==null?void 0:u.experiences)||{}).forEach(d=>{c[`./${d.component}`]=d.location}),r!=null&&r.init&&(c["./InitPlugin"]="./src/app/init.ts"),{name:s,exposes:c,library:{type:"var",name:a},additionalShared:[{libraryName:"@kosdev-code/kos-ui-plugin",sharedConfig:{singleton:!0,eager:!1,requiredVersion:`~${i}`}},{libraryName:"react",sharedConfig:{singleton:!0,eager:!1,strictVersion:!0,requiredVersion:"18.2.0"}},{libraryName:"react-dom",sharedConfig:{singleton:!0,eager:!1,strictVersion:!0,requiredVersion:"18.2.0"}},{libraryName:"@kosdev-code/kos-ui-sdk",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${t}`}},{libraryName:"@kosdev-code/kos-dispense-sdk",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${t}`}},{libraryName:"@kosdev-code/kos-freestyle-sdk",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${t}`}},{libraryName:"@kosdev-code/kos-ddk-components",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${i}`}},{libraryName:"@kosdev-code/kos-ddk-model-components",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${i}`}},{libraryName:"@kosdev-code/kos-ddk-models",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${i}`}},{libraryName:"@kosdev-code/kos-ddk",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${i}`}},{libraryName:"@kosdev-code/kos-ddk-styles",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${i}`}},{libraryName:"@emotion/styled",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"~11.11.0"}},{libraryName:"@emotion/react",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"~11.11.0"}},{libraryName:"reflect-metadata",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^0.2.2"}},{libraryName:"mobx",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^6.9.0"}},{libraryName:"loglevel",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^1.8.1"}},{libraryName:"robot3",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^0.4.0"}},{libraryName:"mobx-react-lite",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^3.4.3"}},{libraryName:"react-router-dom",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^6.11.2"}},{libraryName:"date-fns",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^2.30.0"}},{libraryName:"@use-gesture/react",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^10.3.0"}},{libraryName:"@react-spring/web",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^9.7.3"}},{libraryName:"react-simple-keyboard",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^3.6.13"}},{libraryName:"expr-eval",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:"^2.0.2"}},{libraryName:"zod",sharedConfig:{singleton:!0,eager:!0,strictVersion:!1,requiredVersion:"^3.25.0"}}]}}const M=D.z.object({id:D.z.string().min(1,"ID is required").describe("Unique identifier for this extension"),title:D.z.string().min(1,"Title is required").describe("Display title shown in the interface"),namespace:D.z.string().min(1,"Namespace is required").describe("Namespace for organizing related extensions"),experienceId:D.z.string().min(1,"Experience ID is required").describe("Reference to the UI component experience for rendering")}),se=M.extend({rank:D.z.number().int().min(0).optional().describe("Optional ranking for ordering (higher = preferred)")});function Ze(n,e,t){const i=n.safeParse(e);return i.success?!0:(i.error.errors.forEach(s=>{t.addError(`${s.path.join(".")}: ${s.message}`)}),!1)}function Ye(n,e,t){e&&!e.includes(".")&&t.addWarning(`${n} '${e}' should typically include dot notation (e.g., 'category.item')`)}function oe(n,e,t=1e3){n!==void 0&&n>t&&e.addWarning(`Rank ${n} seems unusually high - consider using lower values for better ordering`)}function Qe(n,e={}){return(e.rankable?se:M).extend(n)}function Xe(n,e,t=1e3){typeof n=="object"&&n!==null&&"rank"in n&&oe(n.rank,e,t)}class A{static getExtensionPoints(e,t={}){const{includeLegacyExtensions:i=!0,includeEmptyExtensionPoints:s=!0}=t,r=w().getAllExtensionPoints(),a=[];return r.forEach(c=>{const l=Object.values((e==null?void 0:e[c.id])||{});!s&&l.length===0||a.push({id:c.id,displayName:c.config.displayName,description:c.config.description,source:"simplified",metadata:c.config.metadata,pluginCount:l.length,plugins:l})}),i&&e&&Object.entries(e).forEach(([c,l])=>{if(a.some(d=>d.id===c))return;const u=Object.values(l||{});!s&&u.length===0||a.push({id:c,source:"legacy",pluginCount:u.length,plugins:u})}),a.sort((c,l)=>c.id.localeCompare(l.id))}static filterExtensionPoints(e,t){if(!t.trim())return e;const i=t.toLowerCase();return e.filter(s=>{var o,r,a,c,l,u;return s.id.toLowerCase().includes(i)||((o=s.displayName)==null?void 0:o.toLowerCase().includes(i))||((r=s.description)==null?void 0:r.toLowerCase().includes(i))||((c=(a=s.metadata)==null?void 0:a.category)==null?void 0:c.toLowerCase().includes(i))||((u=(l=s.metadata)==null?void 0:l.tags)==null?void 0:u.some(d=>d.toLowerCase().includes(i)))})}static calculateHealthStats(e){const t=e.length,i=e.filter(c=>c.pluginCount>0).length,s=e.reduce((c,l)=>c+l.pluginCount,0),o=e.filter(c=>c.source==="simplified").length,r=e.filter(c=>c.source==="legacy").length,a=e.filter(c=>{var l;return(l=c.metadata)==null?void 0:l.deprecated}).length;return{totalExtensionPoints:t,extensionPointsWithPlugins:i,totalPlugins:s,simplifiedExtensionPoints:o,legacyExtensionPoints:r,deprecatedExtensionPoints:a}}static analyzePlugin(e){const t=!!e.component,i=typeof e.rank=="number",s=e.rank||0,o=[];if(t?o.push("UI Component"):o.push("Background Service"),i&&o.push(`Rank: ${s}`),e.namespace){const a=e.namespace;a.includes("kos")||a.includes("ddk")?o.push("First-party"):o.push("Third-party")}e.modalMode&&o.push(`Modal: ${e.modalMode}`);let r="healthy";return e.remote||(r="warning"),{hasComponent:t,hasRank:i,healthStatus:r,capabilities:o}}static getExtensionPointById(e,t){return e.find(i=>i.id===t)}static validateExtensionPointId(e){const t=[],i=[];e.includes(".")||(t.push("Extension point ID should contain at least one dot (namespace.feature)"),i.push('Use format like "ddk.myFeature" or "app.myFeature"'));const s=e.split(".");s.length<2&&t.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(a=>/[A-Z]/.test(a))&&(t.push("Extension point ID parts should be lowercase"),i.push('Use kebab-case or dot notation: "my.feature" not "my.myFeature"')),{isValid:t.length===0,issues:t,suggestions:i}}static validatePluginDescriptor(e){const t=[],i=[],s=[],o=[];if(e.id?e.id.match(/^[a-z0-9-]+$/)||o.push("Plugin ID convention: use lowercase letters, numbers, and hyphens (e.g., 'my-awesome-plugin')"):(s.push("id"),t.push("Plugin descriptor must have an 'id' field")),!e.contributes)i.push("Plugin has no contributions - it won't extend any functionality"),o.push("Add a 'contributes' section with plugin contributions");else{const r=Object.keys(e.contributes);r.length===0&&i.push("Plugin contributes section is empty"),r.forEach(a=>{const c=e.contributes[a];if(!Array.isArray(c)){t.push(`Contribution '${a}' must be an array`);return}c.forEach((l,u)=>{l.id||t.push(`Contribution ${a}[${u}] missing required 'id' field`),a==="experiences"&&l.component&&!l.location&&(t.push(`Experience '${l.id}' has component but no location`),o.push("Add 'location' field pointing to the component file")),["cui","utilities","settings","setup"].includes(a)&&(l.title||i.push(`${a} contribution '${l.id}' missing 'title' field`),l.namespace||i.push(`${a} contribution '${l.id}' missing 'namespace' field`),l.experienceId||t.push(`${a} contribution '${l.id}' missing required 'experienceId' field`))})})}return e.init!==void 0&&typeof e.init!="boolean"&&t.push("'init' field must be a boolean value"),{isValid:t.length===0&&s.length===0,errors:t,warnings:i,missingRequired:s,suggestions:o}}static checkPluginCompatibility(e,t){const i=[],s=[],o=[],r=[];if(!e.contributes)return{isCompatible:!0,issues:["Plugin has no contributions to check"],missingExtensionPoints:[],incompatibleTypes:[],suggestions:[]};const a=w(),c=new Set(t.map(l=>l.id));return Object.entries(e.contributes).forEach(([l,u])=>{this.getExpectedExtensionPoints(l).forEach(g=>{c.has(g)||(s.push(g),i.push(`Extension point '${g}' not available for '${l}' contributions`),r.push(`Ensure the extension point '${g}' is registered`))});const f=a.getAllExtensionPoints().find(g=>g.config.contributionKey===l);f&&u.length>0&&u.forEach((g,P)=>{f.config.isRankable&&typeof g.rank!="number"&&(i.push(`${l}[${P}]: Extension point '${f.id}' expects 'rank' property`),r.push("Add 'rank' property with numeric value for ordering")),f.config.hasView&&!g.experienceId&&(i.push(`${l}[${P}]: Extension point '${f.id}' expects 'experienceId' for view-based contributions`),r.push("Add 'experienceId' property linking to an experience definition"))})}),{isCompatible:i.length===0,issues:i,missingExtensionPoints:s,incompatibleTypes:o,suggestions:r}}static getExpectedExtensionPoints(e){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:[]}[e]||[]}static analyzePluginDescriptor(e,t){const i=this.validatePluginDescriptor(e),s=this.checkPluginCompatibility(e,t),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"),e.contributes&&Object.keys(e.contributes).length===1&&o.push("Consider adding more contribution types to increase plugin value"),{validation:i,compatibility:s,recommendations:o}}}class et{static generateFullDocumentation(e,t={}){const{includeUsageExamples:i=!0,includeTypeDefinitions:s=!0,includeLegacyExtensions:o=!0,includePluginHealth:r=!0}=t,a=A.getExtensionPoints(e,{includeLegacyExtensions:o,includeEmptyExtensionPoints:!0}),c=A.calculateHealthStats(a);let l=this.generateHeader(c);return l+=this.generateTableOfContents(a),l+=this.generateOverviewSection(a,c),a.forEach(u=>{l+=this.generateExtensionPointSection(u,{includeUsageExamples:i,includePluginHealth:r})}),s&&(l+=this.generateTypeDefinitionsSection(a)),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(e){return`# KOS Plugin Extension Points Reference
|
|
2
|
+
|
|
3
|
+
**Generated**: ${new Date().toLocaleString()}
|
|
4
|
+
|
|
5
|
+
## System Overview
|
|
6
|
+
|
|
7
|
+
- **Total Extension Points**: ${e.totalExtensionPoints}
|
|
8
|
+
- **Extension Points with Plugins**: ${e.extensionPointsWithPlugins}
|
|
9
|
+
- **Total Active Plugins**: ${e.totalPlugins}
|
|
10
|
+
- **Simplified Extension Points**: ${e.simplifiedExtensionPoints}
|
|
11
|
+
- **Legacy Extension Points**: ${e.legacyExtensionPoints}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
`}static generateTableOfContents(e){let t=`## Table of Contents
|
|
16
|
+
|
|
17
|
+
`;return t+=`- [Overview](#overview)
|
|
18
|
+
`,t+=`- [Extension Points](#extension-points)
|
|
19
|
+
`,e.forEach(i=>{const s=i.id.toLowerCase().replace(/\./g,"");t+=` - [${i.id}](#${s}) (${i.pluginCount} plugins)
|
|
20
|
+
`}),t+=`- [Type Definitions](#type-definitions)
|
|
21
|
+
`,t+=`- [Contribution Guide](#contribution-guide)
|
|
22
|
+
`,t+=`- [Troubleshooting](#troubleshooting)
|
|
23
|
+
|
|
24
|
+
`,t}static generateOverviewSection(e,t){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
|
+
`,t.deprecatedExtensionPoints>0&&(i+=`### ⚠️ Deprecated Extension Points
|
|
33
|
+
|
|
34
|
+
`,i+=`${t.deprecatedExtensionPoints} extension points are marked as deprecated. `,i+=`Consider migrating to newer alternatives.
|
|
35
|
+
|
|
36
|
+
`),i+`---
|
|
37
|
+
|
|
38
|
+
`}static generateExtensionPointSection(e,t){var r;const{includeUsageExamples:i=!0,includePluginHealth:s=!0}=t;let o=`## ${e.id}
|
|
39
|
+
|
|
40
|
+
`;if(e.displayName&&(o+=`**Display Name**: ${e.displayName}
|
|
41
|
+
|
|
42
|
+
`),e.description&&(o+=`**Description**: ${e.description}
|
|
43
|
+
|
|
44
|
+
`),o+=`**Source**: ${e.source}
|
|
45
|
+
`,o+=`**Active Plugins**: ${e.pluginCount}
|
|
46
|
+
|
|
47
|
+
`,e.metadata){o+=`### Metadata
|
|
48
|
+
|
|
49
|
+
`;const a=e.metadata;a.category&&(o+=`- **Category**: ${a.category}
|
|
50
|
+
`),a.owner&&(o+=`- **Owner**: ${a.owner}
|
|
51
|
+
`),a.since&&(o+=`- **Since**: ${a.since}
|
|
52
|
+
`),(r=a.tags)!=null&&r.length&&(o+=`- **Tags**: ${a.tags.join(", ")}
|
|
53
|
+
`),a.deprecated&&(o+=`- **⚠️ Status**: Deprecated
|
|
54
|
+
`),o+=`
|
|
55
|
+
`}return i&&(o+=this.generateUsageExamples(e)),e.plugins.length>0?o+=this.generatePluginList(e.plugins,s):o+=`### Plugins
|
|
56
|
+
|
|
57
|
+
No plugins currently registered for this extension point.
|
|
58
|
+
|
|
59
|
+
`,o+=this.generateSchemaFieldsSection(e),o+=this.generateContributionStructure(e),o+`---
|
|
60
|
+
|
|
61
|
+
`}static generateUsageExamples(e){let t=`### Usage Examples
|
|
62
|
+
|
|
63
|
+
`;return e.source==="simplified"&&(t+=`#### Using Simplified API
|
|
64
|
+
|
|
65
|
+
`,t+="```typescript\n",t+=`// Import the extension point
|
|
66
|
+
`,t+=`import { ${this.getExtensionPointImportName(e.id)} } from './extension-points';
|
|
67
|
+
|
|
68
|
+
`,t+=`// Use extension component hook
|
|
69
|
+
`,t+=`import { useExtensionComponent } from '@kosdev-code/kos-ui-plugin';
|
|
70
|
+
|
|
71
|
+
`,t+=`const Component = useExtensionComponent(${this.getExtensionPointImportName(e.id)});
|
|
72
|
+
|
|
73
|
+
`,t+=`if (Component) {
|
|
74
|
+
`,t+=` return (
|
|
75
|
+
`,t+=` <Component
|
|
76
|
+
`,t+=` customProp="value"
|
|
77
|
+
`,t+=` onComplete={handleComplete}
|
|
78
|
+
`,t+=` />
|
|
79
|
+
`,t+=` );
|
|
80
|
+
`,t+=`}
|
|
81
|
+
|
|
82
|
+
`,t+=`// Or use with dynamic component
|
|
83
|
+
`,t+=`const [Component] = useDynamicComponent({
|
|
84
|
+
`,t+=` extension: ${this.getExtensionPointImportName(e.id)}.id
|
|
85
|
+
`,t+=`});
|
|
86
|
+
`,t+="```\n\n",t+=`#### Using Typed Hooks
|
|
87
|
+
|
|
88
|
+
`,t+="```typescript\n",t+=`// Get all extensions with type safety
|
|
89
|
+
`,t+=`const extensions = useExtensions(${this.getExtensionPointImportName(e.id)});
|
|
90
|
+
|
|
91
|
+
`,t+=`// Get best extension
|
|
92
|
+
`,t+=`const bestExtension = useBest(${this.getExtensionPointImportName(e.id)});
|
|
93
|
+
|
|
94
|
+
`,t+=`// Check availability
|
|
95
|
+
`,t+=`const hasExtensions = useHasExtensions(${this.getExtensionPointImportName(e.id)});
|
|
96
|
+
`,t+="```\n\n"),t+=`#### Using DynamicComponent
|
|
97
|
+
|
|
98
|
+
`,t+="```typescript\n",t+=`import { DynamicComponent } from '@kosdev-code/kos-ui-plugin';
|
|
99
|
+
`,t+=`import { ${this.getExtensionPointImportName(e.id)} } from './extension-points';
|
|
100
|
+
|
|
101
|
+
`,t+=`<DynamicComponent
|
|
102
|
+
`,t+=` extension={${this.getExtensionPointImportName(e.id)}.id}
|
|
103
|
+
`,t+=` props={{ customData: "value" }}
|
|
104
|
+
`,t+=` fallback={<div>Loading...</div>}
|
|
105
|
+
`,t+=`/>
|
|
106
|
+
`,t+="```\n\n",t+=`#### Using Context
|
|
107
|
+
|
|
108
|
+
`,t+="```typescript\n",t+=`import { useKosPluginsContext } from '@kosdev-code/kos-ui-plugin';
|
|
109
|
+
`,t+=`import { ${this.getExtensionPointImportName(e.id)} } from './extension-points';
|
|
110
|
+
|
|
111
|
+
`,t+=`const { getExtensions } = useKosPluginsContext();
|
|
112
|
+
`,t+=`const extensions = getExtensions(${this.getExtensionPointImportName(e.id)}.id);
|
|
113
|
+
`,t+="```\n\n",t}static generatePluginList(e,t){let i=`### Active Plugins
|
|
114
|
+
|
|
115
|
+
`;return e.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
|
+
`),t){const o=A.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(e){if(e.source!=="simplified")return"";const i=w().getExtensionPoint(e.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(r=>{const a=r.name,c=r.type||"unknown",l=r.required?"✅":"⭕",u=r.description||"-";o+=`| \`${a}\` | ${c} | ${l} | ${u} |
|
|
130
|
+
`}),o+=`
|
|
131
|
+
`,o}static generateContributionStructure(e){let t=`### Contribution Structure
|
|
132
|
+
|
|
133
|
+
`;t+=`To contribute to this extension point, add the following to your plugin descriptor:
|
|
134
|
+
|
|
135
|
+
`,t+="```json\n",t+=`{
|
|
136
|
+
`,t+=` "id": "your-plugin-id",
|
|
137
|
+
`,t+=` "contributes": {
|
|
138
|
+
`;const i=this.inferContributionKey(e);t+=` "${i}": [
|
|
139
|
+
`,t+=` {
|
|
140
|
+
`;const s=this.getSchemaFieldsForContribution(e);if(s.length>0){const r=[];s.forEach(a=>{let c;a.name==="id"?c='"your-contribution-id"':a.name==="title"?c='"Your Contribution Title"':a.name==="namespace"?c='"your-namespace"':a.name==="experienceId"?c='"your-experience-id"':a.name==="dashboardKey"?c='"your-dashboard-key"':a.name==="rank"?c="10":a.type==="string"?c=`"your-${a.name}"`:a.type==="number"?c="0":a.type==="boolean"?c="false":c=`"your-${a.name}"`,(a.required||["experienceId","rank","dashboardKey"].includes(a.name))&&r.push(` "${a.name}": ${c}`)}),t+=r.join(`,
|
|
141
|
+
`)}else{t+=` "id": "your-contribution-id",
|
|
142
|
+
`,t+=` "title": "Your Contribution Title",
|
|
143
|
+
`,t+=' "namespace": "your-namespace"',this.isViewBasedExtensionPoint(e)&&(t+=`,
|
|
144
|
+
"experienceId": "your-experience-id"`),this.isRankableExtensionPoint(e)&&(t+=`,
|
|
145
|
+
"rank": 10`);const r=this.getSpecificFields(e);r.length>0&&(t+=`,
|
|
146
|
+
${r.join(`,
|
|
147
|
+
`)}`)}return t+=`
|
|
148
|
+
}
|
|
149
|
+
`,t+=" ]",(s.some(r=>r.name==="experienceId")||this.isViewBasedExtensionPoint(e))&&(t+=`,
|
|
150
|
+
"experiences": {
|
|
151
|
+
`,t+=` "your-experience-id": {
|
|
152
|
+
`,t+=` "id": "your-experience-id",
|
|
153
|
+
`,t+=` "component": "YourComponent",
|
|
154
|
+
`,t+=` "location": "./src/components/YourComponent.tsx"
|
|
155
|
+
`,t+=` }
|
|
156
|
+
`,t+=" }"),t+=`
|
|
157
|
+
}
|
|
158
|
+
`,t+=`}
|
|
159
|
+
`,t+="```\n\n",t}static generateTypeDefinitionsSection(e){let t=`## Type Definitions
|
|
160
|
+
|
|
161
|
+
`;return t+=`### Extension Point Types
|
|
162
|
+
|
|
163
|
+
`,t+="```typescript\n",e.forEach(i=>{i.source==="simplified"&&(t+=`// ${i.id}
|
|
164
|
+
`,t+=`interface ${this.getExtensionPointTypeName(i.id)} {
|
|
165
|
+
`,t+=` id: "${i.id}";
|
|
166
|
+
`,t+=` displayName?: "${i.displayName||""}";
|
|
167
|
+
`,t+=` description?: "${i.description||""}";
|
|
168
|
+
`,t+=`}
|
|
169
|
+
|
|
170
|
+
`)}),t+="```\n\n",t+=`### Plugin Contribution Types
|
|
171
|
+
|
|
172
|
+
`,t+="```typescript\n",t+=`interface BaseContribution {
|
|
173
|
+
`,t+=` id: string;
|
|
174
|
+
`,t+=` title: string;
|
|
175
|
+
`,t+=` namespace: string;
|
|
176
|
+
`,t+=`}
|
|
177
|
+
|
|
178
|
+
`,t+=`interface ViewBasedContribution extends BaseContribution {
|
|
179
|
+
`,t+=` experienceId: string;
|
|
180
|
+
`,t+=`}
|
|
181
|
+
|
|
182
|
+
`,t+=`interface RankableContribution extends BaseContribution {
|
|
183
|
+
`,t+=` rank: number;
|
|
184
|
+
`,t+=`}
|
|
185
|
+
`,t+="```\n\n",t}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(e){var r;const i=w().getExtensionPoint(e);if((r=i==null?void 0:i.config.metadata)!=null&&r.exportName)return i.config.metadata.exportName;const s=e.split(".");return(s.length>1?s.slice(1):s).map(a=>a.split("-").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("")).join("")+"Extension"}static getExtensionPointTypeName(e){return this.getExtensionPointImportName(e)+"Type"}static getHealthEmoji(e){switch(e){case"healthy":return"✅";case"warning":return"⚠️";case"error":return"❌";default:return"❓"}}static inferContributionKey(e){if(e.source==="simplified"){const r=w().getExtensionPoint(e.id);if(r!=null&&r.config.contributionKey)return r.config.contributionKey}const t=e.id.split("."),i=t[t.length-1];return{cui:"cui",utility:"utilities",utilities:"utilities",setup:"setupStep",settings:"settings",nav:"navViews",troubleAction:"troubleActions",controlPour:"controlPour"}[i]||i+"s"}static isViewBasedExtensionPoint(e){if(e.source==="simplified"){const i=w().getExtensionPoint(e.id);return(i==null?void 0:i.config.hasView)||!1}return e.plugins.some(t=>t.experienceId)}static isRankableExtensionPoint(e){if(e.source==="simplified"){const i=w().getExtensionPoint(e.id);return(i==null?void 0:i.config.isRankable)||!1}return e.plugins.some(t=>typeof t.rank=="number")}static getSchemaFieldsForContribution(e){if(e.source!=="simplified")return[];const i=w().getExtensionPoint(e.id);return i!=null&&i.getSchemaFieldInfo?i.getSchemaFieldInfo():[]}static getSpecificFields(e){const t=[];switch(this.inferContributionKey(e)){case"utilities":t.push('"utilDescriptor": "your-util-descriptor"');break;case"setupStep":t.push('"setupDescriptor": "your-setup-descriptor"');break;case"settings":t.push('"settingsGroup": "your-settings-group"');break;case"navViews":t.push('"navDescriptor": "your-nav-descriptor"');break;case"troubleActions":t.push('"troubleType": "your-trouble-type"');break;case"cui":t.push('"cuiDescriptor": "your-cui-descriptor"');break}return t}}exports.BaseViewExtensionSchema=M;exports.ContributionRegistry=I;exports.DocumentationGenerator=et;exports.PluginDiscoveryService=A;exports.RankableViewExtensionSchema=se;exports.ReactiveExtensionRegistry=Ge;exports.contributionReducer=X;exports.createExtensionSchema=Qe;exports.createViewAwareTransform=Y;exports.defineExtensionPoint=Q;exports.generatePluginConfiguration=Je;exports.getContributions=te;exports.getExtensionPointRegistry=w;exports.getExtensionPointSchema=$e;exports.getExtensions=Be;exports.getValidationResults=we;exports.index=he;exports.initPluginManager=ee;exports.initializeKosPlugins=We;exports.loadExtensions=ne;exports.mf=N;exports.registry=q;exports.resolveBestExtension=J;exports.validateDescriptorFormat=Ye;exports.validateRank=oe;exports.validateRankIfPresent=Xe;exports.validateWithSchema=Ze;
|
|
266
|
+
//# sourceMappingURL=documentation-generator-CAlVz5vA.cjs.map
|