@kosdev-code/kos-ui-plugin 2.1.18 → 2.1.20
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 +938 -848
- 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-component.d.ts +11 -0
- package/lib/hooks/use-extension-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
package/types/plugins.d.ts
CHANGED
|
@@ -39,3 +39,11 @@ export type ProcessedContributions = {
|
|
|
39
39
|
controlPourDefinitions: Record<string, ProcessedControlPourDefinition>;
|
|
40
40
|
experiences: Record<string, ProcessedExperience>;
|
|
41
41
|
};
|
|
42
|
+
|
|
43
|
+
// Export contribution enablement types
|
|
44
|
+
export type {
|
|
45
|
+
ContributionStateChangeEvent,
|
|
46
|
+
DynamicContribution,
|
|
47
|
+
EnablementContext,
|
|
48
|
+
IContributionRegistry,
|
|
49
|
+
} from './contribution-enablement';
|
package/utils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./documentation-generator-CAlVz5vA.cjs");require("zod");function o(i,t,...n){return[i,t,...n].filter(Boolean).join(".")}exports.BaseViewExtensionSchema=e.BaseViewExtensionSchema;exports.ContributionRegistry=e.ContributionRegistry;exports.DocumentationGenerator=e.DocumentationGenerator;exports.PluginDiscoveryService=e.PluginDiscoveryService;exports.RankableViewExtensionSchema=e.RankableViewExtensionSchema;exports.ReactiveExtensionRegistry=e.ReactiveExtensionRegistry;exports.contributionReducer=e.contributionReducer;exports.createExtensionSchema=e.createExtensionSchema;exports.createViewAwareTransform=e.createViewAwareTransform;exports.defineExtensionPoint=e.defineExtensionPoint;exports.generatePluginConfiguration=e.generatePluginConfiguration;exports.getContributions=e.getContributions;exports.getExtensionPointRegistry=e.getExtensionPointRegistry;exports.getExtensionPointSchema=e.getExtensionPointSchema;exports.getExtensions=e.getExtensions;exports.getValidationResults=e.getValidationResults;exports.initPluginManager=e.initPluginManager;exports.initializeKosPlugins=e.initializeKosPlugins;exports.loadExtensions=e.loadExtensions;exports.registry=e.registry;exports.resolveBestExtension=e.resolveBestExtension;exports.validateDescriptorFormat=e.validateDescriptorFormat;exports.validateRank=e.validateRank;exports.validateRankIfPresent=e.validateRankIfPresent;exports.validateWithSchema=e.validateWithSchema;exports.extensionPointId=o;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
package/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../../../packages/sdk/kos-ui-plugin/src/lib/utils/extension-points/extension-point-types.ts","../../../../packages/sdk/kos-ui-plugin/src/lib/utils/processors/process-kos-config.ts"],"sourcesContent":["/**\n * Core types and interfaces for extension point system\n */\n\n// React import removed - component creation happens at runtime via hooks\nimport type { z } from \"zod\";\nimport type {\n BasePluginExtension,\n PluginExtensionsType,\n ProcessedContributions,\n} from \"../../../types/plugins\";\n\n/**\n * Validation context for collecting validation issues\n */\nexport interface ValidationContext {\n addError(message: string): void;\n addWarning(message: string): void;\n addInfo(message: string): void;\n hasErrors(): boolean;\n hasIssues(): boolean;\n getIssues(): { type: \"error\" | \"warning\" | \"info\"; message: string }[];\n}\n\n/**\n * Context provided to transform functions\n */\nexport interface TransformContext {\n remote: string;\n sectionId: string;\n experiences?: Record<string, any>;\n contributions: ProcessedContributions;\n}\n\n/**\n * Schema field information for documentation\n */\nexport interface SchemaFieldInfo {\n name: string;\n description?: string;\n type?: string;\n required?: boolean;\n}\n\n/**\n * Configuration for defining a new extension point\n */\nexport interface ExtensionPointConfig<\n TData = any,\n TProcessed = TData,\n _TProps = any\n> {\n /**\n * Unique identifier for this extension point\n * Convention: \"ddk.{feature}\" or \"ddk.{feature}.{sub-feature}\"\n */\n id: string;\n\n /**\n * Optional display name for documentation/discovery\n */\n displayName?: string;\n\n /**\n * Optional description for documentation/discovery\n */\n description?: string;\n\n /**\n * The contribution key in the plugin descriptor\n * e.g., \"myFeature\" maps to contributes.myFeature in kosdev-plugin.json\n */\n contributionKey: string;\n\n /**\n * Optional related extension points\n * For example, a main extension might have .view and .definition variants\n */\n relatedPoints?: {\n view?: string;\n definition?: string;\n [key: string]: string | undefined;\n };\n\n /**\n * Transform function to process raw contribution data\n * Allows custom processing logic while maintaining type safety\n */\n transform?: (data: TData, context: TransformContext) => TProcessed;\n\n /**\n * Optional validation function\n * Use context.addError/addWarning/addInfo to collect validation issues\n * Return \"skip\" to skip processing this contribution\n */\n validate?: (data: TData, context: ValidationContext) => \"skip\" | void;\n\n /**\n * Whether this extension point uses view/experience pattern\n * Default: false\n */\n hasView?: boolean;\n\n /**\n * Whether contributions should be ranked\n * Default: false\n */\n isRankable?: boolean;\n\n /**\n * Optional Zod schema for runtime validation and documentation\n * Provides both type safety and field introspection for Plugin Explorer\n */\n schema?: z.ZodSchema<TData>;\n\n /**\n * Metadata for discovery/documentation\n */\n metadata?: {\n category?: string;\n tags?: string[];\n since?: string;\n deprecated?: boolean;\n replacedBy?: string;\n owner?: string;\n /**\n * The actual export name of this extension point in the code\n * Used for documentation generation to show correct import statements\n */\n exportName?: string;\n };\n}\n\n/**\n * Props for extension point components\n */\nexport interface ExtensionComponentProps {\n /** Specific module to load (optional) */\n module?: string;\n /** Fallback component when extension not found */\n fallback?: React.ReactNode;\n}\n\n/**\n * Result of defining an extension point\n */\nexport interface ExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> {\n /**\n * The extension point configuration\n */\n config: ExtensionPointConfig<TData, TProcessed, TProps>;\n\n /**\n * Extension point ID for use in components\n */\n id: string;\n\n /**\n * Helper to get typed extensions (for future use with hooks)\n */\n getExtensions?: (\n extensions: PluginExtensionsType\n ) => Record<string, BasePluginExtension & { data: TProcessed }>;\n\n /**\n * Registration status\n */\n isRegistered: boolean;\n\n /**\n * Method to register this extension point\n */\n register: () => void;\n\n // Component property removed - use useExtensionComponent hook or createExtensionComponent factory at runtime\n\n /**\n * Get schema field information for documentation purposes\n * Returns field info that can be safely displayed by Plugin Explorer\n */\n getSchemaFieldInfo?: () => SchemaFieldInfo[];\n}\n\n/**\n * Extension point with hasView: true, guarantees Component property\n */\nexport interface ViewExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> extends ExtensionPointDefinition<TData, TProcessed, TProps> {\n Component: React.ComponentType<ExtensionComponentProps & TProps>;\n}\n\n/**\n * Type-safe extension point ID helper\n * Ensures consistent naming and helps with refactoring\n */\nexport function extensionPointId(\n namespace: string,\n feature: string,\n ...subFeatures: string[]\n): string {\n const parts = [namespace, feature, ...subFeatures].filter(Boolean);\n return parts.join(\".\");\n}\n","/* eslint-disable max-lines-per-function */\nimport type { Contributions } from \"../../../types/global\";\n\ninterface KosConfigView {\n id: string;\n title: string;\n component: string;\n location: string;\n}\n\ninterface KosPluginConfig {\n id: string;\n init?: boolean;\n contributes: Contributions;\n}\n\ninterface DDKConfig {\n name: string;\n kosdev: {\n ddk: {\n ncui: {\n plugin: KosPluginConfig;\n };\n };\n };\n}\n\ninterface CoreKosConfig {\n name: string;\n kos: {\n ui: {\n plugin: KosPluginConfig;\n };\n };\n}\n\nexport type KosConfig = DDKConfig | CoreKosConfig;\n\nfunction normalizeVersion(version: string): string {\n const match = version.match(/^(\\d+)\\.(\\d+)\\.\\d+(?:-\\S+)?$/);\n if (!match) {\n throw new Error(`Invalid version format: ${version}`);\n }\n const [_, major, minor] = match;\n return `${major}.${minor}.0`;\n}\n\nexport interface PluginOptions {\n sdkVersion?: string;\n ddkVersion?: string;\n pluginPath?: string;\n}\nexport function generatePluginConfiguration(\n config: KosConfig,\n options?: PluginOptions\n): any {\n if (options?.sdkVersion) {\n console.log(\"sdkVersion\", options.sdkVersion);\n }\n if (options?.ddkVersion) {\n console.log(\"ddkVersion\", options.ddkVersion);\n }\n const sdkVersion = normalizeVersion(options?.sdkVersion || \"0.2.0\");\n const ddkVersion = normalizeVersion(options?.ddkVersion || \"0.2.0\");\n\n console.log(`Using DDK version: ${ddkVersion}`);\n console.log(`Using SDK version: ${sdkVersion}`);\n const projectId = config?.name;\n if (!projectId) {\n throw new Error(\n \"KOS Configuration should be added. Project name not found in config\"\n );\n }\n const pluginPath = options?.pluginPath || \"kos.ui.plugin\";\n const pluginObj = pluginPath\n .split(\".\")\n .reduce<KosPluginConfig>((obj, key) => {\n console.log(`Accessing key: ${key}`);\n return obj && obj[key] ? obj[key] : undefined;\n }, config as unknown as KosPluginConfig);\n\n const pluginId = pluginObj?.id;\n if (!pluginId) {\n throw new Error(\n \"KOS Configuration should be added. Plugin ID not found in config\"\n );\n }\n const mfConfig = Object.keys(pluginObj?.contributes?.views || {}).reduce(\n (acc, key) => {\n const views = pluginObj.contributes.views[key];\n\n views.forEach((view) => {\n acc[`./${view.component}`] = view.location;\n });\n return acc;\n },\n {}\n );\n\n Object.values(pluginObj?.contributes?.experiences || {}).forEach(\n (experience) => {\n mfConfig[`./${experience.component}`] = experience.location;\n }\n );\n\n if (pluginObj?.init) {\n mfConfig[\"./InitPlugin\"] = \"./src/app/init.ts\";\n }\n\n return {\n name: projectId,\n exposes: mfConfig,\n library: { type: \"var\", name: pluginId },\n additionalShared: [\n {\n libraryName: \"@kosdev-code/kos-ui-plugin\",\n sharedConfig: {\n singleton: true,\n eager: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"react\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: true,\n requiredVersion: \"18.2.0\",\n },\n },\n\n {\n libraryName: \"react-dom\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: true,\n requiredVersion: \"18.2.0\",\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ui-sdk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${sdkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-dispense-sdk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${sdkVersion}`,\n },\n },\n\n {\n libraryName: \"@kosdev-code/kos-freestyle-sdk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${sdkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-components\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-model-components\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-models\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-styles\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@emotion/styled\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"~11.11.0\",\n },\n },\n {\n libraryName: \"@emotion/react\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"~11.11.0\",\n },\n },\n {\n libraryName: \"reflect-metadata\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^0.2.2\",\n },\n },\n {\n libraryName: \"mobx\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^6.9.0\",\n },\n },\n\n {\n libraryName: \"loglevel\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^1.8.1\",\n },\n },\n {\n libraryName: \"robot3\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^0.4.0\",\n },\n },\n {\n libraryName: \"mobx-react-lite\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^3.4.3\",\n },\n },\n {\n libraryName: \"react-router-dom\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^6.11.2\",\n },\n },\n {\n libraryName: \"date-fns\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^2.30.0\",\n },\n },\n {\n libraryName: \"@use-gesture/react\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^10.3.0\",\n },\n },\n {\n libraryName: \"@react-spring/web\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^9.7.3\",\n },\n },\n {\n libraryName: \"react-simple-keyboard\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^3.6.13\",\n },\n },\n {\n libraryName: \"expr-eval\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^2.0.2\",\n },\n },\n {\n libraryName: \"zod\",\n sharedConfig: {\n singleton: true,\n eager: true,\n strictVersion: false,\n requiredVersion: \"^3.25.0\",\n },\n },\n ],\n };\n}\n"],"names":["extensionPointId","namespace","feature","subFeatures","normalizeVersion","version","match","_","major","minor","generatePluginConfiguration","config","options","sdkVersion","ddkVersion","projectId","pluginObj","obj","key","pluginId","mfConfig","_a","acc","view","_b","experience"],"mappings":"yJA0MO,SAASA,EACdC,EACAC,KACGC,EACK,CAER,MADc,CAACF,EAAWC,EAAS,GAAGC,CAAW,EAAE,OAAO,OAAO,EACpD,KAAK,GAAG,CACvB,CC3KA,SAASC,EAAiBC,EAAyB,CACjD,MAAMC,EAAQD,EAAQ,MAAM,8BAA8B,EAC1D,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,2BAA2BD,CAAO,EAAE,EAEtD,KAAM,CAACE,EAAGC,EAAOC,CAAK,EAAIH,EAC1B,MAAO,GAAGE,CAAK,IAAIC,CAAK,IAC1B,CAOO,SAASC,EACdC,EACAC,EACK,SACDA,GAAA,MAAAA,EAAS,YACX,QAAQ,IAAI,aAAcA,EAAQ,UAAU,EAE1CA,GAAA,MAAAA,EAAS,YACX,QAAQ,IAAI,aAAcA,EAAQ,UAAU,EAE9C,MAAMC,EAAaT,GAAiBQ,GAAA,YAAAA,EAAS,aAAc,OAAO,EAC5DE,EAAaV,GAAiBQ,GAAA,YAAAA,EAAS,aAAc,OAAO,EAElE,QAAQ,IAAI,sBAAsBE,CAAU,EAAE,EAC9C,QAAQ,IAAI,sBAAsBD,CAAU,EAAE,EAC9C,MAAME,EAAYJ,GAAA,YAAAA,EAAQ,KAC1B,GAAI,CAACI,EACH,MAAM,IAAI,MACR,sEAAA,EAIJ,MAAMC,IADaJ,GAAA,YAAAA,EAAS,aAAc,iBAEvC,MAAM,GAAG,EACT,OAAwB,CAACK,EAAKC,KAC7B,QAAQ,IAAI,kBAAkBA,CAAG,EAAE,EAC5BD,GAAOA,EAAIC,CAAG,EAAID,EAAIC,CAAG,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Ac,CACZ,UAAW,GACX,MAAO,GACP,cAAe,GACf,gBAAiB,SAAA,CACnB,EAEF,CACE,YAAa,qBACb,aAAc,CACZ,UAAW,GACX,MAAO,GACP,cAAe,GACf,gBAAiB,SAAA,CACnB,EAEF,CACE,YAAa,oBACb,aAAc,CACZ,UAAW,GACX,MAAO,GACP,cAAe,GACf,gBAAiB,QAAA,CACnB,EAEF,CACE,YAAa,wBACb,aAAc,CACZ,UAAW,GACX,MAAO,GACP,cAAe,GACf,gBAAiB,SAAA,CACnB,EAEF,CACE,YAAa,YACb,aAAc,CACZ,UAAW,GACX,MAAO,GACP,cAAe,GACf,gBAAiB,QAAA,CACnB,EAEF,CACE,YAAa,MACb,aAAc,CACZ,UAAW,GACX,MAAO,GACP,cAAe,GACf,gBAAiB,SAAA,CACnB,CACF,CACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../../packages/sdk/kos-ui-plugin/src/lib/utils/extension-points/extension-point-types.ts"],"sourcesContent":["/**\n * Core types and interfaces for extension point system\n */\n\n// React import removed - component creation happens at runtime via hooks\nimport type { z } from \"zod\";\nimport type {\n BasePluginExtension,\n PluginExtensionsType,\n ProcessedContributions,\n} from \"../../../types/plugins\";\n\n/**\n * Validation context for collecting validation issues\n */\nexport interface ValidationContext {\n addError(message: string): void;\n addWarning(message: string): void;\n addInfo(message: string): void;\n hasErrors(): boolean;\n hasIssues(): boolean;\n getIssues(): { type: \"error\" | \"warning\" | \"info\"; message: string }[];\n}\n\n/**\n * Context provided to transform functions\n */\nexport interface TransformContext {\n remote: string;\n sectionId: string;\n experiences?: Record<string, any>;\n contributions: ProcessedContributions;\n}\n\n/**\n * Schema field information for documentation\n */\nexport interface SchemaFieldInfo {\n name: string;\n description?: string;\n type?: string;\n required?: boolean;\n}\n\n/**\n * Configuration for defining a new extension point\n */\nexport interface ExtensionPointConfig<\n TData = any,\n TProcessed = TData,\n _TProps = any\n> {\n /**\n * Unique identifier for this extension point\n * Convention: \"ddk.{feature}\" or \"ddk.{feature}.{sub-feature}\"\n */\n id: string;\n\n /**\n * Optional display name for documentation/discovery\n */\n displayName?: string;\n\n /**\n * Optional description for documentation/discovery\n */\n description?: string;\n\n /**\n * The contribution key in the plugin descriptor\n * e.g., \"myFeature\" maps to contributes.myFeature in kosdev-plugin.json\n */\n contributionKey: string;\n\n /**\n * Optional related extension points\n * For example, a main extension might have .view and .definition variants\n */\n relatedPoints?: {\n view?: string;\n definition?: string;\n [key: string]: string | undefined;\n };\n\n /**\n * Transform function to process raw contribution data\n * Allows custom processing logic while maintaining type safety\n */\n transform?: (data: TData, context: TransformContext) => TProcessed;\n\n /**\n * Optional validation function\n * Use context.addError/addWarning/addInfo to collect validation issues\n * Return \"skip\" to skip processing this contribution\n */\n validate?: (data: TData, context: ValidationContext) => \"skip\" | void;\n\n /**\n * Whether this extension point uses view/experience pattern\n * Default: false\n */\n hasView?: boolean;\n\n /**\n * Whether contributions should be ranked\n * Default: false\n */\n isRankable?: boolean;\n\n /**\n * Optional Zod schema for runtime validation and documentation\n * Provides both type safety and field introspection for Plugin Explorer\n */\n schema?: z.ZodSchema<TData>;\n\n /**\n * Metadata for discovery/documentation\n */\n metadata?: {\n category?: string;\n tags?: string[];\n since?: string;\n deprecated?: boolean;\n replacedBy?: string;\n owner?: string;\n /**\n * The actual export name of this extension point in the code\n * Used for documentation generation to show correct import statements\n */\n exportName?: string;\n };\n}\n\n/**\n * Props for extension point components\n */\nexport interface ExtensionComponentProps {\n /** Specific module to load (optional) */\n module?: string;\n /** Fallback component when extension not found */\n fallback?: React.ReactNode;\n}\n\n/**\n * Result of defining an extension point\n */\nexport interface ExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> {\n /**\n * The extension point configuration\n */\n config: ExtensionPointConfig<TData, TProcessed, TProps>;\n\n /**\n * Extension point ID for use in components\n */\n id: string;\n\n /**\n * Helper to get typed extensions (for future use with hooks)\n */\n getExtensions?: (\n extensions: PluginExtensionsType\n ) => Record<string, BasePluginExtension & { data: TProcessed }>;\n\n /**\n * Registration status\n */\n isRegistered: boolean;\n\n /**\n * Method to register this extension point\n */\n register: () => void;\n\n // Component property removed - use useExtensionComponent hook or createExtensionComponent factory at runtime\n\n /**\n * Get schema field information for documentation purposes\n * Returns field info that can be safely displayed by Plugin Explorer\n */\n getSchemaFieldInfo?: () => SchemaFieldInfo[];\n}\n\n/**\n * Extension point with hasView: true, guarantees Component property\n */\nexport interface ViewExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> extends ExtensionPointDefinition<TData, TProcessed, TProps> {\n Component: React.ComponentType<ExtensionComponentProps & TProps>;\n}\n\n/**\n * Type-safe extension point ID helper\n * Ensures consistent naming and helps with refactoring\n */\nexport function extensionPointId(\n namespace: string,\n feature: string,\n ...subFeatures: string[]\n): string {\n const parts = [namespace, feature, ...subFeatures].filter(Boolean);\n return parts.join(\".\");\n}\n"],"names":["extensionPointId","namespace","feature","subFeatures"],"mappings":"yJA0MO,SAASA,EACdC,EACAC,KACGC,EACK,CAER,MADc,CAACF,EAAWC,EAAS,GAAGC,CAAW,EAAE,OAAO,OAAO,EACpD,KAAK,GAAG,CACvB"}
|
package/utils.js
CHANGED
|
@@ -1,296 +1,34 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as c, C as g, D as l, P as u, p as x, R as d, j as m, t as E, o as P, f as R, h as v, e as f, c as h, k as p, d as S, g as b, b as y, a as k, l as w, n as B, r as C, q as D, s as V, u as j, v as I } from "./documentation-generator-Di4c9D9P.js";
|
|
2
2
|
import "zod";
|
|
3
|
-
function
|
|
4
|
-
return [
|
|
5
|
-
}
|
|
6
|
-
function u(i) {
|
|
7
|
-
const e = i.match(/^(\d+)\.(\d+)\.\d+(?:-\S+)?$/);
|
|
8
|
-
if (!e)
|
|
9
|
-
throw new Error(`Invalid version format: ${i}`);
|
|
10
|
-
const [n, s, t] = e;
|
|
11
|
-
return `${s}.${t}.0`;
|
|
12
|
-
}
|
|
13
|
-
function y(i, e) {
|
|
14
|
-
var g, f;
|
|
15
|
-
e != null && e.sdkVersion && console.log("sdkVersion", e.sdkVersion), e != null && e.ddkVersion && console.log("ddkVersion", e.ddkVersion);
|
|
16
|
-
const n = u((e == null ? void 0 : e.sdkVersion) || "0.2.0"), s = u((e == null ? void 0 : e.ddkVersion) || "0.2.0");
|
|
17
|
-
console.log(`Using DDK version: ${s}`), console.log(`Using SDK version: ${n}`);
|
|
18
|
-
const t = i == null ? void 0 : i.name;
|
|
19
|
-
if (!t)
|
|
20
|
-
throw new Error(
|
|
21
|
-
"KOS Configuration should be added. Project name not found in config"
|
|
22
|
-
);
|
|
23
|
-
const r = ((e == null ? void 0 : e.pluginPath) || "kos.ui.plugin").split(".").reduce((a, o) => (console.log(`Accessing key: ${o}`), a && a[o] ? a[o] : void 0), i), d = r == null ? void 0 : r.id;
|
|
24
|
-
if (!d)
|
|
25
|
-
throw new Error(
|
|
26
|
-
"KOS Configuration should be added. Plugin ID not found in config"
|
|
27
|
-
);
|
|
28
|
-
const l = Object.keys(((g = r == null ? void 0 : r.contributes) == null ? void 0 : g.views) || {}).reduce(
|
|
29
|
-
(a, o) => (r.contributes.views[o].forEach((c) => {
|
|
30
|
-
a[`./${c.component}`] = c.location;
|
|
31
|
-
}), a),
|
|
32
|
-
{}
|
|
33
|
-
);
|
|
34
|
-
return Object.values(((f = r == null ? void 0 : r.contributes) == null ? void 0 : f.experiences) || {}).forEach(
|
|
35
|
-
(a) => {
|
|
36
|
-
l[`./${a.component}`] = a.location;
|
|
37
|
-
}
|
|
38
|
-
), r != null && r.init && (l["./InitPlugin"] = "./src/app/init.ts"), {
|
|
39
|
-
name: t,
|
|
40
|
-
exposes: l,
|
|
41
|
-
library: { type: "var", name: d },
|
|
42
|
-
additionalShared: [
|
|
43
|
-
{
|
|
44
|
-
libraryName: "@kosdev-code/kos-ui-plugin",
|
|
45
|
-
sharedConfig: {
|
|
46
|
-
singleton: !0,
|
|
47
|
-
eager: !1,
|
|
48
|
-
requiredVersion: `~${s}`
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
libraryName: "react",
|
|
53
|
-
sharedConfig: {
|
|
54
|
-
singleton: !0,
|
|
55
|
-
eager: !1,
|
|
56
|
-
strictVersion: !0,
|
|
57
|
-
requiredVersion: "18.2.0"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
libraryName: "react-dom",
|
|
62
|
-
sharedConfig: {
|
|
63
|
-
singleton: !0,
|
|
64
|
-
eager: !1,
|
|
65
|
-
strictVersion: !0,
|
|
66
|
-
requiredVersion: "18.2.0"
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
libraryName: "@kosdev-code/kos-ui-sdk",
|
|
71
|
-
sharedConfig: {
|
|
72
|
-
singleton: !0,
|
|
73
|
-
eager: !1,
|
|
74
|
-
strictVersion: !1,
|
|
75
|
-
requiredVersion: `~${n}`
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
libraryName: "@kosdev-code/kos-dispense-sdk",
|
|
80
|
-
sharedConfig: {
|
|
81
|
-
singleton: !0,
|
|
82
|
-
eager: !1,
|
|
83
|
-
strictVersion: !1,
|
|
84
|
-
requiredVersion: `~${n}`
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
libraryName: "@kosdev-code/kos-freestyle-sdk",
|
|
89
|
-
sharedConfig: {
|
|
90
|
-
singleton: !0,
|
|
91
|
-
eager: !1,
|
|
92
|
-
strictVersion: !1,
|
|
93
|
-
requiredVersion: `~${n}`
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
libraryName: "@kosdev-code/kos-ddk-components",
|
|
98
|
-
sharedConfig: {
|
|
99
|
-
singleton: !0,
|
|
100
|
-
eager: !1,
|
|
101
|
-
strictVersion: !1,
|
|
102
|
-
requiredVersion: `~${s}`
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
libraryName: "@kosdev-code/kos-ddk-model-components",
|
|
107
|
-
sharedConfig: {
|
|
108
|
-
singleton: !0,
|
|
109
|
-
eager: !1,
|
|
110
|
-
strictVersion: !1,
|
|
111
|
-
requiredVersion: `~${s}`
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
libraryName: "@kosdev-code/kos-ddk-models",
|
|
116
|
-
sharedConfig: {
|
|
117
|
-
singleton: !0,
|
|
118
|
-
eager: !1,
|
|
119
|
-
strictVersion: !1,
|
|
120
|
-
requiredVersion: `~${s}`
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
libraryName: "@kosdev-code/kos-ddk",
|
|
125
|
-
sharedConfig: {
|
|
126
|
-
singleton: !0,
|
|
127
|
-
eager: !1,
|
|
128
|
-
strictVersion: !1,
|
|
129
|
-
requiredVersion: `~${s}`
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
libraryName: "@kosdev-code/kos-ddk-styles",
|
|
134
|
-
sharedConfig: {
|
|
135
|
-
singleton: !0,
|
|
136
|
-
eager: !1,
|
|
137
|
-
strictVersion: !1,
|
|
138
|
-
requiredVersion: `~${s}`
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
libraryName: "@emotion/styled",
|
|
143
|
-
sharedConfig: {
|
|
144
|
-
singleton: !0,
|
|
145
|
-
eager: !1,
|
|
146
|
-
strictVersion: !1,
|
|
147
|
-
requiredVersion: "~11.11.0"
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
libraryName: "@emotion/react",
|
|
152
|
-
sharedConfig: {
|
|
153
|
-
singleton: !0,
|
|
154
|
-
eager: !1,
|
|
155
|
-
strictVersion: !1,
|
|
156
|
-
requiredVersion: "~11.11.0"
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
libraryName: "reflect-metadata",
|
|
161
|
-
sharedConfig: {
|
|
162
|
-
singleton: !0,
|
|
163
|
-
eager: !1,
|
|
164
|
-
strictVersion: !1,
|
|
165
|
-
requiredVersion: "^0.2.2"
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
libraryName: "mobx",
|
|
170
|
-
sharedConfig: {
|
|
171
|
-
singleton: !0,
|
|
172
|
-
eager: !1,
|
|
173
|
-
strictVersion: !1,
|
|
174
|
-
requiredVersion: "^6.9.0"
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
libraryName: "loglevel",
|
|
179
|
-
sharedConfig: {
|
|
180
|
-
singleton: !0,
|
|
181
|
-
eager: !1,
|
|
182
|
-
strictVersion: !1,
|
|
183
|
-
requiredVersion: "^1.8.1"
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
libraryName: "robot3",
|
|
188
|
-
sharedConfig: {
|
|
189
|
-
singleton: !0,
|
|
190
|
-
eager: !1,
|
|
191
|
-
strictVersion: !1,
|
|
192
|
-
requiredVersion: "^0.4.0"
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
libraryName: "mobx-react-lite",
|
|
197
|
-
sharedConfig: {
|
|
198
|
-
singleton: !0,
|
|
199
|
-
eager: !1,
|
|
200
|
-
strictVersion: !1,
|
|
201
|
-
requiredVersion: "^3.4.3"
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
libraryName: "react-router-dom",
|
|
206
|
-
sharedConfig: {
|
|
207
|
-
singleton: !0,
|
|
208
|
-
eager: !1,
|
|
209
|
-
strictVersion: !1,
|
|
210
|
-
requiredVersion: "^6.11.2"
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
libraryName: "date-fns",
|
|
215
|
-
sharedConfig: {
|
|
216
|
-
singleton: !0,
|
|
217
|
-
eager: !1,
|
|
218
|
-
strictVersion: !1,
|
|
219
|
-
requiredVersion: "^2.30.0"
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
libraryName: "@use-gesture/react",
|
|
224
|
-
sharedConfig: {
|
|
225
|
-
singleton: !0,
|
|
226
|
-
eager: !1,
|
|
227
|
-
strictVersion: !1,
|
|
228
|
-
requiredVersion: "^10.3.0"
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
libraryName: "@react-spring/web",
|
|
233
|
-
sharedConfig: {
|
|
234
|
-
singleton: !0,
|
|
235
|
-
eager: !1,
|
|
236
|
-
strictVersion: !1,
|
|
237
|
-
requiredVersion: "^9.7.3"
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
libraryName: "react-simple-keyboard",
|
|
242
|
-
sharedConfig: {
|
|
243
|
-
singleton: !0,
|
|
244
|
-
eager: !1,
|
|
245
|
-
strictVersion: !1,
|
|
246
|
-
requiredVersion: "^3.6.13"
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
libraryName: "expr-eval",
|
|
251
|
-
sharedConfig: {
|
|
252
|
-
singleton: !0,
|
|
253
|
-
eager: !1,
|
|
254
|
-
strictVersion: !1,
|
|
255
|
-
requiredVersion: "^2.0.2"
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
libraryName: "zod",
|
|
260
|
-
sharedConfig: {
|
|
261
|
-
singleton: !0,
|
|
262
|
-
eager: !0,
|
|
263
|
-
strictVersion: !1,
|
|
264
|
-
requiredVersion: "^3.25.0"
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
};
|
|
3
|
+
function i(e, a, ...t) {
|
|
4
|
+
return [e, a, ...t].filter(Boolean).join(".");
|
|
269
5
|
}
|
|
270
6
|
export {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
x as
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
E as
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
7
|
+
c as BaseViewExtensionSchema,
|
|
8
|
+
g as ContributionRegistry,
|
|
9
|
+
l as DocumentationGenerator,
|
|
10
|
+
u as PluginDiscoveryService,
|
|
11
|
+
x as RankableViewExtensionSchema,
|
|
12
|
+
d as ReactiveExtensionRegistry,
|
|
13
|
+
m as contributionReducer,
|
|
14
|
+
E as createExtensionSchema,
|
|
15
|
+
P as createViewAwareTransform,
|
|
16
|
+
R as defineExtensionPoint,
|
|
17
|
+
i as extensionPointId,
|
|
18
|
+
v as generatePluginConfiguration,
|
|
19
|
+
f as getContributions,
|
|
20
|
+
h as getExtensionPointRegistry,
|
|
21
|
+
p as getExtensionPointSchema,
|
|
22
|
+
S as getExtensions,
|
|
23
|
+
b as getValidationResults,
|
|
24
|
+
y as initPluginManager,
|
|
25
|
+
k as initializeKosPlugins,
|
|
26
|
+
w as loadExtensions,
|
|
27
|
+
B as registry,
|
|
28
|
+
C as resolveBestExtension,
|
|
29
|
+
D as validateDescriptorFormat,
|
|
30
|
+
V as validateRank,
|
|
31
|
+
j as validateRankIfPresent,
|
|
32
|
+
I as validateWithSchema
|
|
295
33
|
};
|
|
296
34
|
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../packages/sdk/kos-ui-plugin/src/lib/utils/extension-points/extension-point-types.ts","../../../../packages/sdk/kos-ui-plugin/src/lib/utils/processors/process-kos-config.ts"],"sourcesContent":["/**\n * Core types and interfaces for extension point system\n */\n\n// React import removed - component creation happens at runtime via hooks\nimport type { z } from \"zod\";\nimport type {\n BasePluginExtension,\n PluginExtensionsType,\n ProcessedContributions,\n} from \"../../../types/plugins\";\n\n/**\n * Validation context for collecting validation issues\n */\nexport interface ValidationContext {\n addError(message: string): void;\n addWarning(message: string): void;\n addInfo(message: string): void;\n hasErrors(): boolean;\n hasIssues(): boolean;\n getIssues(): { type: \"error\" | \"warning\" | \"info\"; message: string }[];\n}\n\n/**\n * Context provided to transform functions\n */\nexport interface TransformContext {\n remote: string;\n sectionId: string;\n experiences?: Record<string, any>;\n contributions: ProcessedContributions;\n}\n\n/**\n * Schema field information for documentation\n */\nexport interface SchemaFieldInfo {\n name: string;\n description?: string;\n type?: string;\n required?: boolean;\n}\n\n/**\n * Configuration for defining a new extension point\n */\nexport interface ExtensionPointConfig<\n TData = any,\n TProcessed = TData,\n _TProps = any\n> {\n /**\n * Unique identifier for this extension point\n * Convention: \"ddk.{feature}\" or \"ddk.{feature}.{sub-feature}\"\n */\n id: string;\n\n /**\n * Optional display name for documentation/discovery\n */\n displayName?: string;\n\n /**\n * Optional description for documentation/discovery\n */\n description?: string;\n\n /**\n * The contribution key in the plugin descriptor\n * e.g., \"myFeature\" maps to contributes.myFeature in kosdev-plugin.json\n */\n contributionKey: string;\n\n /**\n * Optional related extension points\n * For example, a main extension might have .view and .definition variants\n */\n relatedPoints?: {\n view?: string;\n definition?: string;\n [key: string]: string | undefined;\n };\n\n /**\n * Transform function to process raw contribution data\n * Allows custom processing logic while maintaining type safety\n */\n transform?: (data: TData, context: TransformContext) => TProcessed;\n\n /**\n * Optional validation function\n * Use context.addError/addWarning/addInfo to collect validation issues\n * Return \"skip\" to skip processing this contribution\n */\n validate?: (data: TData, context: ValidationContext) => \"skip\" | void;\n\n /**\n * Whether this extension point uses view/experience pattern\n * Default: false\n */\n hasView?: boolean;\n\n /**\n * Whether contributions should be ranked\n * Default: false\n */\n isRankable?: boolean;\n\n /**\n * Optional Zod schema for runtime validation and documentation\n * Provides both type safety and field introspection for Plugin Explorer\n */\n schema?: z.ZodSchema<TData>;\n\n /**\n * Metadata for discovery/documentation\n */\n metadata?: {\n category?: string;\n tags?: string[];\n since?: string;\n deprecated?: boolean;\n replacedBy?: string;\n owner?: string;\n /**\n * The actual export name of this extension point in the code\n * Used for documentation generation to show correct import statements\n */\n exportName?: string;\n };\n}\n\n/**\n * Props for extension point components\n */\nexport interface ExtensionComponentProps {\n /** Specific module to load (optional) */\n module?: string;\n /** Fallback component when extension not found */\n fallback?: React.ReactNode;\n}\n\n/**\n * Result of defining an extension point\n */\nexport interface ExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> {\n /**\n * The extension point configuration\n */\n config: ExtensionPointConfig<TData, TProcessed, TProps>;\n\n /**\n * Extension point ID for use in components\n */\n id: string;\n\n /**\n * Helper to get typed extensions (for future use with hooks)\n */\n getExtensions?: (\n extensions: PluginExtensionsType\n ) => Record<string, BasePluginExtension & { data: TProcessed }>;\n\n /**\n * Registration status\n */\n isRegistered: boolean;\n\n /**\n * Method to register this extension point\n */\n register: () => void;\n\n // Component property removed - use useExtensionComponent hook or createExtensionComponent factory at runtime\n\n /**\n * Get schema field information for documentation purposes\n * Returns field info that can be safely displayed by Plugin Explorer\n */\n getSchemaFieldInfo?: () => SchemaFieldInfo[];\n}\n\n/**\n * Extension point with hasView: true, guarantees Component property\n */\nexport interface ViewExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> extends ExtensionPointDefinition<TData, TProcessed, TProps> {\n Component: React.ComponentType<ExtensionComponentProps & TProps>;\n}\n\n/**\n * Type-safe extension point ID helper\n * Ensures consistent naming and helps with refactoring\n */\nexport function extensionPointId(\n namespace: string,\n feature: string,\n ...subFeatures: string[]\n): string {\n const parts = [namespace, feature, ...subFeatures].filter(Boolean);\n return parts.join(\".\");\n}\n","/* eslint-disable max-lines-per-function */\nimport type { Contributions } from \"../../../types/global\";\n\ninterface KosConfigView {\n id: string;\n title: string;\n component: string;\n location: string;\n}\n\ninterface KosPluginConfig {\n id: string;\n init?: boolean;\n contributes: Contributions;\n}\n\ninterface DDKConfig {\n name: string;\n kosdev: {\n ddk: {\n ncui: {\n plugin: KosPluginConfig;\n };\n };\n };\n}\n\ninterface CoreKosConfig {\n name: string;\n kos: {\n ui: {\n plugin: KosPluginConfig;\n };\n };\n}\n\nexport type KosConfig = DDKConfig | CoreKosConfig;\n\nfunction normalizeVersion(version: string): string {\n const match = version.match(/^(\\d+)\\.(\\d+)\\.\\d+(?:-\\S+)?$/);\n if (!match) {\n throw new Error(`Invalid version format: ${version}`);\n }\n const [_, major, minor] = match;\n return `${major}.${minor}.0`;\n}\n\nexport interface PluginOptions {\n sdkVersion?: string;\n ddkVersion?: string;\n pluginPath?: string;\n}\nexport function generatePluginConfiguration(\n config: KosConfig,\n options?: PluginOptions\n): any {\n if (options?.sdkVersion) {\n console.log(\"sdkVersion\", options.sdkVersion);\n }\n if (options?.ddkVersion) {\n console.log(\"ddkVersion\", options.ddkVersion);\n }\n const sdkVersion = normalizeVersion(options?.sdkVersion || \"0.2.0\");\n const ddkVersion = normalizeVersion(options?.ddkVersion || \"0.2.0\");\n\n console.log(`Using DDK version: ${ddkVersion}`);\n console.log(`Using SDK version: ${sdkVersion}`);\n const projectId = config?.name;\n if (!projectId) {\n throw new Error(\n \"KOS Configuration should be added. Project name not found in config\"\n );\n }\n const pluginPath = options?.pluginPath || \"kos.ui.plugin\";\n const pluginObj = pluginPath\n .split(\".\")\n .reduce<KosPluginConfig>((obj, key) => {\n console.log(`Accessing key: ${key}`);\n return obj && obj[key] ? obj[key] : undefined;\n }, config as unknown as KosPluginConfig);\n\n const pluginId = pluginObj?.id;\n if (!pluginId) {\n throw new Error(\n \"KOS Configuration should be added. Plugin ID not found in config\"\n );\n }\n const mfConfig = Object.keys(pluginObj?.contributes?.views || {}).reduce(\n (acc, key) => {\n const views = pluginObj.contributes.views[key];\n\n views.forEach((view) => {\n acc[`./${view.component}`] = view.location;\n });\n return acc;\n },\n {}\n );\n\n Object.values(pluginObj?.contributes?.experiences || {}).forEach(\n (experience) => {\n mfConfig[`./${experience.component}`] = experience.location;\n }\n );\n\n if (pluginObj?.init) {\n mfConfig[\"./InitPlugin\"] = \"./src/app/init.ts\";\n }\n\n return {\n name: projectId,\n exposes: mfConfig,\n library: { type: \"var\", name: pluginId },\n additionalShared: [\n {\n libraryName: \"@kosdev-code/kos-ui-plugin\",\n sharedConfig: {\n singleton: true,\n eager: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"react\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: true,\n requiredVersion: \"18.2.0\",\n },\n },\n\n {\n libraryName: \"react-dom\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: true,\n requiredVersion: \"18.2.0\",\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ui-sdk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${sdkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-dispense-sdk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${sdkVersion}`,\n },\n },\n\n {\n libraryName: \"@kosdev-code/kos-freestyle-sdk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${sdkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-components\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-model-components\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-models\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@kosdev-code/kos-ddk-styles\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: `~${ddkVersion}`,\n },\n },\n {\n libraryName: \"@emotion/styled\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"~11.11.0\",\n },\n },\n {\n libraryName: \"@emotion/react\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"~11.11.0\",\n },\n },\n {\n libraryName: \"reflect-metadata\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^0.2.2\",\n },\n },\n {\n libraryName: \"mobx\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^6.9.0\",\n },\n },\n\n {\n libraryName: \"loglevel\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^1.8.1\",\n },\n },\n {\n libraryName: \"robot3\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^0.4.0\",\n },\n },\n {\n libraryName: \"mobx-react-lite\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^3.4.3\",\n },\n },\n {\n libraryName: \"react-router-dom\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^6.11.2\",\n },\n },\n {\n libraryName: \"date-fns\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^2.30.0\",\n },\n },\n {\n libraryName: \"@use-gesture/react\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^10.3.0\",\n },\n },\n {\n libraryName: \"@react-spring/web\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^9.7.3\",\n },\n },\n {\n libraryName: \"react-simple-keyboard\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^3.6.13\",\n },\n },\n {\n libraryName: \"expr-eval\",\n sharedConfig: {\n singleton: true,\n eager: false,\n strictVersion: false,\n requiredVersion: \"^2.0.2\",\n },\n },\n {\n libraryName: \"zod\",\n sharedConfig: {\n singleton: true,\n eager: true,\n strictVersion: false,\n requiredVersion: \"^3.25.0\",\n },\n },\n ],\n };\n}\n"],"names":["extensionPointId","namespace","feature","subFeatures","normalizeVersion","version","match","_","major","minor","generatePluginConfiguration","config","options","sdkVersion","ddkVersion","projectId","pluginObj","obj","key","pluginId","mfConfig","_a","acc","view","_b","experience"],"mappings":";;AA0MO,SAASA,EACdC,GACAC,MACGC,GACK;AAER,SADc,CAACF,GAAWC,GAAS,GAAGC,CAAW,EAAE,OAAO,OAAO,EACpD,KAAK,GAAG;AACvB;AC3KA,SAASC,EAAiBC,GAAyB;AACjD,QAAMC,IAAQD,EAAQ,MAAM,8BAA8B;AAC1D,MAAI,CAACC;AACH,UAAM,IAAI,MAAM,2BAA2BD,CAAO,EAAE;AAEtD,QAAM,CAACE,GAAGC,GAAOC,CAAK,IAAIH;AAC1B,SAAO,GAAGE,CAAK,IAAIC,CAAK;AAC1B;AAOO,SAASC,EACdC,GACAC,GACK;;AACL,EAAIA,KAAA,QAAAA,EAAS,cACX,QAAQ,IAAI,cAAcA,EAAQ,UAAU,GAE1CA,KAAA,QAAAA,EAAS,cACX,QAAQ,IAAI,cAAcA,EAAQ,UAAU;AAE9C,QAAMC,IAAaT,GAAiBQ,KAAA,gBAAAA,EAAS,eAAc,OAAO,GAC5DE,IAAaV,GAAiBQ,KAAA,gBAAAA,EAAS,eAAc,OAAO;AAElE,UAAQ,IAAI,sBAAsBE,CAAU,EAAE,GAC9C,QAAQ,IAAI,sBAAsBD,CAAU,EAAE;AAC9C,QAAME,IAAYJ,KAAA,gBAAAA,EAAQ;AAC1B,MAAI,CAACI;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAIJ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A,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,MAEF;AAAA,QACE,aAAa;AAAA,QACb,cAAc;AAAA,UACZ,WAAW;AAAA,UACX,OAAO;AAAA,UACP,eAAe;AAAA,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,MAEF;AAAA,QACE,aAAa;AAAA,QACb,cAAc;AAAA,UACZ,WAAW;AAAA,UACX,OAAO;AAAA,UACP,eAAe;AAAA,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,MAEF;AAAA,QACE,aAAa;AAAA,QACb,cAAc;AAAA,UACZ,WAAW;AAAA,UACX,OAAO;AAAA,UACP,eAAe;AAAA,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,MAEF;AAAA,QACE,aAAa;AAAA,QACb,cAAc;AAAA,UACZ,WAAW;AAAA,UACX,OAAO;AAAA,UACP,eAAe;AAAA,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,MAEF;AAAA,QACE,aAAa;AAAA,QACb,cAAc;AAAA,UACZ,WAAW;AAAA,UACX,OAAO;AAAA,UACP,eAAe;AAAA,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,MAEF;AAAA,QACE,aAAa;AAAA,QACb,cAAc;AAAA,UACZ,WAAW;AAAA,UACX,OAAO;AAAA,UACP,eAAe;AAAA,UACf,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../packages/sdk/kos-ui-plugin/src/lib/utils/extension-points/extension-point-types.ts"],"sourcesContent":["/**\n * Core types and interfaces for extension point system\n */\n\n// React import removed - component creation happens at runtime via hooks\nimport type { z } from \"zod\";\nimport type {\n BasePluginExtension,\n PluginExtensionsType,\n ProcessedContributions,\n} from \"../../../types/plugins\";\n\n/**\n * Validation context for collecting validation issues\n */\nexport interface ValidationContext {\n addError(message: string): void;\n addWarning(message: string): void;\n addInfo(message: string): void;\n hasErrors(): boolean;\n hasIssues(): boolean;\n getIssues(): { type: \"error\" | \"warning\" | \"info\"; message: string }[];\n}\n\n/**\n * Context provided to transform functions\n */\nexport interface TransformContext {\n remote: string;\n sectionId: string;\n experiences?: Record<string, any>;\n contributions: ProcessedContributions;\n}\n\n/**\n * Schema field information for documentation\n */\nexport interface SchemaFieldInfo {\n name: string;\n description?: string;\n type?: string;\n required?: boolean;\n}\n\n/**\n * Configuration for defining a new extension point\n */\nexport interface ExtensionPointConfig<\n TData = any,\n TProcessed = TData,\n _TProps = any\n> {\n /**\n * Unique identifier for this extension point\n * Convention: \"ddk.{feature}\" or \"ddk.{feature}.{sub-feature}\"\n */\n id: string;\n\n /**\n * Optional display name for documentation/discovery\n */\n displayName?: string;\n\n /**\n * Optional description for documentation/discovery\n */\n description?: string;\n\n /**\n * The contribution key in the plugin descriptor\n * e.g., \"myFeature\" maps to contributes.myFeature in kosdev-plugin.json\n */\n contributionKey: string;\n\n /**\n * Optional related extension points\n * For example, a main extension might have .view and .definition variants\n */\n relatedPoints?: {\n view?: string;\n definition?: string;\n [key: string]: string | undefined;\n };\n\n /**\n * Transform function to process raw contribution data\n * Allows custom processing logic while maintaining type safety\n */\n transform?: (data: TData, context: TransformContext) => TProcessed;\n\n /**\n * Optional validation function\n * Use context.addError/addWarning/addInfo to collect validation issues\n * Return \"skip\" to skip processing this contribution\n */\n validate?: (data: TData, context: ValidationContext) => \"skip\" | void;\n\n /**\n * Whether this extension point uses view/experience pattern\n * Default: false\n */\n hasView?: boolean;\n\n /**\n * Whether contributions should be ranked\n * Default: false\n */\n isRankable?: boolean;\n\n /**\n * Optional Zod schema for runtime validation and documentation\n * Provides both type safety and field introspection for Plugin Explorer\n */\n schema?: z.ZodSchema<TData>;\n\n /**\n * Metadata for discovery/documentation\n */\n metadata?: {\n category?: string;\n tags?: string[];\n since?: string;\n deprecated?: boolean;\n replacedBy?: string;\n owner?: string;\n /**\n * The actual export name of this extension point in the code\n * Used for documentation generation to show correct import statements\n */\n exportName?: string;\n };\n}\n\n/**\n * Props for extension point components\n */\nexport interface ExtensionComponentProps {\n /** Specific module to load (optional) */\n module?: string;\n /** Fallback component when extension not found */\n fallback?: React.ReactNode;\n}\n\n/**\n * Result of defining an extension point\n */\nexport interface ExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> {\n /**\n * The extension point configuration\n */\n config: ExtensionPointConfig<TData, TProcessed, TProps>;\n\n /**\n * Extension point ID for use in components\n */\n id: string;\n\n /**\n * Helper to get typed extensions (for future use with hooks)\n */\n getExtensions?: (\n extensions: PluginExtensionsType\n ) => Record<string, BasePluginExtension & { data: TProcessed }>;\n\n /**\n * Registration status\n */\n isRegistered: boolean;\n\n /**\n * Method to register this extension point\n */\n register: () => void;\n\n // Component property removed - use useExtensionComponent hook or createExtensionComponent factory at runtime\n\n /**\n * Get schema field information for documentation purposes\n * Returns field info that can be safely displayed by Plugin Explorer\n */\n getSchemaFieldInfo?: () => SchemaFieldInfo[];\n}\n\n/**\n * Extension point with hasView: true, guarantees Component property\n */\nexport interface ViewExtensionPointDefinition<\n TData = any,\n TProcessed = TData,\n TProps = any\n> extends ExtensionPointDefinition<TData, TProcessed, TProps> {\n Component: React.ComponentType<ExtensionComponentProps & TProps>;\n}\n\n/**\n * Type-safe extension point ID helper\n * Ensures consistent naming and helps with refactoring\n */\nexport function extensionPointId(\n namespace: string,\n feature: string,\n ...subFeatures: string[]\n): string {\n const parts = [namespace, feature, ...subFeatures].filter(Boolean);\n return parts.join(\".\");\n}\n"],"names":["extensionPointId","namespace","feature","subFeatures"],"mappings":";;AA0MO,SAASA,EACdC,GACAC,MACGC,GACK;AAER,SADc,CAACF,GAAWC,GAAS,GAAGC,CAAW,EAAE,OAAO,OAAO,EACpD,KAAK,GAAG;AACvB;"}
|
package/webpack.cjs
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
2
|
-
`)
|
|
3
|
-
`).map(function(S){return" "+S}).join(`
|
|
4
|
-
`).substr(2):d=`
|
|
5
|
-
`+d.split(`
|
|
6
|
-
`).map(function(S){return" "+S}).join(`
|
|
7
|
-
`))):d=n.stylize("[Circular]","special")),D(c)){if(g&&_.match(/^\d+$/))return d;c=JSON.stringify(""+_),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=n.stylize(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=n.stylize(c,"string"))}return c+": "+d}function le(n,i,s){var p=n.reduce(function(_,g){return g.indexOf(`
|
|
8
|
-
`)>=0,_+g.replace(/\u001b\[\d\d?m/g,"").length+1},0);return p>60?s[0]+(i===""?"":i+`
|
|
9
|
-
`)+" "+n.join(`,
|
|
10
|
-
`)+" "+s[1]:s[0]+i+" "+n.join(", ")+" "+s[1]}function x(n){return Array.isArray(n)}e.isArray=x;function M(n){return typeof n=="boolean"}e.isBoolean=M;function I(n){return n===null}e.isNull=I;function fe(n){return n==null}e.isNullOrUndefined=fe;function ee(n){return typeof n=="number"}e.isNumber=ee;function z(n){return typeof n=="string"}e.isString=z;function ce(n){return typeof n=="symbol"}e.isSymbol=ce;function D(n){return n===void 0}e.isUndefined=D;function k(n){return T(n)&&J(n)==="[object RegExp]"}e.isRegExp=k;function T(n){return typeof n=="object"&&n!==null}e.isObject=T;function F(n){return T(n)&&J(n)==="[object Date]"}e.isDate=F;function R(n){return T(n)&&(J(n)==="[object Error]"||n instanceof Error)}e.isError=R;function L(n){return typeof n=="function"}e.isFunction=L;function pe(n){return n===null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||typeof n=="symbol"||typeof n>"u"}e.isPrimitive=pe,e.isBuffer=we;function J(n){return Object.prototype.toString.call(n)}function q(n){return n<10?"0"+n.toString(10):n.toString(10)}var ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(){var n=new Date,i=[q(n.getHours()),q(n.getMinutes()),q(n.getSeconds())].join(":");return[n.getDate(),ge[n.getMonth()],i].join(" ")}e.log=function(){console.log("%s - %s",de(),e.format.apply(e,arguments))},e.inherits=_e,e._extend=function(n,i){if(!i||!T(i))return n;for(var s=Object.keys(i),p=s.length;p--;)n[s[p]]=i[s[p]];return n};function re(n,i){return Object.prototype.hasOwnProperty.call(n,i)}})(ne);var Oe=process.platform==="win32",O=ne;function C(e,r){for(var t=[],o=0;o<e.length;o++){var u=e[o];!u||u==="."||(u===".."?t.length&&t[t.length-1]!==".."?t.pop():r&&t.push(".."):t.push(u))}return t}function j(e){for(var r=e.length-1,t=0;t<=r&&!e[t];t++);for(var o=r;o>=0&&!e[o];o--);return t===0&&o===r?e:t>o?[]:e.slice(t,o+1)}var oe=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,De=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/,m={};function Y(e){var r=oe.exec(e),t=(r[1]||"")+(r[2]||""),o=r[3]||"",u=De.exec(o),a=u[1],l=u[2],f=u[3];return[t,a,l,f]}function Q(e){var r=oe.exec(e),t=r[1]||"",o=!!t&&t[1]!==":";return{device:t,isUnc:o,isAbsolute:o||!!r[2],tail:r[3]}}function ie(e){return"\\\\"+e.replace(/^[\\\/]+/,"").replace(/[\\\/]+/g,"\\")}m.resolve=function(){for(var e="",r="",t=!1,o=arguments.length-1;o>=-1;o--){var u;if(o>=0?u=arguments[o]:e?(u=process.env["="+e],(!u||u.substr(0,3).toLowerCase()!==e.toLowerCase()+"\\")&&(u=e+"\\")):u=process.cwd(),O.isString(u)){if(!u)continue}else throw new TypeError("Arguments to path.resolve must be strings");var a=Q(u),l=a.device,f=a.isUnc,v=a.isAbsolute,h=a.tail;if(!(l&&e&&l.toLowerCase()!==e.toLowerCase())&&(e||(e=l),t||(r=h+"\\"+r,t=v),e&&t))break}return f&&(e=ie(e)),r=C(r.split(/[\\\/]+/),!t).join("\\"),e+(t?"\\":"")+r||"."};m.normalize=function(e){var r=Q(e),t=r.device,o=r.isUnc,u=r.isAbsolute,a=r.tail,l=/[\\\/]$/.test(a);return a=C(a.split(/[\\\/]+/),!u).join("\\"),!a&&!u&&(a="."),a&&l&&(a+="\\"),o&&(t=ie(t)),t+(u?"\\":"")+a};m.isAbsolute=function(e){return Q(e).isAbsolute};m.join=function(){for(var e=[],r=0;r<arguments.length;r++){var t=arguments[r];if(!O.isString(t))throw new TypeError("Arguments to path.join must be strings");t&&e.push(t)}var o=e.join("\\");return/^[\\\/]{2}[^\\\/]/.test(e[0])||(o=o.replace(/^[\\\/]{2,}/,"\\")),m.normalize(o)};m.relative=function(e,r){e=m.resolve(e),r=m.resolve(r);for(var t=e.toLowerCase(),o=r.toLowerCase(),u=j(r.split("\\")),a=j(t.split("\\")),l=j(o.split("\\")),f=Math.min(a.length,l.length),v=f,h=0;h<f;h++)if(a[h]!==l[h]){v=h;break}if(v==0)return r;for(var y=[],h=v;h<a.length;h++)y.push("..");return y=y.concat(u.slice(v)),y.join("\\")};m._makeLong=function(e){if(!O.isString(e))return e;if(!e)return"";var r=m.resolve(e);return/^[a-zA-Z]\:\\/.test(r)?"\\\\?\\"+r:/^\\\\[^?.]/.test(r)?"\\\\?\\UNC\\"+r.substring(2):e};m.dirname=function(e){var r=Y(e),t=r[0],o=r[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)};m.basename=function(e,r){var t=Y(e)[2];return r&&t.substr(-1*r.length)===r&&(t=t.substr(0,t.length-r.length)),t};m.extname=function(e){return Y(e)[3]};m.format=function(e){if(!O.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var r=e.root||"";if(!O.isString(r))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);var t=e.dir,o=e.base||"";return t?t[t.length-1]===m.sep?t+o:t+m.sep+o:o};m.parse=function(e){if(!O.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var r=Y(e);if(!r||r.length!==4)throw new TypeError("Invalid path '"+e+"'");return{root:r[0],dir:r[0]+r[1].slice(0,-1),base:r[2],ext:r[3],name:r[2].slice(0,r[2].length-r[3].length)}};m.sep="\\";m.delimiter=";";var Ne=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,b={};function B(e){return Ne.exec(e).slice(1)}b.resolve=function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var o=t>=0?arguments[t]:process.cwd();if(O.isString(o)){if(!o)continue}else throw new TypeError("Arguments to path.resolve must be strings");e=o+"/"+e,r=o[0]==="/"}return e=C(e.split("/"),!r).join("/"),(r?"/":"")+e||"."};b.normalize=function(e){var r=b.isAbsolute(e),t=e&&e[e.length-1]==="/";return e=C(e.split("/"),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e};b.isAbsolute=function(e){return e.charAt(0)==="/"};b.join=function(){for(var e="",r=0;r<arguments.length;r++){var t=arguments[r];if(!O.isString(t))throw new TypeError("Arguments to path.join must be strings");t&&(e?e+="/"+t:e+=t)}return b.normalize(e)};b.relative=function(e,r){e=b.resolve(e).substr(1),r=b.resolve(r).substr(1);for(var t=j(e.split("/")),o=j(r.split("/")),u=Math.min(t.length,o.length),a=u,l=0;l<u;l++)if(t[l]!==o[l]){a=l;break}for(var f=[],l=a;l<t.length;l++)f.push("..");return f=f.concat(o.slice(a)),f.join("/")};b._makeLong=function(e){return e};b.dirname=function(e){var r=B(e),t=r[0],o=r[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)};b.basename=function(e,r){var t=B(e)[2];return r&&t.substr(-1*r.length)===r&&(t=t.substr(0,t.length-r.length)),t};b.extname=function(e){return B(e)[3]};b.format=function(e){if(!O.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var r=e.root||"";if(!O.isString(r))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);var t=e.dir?e.dir+b.sep:"",o=e.base||"";return t+o};b.parse=function(e){if(!O.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var r=B(e);if(!r||r.length!==4)throw new TypeError("Invalid path '"+e+"'");return r[1]=r[1]||"",r[2]=r[2]||"",r[3]=r[3]||"",{root:r[0],dir:r[0]+r[1].slice(0,-1),base:r[2],ext:r[3],name:r[2].slice(0,r[2].length-r[3].length)}};b.sep="/";b.delimiter=":";Oe?V.exports=m:V.exports=b;V.exports.posix=b;V.exports.win32=m;var Se=V.exports;const Ae="16.6.1",Te={version:Ae},H=Z,K=Se,je=Z,Pe=Z,Ve=Te,X=Ve.version,$e=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Ie(e){const r={};let t=e.toString();t=t.replace(/\r\n?/mg,`
|
|
11
|
-
`);let o;for(;(o=$e.exec(t))!=null;){const u=o[1];let a=o[2]||"";a=a.trim();const l=a[0];a=a.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),l==='"'&&(a=a.replace(/\\n/g,`
|
|
12
|
-
`),a=a.replace(/\\r/g,"\r")),r[u]=a}return r}function ze(e){e=e||{};const r=ue(e);e.path=r;const t=E.configDotenv(e);if(!t.parsed){const l=new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);throw l.code="MISSING_DATA",l}const o=ae(e).split(","),u=o.length;let a;for(let l=0;l<u;l++)try{const f=o[l].trim(),v=Re(t,f);a=E.decrypt(v.ciphertext,v.key);break}catch(f){if(l+1>=u)throw f}return E.parse(a)}function ke(e){console.log(`[dotenv@${X}][WARN] ${e}`)}function P(e){console.log(`[dotenv@${X}][DEBUG] ${e}`)}function se(e){console.log(`[dotenv@${X}] ${e}`)}function ae(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Re(e,r){let t;try{t=new URL(r)}catch(f){if(f.code==="ERR_INVALID_URL"){const v=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw v.code="INVALID_DOTENV_KEY",v}throw f}const o=t.password;if(!o){const f=new Error("INVALID_DOTENV_KEY: Missing key part");throw f.code="INVALID_DOTENV_KEY",f}const u=t.searchParams.get("environment");if(!u){const f=new Error("INVALID_DOTENV_KEY: Missing environment part");throw f.code="INVALID_DOTENV_KEY",f}const a=`DOTENV_VAULT_${u.toUpperCase()}`,l=e.parsed[a];if(!l){const f=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw f.code="NOT_FOUND_DOTENV_ENVIRONMENT",f}return{ciphertext:l,key:o}}function ue(e){let r=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const t of e.path)H.existsSync(t)&&(r=t.endsWith(".vault")?t:`${t}.vault`);else r=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else r=K.resolve(process.cwd(),".env.vault");return H.existsSync(r)?r:null}function te(e){return e[0]==="~"?K.join(je.homedir(),e.slice(1)):e}function Le(e){const r=!!(e&&e.debug),t=e&&"quiet"in e?e.quiet:!0;(r||!t)&&se("Loading env from encrypted .env.vault");const o=E._parseVault(e);let u=process.env;return e&&e.processEnv!=null&&(u=e.processEnv),E.populate(u,o,e),{parsed:o}}function Ue(e){const r=K.resolve(process.cwd(),".env");let t="utf8";const o=!!(e&&e.debug),u=e&&"quiet"in e?e.quiet:!0;e&&e.encoding?t=e.encoding:o&&P("No encoding is specified. UTF-8 is used by default");let a=[r];if(e&&e.path)if(!Array.isArray(e.path))a=[te(e.path)];else{a=[];for(const h of e.path)a.push(te(h))}let l;const f={};for(const h of a)try{const y=E.parse(H.readFileSync(h,{encoding:t}));E.populate(f,y,e)}catch(y){o&&P(`Failed to load ${h} ${y.message}`),l=y}let v=process.env;if(e&&e.processEnv!=null&&(v=e.processEnv),E.populate(v,f,e),o||!u){const h=Object.keys(f).length,y=[];for(const $ of a)try{const N=K.relative(process.cwd(),$);y.push(N)}catch(N){o&&P(`Failed to load ${$} ${N.message}`),l=N}se(`injecting env (${h}) from ${y.join(",")}`)}return l?{parsed:f,error:l}:{parsed:f}}function Ke(e){if(ae(e).length===0)return E.configDotenv(e);const r=ue(e);return r?E._configVault(e):(ke(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`),E.configDotenv(e))}function Ce(e,r){const t=Buffer.from(r.slice(-64),"hex");let o=Buffer.from(e,"base64");const u=o.subarray(0,12),a=o.subarray(-16);o=o.subarray(12,-16);try{const l=Pe.createDecipheriv("aes-256-gcm",t,u);return l.setAuthTag(a),`${l.update(o)}${l.final()}`}catch(l){const f=l instanceof RangeError,v=l.message==="Invalid key length",h=l.message==="Unsupported state or unable to authenticate data";if(f||v){const y=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw y.code="INVALID_DOTENV_KEY",y}else if(h){const y=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw y.code="DECRYPTION_FAILED",y}else throw l}}function Ye(e,r,t={}){const o=!!(t&&t.debug),u=!!(t&&t.override);if(typeof r!="object"){const a=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw a.code="OBJECT_REQUIRED",a}for(const a of Object.keys(r))Object.prototype.hasOwnProperty.call(e,a)?(u===!0&&(e[a]=r[a]),o&&P(u===!0?`"${a}" is already defined and WAS overwritten`:`"${a}" is already defined and was NOT overwritten`)):e[a]=r[a]}const E={configDotenv:Ue,_configVault:Le,_parseVault:ze,config:Ke,decrypt:Ce,parse:Ie,populate:Ye};A.exports.configDotenv=E.configDotenv;A.exports._configVault=E._configVault;A.exports._parseVault=E._parseVault;var Be=A.exports.config=E.config;A.exports.decrypt=E.decrypt;A.exports.parse=E.parse;A.exports.populate=E.populate;A.exports=E;function Me(){return Object.keys(process.env).filter(r=>r.startsWith("KOS_"))}Be({path:".env"});const Fe=e=>r=>{var t;return r&&(r.resolve=r.resolve||{},r.resolve.fallback={...r.resolve.fallback,path:!1}),r.mode=process.env.NODE_ENV||r.mode,(t=r==null?void 0:r.plugins)==null||t.push(new e.EnvironmentPlugin(["NODE_ENV",...Me()])),r};exports.withKosConfig=Fe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("fs"),M=require("path"),re=require("os"),oe=require("crypto"),F=require("uuid");function G(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Q=G(B),H=G(M);var N={exports:{}};const ne="16.6.1",se={version:ne},J=B,Y=M,ae=re,ie=oe,ce=se,U=ce.version,le=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function ue(e){const t={};let s=e.toString();s=s.replace(/\r\n?/mg,`
|
|
2
|
+
`);let a;for(;(a=le.exec(s))!=null;){const u=a[1];let r=a[2]||"";r=r.trim();const n=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),n==='"'&&(r=r.replace(/\\n/g,`
|
|
3
|
+
`),r=r.replace(/\\r/g,"\r")),t[u]=r}return t}function ge(e){e=e||{};const t=ee(e);e.path=t;const s=p.configDotenv(e);if(!s.parsed){const n=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw n.code="MISSING_DATA",n}const a=Z(e).split(","),u=a.length;let r;for(let n=0;n<u;n++)try{const o=a[n].trim(),c=pe(s,o);r=p.decrypt(c.ciphertext,c.key);break}catch(o){if(n+1>=u)throw o}return p.parse(r)}function de(e){console.log(`[dotenv@${U}][WARN] ${e}`)}function R(e){console.log(`[dotenv@${U}][DEBUG] ${e}`)}function X(e){console.log(`[dotenv@${U}] ${e}`)}function Z(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function pe(e,t){let s;try{s=new URL(t)}catch(o){if(o.code==="ERR_INVALID_URL"){const c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw o}const a=s.password;if(!a){const o=new Error("INVALID_DOTENV_KEY: Missing key part");throw o.code="INVALID_DOTENV_KEY",o}const u=s.searchParams.get("environment");if(!u){const o=new Error("INVALID_DOTENV_KEY: Missing environment part");throw o.code="INVALID_DOTENV_KEY",o}const r=`DOTENV_VAULT_${u.toUpperCase()}`,n=e.parsed[r];if(!n){const o=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${r} in your .env.vault file.`);throw o.code="NOT_FOUND_DOTENV_ENVIRONMENT",o}return{ciphertext:n,key:a}}function ee(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const s of e.path)J.existsSync(s)&&(t=s.endsWith(".vault")?s:`${s}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=Y.resolve(process.cwd(),".env.vault");return J.existsSync(t)?t:null}function z(e){return e[0]==="~"?Y.join(ae.homedir(),e.slice(1)):e}function fe(e){const t=!!(e&&e.debug),s=e&&"quiet"in e?e.quiet:!0;(t||!s)&&X("Loading env from encrypted .env.vault");const a=p._parseVault(e);let u=process.env;return e&&e.processEnv!=null&&(u=e.processEnv),p.populate(u,a,e),{parsed:a}}function ve(e){const t=Y.resolve(process.cwd(),".env");let s="utf8";const a=!!(e&&e.debug),u=e&&"quiet"in e?e.quiet:!0;e&&e.encoding?s=e.encoding:a&&R("No encoding is specified. UTF-8 is used by default");let r=[t];if(e&&e.path)if(!Array.isArray(e.path))r=[z(e.path)];else{r=[];for(const d of e.path)r.push(z(d))}let n;const o={};for(const d of r)try{const g=p.parse(J.readFileSync(d,{encoding:s}));p.populate(o,g,e)}catch(g){a&&R(`Failed to load ${d} ${g.message}`),n=g}let c=process.env;if(e&&e.processEnv!=null&&(c=e.processEnv),p.populate(c,o,e),a||!u){const d=Object.keys(o).length,g=[];for(const m of r)try{const v=Y.relative(process.cwd(),m);g.push(v)}catch(v){a&&R(`Failed to load ${m} ${v.message}`),n=v}X(`injecting env (${d}) from ${g.join(",")}`)}return n?{parsed:o,error:n}:{parsed:o}}function he(e){if(Z(e).length===0)return p.configDotenv(e);const t=ee(e);return t?p._configVault(e):(de(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),p.configDotenv(e))}function De(e,t){const s=Buffer.from(t.slice(-64),"hex");let a=Buffer.from(e,"base64");const u=a.subarray(0,12),r=a.subarray(-16);a=a.subarray(12,-16);try{const n=ie.createDecipheriv("aes-256-gcm",s,u);return n.setAuthTag(r),`${n.update(a)}${n.final()}`}catch(n){const o=n instanceof RangeError,c=n.message==="Invalid key length",d=n.message==="Unsupported state or unable to authenticate data";if(o||c){const g=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw g.code="INVALID_DOTENV_KEY",g}else if(d){const g=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw g.code="DECRYPTION_FAILED",g}else throw n}}function Ee(e,t,s={}){const a=!!(s&&s.debug),u=!!(s&&s.override);if(typeof t!="object"){const r=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw r.code="OBJECT_REQUIRED",r}for(const r of Object.keys(t))Object.prototype.hasOwnProperty.call(e,r)?(u===!0&&(e[r]=t[r]),a&&R(u===!0?`"${r}" is already defined and WAS overwritten`:`"${r}" is already defined and was NOT overwritten`)):e[r]=t[r]}const p={configDotenv:ve,_configVault:fe,_parseVault:ge,config:he,decrypt:De,parse:ue,populate:Ee};N.exports.configDotenv=p.configDotenv;N.exports._configVault=p._configVault;N.exports._parseVault=p._parseVault;var ke=N.exports.config=p.config;N.exports.decrypt=p.decrypt;N.exports.parse=p.parse;N.exports.populate=p.populate;N.exports=p;function we(){return Object.keys(process.env).filter(t=>t.startsWith("KOS_"))}ke({path:".env"});const ye=e=>t=>{var s;return t&&(t.resolve=t.resolve||{},t.resolve.fallback={...t.resolve.fallback,path:!1}),t.mode=process.env.NODE_ENV||t.mode,(s=t==null?void 0:t.plugins)==null||s.push(new e.EnvironmentPlugin(["NODE_ENV",...we()])),t},me=(e={})=>{const{kosJsonPath:t=".kos.json",projectRoot:s,defaultContext:a="kosdev.ddk",verbose:u=!1}=e;return(r,n)=>{var g,m;if(!r.devServer)return u&&console.log("[withPluginDevServer] No devServer config found, skipping middleware"),r;let o=s||process.cwd();s||(r!=null&&r.context&&typeof r.context=="string"?o=r.context:(g=n==null?void 0:n.options)!=null&&g.root&&((m=n==null?void 0:n.options)!=null&&m.projectRoot)&&(o=H.join(n.options.root,n.options.projectRoot)));const c=H.resolve(o,t);u&&console.log("[withPluginDevServer] Configuration:",{kosJsonPath:c,projectRoot:o,defaultContext:a});const d=r.devServer.setupMiddlewares;return r.devServer.setupMiddlewares=(v,O)=>(d&&(v=d(v,O)),O.app.get("/api/kos/ui/plugins/contexts",(L,_)=>{var S,q,E,V;try{if(!Q.existsSync(c)){const b=`.kos.json not found at ${c}`;return console.error(`[withPluginDevServer] ${b}`),_.status(404).json({status:404,error:b,hint:"Ensure .kos.json exists in your plugin project root"})}const k=Q.readFileSync(c,"utf-8"),T=JSON.parse(k),P=(q=(S=T.kos)==null?void 0:S.ui)==null?void 0:q.plugin;if(!P){const b="kos.ui.plugin section not found in .kos.json";return console.error(`[withPluginDevServer] ${b}`),_.status(400).json({status:400,error:b,hint:"Ensure .kos.json has kos.ui.plugin section defined"})}const j=(E=T.test)==null?void 0:E.plugin,I=(j==null?void 0:j.context)||a,K=F.v4(),$={status:200,version:{major:1,minor:0},data:[{name:I,plugins:[{descriptor:P,id:K,path:"/"}]}]};u&&console.log("[withPluginDevServer] Serving plugin metadata:",{pluginId:P.id,context:I,extensionsCount:((V=P.extensions)==null?void 0:V.length)||0}),_.json($)}catch(k){console.error("[withPluginDevServer] Error serving plugin metadata:",k),_.status(500).json({status:500,error:"Failed to serve plugin metadata",details:k instanceof Error?k.message:String(k)})}}),u&&console.log("[withPluginDevServer] Plugin metadata endpoint registered at /api/kos/ui/plugins/contexts"),v),r}},_e=e=>{const{pluginServers:t,includeHostPlugins:s=!0,kosJsonPath:a=".kos.json",mergeWithBackend:u=!1,fallbackToBackend:r=!0,backendUrl:n="http://localhost:8081",verbose:o=!1}=e;return(c,d)=>{var O,L;let g=process.cwd();c!=null&&c.context&&typeof c.context=="string"?g=c.context:(O=d==null?void 0:d.options)!=null&&O.root&&((L=d==null?void 0:d.options)!=null&&L.projectRoot)&&(g=M.join(d.options.root,d.options.projectRoot));const m=M.join(g,a);if(!c.devServer)return o&&console.log("[withPluginDevAggregator] No devServer config found, skipping middleware"),c;o&&console.log("[withPluginDevAggregator] Configuration:",{pluginServers:t,fallbackToBackend:r,backendUrl:n,projectRoot:g,kosJsonPath:m});const v=c.devServer.setupMiddlewares;return c.devServer.setupMiddlewares=(_,S)=>(v&&(_=v(_,S)),S.app.get("/api/kos/ui/plugins/contexts",async(q,E)=>{var V,k,T,P,j,I,K;try{if(t.length===0)if(r){o&&console.log("[withPluginDevAggregator] No plugin servers, proxying to backend:",n);const l=await(await fetch(`${n}/api/kos/ui/plugins/contexts`)).json();return E.json(l)}else return E.status(404).json({status:404,error:"No plugin servers configured",hint:"Add plugin server URLs to withPluginDevAggregator options or enable fallbackToBackend"});const b=(await Promise.all(t.map(async i=>{try{const l=await fetch(`${i}/api/kos/ui/plugins/contexts`);if(!l.ok)return o&&console.warn(`[withPluginDevAggregator] Failed to fetch from ${i}: ${l.status}`),null;const f=await l.json();return{serverUrl:i,data:f}}catch(l){return o&&console.warn(`[withPluginDevAggregator] Error fetching from ${i}:`,l),null}}))).filter(i=>i&&i.data&&i.data.status===200);if(b.length===0&&r){o&&console.log("[withPluginDevAggregator] No plugin servers responded, falling back to backend");try{const l=await(await fetch(`${n}/api/kos/ui/plugins/contexts`)).json();return E.json(l)}catch(i){return E.status(503).json({status:503,error:"No plugin servers available and backend unreachable",details:i instanceof Error?i.message:String(i)})}}const D={},C={};if(u)try{o&&console.log("[withPluginDevAggregator] Fetching backend plugins from:",n);const i=await fetch(`${n}/api/kos/ui/plugins/contexts`);if(i.ok){const l=await i.json();l.status===200&&l.data&&(l.data.forEach(f=>{const w=f.name;D[w]||(D[w]=[]),f.plugins.forEach(y=>{var h;D[w].push(y),o&&console.log(`[withPluginDevAggregator] Added backend plugin: ${(h=y.descriptor)==null?void 0:h.id} (no override)`)})}),o&&console.log("[withPluginDevAggregator] Successfully merged backend plugins"))}else o&&console.warn(`[withPluginDevAggregator] Backend fetch failed: ${i.status}`)}catch(i){o&&console.warn("[withPluginDevAggregator] Error fetching backend plugins:",i)}if(s)try{const i=B.readFileSync(m,"utf-8"),l=JSON.parse(i),f=(k=(V=l.kos)==null?void 0:V.ui)==null?void 0:k.plugin,w=(j=(P=(T=l.kosdev)==null?void 0:T.ddk)==null?void 0:P.ncui)==null?void 0:j.plugin,y=[];f&&y.push({name:((K=(I=l.test)==null?void 0:I.plugin)==null?void 0:K.context)||"kos.ui",plugin:{descriptor:f,id:F.v4(),path:"/"}}),w&&y.push({name:"kosdev.ddk",plugin:{descriptor:w,id:F.v4(),path:"/"}}),y.forEach(({name:h,plugin:A})=>{D[h]||(D[h]=[]),D[h].push(A),o&&console.log(`[withPluginDevAggregator] Added host plugin: ${A.descriptor.id} to context ${h}`)})}catch(i){o&&console.warn("[withPluginDevAggregator] Failed to read host .kos.json:",i)}b.forEach(i=>{var w;if(!i)return;const{serverUrl:l,data:f}=i;(w=f.data)==null||w.forEach(y=>{const h=y.name;D[h]||(D[h]=[]),y.plugins.forEach(A=>{var W;D[h].push(A),C[A.id]=`${l}/`,o&&console.log(`[withPluginDevAggregator] Added local dev plugin: ${(W=A.descriptor)==null?void 0:W.id} with override to ${l}/`)})})});const x=Object.entries(D).map(([i,l])=>({name:i,plugins:l})),te={status:200,version:{major:1,minor:0},data:x,overrides:C};o&&console.log("[withPluginDevAggregator] Aggregated plugins:",{contexts:x.length,totalPlugins:x.reduce((i,l)=>i+l.plugins.length,0),pluginIds:x.flatMap(i=>i.plugins.map(l=>{var f;return(f=l.descriptor)==null?void 0:f.id})),overrides:C}),E.json(te)}catch($){console.error("[withPluginDevAggregator] Error aggregating plugins:",$),E.status(500).json({status:500,error:"Failed to aggregate plugin metadata",details:$ instanceof Error?$.message:String($)})}}),o&&console.log("[withPluginDevAggregator] Plugin aggregation endpoint registered at /api/kos/ui/plugins/contexts"),_),c}};exports.withKosConfig=ye;exports.withPluginDevAggregator=_e;exports.withPluginDevServer=me;
|
|
13
4
|
//# sourceMappingURL=webpack.cjs.map
|