@kosdev-code/kos-ui-plugin 0.1.0-dev.5096 → 0.1.0-dev.5101
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-DFaIDo0E.cjs → documentation-generator-D1Yzvcw3.cjs} +5 -5
- package/documentation-generator-D1Yzvcw3.cjs.map +1 -0
- package/{documentation-generator-auruIa_o.js → documentation-generator-vDywn3tb.js} +302 -228
- package/documentation-generator-vDywn3tb.js.map +1 -0
- package/index.cjs +2 -2
- package/index.js +2 -2
- package/lib/utils/processors/initialize-plugins.d.ts.map +1 -1
- 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/utils.cjs +1 -1
- package/utils.js +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.map +0 -1
- package/documentation-generator-auruIa_o.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Plugin Development Mode Aggregation Middleware
|
|
3
|
+
*
|
|
4
|
+
* This webpack composable aggregates metadata from multiple plugin dev servers
|
|
5
|
+
* running on different ports, combining them into a single response at the
|
|
6
|
+
* `/api/kos/ui/plugins/contexts` endpoint.
|
|
7
|
+
*
|
|
8
|
+
* This allows a host app to load multiple plugins simultaneously during development.
|
|
9
|
+
*/
|
|
10
|
+
export interface PluginDevAggregatorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* List of plugin dev server URLs to aggregate.
|
|
13
|
+
* Example: ['http://localhost:4201', 'http://localhost:4202']
|
|
14
|
+
*/
|
|
15
|
+
pluginServers: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Include the host app's own .kos.json plugin definitions.
|
|
18
|
+
* Default: true
|
|
19
|
+
*/
|
|
20
|
+
includeHostPlugins?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Path to the host app's .kos.json file.
|
|
23
|
+
* Default: './.kos.json'
|
|
24
|
+
*/
|
|
25
|
+
kosJsonPath?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Merge backend plugins with local dev plugins.
|
|
28
|
+
* When true, fetches plugins from backend and overlays local dev plugins on top.
|
|
29
|
+
* Local dev plugins get overrides pointing to dev servers.
|
|
30
|
+
* Backend plugins use their original URLs (no overrides).
|
|
31
|
+
*
|
|
32
|
+
* This is useful for third-party developers who want to:
|
|
33
|
+
* - Run against a production DDK backend
|
|
34
|
+
* - Load DDK base plugins from the backend
|
|
35
|
+
* - Develop their own custom plugins locally
|
|
36
|
+
*
|
|
37
|
+
* Default: false (local-only mode)
|
|
38
|
+
*/
|
|
39
|
+
mergeWithBackend?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Fallback to backend if no local plugin servers are available.
|
|
42
|
+
* Default: true
|
|
43
|
+
*/
|
|
44
|
+
fallbackToBackend?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Backend URL to fallback to when no plugin servers available.
|
|
47
|
+
* Default: 'http://localhost:8081'
|
|
48
|
+
*/
|
|
49
|
+
backendUrl?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Enable verbose logging for debugging.
|
|
52
|
+
* Default: false
|
|
53
|
+
*/
|
|
54
|
+
verbose?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Webpack plugin composable that aggregates multiple plugin dev servers.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // Host app webpack.config.ts
|
|
62
|
+
* import { withPluginDevAggregator } from '@kosdev-code/kos-ui-plugin/webpack';
|
|
63
|
+
*
|
|
64
|
+
* export default composePlugins(
|
|
65
|
+
* withNx(),
|
|
66
|
+
* withReact({}),
|
|
67
|
+
* withPluginDevAggregator({
|
|
68
|
+
* pluginServers: [
|
|
69
|
+
* 'http://localhost:4201', // beverage-pour
|
|
70
|
+
* 'http://localhost:4202' // kos-ddk-standard-plugin
|
|
71
|
+
* ]
|
|
72
|
+
* })
|
|
73
|
+
* );
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example With environment variables
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const pluginServers = [
|
|
79
|
+
* process.env.PLUGIN_A_DEV === 'true' && 'http://localhost:4201',
|
|
80
|
+
* process.env.PLUGIN_B_DEV === 'true' && 'http://localhost:4202',
|
|
81
|
+
* ].filter(Boolean);
|
|
82
|
+
*
|
|
83
|
+
* export default composePlugins(
|
|
84
|
+
* withNx(),
|
|
85
|
+
* withReact({}),
|
|
86
|
+
* withPluginDevAggregator({
|
|
87
|
+
* pluginServers,
|
|
88
|
+
* fallbackToBackend: pluginServers.length === 0
|
|
89
|
+
* })
|
|
90
|
+
* );
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare const withPluginDevAggregator: (options: PluginDevAggregatorOptions) => (config: any, context: any) => any;
|
|
94
|
+
//# sourceMappingURL=with-plugin-dev-aggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-plugin-dev-aggregator.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-plugin/src/lib/webpack/with-plugin-dev-aggregator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;;OAYG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,uBAAuB,YACzB,0BAA0B,cAYnB,GAAG,WAAW,GAAG,QA8VlC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for plugin development server middleware
|
|
3
|
+
*/
|
|
4
|
+
export interface PluginDevServerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Path to .kos.json file, relative to project root.
|
|
7
|
+
* Default: '.kos.json'
|
|
8
|
+
*/
|
|
9
|
+
kosJsonPath?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Project root directory. Used to resolve kosJsonPath.
|
|
12
|
+
* Default: process.cwd()
|
|
13
|
+
*/
|
|
14
|
+
projectRoot?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Default plugin context if not specified in .kos.json test section.
|
|
17
|
+
* Default: 'kosdev.ddk'
|
|
18
|
+
*/
|
|
19
|
+
defaultContext?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Enable verbose logging for debugging.
|
|
22
|
+
* Default: false
|
|
23
|
+
*/
|
|
24
|
+
verbose?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Webpack plugin composable that adds plugin development server middleware.
|
|
28
|
+
*
|
|
29
|
+
* This middleware serves the `/api/kos/ui/plugins/contexts` endpoint, mimicking
|
|
30
|
+
* the backend KOS plugin API response format. It enables local plugin development
|
|
31
|
+
* without requiring backend deployment.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // webpack.config.ts
|
|
36
|
+
* import { withKosConfig, withPluginDevServer } from '@kosdev-code/kos-ui-plugin/webpack';
|
|
37
|
+
* import { composePlugins, withNx } from '@nx/webpack';
|
|
38
|
+
*
|
|
39
|
+
* export default composePlugins(
|
|
40
|
+
* withNx(),
|
|
41
|
+
* withReact({}),
|
|
42
|
+
* withKosConfig(webpack),
|
|
43
|
+
* withPluginDevServer() // ← Add plugin dev server
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example With options
|
|
48
|
+
* ```typescript
|
|
49
|
+
* export default composePlugins(
|
|
50
|
+
* withNx(),
|
|
51
|
+
* withReact({}),
|
|
52
|
+
* withKosConfig(webpack),
|
|
53
|
+
* withPluginDevServer({
|
|
54
|
+
* kosJsonPath: '.kos.json',
|
|
55
|
+
* defaultContext: 'kosdev.ddk',
|
|
56
|
+
* verbose: true
|
|
57
|
+
* })
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ## .kos.json Structure
|
|
62
|
+
*
|
|
63
|
+
* The middleware reads two sections from .kos.json:
|
|
64
|
+
*
|
|
65
|
+
* ```json
|
|
66
|
+
* {
|
|
67
|
+
* "kos": {
|
|
68
|
+
* "ui": {
|
|
69
|
+
* "plugin": {
|
|
70
|
+
* "id": "MyPlugin",
|
|
71
|
+
* "extensions": [...],
|
|
72
|
+
* "contributes": {...}
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* },
|
|
76
|
+
* "test": {
|
|
77
|
+
* "plugin": {
|
|
78
|
+
* "context": "kosdev.ddk"
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* - `kos.ui.plugin`: Production plugin descriptor (becomes API `descriptor`)
|
|
85
|
+
* - `test.plugin.context`: Development plugin context/group name
|
|
86
|
+
*
|
|
87
|
+
* ## Response Format
|
|
88
|
+
*
|
|
89
|
+
* The middleware returns the same format as the backend `/api/kos/ui/plugins/contexts`:
|
|
90
|
+
*
|
|
91
|
+
* ```json
|
|
92
|
+
* {
|
|
93
|
+
* "status": 200,
|
|
94
|
+
* "version": {"major": 1, "minor": 0},
|
|
95
|
+
* "data": [
|
|
96
|
+
* {
|
|
97
|
+
* "name": "kosdev.ddk",
|
|
98
|
+
* "plugins": [
|
|
99
|
+
* {
|
|
100
|
+
* "descriptor": { ... },
|
|
101
|
+
* "id": "uuid-v4",
|
|
102
|
+
* "path": "/"
|
|
103
|
+
* }
|
|
104
|
+
* ]
|
|
105
|
+
* }
|
|
106
|
+
* ]
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @param options - Configuration options
|
|
111
|
+
*/
|
|
112
|
+
export declare const withPluginDevServer: (options?: PluginDevServerOptions) => (config: any, context: any) => any;
|
|
113
|
+
//# sourceMappingURL=with-plugin-dev-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-plugin-dev-server.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-plugin/src/lib/webpack/with-plugin-dev-server.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqFG;AACH,eAAO,MAAM,mBAAmB,aAAa,sBAAsB,cAQjD,GAAG,WAAW,GAAG,QAuJlC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-ui-plugin",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.5101",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"kos": {
|
|
23
23
|
"build": {
|
|
24
|
-
"gitHash": "
|
|
24
|
+
"gitHash": "96dbc64113639eae888fbbd86d1258fbd6a9795f"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
package/utils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./documentation-generator-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./documentation-generator-D1Yzvcw3.cjs");require("zod");function m(n,e,...t){return[n,e,...t].filter(Boolean).join(".")}function V(n){const e=n.match(/^(\d+)\.(\d+)\.\d+(?:-\S+)?$/);if(!e)throw new Error(`Invalid version format: ${n}`);const[t,s,l]=e;return`${s}.${l}.0`}function h(n,e){var c,u;e!=null&&e.sdkVersion&&console.log("sdkVersion",e.sdkVersion),e!=null&&e.ddkVersion&&console.log("ddkVersion",e.ddkVersion);const t=V((e==null?void 0:e.sdkVersion)||"0.2.0"),s=V((e==null?void 0:e.ddkVersion)||"0.2.0");console.log(`Using DDK version: ${s}`),console.log(`Using SDK version: ${t}`);const l=n==null?void 0:n.name;if(!l)throw new Error("KOS Configuration should be added. Project name not found in config");const i=((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),n),g=i==null?void 0:i.id;if(!g)throw new Error("KOS Configuration should be added. Plugin ID not found in config");const d=Object.keys(((c=i==null?void 0:i.contributes)==null?void 0:c.views)||{}).reduce((a,o)=>(i.contributes.views[o].forEach(f=>{a[`./${f.component}`]=f.location}),a),{});return Object.values(((u=i==null?void 0:i.contributes)==null?void 0:u.experiences)||{}).forEach(a=>{d[`./${a.component}`]=a.location}),i!=null&&i.init&&(d["./InitPlugin"]="./src/app/init.ts"),{name:l,exposes:d,library:{type:"var",name:g},additionalShared:[{libraryName:"@kosdev-code/kos-ui-plugin",sharedConfig:{singleton:!0,eager:!1,requiredVersion:`~${s}`}},{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:`~${s}`}},{libraryName:"@kosdev-code/kos-ddk-model-components",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${s}`}},{libraryName:"@kosdev-code/kos-ddk-models",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${s}`}},{libraryName:"@kosdev-code/kos-ddk",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${s}`}},{libraryName:"@kosdev-code/kos-ddk-styles",sharedConfig:{singleton:!0,eager:!1,strictVersion:!1,requiredVersion:`~${s}`}},{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"}}]}}exports.BaseViewExtensionSchema=r.BaseViewExtensionSchema;exports.DocumentationGenerator=r.DocumentationGenerator;exports.PluginDiscoveryService=r.PluginDiscoveryService;exports.RankableViewExtensionSchema=r.RankableViewExtensionSchema;exports.contributionReducer=r.contributionReducer;exports.createExtensionSchema=r.createExtensionSchema;exports.createViewAwareTransform=r.createViewAwareTransform;exports.defineExtensionPoint=r.defineExtensionPoint;exports.getContributions=r.getContributions;exports.getExtensionPointRegistry=r.getExtensionPointRegistry;exports.getExtensionPointSchema=r.getExtensionPointSchema;exports.getExtensions=r.getExtensions;exports.getValidationResults=r.getValidationResults;exports.initPluginManager=r.initPluginManager;exports.initializeKosPlugins=r.initializeKosPlugins;exports.loadExtensions=r.loadExtensions;exports.registry=r.registry;exports.resolveBestExtension=r.resolveBestExtension;exports.validateDescriptorFormat=r.validateDescriptorFormat;exports.validateRank=r.validateRank;exports.validateRankIfPresent=r.validateRankIfPresent;exports.validateWithSchema=r.validateWithSchema;exports.extensionPointId=m;exports.generatePluginConfiguration=h;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
package/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as v, D as q, P as N, R as $, d as x, q as P, n as w, h as E, e as S, c as D, j as I, f as R, g as K, b as B, a as z, l as A, k as U, r as F, o as G, p as M, s as T, v as W } from "./documentation-generator-
|
|
1
|
+
import { B as v, D as q, P as N, R as $, d as x, q as P, n as w, h as E, e as S, c as D, j as I, f as R, g as K, b as B, a as z, l as A, k as U, r as F, o as G, p as M, s as T, v as W } from "./documentation-generator-vDywn3tb.js";
|
|
2
2
|
import "zod";
|
|
3
3
|
function k(i, e, ...n) {
|
|
4
4
|
return [i, e, ...n].filter(Boolean).join(".");
|
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
|