@podlite/schema 0.0.3 → 0.0.7
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/CHANGELOG.md +18 -0
- package/lib/ast-helpers.d.ts +1 -0
- package/lib/ast-helpers.js +15 -0
- package/lib/ast-inerator.d.ts +7 -0
- package/lib/ast-inerator.js +70 -0
- package/lib/blocks-helpers.d.ts +27 -0
- package/lib/blocks-helpers.js +54 -34
- package/lib/helpers.d.ts +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +38 -52
- package/lib/query-helpers.d.ts +27 -0
- package/lib/query-helpers.js +133 -0
- package/lib/types.d.ts +332 -0
- package/package.json +21 -11
- package/schema/AstTree.json +990 -160
- package/schema/PodliteDocument.json +990 -160
- package/schema/index.d.ts +3 -0
- package/schema/index.js +4 -0
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
export interface RuleHandler<T = any> {
|
|
2
|
+
(writer: any, processor: any, tree: PodliteDocument): (node: T, ctx: any, interator: any) => void | AstTree | PodNode;
|
|
3
|
+
}
|
|
4
|
+
export interface Plugin {
|
|
5
|
+
toAst?: RuleHandler;
|
|
6
|
+
toAstAfter?: RuleHandler;
|
|
7
|
+
toHtml?: RuleHandler;
|
|
8
|
+
}
|
|
9
|
+
export interface Plugins {
|
|
10
|
+
[name: string]: Plugin;
|
|
11
|
+
}
|
|
12
|
+
export interface RulesStrict {
|
|
13
|
+
'A<>': RuleHandler<FormattingCodeA>;
|
|
14
|
+
'B<>': RuleHandler<FormattingCodeB>;
|
|
15
|
+
'C<>': RuleHandler<FormattingCodeC>;
|
|
16
|
+
'E<>': RuleHandler<FormattingCodeE>;
|
|
17
|
+
'D<>': RuleHandler<FormattingCodeD>;
|
|
18
|
+
'I<>': RuleHandler<FormattingCodeI>;
|
|
19
|
+
'K<>': RuleHandler<FormattingCodeAny>;
|
|
20
|
+
'R<>': RuleHandler<FormattingCodeAny>;
|
|
21
|
+
'T<>': RuleHandler<FormattingCodeAny>;
|
|
22
|
+
'V<>': RuleHandler<FormattingCodeAny>;
|
|
23
|
+
'N<>': RuleHandler<FormattingCodeN>;
|
|
24
|
+
'X<>': RuleHandler<FormattingCodeX>;
|
|
25
|
+
'S<>': RuleHandler<FormattingCodeS>;
|
|
26
|
+
'L<>': RuleHandler<FormattingCodeL>;
|
|
27
|
+
'U<>': RuleHandler<FormattingCodeAny>;
|
|
28
|
+
'Z<>': RuleHandler<FormattingCodeAny>;
|
|
29
|
+
'pod': RuleHandler<Para>;
|
|
30
|
+
'root': RuleHandler<RootBlock>;
|
|
31
|
+
':para': RuleHandler<Para>;
|
|
32
|
+
':text': RuleHandler<Text>;
|
|
33
|
+
':blankline': RuleHandler<BlankLine>;
|
|
34
|
+
':ambient': RuleHandler<Ambient>;
|
|
35
|
+
':code': RuleHandler<Code>;
|
|
36
|
+
':verbatim': RuleHandler<Verbatim>;
|
|
37
|
+
':list': RuleHandler<List>;
|
|
38
|
+
':config': RuleHandler<BlockConfig>;
|
|
39
|
+
':alias': RuleHandler<Alias>;
|
|
40
|
+
'data': RuleHandler<BlockData>;
|
|
41
|
+
'code': RuleHandler<BlockCode>;
|
|
42
|
+
'para': RuleHandler<BlockPara>;
|
|
43
|
+
'defn': RuleHandler<BlockDefn>;
|
|
44
|
+
'nested': RuleHandler<BlockNested>;
|
|
45
|
+
'output': RuleHandler<BlockOutput>;
|
|
46
|
+
'input': RuleHandler<BlockInput>;
|
|
47
|
+
'image': RuleHandler<BlockImage>;
|
|
48
|
+
':image': RuleHandler<Image>;
|
|
49
|
+
'item:block': RuleHandler<BlockItem>;
|
|
50
|
+
'item': RuleHandler<BlockItem>;
|
|
51
|
+
'comment:block': RuleHandler<BlockComment>;
|
|
52
|
+
'comment': RuleHandler<BlockComment>;
|
|
53
|
+
'head:block': RuleHandler<BlockHead>;
|
|
54
|
+
'head': RuleHandler<BlockHead>;
|
|
55
|
+
':fcode': RuleHandler<FormattingCodes>;
|
|
56
|
+
'table:block': RuleHandler<BlockTable>;
|
|
57
|
+
'table': RuleHandler<BlockTable>;
|
|
58
|
+
':separator': RuleHandler<Separator>;
|
|
59
|
+
'table_row': RuleHandler<TableRow>;
|
|
60
|
+
'table_cell': RuleHandler<TableCell>;
|
|
61
|
+
'table_head': RuleHandler<TableHead>;
|
|
62
|
+
':toc': RuleHandler<Toc>;
|
|
63
|
+
':toc-list': RuleHandler<TocList>;
|
|
64
|
+
':toc-item': RuleHandler<TocItem>;
|
|
65
|
+
'Diagram': RuleHandler<BlockDiagram>;
|
|
66
|
+
'Image': RuleHandler<BlockNamed>;
|
|
67
|
+
}
|
|
68
|
+
export interface Rules extends RulesStrict {
|
|
69
|
+
[name: string]: RuleHandler;
|
|
70
|
+
}
|
|
71
|
+
export interface Position {
|
|
72
|
+
line: number;
|
|
73
|
+
column: number;
|
|
74
|
+
offset: number;
|
|
75
|
+
}
|
|
76
|
+
export interface Location {
|
|
77
|
+
start: Position;
|
|
78
|
+
end: Position;
|
|
79
|
+
}
|
|
80
|
+
export interface Image {
|
|
81
|
+
type: 'image';
|
|
82
|
+
src: string;
|
|
83
|
+
alt?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface Toc {
|
|
86
|
+
type: 'toc';
|
|
87
|
+
title?: string;
|
|
88
|
+
content: TocList;
|
|
89
|
+
}
|
|
90
|
+
export interface TocList {
|
|
91
|
+
type: 'toc-list';
|
|
92
|
+
level: number;
|
|
93
|
+
content: Array<TocItem | TocList>;
|
|
94
|
+
}
|
|
95
|
+
export interface TocItem {
|
|
96
|
+
type: 'toc-item';
|
|
97
|
+
node: PodNode;
|
|
98
|
+
content: Array<Node>;
|
|
99
|
+
}
|
|
100
|
+
export interface BlockImage extends Omit<Block, 'content'> {
|
|
101
|
+
name: 'image';
|
|
102
|
+
caption?: string;
|
|
103
|
+
link?: string;
|
|
104
|
+
content: [Image, BlockCaption];
|
|
105
|
+
}
|
|
106
|
+
export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id'> {
|
|
107
|
+
name: 'caption';
|
|
108
|
+
content: Array<Node>;
|
|
109
|
+
}
|
|
110
|
+
export interface RootBlock extends Omit<Block, 'location'> {
|
|
111
|
+
name: 'root';
|
|
112
|
+
content: AstTree;
|
|
113
|
+
}
|
|
114
|
+
export interface FormattingCodeB {
|
|
115
|
+
type: "fcode";
|
|
116
|
+
name: "B";
|
|
117
|
+
content?: Array<Node>;
|
|
118
|
+
}
|
|
119
|
+
export interface FormattingCodeC {
|
|
120
|
+
type: "fcode";
|
|
121
|
+
name: "C";
|
|
122
|
+
content?: Array<FormattingCodes | string>;
|
|
123
|
+
}
|
|
124
|
+
export interface FormattingCodeE {
|
|
125
|
+
type: "fcode";
|
|
126
|
+
name: "E";
|
|
127
|
+
content: Array<{
|
|
128
|
+
type: "number";
|
|
129
|
+
value: number;
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
export interface FormattingCodeN {
|
|
133
|
+
type: "fcode";
|
|
134
|
+
name: "N";
|
|
135
|
+
content?: Array<FormattingCodes | string>;
|
|
136
|
+
}
|
|
137
|
+
export interface FormattingCodeX {
|
|
138
|
+
type: "fcode";
|
|
139
|
+
name: "X";
|
|
140
|
+
entry: Array<string> | null;
|
|
141
|
+
content?: Array<FormattingCodes | string>;
|
|
142
|
+
}
|
|
143
|
+
export interface FormattingCodeZ {
|
|
144
|
+
type: "fcode";
|
|
145
|
+
name: "Z";
|
|
146
|
+
content?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface FormattingCodeV {
|
|
149
|
+
type: "fcode";
|
|
150
|
+
name: "V";
|
|
151
|
+
content?: string;
|
|
152
|
+
}
|
|
153
|
+
export interface FormattingCodeS {
|
|
154
|
+
type: "fcode";
|
|
155
|
+
name: "S";
|
|
156
|
+
content?: string | Text;
|
|
157
|
+
}
|
|
158
|
+
export interface FormattingCodeA {
|
|
159
|
+
type: "fcode";
|
|
160
|
+
name: "A";
|
|
161
|
+
content: string | Text;
|
|
162
|
+
}
|
|
163
|
+
export interface FormattingCodeD {
|
|
164
|
+
type: "fcode";
|
|
165
|
+
name: "D";
|
|
166
|
+
synonyms: Array<string>;
|
|
167
|
+
content: string;
|
|
168
|
+
}
|
|
169
|
+
export interface FormattingCodeL {
|
|
170
|
+
type: "fcode";
|
|
171
|
+
name: "L";
|
|
172
|
+
meta: string | null;
|
|
173
|
+
content: string | Text;
|
|
174
|
+
}
|
|
175
|
+
export interface FormattingCodeI {
|
|
176
|
+
type: "fcode";
|
|
177
|
+
name: "I";
|
|
178
|
+
meta: string;
|
|
179
|
+
content: string | Text;
|
|
180
|
+
}
|
|
181
|
+
export interface FormattingCodeAny {
|
|
182
|
+
type: "fcode";
|
|
183
|
+
name: string;
|
|
184
|
+
content?: Array<FormattingCodes | string>;
|
|
185
|
+
}
|
|
186
|
+
export interface Ambient {
|
|
187
|
+
type: "ambient";
|
|
188
|
+
text: string;
|
|
189
|
+
location: Location;
|
|
190
|
+
}
|
|
191
|
+
export interface Verbatim {
|
|
192
|
+
type: "verbatim";
|
|
193
|
+
value: string;
|
|
194
|
+
}
|
|
195
|
+
export interface Text {
|
|
196
|
+
type: "text";
|
|
197
|
+
value: string;
|
|
198
|
+
}
|
|
199
|
+
export interface Para {
|
|
200
|
+
type: "para";
|
|
201
|
+
text: string;
|
|
202
|
+
margin: string;
|
|
203
|
+
location: Location;
|
|
204
|
+
content: Array<Node | FormattingCodes>;
|
|
205
|
+
}
|
|
206
|
+
export interface Code {
|
|
207
|
+
type: "code";
|
|
208
|
+
text: string;
|
|
209
|
+
margin: string;
|
|
210
|
+
location: Location;
|
|
211
|
+
content: Array<Verbatim | string>;
|
|
212
|
+
}
|
|
213
|
+
export interface BlankLine {
|
|
214
|
+
type: "blankline";
|
|
215
|
+
}
|
|
216
|
+
export interface List {
|
|
217
|
+
type: "list";
|
|
218
|
+
level: string | number;
|
|
219
|
+
content: Array<BlockItem | BlankLine | List>;
|
|
220
|
+
list: "itemized";
|
|
221
|
+
}
|
|
222
|
+
export interface ConfigItemKV {
|
|
223
|
+
[key: string]: string | number | boolean;
|
|
224
|
+
}
|
|
225
|
+
export interface BrokenConfigItem extends Omit<ConfigItem, 'type'> {
|
|
226
|
+
}
|
|
227
|
+
export interface ConfigItem {
|
|
228
|
+
name: string;
|
|
229
|
+
value: boolean | string | number | Array<string | number | boolean> | ConfigItemKV;
|
|
230
|
+
type: string;
|
|
231
|
+
}
|
|
232
|
+
export interface BlockConfig {
|
|
233
|
+
name: string;
|
|
234
|
+
type: "config";
|
|
235
|
+
config: Array<ConfigItem>;
|
|
236
|
+
margin: string;
|
|
237
|
+
}
|
|
238
|
+
export interface Alias {
|
|
239
|
+
name: string;
|
|
240
|
+
type: "alias";
|
|
241
|
+
replacement: Array<string>;
|
|
242
|
+
margin: string;
|
|
243
|
+
}
|
|
244
|
+
export interface Separator {
|
|
245
|
+
type: 'separator';
|
|
246
|
+
text: string;
|
|
247
|
+
}
|
|
248
|
+
export interface Block {
|
|
249
|
+
type: "block";
|
|
250
|
+
location: Location;
|
|
251
|
+
content: Array<Node>;
|
|
252
|
+
margin: string;
|
|
253
|
+
config?: Array<ConfigItem | BrokenConfigItem>;
|
|
254
|
+
id?: string;
|
|
255
|
+
}
|
|
256
|
+
export interface BlockPod extends Block {
|
|
257
|
+
name: 'pod';
|
|
258
|
+
}
|
|
259
|
+
export interface BlockData extends Block {
|
|
260
|
+
name: 'data';
|
|
261
|
+
}
|
|
262
|
+
export interface BlockComment extends Block {
|
|
263
|
+
name: 'comment';
|
|
264
|
+
}
|
|
265
|
+
export interface BlockDefn extends Block {
|
|
266
|
+
name: 'defn';
|
|
267
|
+
}
|
|
268
|
+
export interface BlockItem extends Block {
|
|
269
|
+
name: "item";
|
|
270
|
+
content: Array<Node>;
|
|
271
|
+
level: string | number;
|
|
272
|
+
}
|
|
273
|
+
export interface BlockOutput extends Block {
|
|
274
|
+
name: "output";
|
|
275
|
+
}
|
|
276
|
+
export interface BlockInput extends Block {
|
|
277
|
+
name: "input";
|
|
278
|
+
}
|
|
279
|
+
export interface BlockPara extends Block {
|
|
280
|
+
name: "para";
|
|
281
|
+
}
|
|
282
|
+
export interface BlockCode extends Block {
|
|
283
|
+
name: 'code';
|
|
284
|
+
}
|
|
285
|
+
export interface BlockNested extends Block {
|
|
286
|
+
name: 'nested';
|
|
287
|
+
}
|
|
288
|
+
export interface BlockHead extends Block {
|
|
289
|
+
name: 'head';
|
|
290
|
+
level: number | string;
|
|
291
|
+
}
|
|
292
|
+
export interface BlockTable extends Omit<Block, 'content'> {
|
|
293
|
+
name: "table";
|
|
294
|
+
content: Array<TableHead | TableSeparator | TableRow | BlankLine>;
|
|
295
|
+
text?: string;
|
|
296
|
+
}
|
|
297
|
+
export interface TableCell {
|
|
298
|
+
name: "table_cell";
|
|
299
|
+
type: "block";
|
|
300
|
+
content: Array<string>;
|
|
301
|
+
}
|
|
302
|
+
export interface TableRow {
|
|
303
|
+
name: "table_row";
|
|
304
|
+
type: "block";
|
|
305
|
+
content: Array<TableCell>;
|
|
306
|
+
}
|
|
307
|
+
export interface TableHead {
|
|
308
|
+
name: "table_head";
|
|
309
|
+
type: "block";
|
|
310
|
+
content: Array<TableCell>;
|
|
311
|
+
}
|
|
312
|
+
export interface TableSeparator {
|
|
313
|
+
"type": "separator";
|
|
314
|
+
"text": string;
|
|
315
|
+
}
|
|
316
|
+
export declare type BlockAny = BlockNamed;
|
|
317
|
+
export interface BlockNamed extends Omit<Block, 'content'> {
|
|
318
|
+
name: Capitalize<string>;
|
|
319
|
+
content: [(Verbatim | Para | Code)?] | Array<Image | BlockCaption>;
|
|
320
|
+
}
|
|
321
|
+
export interface BlockDiagram extends Omit<BlockNamed, 'content'> {
|
|
322
|
+
name: 'Diagram';
|
|
323
|
+
content: [Verbatim];
|
|
324
|
+
custom?: {
|
|
325
|
+
location: Location;
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
export declare type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
|
|
329
|
+
export declare type PodNode = Ambient | BlockPod | BlockData | BlockCode | BlankLine | BlockNested | BlockOutput | BlockInput | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
|
|
330
|
+
export declare type Node = PodNode;
|
|
331
|
+
export declare type AstTree = Array<PodNode>;
|
|
332
|
+
export declare type PodliteDocument = RootBlock;
|
package/package.json
CHANGED
|
@@ -1,37 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podlite/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "podlite schema",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"files": [
|
|
9
9
|
"lib/**/*.js",
|
|
10
|
+
"lib/**/*.d.ts",
|
|
10
11
|
"schema/*",
|
|
11
12
|
"README.md",
|
|
12
13
|
"CHANGELOG.md"
|
|
13
14
|
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=14"
|
|
17
|
+
},
|
|
18
|
+
"engineStrict": true,
|
|
14
19
|
"publishConfig": {
|
|
15
|
-
"access": "public"
|
|
20
|
+
"access": "public",
|
|
21
|
+
"main": "index.js",
|
|
22
|
+
"module": "index.js",
|
|
23
|
+
"types": "./lib/index.d.ts"
|
|
16
24
|
},
|
|
17
25
|
"scripts": {
|
|
18
26
|
"clean": "rm -rf lib tsconfig.tsbuildinfo",
|
|
19
|
-
"build": "
|
|
27
|
+
"build": "run-s build:ts build:ast",
|
|
20
28
|
"build:ast": "ts-node scripts/make-ast-scheme.ts",
|
|
21
|
-
"build:ts": "tsc",
|
|
29
|
+
"build:ts": "yarn g:tsc --build $INIT_CWD",
|
|
22
30
|
"watch": "npx nodemon -e js,ts --exec 'yarn' build",
|
|
23
|
-
"test": "jest"
|
|
31
|
+
"test": "yarn g:jest --passWithNoTests"
|
|
24
32
|
},
|
|
25
33
|
"dependencies": {
|
|
26
34
|
"ajv": "^7.2.3",
|
|
27
35
|
"json-pointer": "^0.6.1",
|
|
28
|
-
"
|
|
36
|
+
"nanoid": "^3.1.30",
|
|
37
|
+
"pod6": "0.0.43"
|
|
29
38
|
},
|
|
30
39
|
"devDependencies": {
|
|
31
|
-
"
|
|
40
|
+
"@types/node": "^17.0.7",
|
|
41
|
+
"glob": "^7.2.0",
|
|
32
42
|
"ts-node": "^9.1.1",
|
|
33
|
-
"typescript": "4.
|
|
34
|
-
"typescript-json-schema": "
|
|
43
|
+
"typescript": "4.5.4",
|
|
44
|
+
"typescript-json-schema": "0.53.0"
|
|
35
45
|
},
|
|
36
|
-
"
|
|
37
|
-
}
|
|
46
|
+
"module": "index.js"
|
|
47
|
+
}
|