@wdprlib/parser 4.3.0 → 5.0.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 +26 -38
- package/dist/index.cjs +1035 -249
- package/dist/index.d.cts +203 -158
- package/dist/index.d.ts +203 -158
- package/dist/index.js +930 -139
- package/package.json +2 -2
- package/src/index.ts +13 -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/preprocess/expr/index.ts +26 -0
- package/src/parser/preprocess/utils/raw-regions.ts +16 -7
- 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 +4 -1
- package/src/parser/rules/block/module/listpages/index.ts +2 -0
- 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/listpages/selectors.ts +64 -0
- package/src/parser/rules/block/module/listpages/types/external-data.ts +22 -0
- 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 +172 -0
- package/src/pipeline/types.ts +63 -0
package/dist/index.d.ts
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
|
*
|
|
@@ -533,6 +674,8 @@ interface PageData {
|
|
|
533
674
|
ratingPercent?: number;
|
|
534
675
|
revisions: number;
|
|
535
676
|
}
|
|
677
|
+
type PageDataInput = Pick<PageData, "fullname" | "title" | "createdAt" | "updatedAt" | "tags"> & Partial<Omit<PageData, "fullname" | "title" | "createdAt" | "updatedAt" | "tags">>;
|
|
678
|
+
declare function definePageData(input: PageDataInput): PageData;
|
|
536
679
|
/**
|
|
537
680
|
* Site context information.
|
|
538
681
|
*/
|
|
@@ -688,116 +831,52 @@ interface VariableContext {
|
|
|
688
831
|
* Compiled template function.
|
|
689
832
|
*/
|
|
690
833
|
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;
|
|
834
|
+
interface ProcessWikitextCallbackContext<TPage extends WikitextPageContext> {
|
|
835
|
+
page: TPage;
|
|
836
|
+
settings: WikitextSettings3;
|
|
704
837
|
}
|
|
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. */
|
|
838
|
+
interface ProcessWikitextDataProvider<TPage extends WikitextPageContext> {
|
|
839
|
+
fetchInclude?: (pageRef: PageRef3, context: ProcessWikitextCallbackContext<TPage>) => Promise<string | null>;
|
|
840
|
+
fetchListPages?: (query: NormalizedListPagesQuery, requirement: ListPagesDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListPagesExternalData | null | undefined>;
|
|
841
|
+
fetchListUsers?: (requirement: ListUsersDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListUsersExternalData | null | undefined>;
|
|
842
|
+
fetchTagCloud?: (requirement: TagCloudDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<TagCloudExternalData | null | undefined>;
|
|
843
|
+
}
|
|
844
|
+
interface ProcessWikitextOptions<TPage extends WikitextPageContext> {
|
|
845
|
+
page: TPage;
|
|
736
846
|
settings?: WikitextSettings3;
|
|
847
|
+
dataProvider?: ProcessWikitextDataProvider<TPage>;
|
|
848
|
+
includeMaxIterations?: number;
|
|
737
849
|
}
|
|
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;
|
|
850
|
+
interface ProcessedWikitextDocument<TPage extends WikitextPageContext = WikitextPageContext> {
|
|
851
|
+
ast: SyntaxTree;
|
|
852
|
+
page: TPage;
|
|
853
|
+
settings: WikitextSettings3;
|
|
854
|
+
diagnostics: Diagnostic[];
|
|
855
|
+
dependencies: IncludeDependency[];
|
|
756
856
|
}
|
|
857
|
+
declare function processWikitext<TPage extends WikitextPageContext2>(source: string, options: ProcessWikitextOptions<TPage>): Promise<ProcessedWikitextDocument<TPage>>;
|
|
858
|
+
import { ParseResult as ParseResult3, SyntaxTree as SyntaxTree2 } from "@wdprlib/ast";
|
|
757
859
|
/**
|
|
758
|
-
*
|
|
860
|
+
* Parser function type for re-parsing substituted template output as wikitext.
|
|
759
861
|
*
|
|
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.
|
|
862
|
+
* Used by ListPages and ListUsers modules during the resolution phase. After
|
|
863
|
+
* template variables are substituted with actual data, the resulting string
|
|
864
|
+
* needs to be parsed as wikitext to produce AST elements.
|
|
771
865
|
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* produces the same source again; the resolver stops at that point.
|
|
866
|
+
* @param input - Wikitext string to parse
|
|
867
|
+
* @returns Object containing the parsed elements
|
|
775
868
|
*/
|
|
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
|
-
}
|
|
869
|
+
type ModuleParseResult = SyntaxTree2 | ParseResult3;
|
|
870
|
+
type ParseFunction = (input: string) => ModuleParseResult;
|
|
784
871
|
/**
|
|
785
|
-
*
|
|
872
|
+
* Callback to retrieve the current page's tags during the resolve phase.
|
|
786
873
|
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
874
|
+
* Called when evaluating `[[iftags]]` conditions. The application must provide
|
|
875
|
+
* this callback with access to the current page's tag list.
|
|
876
|
+
*
|
|
877
|
+
* @returns Array of tag names for the current page
|
|
790
878
|
*/
|
|
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
|
-
}
|
|
879
|
+
type IfTagsResolver = () => string[];
|
|
801
880
|
/**
|
|
802
881
|
* Callback bag for supplying external data during module resolution.
|
|
803
882
|
*
|
|
@@ -859,7 +938,7 @@ interface DataProvider {
|
|
|
859
938
|
*/
|
|
860
939
|
getPageTags?: IfTagsResolver;
|
|
861
940
|
}
|
|
862
|
-
import { SyntaxTree } from "@wdprlib/ast";
|
|
941
|
+
import { SyntaxTree as SyntaxTree3 } from "@wdprlib/ast";
|
|
863
942
|
/**
|
|
864
943
|
* Complete result of extracting data requirements from an AST.
|
|
865
944
|
*
|
|
@@ -889,7 +968,13 @@ interface ExtractionResult {
|
|
|
889
968
|
* @param ast - The parsed syntax tree to analyze
|
|
890
969
|
* @returns Extraction result containing requirements and compiled templates
|
|
891
970
|
*/
|
|
892
|
-
declare function extractDataRequirements(ast:
|
|
971
|
+
declare function extractDataRequirements(ast: SyntaxTree3): ExtractionResult;
|
|
972
|
+
type SelectorPage = Pick<PageData, "category" | "tags" | "hiddenTags">;
|
|
973
|
+
type CurrentPage = {
|
|
974
|
+
category: string;
|
|
975
|
+
tags: readonly string[];
|
|
976
|
+
};
|
|
977
|
+
declare function matchesListPagesSelectors(page: SelectorPage, query: Pick<NormalizedListPagesQuery, "category" | "tags">, currentPage: CurrentPage): boolean;
|
|
893
978
|
/**
|
|
894
979
|
* Compile a ListPages template string into an executable function.
|
|
895
980
|
*
|
|
@@ -954,48 +1039,6 @@ declare function normalizeQuery(query: ListPagesQuery): NormalizedListPagesQuery
|
|
|
954
1039
|
*/
|
|
955
1040
|
declare function preprocessIftags(source: string, pageTags: string[] | null): string;
|
|
956
1041
|
/**
|
|
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
1042
|
* Compile a ListUsers template string into an executable function.
|
|
1000
1043
|
*
|
|
1001
1044
|
* The template is split into alternating static strings and dynamic getter
|
|
@@ -1070,7 +1113,7 @@ declare function isTagCloudModule(module: Module4): module is TagCloudModuleData
|
|
|
1070
1113
|
* @returns Array of AST elements replacing the module node
|
|
1071
1114
|
*/
|
|
1072
1115
|
declare function resolveTagCloud(module: TagCloudModuleData, data: TagCloudExternalData): Element7[];
|
|
1073
|
-
import { SyntaxTree as
|
|
1116
|
+
import { Diagnostic as Diagnostic3, SyntaxTree as SyntaxTree4 } from "@wdprlib/ast";
|
|
1074
1117
|
/**
|
|
1075
1118
|
* Transform module-generated wikitext before it is parsed back into AST nodes.
|
|
1076
1119
|
*
|
|
@@ -1138,6 +1181,8 @@ interface ResolveOptions {
|
|
|
1138
1181
|
* state outside wdpr.
|
|
1139
1182
|
*/
|
|
1140
1183
|
transformModuleSource?: ModuleSourceTransform;
|
|
1184
|
+
/** Receives diagnostics emitted by ListPages/ListUsers secondary parses. */
|
|
1185
|
+
onDiagnostics?: (diagnostics: Diagnostic3[]) => void;
|
|
1141
1186
|
}
|
|
1142
1187
|
/**
|
|
1143
1188
|
* Resolve all modules in the AST
|
|
@@ -1153,6 +1198,6 @@ interface ResolveOptions {
|
|
|
1153
1198
|
* @param dataProvider - Callback provider to fetch data for each module
|
|
1154
1199
|
* @param options - Resolution options including requirements
|
|
1155
1200
|
*/
|
|
1156
|
-
declare function resolveModules(ast:
|
|
1201
|
+
declare function resolveModules(ast: SyntaxTree4, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree4>;
|
|
1157
1202
|
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,
|
|
1203
|
+
export { tokenize, text, resolveTagCloud, resolveModules, resolveListUsers, resolveIncludesWithTrace, resolveIncludesAsyncWithTrace, resolveIncludesAsync, resolveIncludes, processWikitext, preprocessIftags, parseTags, parseParent, parseOrder, parseNumericSelector, parseDateSelector, parseCategory, parse, paragraph, normalizeQuery, matchesListPagesSelectors, listItemSubList, listItemElements, list, link, lineBreak, italics, isTagCloudModule, isListUsersModule, horizontalRule, heading, extractListUsersVariables, extractIncludeReferences, extractDataRequirements, definePageData, 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 };
|