toolcraft 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 +91 -0
- package/dist/cli.compile-check.d.ts +1 -0
- package/dist/cli.compile-check.js +26 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.js +1312 -0
- package/dist/index.compile-check.d.ts +1 -0
- package/dist/index.compile-check.js +50 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +366 -0
- package/dist/mcp.compile-check.d.ts +1 -0
- package/dist/mcp.compile-check.js +26 -0
- package/dist/mcp.d.ts +31 -0
- package/dist/mcp.js +354 -0
- package/dist/number-schema.d.ts +3 -0
- package/dist/number-schema.js +8 -0
- package/dist/renderer.d.ts +5 -0
- package/dist/renderer.js +148 -0
- package/dist/schema-scope.d.ts +4 -0
- package/dist/schema-scope.js +34 -0
- package/dist/sdk.compile-check.d.ts +1 -0
- package/dist/sdk.compile-check.js +79 -0
- package/dist/sdk.d.ts +63 -0
- package/dist/sdk.js +218 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.js +121 -0
- package/node_modules/@poe-code/design-system/dist/acp/index.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/acp/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/acp/writer.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/acp/writer.js +21 -0
- package/node_modules/@poe-code/design-system/dist/components/command-errors.d.ts +16 -0
- package/node_modules/@poe-code/design-system/dist/components/command-errors.js +22 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.js +27 -0
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/components/index.js +7 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.js +60 -0
- package/node_modules/@poe-code/design-system/dist/components/symbols.d.ts +12 -0
- package/node_modules/@poe-code/design-system/dist/components/symbols.js +71 -0
- package/node_modules/@poe-code/design-system/dist/components/table.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/components/table.js +74 -0
- package/node_modules/@poe-code/design-system/dist/components/text.d.ts +14 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +104 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.js +298 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.js +189 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/border.js +123 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/footer.js +57 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.js +254 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/stats-pane.js +121 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/dashboard.js +167 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/demo.js +145 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/index.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/index.js +4 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.js +99 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/layout.js +79 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/snapshot.js +68 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/store.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/store.js +51 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.js +233 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.d.ts +36 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.js +1 -0
- package/node_modules/@poe-code/design-system/dist/index.d.ts +33 -0
- package/node_modules/@poe-code/design-system/dist/index.js +31 -0
- package/node_modules/@poe-code/design-system/dist/internal/output-format.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/internal/output-format.js +22 -0
- package/node_modules/@poe-code/design-system/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/internal/strip-ansi.js +3 -0
- package/node_modules/@poe-code/design-system/dist/internal/theme-detect.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/internal/theme-detect.js +49 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.d.ts +66 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.js +132 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.js +15 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.js +101 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.js +39 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/@poe-code/design-system/dist/prompts/theme.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/prompts/theme.js +12 -0
- package/node_modules/@poe-code/design-system/dist/static/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/static/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/static/menu.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/static/menu.js +36 -0
- package/node_modules/@poe-code/design-system/dist/static/spinner.d.ts +14 -0
- package/node_modules/@poe-code/design-system/dist/static/spinner.js +46 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/index.js +8 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.js +412 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/inline.js +1166 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.js +572 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/@poe-code/design-system/dist/tokens/colors.d.ts +35 -0
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +34 -0
- package/node_modules/@poe-code/design-system/dist/tokens/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/tokens/index.js +4 -0
- package/node_modules/@poe-code/design-system/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/tokens/spacing.js +6 -0
- package/node_modules/@poe-code/design-system/dist/tokens/typography.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/tokens/typography.js +8 -0
- package/node_modules/@poe-code/design-system/dist/tokens/widths.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/tokens/widths.js +5 -0
- package/node_modules/@poe-code/design-system/package.json +25 -0
- package/package.json +57 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
class FrontmatterParseError extends Error {
|
|
2
|
+
}
|
|
3
|
+
class YamlSubsetParser {
|
|
4
|
+
lines;
|
|
5
|
+
position = 0;
|
|
6
|
+
constructor(yamlBlock) {
|
|
7
|
+
this.lines = tokenizeYamlBlock(yamlBlock);
|
|
8
|
+
}
|
|
9
|
+
parse() {
|
|
10
|
+
this.skipBlankLines();
|
|
11
|
+
if (this.position >= this.lines.length) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
return this.parseObject(0);
|
|
15
|
+
}
|
|
16
|
+
parseObject(expectedIndent) {
|
|
17
|
+
const result = {};
|
|
18
|
+
while (true) {
|
|
19
|
+
this.skipBlankLines();
|
|
20
|
+
const line = this.lines[this.position];
|
|
21
|
+
if (line === undefined) {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
if (line.indent < expectedIndent) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
if (line.indent !== expectedIndent || isArrayItem(line.content)) {
|
|
28
|
+
throw new FrontmatterParseError("Invalid object indentation.");
|
|
29
|
+
}
|
|
30
|
+
const entry = parseKeyValue(line.content);
|
|
31
|
+
if (entry === null || hasOwn(result, entry.key)) {
|
|
32
|
+
throw new FrontmatterParseError("Invalid mapping entry.");
|
|
33
|
+
}
|
|
34
|
+
this.position += 1;
|
|
35
|
+
result[entry.key] = this.readEntryValue(entry, expectedIndent);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
parseArray(expectedIndent) {
|
|
40
|
+
const result = [];
|
|
41
|
+
while (true) {
|
|
42
|
+
this.skipBlankLines();
|
|
43
|
+
const line = this.lines[this.position];
|
|
44
|
+
if (line === undefined) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
if (line.indent < expectedIndent) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (line.indent !== expectedIndent) {
|
|
51
|
+
throw new FrontmatterParseError("Invalid array indentation.");
|
|
52
|
+
}
|
|
53
|
+
const item = parseArrayItem(line.content);
|
|
54
|
+
if (item === null) {
|
|
55
|
+
throw new FrontmatterParseError("Invalid array item.");
|
|
56
|
+
}
|
|
57
|
+
this.position += 1;
|
|
58
|
+
if (item.length > 0) {
|
|
59
|
+
result.push(parseScalar(item));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const nestedLine = this.peekMeaningfulLine();
|
|
63
|
+
if (nestedLine === undefined || nestedLine.indent <= expectedIndent) {
|
|
64
|
+
result.push(null);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
result.push(isArrayItem(nestedLine.content)
|
|
68
|
+
? this.parseArray(nestedLine.indent)
|
|
69
|
+
: this.parseObject(nestedLine.indent));
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
readEntryValue(entry, currentIndent) {
|
|
74
|
+
if (entry.value !== undefined) {
|
|
75
|
+
return parseScalar(entry.value);
|
|
76
|
+
}
|
|
77
|
+
const nestedLine = this.peekMeaningfulLine();
|
|
78
|
+
if (nestedLine === undefined || nestedLine.indent <= currentIndent) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return isArrayItem(nestedLine.content)
|
|
82
|
+
? this.parseArray(nestedLine.indent)
|
|
83
|
+
: this.parseObject(nestedLine.indent);
|
|
84
|
+
}
|
|
85
|
+
peekMeaningfulLine() {
|
|
86
|
+
let index = this.position;
|
|
87
|
+
while (index < this.lines.length) {
|
|
88
|
+
const line = this.lines[index];
|
|
89
|
+
if (line.content.length > 0) {
|
|
90
|
+
return line;
|
|
91
|
+
}
|
|
92
|
+
index += 1;
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
skipBlankLines() {
|
|
97
|
+
while (this.position < this.lines.length && this.lines[this.position].content.length === 0) {
|
|
98
|
+
this.position += 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function extractFrontmatter(markdown) {
|
|
103
|
+
if (!startsWithFrontmatterFence(markdown)) {
|
|
104
|
+
return { body: markdown };
|
|
105
|
+
}
|
|
106
|
+
const openingLine = readLine(markdown, 0);
|
|
107
|
+
if (stripBom(openingLine.text) !== "---") {
|
|
108
|
+
return { body: markdown };
|
|
109
|
+
}
|
|
110
|
+
let position = openingLine.nextPosition;
|
|
111
|
+
let closingFenceStart;
|
|
112
|
+
let closingFenceNextPosition;
|
|
113
|
+
while (position <= markdown.length) {
|
|
114
|
+
const line = readLine(markdown, position);
|
|
115
|
+
if (line.text === "---") {
|
|
116
|
+
closingFenceStart = line.start;
|
|
117
|
+
closingFenceNextPosition = line.nextPosition;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
if (line.nextPosition >= markdown.length) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
position = line.nextPosition;
|
|
124
|
+
}
|
|
125
|
+
if (closingFenceStart === undefined || closingFenceNextPosition === undefined) {
|
|
126
|
+
return { body: markdown };
|
|
127
|
+
}
|
|
128
|
+
const rawFrontmatter = sliceFrontmatterBlock(markdown, openingLine.nextPosition, closingFenceStart);
|
|
129
|
+
const frontmatter = parseFrontmatterBlock(rawFrontmatter);
|
|
130
|
+
return withRange({
|
|
131
|
+
frontmatter,
|
|
132
|
+
body: markdown.slice(closingFenceNextPosition)
|
|
133
|
+
}, {
|
|
134
|
+
start: 0,
|
|
135
|
+
end: Buffer.byteLength(markdown.slice(0, closingFenceNextPosition), "utf8")
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function parseFrontmatterBlock(yamlBlock) {
|
|
139
|
+
if (yamlBlock.length === 0) {
|
|
140
|
+
return {};
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
return new YamlSubsetParser(yamlBlock).parse();
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (error instanceof FrontmatterParseError) {
|
|
147
|
+
return { raw: yamlBlock };
|
|
148
|
+
}
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function tokenizeYamlBlock(yamlBlock) {
|
|
153
|
+
const lines = yamlBlock.replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
154
|
+
return lines.map((line) => {
|
|
155
|
+
let indent = 0;
|
|
156
|
+
while (indent < line.length && line[indent] === " ") {
|
|
157
|
+
indent += 1;
|
|
158
|
+
}
|
|
159
|
+
for (let index = 0; index < indent; index += 1) {
|
|
160
|
+
if (line[index] === "\t") {
|
|
161
|
+
throw new FrontmatterParseError("Tabs are not supported in frontmatter indentation.");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (indent < line.length && line[indent] === "\t") {
|
|
165
|
+
throw new FrontmatterParseError("Tabs are not supported in frontmatter indentation.");
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
indent,
|
|
169
|
+
content: line.slice(indent)
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function parseKeyValue(content) {
|
|
174
|
+
const separator = findUnquotedMappingSeparator(content);
|
|
175
|
+
if (separator === -1) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const key = trimAsciiWhitespace(content.slice(0, separator));
|
|
179
|
+
if (key.length === 0) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
const rawValue = trimAsciiWhitespaceStart(content.slice(separator + 1));
|
|
183
|
+
return rawValue.length === 0 ? { key } : { key, value: rawValue };
|
|
184
|
+
}
|
|
185
|
+
function parseArrayItem(content) {
|
|
186
|
+
if (!isArrayItem(content)) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
return trimAsciiWhitespaceStart(content.slice(1));
|
|
190
|
+
}
|
|
191
|
+
function isArrayItem(content) {
|
|
192
|
+
if (!content.startsWith("-")) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
if (content.length === 1) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
const nextCharacter = content[1];
|
|
199
|
+
return nextCharacter === " " || nextCharacter === "\t";
|
|
200
|
+
}
|
|
201
|
+
function parseScalar(value) {
|
|
202
|
+
if (value.length === 0) {
|
|
203
|
+
return "";
|
|
204
|
+
}
|
|
205
|
+
if (isQuoted(value, "'")) {
|
|
206
|
+
return value.slice(1, -1).replaceAll("''", "'");
|
|
207
|
+
}
|
|
208
|
+
if (isQuoted(value, '"')) {
|
|
209
|
+
return parseDoubleQuotedString(value.slice(1, -1));
|
|
210
|
+
}
|
|
211
|
+
if (value === "true") {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
if (value === "false") {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
if (value === "null") {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
if (isNumberLiteral(value)) {
|
|
221
|
+
return Number(value);
|
|
222
|
+
}
|
|
223
|
+
if (hasUnquotedMappingSeparator(value)) {
|
|
224
|
+
throw new FrontmatterParseError("Unquoted mapping separators are not supported in scalar values.");
|
|
225
|
+
}
|
|
226
|
+
return value;
|
|
227
|
+
}
|
|
228
|
+
function parseDoubleQuotedString(value) {
|
|
229
|
+
let result = "";
|
|
230
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
231
|
+
const character = value[index];
|
|
232
|
+
if (character !== "\\") {
|
|
233
|
+
result += character;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
index += 1;
|
|
237
|
+
if (index >= value.length) {
|
|
238
|
+
result += "\\";
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
const escaped = value[index];
|
|
242
|
+
if (escaped === "n") {
|
|
243
|
+
result += "\n";
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (escaped === "r") {
|
|
247
|
+
result += "\r";
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (escaped === "t") {
|
|
251
|
+
result += "\t";
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (escaped === "b") {
|
|
255
|
+
result += "\b";
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (escaped === "f") {
|
|
259
|
+
result += "\f";
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (escaped === '"' || escaped === "\\" || escaped === "/") {
|
|
263
|
+
result += escaped;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (escaped === "u") {
|
|
267
|
+
const codePoint = value.slice(index + 1, index + 5);
|
|
268
|
+
if (codePoint.length === 4 && isHexadecimal(codePoint)) {
|
|
269
|
+
result += String.fromCodePoint(Number.parseInt(codePoint, 16));
|
|
270
|
+
index += 4;
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
result += `\\${escaped}`;
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
function isQuoted(value, quote) {
|
|
279
|
+
return value.length >= 2 && value[0] === quote && value[value.length - 1] === quote;
|
|
280
|
+
}
|
|
281
|
+
function isNumberLiteral(value) {
|
|
282
|
+
let index = 0;
|
|
283
|
+
let hasDigits = false;
|
|
284
|
+
let hasDecimal = false;
|
|
285
|
+
if (value[index] === "-" || value[index] === "+") {
|
|
286
|
+
index += 1;
|
|
287
|
+
}
|
|
288
|
+
while (index < value.length) {
|
|
289
|
+
const character = value[index];
|
|
290
|
+
if (character >= "0" && character <= "9") {
|
|
291
|
+
hasDigits = true;
|
|
292
|
+
index += 1;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (character === "." && !hasDecimal) {
|
|
296
|
+
hasDecimal = true;
|
|
297
|
+
index += 1;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
return hasDigits;
|
|
303
|
+
}
|
|
304
|
+
function hasUnquotedMappingSeparator(value) {
|
|
305
|
+
return findUnquotedMappingSeparator(value) !== -1;
|
|
306
|
+
}
|
|
307
|
+
function findUnquotedMappingSeparator(value) {
|
|
308
|
+
let quote = null;
|
|
309
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
310
|
+
const character = value[index];
|
|
311
|
+
if (quote !== null) {
|
|
312
|
+
if (character === "\\" && quote === '"') {
|
|
313
|
+
index += 1;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (character === quote) {
|
|
317
|
+
quote = null;
|
|
318
|
+
}
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (character === "'" || character === '"') {
|
|
322
|
+
quote = character;
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (character !== ":") {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const nextCharacter = value[index + 1];
|
|
329
|
+
if (nextCharacter === undefined || nextCharacter === " " || nextCharacter === "\t") {
|
|
330
|
+
return index;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return -1;
|
|
334
|
+
}
|
|
335
|
+
function sliceFrontmatterBlock(content, start, end) {
|
|
336
|
+
let sliceEnd = end;
|
|
337
|
+
if (sliceEnd > start && content[sliceEnd - 1] === "\n") {
|
|
338
|
+
sliceEnd -= 1;
|
|
339
|
+
if (sliceEnd > start && content[sliceEnd - 1] === "\r") {
|
|
340
|
+
sliceEnd -= 1;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return content.slice(start, sliceEnd);
|
|
344
|
+
}
|
|
345
|
+
function startsWithFrontmatterFence(value) {
|
|
346
|
+
return (value.startsWith("---\n") ||
|
|
347
|
+
value.startsWith("---\r\n") ||
|
|
348
|
+
value.startsWith("\uFEFF---\n") ||
|
|
349
|
+
value.startsWith("\uFEFF---\r\n"));
|
|
350
|
+
}
|
|
351
|
+
function stripBom(value) {
|
|
352
|
+
return value.startsWith("\uFEFF") ? value.slice(1) : value;
|
|
353
|
+
}
|
|
354
|
+
function withRange(value, range) {
|
|
355
|
+
Object.defineProperty(value, "range", {
|
|
356
|
+
value: range,
|
|
357
|
+
enumerable: false,
|
|
358
|
+
configurable: true,
|
|
359
|
+
writable: true
|
|
360
|
+
});
|
|
361
|
+
return value;
|
|
362
|
+
}
|
|
363
|
+
function readLine(input, position) {
|
|
364
|
+
let end = position;
|
|
365
|
+
while (end < input.length && input[end] !== "\n" && input[end] !== "\r") {
|
|
366
|
+
end += 1;
|
|
367
|
+
}
|
|
368
|
+
let nextPosition = end;
|
|
369
|
+
if (input[nextPosition] === "\r" && input[nextPosition + 1] === "\n") {
|
|
370
|
+
nextPosition += 2;
|
|
371
|
+
}
|
|
372
|
+
else if (input[nextPosition] === "\n" || input[nextPosition] === "\r") {
|
|
373
|
+
nextPosition += 1;
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
text: input.slice(position, end),
|
|
377
|
+
start: position,
|
|
378
|
+
nextPosition
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function trimAsciiWhitespace(value) {
|
|
382
|
+
return trimAsciiWhitespaceEnd(trimAsciiWhitespaceStart(value));
|
|
383
|
+
}
|
|
384
|
+
function trimAsciiWhitespaceStart(value) {
|
|
385
|
+
let start = 0;
|
|
386
|
+
while (start < value.length && (value[start] === " " || value[start] === "\t")) {
|
|
387
|
+
start += 1;
|
|
388
|
+
}
|
|
389
|
+
return value.slice(start);
|
|
390
|
+
}
|
|
391
|
+
function trimAsciiWhitespaceEnd(value) {
|
|
392
|
+
let end = value.length;
|
|
393
|
+
while (end > 0 && (value[end - 1] === " " || value[end - 1] === "\t")) {
|
|
394
|
+
end -= 1;
|
|
395
|
+
}
|
|
396
|
+
return value.slice(0, end);
|
|
397
|
+
}
|
|
398
|
+
function hasOwn(record, key) {
|
|
399
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
400
|
+
}
|
|
401
|
+
function isHexadecimal(value) {
|
|
402
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
403
|
+
const character = value[index];
|
|
404
|
+
if ((character >= "0" && character <= "9") ||
|
|
405
|
+
(character >= "a" && character <= "f") ||
|
|
406
|
+
(character >= "A" && character <= "F")) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MdNode } from "../ast.js";
|
|
2
|
+
type OffsetMap = readonly number[];
|
|
3
|
+
export type ParseInlineOptions = {
|
|
4
|
+
footnoteLabels?: ReadonlySet<string>;
|
|
5
|
+
allowLiteralAutolinks?: boolean;
|
|
6
|
+
offset?: number;
|
|
7
|
+
offsets?: OffsetMap;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseInline(raw: string, options?: ParseInlineOptions): MdNode[];
|
|
10
|
+
export {};
|