@the_dissidents/libemmm 0.0.7 → 0.0.9
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 +204 -62
- package/dist/chunk-Bp6m_JJh.js +13 -0
- package/dist/index.cjs +3311 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +727 -0
- package/dist/index.d.ts +611 -493
- package/dist/index.js +3085 -3114
- package/dist/index.js.map +1 -1
- package/package.json +27 -16
- package/dist/index.d.mts +0 -608
- package/dist/index.mjs +0 -3228
- package/dist/index.mjs.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
import * as minimal_jsx_runtime_jsx_runtime0 from "minimal-jsx-runtime/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/debug.d.ts
|
|
6
|
+
declare enum DebugLevel {
|
|
7
|
+
Trace = 0,
|
|
8
|
+
Info = 1,
|
|
9
|
+
Warning = 2,
|
|
10
|
+
Error = 3,
|
|
11
|
+
None = 4,
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/source.d.ts
|
|
15
|
+
type SourceDescriptor = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
};
|
|
18
|
+
interface Source extends SourceDescriptor {
|
|
19
|
+
readonly nLines: number;
|
|
20
|
+
/**
|
|
21
|
+
* Return the row- and column-index corresponding to a given location. The indices are zero-based.
|
|
22
|
+
*/
|
|
23
|
+
getRowCol(loc: number): [row: number, col: number];
|
|
24
|
+
/**
|
|
25
|
+
* Returns the position of the start of row `n` (zero-based). If `n` is zero, returns zero. If the source contains less than `n` rows, returns `Infinity`.
|
|
26
|
+
*/
|
|
27
|
+
getRowStart(n: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the content of the row `n` (zero-based). If the source contains less than `n` rows, returns `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
getRow(n: number): string | undefined;
|
|
32
|
+
}
|
|
33
|
+
declare class StringSource implements Source {
|
|
34
|
+
private readonly src;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly nLines: number;
|
|
37
|
+
private readonly lineMap;
|
|
38
|
+
constructor(d: SourceDescriptor, src: string);
|
|
39
|
+
getRowCol(pos: number): [row: number, col: number];
|
|
40
|
+
getRowStart(n: number): number;
|
|
41
|
+
getRow(n: number): string | undefined;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/module.d.ts
|
|
45
|
+
type ModuleDefinition = {
|
|
46
|
+
usedModules: Set<string>;
|
|
47
|
+
blocks: Set<BlockModifierDefinition<unknown>>;
|
|
48
|
+
inlines: Set<InlineModifierDefinition<unknown>>;
|
|
49
|
+
inlineShorthands: Set<InlineShorthand<unknown>>;
|
|
50
|
+
blockShorthands: Set<BlockShorthand<unknown>>;
|
|
51
|
+
};
|
|
52
|
+
declare namespace ModuleDefinition {
|
|
53
|
+
function from(cxt: ParseContext): ModuleDefinition;
|
|
54
|
+
function apply(defs: ModuleDefinition, cxt: ParseContext): void;
|
|
55
|
+
function diff(cnew: ModuleDefinition, cold: ModuleDefinition): ModuleDefinition;
|
|
56
|
+
function combine(cnew: ModuleDefinition, cold: ModuleDefinition): [ModuleDefinition, string];
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/scanner.d.ts
|
|
60
|
+
type Inspector = {
|
|
61
|
+
position: number;
|
|
62
|
+
callback: (cxt: ParseContext, pos: number) => void;
|
|
63
|
+
};
|
|
64
|
+
declare class SimpleScanner implements Scanner {
|
|
65
|
+
#private;
|
|
66
|
+
private src;
|
|
67
|
+
readonly source: Source;
|
|
68
|
+
constructor(src: string, sourceDesc?: SourceDescriptor, inspectors?: Inspector[]);
|
|
69
|
+
position(): number;
|
|
70
|
+
isEOF(): boolean;
|
|
71
|
+
inspectors(): Inspector[];
|
|
72
|
+
peek(str: string): boolean;
|
|
73
|
+
acceptChar(): string;
|
|
74
|
+
accept(str: string): boolean;
|
|
75
|
+
acceptWhitespaceChar(): string | null;
|
|
76
|
+
}
|
|
77
|
+
interface Scanner {
|
|
78
|
+
readonly source: Source;
|
|
79
|
+
position(): number;
|
|
80
|
+
isEOF(): boolean;
|
|
81
|
+
/** Sources can have inspectors in them, which are positions that trigger a callback when encounterede. This function returns the inspectors that lie between the current position and where this function was previously called (or the beginning for the first call). */
|
|
82
|
+
inspectors(): Inspector[];
|
|
83
|
+
/** return true if sees str immediately */
|
|
84
|
+
peek(str: string): boolean;
|
|
85
|
+
/** if sees str immediately, consumes it and returns true */
|
|
86
|
+
accept(str: string): boolean;
|
|
87
|
+
/** consumes a character and returns it; throws at EOF */
|
|
88
|
+
acceptChar(): string;
|
|
89
|
+
/** newlines are NOT whitespaces */
|
|
90
|
+
acceptWhitespaceChar(): string | null;
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/util.d.ts
|
|
94
|
+
declare class NameManager<T$1 extends {
|
|
95
|
+
name: string;
|
|
96
|
+
}> {
|
|
97
|
+
private array;
|
|
98
|
+
private data;
|
|
99
|
+
constructor(from?: ReadonlyNameManager<T$1> | readonly T$1[] | ReadonlySet<T$1>);
|
|
100
|
+
toArray(): T$1[];
|
|
101
|
+
toSet(): Set<T$1>;
|
|
102
|
+
get(name: string): T$1 | undefined;
|
|
103
|
+
has(name: string): boolean;
|
|
104
|
+
remove(name: string): void;
|
|
105
|
+
add(...elems: T$1[]): void;
|
|
106
|
+
find(predicate: (x: T$1) => boolean): T$1 | undefined;
|
|
107
|
+
}
|
|
108
|
+
type ReadonlyNameManager<T$1 extends {
|
|
109
|
+
name: string;
|
|
110
|
+
}> = Omit<NameManager<T$1>, 'add' | 'remove'>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/parser-config.d.ts
|
|
113
|
+
interface ParseContextStoreDefinitions {}
|
|
114
|
+
type ParseContextStoreKey = keyof ParseContextStoreDefinitions;
|
|
115
|
+
type ParseContextStoreEntry<S extends ParseContextStoreKey> = ParseContextStoreDefinitions[S];
|
|
116
|
+
declare class ParseContext {
|
|
117
|
+
readonly config: Configuration;
|
|
118
|
+
variables: Map<string, string>;
|
|
119
|
+
private data;
|
|
120
|
+
usedModules: Set<string>;
|
|
121
|
+
constructor(config: Configuration, variables?: Map<string, string>);
|
|
122
|
+
init<S extends ParseContextStoreKey>(key: S, obj: ParseContextStoreEntry<S>): void;
|
|
123
|
+
set<S extends ParseContextStoreKey>(key: S, obj: ParseContextStoreEntry<S>): void;
|
|
124
|
+
get<S extends ParseContextStoreKey>(key: S): ParseContextStoreEntry<S>;
|
|
125
|
+
parse(scanner: Scanner): Document$1;
|
|
126
|
+
}
|
|
127
|
+
declare class Document$1 {
|
|
128
|
+
readonly root: RootNode;
|
|
129
|
+
readonly context: ParseContext;
|
|
130
|
+
readonly messages: readonly Message[];
|
|
131
|
+
constructor(root: RootNode, context: ParseContext, messages: readonly Message[]);
|
|
132
|
+
toStripped(): Document$1;
|
|
133
|
+
/**
|
|
134
|
+
* Performs a depth-first walk of the node tree.
|
|
135
|
+
*/
|
|
136
|
+
walk(callback: (node: BlockEntity | InlineEntity | ArgumentEntity) => 'skip' | 'break' | 'continue'): void;
|
|
137
|
+
/**
|
|
138
|
+
* Gets all nodes that covers the given position, from outermost to innermost (essentially a path).
|
|
139
|
+
*/
|
|
140
|
+
resolvePosition(pos: number): (BlockEntity | InlineEntity | ArgumentEntity)[];
|
|
141
|
+
}
|
|
142
|
+
type Shorthand<TMod> = {
|
|
143
|
+
name: string;
|
|
144
|
+
parts: readonly string[];
|
|
145
|
+
postfix: string | undefined;
|
|
146
|
+
mod: TMod;
|
|
147
|
+
};
|
|
148
|
+
type BlockShorthand<TState> = Shorthand<BlockModifierDefinition<TState>>;
|
|
149
|
+
type InlineShorthand<TState> = Shorthand<InlineModifierDefinition<TState>>;
|
|
150
|
+
type KernelConfiguration = {
|
|
151
|
+
collapseWhitespaces: boolean;
|
|
152
|
+
reparseDepthLimit: number;
|
|
153
|
+
};
|
|
154
|
+
interface ReadonlyConfiguration {
|
|
155
|
+
readonly initializers: readonly ((cxt: ParseContext) => void)[];
|
|
156
|
+
readonly blockModifiers: ReadonlyNameManager<BlockModifierDefinition<any>>;
|
|
157
|
+
readonly inlineModifiers: ReadonlyNameManager<InlineModifierDefinition<any>>;
|
|
158
|
+
readonly systemModifiers: ReadonlyNameManager<SystemModifierDefinition<any>>;
|
|
159
|
+
readonly argumentInterpolators: ReadonlyNameManager<ArgumentInterpolatorDefinition>;
|
|
160
|
+
readonly blockShorthands: ReadonlyNameManager<BlockShorthand<any>>;
|
|
161
|
+
readonly inlineShorthands: ReadonlyNameManager<InlineShorthand<any>>;
|
|
162
|
+
readonly kernel: KernelConfiguration;
|
|
163
|
+
}
|
|
164
|
+
declare class Configuration implements ReadonlyConfiguration {
|
|
165
|
+
initializers: ((cxt: ParseContext) => void)[];
|
|
166
|
+
modules: Map<string, ModuleDefinition>;
|
|
167
|
+
blockModifiers: NameManager<BlockModifierDefinition<any>>;
|
|
168
|
+
inlineModifiers: NameManager<InlineModifierDefinition<any>>;
|
|
169
|
+
systemModifiers: NameManager<SystemModifierDefinition<any>>;
|
|
170
|
+
argumentInterpolators: NameManager<ArgumentInterpolatorDefinition>;
|
|
171
|
+
blockShorthands: NameManager<BlockShorthand<any>>;
|
|
172
|
+
inlineShorthands: NameManager<InlineShorthand<any>>;
|
|
173
|
+
kernel: KernelConfiguration;
|
|
174
|
+
static from(from: ReadonlyConfiguration): Configuration;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/modifier.d.ts
|
|
178
|
+
declare enum ModifierSlotType {
|
|
179
|
+
Normal = 0,
|
|
180
|
+
/** Content is preformatted: no escaping, no inner tags */
|
|
181
|
+
Preformatted = 1,
|
|
182
|
+
/** No content slot */
|
|
183
|
+
None = 2,
|
|
184
|
+
}
|
|
185
|
+
type ModifierMetadata = {};
|
|
186
|
+
declare class ModifierBase<TNode, TEntity> {
|
|
187
|
+
readonly name: string;
|
|
188
|
+
readonly slotType: ModifierSlotType;
|
|
189
|
+
constructor(name: string, slotType?: ModifierSlotType, args?: Partial<ModifierBase<TNode, TEntity>>);
|
|
190
|
+
metadata: ModifierMetadata;
|
|
191
|
+
/**
|
|
192
|
+
* Common values: heading, emphasis, keyword, highlight, commentary, comment, link, quote, pre
|
|
193
|
+
*/
|
|
194
|
+
roleHint?: string;
|
|
195
|
+
/**
|
|
196
|
+
* If true, any modifier encountered inside it will *not* be expanded *during parse-content*,
|
|
197
|
+
* *unless* that modifier is `alwaysTryExpand`. In the vast majority of cases, you shouldn't
|
|
198
|
+
* be using this.
|
|
199
|
+
*/
|
|
200
|
+
delayContentExpansion: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* If true, such a modifier will always be expanded whenever it is encountered, *even if*
|
|
203
|
+
* it is contained in a modifier with `delayContentExpansion`. In the vast majority of cases,
|
|
204
|
+
* you shouldn't be using this.
|
|
205
|
+
*/
|
|
206
|
+
alwaysTryExpand: boolean;
|
|
207
|
+
/** Called before the modifier's content is parsed.
|
|
208
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
209
|
+
*/
|
|
210
|
+
beforeParseContent?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
211
|
+
/** Called after the modifier's content is parsed.
|
|
212
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
213
|
+
*/
|
|
214
|
+
afterParseContent?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
215
|
+
/** Called before reparsing of the expansion.
|
|
216
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.*/
|
|
217
|
+
beforeProcessExpansion?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
218
|
+
/** Called before reparsing of the expansion.
|
|
219
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.*/
|
|
220
|
+
afterProcessExpansion?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
221
|
+
/**
|
|
222
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
223
|
+
*/
|
|
224
|
+
prepareExpand?: (node: TNode, cxt: ParseContext, immediate: boolean) => Message[];
|
|
225
|
+
/**
|
|
226
|
+
* @param immediate False when the node is inside a `delayContentExpansion` modifier, but it is `alwaysTryExpand`; otherwise true.
|
|
227
|
+
*/
|
|
228
|
+
expand?: (node: TNode, cxt: ParseContext, immediate: boolean) => TEntity[] | undefined;
|
|
229
|
+
}
|
|
230
|
+
declare class BlockModifierDefinition<TState> extends ModifierBase<BlockModifierNode<TState>, BlockEntity> {}
|
|
231
|
+
declare class InlineModifierDefinition<TState> extends ModifierBase<InlineModifierNode<TState>, InlineEntity> {}
|
|
232
|
+
declare class SystemModifierDefinition<TState> extends ModifierBase<SystemModifierNode<TState>, never> {}
|
|
233
|
+
declare class ArgumentInterpolatorDefinition {
|
|
234
|
+
readonly name: string;
|
|
235
|
+
readonly postfix: string;
|
|
236
|
+
constructor(name: string, postfix: string, args?: Partial<ArgumentInterpolatorDefinition>);
|
|
237
|
+
alwaysTryExpand: boolean;
|
|
238
|
+
expand?: (content: string, cxt: ParseContext, immediate: boolean) => string | undefined;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/interface.d.ts
|
|
242
|
+
declare enum MessageSeverity {
|
|
243
|
+
Info = 0,
|
|
244
|
+
Warning = 1,
|
|
245
|
+
Error = 2,
|
|
246
|
+
}
|
|
247
|
+
type Message = {
|
|
248
|
+
readonly severity: MessageSeverity;
|
|
249
|
+
readonly location: LocationRange;
|
|
250
|
+
readonly info: string;
|
|
251
|
+
readonly code: number;
|
|
252
|
+
};
|
|
253
|
+
type LocationRange = {
|
|
254
|
+
original?: LocationRange;
|
|
255
|
+
source: Source;
|
|
256
|
+
start: number;
|
|
257
|
+
end: number;
|
|
258
|
+
actualEnd?: number;
|
|
259
|
+
};
|
|
260
|
+
declare enum NodeType {
|
|
261
|
+
Root = 0,
|
|
262
|
+
Group = 1,
|
|
263
|
+
Paragraph = 2,
|
|
264
|
+
Preformatted = 3,
|
|
265
|
+
Text = 4,
|
|
266
|
+
Escaped = 5,
|
|
267
|
+
SystemModifier = 6,
|
|
268
|
+
InlineModifier = 7,
|
|
269
|
+
BlockModifier = 8,
|
|
270
|
+
Interpolation = 9,
|
|
271
|
+
}
|
|
272
|
+
type RootNode = {
|
|
273
|
+
type: NodeType.Root;
|
|
274
|
+
content: BlockEntity[];
|
|
275
|
+
source: Source;
|
|
276
|
+
};
|
|
277
|
+
type GroupNode = {
|
|
278
|
+
location: LocationRange;
|
|
279
|
+
type: NodeType.Group;
|
|
280
|
+
content: BlockEntity[];
|
|
281
|
+
};
|
|
282
|
+
type ParagraphNode = {
|
|
283
|
+
location: LocationRange;
|
|
284
|
+
type: NodeType.Paragraph;
|
|
285
|
+
content: InlineEntity[];
|
|
286
|
+
};
|
|
287
|
+
type PreNode = {
|
|
288
|
+
location: LocationRange;
|
|
289
|
+
type: NodeType.Preformatted;
|
|
290
|
+
content: {
|
|
291
|
+
start: number;
|
|
292
|
+
end: number;
|
|
293
|
+
text: string;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
type TextNode = {
|
|
297
|
+
location: LocationRange;
|
|
298
|
+
type: NodeType.Text;
|
|
299
|
+
content: string;
|
|
300
|
+
};
|
|
301
|
+
type EscapedNode = {
|
|
302
|
+
location: LocationRange;
|
|
303
|
+
type: NodeType.Escaped;
|
|
304
|
+
content: string;
|
|
305
|
+
};
|
|
306
|
+
type ModifierArguments = {
|
|
307
|
+
positional: ModifierArgument[];
|
|
308
|
+
named: Map<string, ModifierArgument>;
|
|
309
|
+
location: LocationRange;
|
|
310
|
+
};
|
|
311
|
+
type ModifierNodeBase<TState> = {
|
|
312
|
+
location: LocationRange;
|
|
313
|
+
state?: TState;
|
|
314
|
+
head: LocationRange;
|
|
315
|
+
arguments: ModifierArguments;
|
|
316
|
+
};
|
|
317
|
+
type SystemModifierNode<TState> = ModifierNodeBase<TState> & {
|
|
318
|
+
type: NodeType.SystemModifier;
|
|
319
|
+
mod: SystemModifierDefinition<TState>;
|
|
320
|
+
content: BlockEntity[];
|
|
321
|
+
expansion?: never[];
|
|
322
|
+
};
|
|
323
|
+
type BlockModifierNode<TState> = ModifierNodeBase<TState> & {
|
|
324
|
+
type: NodeType.BlockModifier;
|
|
325
|
+
mod: BlockModifierDefinition<TState>;
|
|
326
|
+
content: BlockEntity[];
|
|
327
|
+
expansion?: BlockEntity[];
|
|
328
|
+
};
|
|
329
|
+
type InlineModifierNode<TState> = ModifierNodeBase<TState> & {
|
|
330
|
+
type: NodeType.InlineModifier;
|
|
331
|
+
mod: InlineModifierDefinition<TState>;
|
|
332
|
+
content: InlineEntity[];
|
|
333
|
+
expansion?: InlineEntity[];
|
|
334
|
+
};
|
|
335
|
+
type ModifierNode<T$1 = any> = BlockModifierNode<T$1> | InlineModifierNode<T$1> | SystemModifierNode<T$1>;
|
|
336
|
+
type BlockEntity = GroupNode | ParagraphNode | PreNode | BlockModifierNode<any> | SystemModifierNode<any>;
|
|
337
|
+
type InlineEntity = TextNode | EscapedNode | InlineModifierNode<any> | SystemModifierNode<any>;
|
|
338
|
+
type DocumentNode = BlockEntity | InlineEntity | RootNode;
|
|
339
|
+
type InterpolationNode = {
|
|
340
|
+
location: LocationRange;
|
|
341
|
+
type: NodeType.Interpolation;
|
|
342
|
+
definition: ArgumentInterpolatorDefinition;
|
|
343
|
+
argument: ModifierArgument;
|
|
344
|
+
expansion?: string;
|
|
345
|
+
};
|
|
346
|
+
type ModifierArgument = {
|
|
347
|
+
location: LocationRange;
|
|
348
|
+
content: ArgumentEntity[];
|
|
349
|
+
expansion?: string;
|
|
350
|
+
};
|
|
351
|
+
type ArgumentEntity = TextNode | EscapedNode | InterpolationNode;
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/parser.d.ts
|
|
354
|
+
declare class Parser {
|
|
355
|
+
#private;
|
|
356
|
+
private scanner;
|
|
357
|
+
private cxt;
|
|
358
|
+
private emit;
|
|
359
|
+
private delayDepth;
|
|
360
|
+
constructor(scanner: Scanner, cxt: ParseContext);
|
|
361
|
+
parse(): Document$1;
|
|
362
|
+
private WHITESPACES;
|
|
363
|
+
private WHITESPACES_OR_NEWLINES;
|
|
364
|
+
private SHOULD_BE_A_NEWLINE;
|
|
365
|
+
private WARN_IF_MORE_NEWLINES_THAN;
|
|
366
|
+
private DOCUMENT;
|
|
367
|
+
private BLOCK_ENTITY;
|
|
368
|
+
private MODIFIER;
|
|
369
|
+
private PRE_PARAGRAPH;
|
|
370
|
+
private MAYBE_GROUPED_PARAGRAPH;
|
|
371
|
+
private PARAGRAPH;
|
|
372
|
+
private SHORTHAND;
|
|
373
|
+
private MODIFIER_BODY;
|
|
374
|
+
private INLINE_ENTITY;
|
|
375
|
+
private PREFORMATTED_INLINE_ENTITY;
|
|
376
|
+
private ARGUMENT_CONTENT;
|
|
377
|
+
private POSSIBLY_NAMED_ARGUMENT;
|
|
378
|
+
private ARGUMENTS;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/renderer.d.ts
|
|
382
|
+
type RendererType<TState, TReturn, TDocument, TOptions = undefined> = {
|
|
383
|
+
state: TState;
|
|
384
|
+
return: TReturn;
|
|
385
|
+
document: TDocument;
|
|
386
|
+
options: TOptions;
|
|
387
|
+
};
|
|
388
|
+
type AnyRendererType = RendererType<any, any, any, any>;
|
|
389
|
+
type getState<Type> = Type extends RendererType<infer T, any, any, any> ? T : never;
|
|
390
|
+
type getReturn<Type> = Type extends RendererType<any, infer T, any, any> ? T : never;
|
|
391
|
+
type getDocument<Type> = Type extends RendererType<any, any, infer T, any> ? T : never;
|
|
392
|
+
type getOptions<Type> = Type extends RendererType<any, any, any, infer T> ? T : never;
|
|
393
|
+
type NodeRenderer<Type extends AnyRendererType, TNode> = (node: TNode, cxt: RenderContext<Type>) => getReturn<Type>;
|
|
394
|
+
type NodeRendererDefinition<Type extends AnyRendererType, TNode, TDef> = [def: TDef, renderer: NodeRenderer<Type, TNode>];
|
|
395
|
+
declare class RenderContext<Type extends AnyRendererType> {
|
|
396
|
+
readonly config: RenderConfiguration<Type>;
|
|
397
|
+
readonly parsedDocument: Document$1;
|
|
398
|
+
state: getState<Type>;
|
|
399
|
+
renderEntity(node: BlockEntity | InlineEntity): getReturn<Type>[];
|
|
400
|
+
constructor(config: RenderConfiguration<Type>, parsedDocument: Document$1, state: getState<Type>);
|
|
401
|
+
}
|
|
402
|
+
interface ReadonlyRenderConfiguration<Type extends AnyRendererType> {
|
|
403
|
+
readonly options: getOptions<Type>;
|
|
404
|
+
readonly paragraphRenderer?: NodeRenderer<Type, ParagraphNode>;
|
|
405
|
+
readonly textRenderer?: NodeRenderer<Type, TextNode | PreNode | EscapedNode>;
|
|
406
|
+
readonly undefinedBlockRenderer?: NodeRenderer<Type, BlockModifierNode<any>>;
|
|
407
|
+
readonly undefinedInlineRenderer?: NodeRenderer<Type, InlineModifierNode<any>>;
|
|
408
|
+
readonly blockRenderers: ReadonlyMap<BlockModifierDefinition<any>, NodeRenderer<Type, BlockModifierNode<any>>>;
|
|
409
|
+
readonly inlineRenderers: ReadonlyMap<InlineModifierDefinition<any>, NodeRenderer<Type, InlineModifierNode<any>>>;
|
|
410
|
+
readonly postprocessor: (results: getReturn<Type>[], cxt: RenderContext<Type>) => getDocument<Type>;
|
|
411
|
+
render(doc: Document$1, state: getState<Type>): getDocument<Type>;
|
|
412
|
+
}
|
|
413
|
+
type BlockRendererDefiniton<Type extends AnyRendererType, ModState = any> = NodeRendererDefinition<Type, BlockModifierNode<ModState>, BlockModifierDefinition<ModState>>;
|
|
414
|
+
type InlineRendererDefiniton<Type extends AnyRendererType, ModState = any> = NodeRendererDefinition<Type, InlineModifierNode<ModState>, InlineModifierDefinition<ModState>>;
|
|
415
|
+
declare class RenderConfiguration<Type extends AnyRendererType> implements ReadonlyRenderConfiguration<Type> {
|
|
416
|
+
options: getOptions<Type>;
|
|
417
|
+
postprocessor: (results: getReturn<Type>[], cxt: RenderContext<Type>) => getDocument<Type>;
|
|
418
|
+
paragraphRenderer?: NodeRenderer<Type, ParagraphNode>;
|
|
419
|
+
textRenderer?: NodeRenderer<Type, TextNode | PreNode | EscapedNode>;
|
|
420
|
+
undefinedBlockRenderer?: NodeRenderer<Type, BlockModifierNode<any>>;
|
|
421
|
+
undefinedInlineRenderer?: NodeRenderer<Type, InlineModifierNode<any>>;
|
|
422
|
+
blockRenderers: Map<BlockModifierDefinition<any>, NodeRenderer<Type, BlockModifierNode<any>>>;
|
|
423
|
+
inlineRenderers: Map<InlineModifierDefinition<any>, NodeRenderer<Type, InlineModifierNode<any>>>;
|
|
424
|
+
constructor(options: getOptions<Type>, postprocessor: (results: getReturn<Type>[], cxt: RenderContext<Type>) => getDocument<Type>);
|
|
425
|
+
render(doc: Document$1, state: getState<Type>): getDocument<Type>;
|
|
426
|
+
addBlockRenderer(...rs: BlockRendererDefiniton<Type>[]): void;
|
|
427
|
+
addInlineRenderer(...rs: InlineRendererDefiniton<Type>[]): void;
|
|
428
|
+
static from<Type extends AnyRendererType>(from: ReadonlyRenderConfiguration<Type>): RenderConfiguration<Type>;
|
|
429
|
+
}
|
|
430
|
+
declare namespace messages_d_exports {
|
|
431
|
+
export { ArgumentCountMismatchMessage, CannotExpandArgumentMessage, CannotUseModuleInSelfMessage, ContentExpectedMessage, DuplicateNamedArgumentMessage, EitherNormalOrPreMessage, EntityNotAllowedMessage, ExpectedMessage, InternalErrorMessage, InvalidArgumentMessage, MultipleBlocksNotPermittedMessage, NameAlreadyDefinedMessage, NewBlockShouldBeOnNewlineMessage, NoNestedModuleMessage, OnlySimpleParagraphsPermittedMessage, OverwriteDefinitionsMessage, OverwriteSpecialVariableMessage, ReachedRecursionLimitMessage, ShouldBeOnNewlineMessage, SlotUsedOutsideDefinitionMessage, UnclosedInlineModifierMessage, UndefinedVariableMessage, UnknownModifierMessage, UnnecessaryNewlineMessage };
|
|
432
|
+
}
|
|
433
|
+
declare class AddThingMessage implements Message {
|
|
434
|
+
readonly code: number;
|
|
435
|
+
readonly severity: MessageSeverity;
|
|
436
|
+
readonly location: LocationRange;
|
|
437
|
+
readonly info: string;
|
|
438
|
+
constructor(code: number, severity: MessageSeverity, location: LocationRange, info: string);
|
|
439
|
+
}
|
|
440
|
+
declare class RemoveThingMessage implements Message {
|
|
441
|
+
readonly code: number;
|
|
442
|
+
readonly severity: MessageSeverity;
|
|
443
|
+
readonly location: LocationRange;
|
|
444
|
+
readonly info: string;
|
|
445
|
+
constructor(code: number, severity: MessageSeverity, location: LocationRange, info: string);
|
|
446
|
+
}
|
|
447
|
+
declare class ExpectedMessage implements Message {
|
|
448
|
+
readonly location: LocationRange;
|
|
449
|
+
private what;
|
|
450
|
+
constructor(location: LocationRange, what: string);
|
|
451
|
+
readonly code = 1;
|
|
452
|
+
readonly severity = MessageSeverity.Error;
|
|
453
|
+
get info(): string;
|
|
454
|
+
}
|
|
455
|
+
declare class UnknownModifierMessage implements Message {
|
|
456
|
+
readonly location: LocationRange;
|
|
457
|
+
private what;
|
|
458
|
+
constructor(location: LocationRange, what: string);
|
|
459
|
+
readonly code = 2;
|
|
460
|
+
readonly severity = MessageSeverity.Error;
|
|
461
|
+
get info(): string;
|
|
462
|
+
}
|
|
463
|
+
declare class UnclosedInlineModifierMessage implements Message {
|
|
464
|
+
readonly location: LocationRange;
|
|
465
|
+
private what;
|
|
466
|
+
constructor(location: LocationRange, what: string);
|
|
467
|
+
readonly code = 3;
|
|
468
|
+
readonly severity = MessageSeverity.Error;
|
|
469
|
+
get info(): string;
|
|
470
|
+
}
|
|
471
|
+
declare class ArgumentCountMismatchMessage implements Message {
|
|
472
|
+
readonly location: LocationRange;
|
|
473
|
+
constructor(location: LocationRange, min?: number, max?: number);
|
|
474
|
+
private msg;
|
|
475
|
+
readonly code = 4;
|
|
476
|
+
readonly severity = MessageSeverity.Error;
|
|
477
|
+
get info(): string;
|
|
478
|
+
}
|
|
479
|
+
declare class CannotExpandArgumentMessage implements Message {
|
|
480
|
+
readonly location: LocationRange;
|
|
481
|
+
private what?;
|
|
482
|
+
constructor(location: LocationRange, what?: string | undefined);
|
|
483
|
+
readonly code = 5;
|
|
484
|
+
readonly severity = MessageSeverity.Error;
|
|
485
|
+
get info(): string;
|
|
486
|
+
}
|
|
487
|
+
declare class InvalidArgumentMessage implements Message {
|
|
488
|
+
readonly location: LocationRange;
|
|
489
|
+
private what?;
|
|
490
|
+
constructor(location: LocationRange, what?: string | undefined);
|
|
491
|
+
readonly code = 6;
|
|
492
|
+
readonly severity = MessageSeverity.Error;
|
|
493
|
+
get info(): string;
|
|
494
|
+
}
|
|
495
|
+
declare class EntityNotAllowedMessage implements Message {
|
|
496
|
+
readonly location: LocationRange;
|
|
497
|
+
private what?;
|
|
498
|
+
constructor(location: LocationRange, what?: string | undefined);
|
|
499
|
+
readonly code = 7;
|
|
500
|
+
readonly severity = MessageSeverity.Error;
|
|
501
|
+
get info(): string;
|
|
502
|
+
}
|
|
503
|
+
declare class ReachedRecursionLimitMessage implements Message {
|
|
504
|
+
readonly location: LocationRange;
|
|
505
|
+
private limit;
|
|
506
|
+
private what;
|
|
507
|
+
constructor(location: LocationRange, limit: number, what: string);
|
|
508
|
+
readonly code = 8;
|
|
509
|
+
readonly severity = MessageSeverity.Error;
|
|
510
|
+
get info(): string;
|
|
511
|
+
}
|
|
512
|
+
declare class SlotUsedOutsideDefinitionMessage implements Message {
|
|
513
|
+
readonly location: LocationRange;
|
|
514
|
+
constructor(location: LocationRange);
|
|
515
|
+
readonly code = 9;
|
|
516
|
+
readonly severity = MessageSeverity.Error;
|
|
517
|
+
get info(): string;
|
|
518
|
+
}
|
|
519
|
+
declare class NoNestedModuleMessage implements Message {
|
|
520
|
+
readonly location: LocationRange;
|
|
521
|
+
constructor(location: LocationRange);
|
|
522
|
+
readonly code = 10;
|
|
523
|
+
readonly severity = MessageSeverity.Error;
|
|
524
|
+
get info(): string;
|
|
525
|
+
}
|
|
526
|
+
declare class CannotUseModuleInSelfMessage implements Message {
|
|
527
|
+
readonly location: LocationRange;
|
|
528
|
+
constructor(location: LocationRange);
|
|
529
|
+
readonly code = 11;
|
|
530
|
+
readonly severity = MessageSeverity.Error;
|
|
531
|
+
get info(): string;
|
|
532
|
+
}
|
|
533
|
+
declare class EitherNormalOrPreMessage implements Message {
|
|
534
|
+
readonly location: LocationRange;
|
|
535
|
+
constructor(location: LocationRange);
|
|
536
|
+
readonly code = 12;
|
|
537
|
+
readonly severity = MessageSeverity.Error;
|
|
538
|
+
get info(): string;
|
|
539
|
+
}
|
|
540
|
+
declare class MultipleBlocksNotPermittedMessage implements Message {
|
|
541
|
+
readonly location: LocationRange;
|
|
542
|
+
constructor(location: LocationRange);
|
|
543
|
+
readonly code = 13;
|
|
544
|
+
readonly severity = MessageSeverity.Error;
|
|
545
|
+
get info(): string;
|
|
546
|
+
}
|
|
547
|
+
declare class OnlySimpleParagraphsPermittedMessage implements Message {
|
|
548
|
+
readonly location: LocationRange;
|
|
549
|
+
constructor(location: LocationRange);
|
|
550
|
+
readonly code = 14;
|
|
551
|
+
readonly severity = MessageSeverity.Error;
|
|
552
|
+
get info(): string;
|
|
553
|
+
}
|
|
554
|
+
declare class ContentExpectedMessage implements Message {
|
|
555
|
+
readonly location: LocationRange;
|
|
556
|
+
constructor(location: LocationRange);
|
|
557
|
+
readonly code = 15;
|
|
558
|
+
readonly severity = MessageSeverity.Error;
|
|
559
|
+
get info(): string;
|
|
560
|
+
}
|
|
561
|
+
declare class InternalErrorMessage implements Message {
|
|
562
|
+
readonly location: LocationRange;
|
|
563
|
+
readonly error: any;
|
|
564
|
+
constructor(location: LocationRange, error: any);
|
|
565
|
+
readonly code = 16;
|
|
566
|
+
readonly severity = MessageSeverity.Error;
|
|
567
|
+
get info(): string;
|
|
568
|
+
}
|
|
569
|
+
declare class DuplicateNamedArgumentMessage implements Message {
|
|
570
|
+
readonly location: LocationRange;
|
|
571
|
+
readonly name: string;
|
|
572
|
+
constructor(location: LocationRange, name: string);
|
|
573
|
+
readonly code = 17;
|
|
574
|
+
readonly severity = MessageSeverity.Error;
|
|
575
|
+
get info(): string;
|
|
576
|
+
}
|
|
577
|
+
declare class UnnecessaryNewlineMessage extends RemoveThingMessage {
|
|
578
|
+
constructor(location: LocationRange);
|
|
579
|
+
}
|
|
580
|
+
declare class NewBlockShouldBeOnNewlineMessage extends AddThingMessage {
|
|
581
|
+
constructor(location: LocationRange);
|
|
582
|
+
}
|
|
583
|
+
declare class ShouldBeOnNewlineMessage extends AddThingMessage {
|
|
584
|
+
constructor(location: LocationRange);
|
|
585
|
+
}
|
|
586
|
+
declare class NameAlreadyDefinedMessage implements Message {
|
|
587
|
+
readonly location: LocationRange;
|
|
588
|
+
private what;
|
|
589
|
+
constructor(location: LocationRange, what: string);
|
|
590
|
+
readonly code = 4;
|
|
591
|
+
readonly severity = MessageSeverity.Warning;
|
|
592
|
+
get info(): string;
|
|
593
|
+
}
|
|
594
|
+
declare class UndefinedVariableMessage implements Message {
|
|
595
|
+
readonly location: LocationRange;
|
|
596
|
+
private what;
|
|
597
|
+
constructor(location: LocationRange, what: string);
|
|
598
|
+
readonly code = 5;
|
|
599
|
+
readonly severity = MessageSeverity.Warning;
|
|
600
|
+
get info(): string;
|
|
601
|
+
}
|
|
602
|
+
declare class OverwriteDefinitionsMessage implements Message {
|
|
603
|
+
readonly location: LocationRange;
|
|
604
|
+
private what;
|
|
605
|
+
constructor(location: LocationRange, what: string);
|
|
606
|
+
readonly code = 6;
|
|
607
|
+
readonly severity = MessageSeverity.Warning;
|
|
608
|
+
get info(): string;
|
|
609
|
+
}
|
|
610
|
+
declare class OverwriteSpecialVariableMessage implements Message {
|
|
611
|
+
readonly location: LocationRange;
|
|
612
|
+
private varname;
|
|
613
|
+
private previous;
|
|
614
|
+
constructor(location: LocationRange, varname: string, previous: string);
|
|
615
|
+
readonly code = 6;
|
|
616
|
+
readonly severity = MessageSeverity.Warning;
|
|
617
|
+
get info(): string;
|
|
618
|
+
}
|
|
619
|
+
declare namespace modifier_helper_d_exports {
|
|
620
|
+
export { bindArgs, createParagraphWrapper, createPlaintextWrapper, onlyPermitPlaintextParagraph, onlyPermitSimpleParagraphs, onlyPermitSingleBlock };
|
|
621
|
+
}
|
|
622
|
+
type BindResult<P extends string[], Opt extends string[], N extends Record<string, string>> = {
|
|
623
|
+
msgs: Message[];
|
|
624
|
+
args: undefined;
|
|
625
|
+
nodes: undefined;
|
|
626
|
+
rest: undefined;
|
|
627
|
+
restNodes: undefined;
|
|
628
|
+
} | {
|
|
629
|
+
msgs: null;
|
|
630
|
+
args: { [key in P[number]]: string } & { [key in Opt[number]]?: string | undefined } & { [key in keyof N]: string };
|
|
631
|
+
nodes: { [key in P[number]]: ModifierArgument } & { [key in Opt[number]]: ModifierArgument | undefined } & { [key in keyof N]: ModifierArgument | undefined };
|
|
632
|
+
rest: string[];
|
|
633
|
+
restNodes: ModifierArgument[];
|
|
634
|
+
};
|
|
635
|
+
declare function bindArgs<P extends string[], Opt extends string[] = [], N extends Record<string, string> = {}>(node: ModifierNode, p: readonly [...P], opts?: {
|
|
636
|
+
named?: N;
|
|
637
|
+
optional?: readonly [...Opt];
|
|
638
|
+
rest?: boolean;
|
|
639
|
+
restNamed?: boolean;
|
|
640
|
+
trim?: boolean;
|
|
641
|
+
}): BindResult<P, Opt, N>;
|
|
642
|
+
/**
|
|
643
|
+
* Helper function to ensure that a modifier only accepts plaintext paragraphs as content.
|
|
644
|
+
* @returns The content as a string if OK, otherwise an array of error messages.
|
|
645
|
+
*/
|
|
646
|
+
declare function onlyPermitPlaintextParagraph(node: BlockModifierNode<any> | SystemModifierNode<any>): Message[] | string;
|
|
647
|
+
/**
|
|
648
|
+
* Helper function to ensure that a modifier does not accept any block modifiers inside its content.
|
|
649
|
+
* @returns `null` if OK, otherwise an array of error messages.
|
|
650
|
+
*/
|
|
651
|
+
declare function onlyPermitSimpleParagraphs(node: BlockModifierNode<any> | SystemModifierNode<any>): Message[] | null;
|
|
652
|
+
/**
|
|
653
|
+
* Helper function to ensure that a modifier only accepts one block as its content.
|
|
654
|
+
* @returns `null` if OK, otherwise an array of error messages.
|
|
655
|
+
*/
|
|
656
|
+
declare function onlyPermitSingleBlock(node: BlockModifierNode<any> | SystemModifierNode<any>, opt?: {
|
|
657
|
+
optional?: boolean;
|
|
658
|
+
}): Message[] | null;
|
|
659
|
+
declare function createPlaintextWrapper(name: string, get: (cxt: ParseContext) => string | undefined, set: (cxt: ParseContext, value: string) => string, slotType?: ModifierSlotType): SystemModifierDefinition<void>;
|
|
660
|
+
declare function createParagraphWrapper(name: string, get: (cxt: ParseContext) => ParagraphNode | undefined, set: (cxt: ParseContext, value: ParagraphNode) => void, slotType?: ModifierSlotType): SystemModifierDefinition<void>;
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/node-util.d.ts
|
|
663
|
+
type CloneNodeOptions = {
|
|
664
|
+
newLocation?: LocationRange;
|
|
665
|
+
withState?: boolean;
|
|
666
|
+
};
|
|
667
|
+
declare function cloneNode<T$1 extends DocumentNode>(node: T$1, options?: CloneNodeOptions): T$1;
|
|
668
|
+
declare function cloneNodes<T$1 extends readonly DocumentNode[]>(nodes: T$1, options?: CloneNodeOptions): T$1;
|
|
669
|
+
/** Warning: modifies the original nodes */
|
|
670
|
+
declare function stripNode(...nodes: DocumentNode[]): DocumentNode[];
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/builtin/builtin.d.ts
|
|
673
|
+
declare const BuiltinConfiguration: ReadonlyConfiguration;
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/default/default.d.ts
|
|
676
|
+
declare const DefaultConfiguration: ReadonlyConfiguration;
|
|
677
|
+
//#endregion
|
|
678
|
+
//#region src/default/html-renderer.d.ts
|
|
679
|
+
type HTMLRendererOptions = {
|
|
680
|
+
document: Document;
|
|
681
|
+
headPlugins: HTMLComponentPlugin[];
|
|
682
|
+
headerPlugins: HTMLComponentPlugin[];
|
|
683
|
+
footerPlugins: HTMLComponentPlugin[];
|
|
684
|
+
postprocessPlugins: HTMLPostprocessPlugin[];
|
|
685
|
+
transformAsset: (id: string) => string | undefined;
|
|
686
|
+
};
|
|
687
|
+
type HTMLRenderType = {
|
|
688
|
+
state: HTMLRenderState;
|
|
689
|
+
options: HTMLRendererOptions;
|
|
690
|
+
document: Document;
|
|
691
|
+
return: Node | Node[];
|
|
692
|
+
};
|
|
693
|
+
type HTMLRenderPlugin = (elem: BlockEntity | InlineEntity, cxt: RenderContext<HTMLRenderType>) => string | undefined;
|
|
694
|
+
type HTMLComponentPlugin = (cxt: RenderContext<HTMLRenderType>) => Node | Node[] | undefined;
|
|
695
|
+
type HTMLPostprocessPlugin = (cxt: RenderContext<HTMLRenderType>, output: Document) => void;
|
|
696
|
+
declare class HTMLRenderState {
|
|
697
|
+
title: string;
|
|
698
|
+
stylesheet: string;
|
|
699
|
+
cssVariables: Map<string, string>;
|
|
700
|
+
invalidBlock(node: BlockEntity, msg: string): minimal_jsx_runtime_jsx_runtime0.JSX.Element;
|
|
701
|
+
invalidInline(node: InlineEntity, msg: string): minimal_jsx_runtime_jsx_runtime0.JSX.Element;
|
|
702
|
+
render(elems: (BlockEntity | InlineEntity)[], cxt: RenderContext<HTMLRenderType>): DocumentFragment;
|
|
703
|
+
}
|
|
704
|
+
declare const HTMLRenderConfiguration: ReadonlyRenderConfiguration<HTMLRenderType>;
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/debug-print.d.ts
|
|
707
|
+
declare const debugPrint: {
|
|
708
|
+
blockModifier: (x: BlockModifierDefinition<any>) => string;
|
|
709
|
+
inlineModifier: (x: InlineModifierDefinition<any>) => string;
|
|
710
|
+
inlineShorthand: (x: InlineShorthand<any>) => string;
|
|
711
|
+
blockShorthand: (x: BlockShorthand<any>) => string;
|
|
712
|
+
argument: (arg: ModifierArgument) => string;
|
|
713
|
+
node: (...nodes: (BlockEntity | InlineEntity)[]) => string;
|
|
714
|
+
message: typeof debugPrintMsg;
|
|
715
|
+
range: typeof debugPrintRange;
|
|
716
|
+
document: typeof debugDumpDocument;
|
|
717
|
+
};
|
|
718
|
+
declare function debugPrintRange(loc: LocationRange, context?: number): string;
|
|
719
|
+
declare function debugPrintMsg(m: Message): string;
|
|
720
|
+
declare function debugDumpDocument(doc: Document$1): string;
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/index.d.ts
|
|
723
|
+
declare const emmmVersion = "0.0.6";
|
|
724
|
+
declare function setDebugLevel(level: DebugLevel): void;
|
|
725
|
+
//#endregion
|
|
726
|
+
export { ArgumentEntity, ArgumentInterpolatorDefinition, BlockEntity, BlockModifierDefinition, BlockModifierNode, BlockRendererDefiniton, BlockShorthand, BuiltinConfiguration, CloneNodeOptions, Configuration, DebugLevel, DefaultConfiguration, Document$1 as Document, DocumentNode, EscapedNode, GroupNode, HTMLComponentPlugin, HTMLPostprocessPlugin, HTMLRenderConfiguration, HTMLRenderPlugin, HTMLRenderState, HTMLRenderType, HTMLRendererOptions, InlineEntity, InlineModifierDefinition, InlineModifierNode, InlineRendererDefiniton, InlineShorthand, Inspector, InterpolationNode, KernelConfiguration, LocationRange, Message, MessageSeverity, ModifierArgument, ModifierArguments, ModifierMetadata, ModifierNode, ModifierSlotType, NodeRenderer, NodeRendererDefinition, NodeType, ParagraphNode, ParseContext, ParseContextStoreDefinitions, ParseContextStoreKey, Parser, PreNode, ReadonlyConfiguration, ReadonlyRenderConfiguration, RenderConfiguration, RenderContext, RendererType, RootNode, Scanner, SimpleScanner, Source, SourceDescriptor, StringSource, SystemModifierDefinition, SystemModifierNode, TextNode, cloneNode, cloneNodes, debugPrint, emmmVersion, modifier_helper_d_exports as helper, messages_d_exports as messages, setDebugLevel, stripNode };
|
|
727
|
+
//# sourceMappingURL=index.d.cts.map
|