ts-graphviz 1.8.3-dev.273c1f434 → 2.0.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/README.md +40 -13
  3. package/lib/adapter.cjs +1 -0
  4. package/lib/adapter.d.ts +1 -0
  5. package/lib/adapter.js +1 -0
  6. package/lib/ast.cjs +1 -0
  7. package/lib/ast.d.ts +1 -0
  8. package/lib/ast.js +1 -0
  9. package/lib/attribute.d.ts +2 -0
  10. package/lib/from-dot.d.ts +10 -0
  11. package/lib/model-factory-builder.d.ts +7 -0
  12. package/lib/model-factory.d.ts +6 -0
  13. package/lib/to-dot.d.ts +7 -0
  14. package/lib/ts-graphviz.cjs +1 -0
  15. package/lib/ts-graphviz.d.ts +7 -0
  16. package/lib/ts-graphviz.js +55 -0
  17. package/lib/types.d.ts +14 -0
  18. package/package.json +76 -119
  19. package/SECURITY.md +0 -5
  20. package/lib/adapter/browser/index.cjs +0 -12
  21. package/lib/adapter/browser/index.d.ts +0 -15
  22. package/lib/adapter/browser/index.js +0 -9
  23. package/lib/adapter/deno/mod.d.ts +0 -13
  24. package/lib/adapter/deno/mod.js +0 -36
  25. package/lib/adapter/node/index.cjs +0 -45
  26. package/lib/adapter/node/index.d.ts +0 -15
  27. package/lib/adapter/node/index.js +0 -42
  28. package/lib/adapter/types/index.cjs +0 -1
  29. package/lib/adapter/types/index.d.ts +0 -134
  30. package/lib/adapter/types/index.js +0 -0
  31. package/lib/adapter/utils/index.cjs +0 -58
  32. package/lib/adapter/utils/index.d.ts +0 -11
  33. package/lib/adapter/utils/index.js +0 -56
  34. package/lib/ast/index.cjs +0 -5775
  35. package/lib/ast/index.d.ts +0 -946
  36. package/lib/ast/index.js +0 -5770
  37. package/lib/common/index.cjs +0 -58
  38. package/lib/common/index.d.ts +0 -4981
  39. package/lib/common/index.js +0 -58
  40. package/lib/core/index.cjs +0 -359
  41. package/lib/core/index.d.ts +0 -347
  42. package/lib/core/index.js +0 -364
  43. package/lib/index.cjs +0 -23
  44. package/lib/index.d.ts +0 -3
  45. package/lib/index.js +0 -2
  46. package/lib/utils/index.cjs +0 -41
  47. package/lib/utils/index.d.ts +0 -34
  48. package/lib/utils/index.js +0 -37
package/CHANGELOG.md ADDED
@@ -0,0 +1,307 @@
1
+ # ts-graphviz
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#956](https://github.com/ts-graphviz/ts-graphviz/pull/956) [`1e4f57a`](https://github.com/ts-graphviz/ts-graphviz/commit/1e4f57aee8a97fa79240c002ef4925b0fa6a0548) Thanks [@kamiazya](https://github.com/kamiazya)! - # ts-graphviz v2
8
+
9
+ ## Why?
10
+
11
+ ### Dropping support for Node.js 14 & 16
12
+
13
+ We are introducing a major version upgrade to ts-graphviz to ensure better performance, security, and compatibility with the latest improvements in the JavaScript ecosystem. With this upgrade, we will no longer support Node.js 14 & 16, which has reached its End-of-Life (EOL), and set the new minimum guaranteed version to **Node.js 18**.
14
+
15
+ This major version upgrade is necessary due to the following reasons:
16
+
17
+ 1. **Breaking Change**: Dropping support for Node.js 14 & 16 is considered a breaking change, which requires a major version upgrade according to semantic versioning principles.
18
+
19
+ 2. **Improved Stability and Performance**: By focusing on LTS versions, we can provide a library that benefits from the stability, long-term support, and performance improvements provided by newer Node.js versions.
20
+
21
+ 3. **Security**: Ensuring that our library is compatible with the latest supported Node.js versions helps to minimize potential security vulnerabilities.
22
+
23
+ To help our users understand our approach to Node.js version support, we have established a clear [Node.js Version Support Policy](#nodejs-version-support-policy) for ts-graphviz.
24
+
25
+ We encourage our users to update their projects to the latest LTS version of Node.js to ensure the best performance, security, and compatibility with ts-graphviz.
26
+
27
+ ## Key Concepts
28
+
29
+ ts-graphviz is a TypeScript library designed to create, manipulate, and render Graphviz DOT language graphs.
30
+
31
+ It is built around several key concepts that make it modular, extensible, and easy to use:
32
+
33
+ 1. **TypeScript-First Design & Type Definitions**: ts-graphviz is designed with TypeScript as its primary language, providing strong typing and ensuring seamless integration with TypeScript projects. This enables users to leverage the full power of TypeScript's type system and tooling while working with Graphviz graphs. The library includes comprehensive type definitions for DOT language elements, making it easier to work with Graphviz elements in a type-safe manner.
34
+
35
+ 2. **Object-Oriented API**: ts-graphviz provides an object-oriented API for creating and manipulating graph elements like graphs, nodes, and edges. This enables users to work with complex graph structures intuitively and efficiently.
36
+
37
+ 3. **Modular Design[New in v2]**: The library is split into multiple packages, each serving a specific purpose. This modular design allows users to pick and choose the functionality they need, resulting in improved maintainability and flexibility.
38
+
39
+ 4. **AST Support**: ts-graphviz includes a module for processing DOT language at the Abstract Syntax Tree (AST) level. This feature allows users to parse and generate DOT language while preserving its structure, making it easier to manipulate and transform graphs programmatically.
40
+
41
+ 5. **Runtime Adapter**: The library provides adapter functions that enable users to execute Graphviz commands across different runtime environments, such as Node.js and Deno. These adapter functions serve as a wrapper, allowing for seamless integration with various platforms.
42
+
43
+ 6. **Extensibility**: ts-graphviz has been designed with extensibility in mind, allowing users to extend its functionality with custom implementations for specific use cases.
44
+
45
+ 7. **Multi-Paradigm Support**: ts-graphviz is designed to accommodate various programming paradigms, such as Object-Oriented Programming, Declarative Programming, and Functional Programming. This ensures that users can choose the programming style that best suits their needs and preferences, making it adaptable and versatile across different use cases and development approaches.
46
+
47
+ By combining these key concepts, ts-graphviz aims to provide a powerful and user-friendly tool for working with Graphviz DOT language in TypeScript projects.
48
+
49
+ # What's changed?
50
+
51
+ ## Package splitting and monorepo-ization
52
+
53
+ ### Purpose
54
+
55
+ The purpose of package splitting and monorepo-ization in the ts-graphviz v2 is to achieve the following objectives:
56
+
57
+ - **Improved modularity**: By separating functionality into distinct packages, the library becomes more modular. This allows users to install and use only the specific components they need, reducing unnecessary dependencies and improving overall performance.
58
+ - **Easier maintainability**: Splitting the library into smaller packages makes it easier for developers to maintain and update each package independently. This allows for faster bug fixes, feature enhancements, and more efficient development cycles.
59
+ - **Clearer dependencies**: Package splitting results in a more explicit dependency structure between components, making it easier for developers to understand and manage dependencies within the project.
60
+ - **Increased flexibility**: With a modular package structure, users can choose to use only the features they need, making it easier to integrate ts-graphviz into a broader range of projects and applications.
61
+ - **Simplified collaboration**: By breaking down the library into separate packages within a monorepo, contributors can focus on specific areas of interest without interfering with other parts of the library. This facilitates collaboration and encourages more developers to contribute to the project.
62
+ - **Centralized management**: Monorepo-ization allows for the centralized management of all the packages. This enables developers to track issues, manage pull requests, and maintain documentation in a single location, increasing efficiency and reducing overhead.
63
+ - **Consistent versioning and releases**: Monorepo-ization ensures that versioning and release processes are consistent across all packages, making it easier to maintain and update the library as a whole.
64
+
65
+ Overall, package splitting and monorepo-ization aim to create a more robust, maintainable, and user-friendly library that better serves the needs of the ts-graphviz community.
66
+
67
+ ### Packages
68
+
69
+ In v2 of ts-graphviz, the library functionality will be split into several packages. The packages to be split are as follows:
70
+
71
+ - **@ts-graphviz/common**: Contains type information related to DOT language attributes, attribute values, and models.
72
+ - **@ts-graphviz/ast**: Includes the module for processing DOT language at the AST (Abstract Syntax Tree) level.
73
+ - **@ts-graphviz/core**: Comprises the implementation of models and functions provided to users.
74
+ - **@ts-graphviz/adapter**: Handles runtime-dependent processing. For example, it provides I/O processing related to image generation in Graphviz on different runtimes, such as Node.js and Deno.
75
+
76
+ To ensure that existing users are not affected, the ts-graphviz package will remain available. This change will result in a clear division of functionality and will improve the scalability and maintainability of the project. However, users of previous versions and users who wish to use the library without extending it will be able to continue to use the ts-graphviz package as is.
77
+
78
+ - **ts-graphviz**: The main package that serves as the entry point for users. It provides a high-level API for creating, manipulating, and rendering Graphviz DOT language graphs. This package depends on the other packages to provide its functionality.
79
+
80
+ Please note that while we strive to maintain compatibility, there might be some minor differences or limitations in the compatibility package compared to the original ts-graphviz library. It is essential to review the documentation and update your code accordingly if needed, but only when you decide to migrate to the new package structure.
81
+
82
+ ### Dependency graph
83
+
84
+ | Package | Summary | Description |
85
+ | -------------------------------------------------------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
86
+ | [ts-graphviz](https://www.npmjs.com/package/ts-graphviz) | Graphviz library for TypeScript | The main package that serves as the entry point for users. It provides a high-level API for creating, manipulating, and rendering Graphviz DOT language graphs. |
87
+ | [@ts-graphviz/common](https://www.npmjs.com/package/@ts-graphviz/common) | Graphviz Types and Utilities | Contains type information related to DOT language attributes, attribute values, and models. |
88
+ | [@ts-graphviz/ast](https://www.npmjs.com/package/@ts-graphviz/ast) | Graphviz AST(Abstract Syntax Tree) Utilities | Includes the module for processing DOT language at the AST (Abstract Syntax Tree) level. |
89
+ | [@ts-graphviz/core](https://www.npmjs.com/package/@ts-graphviz/core) | Graphviz Models for Object-Oriented Programming | Comprises the implementation of models and functions provided to users. |
90
+ | [@ts-graphviz/adapter](https://www.npmjs.com/package/@ts-graphviz/adapter) | Graphviz Runtime adapters for Cross Platform | Handles runtime-dependent processing, such as input/output processing and Renderer implementations for different environments. |
91
+
92
+ ![dependency-graph](https://user-images.githubusercontent.com/35218186/236679412-ccef1f5d-14e8-46d1-808d-28bfe810ffda.svg)
93
+
94
+ ## Node.js Version Support Update
95
+
96
+ Starting with the upcoming release, ts-graphviz will no longer support Node.js 14 & 16, which has reached its End-of-Life (EOL). The new minimum guaranteed version will be **Node.js 18**. This decision allows us to focus on providing a secure and up-to-date library while minimizing the maintenance burden of supporting outdated versions.
97
+
98
+ To minimize disruption for our users, we have established a clear **Node.js Version Support Policy** for our library. This policy helps users understand our approach to Node.js version support and what to expect when using our library.
99
+
100
+ We encourage our users to update their projects to the latest LTS version of Node.js to ensure the best performance, security, and compatibility with ts-graphviz.
101
+
102
+ ### Node.js Version Support Policy
103
+
104
+ Our goal is to provide a stable and secure library for our users while keeping up with improvements in the JavaScript ecosystem. To achieve this, we have established the following Node.js version support policy for ts-graphviz:
105
+
106
+ 1. **Minimum Guaranteed Version**: We guarantee support for the latest Node.js version that has entered Long-Term Support (LTS) at the time of a major release of our library. This ensures that our library benefits from the stability and long-term support provided by LTS versions.
107
+
108
+ 2. **End-of-Life (EOL) Policy**: We will cease support for Node.js versions when they reach their EOL, as defined by the Node.js release schedule. This helps us focus on providing a secure and up-to-date library while minimizing the maintenance burden of supporting outdated versions.
109
+
110
+ 3. **Version Support Communication**: We will communicate our Node.js version support policy in our library's documentation and release notes. When a new major version is released or when a Node.js version enters EOL, we will inform our users through release notes, blog posts, or other relevant channels.
111
+
112
+ 4. **Migration Guides** : When introducing breaking changes due to Node.js version support updates, we will provide migration guides to help our users transition their projects to the new requirements smoothly.
113
+
114
+ ### Migration Guides
115
+
116
+ #### Update Node.js Version
117
+
118
+ To migrate to the new Node.js version support policy, follow these steps:
119
+
120
+ 1. **Check Node.js Version**: First, check the version of Node.js used in your project by running the following command in your terminal:
121
+ ```sh
122
+ node -v
123
+ ```
124
+ 2. **Update Node.js**: If your project is using Node.js 14 or 16, update it to the latest LTS version of Node.js (Node.js 18) by following the installation instructions provided on the official Node.js website or using a version manager like nvm or n.
125
+ 3. **Update Dependencies**: After updating Node.js, review your project's dependencies to ensure that they are compatible with the new Node.js version. Update any dependencies that require changes to work with the latest LTS version of Node.js.
126
+ 4. **Test and Verify**: Test your project with the updated Node.js version to ensure that it works as expected. Verify that all functionality is intact and that there are no compatibility issues with the new Node.js version.
127
+
128
+ By following these steps, you can migrate your project to the latest LTS version of Node.js and ensure compatibility with ts-graphviz.
129
+
130
+ #### Migrate `AttributeKeyDict` type to `Attribute.keys` type
131
+
132
+ `AttributeKeyDict` was deprecated in v1, so it was removed in v2.
133
+ Please modify to use `Attribute.keys`.
134
+
135
+ ```diff
136
+ - import { AttributeKeyDict } from 'ts-graphviz';
137
+ + import { Attribute } from '@ts-graphviz/common';
138
+
139
+ - const foo: AttributeKeyDict = ...;
140
+ + const foo: Attribute.keys = ...;
141
+ ```
142
+
143
+ #### Migrate `ts-graphviz/adapter` to `@ts-graphviz/adapter`
144
+
145
+ To migrate from the `ts-graphviz/adapter` module to the `@ts-graphviz/adapter` module, follow these steps:
146
+
147
+ 1. **Update Import Statements**: Update import statements in your code to use the new module name.
148
+
149
+ ```diff
150
+ - import { } from 'ts-graphviz/adapter';
151
+ + import { } from '@ts-graphviz/adapter';
152
+ ```
153
+
154
+ 2. **Update Package.json**: Update the `ts-graphviz` dependency in your `package.json` file to use the new version of the `@ts-graphviz/adapter` module.
155
+
156
+ ```diff
157
+ - "ts-graphviz": "^1.0.0",
158
+ + "ts-graphviz": "^2.0.0",
159
+ + "@ts-graphviz/adapter": "^2.0.0",
160
+ ```
161
+
162
+ 3. **Update Code References**: Search your codebase for any references to the `ts-graphviz/adapter` module and update them to use the new module name.
163
+
164
+ ```diff
165
+ - import { } from 'ts-graphviz/adapter';
166
+ + import { } from '@ts-graphviz/adapter';
167
+ ```
168
+
169
+ #### Migrate `ts-graphviz/ast` to `@ts-graphviz/ast`
170
+
171
+ To migrate from the `ts-graphviz/adapter` module to the `@ts-graphviz/adapter` module, follow these steps:
172
+
173
+ 1. **Update Import Statements**: Update import statements in your code to use the new module name.
174
+
175
+ ```diff
176
+ - import { } from 'ts-graphviz/ast';
177
+ + import { } from '@ts-graphviz/ast';
178
+ ```
179
+
180
+ 2. **Update Package.json**: Update the `ts-graphviz` dependency in your `package.json` file to use the new version of the `@ts-graphviz/ast` module.
181
+
182
+ ```diff
183
+ - "ts-graphviz": "^1.0.0",
184
+ + "ts-graphviz": "^2.0.0",
185
+ + "@ts-graphviz/ast": "^2.0.0",
186
+ ```
187
+
188
+ 3. **Update Code References**: Search your codebase for any references to the `ts-graphviz/ast` module and update them to use the new module name.
189
+
190
+ ```diff
191
+ - import { } from 'ts-graphviz/ast';
192
+ + import { } from '@ts-graphviz/ast';
193
+ ```
194
+
195
+ #### Migrate Extending the Type System
196
+
197
+ Common types moves to `@ts-graphviz/common` in v2.0.0.
198
+
199
+ If you have extended the type system, you need to update the import path.
200
+
201
+ ##### Use Case: Specifying Custom Graph Layout and Output Formats
202
+
203
+ ```diff
204
+ -import { $keywords } from 'ts-graphviz';
205
+ +import { $keywords } from '@ts-graphviz/common';
206
+ -import { toFile } from 'ts-graphviz/adapter';
207
+ +import { toFile } from '@ts-graphviz/adapter';
208
+
209
+ -// 1. Declare the 'ts-graphviz/adapter' module.
210
+ -declare module 'ts-graphviz/adapter' {
211
+ +// 1. Declare the '@ts-graphviz/adapter' module.
212
+ +declare module '@ts-graphviz/adapter' {
213
+ export namespace Layout {
214
+ // 2. Define the $values interface in the Layout namespace.
215
+ // 3. Inherit from $keywords<'my-custom-algorithm'> and specify the name of the new layout engine in <...>.
216
+ export interface $values extends $keywords<'my-custom-algorithm'> {}
217
+ }
218
+
219
+ export namespace Format {
220
+ // 4. Define the $values interface in the Format namespace.
221
+ // 5. Inherit from $keywords<'mp4'> and specify the name of the new output format in <...>.
222
+ export interface $values extends $keywords<'mp4'> {}
223
+ }
224
+ }
225
+
226
+ toFile('digraph { a -> b }', '/path/to/file', {
227
+ layout: 'my-custom-algorithm',
228
+ format: 'mp4',
229
+ });
230
+ ```
231
+
232
+ ##### Use Case: Adding Custom Attributes
233
+
234
+ ```diff
235
+ - import { digraph, toDot, attribute as _, $keywords } from 'ts-graphviz';
236
+ + import { $keywords } from '@ts-graphviz'/common;
237
+ + import { digraph, toDot, attribute as _ } from 'ts-graphviz';
238
+
239
+ -// 1. Declare the 'ts-graphviz' module.
240
+ -declare module 'ts-graphviz' {
241
+ +// 1. Declare the '@ts-graphviz/common' module.
242
+ +declare module '@ts-graphviz/common' {
243
+ export namespace GraphAttributeKey {
244
+ // 2. Define the $values interface in the GraphAttributeKey namespace.
245
+ // 3. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
246
+ export interface $values extends $keywords<'hoge'> {}
247
+ }
248
+
249
+ export namespace Attribute {
250
+ // 4. Define the $keys interface in the Attribute namespace.
251
+ // 5. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
252
+ export interface $keys extends $keywords<'hoge'> {}
253
+
254
+ // 6. Define the $types interface in the Attribute namespace.
255
+ // 7. Specify the new attribute in the key and define its corresponding value in the value.
256
+ export interface $types {
257
+ hoge: string;
258
+ }
259
+ }
260
+ }
261
+
262
+ console.log(
263
+ toDot(
264
+ digraph((g) => {
265
+ g.set(_.hoge, 'fuga');
266
+ }),
267
+ ),
268
+ );
269
+ ```
270
+
271
+ ## Development
272
+
273
+ ### Package manager
274
+
275
+ Migration from yarn v1 to pnpm has been done for package management.
276
+
277
+ ### Build tool and Test suite
278
+
279
+ To enhance the development experience, the build tool has been changed from rollup to vite, and the test suite from jest to vitest. This was done because jest lacked standard support for monorepo integration and TypeScript, requiring the installation of additional plugins. However, vite and vitest handle these challenges more elegantly, providing a smoother and more efficient development workflow.
280
+
281
+ ### Release flow
282
+
283
+ The release flow has been updated to use the changeset tool to manage changes and releases.
284
+
285
+ This tool allows for a more streamlined and automated release process, making it easier to manage versioning and changelogs across multiple packages within the monorepo.
286
+
287
+ ### Linter an Formatter
288
+
289
+ The linter and formatter have been updated to use biome, respectively.
290
+
291
+ This change was made to ensure consistent code style and formatting across the entire codebase, making it easier to maintain and contribute to the project.
292
+
293
+ ## API Changes
294
+
295
+ - The status of the ModelContext API and other APIs that were provided in beta and alpha have been removed. This is a temporary measure to ensure compliance with the `@microsoft/api-extractor` specification used internally in the d.ts file rollup.
296
+
297
+ ### Patch Changes
298
+
299
+ - [#966](https://github.com/ts-graphviz/ts-graphviz/pull/966) [`d579034`](https://github.com/ts-graphviz/ts-graphviz/commit/d579034d3b834eceafa4aa290c0e0d4fd74a5192) Thanks [@dependabot](https://github.com/apps/dependabot)! - build(deps-dev): bump vite-plugin-dts from 3.7.2 to 3.7.3
300
+
301
+ - [#970](https://github.com/ts-graphviz/ts-graphviz/pull/970) [`54f4565`](https://github.com/ts-graphviz/ts-graphviz/commit/54f45653d89640a16b6baa1a005e963b349fd2cd) Thanks [@dependabot](https://github.com/apps/dependabot)! - build(deps-dev): bump @types/node from 20.11.20 to 20.11.24
302
+
303
+ - Updated dependencies [[`d579034`](https://github.com/ts-graphviz/ts-graphviz/commit/d579034d3b834eceafa4aa290c0e0d4fd74a5192), [`54f4565`](https://github.com/ts-graphviz/ts-graphviz/commit/54f45653d89640a16b6baa1a005e963b349fd2cd), [`1e4f57a`](https://github.com/ts-graphviz/ts-graphviz/commit/1e4f57aee8a97fa79240c002ef4925b0fa6a0548)]:
304
+ - @ts-graphviz/core@2.0.0
305
+ - @ts-graphviz/common@2.0.0
306
+ - @ts-graphviz/ast@2.0.0
307
+ - @ts-graphviz/adapter@2.0.0
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
+ <div align="center">
2
+
1
3
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d6485f9858ed4b3e8ef76611a2896bc4)](https://app.codacy.com/gh/ts-graphviz/ts-graphviz?utm_source=github.com&utm_medium=referral&utm_content=ts-graphviz/ts-graphviz&utm_campaign=Badge_Grade_Settings)
2
4
  [![GitHub Action](https://github.com/kamiazya/ts-graphviz/workflows/NodeCI/badge.svg)](https://github.com/kamiazya/ts-graphviz/actions?workflow=NodeCI)
3
5
  [![npm version](https://badge.fury.io/js/ts-graphviz.svg)](https://badge.fury.io/js/ts-graphviz)
4
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
7
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
6
- [![code style: prettier](https://img.shields.io/badge/code%20style-prettier-ff69b4?logo=prettier&style=flat)](https://github.com/facebook/jest)
7
- [![test: jest](https://img.shields.io/badge/tested%20with-jest-99424f?logo=jest&style=flat)](https://github.com/facebook/jest)
8
+
8
9
  ![node version](https://img.shields.io/node/v/ts-graphviz)
9
10
  [![deno version](https://img.shields.io/badge/deno-^1.28.0-black?logo=deno)](https://github.com/denoland/deno)
10
11
  ![npm](https://img.shields.io/npm/dm/ts-graphviz)
@@ -15,13 +16,21 @@
15
16
 
16
17
  [Graphviz](https://graphviz.gitlab.io/) library for TypeScript.
17
18
 
19
+ 🔗
20
+
18
21
  [![GitHub](https://img.shields.io/badge/-GitHub-181717?logo=GitHub&style=flat)](https://github.com/ts-graphviz/ts-graphviz)
19
22
  [![npm](https://img.shields.io/badge/-npm-CB3837?logo=npm&style=flat)](https://www.npmjs.com/package/ts-graphviz)
20
23
  [![yarn](https://img.shields.io/badge/-yarn-ffffff?logo=Yarn&style=flat)](https://yarnpkg.com/package/ts-graphviz)
21
24
  [![Refarence](https://img.shields.io/badge/-Refarence-3178C6?logo=TypeScript&style=flat&logoColor=fff)](https://ts-graphviz.github.io/ts-graphviz/)
22
25
  [![Suponser](https://img.shields.io/badge/-Suponser-fff?logo=GitHub%20Sponsors&style=flat)](https://github.com/sponsors/kamiazya)
23
26
 
24
- > [English](https://github.com/ts-graphviz/ts-graphviz/blob/main/README.md) | [日本語](https://github.com/ts-graphviz/ts-graphviz/blob/main/README_ja.md)
27
+ [![format: Biome](https://img.shields.io/badge/format%20with-Biome-F7B911?logo=biome&style=flat)](https://biomejs.dev/)
28
+ [![test: Vitest](https://img.shields.io/badge/tested%20with-Vitest-6E9F18?logo=vitest&style=flat)](https://vitest.dev/)
29
+ [![build: Vite](https://img.shields.io/badge/build%20with-Vite-646CFF?logo=vite&style=flat)](https://rollupjs.org/)
30
+
31
+ </div>
32
+
33
+ ---
25
34
 
26
35
  ## Key Features ✨
27
36
 
@@ -33,6 +42,12 @@
33
42
  - Designed to be object-oriented, it provides APIs that can be adapted to both imperative and declarative APIs. You can choose the paradigm that best fits your project.
34
43
  - **Suitable for any use cases**
35
44
  - Both a high-layer API to provide models and a low-layer API to handle ASTs are provided to address any use cases.
45
+ - **Modular and Extensible**
46
+ - The library is split into multiple packages, each serving a specific purpose. This modular design allows users to pick and choose the functionality they need, resulting in improved maintainability and flexibility.
47
+ - **Cross Platform**
48
+ - It supports both Node.js and Deno and Browser.
49
+ - **Customizable**
50
+ - It provides a way to extend the library's type system to customize graph visualization solutions to meet specific needs.
36
51
 
37
52
  ## Installation 💽
38
53
 
@@ -338,7 +353,7 @@ const dot = toDot(g);
338
353
 
339
354
  </details>
340
355
 
341
- ### `ts-graphviz/adapter` Module 🔌
356
+ ### `@ts-graphviz/adapter` Module 🔌
342
357
 
343
358
  > This module status is ![beta](https://img.shields.io/badge/-beta-orange).
344
359
 
@@ -388,7 +403,7 @@ This module provides the following functions.
388
403
 
389
404
  > **Note** Designed to work with Node.js and Deno, Stream is runtime native.
390
405
 
391
- ### `ts-graphviz/ast` Module 🔢
406
+ ### `@ts-graphviz/ast` Module 🔢
392
407
 
393
408
  > This module status is ![beta](https://img.shields.io/badge/-beta-orange).
394
409
 
@@ -414,7 +429,7 @@ Please refer to the TypeScript type definition.
414
429
 
415
430
 
416
431
  ```typescript
417
- import { parse } from 'ts-graphviz/ast';
432
+ import { parse } from '@ts-graphviz/ast';
418
433
 
419
434
  const ast = parse(`
420
435
  digraph example {
@@ -519,11 +534,11 @@ With ts-graphviz, you can extend the library's type system to customize graph vi
519
534
  #### Use Case: Specifying Custom Graph Layout and Output Formats
520
535
 
521
536
  ```ts
522
- import { $keywords } from 'ts-graphviz';
523
- import { toFile } from 'ts-graphviz/adapter';
537
+ import { $keywords } from '@ts-graphviz/common';
538
+ import { toFile } from '@ts-graphviz/adapter';
524
539
 
525
- // 1. Declare the 'ts-graphviz/adapter' module.
526
- declare module 'ts-graphviz/adapter' {
540
+ // 1. Declare the '@ts-graphviz/adapter' module.
541
+ declare module '@ts-graphviz/adapter' {
527
542
  export namespace Layout {
528
543
  // 2. Define the $values interface in the Layout namespace.
529
544
  // 3. Inherit from $keywords<'my-custom-algorithm'> and specify the name of the new layout engine in <...>.
@@ -546,10 +561,11 @@ toFile('digraph { a -> b }', '/path/to/file', {
546
561
  #### Use Case: Adding Custom Attributes
547
562
 
548
563
  ```ts
549
- import { digraph, toDot, attribute as _, $keywords } from 'ts-graphviz';
564
+ import { $keywords } from '@ts-graphviz/common';
565
+ import { digraph, toDot, attribute as _ } from 'ts-graphviz';
550
566
 
551
- // 1. Declare the 'ts-graphviz' module.
552
- declare module 'ts-graphviz' {
567
+ // 1. Declare the '@ts-graphviz/common' module.
568
+ declare module '@ts-graphviz/common' {
553
569
  export namespace GraphAttributeKey {
554
570
  // 2. Define the $values interface in the GraphAttributeKey namespace.
555
571
  // 3. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
@@ -578,6 +594,17 @@ console.log(
578
594
  );
579
595
  ```
580
596
 
597
+ ## Deep dive 🏊‍♂️
598
+
599
+ ### Architecture 🏛
600
+
601
+ See [ARCHITECTURE.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/ARCHITECTURE.md) for more details.
602
+
603
+ ### Security 🛡️
604
+
605
+ See [SECURITY.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/SECURITY.md) for more details.
606
+
607
+
581
608
  ## Who's using `ts-graphviz` 📜
582
609
 
583
610
  - [Apollo GraphQL](https://github.com/apollographql)
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ts-graphviz/adapter");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
@@ -0,0 +1 @@
1
+ export * from '@ts-graphviz/adapter';
package/lib/adapter.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@ts-graphviz/adapter";
package/lib/ast.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ts-graphviz/ast");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
package/lib/ast.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@ts-graphviz/ast';
package/lib/ast.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@ts-graphviz/ast";
@@ -0,0 +1,2 @@
1
+ import { Attribute } from '@ts-graphviz/common';
2
+ export declare const attribute: Attribute.keys;
@@ -0,0 +1,10 @@
1
+ import { ConvertToModelOptions, ParseOptions } from '@ts-graphviz/ast';
2
+ import { EdgeModel, NodeModel, RootGraphModel, SubgraphModel } from '@ts-graphviz/common';
3
+ export interface FromDotOptions<T extends 'Dot' | 'Graph' | 'Node' | 'Edge' | 'Subgraph'> {
4
+ parse?: ParseOptions<T>;
5
+ convert?: ConvertToModelOptions;
6
+ }
7
+ export declare function fromDot(dot: string, options?: FromDotOptions<'Dot' | 'Graph'>): RootGraphModel;
8
+ export declare function fromDot(dot: string, options?: FromDotOptions<'Node'>): NodeModel;
9
+ export declare function fromDot(dot: string, options?: FromDotOptions<'Edge'>): EdgeModel;
10
+ export declare function fromDot(dot: string, options?: FromDotOptions<'Subgraph'>): SubgraphModel;
@@ -0,0 +1,7 @@
1
+ import { ModelsContext } from '@ts-graphviz/common';
2
+ import { ModelFactory } from './types.js';
3
+ export declare function ModelFactoryBuilder(this: ModelsContext, directed: boolean, strictMode: boolean): ModelFactory;
4
+ export declare function createModelFactories(strict: boolean, context?: ModelsContext): Readonly<{
5
+ digraph: ModelFactory;
6
+ graph: ModelFactory;
7
+ }>;
@@ -0,0 +1,6 @@
1
+ import { ModelsContext } from '@ts-graphviz/common';
2
+ import { ModelFactories, ModelFactoriesWithStrict } from './types.js';
3
+ export declare const digraph: import("./types.js").ModelFactory;
4
+ export declare const graph: import("./types.js").ModelFactory;
5
+ export declare const strict: ModelFactories;
6
+ export declare function withContext(models: Partial<ModelsContext>): ModelFactoriesWithStrict;
@@ -0,0 +1,7 @@
1
+ import { ConvertFromModelOptions, PrintOptions } from '@ts-graphviz/ast';
2
+ import { DotObjectModel } from '@ts-graphviz/common';
3
+ export interface ToDotOptions {
4
+ convert?: ConvertFromModelOptions;
5
+ print?: PrintOptions;
6
+ }
7
+ export declare function toDot(model: DotObjectModel, options?: ToDotOptions): string;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@ts-graphviz/core"),n=require("@ts-graphviz/common"),c=require("@ts-graphviz/ast"),h=new Proxy(Object.freeze({}),{get:(t,e)=>e});function u(t,e){return(...r)=>{const l=t?this.Digraph:this.Graph,y=r.find(o=>typeof o=="string"),d=r.find(o=>typeof o=="object"),f=r.find(o=>typeof o=="function"),a=new l(y,e,d);return a.with(this),typeof f=="function"&&f(a),a}}function i(t,e=n.RootModelsContext){return Object.freeze({digraph:u.call(e,!0,t),graph:u.call(e,!1,t)})}const p=i(!1),b=p.digraph,g=p.graph,O=i(!0);function j(t){const e=n.createModelsContext(t);return Object.freeze({...i(!1,e),strict:i(!0,e)})}function m(t,e){const r=c.parse(t,e?.parse);if(Array.isArray(r)||r.type==="Attribute"||r.type==="AttributeList"||r.type==="Comment"||r.type==="NodeRef"||r.type==="NodeRefGroup"||r.type==="Literal")throw new Error;return c.toModel(r,e?.convert)}function w(t,e){const r=c.fromModel(t,e?.convert);return c.stringify(r,e?.print)}s.registerDefault();exports.attribute=h;exports.digraph=b;exports.fromDot=m;exports.graph=g;exports.strict=O;exports.toDot=w;exports.withContext=j;Object.keys(s).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>s[t]})});Object.keys(n).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>n[t]})});
@@ -0,0 +1,7 @@
1
+ export * from '@ts-graphviz/common';
2
+ export * from '@ts-graphviz/core';
3
+ export * from './types.js';
4
+ export * from './attribute.js';
5
+ export * from './model-factory.js';
6
+ export * from './from-dot.js';
7
+ export * from './to-dot.js';
@@ -0,0 +1,55 @@
1
+ import { registerDefault as l } from "@ts-graphviz/core";
2
+ export * from "@ts-graphviz/core";
3
+ import { RootModelsContext as d, createModelsContext as y } from "@ts-graphviz/common";
4
+ export * from "@ts-graphviz/common";
5
+ import { parse as h, toModel as m, fromModel as g, stringify as b } from "@ts-graphviz/ast";
6
+ const j = new Proxy(
7
+ Object.freeze({}),
8
+ {
9
+ get: (r, t) => t
10
+ }
11
+ );
12
+ function f(r, t) {
13
+ return (...e) => {
14
+ const a = r ? this.Digraph : this.Graph, p = e.find((o) => typeof o == "string"), u = e.find(
15
+ (o) => typeof o == "object"
16
+ ), c = e.find(
17
+ (o) => typeof o == "function"
18
+ ), i = new a(p, t, u);
19
+ return i.with(this), typeof c == "function" && c(i), i;
20
+ };
21
+ }
22
+ function n(r, t = d) {
23
+ return Object.freeze({
24
+ digraph: f.call(t, !0, r),
25
+ graph: f.call(t, !1, r)
26
+ });
27
+ }
28
+ const s = n(!1), A = s.digraph, C = s.graph, D = n(!0);
29
+ function z(r) {
30
+ const t = y(r);
31
+ return Object.freeze({
32
+ ...n(!1, t),
33
+ strict: n(!0, t)
34
+ });
35
+ }
36
+ function G(r, t) {
37
+ const e = h(r, t?.parse);
38
+ if (Array.isArray(e) || e.type === "Attribute" || e.type === "AttributeList" || e.type === "Comment" || e.type === "NodeRef" || e.type === "NodeRefGroup" || e.type === "Literal")
39
+ throw new Error();
40
+ return m(e, t?.convert);
41
+ }
42
+ function O(r, t) {
43
+ const e = g(r, t?.convert);
44
+ return b(e, t?.print);
45
+ }
46
+ l();
47
+ export {
48
+ j as attribute,
49
+ A as digraph,
50
+ G as fromDot,
51
+ C as graph,
52
+ D as strict,
53
+ O as toDot,
54
+ z as withContext
55
+ };
package/lib/types.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { GraphAttributesObject, RootGraphModel } from '@ts-graphviz/common';
2
+ export interface ModelFactory {
3
+ (id?: string, attributes?: GraphAttributesObject, callback?: (g: RootGraphModel) => void): RootGraphModel;
4
+ (attributes?: GraphAttributesObject, callback?: (g: RootGraphModel) => void): RootGraphModel;
5
+ (id?: string, callback?: (g: RootGraphModel) => void): RootGraphModel;
6
+ (callback?: (g: RootGraphModel) => void): RootGraphModel;
7
+ }
8
+ export interface ModelFactories {
9
+ digraph: ModelFactory;
10
+ graph: ModelFactory;
11
+ }
12
+ export interface ModelFactoriesWithStrict extends ModelFactories {
13
+ strict: ModelFactories;
14
+ }