@likec4/generators 1.40.0 → 1.41.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,2 +1,4 @@
1
1
  import { type AnyLikeC4Model } from '@likec4/core/model';
2
- export declare function generateAux(model: AnyLikeC4Model): string;
2
+ export declare function generateAux(model: AnyLikeC4Model, options?: {
3
+ useCorePackage?: boolean;
4
+ }): string;
@@ -22,9 +22,10 @@ function elementIdToUnion(_elements) {
22
22
  );
23
23
  return union.join("\n").trimStart();
24
24
  }
25
- export function generateAux(model) {
25
+ export function generateAux(model, options = {}) {
26
+ const { useCorePackage = false } = options;
26
27
  return `
27
- import type { Aux, SpecAux } from '@likec4/core/types';
28
+ import type { Aux, SpecAux } from '${useCorePackage ? "@likec4/core/types" : "likec4/model"}';
28
29
 
29
30
  export type $Specs = SpecAux<
30
31
  // Element kinds
@@ -1,2 +1,4 @@
1
1
  import type { LikeC4Model } from '@likec4/core/model';
2
- export declare function generateLikeC4Model(model: LikeC4Model<any>): string;
2
+ export declare function generateLikeC4Model(model: LikeC4Model<any>, options?: {
3
+ useCorePackage?: boolean;
4
+ }): string;
@@ -1,7 +1,8 @@
1
1
  import JSON5 from "json5";
2
2
  import { generateAux } from "./generate-aux.js";
3
- export function generateLikeC4Model(model) {
4
- const aux = generateAux(model);
3
+ export function generateLikeC4Model(model, options = {}) {
4
+ const aux = generateAux(model, options);
5
+ const { useCorePackage = false } = options;
5
6
  return `
6
7
  /* prettier-ignore-start */
7
8
  /* eslint-disable */
@@ -11,7 +12,7 @@ export function generateLikeC4Model(model) {
11
12
  * DO NOT EDIT MANUALLY!
12
13
  ******************************************************************************/
13
14
 
14
- import { LikeC4Model } from '@likec4/core/model'
15
+ import { LikeC4Model } from '${useCorePackage ? "@likec4/core" : "likec4"}/model'
15
16
  ${aux}
16
17
 
17
18
  export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(${JSON5.stringify(model.$data, { space: 2, quote: "'" })} as any) as any
@@ -1,2 +1,4 @@
1
1
  import type { AnyLikeC4Model } from '@likec4/core/model';
2
- export declare function generateReactTypes(model: AnyLikeC4Model): string;
2
+ export declare function generateReactTypes(model: AnyLikeC4Model, options?: {
3
+ useCorePackage?: boolean;
4
+ }): string;
@@ -1,8 +1,9 @@
1
1
  import { invariant } from "@likec4/core/utils";
2
2
  import { generateAux } from "../model/generate-aux.js";
3
- export function generateReactTypes(model) {
3
+ export function generateReactTypes(model, options = {}) {
4
+ const { useCorePackage = false } = options;
4
5
  invariant(!model.isParsed(), "can not generate react types for parsed model");
5
- const aux = generateAux(model);
6
+ const aux = generateAux(model, options);
6
7
  return `
7
8
  /* prettier-ignore-start */
8
9
  /* eslint-disable */
@@ -14,8 +15,8 @@ export function generateReactTypes(model) {
14
15
 
15
16
  import type { PropsWithChildren } from 'react'
16
17
  import type { JSX } from 'react/jsx-runtime'
17
- import type { LikeC4Model } from '@likec4/core/model'
18
- import type { DiagramView } from '@likec4/core/types'
18
+ import type { LikeC4Model } from '${useCorePackage ? "@likec4/core" : "likec4"}/model'
19
+ import type { DiagramView } from '${useCorePackage ? "@likec4/core/types" : "likec4/model"}'
19
20
  import type {
20
21
  LikeC4ViewProps as GenericLikeC4ViewProps,
21
22
  ReactLikeC4Props as GenericReactLikeC4Props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/generators",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -39,14 +39,14 @@
39
39
  "json5": "^2.2.3",
40
40
  "langium": "3.5.0",
41
41
  "remeda": "^2.30.0",
42
- "@likec4/core": "1.40.0"
42
+ "@likec4/core": "1.41.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "~20.19.11",
46
46
  "typescript": "5.9.2",
47
47
  "unbuild": "3.5.0",
48
48
  "vitest": "3.2.4",
49
- "@likec4/tsconfig": "1.40.0"
49
+ "@likec4/tsconfig": "1.41.0"
50
50
  },
51
51
  "scripts": {
52
52
  "typecheck": "tsc -b --verbose",
@@ -28,9 +28,10 @@ function elementIdToUnion(_elements: Record<string, { id: string }>) {
28
28
  return union.join('\n').trimStart()
29
29
  }
30
30
 
31
- export function generateAux(model: AnyLikeC4Model) {
31
+ export function generateAux(model: AnyLikeC4Model, options: { useCorePackage?: boolean } = {}) {
32
+ const { useCorePackage = false } = options
32
33
  return `
33
- import type { Aux, SpecAux } from '@likec4/core/types';
34
+ import type { Aux, SpecAux } from '${useCorePackage ? '@likec4/core/types' : 'likec4/model'}';
34
35
 
35
36
  export type $Specs = SpecAux<
36
37
  // Element kinds
@@ -2,8 +2,9 @@ import type { LikeC4Model } from '@likec4/core/model'
2
2
  import JSON5 from 'json5'
3
3
  import { generateAux } from './generate-aux'
4
4
 
5
- export function generateLikeC4Model(model: LikeC4Model<any>) {
6
- const aux = generateAux(model)
5
+ export function generateLikeC4Model(model: LikeC4Model<any>, options: { useCorePackage?: boolean } = {}) {
6
+ const aux = generateAux(model, options)
7
+ const { useCorePackage = false } = options
7
8
 
8
9
  return `
9
10
  /* prettier-ignore-start */
@@ -14,7 +15,7 @@ export function generateLikeC4Model(model: LikeC4Model<any>) {
14
15
  * DO NOT EDIT MANUALLY!
15
16
  ******************************************************************************/
16
17
 
17
- import { LikeC4Model } from '@likec4/core/model'
18
+ import { LikeC4Model } from '${useCorePackage ? '@likec4/core' : 'likec4'}/model'
18
19
  ${aux}
19
20
 
20
21
  export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(${
@@ -2,9 +2,10 @@ import type { AnyLikeC4Model } from '@likec4/core/model'
2
2
  import { invariant } from '@likec4/core/utils'
3
3
  import { generateAux } from '../model/generate-aux'
4
4
 
5
- export function generateReactTypes(model: AnyLikeC4Model) {
5
+ export function generateReactTypes(model: AnyLikeC4Model, options: { useCorePackage?: boolean } = {}) {
6
+ const { useCorePackage = false } = options
6
7
  invariant(!model.isParsed(), 'can not generate react types for parsed model')
7
- const aux = generateAux(model)
8
+ const aux = generateAux(model, options)
8
9
 
9
10
  return `
10
11
  /* prettier-ignore-start */
@@ -17,8 +18,8 @@ export function generateReactTypes(model: AnyLikeC4Model) {
17
18
 
18
19
  import type { PropsWithChildren } from 'react'
19
20
  import type { JSX } from 'react/jsx-runtime'
20
- import type { LikeC4Model } from '@likec4/core/model'
21
- import type { DiagramView } from '@likec4/core/types'
21
+ import type { LikeC4Model } from '${useCorePackage ? '@likec4/core' : 'likec4'}/model'
22
+ import type { DiagramView } from '${useCorePackage ? '@likec4/core/types' : 'likec4/model'}'
22
23
  import type {
23
24
  LikeC4ViewProps as GenericLikeC4ViewProps,
24
25
  ReactLikeC4Props as GenericReactLikeC4Props