@likec4/config 1.59.2 → 1.59.3
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/dist/chunks/index.d.mts +33 -1
- package/dist/chunks/src.mjs +17 -16
- package/dist/chunks/webapp-export-formats.d.mts +6 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +1 -1
- package/dist/node/index.d.mts +3 -2
- package/dist/node/index.mjs +2 -2
- package/dist/webapp-export-formats.d.mts +2 -0
- package/dist/webapp-export-formats.mjs +1 -0
- package/package.json +16 -9
- package/schema.json +35 -0
- package/src/index.ts +12 -0
- package/src/schema.ts +30 -0
- package/src/webapp-export-formats.ts +7 -0
- package/webapp-export-formats/package.json +4 -0
package/dist/chunks/index.d.mts
CHANGED
|
@@ -20,6 +20,27 @@ interface VscodeURI {
|
|
|
20
20
|
readonly fragment: string;
|
|
21
21
|
toString(): string;
|
|
22
22
|
}
|
|
23
|
+
declare const WebappExportFormatSchema: z.ZodEnum<{
|
|
24
|
+
png: "png";
|
|
25
|
+
jpg: "jpg";
|
|
26
|
+
dot: "dot";
|
|
27
|
+
d2: "d2";
|
|
28
|
+
mmd: "mmd";
|
|
29
|
+
puml: "puml";
|
|
30
|
+
drawio: "drawio";
|
|
31
|
+
}>;
|
|
32
|
+
declare const WebappConfigSchema: z.ZodObject<{
|
|
33
|
+
exportFormats: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
34
|
+
png: "png";
|
|
35
|
+
jpg: "jpg";
|
|
36
|
+
dot: "dot";
|
|
37
|
+
d2: "d2";
|
|
38
|
+
mmd: "mmd";
|
|
39
|
+
puml: "puml";
|
|
40
|
+
drawio: "drawio";
|
|
41
|
+
}>>>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
type WebappConfig = z.infer<typeof WebappConfigSchema>;
|
|
23
44
|
declare const LikeC4ProjectJsonConfigSchema: z.ZodObject<{
|
|
24
45
|
name: z.ZodString;
|
|
25
46
|
extends: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
@@ -150,6 +171,17 @@ declare const LikeC4ProjectJsonConfigSchema: z.ZodObject<{
|
|
|
150
171
|
}, z.core.$strict>, z.ZodObject<{
|
|
151
172
|
exclude: z.ZodArray<z.ZodString>;
|
|
152
173
|
}, z.core.$strict>]>>;
|
|
174
|
+
webapp: z.ZodOptional<z.ZodObject<{
|
|
175
|
+
exportFormats: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
176
|
+
png: "png";
|
|
177
|
+
jpg: "jpg";
|
|
178
|
+
dot: "dot";
|
|
179
|
+
d2: "d2";
|
|
180
|
+
mmd: "mmd";
|
|
181
|
+
puml: "puml";
|
|
182
|
+
drawio: "drawio";
|
|
183
|
+
}>>>;
|
|
184
|
+
}, z.core.$strict>>;
|
|
153
185
|
}, z.core.$strip>;
|
|
154
186
|
type LikeC4ProjectJsonConfig = z.input<typeof LikeC4ProjectJsonConfigSchema>;
|
|
155
187
|
/**
|
|
@@ -593,4 +625,4 @@ declare function defineTheme<const S extends LikeC4ConfigThemeInput>(theme: S):
|
|
|
593
625
|
*/
|
|
594
626
|
declare function defineStyle<const S extends LikeC4StylesConfigInput>(styles: S): LikeC4ProjectStylesConfig;
|
|
595
627
|
//#endregion
|
|
596
|
-
export { VscodeURI as C, LocateResult as S, GeneratorFnParams as _, defineThemeColor as a, LikeC4ProjectConfigOps as b, isLikeC4JsonConfig as c, LikeC4StylesConfig as d, LikeC4StylesConfigInput as f, GeneratorFnContext as g, GeneratorFn as h, defineTheme as i, isLikeC4NonJsonConfig as l, ThemeColorValuesInput as m, defineGenerators as n, ConfigFilenames as o, LikeC4StylesConfigSchema as p, defineStyle as r, isLikeC4Config as s, defineConfig as t, LikeC4ConfigThemeInput as u, LikeC4ProjectConfig as v,
|
|
628
|
+
export { VscodeURI as C, IncludeConfig as D, WebappExportFormatSchema as E, LocateResult as S, WebappConfigSchema as T, GeneratorFnParams as _, defineThemeColor as a, LikeC4ProjectConfigOps as b, isLikeC4JsonConfig as c, LikeC4StylesConfig as d, LikeC4StylesConfigInput as f, GeneratorFnContext as g, GeneratorFn as h, defineTheme as i, isLikeC4NonJsonConfig as l, ThemeColorValuesInput as m, defineGenerators as n, ConfigFilenames as o, LikeC4StylesConfigSchema as p, defineStyle as r, isLikeC4Config as s, defineConfig as t, LikeC4ConfigThemeInput as u, LikeC4ProjectConfig as v, WebappConfig as w, LikeC4ProjectJsonConfig as x, LikeC4ProjectConfigInput as y };
|
package/dist/chunks/src.mjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import"./rolldown-runtime.mjs";import e from"json5";import
|
|
2
|
-
`)}),maxDepth:
|
|
3
|
-
`)}),fileThreshold:
|
|
1
|
+
import"./rolldown-runtime.mjs";import{WebappExportFormats as e}from"../webapp-export-formats.mjs";import t from"json5";import n from"zod/v4";import{BorderStyles as r,ElementShapes as i,IconPositions as a,RelationshipArrowTypes as o,Sizes as s,ThemeColors as c,computeColorValues as l}from"@likec4/core/styles";import{exact as u}from"@likec4/core/types";const d=/^@[A-Za-z0-9_-]*$/,f=/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,p=n.string().min(1,`Image alias key cannot be empty`).regex(d,`Image alias key must match /^@\\w+$/`),m=n.string().min(1,`Image alias value cannot be empty`).regex(f,`Image alias value must be a relative path (no leading slash or protocol)`),h=n.record(p,m).meta({id:`ImageAliases`,description:`Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash).`}),g=n.string().min(1,`Include path cannot be empty`).regex(/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,`Include path must be a relative path (no leading slash, drive letter, or protocol)`),_=n.strictObject({paths:n.array(g).meta({description:[`Additional relative directory paths to include LikeC4 source files from, searched recursively.`,`Paths are relative to the project folder (the folder containing this config file).`,`Example: ["../shared", "../common/specs"]`].join(`
|
|
2
|
+
`)}),maxDepth:n.number().int().min(1).max(20).default(3).meta({description:[`Maximum directory depth to scan when searching for .c4 files in include paths.`,`Prevents excessive scanning of deeply nested directories.`,`Default: 3`].join(`
|
|
3
|
+
`)}),fileThreshold:n.number().int().min(1).max(1e4).default(30).meta({description:[`Maximum number of files to load from include paths before warning.`,`Helps identify performance issues from accidentally including large directories.`,`Default: 30`].join(`
|
|
4
4
|
`)})}).meta({id:`include-config`,description:[`Configuration for including additional LikeC4 source files from other directories.`,`Example: { "paths": ["../shared", "../common/specs"], "maxDepth": 5, "fileThreshold": 50 }`].join(`
|
|
5
|
-
`)}),
|
|
6
|
-
(must be a valid color name from the theme)`}),opacity:
|
|
7
|
-
(must be a valid color name from the theme)`}),line:
|
|
8
|
-
These values will be used if such property is not defined`}),
|
|
9
|
-
(must be a valid color name from the theme)`}),opacity:
|
|
10
|
-
These values will be used if such property is not defined`}),relationship:
|
|
11
|
-
These values will be used if such property is not defined`})}).meta({id:`DefaultStyleValues`}),
|
|
12
|
-
These values will be used if such property is not defined`}),customCss:
|
|
13
|
-
`)})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),
|
|
14
|
-
`)}),
|
|
15
|
-
|
|
16
|
-
`+
|
|
17
|
-
`+
|
|
5
|
+
`)}),v=n.int().min(0,`Opacity must be between 0 and 100`).max(100,`Opacity must be between 0 and 100`).meta({id:`Opacity`,description:`Opacity 0-100%`}),y=n.enum(i).meta({id:`ElementShape`}),b=n.enum(r).meta({id:`BorderStyle`}),x=n.enum(s).meta({id:`ElementSize`}),S=n.enum(a).meta({id:`IconPosition`}),C=n.enum(o).meta({id:`ArrowType`}),w=n.enum([`dashed`,`solid`,`dotted`]).meta({id:`LineType`}),T=n.enum(c).meta({id:`ThemeColorName`}),E=n.custom().refine(e=>typeof e==`string`,`Custom color name must be a string`).transform(e=>e).meta({id:`CustomColorName`}),D=T.or(E).transform(e=>e).meta({id:`ColorName`}),O=n.string().min(1,`Color value cannot be empty`).meta({id:`ColorLiteral`}),k=n.strictObject({fill:O.meta({description:`Background color`}),stroke:O.meta({description:`Stroke color (border, paths above background)`}),hiContrast:O.meta({description:`High contrast text color (title)`}),loContrast:O.meta({description:`Low contrast text color (description)`})}).meta({id:`ElementColorValues`}).transform(e=>e),A=n.strictObject({line:O.meta({description:`Line color`}),label:O.meta({description:`Label text color`}),labelBg:O.optional().default(`rgba(0, 0, 0, 0.5)`).meta({description:`Label background color`})}).meta({id:`RelationshipColorValues`}).transform(e=>e),j=n.strictObject({elements:k.or(O.transform(e=>l(e).elements)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),relationships:A.or(O.transform(e=>l(e).relationships)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`})}).transform(e=>e).meta({id:`StrictThemeColorValues`,description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color value`}).or(O.transform(e=>l(e))).transform(e=>e).meta({id:`ThemeColorValues`,description:`Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),M=n.partialRecord(D,j).transform(e=>e),N=n.strictObject({width:n.number().min(50),height:n.number().min(50)}).meta({id:`Dimensions`,description:`Defines dimensions for theme size`}),P=n.partialRecord(x,N),F=n.strictObject({colors:M.optional().meta({description:`Override theme colors`}),sizes:P.optional().meta({description:`Override theme sizes`})}).meta({id:`ThemeCustomization`,description:`Customize theme colors and sizes`}).transform(({colors:e,sizes:t})=>u({colors:e?u(e):void 0,sizes:t?u(t):void 0})),I=n.strictObject({color:D.optional().meta({description:`Default color for groups
|
|
6
|
+
(must be a valid color name from the theme)`}),opacity:v.optional().meta({description:`Default opacity for groups`}),border:b.optional().meta({description:`Default border for groups`})}).meta({id:`GroupDefaultStyleValues`}),L=n.strictObject({color:D.optional().meta({description:`Default color for relationships
|
|
7
|
+
(must be a valid color name from the theme)`}),line:w.optional().meta({description:`Default line style for relationships`}),arrow:C.optional().meta({description:`Default arrow style for relationships`})}).meta({id:`RelationshipDefaultStyleValues`,description:`Override default values for relationship style properties
|
|
8
|
+
These values will be used if such property is not defined`}),R=n.strictObject({color:D.optional().meta({description:`Default color for elements
|
|
9
|
+
(must be a valid color name from the theme)`}),opacity:v.optional().meta({description:`Default opacity (0-100%) for elements when displayed as a group (like a container)`}),border:b.optional().meta({description:`Default border style for elements when displayed as a group (like a container)`}),size:x.optional().meta({description:`Default size for elements`}),shape:y.optional().meta({description:`Default shape for elements`}),iconPosition:S.optional().meta({description:`Default icon position for elements`}),group:I.optional().meta({description:`Override default values for group style properties
|
|
10
|
+
These values will be used if such property is not defined`}),relationship:L.optional().meta({description:`Override default values for relationship style properties
|
|
11
|
+
These values will be used if such property is not defined`})}).meta({id:`DefaultStyleValues`}),z=n.union([n.string().min(1,`Custom CSS file path cannot be empty`),n.array(n.string().min(1,`Custom CSS file path cannot be empty`))]).meta({id:`CustomStylesheets`}),B=n.strictObject({theme:F.optional().meta({description:`Project theme customization`}),defaults:R.optional().meta({description:`Override default values for style properties
|
|
12
|
+
These values will be used if such property is not defined`}),customCss:z.optional().meta({description:`Custom CSS (or list of CSS files) to be included in the generated diagrams`})}).transform(({theme:e,defaults:t,customCss:n})=>u({defaults:normalizeDefaults(t),customCss:normalizeStylesheets(n),theme:e}));function normalizeDefaults(e){if(!e)return;let{relationship:t,group:n,...r}=e;return u({...r,relationship:t&&u(t),group:n&&u(n)})}function normalizeStylesheets(e){if(!e)return;let t=(Array.isArray(e)?e:[e]).filter(Boolean);if(t.length!==0)return{paths:t,content:``}}const V=n.strictObject({outDir:n.string().default(`.likec4`).meta({description:[`Path to the directory where manual layouts will be stored,`,`relative to the folder containing the project config. `,``,`Defaults to '.likec4'.`].join(`
|
|
13
|
+
`)})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),H=n.enum(e),U=n.strictObject({exportFormats:n.array(H).refine(e=>new Set(e).size===e.length,{message:`Export formats cannot contain duplicates`}).default([...e]).meta({description:[`Webapp export formats enabled in the generated application.`,`Omit to enable all export formats. Use an empty array to disable webapp exports.`].join(`
|
|
14
|
+
`)})}).meta({id:`WebappConfig`,description:`Configuration for the generated web application`}),W=n.union([n.strictObject({redirect:n.literal(!0)}),n.strictObject({include:n.array(n.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`include list cannot be empty`)}),n.strictObject({exclude:n.array(n.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`exclude list cannot be empty`)})]).meta({id:`LandingPageConfig`,description:`Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid.`}),G=n.object({name:n.string().nonempty(`Project name cannot be empty`).refine(e=>e!=="default",{abort:!0,error:`Project name cannot be "default"`}).refine(e=>!e.includes(`.`)&&!e.includes(`@`)&&!e.includes(`#`),{abort:!0,error:`Project name cannot contain ".", "@" or "#", try to use A-z, 0-9, _ and -`}).meta({description:`Project name, must be unique in the workspace`}),extends:n.union([n.string().min(1,`Extend path cannot be empty`),n.array(n.string().min(1,`Extend path cannot be empty`)).min(1,`Extend list cannot be empty`)]).optional().meta({description:`Extend styles from other config files`}),title:n.string().nonempty(`Project title cannot be empty if specified`).optional().meta({description:`A human readable title for the project`}),contactPerson:n.string().nonempty(`Contact person cannot be empty if specified`).optional().meta({description:`A person who has been involved in creating or maintaining this project`}),metadata:n.record(n.string(),n.any()).optional().meta({description:`Arbitrary metadata as key-value pairs for custom project information`}),styles:B.optional().meta({description:`Project styles customization`}),imageAliases:h.optional(),include:_.optional(),exclude:n.array(n.string()).optional().meta({description:`List of file patterns to exclude from the project, default is ["**/node_modules/**"]`}),manualLayouts:V.optional(),inferTechnologyFromIcon:n.boolean().optional().meta({description:[`Automatically derive element technology from icon name when technology is not set explicitly.`,`Applies to aws:, azure:, gcp:, and tech: icons. Bootstrap icons are excluded.`,`Defaults to true.`].join(`
|
|
15
|
+
`)}),implicitViews:n.boolean().optional().meta({description:`Auto-generate scoped views for elements without explicit views. Defaults to false.`}),landingPage:W.optional(),webapp:U.optional()}).meta({id:`LikeC4ProjectConfig`,description:`LikeC4 Project Configuration`}),K=n.instanceof(Function),q=n.record(n.string(),K),J=G.extend({generators:q.optional()});function validateProjectConfig(e){let t=e.landingPage,r=null;if(t!=null){let e=W.safeParse(t);if(!e.success)throw Error(`Config validation failed:
|
|
16
|
+
`+n.prettifyError(e.error));r=e.data}let i=G.safeParse(e);if(!i.success)throw Error(`Config validation failed:
|
|
17
|
+
`+n.prettifyError(i.error));let a=i.data;r!==null&&(a={...a,landingPage:r});let o=e.generators;if(typeof o==`object`&&o&&!Array.isArray(o)){let e=q.safeParse(o);if(!e.success)throw Error(`Config validation failed (generators):
|
|
18
|
+
`+n.prettifyError(e.error));return{...a,generators:e.data}}return a}function parseProjectConfigJSON(e){return validateProjectConfig(t.parse(e.trim()||`{}`))}const Y={parse:parseProjectConfigJSON,validate:validateProjectConfig,normalizeInclude:e=>{let t=_.safeParse(e);return t.success?t.data:{paths:[],maxDepth:3,fileThreshold:30}}};function trimTrailingSlashes(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)t--;return e.slice(0,t)}function splitPath(e){return e.split(`/`).flatMap(e=>e.split(`\\`))}function basename(e){let t=trimTrailingSlashes(e),n=splitPath(t);return n[n.length-1]||t}const X=[`.likec4rc`,`.likec4.config.json`,`likec4.config.json`],Z=[`likec4.config.js`,`likec4.config.cjs`,`likec4.config.mjs`,`likec4.config.ts`,`likec4.config.cts`,`likec4.config.mts`],Q=[...X,...Z];function isLikeC4JsonConfig(e){return X.includes(basename(e))}function isLikeC4NonJsonConfig(e){return Z.includes(basename(e))}function isLikeC4Config(e){return isLikeC4JsonConfig(e)||isLikeC4NonJsonConfig(e)}function defineConfig(e){return J.parse(e)}function defineGenerators(e){return q.parse(e)}function defineThemeColor(e){return j.parse(e)}function defineTheme(e){return F.parse(e)}function defineStyle(e){return B.parse(e)}export{defineThemeColor as a,isLikeC4JsonConfig as c,G as d,U as f,B as h,defineTheme as i,isLikeC4NonJsonConfig as l,validateProjectConfig as m,defineGenerators as n,Q as o,H as p,defineStyle as r,isLikeC4Config as s,defineConfig as t,Y as u};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { t as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
//#region src/webapp-export-formats.d.ts
|
|
3
|
+
declare const WebappExportFormats: readonly ["png", "jpg", "dot", "d2", "mmd", "puml", "drawio"];
|
|
4
|
+
type WebappExportFormat = typeof WebappExportFormats[number];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { WebappExportFormats as n, WebappExportFormat as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { S as LocateResult, _ as GeneratorFnParams, a as defineThemeColor, b as LikeC4ProjectConfigOps, c as isLikeC4JsonConfig, d as LikeC4StylesConfig, f as LikeC4StylesConfigInput, g as GeneratorFnContext, h as GeneratorFn, i as defineTheme, l as isLikeC4NonJsonConfig, m as ThemeColorValuesInput, n as defineGenerators, o as ConfigFilenames, p as LikeC4StylesConfigSchema, r as defineStyle, s as isLikeC4Config, t as defineConfig, u as LikeC4ConfigThemeInput, v as LikeC4ProjectConfig, w as
|
|
2
|
-
|
|
1
|
+
import { D as IncludeConfig, E as WebappExportFormatSchema, S as LocateResult, T as WebappConfigSchema, _ as GeneratorFnParams, a as defineThemeColor, b as LikeC4ProjectConfigOps, c as isLikeC4JsonConfig, d as LikeC4StylesConfig, f as LikeC4StylesConfigInput, g as GeneratorFnContext, h as GeneratorFn, i as defineTheme, l as isLikeC4NonJsonConfig, m as ThemeColorValuesInput, n as defineGenerators, o as ConfigFilenames, p as LikeC4StylesConfigSchema, r as defineStyle, s as isLikeC4Config, t as defineConfig, u as LikeC4ConfigThemeInput, v as LikeC4ProjectConfig, w as WebappConfig, x as LikeC4ProjectJsonConfig, y as LikeC4ProjectConfigInput } from "./chunks/index.mjs";
|
|
2
|
+
import { n as WebappExportFormats, t as WebappExportFormat } from "./chunks/webapp-export-formats.mjs";
|
|
3
|
+
export { ConfigFilenames, type GeneratorFn, type GeneratorFnContext, type GeneratorFnParams, type IncludeConfig, type LikeC4ConfigThemeInput, type LikeC4ProjectConfig, type LikeC4ProjectConfigInput, LikeC4ProjectConfigOps, type LikeC4ProjectJsonConfig, type LikeC4StylesConfig, type LikeC4StylesConfigInput, LikeC4StylesConfigSchema, type LocateResult, type ThemeColorValuesInput, type WebappConfig, WebappConfigSchema, type WebappExportFormat, WebappExportFormatSchema, WebappExportFormats, defineConfig, defineGenerators, defineStyle, defineTheme, defineThemeColor, isLikeC4Config, isLikeC4JsonConfig, isLikeC4NonJsonConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,
|
|
1
|
+
import{a as e,c as t,f as n,h as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./chunks/src.mjs";import{WebappExportFormats as p}from"./webapp-export-formats.mjs";export{s as ConfigFilenames,f as LikeC4ProjectConfigOps,r as LikeC4StylesConfigSchema,n as WebappConfigSchema,c as WebappExportFormatSchema,p as WebappExportFormats,d as defineConfig,o as defineGenerators,l as defineStyle,i as defineTheme,e as defineThemeColor,u as isLikeC4Config,t as isLikeC4JsonConfig,a as isLikeC4NonJsonConfig};
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "../chunks/rolldown-runtime.mjs";
|
|
2
|
-
import { C as VscodeURI, S as LocateResult, _ as GeneratorFnParams, a as defineThemeColor, b as LikeC4ProjectConfigOps, c as isLikeC4JsonConfig, d as LikeC4StylesConfig, f as LikeC4StylesConfigInput, g as GeneratorFnContext, h as GeneratorFn, i as defineTheme, l as isLikeC4NonJsonConfig, m as ThemeColorValuesInput, n as defineGenerators, o as ConfigFilenames, p as LikeC4StylesConfigSchema, r as defineStyle, s as isLikeC4Config, t as defineConfig, u as LikeC4ConfigThemeInput, v as LikeC4ProjectConfig, w as
|
|
2
|
+
import { C as VscodeURI, D as IncludeConfig, E as WebappExportFormatSchema, S as LocateResult, T as WebappConfigSchema, _ as GeneratorFnParams, a as defineThemeColor, b as LikeC4ProjectConfigOps, c as isLikeC4JsonConfig, d as LikeC4StylesConfig, f as LikeC4StylesConfigInput, g as GeneratorFnContext, h as GeneratorFn, i as defineTheme, l as isLikeC4NonJsonConfig, m as ThemeColorValuesInput, n as defineGenerators, o as ConfigFilenames, p as LikeC4StylesConfigSchema, r as defineStyle, s as isLikeC4Config, t as defineConfig, u as LikeC4ConfigThemeInput, v as LikeC4ProjectConfig, w as WebappConfig, x as LikeC4ProjectJsonConfig, y as LikeC4ProjectConfigInput } from "../chunks/index.mjs";
|
|
3
|
+
import { n as WebappExportFormats, t as WebappExportFormat } from "../chunks/webapp-export-formats.mjs";
|
|
3
4
|
//#region src/node/load-config.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Load LikeC4 Project config file.
|
|
@@ -7,4 +8,4 @@ import { C as VscodeURI, S as LocateResult, _ as GeneratorFnParams, a as defineT
|
|
|
7
8
|
*/
|
|
8
9
|
declare function loadConfig(filepath: VscodeURI | string): Promise<LikeC4ProjectConfig>;
|
|
9
10
|
//#endregion
|
|
10
|
-
export { ConfigFilenames, type GeneratorFn, type GeneratorFnContext, type GeneratorFnParams, type IncludeConfig, type LikeC4ConfigThemeInput, type LikeC4ProjectConfig, type LikeC4ProjectConfigInput, LikeC4ProjectConfigOps, type LikeC4ProjectJsonConfig, type LikeC4StylesConfig, type LikeC4StylesConfigInput, LikeC4StylesConfigSchema, type LocateResult, type ThemeColorValuesInput, defineConfig, defineGenerators, defineStyle, defineTheme, defineThemeColor, isLikeC4Config, isLikeC4JsonConfig, isLikeC4NonJsonConfig, loadConfig };
|
|
11
|
+
export { ConfigFilenames, type GeneratorFn, type GeneratorFnContext, type GeneratorFnParams, type IncludeConfig, type LikeC4ConfigThemeInput, type LikeC4ProjectConfig, type LikeC4ProjectConfigInput, LikeC4ProjectConfigOps, type LikeC4ProjectJsonConfig, type LikeC4StylesConfig, type LikeC4StylesConfigInput, LikeC4StylesConfigSchema, type LocateResult, type ThemeColorValuesInput, type WebappConfig, WebappConfigSchema, type WebappExportFormat, WebappExportFormatSchema, WebappExportFormats, defineConfig, defineGenerators, defineStyle, defineTheme, defineThemeColor, isLikeC4Config, isLikeC4JsonConfig, isLikeC4NonJsonConfig, loadConfig };
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../chunks/rolldown-runtime.mjs";import{a as e,c as t,d as n,f as r,i,
|
|
1
|
+
import"../chunks/rolldown-runtime.mjs";import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"../chunks/src.mjs";import{WebappExportFormats as h}from"../webapp-export-formats.mjs";import g from"json5";import _ from"zod/v4";import{invariant as v}from"@likec4/core";import{logger as y,wrapError as b}from"@likec4/log";import{bundleRequire as x}from"bundle-require";import{defu as S}from"defu";import{formatMessagesSync as C}from"esbuild";import*as w from"node:fs/promises";import{basename as T,dirname as E,relative as D,resolve as O}from"node:path";import{cwd as k}from"node:process";import{hasAtLeast as A,isNonNullish as j,last as M,omit as N}from"remeda";const P=n.pick({extends:!0,styles:!0}).loose(),normalizeExtends=e=>e?Array.isArray(e)?e:[e]:[],parseJsonConfig=async e=>{let t=await w.readFile(e,`utf-8`),n;try{n=g.parse(t.trim()||`{}`)}catch(t){throw b(t,`${e}:`)}if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`${e}: Config must be a JSON object`);let r=P.safeParse(n);if(!r.success)throw Error(`${e}: Invalid config\n`+_.prettifyError(r.error));return r.data},loadJsonConfigs=async(e,t)=>{if(t.includes(e)){let n=t.indexOf(e),r=[...t.slice(n),e].join(` -> `);throw Error(`Config extends cycle detected: ${r}`)}let n=await parseJsonConfig(e),r=normalizeExtends(n.extends),i=[...t,e],a=[];for(let t of r){let n=O(E(e),t);a.push(...await loadJsonConfigs(n,i))}return[...a,n]};async function loadConfig(e){e=typeof e==`string`?e:e.fsPath,y.getChild(`config`).trace`Loading config: ${D(k(),e)}`;let n=E(e),r=T(e),i={name:T(n)};if(t(r)){let t=await loadJsonConfigs(O(e),[]);v(A(t,1),`Expect at least one config`);let n=N(M(t),[`extends`,`styles`]),r=t.map(e=>e.styles).filter(j),a=r.length>0?S({},...r.reverse()):void 0;return s({...i,...n,...a?{styles:a}:{}})}v(o(r),`Invalid name for config file: ${e}`);let{mod:a}=await x({filepath:e,cwd:n,esbuildOptions:{resolveExtensions:[`.ts`,`.mts`,`.cts`,`.mjs`,`.js`,`.cjs`],plugins:[{name:`likec4-config`,setup(e){e.onResolve({filter:/^@?likec4\/config$/},e=>({path:e.path,namespace:`likec4-config`})),e.onEnd(e=>{let t=C(e.errors,{kind:`error`});for(let e of t)y.error(e)}),e.onLoad({filter:/.*/,namespace:`likec4-config`},e=>({contents:`
|
|
2
2
|
// Mock implementation to allow loading config files without bundling @likec4/config
|
|
3
3
|
function mock(x) { return x }
|
|
4
4
|
export {
|
|
@@ -7,4 +7,4 @@ export {
|
|
|
7
7
|
mock as defineStyle,
|
|
8
8
|
mock as defineTheme,
|
|
9
9
|
mock as defineThemeColor,
|
|
10
|
-
}`,loader:`js`}))}}]}});return
|
|
10
|
+
}`,loader:`js`}))}}]}});return s(Object.assign(i,a?.default??a))}export{l as ConfigFilenames,m as LikeC4ProjectConfigOps,i as LikeC4StylesConfigSchema,r as WebappConfigSchema,u as WebappExportFormatSchema,h as WebappExportFormats,p as defineConfig,c as defineGenerators,d as defineStyle,a as defineTheme,e as defineThemeColor,f as isLikeC4Config,t as isLikeC4JsonConfig,o as isLikeC4NonJsonConfig,loadConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=[`png`,`jpg`,`dot`,`d2`,`mmd`,`puml`,`drawio`];export{e as WebappExportFormats};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/config",
|
|
3
|
-
"version": "1.59.
|
|
3
|
+
"version": "1.59.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
"default": "./dist/node/index.mjs"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
+
"./webapp-export-formats": {
|
|
49
|
+
"sources": "./src/webapp-export-formats.ts",
|
|
50
|
+
"default": {
|
|
51
|
+
"types": "./dist/webapp-export-formats.d.mts",
|
|
52
|
+
"default": "./dist/webapp-export-formats.mjs"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
48
55
|
"./package.json": "./package.json",
|
|
49
56
|
"./schema.json": "./schema.json"
|
|
50
57
|
},
|
|
@@ -53,14 +60,14 @@
|
|
|
53
60
|
"access": "public"
|
|
54
61
|
},
|
|
55
62
|
"dependencies": {
|
|
63
|
+
"@likec4/core": "1.59.3",
|
|
64
|
+
"@likec4/log": "1.59.3",
|
|
56
65
|
"json5": "^2.2.3",
|
|
57
66
|
"zod": "^4.4.3",
|
|
58
|
-
"remeda": "^2.
|
|
67
|
+
"remeda": "^2.45.0",
|
|
59
68
|
"defu": "^6.1.7",
|
|
60
69
|
"ufo": "1.6.4",
|
|
61
|
-
"type-fest": "^4.41.0"
|
|
62
|
-
"@likec4/core": "1.59.2",
|
|
63
|
-
"@likec4/log": "1.59.2"
|
|
70
|
+
"type-fest": "^4.41.0"
|
|
64
71
|
},
|
|
65
72
|
"peerDependencies": {
|
|
66
73
|
"bundle-require": "^5.1.0",
|
|
@@ -75,15 +82,15 @@
|
|
|
75
82
|
}
|
|
76
83
|
},
|
|
77
84
|
"devDependencies": {
|
|
85
|
+
"@likec4/tsconfig": "1.59.3",
|
|
86
|
+
"@likec4/devops": "1.59.3",
|
|
78
87
|
"@types/node": "~22.19.19",
|
|
79
88
|
"tsx": "4.22.5",
|
|
80
|
-
"turbo": "2.10.
|
|
89
|
+
"turbo": "2.10.12",
|
|
81
90
|
"typescript": "6.0.3",
|
|
82
91
|
"tsdown": "^0.22.9",
|
|
83
92
|
"nano-spawn": "^2.1.0",
|
|
84
|
-
"vitest": "4.1.
|
|
85
|
-
"@likec4/devops": "1.59.2",
|
|
86
|
-
"@likec4/tsconfig": "1.59.2"
|
|
93
|
+
"vitest": "4.1.11"
|
|
87
94
|
},
|
|
88
95
|
"scripts": {
|
|
89
96
|
"generate": "tsx --conditions=sources scripts/generate.mts",
|
package/schema.json
CHANGED
|
@@ -87,6 +87,9 @@
|
|
|
87
87
|
},
|
|
88
88
|
"landingPage": {
|
|
89
89
|
"$ref": "#/$defs/LandingPageConfig"
|
|
90
|
+
},
|
|
91
|
+
"webapp": {
|
|
92
|
+
"$ref": "#/$defs/WebappConfig"
|
|
90
93
|
}
|
|
91
94
|
},
|
|
92
95
|
"required": [
|
|
@@ -537,6 +540,38 @@
|
|
|
537
540
|
}
|
|
538
541
|
],
|
|
539
542
|
"description": "Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid."
|
|
543
|
+
},
|
|
544
|
+
"WebappConfig": {
|
|
545
|
+
"type": "object",
|
|
546
|
+
"properties": {
|
|
547
|
+
"exportFormats": {
|
|
548
|
+
"default": [
|
|
549
|
+
"png",
|
|
550
|
+
"jpg",
|
|
551
|
+
"dot",
|
|
552
|
+
"d2",
|
|
553
|
+
"mmd",
|
|
554
|
+
"puml",
|
|
555
|
+
"drawio"
|
|
556
|
+
],
|
|
557
|
+
"description": "Webapp export formats enabled in the generated application.\nOmit to enable all export formats. Use an empty array to disable webapp exports.",
|
|
558
|
+
"type": "array",
|
|
559
|
+
"items": {
|
|
560
|
+
"type": "string",
|
|
561
|
+
"enum": [
|
|
562
|
+
"png",
|
|
563
|
+
"jpg",
|
|
564
|
+
"dot",
|
|
565
|
+
"d2",
|
|
566
|
+
"mmd",
|
|
567
|
+
"puml",
|
|
568
|
+
"drawio"
|
|
569
|
+
]
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
"additionalProperties": false,
|
|
574
|
+
"description": "Configuration for the generated web application"
|
|
540
575
|
}
|
|
541
576
|
}
|
|
542
577
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
//
|
|
3
|
+
// Copyright (c) 2023-2026 Denis Davydkov
|
|
4
|
+
// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
// Portions of this file have been modified by NVIDIA CORPORATION & AFFILIATES.
|
|
7
|
+
|
|
1
8
|
export type {
|
|
2
9
|
GeneratorFn,
|
|
3
10
|
GeneratorFnContext,
|
|
@@ -6,10 +13,15 @@ export type {
|
|
|
6
13
|
LikeC4ProjectConfigInput,
|
|
7
14
|
LikeC4ProjectJsonConfig,
|
|
8
15
|
LocateResult,
|
|
16
|
+
WebappConfig,
|
|
17
|
+
WebappExportFormat,
|
|
9
18
|
} from './schema'
|
|
10
19
|
|
|
11
20
|
export {
|
|
12
21
|
LikeC4ProjectConfigOps,
|
|
22
|
+
WebappConfigSchema,
|
|
23
|
+
WebappExportFormats,
|
|
24
|
+
WebappExportFormatSchema,
|
|
13
25
|
} from './schema'
|
|
14
26
|
|
|
15
27
|
export type {
|
package/src/schema.ts
CHANGED
|
@@ -22,6 +22,7 @@ import z from 'zod/v4'
|
|
|
22
22
|
import { ImageAliasesSchema } from './schema.image-alias'
|
|
23
23
|
import { type IncludeConfig, IncludeSchema } from './schema.include'
|
|
24
24
|
import { LikeC4StylesConfigSchema } from './schema.theme'
|
|
25
|
+
import { type WebappExportFormat, WebappExportFormats } from './webapp-export-formats'
|
|
25
26
|
|
|
26
27
|
export interface VscodeURI {
|
|
27
28
|
readonly scheme: string
|
|
@@ -53,6 +54,34 @@ export const ManualLayoutsConfigSchema = z
|
|
|
53
54
|
|
|
54
55
|
export type ManualLayoutsConfig = z.infer<typeof ManualLayoutsConfigSchema>
|
|
55
56
|
|
|
57
|
+
export { WebappExportFormats }
|
|
58
|
+
|
|
59
|
+
export const WebappExportFormatSchema = z.enum(WebappExportFormats)
|
|
60
|
+
|
|
61
|
+
export type { WebappExportFormat }
|
|
62
|
+
|
|
63
|
+
export const WebappConfigSchema = z
|
|
64
|
+
.strictObject({
|
|
65
|
+
exportFormats: z.array(WebappExportFormatSchema)
|
|
66
|
+
.refine(
|
|
67
|
+
(formats) => new Set(formats).size === formats.length,
|
|
68
|
+
{ message: 'Export formats cannot contain duplicates' },
|
|
69
|
+
)
|
|
70
|
+
.default([...WebappExportFormats])
|
|
71
|
+
.meta({
|
|
72
|
+
description: [
|
|
73
|
+
'Webapp export formats enabled in the generated application.',
|
|
74
|
+
'Omit to enable all export formats. Use an empty array to disable webapp exports.',
|
|
75
|
+
].join('\n'),
|
|
76
|
+
}),
|
|
77
|
+
})
|
|
78
|
+
.meta({
|
|
79
|
+
id: 'WebappConfig',
|
|
80
|
+
description: 'Configuration for the generated web application',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
export type WebappConfig = z.infer<typeof WebappConfigSchema>
|
|
84
|
+
|
|
56
85
|
export const LandingPageSchema = z
|
|
57
86
|
.union([
|
|
58
87
|
z.strictObject({
|
|
@@ -128,6 +157,7 @@ export const LikeC4ProjectJsonConfigSchema = z.object({
|
|
|
128
157
|
description: 'Auto-generate scoped views for elements without explicit views. Defaults to false.',
|
|
129
158
|
}),
|
|
130
159
|
landingPage: LandingPageSchema.optional(),
|
|
160
|
+
webapp: WebappConfigSchema.optional(),
|
|
131
161
|
})
|
|
132
162
|
.meta({
|
|
133
163
|
id: 'LikeC4ProjectConfig',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
//
|
|
3
|
+
// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
4
|
+
|
|
5
|
+
export const WebappExportFormats = ['png', 'jpg', 'dot', 'd2', 'mmd', 'puml', 'drawio'] as const
|
|
6
|
+
|
|
7
|
+
export type WebappExportFormat = typeof WebappExportFormats[number]
|