@iyio/protogen 0.0.1
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/README.md +18 -0
- package/esm/package.json +3 -0
- package/esm/src/index.d.ts +11 -0
- package/esm/src/index.js +12 -0
- package/esm/src/index.js.map +1 -0
- package/esm/src/lib/executeProtoPipelineAsync.d.ts +2 -0
- package/esm/src/lib/executeProtoPipelineAsync.js +57 -0
- package/esm/src/lib/executeProtoPipelineAsync.js.map +1 -0
- package/esm/src/lib/markdown.d.ts +5 -0
- package/esm/src/lib/markdown.js +244 -0
- package/esm/src/lib/markdown.js.map +1 -0
- package/esm/src/lib/output-utils.d.ts +25 -0
- package/esm/src/lib/output-utils.js +163 -0
- package/esm/src/lib/output-utils.js.map +1 -0
- package/esm/src/lib/protogen-cli.d.ts +17 -0
- package/esm/src/lib/protogen-cli.js +25 -0
- package/esm/src/lib/protogen-cli.js.map +1 -0
- package/esm/src/lib/protogen-lib.d.ts +5 -0
- package/esm/src/lib/protogen-lib.js +19 -0
- package/esm/src/lib/protogen-lib.js.map +1 -0
- package/esm/src/lib/protogen-node.d.ts +61 -0
- package/esm/src/lib/protogen-node.js +532 -0
- package/esm/src/lib/protogen-node.js.map +1 -0
- package/esm/src/lib/protogen-pipeline-types.d.ts +91 -0
- package/esm/src/lib/protogen-pipeline-types.js +21 -0
- package/esm/src/lib/protogen-pipeline-types.js.map +1 -0
- package/esm/src/lib/protogen-pipeline.d.ts +5 -0
- package/esm/src/lib/protogen-pipeline.js +90 -0
- package/esm/src/lib/protogen-pipeline.js.map +1 -0
- package/esm/src/lib/protogen-plugin-util.d.ts +10 -0
- package/esm/src/lib/protogen-plugin-util.js +16 -0
- package/esm/src/lib/protogen-plugin-util.js.map +1 -0
- package/esm/src/lib/protogen-types.d.ts +117 -0
- package/esm/src/lib/protogen-types.js +2 -0
- package/esm/src/lib/protogen-types.js.map +1 -0
- package/esm/src/lib/test-plugin.d.ts +1 -0
- package/esm/src/lib/test-plugin.js +19 -0
- package/esm/src/lib/test-plugin.js.map +1 -0
- package/esm/src/lib/typescript-utils.d.ts +12 -0
- package/esm/src/lib/typescript-utils.js +92 -0
- package/esm/src/lib/typescript-utils.js.map +1 -0
- package/package.json +17 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +15 -0
- package/src/index.js.map +1 -0
- package/src/lib/executeProtoPipelineAsync.d.ts +2 -0
- package/src/lib/executeProtoPipelineAsync.js +61 -0
- package/src/lib/executeProtoPipelineAsync.js.map +1 -0
- package/src/lib/markdown.d.ts +5 -0
- package/src/lib/markdown.js +250 -0
- package/src/lib/markdown.js.map +1 -0
- package/src/lib/output-utils.d.ts +25 -0
- package/src/lib/output-utils.js +170 -0
- package/src/lib/output-utils.js.map +1 -0
- package/src/lib/protogen-cli.d.ts +17 -0
- package/src/lib/protogen-cli.js +29 -0
- package/src/lib/protogen-cli.js.map +1 -0
- package/src/lib/protogen-lib.d.ts +5 -0
- package/src/lib/protogen-lib.js +26 -0
- package/src/lib/protogen-lib.js.map +1 -0
- package/src/lib/protogen-node.d.ts +61 -0
- package/src/lib/protogen-node.js +563 -0
- package/src/lib/protogen-node.js.map +1 -0
- package/src/lib/protogen-pipeline-types.d.ts +91 -0
- package/src/lib/protogen-pipeline-types.js +24 -0
- package/src/lib/protogen-pipeline-types.js.map +1 -0
- package/src/lib/protogen-pipeline.d.ts +5 -0
- package/src/lib/protogen-pipeline.js +95 -0
- package/src/lib/protogen-pipeline.js.map +1 -0
- package/src/lib/protogen-plugin-util.d.ts +10 -0
- package/src/lib/protogen-plugin-util.js +20 -0
- package/src/lib/protogen-plugin-util.js.map +1 -0
- package/src/lib/protogen-types.d.ts +117 -0
- package/src/lib/protogen-types.js +3 -0
- package/src/lib/protogen-types.js.map +1 -0
- package/src/lib/test-plugin.d.ts +1 -0
- package/src/lib/test-plugin.js +21 -0
- package/src/lib/test-plugin.js.map +1 -0
- package/src/lib/typescript-utils.d.ts +12 -0
- package/src/lib/typescript-utils.js +102 -0
- package/src/lib/typescript-utils.js.map +1 -0
- package/src/package.json +4 -0
- package/test.md +440 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# protogen
|
|
2
|
+
A type generator that works with Zod
|
|
3
|
+
|
|
4
|
+
## CLI
|
|
5
|
+
|
|
6
|
+
Arguments:
|
|
7
|
+
- -i --input - input file
|
|
8
|
+
- -l --load-plugin - load plugin module - The exported members can be used as readers, parsers, generators or writers.
|
|
9
|
+
- -o --output - output destination. Can be a filename or directory. If a directory a default filename will be generated
|
|
10
|
+
- -r --reader - reader name - default - "fileReader"
|
|
11
|
+
- -p --parser - parser name - default - "lucidCsvParser"
|
|
12
|
+
- -g --generator - generator name - default - "zodGenerator"
|
|
13
|
+
- -w --writer - writer name - default = "fileWriter"
|
|
14
|
+
- --no-default-plugins - If set the default plugins will not be used
|
|
15
|
+
|
|
16
|
+
All other flags can be used by plugins.
|
|
17
|
+
|
|
18
|
+
Values to not preceded with a flag are used as inputs.
|
package/esm/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './lib/executeProtoPipelineAsync';
|
|
2
|
+
export * from './lib/markdown';
|
|
3
|
+
export * from './lib/output-utils';
|
|
4
|
+
export * from './lib/protogen-cli';
|
|
5
|
+
export * from './lib/protogen-lib';
|
|
6
|
+
export * from './lib/protogen-node';
|
|
7
|
+
export * from './lib/protogen-pipeline';
|
|
8
|
+
export * from './lib/protogen-pipeline-types';
|
|
9
|
+
export * from './lib/protogen-plugin-util';
|
|
10
|
+
export * from './lib/protogen-types';
|
|
11
|
+
export * from './lib/typescript-utils';
|
package/esm/src/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './lib/executeProtoPipelineAsync';
|
|
2
|
+
export * from './lib/markdown';
|
|
3
|
+
export * from './lib/output-utils';
|
|
4
|
+
export * from './lib/protogen-cli';
|
|
5
|
+
export * from './lib/protogen-lib';
|
|
6
|
+
export * from './lib/protogen-node';
|
|
7
|
+
export * from './lib/protogen-pipeline';
|
|
8
|
+
export * from './lib/protogen-pipeline-types';
|
|
9
|
+
export * from './lib/protogen-plugin-util';
|
|
10
|
+
export * from './lib/protogen-types';
|
|
11
|
+
export * from './lib/typescript-utils';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { protoParseConfig } from "./protogen-pipeline";
|
|
3
|
+
const getConfig = (ctx, plugin) => {
|
|
4
|
+
const configScheme = plugin.configScheme;
|
|
5
|
+
return configScheme ? protoParseConfig(configScheme, ctx.args) : null;
|
|
6
|
+
};
|
|
7
|
+
export const executeTGenPipelineAsync = ({ context, plugins, config }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
const log = context.log;
|
|
9
|
+
log(`\n--------------------------\nStart pipeline${config.dryRun ? ' ( DRY RUN )' : ''} - ${context.executionId}}`);
|
|
10
|
+
const runPluginsAsync = (stage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
var _a;
|
|
12
|
+
context.stage = stage;
|
|
13
|
+
log(`\n## Stage ${stage}`);
|
|
14
|
+
for (const info of plugins) {
|
|
15
|
+
const plugin = info.plugin;
|
|
16
|
+
if (plugin.beforeEach) {
|
|
17
|
+
log(`beforeEach ${info.source}:${info.name}`);
|
|
18
|
+
yield plugin.beforeEach(context, getConfig(context, plugin), info);
|
|
19
|
+
}
|
|
20
|
+
if (plugin[stage]) {
|
|
21
|
+
log(`${stage} ${info.source}:${info.name}`);
|
|
22
|
+
yield ((_a = plugin[stage]) === null || _a === void 0 ? void 0 : _a.call(plugin, context, getConfig(context, plugin), info));
|
|
23
|
+
}
|
|
24
|
+
if (plugin.afterEach) {
|
|
25
|
+
log(`afterEach ${info.source}:${info.name}`);
|
|
26
|
+
yield plugin.afterEach(context, getConfig(context, plugin), info);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
log("\n## Plugins");
|
|
31
|
+
for (const info of plugins) {
|
|
32
|
+
log(`plugin ${info.source}:${info.name}`);
|
|
33
|
+
}
|
|
34
|
+
for (const info of plugins) {
|
|
35
|
+
if (info.plugin.beforeAll) {
|
|
36
|
+
log(`beforeAll ${info.source}:${info.name}`);
|
|
37
|
+
yield info.plugin.beforeAll(context, getConfig(context, info.plugin), info);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
yield runPluginsAsync('init');
|
|
41
|
+
yield runPluginsAsync('input');
|
|
42
|
+
yield runPluginsAsync('preprocess');
|
|
43
|
+
yield runPluginsAsync('parse');
|
|
44
|
+
yield runPluginsAsync('generate');
|
|
45
|
+
yield runPluginsAsync('output');
|
|
46
|
+
for (const info of plugins) {
|
|
47
|
+
if (info.plugin.afterAll) {
|
|
48
|
+
log(`afterAll ${info.source}:${info.name}`);
|
|
49
|
+
yield info.plugin.afterAll(context, getConfig(context, info.plugin), info);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (config.logImportMap) {
|
|
53
|
+
log(`\nimportMap:${JSON.stringify(context.importMap, null, 4)}`);
|
|
54
|
+
}
|
|
55
|
+
log(`\nEnd pipeline${config.dryRun ? ' ( DRY RUN )' : ''} - ${context.executionId}\n--------------------------\n`);
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=executeProtoPipelineAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeProtoPipelineAsync.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/executeProtoPipelineAsync.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,SAAS,GAAC,CAAC,GAAgB,EAAC,MAA0B,EAAK,EAAE;IAC/D,MAAM,YAAY,GAAE,MAAmD,CAAC,YAAY,CAAC;IACrF,OAAO,YAAY,CAAA,CAAC,CAAA,gBAAgB,CAAC,YAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAA,CAAC,CAAA,IAAI,CAAA;AACpE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAC,CAAO,EACzC,OAAO,EACP,OAAO,EACP,MAAM,EACK,EAAe,EAAE;IAE5B,MAAM,GAAG,GAAC,OAAO,CAAC,GAAG,CAAC;IAEtB,GAAG,CAAC,+CAA+C,MAAM,CAAC,MAAM,CAAA,CAAC,CAAA,cAAc,CAAA,CAAC,CAAA,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;IAEhH,MAAM,eAAe,GAAC,CAAO,KAAgB,EAAC,EAAE;;QAC5C,OAAO,CAAC,KAAK,GAAC,KAAK,CAAC;QACpB,GAAG,CAAC,cAAc,KAAK,EAAE,CAAC,CAAC;QAE3B,KAAI,MAAM,IAAI,IAAI,OAAO,EAAC;YACtB,MAAM,MAAM,GAAC,IAAI,CAAC,MAAM,CAAC;YACzB,IAAG,MAAM,CAAC,UAAU,EAAC;gBACjB,GAAG,CAAC,cAAc,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC9C,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,EAAC,SAAS,CAAC,OAAO,EAAC,MAAM,CAAC,EAAC,IAAI,CAAC,CAAC;aACnE;YACD,IAAG,MAAM,CAA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MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;IAGhC,KAAI,MAAM,IAAI,IAAI,OAAO,EAAC;QACtB,IAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAC;YACpB,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;YAC3C,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAC,SAAS,CAAC,OAAO,EAAC,IAAI,CAAC,MAAM,CAAC,EAAC,IAAI,CAAC,CAAC;SAC3E;KACJ;IAED,IAAG,MAAM,CAAC,YAAY,EAAC;QACnB,GAAG,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAC,IAAI,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAClE;IAED,GAAG,CAAC,iBAAiB,MAAM,CAAC,MAAM,CAAA,CAAC,CAAA,cAAc,CAAA,CAAC,CAAA,EAAE,MAAM,OAAO,CAAC,WAAW,gCAAgC,CAAC,CAAA;AAElH,CAAC,CAAA,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ProtoNormalizeNodesOptions } from "./protogen-node";
|
|
2
|
+
import { ProtoNode, ProtoNodeRenderData, ProtoParsingResult } from "./protogen-types";
|
|
3
|
+
export declare const protoMarkdownGetIndent: (value: string) => string;
|
|
4
|
+
export declare const protoMarkdownParseNodes: (code: string, options?: ProtoNormalizeNodesOptions) => ProtoParsingResult;
|
|
5
|
+
export declare const protoMarkdownRenderer: (node: ProtoNode, renderData: ProtoNodeRenderData) => ProtoNodeRenderData;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { protoAddChild, protoCreateEmptyNode, protoCreateNodeAddressMap, protoEnsureUniqueAddress, protoNormalizeNodes } from "./protogen-node";
|
|
2
|
+
const lineReg = /^([ \t]*)(#+|-)[ \t]+(\$?\w[\w-]*)(\??)(:)?[ \t]*(.*)(?=\n|$)/;
|
|
3
|
+
const lineRegSpace = 1;
|
|
4
|
+
const lineRegMarkdownType = 2;
|
|
5
|
+
const lineRegName = 3;
|
|
6
|
+
const lineRegOptional = 4;
|
|
7
|
+
const lineCol = 5;
|
|
8
|
+
const lineRegRest = 6;
|
|
9
|
+
const codeReg = /[ \t]*```/;
|
|
10
|
+
const hrReg = /(^|\n)-{2,}[ \t]*/;
|
|
11
|
+
const spaceStartReg = /^([ \t]+)/;
|
|
12
|
+
const spaceStartRegIndex = 1;
|
|
13
|
+
export const protoMarkdownGetIndent = (value) => { var _a, _b; return (_b = (_a = spaceStartReg.exec(value)) === null || _a === void 0 ? void 0 : _a[spaceStartRegIndex]) !== null && _b !== void 0 ? _b : ''; };
|
|
14
|
+
export const protoMarkdownParseNodes = (code, options) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const rootNodes = [];
|
|
17
|
+
const allNodes = [];
|
|
18
|
+
let nodeStack = {};
|
|
19
|
+
let currentNode = null;
|
|
20
|
+
let lastNode = null;
|
|
21
|
+
let inCode = false;
|
|
22
|
+
const reset = () => {
|
|
23
|
+
currentNode = null;
|
|
24
|
+
lastNode = null;
|
|
25
|
+
nodeStack = {};
|
|
26
|
+
};
|
|
27
|
+
const lines = code.split('\n');
|
|
28
|
+
const pushRootNode = (node) => {
|
|
29
|
+
protoEnsureUniqueAddress(node, rootNodes);
|
|
30
|
+
rootNodes.push(node);
|
|
31
|
+
};
|
|
32
|
+
const addContent = (line) => {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const depth = getDepth(protoMarkdownGetIndent(line), '');
|
|
35
|
+
const value = line.replace(/[ \t]*(#+|-)?[ \t]*/, '').trim();
|
|
36
|
+
if (lastNode &&
|
|
37
|
+
lastNode.isContent &&
|
|
38
|
+
lastNode.renderData) {
|
|
39
|
+
const indent = (_a = lastNode.renderData.indent) !== null && _a !== void 0 ? _a : '';
|
|
40
|
+
if (indent && line.startsWith(indent)) {
|
|
41
|
+
line = line.substring(indent.length);
|
|
42
|
+
}
|
|
43
|
+
lastNode.renderData.input += '\n' + (line ? lastNode.renderData.indent : '') + line;
|
|
44
|
+
lastNode.value += '\n' + (protoMarkdownGetIndent(line)) + value;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const content = protoCreateEmptyNode('#', '', value);
|
|
48
|
+
allNodes.push(content);
|
|
49
|
+
content.renderData = {
|
|
50
|
+
indent: (_c = (_b = /^([ \t]+)/.exec(line)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : '',
|
|
51
|
+
input: line,
|
|
52
|
+
depth,
|
|
53
|
+
};
|
|
54
|
+
content.isContent = true;
|
|
55
|
+
if (currentNode === null || currentNode === void 0 ? void 0 : currentNode.contentFocused) {
|
|
56
|
+
content.importantContent = true;
|
|
57
|
+
}
|
|
58
|
+
if (currentNode) {
|
|
59
|
+
protoAddChild(currentNode, content);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
pushRootNode(content);
|
|
63
|
+
}
|
|
64
|
+
lastNode = content;
|
|
65
|
+
};
|
|
66
|
+
for (const _line of lines) {
|
|
67
|
+
const line = _line.trimEnd();
|
|
68
|
+
if (inCode) {
|
|
69
|
+
addContent(line);
|
|
70
|
+
if (codeReg.test(line)) {
|
|
71
|
+
inCode = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const match = lineReg.exec(line);
|
|
76
|
+
if (match && (match[lineCol] || match[lineRegMarkdownType].startsWith('#'))) {
|
|
77
|
+
const mdType = match[lineRegMarkdownType];
|
|
78
|
+
const depth = getDepth(match[lineRegSpace], mdType);
|
|
79
|
+
const parent = nodeStack[depth - 1];
|
|
80
|
+
const name = match[lineRegName];
|
|
81
|
+
const value = match[lineRegRest];
|
|
82
|
+
const { types, tags } = parseTypesAndFlags((_a = rootNodes[rootNodes.length - 1]) !== null && _a !== void 0 ? _a : null, value);
|
|
83
|
+
const node = {
|
|
84
|
+
name,
|
|
85
|
+
address: name,
|
|
86
|
+
type: types[0].type,
|
|
87
|
+
types,
|
|
88
|
+
value,
|
|
89
|
+
renderData: {
|
|
90
|
+
input: line,
|
|
91
|
+
depth,
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
allNodes.push(node);
|
|
95
|
+
if (parent === null || parent === void 0 ? void 0 : parent.contentFocused) {
|
|
96
|
+
node.importantContent = true;
|
|
97
|
+
}
|
|
98
|
+
if (match[lineRegOptional]) {
|
|
99
|
+
node.optional = true;
|
|
100
|
+
}
|
|
101
|
+
if (types[1]) {
|
|
102
|
+
node.refType = types[1];
|
|
103
|
+
}
|
|
104
|
+
if (tags) {
|
|
105
|
+
node.tags = tags;
|
|
106
|
+
}
|
|
107
|
+
if (mdType === '######' && node.name.startsWith('$')) {
|
|
108
|
+
node.contentFocused = true;
|
|
109
|
+
}
|
|
110
|
+
if (name.startsWith('$')) {
|
|
111
|
+
node.special = true;
|
|
112
|
+
}
|
|
113
|
+
if (parent) {
|
|
114
|
+
protoAddChild(parent, node);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
pushRootNode(node);
|
|
118
|
+
}
|
|
119
|
+
nodeStack[depth] = node;
|
|
120
|
+
currentNode = node;
|
|
121
|
+
lastNode = node;
|
|
122
|
+
}
|
|
123
|
+
else { // add content
|
|
124
|
+
if (hrReg.test(line)) {
|
|
125
|
+
reset();
|
|
126
|
+
}
|
|
127
|
+
addContent(line);
|
|
128
|
+
if (codeReg.test(line)) {
|
|
129
|
+
inCode = true;
|
|
130
|
+
}
|
|
131
|
+
else if (currentNode) {
|
|
132
|
+
let subMatch;
|
|
133
|
+
// check for tags
|
|
134
|
+
if (/^[ \t]*-[ \t]+\([ \t]*(\w+)[ \t]*\)/.test(line)) {
|
|
135
|
+
const { tags } = parseTypesAndFlags((_b = rootNodes[rootNodes.length - 1]) !== null && _b !== void 0 ? _b : null, line);
|
|
136
|
+
if (tags) {
|
|
137
|
+
for (const t of tags) {
|
|
138
|
+
if (!currentNode.tags) {
|
|
139
|
+
currentNode.tags = [];
|
|
140
|
+
}
|
|
141
|
+
if (!currentNode.tags.includes(t)) {
|
|
142
|
+
currentNode.tags.push(t);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// check of links
|
|
147
|
+
}
|
|
148
|
+
else if (subMatch = /^([ \t]*|[ \t]*-[ \t]+)\[([^[]+)\]\(([^)]+)\)/.exec(line)) {
|
|
149
|
+
if (!currentNode.links) {
|
|
150
|
+
currentNode.links = [];
|
|
151
|
+
}
|
|
152
|
+
currentNode.links.push({
|
|
153
|
+
name: subMatch[2].trim(),
|
|
154
|
+
address: subMatch[3].trim()
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const addressMap = protoCreateNodeAddressMap(allNodes);
|
|
162
|
+
protoNormalizeNodes(allNodes, Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { addressMap }));
|
|
163
|
+
return { rootNodes, allNodes, addressMap };
|
|
164
|
+
};
|
|
165
|
+
const parseTypesAndFlags = (rootNode, value) => {
|
|
166
|
+
const matches = value.matchAll(/([@>#~*?! \t]+)?(\(?)[ \t]*([\w.\-[\]]+)(\)?)/g);
|
|
167
|
+
const flagsI = 1;
|
|
168
|
+
const tagOpenI = 2;
|
|
169
|
+
const nameI = 3;
|
|
170
|
+
const tagCloseI = 4;
|
|
171
|
+
const types = [];
|
|
172
|
+
let tags;
|
|
173
|
+
for (const match of matches) {
|
|
174
|
+
const nameMatch = match[nameI];
|
|
175
|
+
if (match[tagOpenI]) {
|
|
176
|
+
if (!match[tagCloseI]) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (!tags) {
|
|
180
|
+
tags = [];
|
|
181
|
+
}
|
|
182
|
+
if (!tags.includes(nameMatch)) {
|
|
183
|
+
tags.push(nameMatch);
|
|
184
|
+
}
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const path = nameMatch.split('.');
|
|
188
|
+
const isArray = path[0].includes('[]');
|
|
189
|
+
for (let i = 0; i < path.length; i++) {
|
|
190
|
+
if (path[i].includes('[]')) {
|
|
191
|
+
path[i] = path[i].replace(/\[\]/g, '');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!path[0] && rootNode) {
|
|
195
|
+
path[0] = rootNode.name;
|
|
196
|
+
}
|
|
197
|
+
const name = path[0];
|
|
198
|
+
const type = {
|
|
199
|
+
type: name,
|
|
200
|
+
isRefType: /[A-Z]/.test(name.charAt(0)),
|
|
201
|
+
path,
|
|
202
|
+
};
|
|
203
|
+
types.push(type);
|
|
204
|
+
if (isArray) {
|
|
205
|
+
type.isArray = true;
|
|
206
|
+
}
|
|
207
|
+
const flags = match[flagsI];
|
|
208
|
+
if (flags) {
|
|
209
|
+
if (flags.includes('*')) {
|
|
210
|
+
type.important = true;
|
|
211
|
+
}
|
|
212
|
+
if (flags.includes('>')) {
|
|
213
|
+
type.source = true;
|
|
214
|
+
}
|
|
215
|
+
if (flags.includes('@')) {
|
|
216
|
+
type.copySource = true;
|
|
217
|
+
}
|
|
218
|
+
if (flags.includes('!')) {
|
|
219
|
+
type.ex = true;
|
|
220
|
+
}
|
|
221
|
+
if (flags.includes('?')) {
|
|
222
|
+
type.question = true;
|
|
223
|
+
}
|
|
224
|
+
if (flags.includes('#')) {
|
|
225
|
+
type.hash = true;
|
|
226
|
+
}
|
|
227
|
+
if (flags.includes('~')) {
|
|
228
|
+
type.less = true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (!types.length) {
|
|
233
|
+
types.push({ type: '', path: [] });
|
|
234
|
+
}
|
|
235
|
+
return { types, tags };
|
|
236
|
+
};
|
|
237
|
+
const getDepth = (space, markdownType) => {
|
|
238
|
+
return (Math.floor(space.length / 2)) + (markdownType.startsWith('#') ? 0 : 1);
|
|
239
|
+
};
|
|
240
|
+
export const protoMarkdownRenderer = (node, renderData) => {
|
|
241
|
+
const input = `- ${node.name}${node.value ? ': ' + node.value : ''}`;
|
|
242
|
+
return Object.assign(Object.assign({}, renderData), { input });
|
|
243
|
+
};
|
|
244
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,mBAAmB,EAA8B,MAAM,iBAAiB,CAAC;AAG5K,MAAM,OAAO,GAAC,+DAA+D,CAAC;AAC9E,MAAM,YAAY,GAAC,CAAC,CAAC;AACrB,MAAM,mBAAmB,GAAC,CAAC,CAAC;AAC5B,MAAM,WAAW,GAAC,CAAC,CAAC;AACpB,MAAM,eAAe,GAAC,CAAC,CAAC;AACxB,MAAM,OAAO,GAAC,CAAC,CAAC;AAChB,MAAM,WAAW,GAAC,CAAC,CAAC;AAEpB,MAAM,OAAO,GAAC,WAAW,CAAC;AAE1B,MAAM,KAAK,GAAC,mBAAmB,CAAC;AAEhC,MAAM,aAAa,GAAC,WAAW,CAAC;AAChC,MAAM,kBAAkB,GAAC,CAAC,CAAC;AAE3B,MAAM,CAAC,MAAM,sBAAsB,GAAC,CAAC,KAAY,EAAC,EAAE,eAAA,OAAA,MAAA,MAAA,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,0CAAG,kBAAkB,CAAC,mCAAE,EAAE,CAAA,EAAA,CAAA;AAGvG,MAAM,CAAC,MAAM,uBAAuB,GAAC,CAAC,IAAW,EAAC,OAAmC,EAAoB,EAAE;;IAEvG,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,SAAS,GAA4B,EAAE,CAAA;IAC3C,IAAI,WAAW,GAAgB,IAAI,CAAC;IACpC,IAAI,QAAQ,GAAgB,IAA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AC;IAE7D,uCACO,UAAU,KACb,KAAK,IACR;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const protoLabelOutputLines: (lines: string[], label: string, startIndex?: number, end?: number) => void;
|
|
2
|
+
export type ProtoSourceCodeMerger = (options: ProtoMergeSourceCodeOptions) => string[];
|
|
3
|
+
export interface ProtoMergeSourceCodeOptions {
|
|
4
|
+
overwriting: string | string[];
|
|
5
|
+
existing: string | string[];
|
|
6
|
+
mergeSections?: (existing: ProtoCodeSection, overwriting: ProtoCodeSection) => ProtoCodeSection;
|
|
7
|
+
createSectionsConfig?: ProtoCreateCodeSectionsOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare const protoMergeSourceCode: ({ overwriting, existing, mergeSections, createSectionsConfig }: ProtoMergeSourceCodeOptions) => string[];
|
|
10
|
+
export interface ProtoCreateCodeSectionsOptions {
|
|
11
|
+
sectionRegex: RegExp;
|
|
12
|
+
sectionContentIndex?: number;
|
|
13
|
+
nameReg?: RegExp;
|
|
14
|
+
nameIndex?: number;
|
|
15
|
+
getName?: (sectionContent: string) => string;
|
|
16
|
+
defaultName?: string;
|
|
17
|
+
takeCommentPrefix?: boolean;
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const protoCreateCodeSections: (code: string[], { sectionRegex, sectionContentIndex, nameReg, nameIndex, getName, defaultName, takeCommentPrefix, debug }?: ProtoCreateCodeSectionsOptions) => ProtoCodeSection[];
|
|
21
|
+
export interface ProtoCodeSection {
|
|
22
|
+
name: string;
|
|
23
|
+
lines: string[];
|
|
24
|
+
}
|
|
25
|
+
export declare const protoMergeTsImports: ({ createSectionsConfig, mergeSections, ...props }: ProtoMergeSourceCodeOptions) => string[];
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
export const protoLabelOutputLines = (lines, label, startIndex = 0, end = lines.length) => {
|
|
3
|
+
let maxLength = 0;
|
|
4
|
+
for (let i = startIndex; i < end; i++) {
|
|
5
|
+
if (lines[i].length > maxLength) {
|
|
6
|
+
maxLength = lines[i].length;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
maxLength += 4;
|
|
10
|
+
for (let i = startIndex; i < end; i++) {
|
|
11
|
+
lines[i] += ' '.repeat(maxLength - lines[i].length) + '// <<';
|
|
12
|
+
if (i === startIndex) {
|
|
13
|
+
lines[i] += ' proto ' + label;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const protoMergeSourceCode = ({ overwriting, existing, mergeSections, createSectionsConfig }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
if (typeof overwriting === 'string') {
|
|
20
|
+
overwriting = overwriting.split('\n');
|
|
21
|
+
}
|
|
22
|
+
if (typeof existing === 'string') {
|
|
23
|
+
existing = existing.split('\n');
|
|
24
|
+
}
|
|
25
|
+
if (existing.length <= 1 && !((_a = existing[0]) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
26
|
+
return overwriting;
|
|
27
|
+
}
|
|
28
|
+
const oSections = protoCreateCodeSections(overwriting, createSectionsConfig);
|
|
29
|
+
const existingSections = protoCreateCodeSections(existing, createSectionsConfig);
|
|
30
|
+
for (let i = 0; i < existingSections.length; i++) {
|
|
31
|
+
const section = existingSections[i];
|
|
32
|
+
if (!section.name) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const match = oSections.find(s => s.name === section.name);
|
|
36
|
+
if (match) {
|
|
37
|
+
existingSections[i] = mergeSections ? mergeSections(match, section) : match;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const output = [];
|
|
41
|
+
for (const section of existingSections) {
|
|
42
|
+
for (const line of section.lines) {
|
|
43
|
+
output.push(line);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return output;
|
|
47
|
+
};
|
|
48
|
+
export const protoCreateCodeSections = (code, { sectionRegex, sectionContentIndex = 0, nameReg, nameIndex = 0, getName, defaultName, takeCommentPrefix, debug } = {
|
|
49
|
+
sectionRegex: /\/\/\s*<<(.*)$/,
|
|
50
|
+
sectionContentIndex: 1,
|
|
51
|
+
nameReg: /proto\s+(.*)/,
|
|
52
|
+
nameIndex: 1,
|
|
53
|
+
takeCommentPrefix: true,
|
|
54
|
+
}) => {
|
|
55
|
+
var _a, _b, _c, _d, _e;
|
|
56
|
+
const sections = [];
|
|
57
|
+
let section = {
|
|
58
|
+
name: '',
|
|
59
|
+
lines: []
|
|
60
|
+
};
|
|
61
|
+
const pushSection = () => {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!section.lines.length) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const lastSection = sections[sections.length - 1];
|
|
67
|
+
if (takeCommentPrefix && lastSection && section.name && !lastSection.name) {
|
|
68
|
+
let startCommentIndex = null;
|
|
69
|
+
for (let i = lastSection.lines.length - 1; i >= 0; i--) {
|
|
70
|
+
const line = lastSection.lines[i];
|
|
71
|
+
if (!line.trim() || /^\s*\*/.test(line)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (/^\s*\/\*\*/.test(line)) {
|
|
75
|
+
startCommentIndex = i;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (startCommentIndex !== null) {
|
|
80
|
+
for (let i = lastSection.lines.length - 1; i >= startCommentIndex; i--) {
|
|
81
|
+
section.lines.unshift((_a = lastSection.lines.pop()) !== null && _a !== void 0 ? _a : '');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!lastSection.lines.length) {
|
|
85
|
+
sections.pop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
sections.push(section);
|
|
89
|
+
};
|
|
90
|
+
for (const line of code) {
|
|
91
|
+
const match = sectionRegex.exec(line);
|
|
92
|
+
if (match) {
|
|
93
|
+
let name = ((_e = (_a = getName === null || getName === void 0 ? void 0 : getName(match[sectionContentIndex])) !== null && _a !== void 0 ? _a : (_d = nameReg === null || nameReg === void 0 ? void 0 : nameReg.exec((_c = (_b = match[sectionContentIndex]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '')) === null || _d === void 0 ? void 0 : _d[nameIndex]) !== null && _e !== void 0 ? _e : defaultName);
|
|
94
|
+
if (name && name !== section.name) {
|
|
95
|
+
pushSection();
|
|
96
|
+
if (sections.some(s => s.name === name)) {
|
|
97
|
+
let i = 2;
|
|
98
|
+
while (sections.some(s => s.name === (name !== null && name !== void 0 ? name : '') + i)) {
|
|
99
|
+
i++;
|
|
100
|
+
}
|
|
101
|
+
name += i;
|
|
102
|
+
}
|
|
103
|
+
section = {
|
|
104
|
+
name,
|
|
105
|
+
lines: []
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (section.name) {
|
|
110
|
+
pushSection();
|
|
111
|
+
section = {
|
|
112
|
+
name: '',
|
|
113
|
+
lines: []
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
section.lines.push(line);
|
|
117
|
+
}
|
|
118
|
+
pushSection();
|
|
119
|
+
if (debug && sections.some(s => s.name)) {
|
|
120
|
+
console.debug('code sections', sections);
|
|
121
|
+
}
|
|
122
|
+
return sections;
|
|
123
|
+
};
|
|
124
|
+
export const protoMergeTsImports = (_a) => {
|
|
125
|
+
var { createSectionsConfig = defaultMergeTsImportsSectionConfig, mergeSections = defaultMergeTsImportsMerger } = _a, props = __rest(_a, ["createSectionsConfig", "mergeSections"]);
|
|
126
|
+
return protoMergeSourceCode(Object.assign({ createSectionsConfig,
|
|
127
|
+
mergeSections }, props));
|
|
128
|
+
};
|
|
129
|
+
const importReg = /^import\s+\{(.*?)\}\s+from\s+['"](.*?)['"]/;
|
|
130
|
+
const defaultMergeTsImportsSectionConfig = {
|
|
131
|
+
sectionRegex: importReg,
|
|
132
|
+
defaultName: 'import',
|
|
133
|
+
};
|
|
134
|
+
const defaultMergeTsImportsMerger = (existing, overwriting) => {
|
|
135
|
+
const map = {};
|
|
136
|
+
addImportsToMap(existing.lines, map);
|
|
137
|
+
addImportsToMap(overwriting.lines, map);
|
|
138
|
+
return {
|
|
139
|
+
name: existing.name,
|
|
140
|
+
lines: Object.keys(map).map(k => `import { ${map[k].join(', ')} } from '${k}';`),
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const addImportsToMap = (code, map) => {
|
|
144
|
+
for (const line of code) {
|
|
145
|
+
const match = importReg.exec(line);
|
|
146
|
+
if (!match) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const packageName = match[2].trim();
|
|
150
|
+
let pkg = map[packageName];
|
|
151
|
+
if (!pkg) {
|
|
152
|
+
map[packageName] = pkg = [];
|
|
153
|
+
}
|
|
154
|
+
const names = match[1].split(',');
|
|
155
|
+
for (const n of names) {
|
|
156
|
+
const name = n.trim();
|
|
157
|
+
if (name && !pkg.includes(name)) {
|
|
158
|
+
pkg.push(name);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=output-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-utils.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/output-utils.ts"],"names":[],"mappings":";AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAC,CAC/B,KAAc,EACd,KAAY,EACZ,aAAkB,CAAC,EACnB,MAAW,KAAK,CAAC,MAAM,EAAC,EAAE;IAE1B,IAAI,SAAS,GAAC,CAAC,CAAC;IAChB,KAAI,IAAI,CAAC,GAAC,UAAU,EAAC,CAAC,GAAC,GAAG,EAAC,CAAC,EAAE,EAAC;QAC3B,IAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAC,SAAS,EAAC;YACzB,SAAS,GAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;SAC7B;KACJ;IAED,SAAS,IAAE,CAAC,CAAC;IACb,KAAI,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KAAI,MAAM,CAAC,IAAI,KAAK,EAAC;YACjB,MAAM,IAAI,GAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACpB,IAAG,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAC;gBAC3B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAClB;SACJ;KACJ;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const protoCliFlags: {
|
|
2
|
+
readonly input: "-i";
|
|
3
|
+
readonly loadPlugin: "-l";
|
|
4
|
+
readonly loadPluginPath: "-lp";
|
|
5
|
+
readonly output: "-o";
|
|
6
|
+
readonly reader: "-r";
|
|
7
|
+
readonly parser: "-p";
|
|
8
|
+
readonly generator: "-g";
|
|
9
|
+
readonly writer: "-w";
|
|
10
|
+
readonly workingDirectory: "-d";
|
|
11
|
+
readonly verbose: "-v";
|
|
12
|
+
readonly noDefaultPlugins: "--no-default-plugins";
|
|
13
|
+
};
|
|
14
|
+
export declare const protoParseCliArgs: (argList: string[], argStart: number) => {
|
|
15
|
+
args: import("@iyio/common").HashMap<string[]>;
|
|
16
|
+
config: Partial<import("./protogen-pipeline-types").ProtoPipelineConfig>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseCliArgsT } from "@iyio/common";
|
|
2
|
+
import { ProtoCliAliases, ProtoPipelineConfigCliConverter } from "./protogen-pipeline-types";
|
|
3
|
+
export const protoCliFlags = {
|
|
4
|
+
input: '-i',
|
|
5
|
+
loadPlugin: '-l',
|
|
6
|
+
loadPluginPath: '-lp',
|
|
7
|
+
output: '-o',
|
|
8
|
+
reader: '-r',
|
|
9
|
+
parser: '-p',
|
|
10
|
+
generator: '-g',
|
|
11
|
+
writer: '-w',
|
|
12
|
+
workingDirectory: '-d',
|
|
13
|
+
verbose: '-v',
|
|
14
|
+
noDefaultPlugins: '--no-default-plugins',
|
|
15
|
+
};
|
|
16
|
+
export const protoParseCliArgs = (argList, argStart) => {
|
|
17
|
+
const { argMap: args, parsed: config } = parseCliArgsT({
|
|
18
|
+
args: argList,
|
|
19
|
+
startIndex: argStart,
|
|
20
|
+
aliasMap: ProtoCliAliases,
|
|
21
|
+
converter: ProtoPipelineConfigCliConverter
|
|
22
|
+
});
|
|
23
|
+
return { args, config };
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=protogen-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protogen-cli.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/protogen-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE7F,MAAM,CAAC,MAAM,aAAa,GAAC;IACvB,KAAK,EAAC,IAAI;IACV,UAAU,EAAC,IAAI;IACf,cAAc,EAAC,KAAK;IACpB,MAAM,EAAC,IAAI;IACX,MAAM,EAAC,IAAI;IACX,MAAM,EAAC,IAAI;IACX,SAAS,EAAC,IAAI;IACd,MAAM,EAAC,IAAI;IACX,gBAAgB,EAAC,IAAI;IACrB,OAAO,EAAC,IAAI;IACZ,gBAAgB,EAAC,sBAAsB;CACjC,CAAC;AAGX,MAAM,CAAC,MAAM,iBAAiB,GAAC,CAAC,OAAgB,EAAC,QAAe,EAAC,EAAE;IAC/D,MAAM,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,GAAC,aAAa,CAAC;QAC5C,IAAI,EAAC,OAAO;QACZ,UAAU,EAAC,QAAQ;QACnB,QAAQ,EAAC,eAAe;QACxB,SAAS,EAAC,+BAA+B;KAC5C,CAAC,CAAC;IAEH,OAAO,EAAC,IAAI,EAAC,MAAM,EAAC,CAAA;AACxB,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ProtoLayout, ProtoNode } from "./protogen-types";
|
|
2
|
+
export declare const protoGetLayout: (node: ProtoNode) => ProtoLayout | null;
|
|
3
|
+
export declare const protoGetLayoutOrDefault: (node: ProtoNode) => ProtoLayout;
|
|
4
|
+
export declare const protoSetLayout: (node: ProtoNode, layout: ProtoLayout | null) => void;
|
|
5
|
+
export declare const protoGetEmptyLayout: () => ProtoLayout;
|