@likec4/core 1.2.2 → 1.3.0

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.
@@ -1,4 +1,9 @@
1
1
  import type { Opaque } from './opaque';
2
2
  export type NonEmptyArray<T> = [T, ...T[]] | [...T[], T];
3
3
  export type IconUrl = Opaque<string, 'IconUrl'>;
4
+ export type Point = readonly [x: number, y: number];
5
+ export interface XYPosition {
6
+ x: number;
7
+ y: number;
8
+ }
4
9
  //# sourceMappingURL=_common.d.ts.map
@@ -6,5 +6,6 @@ export * from './opaque';
6
6
  export * from './relation';
7
7
  export * from './theme';
8
8
  export * from './view';
9
+ export * from './view-changes';
9
10
  export * as Expr from './expression';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -6,5 +6,6 @@ export * from './opaque';
6
6
  export * from './relation';
7
7
  export * from './theme';
8
8
  export * from './view';
9
+ export * from './view-changes';
9
10
  import * as Expr_1 from './expression';
10
11
  export { Expr_1 as Expr };
@@ -0,0 +1,30 @@
1
+ import type { NonEmptyArray, XYPosition } from './_common';
2
+ import type { BorderStyle, ElementShape, Fqn } from './element';
3
+ import type { ThemeColor } from './theme';
4
+ import type { EdgeId } from './view';
5
+ export declare namespace ViewChanges {
6
+ interface ChangeElementStyle {
7
+ op: 'change-element-style';
8
+ style: {
9
+ border?: BorderStyle;
10
+ opacity?: number;
11
+ shape?: ElementShape;
12
+ color?: ThemeColor;
13
+ };
14
+ targets: NonEmptyArray<Fqn>;
15
+ }
16
+ interface SaveManualLayout {
17
+ op: 'save-manual-layout';
18
+ nodes: Record<Fqn, {
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ }>;
24
+ edges: Record<EdgeId, {
25
+ controlPoints: XYPosition[];
26
+ }>;
27
+ }
28
+ }
29
+ export type ViewChangeOp = ViewChanges.ChangeElementStyle | ViewChanges.SaveManualLayout;
30
+ //# sourceMappingURL=view-changes.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { IconUrl, NonEmptyArray } from './_common';
1
+ import type { IconUrl, NonEmptyArray, Point, XYPosition } from './_common';
2
2
  import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element';
3
3
  import type { CustomElementExpr, ElementExpression, Expression } from './expression';
4
4
  import type { Opaque } from './opaque';
@@ -50,6 +50,10 @@ export interface BasicView<ViewType extends 'element' | 'dynamic' = 'element' |
50
50
  * Undefined if the view is auto-generated.
51
51
  */
52
52
  readonly relativePath?: string;
53
+ /**
54
+ * If the view is changed manually this field contains the layout data.
55
+ */
56
+ readonly manualLayout?: ViewManualLayout | undefined;
53
57
  }
54
58
  export interface BasicElementView extends BasicView<'element'> {
55
59
  readonly viewOf?: Fqn;
@@ -147,7 +151,6 @@ export interface ComputedDynamicView extends Omit<DynamicView, 'rules' | 'steps'
147
151
  export declare function isComputedDynamicView(view: ComputedView): view is ComputedDynamicView;
148
152
  export type ComputedView = ComputedElementView | ComputedDynamicView;
149
153
  export declare function isComputedElementView(view: ComputedView): view is ComputedElementView;
150
- export type Point = readonly [x: number, y: number];
151
154
  export type BBox = {
152
155
  x: number;
153
156
  y: number;
@@ -184,4 +187,15 @@ export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
184
187
  readonly width: number;
185
188
  readonly height: number;
186
189
  }
190
+ export interface ViewManualLayout {
191
+ readonly nodes: Record<Fqn, {
192
+ x: number;
193
+ y: number;
194
+ width: number;
195
+ height: number;
196
+ }>;
197
+ readonly edges: Record<EdgeId, {
198
+ controlPoints: XYPosition[];
199
+ }>;
200
+ }
187
201
  //# sourceMappingURL=view.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -14,7 +14,8 @@
14
14
  "typecheck": "tsc --noEmit",
15
15
  "prepack": "tsc",
16
16
  "lint": "run -T eslint src/ --fix",
17
- "test": "run -T vitest run",
17
+ "test": "vitest run --no-isolate",
18
+ "test:watch": "vitest",
18
19
  "clean": "run -T rimraf dist"
19
20
  },
20
21
  "files": [
@@ -70,7 +71,7 @@
70
71
  "type-fest": "^4.18.2"
71
72
  },
72
73
  "devDependencies": {
73
- "@likec4/tsconfig": "1.2.2",
74
+ "@likec4/tsconfig": "1.3.0",
74
75
  "@total-typescript/ts-reset": "^0.5.1",
75
76
  "execa": "^9.1.0",
76
77
  "typescript": "^5.4.5",
@@ -3,3 +3,10 @@ import type { Opaque } from './opaque'
3
3
  export type NonEmptyArray<T> = [T, ...T[]] | [...T[], T]
4
4
 
5
5
  export type IconUrl = Opaque<string, 'IconUrl'>
6
+
7
+ export type Point = readonly [x: number, y: number]
8
+
9
+ export interface XYPosition {
10
+ x: number
11
+ y: number
12
+ }
@@ -6,5 +6,6 @@ export * from './opaque'
6
6
  export * from './relation'
7
7
  export * from './theme'
8
8
  export * from './view'
9
+ export * from './view-changes'
9
10
 
10
11
  export * as Expr from './expression'
@@ -0,0 +1,31 @@
1
+ import type { NonEmptyArray, XYPosition } from './_common'
2
+ import type { BorderStyle, ElementShape, Fqn } from './element'
3
+ import type { ThemeColor } from './theme'
4
+ import type { EdgeId } from './view'
5
+
6
+ export namespace ViewChanges {
7
+ export interface ChangeElementStyle {
8
+ op: 'change-element-style'
9
+ style: {
10
+ border?: BorderStyle
11
+ opacity?: number
12
+ shape?: ElementShape
13
+ color?: ThemeColor
14
+ }
15
+ targets: NonEmptyArray<Fqn>
16
+ }
17
+
18
+ export interface SaveManualLayout {
19
+ op: 'save-manual-layout'
20
+ nodes: Record<Fqn, {
21
+ x: number
22
+ y: number
23
+ width: number
24
+ height: number
25
+ }>
26
+ edges: Record<EdgeId, {
27
+ controlPoints: XYPosition[]
28
+ }>
29
+ }
30
+ }
31
+ export type ViewChangeOp = ViewChanges.ChangeElementStyle | ViewChanges.SaveManualLayout
package/src/types/view.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isNullish } from 'remeda'
2
- import type { IconUrl, NonEmptyArray } from './_common'
2
+ import type { IconUrl, NonEmptyArray, Point, XYPosition } from './_common'
3
3
  import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element'
4
4
  import type { CustomElementExpr, ElementExpression, Expression } from './expression'
5
5
  import type { Opaque } from './opaque'
@@ -70,6 +70,11 @@ export interface BasicView<ViewType extends 'element' | 'dynamic' = 'element' |
70
70
  * Undefined if the view is auto-generated.
71
71
  */
72
72
  readonly relativePath?: string
73
+
74
+ /**
75
+ * If the view is changed manually this field contains the layout data.
76
+ */
77
+ readonly manualLayout?: ViewManualLayout | undefined
73
78
  }
74
79
 
75
80
  export interface BasicElementView extends BasicView<'element'> {
@@ -214,8 +219,6 @@ export function isComputedElementView(view: ComputedView): view is ComputedEleme
214
219
  return isNullish(view.__) || view.__ === 'element'
215
220
  }
216
221
 
217
- export type Point = readonly [x: number, y: number]
218
-
219
222
  // Bounding box
220
223
  export type BBox = {
221
224
  x: number
@@ -261,3 +264,15 @@ export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
261
264
  readonly width: number
262
265
  readonly height: number
263
266
  }
267
+
268
+ export interface ViewManualLayout {
269
+ readonly nodes: Record<Fqn, {
270
+ x: number
271
+ y: number
272
+ width: number
273
+ height: number
274
+ }>
275
+ readonly edges: Record<EdgeId, {
276
+ controlPoints: XYPosition[]
277
+ }>
278
+ }