@mmd-toolkit/ast 0.0.0 → 0.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.
- package/LICENSE +21 -0
- package/README.ja.md +38 -0
- package/README.md +38 -0
- package/lib/index.d.mts +9588 -0
- package/package.json +20 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yosuke Ota
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @mmd-toolkit/ast
|
|
2
|
+
|
|
3
|
+
英語版: [README.md](./README.md)
|
|
4
|
+
|
|
5
|
+
[`@mmd-toolkit/parser`](../parser) が返す構文木の TypeScript の型です。
|
|
6
|
+
`Root`、`FlowchartVertex`、`Identifier` など、すべてのノードの型と、
|
|
7
|
+
図種 id の合併型 `DiagramType` を持ちます。
|
|
8
|
+
名前と欄は、仕様の [`ast.md`](../spec/docs/ast.ja.md) のものです。
|
|
9
|
+
|
|
10
|
+
このパッケージは型だけを持ち、実行するコードはありません。
|
|
11
|
+
|
|
12
|
+
mermaid-js とは関係のない、第三者のプロジェクトです。
|
|
13
|
+
|
|
14
|
+
## 導入
|
|
15
|
+
|
|
16
|
+
パーサーの版か、互換のある新しい版を、パーサーと一緒に入れます。
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install @mmd-toolkit/parser
|
|
20
|
+
npm install --save-dev @mmd-toolkit/ast
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
パーサー、`prettier-plugin-mmd`、`@mmd-toolkit/eslint-plugin` は、
|
|
24
|
+
このパッケージを任意の peer 依存にしています。
|
|
25
|
+
利用者が、型を使うときだけダウンロードするようにするためです。
|
|
26
|
+
パーサーは自分の版の `^` を求め、2 つのプラグインはどの版でも受け付けます。
|
|
27
|
+
|
|
28
|
+
## 使い方
|
|
29
|
+
|
|
30
|
+
型は、このパッケージから import します。
|
|
31
|
+
パーサーは export しません。
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { parse } from "@mmd-toolkit/parser"
|
|
35
|
+
import type { Root } from "@mmd-toolkit/ast"
|
|
36
|
+
|
|
37
|
+
const root: Root = parse("flowchart LR\nA --> B\n")
|
|
38
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @mmd-toolkit/ast
|
|
2
|
+
|
|
3
|
+
Japanese version: [README.ja.md](./README.ja.md)
|
|
4
|
+
|
|
5
|
+
The TypeScript types of the syntax tree that [`@mmd-toolkit/parser`](../parser)
|
|
6
|
+
returns: a type for every node, such as `Root`, `FlowchartVertex`, and
|
|
7
|
+
`Identifier`, and `DiagramType`, the union of the diagram type ids. The names
|
|
8
|
+
and fields are those of the specification's [`ast.md`](../spec/docs/ast.md).
|
|
9
|
+
|
|
10
|
+
The package holds types only and no code that runs.
|
|
11
|
+
|
|
12
|
+
It is a third-party project, not affiliated with mermaid-js.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Install it next to the parser, at the version of the parser or a later
|
|
17
|
+
compatible one:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @mmd-toolkit/parser
|
|
21
|
+
npm install --save-dev @mmd-toolkit/ast
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The parser, `prettier-plugin-mmd`, and `@mmd-toolkit/eslint-plugin` declare this
|
|
25
|
+
package as an optional peer dependency, so that their users download it only
|
|
26
|
+
when they use the types. The parser asks for `^` of its own version; the two
|
|
27
|
+
plugins accept any version.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Import the types from this package; the parser does not export them:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { parse } from "@mmd-toolkit/parser"
|
|
35
|
+
import type { Root } from "@mmd-toolkit/ast"
|
|
36
|
+
|
|
37
|
+
const root: Root = parse("flowchart LR\nA --> B\n")
|
|
38
|
+
```
|