@likec4/core 1.0.2 → 1.1.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@likec4/core`
2
2
 
3
- [docs](https://likec4.dev/docs/)
3
+ [docs](https://docs.likec4.dev/)
4
4
 
5
5
  Package contains:
6
6
 
@@ -1,4 +1,3 @@
1
- import stringify from 'safe-stable-stringify';
2
1
  import { CustomError } from 'ts-custom-error';
3
2
  import { isString } from '../utils/guards';
4
3
  /**
@@ -62,7 +61,7 @@ export function normalizeError(e) {
62
61
  if (e instanceof BaseError || e instanceof Error) {
63
62
  return e;
64
63
  }
65
- const message = isString(e) ? e : stringify(e);
64
+ const message = isString(e) ? e : String(e);
66
65
  const error = new UnknownError(message);
67
66
  Error.captureStackTrace(error, normalizeError);
68
67
  return error;
@@ -88,8 +87,7 @@ export class NonExhaustiveError extends BaseError {
88
87
  }
89
88
  }
90
89
  export function nonexhaustive(value) {
91
- const val = typeof value === 'string' ? value : stringify(value);
92
- throw new NonExhaustiveError(`NonExhaustive value: ${val}`);
90
+ throw new NonExhaustiveError(`NonExhaustive value: ${value}`);
93
91
  }
94
92
  export class InvalidModelError extends BaseError {
95
93
  constructor(message, options) {
@@ -1,5 +1,5 @@
1
1
  import type { IconUrl, NonEmptyArray } from './_common';
2
- import type { ElementKind, ElementShape, Fqn, Tag } from './element';
2
+ import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element';
3
3
  import type { Opaque } from './opaque';
4
4
  import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation';
5
5
  import type { ThemeColor } from './theme';
@@ -19,8 +19,15 @@ export interface ComputedNode {
19
19
  inEdges: EdgeId[];
20
20
  outEdges: EdgeId[];
21
21
  shape: ElementShape;
22
+ /**
23
+ * @deprecated Use `style` instead
24
+ */
22
25
  color: ThemeColor;
26
+ /**
27
+ * @deprecated Use `style` instead
28
+ */
23
29
  icon?: IconUrl;
30
+ style: ElementStyle;
24
31
  navigateTo?: ViewID;
25
32
  level: number;
26
33
  depth?: number;
@@ -3,13 +3,16 @@ import type { Opaque } from './opaque';
3
3
  import type { ThemeColor } from './theme';
4
4
  export type Fqn = Opaque<string, 'Fqn'>;
5
5
  export declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
6
+ export declare const BorderStyles: readonly ["solid", "dashed", "dotted", "none"];
7
+ export type BorderStyle = typeof BorderStyles[number];
6
8
  export type ElementKind = Opaque<string, 'ElementKind'>;
7
9
  export declare const ElementShapes: readonly ["rectangle", "person", "browser", "mobile", "cylinder", "storage", "queue"];
8
10
  export type ElementShape = typeof ElementShapes[number];
9
11
  export declare const DefaultThemeColor = "primary";
10
12
  export declare const DefaultElementShape = "rectangle";
11
13
  export interface ElementStyle {
12
- shape?: ElementShape;
14
+ border?: BorderStyle;
15
+ opacity?: number;
13
16
  }
14
17
  export type Tag = Opaque<string, 'Tag'>;
15
18
  export interface TagSpec {
@@ -27,4 +30,5 @@ export interface Element {
27
30
  readonly icon?: IconUrl;
28
31
  readonly shape?: ElementShape;
29
32
  readonly color?: ThemeColor;
33
+ readonly style?: ElementStyle;
30
34
  }
@@ -1,6 +1,7 @@
1
1
  export function AsFqn(name, parent) {
2
2
  return (parent ? parent + '.' + name : name);
3
3
  }
4
+ export const BorderStyles = ['solid', 'dashed', 'dotted', 'none'];
4
5
  export const ElementShapes = [
5
6
  'rectangle',
6
7
  'person',
@@ -1,4 +1,5 @@
1
- import type { ElementKind, ElementShape, Fqn, Tag } from './element';
1
+ import type { IconUrl } from './_common';
2
+ import type { BorderStyle, ElementKind, ElementShape, Fqn, Tag } from './element';
2
3
  import type { ThemeColor } from './theme';
3
4
  import type { ViewID } from './view';
4
5
  interface BaseExpr {
@@ -33,6 +34,9 @@ export interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
33
34
  technology?: string;
34
35
  shape?: ElementShape;
35
36
  color?: ThemeColor;
37
+ icon?: IconUrl;
38
+ border?: BorderStyle;
39
+ opacity?: number;
36
40
  navigateTo?: ViewID;
37
41
  };
38
42
  }
@@ -1,5 +1,5 @@
1
1
  import type { IconUrl, NonEmptyArray } from './_common';
2
- import type { ElementShape, Fqn, Tag } from './element';
2
+ import type { ElementShape, ElementStyle, Fqn, Tag } from './element';
3
3
  import type { ElementExpression, Expression } from './expression';
4
4
  import type { Opaque } from './opaque';
5
5
  import type { ThemeColor } from './theme';
@@ -14,7 +14,7 @@ export type ViewRuleExpression = {
14
14
  export declare function isViewRuleExpression(rule: ViewRule): rule is ViewRuleExpression;
15
15
  export interface ViewRuleStyle {
16
16
  targets: ElementExpression[];
17
- style: {
17
+ style: ElementStyle & {
18
18
  color?: ThemeColor;
19
19
  shape?: ElementShape;
20
20
  icon?: IconUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -67,12 +67,12 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "remeda": "^1.61.0",
70
- "safe-stable-stringify": "^2.4.3",
71
- "ts-custom-error": "^3.3.1"
70
+ "ts-custom-error": "^3.3.1",
71
+ "type-fest": "^4.18.2"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@total-typescript/ts-reset": "^0.5.1",
75
- "execa": "^8.0.1",
75
+ "execa": "^9.1.0",
76
76
  "typescript": "^5.4.5",
77
77
  "vitest": "~1.5.2"
78
78
  },