@wdprlib/parser 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -38
- package/dist/index.cjs +973 -134
- package/dist/index.d.cts +195 -158
- package/dist/index.d.ts +195 -158
- package/dist/index.js +955 -113
- package/package.json +2 -2
- package/src/index.ts +17 -0
- package/src/parser/parse/context.ts +1 -0
- package/src/parser/parse/options.ts +6 -0
- package/src/parser/parse/result.ts +3 -1
- package/src/parser/rules/block/gallery/index.ts +215 -0
- package/src/parser/rules/block/gallery/items.ts +62 -0
- package/src/parser/rules/block/index.ts +3 -0
- package/src/parser/rules/block/module/include/index.ts +6 -1
- package/src/parser/rules/block/module/include/resolve/index.ts +23 -3
- package/src/parser/rules/block/module/include/resolve/iterate.ts +71 -0
- package/src/parser/rules/block/module/index.ts +2 -1
- package/src/parser/rules/block/module/listpages/resolution/items.ts +2 -2
- package/src/parser/rules/block/module/listpages/resolution/wrapper.ts +3 -3
- package/src/parser/rules/block/module/listusers/resolve.ts +2 -2
- package/src/parser/rules/block/module/resolution/document.ts +357 -0
- package/src/parser/rules/block/module/resolution/resolve-async.ts +269 -0
- package/src/parser/rules/block/module/resolution/styles.ts +134 -12
- package/src/parser/rules/block/module/resolution/walk-resolve.ts +19 -1
- package/src/parser/rules/block/module/resolve.ts +32 -13
- package/src/parser/rules/block/module/types.ts +7 -2
- package/src/parser/rules/contracts/parse-context.ts +1 -0
- package/src/pipeline/index.ts +7 -0
- package/src/pipeline/process.ts +105 -0
- package/src/pipeline/types.ts +63 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Position as Position2, Point, Version as Version2, Element as Element8, SyntaxTree as
|
|
1
|
+
import { Position as Position2, Point, Version as Version2, Element as Element8, SyntaxTree as SyntaxTree5, ContainerType, ContainerData, AttributeMap, VariableMap, Alignment, LinkType, LinkLocation, LinkLabel, PageRef as PageRef4, ImageSource, FloatAlignment, ListType, ListItem, ListData, CodeBlockData as CodeBlockData2, TabData, TableCell, TableRow, TableData, DefinitionListItem, Module as Module5, CollapsibleData, ClearFloat, AnchorTarget, HeaderType, AlignType, HeadingLevel, Heading, DateItem, Embed, TocEntry as TocEntry2, GallerySize, GalleryOrder, GalleryItem, GalleryContent, GalleryData, Diagnostic as Diagnostic4, DiagnosticSeverity, ParseResult as ParseResult4 } from "@wdprlib/ast";
|
|
2
2
|
import { createPoint, createPosition, text, container, paragraph, bold, italics, heading, lineBreak, horizontalRule, link, list, listItemElements, listItemSubList } from "@wdprlib/ast";
|
|
3
|
-
import { WikitextMode, WikitextSettings as
|
|
3
|
+
import { WikitextMode, WikitextSettings as WikitextSettings5 } from "@wdprlib/ast";
|
|
4
4
|
import { createSettings, DEFAULT_SETTINGS } from "@wdprlib/ast";
|
|
5
5
|
import { Position } from "@wdprlib/ast";
|
|
6
6
|
/**
|
|
@@ -181,6 +181,12 @@ interface ParserOptions {
|
|
|
181
181
|
* - `string[]`: every iftags block is evaluated against the given tags eagerly.
|
|
182
182
|
*/
|
|
183
183
|
pageTags?: string[] | null;
|
|
184
|
+
/**
|
|
185
|
+
* Append the implicit document-level footnote block when no explicit block
|
|
186
|
+
* exists. Defaults to true. Fragment pipelines can disable this and add one
|
|
187
|
+
* block after all fragments have been merged.
|
|
188
|
+
*/
|
|
189
|
+
appendImplicitFootnoteBlock?: boolean;
|
|
184
190
|
}
|
|
185
191
|
import { ParseResult } from "@wdprlib/ast";
|
|
186
192
|
/**
|
|
@@ -225,20 +231,155 @@ declare class Parser {
|
|
|
225
231
|
* @since 2.0.0
|
|
226
232
|
*/
|
|
227
233
|
declare function parse(source: string, options?: ParserOptions): ParseResult2;
|
|
228
|
-
import {
|
|
234
|
+
import { WikitextPageContext as WikitextPageContext2 } from "@wdprlib/ast";
|
|
235
|
+
import { Diagnostic, PageRef as PageRef3, SyntaxTree, WikitextPageContext, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
236
|
+
import { PageRef as PageRef2, WikitextSettings as WikitextSettings2 } from "@wdprlib/ast";
|
|
237
|
+
interface IncludeAssignment {
|
|
238
|
+
key: string;
|
|
239
|
+
value: string;
|
|
240
|
+
}
|
|
229
241
|
/**
|
|
230
|
-
*
|
|
242
|
+
* Callback to fetch page content for include resolution.
|
|
243
|
+
* Returns the wikitext source of the page, or null if the page does not exist.
|
|
231
244
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
245
|
+
* @security The fetcher is called with user-provided page references.
|
|
246
|
+
* Implementations should validate and sanitize page references before
|
|
247
|
+
* using them in database queries or file system access.
|
|
248
|
+
*/
|
|
249
|
+
type IncludeFetcher = (pageRef: PageRef2) => string | null;
|
|
250
|
+
/**
|
|
251
|
+
* Async callback to fetch page content for include resolution.
|
|
252
|
+
* Returns a promise of the wikitext source, or null if the page does not exist.
|
|
235
253
|
*
|
|
236
|
-
* @
|
|
237
|
-
*
|
|
254
|
+
* @security The fetcher is called with user-provided page references.
|
|
255
|
+
* Implementations should validate and sanitize page references before
|
|
256
|
+
* using them in database queries or file system access.
|
|
238
257
|
*/
|
|
239
|
-
type
|
|
240
|
-
|
|
241
|
-
|
|
258
|
+
type AsyncIncludeFetcher = (pageRef: PageRef2) => Promise<string | null>;
|
|
259
|
+
/**
|
|
260
|
+
* Options for resolveIncludes / resolveIncludesAsync.
|
|
261
|
+
*/
|
|
262
|
+
interface ResolveIncludesOptions {
|
|
263
|
+
/**
|
|
264
|
+
* Maximum number of expansion iterations (default: 10).
|
|
265
|
+
*
|
|
266
|
+
* Each iteration replaces all `[[include]]` directives in the current
|
|
267
|
+
* source with fetched content. Iteration stops when the source is
|
|
268
|
+
* unchanged or this limit is reached.
|
|
269
|
+
*/
|
|
270
|
+
maxIterations?: number;
|
|
271
|
+
/** Wikitext settings. If enablePageSyntax is false, includes are not expanded. */
|
|
272
|
+
settings?: WikitextSettings2;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* A single include directive found in raw source text.
|
|
276
|
+
*
|
|
277
|
+
* This represents the directive as it existed during the include expansion
|
|
278
|
+
* phase. It does not imply that the target exists, and it does not include
|
|
279
|
+
* nested dependencies introduced by the target source.
|
|
280
|
+
*/
|
|
281
|
+
interface IncludeReference {
|
|
282
|
+
/** Target page reference parsed from the directive. */
|
|
283
|
+
location: PageRef2;
|
|
284
|
+
/** Variable assignments parsed from the directive, preserving source order. */
|
|
285
|
+
assignments: IncludeAssignment[];
|
|
286
|
+
/** Index of the opening `[[`. */
|
|
287
|
+
start: number;
|
|
288
|
+
/** Index just past the closing `]]`. */
|
|
289
|
+
end: number;
|
|
290
|
+
/** Text between `[[include ` and the closing `]]`. */
|
|
291
|
+
inner: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Include dependency observed during iterative expansion.
|
|
295
|
+
*
|
|
296
|
+
* Unlike `IncludeReference`, this is collected after a fetchable include layer
|
|
297
|
+
* has actually been expanded. If an included page introduces another include,
|
|
298
|
+
* that nested directive appears as a later `IncludeDependency` with a higher
|
|
299
|
+
* `iteration`.
|
|
300
|
+
*/
|
|
301
|
+
interface IncludeDependency extends IncludeReference {
|
|
302
|
+
/** Zero-based expansion iteration where this directive was observed. */
|
|
303
|
+
iteration: number;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Trace data for one include expansion iteration.
|
|
307
|
+
*
|
|
308
|
+
* `directives` is the scan result before replacements for that iteration.
|
|
309
|
+
* `changed` is false for stable self-includes where replacing the directive
|
|
310
|
+
* produces the same source again; the resolver stops at that point.
|
|
311
|
+
*/
|
|
312
|
+
interface IncludeIterationTrace {
|
|
313
|
+
/** Zero-based expansion iteration. */
|
|
314
|
+
iteration: number;
|
|
315
|
+
/** Include directives found in the source for this iteration. */
|
|
316
|
+
directives: IncludeReference[];
|
|
317
|
+
/** Whether replacing the directives changed the source. */
|
|
318
|
+
changed: boolean;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Result returned by trace-enabled include expansion.
|
|
322
|
+
*
|
|
323
|
+
* The `source` field is intended to be byte-for-byte equivalent to
|
|
324
|
+
* `resolveIncludes(source, fetcher, options)` for the same inputs. The rest of
|
|
325
|
+
* the object is diagnostic data for dependency collection and cache planning.
|
|
326
|
+
*/
|
|
327
|
+
interface ResolveIncludesTraceResult {
|
|
328
|
+
/** Final expanded source. */
|
|
329
|
+
source: string;
|
|
330
|
+
/** Include dependencies observed across all expansion iterations. */
|
|
331
|
+
dependencies: IncludeDependency[];
|
|
332
|
+
/** Per-iteration include scan and change information. */
|
|
333
|
+
iterations: IncludeIterationTrace[];
|
|
334
|
+
/** True when expansion stopped with directives still present after hitting the iteration cap. */
|
|
335
|
+
reachedMaxIterations: boolean;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Expand all [[include]] directives in the source text.
|
|
339
|
+
*
|
|
340
|
+
* Uses Wikidot-compatible iterative expansion: each iteration replaces
|
|
341
|
+
* all include directives in the current source with fetched and
|
|
342
|
+
* variable-substituted content. Iteration continues until no further
|
|
343
|
+
* changes occur or `maxIterations` is reached.
|
|
344
|
+
*/
|
|
345
|
+
declare function resolveIncludes(source: string, fetcher: IncludeFetcher, options?: ResolveIncludesOptions): string;
|
|
346
|
+
/**
|
|
347
|
+
* Expand all [[include]] directives and return dependency/iteration trace data.
|
|
348
|
+
*
|
|
349
|
+
* This follows the same sync expansion behavior as {@link resolveIncludes};
|
|
350
|
+
* the additional trace data is intended for application-level dependency
|
|
351
|
+
* graphs, cache invalidation, and diagnostics.
|
|
352
|
+
*/
|
|
353
|
+
declare function resolveIncludesWithTrace(source: string, fetcher: IncludeFetcher, options?: ResolveIncludesOptions): ResolveIncludesTraceResult;
|
|
354
|
+
/**
|
|
355
|
+
* Async version of {@link resolveIncludes}.
|
|
356
|
+
*
|
|
357
|
+
* Expand all [[include]] directives using an async fetcher, allowing
|
|
358
|
+
* page content to be loaded from async sources such as databases.
|
|
359
|
+
*/
|
|
360
|
+
declare function resolveIncludesAsync(source: string, fetcher: AsyncIncludeFetcher, options?: ResolveIncludesOptions): Promise<string>;
|
|
361
|
+
/**
|
|
362
|
+
* Async include expansion with dependency and iteration trace data.
|
|
363
|
+
*/
|
|
364
|
+
declare function resolveIncludesAsyncWithTrace(source: string, fetcher: AsyncIncludeFetcher, options?: ResolveIncludesOptions): Promise<ResolveIncludesTraceResult>;
|
|
365
|
+
/**
|
|
366
|
+
* Extract include directives from raw source without fetching or expanding them.
|
|
367
|
+
*
|
|
368
|
+
* This uses the same scanner and directive parser as `resolveIncludes`, so it
|
|
369
|
+
* reports only directives that the include expansion pass would recognize.
|
|
370
|
+
*
|
|
371
|
+
* This is a source-phase API. It intentionally does not evaluate later syntax
|
|
372
|
+
* such as comments, expressions, or iftags. Wikidot expands includes before
|
|
373
|
+
* those phases, so an include inside a later comment block is still reported,
|
|
374
|
+
* while a token that only becomes `[[include ...]]` after comment/expression/
|
|
375
|
+
* iftags processing is not reported.
|
|
376
|
+
*
|
|
377
|
+
* The result is not a complete transitive dependency graph. Nested includes
|
|
378
|
+
* only become visible after fetching and expanding the current layer; use
|
|
379
|
+
* `resolveIncludesWithTrace` when the caller needs observed dependency edges
|
|
380
|
+
* across iterative expansion.
|
|
381
|
+
*/
|
|
382
|
+
declare function extractIncludeReferences(source: string, options?: ResolveIncludesOptions): IncludeReference[];
|
|
242
383
|
/**
|
|
243
384
|
* ListPages query parameters for page selection.
|
|
244
385
|
*
|
|
@@ -688,116 +829,52 @@ interface VariableContext {
|
|
|
688
829
|
* Compiled template function.
|
|
689
830
|
*/
|
|
690
831
|
type CompiledTemplate = (ctx: VariableContext) => string;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
* Called when evaluating `[[iftags]]` conditions. The application must provide
|
|
695
|
-
* this callback with access to the current page's tag list.
|
|
696
|
-
*
|
|
697
|
-
* @returns Array of tag names for the current page
|
|
698
|
-
*/
|
|
699
|
-
type IfTagsResolver = () => string[];
|
|
700
|
-
import { PageRef as PageRef2, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
701
|
-
interface IncludeAssignment {
|
|
702
|
-
key: string;
|
|
703
|
-
value: string;
|
|
832
|
+
interface ProcessWikitextCallbackContext<TPage extends WikitextPageContext> {
|
|
833
|
+
page: TPage;
|
|
834
|
+
settings: WikitextSettings3;
|
|
704
835
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
type IncludeFetcher = (pageRef: PageRef2) => string | null;
|
|
714
|
-
/**
|
|
715
|
-
* Async callback to fetch page content for include resolution.
|
|
716
|
-
* Returns a promise of the wikitext source, or null if the page does not exist.
|
|
717
|
-
*
|
|
718
|
-
* @security The fetcher is called with user-provided page references.
|
|
719
|
-
* Implementations should validate and sanitize page references before
|
|
720
|
-
* using them in database queries or file system access.
|
|
721
|
-
*/
|
|
722
|
-
type AsyncIncludeFetcher = (pageRef: PageRef2) => Promise<string | null>;
|
|
723
|
-
/**
|
|
724
|
-
* Options for resolveIncludes / resolveIncludesAsync.
|
|
725
|
-
*/
|
|
726
|
-
interface ResolveIncludesOptions {
|
|
727
|
-
/**
|
|
728
|
-
* Maximum number of expansion iterations (default: 10).
|
|
729
|
-
*
|
|
730
|
-
* Each iteration replaces all `[[include]]` directives in the current
|
|
731
|
-
* source with fetched content. Iteration stops when the source is
|
|
732
|
-
* unchanged or this limit is reached.
|
|
733
|
-
*/
|
|
734
|
-
maxIterations?: number;
|
|
735
|
-
/** Wikitext settings. If enablePageSyntax is false, includes are not expanded. */
|
|
836
|
+
interface ProcessWikitextDataProvider<TPage extends WikitextPageContext> {
|
|
837
|
+
fetchInclude?: (pageRef: PageRef3, context: ProcessWikitextCallbackContext<TPage>) => Promise<string | null>;
|
|
838
|
+
fetchListPages?: (query: NormalizedListPagesQuery, requirement: ListPagesDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListPagesExternalData | null | undefined>;
|
|
839
|
+
fetchListUsers?: (requirement: ListUsersDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListUsersExternalData | null | undefined>;
|
|
840
|
+
fetchTagCloud?: (requirement: TagCloudDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<TagCloudExternalData | null | undefined>;
|
|
841
|
+
}
|
|
842
|
+
interface ProcessWikitextOptions<TPage extends WikitextPageContext> {
|
|
843
|
+
page: TPage;
|
|
736
844
|
settings?: WikitextSettings3;
|
|
845
|
+
dataProvider?: ProcessWikitextDataProvider<TPage>;
|
|
846
|
+
includeMaxIterations?: number;
|
|
737
847
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
*/
|
|
745
|
-
interface IncludeReference {
|
|
746
|
-
/** Target page reference parsed from the directive. */
|
|
747
|
-
location: PageRef2;
|
|
748
|
-
/** Variable assignments parsed from the directive, preserving source order. */
|
|
749
|
-
assignments: IncludeAssignment[];
|
|
750
|
-
/** Index of the opening `[[`. */
|
|
751
|
-
start: number;
|
|
752
|
-
/** Index just past the closing `]]`. */
|
|
753
|
-
end: number;
|
|
754
|
-
/** Text between `[[include ` and the closing `]]`. */
|
|
755
|
-
inner: string;
|
|
848
|
+
interface ProcessedWikitextDocument<TPage extends WikitextPageContext = WikitextPageContext> {
|
|
849
|
+
ast: SyntaxTree;
|
|
850
|
+
page: TPage;
|
|
851
|
+
settings: WikitextSettings3;
|
|
852
|
+
diagnostics: Diagnostic[];
|
|
853
|
+
dependencies: IncludeDependency[];
|
|
756
854
|
}
|
|
855
|
+
declare function processWikitext<TPage extends WikitextPageContext2>(source: string, options: ProcessWikitextOptions<TPage>): Promise<ProcessedWikitextDocument<TPage>>;
|
|
856
|
+
import { ParseResult as ParseResult3, SyntaxTree as SyntaxTree2 } from "@wdprlib/ast";
|
|
757
857
|
/**
|
|
758
|
-
*
|
|
858
|
+
* Parser function type for re-parsing substituted template output as wikitext.
|
|
759
859
|
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* `iteration`.
|
|
764
|
-
*/
|
|
765
|
-
interface IncludeDependency extends IncludeReference {
|
|
766
|
-
/** Zero-based expansion iteration where this directive was observed. */
|
|
767
|
-
iteration: number;
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* Trace data for one include expansion iteration.
|
|
860
|
+
* Used by ListPages and ListUsers modules during the resolution phase. After
|
|
861
|
+
* template variables are substituted with actual data, the resulting string
|
|
862
|
+
* needs to be parsed as wikitext to produce AST elements.
|
|
771
863
|
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* produces the same source again; the resolver stops at that point.
|
|
864
|
+
* @param input - Wikitext string to parse
|
|
865
|
+
* @returns Object containing the parsed elements
|
|
775
866
|
*/
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
iteration: number;
|
|
779
|
-
/** Include directives found in the source for this iteration. */
|
|
780
|
-
directives: IncludeReference[];
|
|
781
|
-
/** Whether replacing the directives changed the source. */
|
|
782
|
-
changed: boolean;
|
|
783
|
-
}
|
|
867
|
+
type ModuleParseResult = SyntaxTree2 | ParseResult3;
|
|
868
|
+
type ParseFunction = (input: string) => ModuleParseResult;
|
|
784
869
|
/**
|
|
785
|
-
*
|
|
870
|
+
* Callback to retrieve the current page's tags during the resolve phase.
|
|
786
871
|
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
872
|
+
* Called when evaluating `[[iftags]]` conditions. The application must provide
|
|
873
|
+
* this callback with access to the current page's tag list.
|
|
874
|
+
*
|
|
875
|
+
* @returns Array of tag names for the current page
|
|
790
876
|
*/
|
|
791
|
-
|
|
792
|
-
/** Final expanded source. */
|
|
793
|
-
source: string;
|
|
794
|
-
/** Include dependencies observed across all expansion iterations. */
|
|
795
|
-
dependencies: IncludeDependency[];
|
|
796
|
-
/** Per-iteration include scan and change information. */
|
|
797
|
-
iterations: IncludeIterationTrace[];
|
|
798
|
-
/** True when expansion stopped with directives still present after hitting the iteration cap. */
|
|
799
|
-
reachedMaxIterations: boolean;
|
|
800
|
-
}
|
|
877
|
+
type IfTagsResolver = () => string[];
|
|
801
878
|
/**
|
|
802
879
|
* Callback bag for supplying external data during module resolution.
|
|
803
880
|
*
|
|
@@ -859,7 +936,7 @@ interface DataProvider {
|
|
|
859
936
|
*/
|
|
860
937
|
getPageTags?: IfTagsResolver;
|
|
861
938
|
}
|
|
862
|
-
import { SyntaxTree } from "@wdprlib/ast";
|
|
939
|
+
import { SyntaxTree as SyntaxTree3 } from "@wdprlib/ast";
|
|
863
940
|
/**
|
|
864
941
|
* Complete result of extracting data requirements from an AST.
|
|
865
942
|
*
|
|
@@ -889,7 +966,7 @@ interface ExtractionResult {
|
|
|
889
966
|
* @param ast - The parsed syntax tree to analyze
|
|
890
967
|
* @returns Extraction result containing requirements and compiled templates
|
|
891
968
|
*/
|
|
892
|
-
declare function extractDataRequirements(ast:
|
|
969
|
+
declare function extractDataRequirements(ast: SyntaxTree3): ExtractionResult;
|
|
893
970
|
/**
|
|
894
971
|
* Compile a ListPages template string into an executable function.
|
|
895
972
|
*
|
|
@@ -954,48 +1031,6 @@ declare function normalizeQuery(query: ListPagesQuery): NormalizedListPagesQuery
|
|
|
954
1031
|
*/
|
|
955
1032
|
declare function preprocessIftags(source: string, pageTags: string[] | null): string;
|
|
956
1033
|
/**
|
|
957
|
-
* Expand all [[include]] directives in the source text.
|
|
958
|
-
*
|
|
959
|
-
* Uses Wikidot-compatible iterative expansion: each iteration replaces
|
|
960
|
-
* all include directives in the current source with fetched and
|
|
961
|
-
* variable-substituted content. Iteration continues until no further
|
|
962
|
-
* changes occur or `maxIterations` is reached.
|
|
963
|
-
*/
|
|
964
|
-
declare function resolveIncludes(source: string, fetcher: IncludeFetcher, options?: ResolveIncludesOptions): string;
|
|
965
|
-
/**
|
|
966
|
-
* Expand all [[include]] directives and return dependency/iteration trace data.
|
|
967
|
-
*
|
|
968
|
-
* This follows the same sync expansion behavior as {@link resolveIncludes};
|
|
969
|
-
* the additional trace data is intended for application-level dependency
|
|
970
|
-
* graphs, cache invalidation, and diagnostics.
|
|
971
|
-
*/
|
|
972
|
-
declare function resolveIncludesWithTrace(source: string, fetcher: IncludeFetcher, options?: ResolveIncludesOptions): ResolveIncludesTraceResult;
|
|
973
|
-
/**
|
|
974
|
-
* Async version of {@link resolveIncludes}.
|
|
975
|
-
*
|
|
976
|
-
* Expand all [[include]] directives using an async fetcher, allowing
|
|
977
|
-
* page content to be loaded from async sources such as databases.
|
|
978
|
-
*/
|
|
979
|
-
declare function resolveIncludesAsync(source: string, fetcher: AsyncIncludeFetcher, options?: ResolveIncludesOptions): Promise<string>;
|
|
980
|
-
/**
|
|
981
|
-
* Extract include directives from raw source without fetching or expanding them.
|
|
982
|
-
*
|
|
983
|
-
* This uses the same scanner and directive parser as `resolveIncludes`, so it
|
|
984
|
-
* reports only directives that the include expansion pass would recognize.
|
|
985
|
-
*
|
|
986
|
-
* This is a source-phase API. It intentionally does not evaluate later syntax
|
|
987
|
-
* such as comments, expressions, or iftags. Wikidot expands includes before
|
|
988
|
-
* those phases, so an include inside a later comment block is still reported,
|
|
989
|
-
* while a token that only becomes `[[include ...]]` after comment/expression/
|
|
990
|
-
* iftags processing is not reported.
|
|
991
|
-
*
|
|
992
|
-
* The result is not a complete transitive dependency graph. Nested includes
|
|
993
|
-
* only become visible after fetching and expanding the current layer; use
|
|
994
|
-
* `resolveIncludesWithTrace` when the caller needs observed dependency edges
|
|
995
|
-
* across iterative expansion.
|
|
996
|
-
*/
|
|
997
|
-
declare function extractIncludeReferences(source: string, options?: ResolveIncludesOptions): IncludeReference[];
|
|
998
|
-
/**
|
|
999
1034
|
* Compile a ListUsers template string into an executable function.
|
|
1000
1035
|
*
|
|
1001
1036
|
* The template is split into alternating static strings and dynamic getter
|
|
@@ -1070,7 +1105,7 @@ declare function isTagCloudModule(module: Module4): module is TagCloudModuleData
|
|
|
1070
1105
|
* @returns Array of AST elements replacing the module node
|
|
1071
1106
|
*/
|
|
1072
1107
|
declare function resolveTagCloud(module: TagCloudModuleData, data: TagCloudExternalData): Element7[];
|
|
1073
|
-
import { SyntaxTree as
|
|
1108
|
+
import { Diagnostic as Diagnostic3, SyntaxTree as SyntaxTree4 } from "@wdprlib/ast";
|
|
1074
1109
|
/**
|
|
1075
1110
|
* Transform module-generated wikitext before it is parsed back into AST nodes.
|
|
1076
1111
|
*
|
|
@@ -1138,6 +1173,8 @@ interface ResolveOptions {
|
|
|
1138
1173
|
* state outside wdpr.
|
|
1139
1174
|
*/
|
|
1140
1175
|
transformModuleSource?: ModuleSourceTransform;
|
|
1176
|
+
/** Receives diagnostics emitted by ListPages/ListUsers secondary parses. */
|
|
1177
|
+
onDiagnostics?: (diagnostics: Diagnostic3[]) => void;
|
|
1141
1178
|
}
|
|
1142
1179
|
/**
|
|
1143
1180
|
* Resolve all modules in the AST
|
|
@@ -1153,6 +1190,6 @@ interface ResolveOptions {
|
|
|
1153
1190
|
* @param dataProvider - Callback provider to fetch data for each module
|
|
1154
1191
|
* @param options - Resolution options including requirements
|
|
1155
1192
|
*/
|
|
1156
|
-
declare function resolveModules(ast:
|
|
1193
|
+
declare function resolveModules(ast: SyntaxTree4, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree4>;
|
|
1157
1194
|
import { STYLE_SLOT_PREFIX } from "@wdprlib/ast";
|
|
1158
|
-
export { tokenize, text, resolveTagCloud, resolveModules, resolveListUsers, resolveIncludesWithTrace, resolveIncludesAsync, resolveIncludes, preprocessIftags, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isTagCloudModule, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractIncludeReferences, extractDataRequirements, createToken, createSettings, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold,
|
|
1195
|
+
export { tokenize, text, resolveTagCloud, resolveModules, resolveListUsers, resolveIncludesWithTrace, resolveIncludesAsyncWithTrace, resolveIncludesAsync, resolveIncludes, processWikitext, preprocessIftags, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, listItemSubList, listItemElements, list, link, lineBreak, italics, isTagCloudModule, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractIncludeReferences, extractDataRequirements, createToken, createSettings, createPosition, createPoint, container, compileTemplate, compileListUsersTemplate, bold, WikitextSettings5 as WikitextSettings, WikitextMode, Version2 as Version, VariableMap, VariableContext, UserInfo, TokenType, Token, TocEntry2 as TocEntry, TagCloudTagData, TagCloudModuleData, TagCloudExternalData, TagCloudDataRequirement, TagCloudDataFetcher, TableRow, TableData, TableCell, TabData, SyntaxTree5 as SyntaxTree, SiteContext, STYLE_SLOT_PREFIX, ResolveOptions, ResolveIncludesTraceResult, ResolveIncludesOptions, ProcessedWikitextDocument, ProcessWikitextOptions, ProcessWikitextDataProvider, ProcessWikitextCallbackContext, Position2 as Position, Point, ParserOptions, Parser, ParseResult4 as ParseResult, ParseFunction, PageRef4 as PageRef, PageData, NormalizedTags, NormalizedParent, NormalizedOrder, NormalizedNumericSelector, NormalizedListPagesQuery, NormalizedDateSelector, NormalizedCategory, ModuleSourceTransform, ModuleParseResult, Module5 as Module, ListUsersVariableContext, ListUsersVariable, ListUsersUserData, ListUsersExternalData, ListUsersDataRequirement, ListUsersDataFetcher, ListUsersCompiledTemplate, ListType, ListPagesVariable, ListPagesQuery, ListPagesExternalData, ListPagesDataRequirement, ListPagesDataFetcher, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LexerOptions, Lexer, IncludeReference, IncludeIterationTrace, IncludeFetcher, IncludeDependency, ImageSource, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FloatAlignment, ExtractionResult, Embed, Element8 as Element, DiagnosticSeverity, Diagnostic4 as Diagnostic, DefinitionListItem, DateItem, DataRequirements, DataProvider, DEFAULT_SETTINGS, ContainerType, ContainerData, CompiledTemplate, CollapsibleData, CodeBlockData2 as CodeBlockData, ClearFloat, AttributeMap, AsyncIncludeFetcher, AnchorTarget, Alignment, AlignType };
|