@wdprlib/parser 5.3.0 → 6.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/dist/index.cjs +2429 -1199
- package/dist/index.d.cts +95 -8
- package/dist/index.d.ts +95 -8
- package/dist/index.js +2385 -1152
- package/package.json +3 -2
- package/src/build-info.generated.ts +2 -2
- package/src/index.ts +3 -0
- package/src/lexer/lexer.ts +34 -5
- package/src/lexer/quoted-string.ts +4 -4
- package/src/lexer/syntax-actions.ts +6 -1
- package/src/lexer/text-actions.ts +15 -1
- package/src/lexer/url-schemes.ts +78 -0
- package/src/parser/constants.ts +4 -0
- package/src/parser/parse/block.ts +1 -1
- package/src/parser/postprocess/divAdjacentParagraph.ts +23 -21
- package/src/parser/postprocess/spanStrip/merge.ts +8 -2
- package/src/parser/preprocess/typography.ts +25 -3
- package/src/parser/preprocess/utils/raw-regions.ts +59 -14
- package/src/parser/preprocess/whitespace/index.ts +8 -1
- package/src/parser/rules/block/bibliography/entry-content.ts +1 -1
- package/src/parser/rules/block/block-list/bare-content.ts +3 -1
- package/src/parser/rules/block/block-list/bare-paragraph.ts +7 -2
- package/src/parser/rules/block/block-list/item-content.ts +7 -3
- package/src/parser/rules/block/block-list/li-content.ts +8 -3
- package/src/parser/rules/block/block-list/li-item.ts +1 -1
- package/src/parser/rules/block/blockquote/build.ts +1 -1
- package/src/parser/rules/block/code/boundary.ts +76 -0
- package/src/parser/rules/block/code/content.ts +11 -40
- package/src/parser/rules/block/code/index.ts +8 -31
- package/src/parser/rules/block/code/open.ts +46 -0
- package/src/parser/rules/block/definition-list/item-key.ts +1 -1
- package/src/parser/rules/block/definition-list/item-value.ts +1 -1
- package/src/parser/rules/block/div/failed.ts +2 -0
- package/src/parser/rules/block/index.ts +3 -0
- package/src/parser/rules/block/list/line.ts +6 -3
- package/src/parser/rules/block/math/boundary.ts +104 -0
- package/src/parser/rules/block/math/index.ts +17 -57
- package/src/parser/rules/block/module/index.ts +3 -2
- package/src/parser/rules/block/module/listpages/extraction/listpages.ts +5 -0
- package/src/parser/rules/block/module/listpages/extraction/query.ts +1 -0
- package/src/parser/rules/block/module/listpages/extraction/template.ts +16 -0
- package/src/parser/rules/block/module/listpages/extraction/variables.ts +1 -0
- package/src/parser/rules/block/module/listpages/index.ts +1 -0
- package/src/parser/rules/block/module/listpages/normalization/order-parent.ts +9 -1
- package/src/parser/rules/block/module/listpages/normalize.ts +1 -0
- package/src/parser/rules/block/module/listpages/parser.ts +1 -0
- package/src/parser/rules/block/module/listpages/resolve.ts +4 -2
- package/src/parser/rules/block/module/listpages/template/excerpt.ts +63 -0
- package/src/parser/rules/block/module/listpages/template/format/content.ts +0 -32
- package/src/parser/rules/block/module/listpages/template/format/index.ts +1 -1
- package/src/parser/rules/block/module/listpages/template/getters/index.ts +14 -0
- package/src/parser/rules/block/module/listpages/template/getters/parameterized.ts +3 -1
- package/src/parser/rules/block/module/listpages/template/getters/registered.ts +52 -0
- package/src/parser/rules/block/module/listpages/template/getters/simple.ts +15 -5
- package/src/parser/rules/block/module/listpages/template/literal.ts +6 -0
- package/src/parser/rules/block/module/listpages/template/syntax.ts +10 -1
- package/src/parser/rules/block/module/listpages/types/data-requirements.ts +6 -0
- package/src/parser/rules/block/module/listpages/types/external-data.ts +36 -2
- package/src/parser/rules/block/module/listpages/types/normalized-query.ts +14 -4
- package/src/parser/rules/block/module/listpages/types/query.ts +2 -0
- package/src/parser/rules/block/module/listpages/types/variables.ts +5 -0
- package/src/parser/rules/block/module/listpages/url-resolution/fields.ts +2 -0
- package/src/parser/rules/block/module/listusers/resolve.ts +2 -1
- package/src/parser/rules/block/module/mapping.ts +2 -1
- package/src/parser/rules/block/module/rate/index.ts +16 -19
- package/src/parser/rules/block/module/rate/resolve.ts +108 -0
- package/src/parser/rules/block/module/rate/types.ts +6 -16
- package/src/parser/rules/block/module/resolution/resolve-async.ts +2 -1
- package/src/parser/rules/block/module/resolve.ts +10 -8
- package/src/parser/rules/block/module/types-common.ts +4 -0
- package/src/parser/rules/block/note/boundary.ts +88 -0
- package/src/parser/rules/block/note/index.ts +37 -0
- package/src/parser/rules/block/paragraph/index.ts +12 -4
- package/src/parser/rules/block/paragraph/normalize.ts +6 -1
- package/src/parser/rules/block/parsing/block-item.ts +1 -1
- package/src/parser/rules/block/parsing/content.ts +1 -1
- package/src/parser/rules/block/parsing/inline-content.ts +6 -3
- package/src/parser/rules/block/table/pipe/cell.ts +3 -1
- package/src/parser/rules/block/table-block/cell-content/index.ts +1 -1
- package/src/parser/rules/block/table-block/cell-content/segments.ts +5 -2
- package/src/parser/rules/block/table-block/cell-newline.ts +2 -1
- package/src/parser/rules/contracts/rule.ts +4 -2
- package/src/parser/rules/contracts/scope.ts +2 -0
- package/src/parser/rules/inline/anchor/child.ts +8 -2
- package/src/parser/rules/inline/anchor/content.ts +3 -1
- package/src/parser/rules/inline/anchor/index.ts +4 -1
- package/src/parser/rules/inline/anchor/newline.ts +2 -1
- package/src/parser/rules/inline/autolink.ts +153 -0
- package/src/parser/rules/inline/button/attributes.ts +17 -0
- package/src/parser/rules/inline/button/index.ts +17 -0
- package/src/parser/rules/inline/button/syntax.ts +56 -0
- package/src/parser/rules/inline/date/index.ts +17 -0
- package/src/parser/rules/inline/date/syntax.ts +46 -0
- package/src/parser/rules/inline/email/candidates.ts +134 -0
- package/src/parser/rules/inline/email/index.ts +36 -0
- package/src/parser/rules/inline/email/scan.ts +76 -0
- package/src/parser/rules/inline/expr/branch.ts +3 -1
- package/src/parser/rules/inline/footnote/boundary.ts +56 -0
- package/src/parser/rules/inline/footnote/content.ts +29 -41
- package/src/parser/rules/inline/footnote/elements.ts +9 -34
- package/src/parser/rules/inline/footnote/index.ts +4 -1
- package/src/parser/rules/inline/formatting/close.ts +12 -0
- package/src/parser/rules/inline/index.ts +14 -0
- package/src/parser/rules/inline/line-break/newline.ts +8 -1
- package/src/parser/rules/inline/link-bracket/direct-url.ts +11 -3
- package/src/parser/rules/inline/link-bracket/parsed.ts +9 -4
- package/src/parser/rules/inline/link-bracket/parts.ts +14 -36
- package/src/parser/rules/inline/link-bracket/special-target.ts +9 -0
- package/src/parser/rules/inline/link-single.ts +9 -7
- package/src/parser/rules/inline/link-triple/index.ts +1 -0
- package/src/parser/rules/inline/link-triple/label.ts +7 -1
- package/src/parser/rules/inline/parsing/automatic-line-break.ts +35 -0
- package/src/parser/rules/inline/parsing/block-boundary.ts +2 -0
- package/src/parser/rules/inline/parsing/block-start-predicates.ts +10 -0
- package/src/parser/rules/inline/parsing/inline-content.ts +46 -7
- package/src/parser/rules/inline/parsing/plain-text.ts +7 -2
- package/src/parser/rules/inline/parsing/preserved-line-break.ts +13 -0
- package/src/parser/rules/inline/parsing/raw-tag.ts +19 -0
- package/src/parser/rules/inline/raw/angle.ts +2 -1
- package/src/parser/rules/inline/raw/end.ts +21 -1
- package/src/parser/rules/inline/size/content.ts +32 -5
- package/src/parser/rules/inline/size/value.ts +11 -0
- package/src/parser/rules/inline/social/index.ts +17 -0
- package/src/parser/rules/inline/social/syntax.ts +40 -0
- package/src/parser/rules/inline/span/content.ts +3 -1
- package/src/parser/rules/inline/span/newline.ts +2 -1
- package/src/parser/rules/opaque-probe.ts +58 -0
- package/src/pipeline/process.ts +13 -0
- package/src/pipeline/types.ts +19 -0
- package/src/parser/rules/block/math/content.ts +0 -54
- package/src/parser/rules/block/math/name.ts +0 -35
- package/src/parser/rules/inline/footnote/child.ts +0 -22
- package/src/parser/rules/inline/footnote/newline.ts +0 -27
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ declare const buildInfo: Readonly<{
|
|
|
4
4
|
sha: string | null;
|
|
5
5
|
dirty: boolean | null;
|
|
6
6
|
}>;
|
|
7
|
+
import { RatingRef as RatingRef3, RatingVote, RatingAggregate as RatingAggregate2, RatingState as RatingState3 } from "@wdprlib/ast";
|
|
7
8
|
import { Position as Position2, Point, Version as Version2, Element as Element8, SyntaxTree as SyntaxTree5, ContainerType, ContainerData, AttributeMap, VariableMap, Alignment, LinkType, LinkLocation, LinkLabel, PageRef as PageRef7, 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";
|
|
8
9
|
import { createPoint, createPosition, text, container, paragraph, bold, italics, heading, lineBreak, horizontalRule, link, list, listItemElements, listItemSubList } from "@wdprlib/ast";
|
|
9
10
|
import { WikitextMode, WikitextSettings as WikitextSettings5 } from "@wdprlib/ast";
|
|
@@ -103,6 +104,8 @@ declare class Lexer {
|
|
|
103
104
|
* consume content up to the next `"` or newline.
|
|
104
105
|
*/
|
|
105
106
|
private blockOpenerDepth;
|
|
107
|
+
private rawTagBounds;
|
|
108
|
+
private rawClosesExhausted;
|
|
106
109
|
constructor(source: string, options?: LexerOptions);
|
|
107
110
|
/**
|
|
108
111
|
* Tokenize the entire source
|
|
@@ -234,7 +237,7 @@ declare class Parser {
|
|
|
234
237
|
*/
|
|
235
238
|
declare function parse(source: string, options?: ParserOptions): ParseResult2;
|
|
236
239
|
import { WikitextPageContext as WikitextPageContext2 } from "@wdprlib/ast";
|
|
237
|
-
import { Diagnostic, PageRef as PageRef5, SyntaxTree, WikitextPageContext, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
240
|
+
import { Diagnostic, PageRef as PageRef5, SyntaxTree, WikitextPageContext, WikitextSettings as WikitextSettings3, RatingRef, RatingState, ReadableTextOptions } from "@wdprlib/ast";
|
|
238
241
|
import { PageRef as PageRef4, WikitextSettings as WikitextSettings2 } from "@wdprlib/ast";
|
|
239
242
|
interface IncludeAssignment {
|
|
240
243
|
key: string;
|
|
@@ -410,6 +413,8 @@ interface ListPagesQuery {
|
|
|
410
413
|
createdBy?: string;
|
|
411
414
|
/** Rating selector. @untrusted User input. */
|
|
412
415
|
rating?: string;
|
|
416
|
+
/** Exact registered custom key for rating/votes filters and order; omitted means main. */
|
|
417
|
+
ratingAxis?: string;
|
|
413
418
|
/** Votes selector. @untrusted User input. */
|
|
414
419
|
votes?: string;
|
|
415
420
|
/** Page name selector. @untrusted User input. */
|
|
@@ -434,7 +439,7 @@ interface ListPagesQuery {
|
|
|
434
439
|
/**
|
|
435
440
|
* All supported ListPages template variables.
|
|
436
441
|
*/
|
|
437
|
-
type ListPagesVariable = "created_at" | "created_by" | "created_by_unix" | "created_by_id" | "created_by_linked" | "updated_at" | "updated_by" | "updated_by_unix" | "updated_by_id" | "updated_by_linked" | "commented_at" | "commented_by" | "commented_by_unix" | "commented_by_id" | "commented_by_linked" | "name" | "category" | "fullname" | "title" | "title_linked" | "link" | "parent_name" | "parent_category" | "parent_fullname" | "parent_title" | "parent_title_linked" | "content" | "content_n" | "preview" | "preview_n" | "summary" | "first_paragraph" | "tags" | "tags_linked" | "_tags" | "_tags_linked" | "form_data" | "form_raw" | "form_label" | "form_hint" | "children" | "comments" | "size" | "rating" | "rating_votes" | "rating_percent" | "revisions" | "index" | "total" | "limit" | "total_or_limit" | "site_title" | "site_name" | "site_domain";
|
|
442
|
+
type ListPagesVariable = "metadata" | "customrate" | "customrate_votes" | "customrate_percent" | "created_at" | "created_by" | "created_by_unix" | "created_by_id" | "created_by_linked" | "updated_at" | "updated_by" | "updated_by_unix" | "updated_by_id" | "updated_by_linked" | "commented_at" | "commented_by" | "commented_by_unix" | "commented_by_id" | "commented_by_linked" | "name" | "category" | "fullname" | "title" | "title_linked" | "link" | "parent_name" | "parent_category" | "parent_fullname" | "parent_title" | "parent_title_linked" | "content" | "content_n" | "preview" | "preview_n" | "excerpt" | "summary" | "first_paragraph" | "tags" | "tags_linked" | "_tags" | "_tags_linked" | "form_data" | "form_raw" | "form_label" | "form_hint" | "children" | "comments" | "size" | "rating" | "rating_votes" | "rating_percent" | "revisions" | "index" | "total" | "limit" | "total_or_limit" | "site_title" | "site_name" | "site_domain";
|
|
438
443
|
/**
|
|
439
444
|
*
|
|
440
445
|
* Type definitions for the ListUsers module.
|
|
@@ -612,6 +617,12 @@ interface ListPagesDataRequirement {
|
|
|
612
617
|
previewLengths?: number[];
|
|
613
618
|
/** Field names needed for form_data{field} etc. */
|
|
614
619
|
formFields?: string[];
|
|
620
|
+
/** Exact metadata keys used by display templates. Also validate query.order on the host. */
|
|
621
|
+
metadataKeys?: string[];
|
|
622
|
+
/** Exact custom rating keys needed for display, independent of query.ratingAxis. */
|
|
623
|
+
customRateKeys?: string[];
|
|
624
|
+
/** Supply PageData.readableText and firstParagraph for previews, excerpts, and summaries. */
|
|
625
|
+
needsReadableText?: boolean;
|
|
615
626
|
/** Prefix for tags_linked|prefix */
|
|
616
627
|
tagsLinkPrefix?: string;
|
|
617
628
|
/** Prefix for _tags_linked|prefix */
|
|
@@ -635,6 +646,21 @@ interface DataRequirements {
|
|
|
635
646
|
listUsers: ListUsersDataRequirement[];
|
|
636
647
|
tagCloud: TagCloudDataRequirement[];
|
|
637
648
|
}
|
|
649
|
+
import { RatingAggregate } from "@wdprlib/ast";
|
|
650
|
+
/** Values for host-registered metadata keys. Missing entries remain unavailable. */
|
|
651
|
+
type PageMetadataValue = {
|
|
652
|
+
type: "text";
|
|
653
|
+
value: string;
|
|
654
|
+
} | {
|
|
655
|
+
type: "number";
|
|
656
|
+
value: number;
|
|
657
|
+
} | {
|
|
658
|
+
type: "date";
|
|
659
|
+
value: Date;
|
|
660
|
+
} | {
|
|
661
|
+
type: "user";
|
|
662
|
+
value: UserInfo;
|
|
663
|
+
};
|
|
638
664
|
/**
|
|
639
665
|
* User information.
|
|
640
666
|
*/
|
|
@@ -647,6 +673,18 @@ interface UserInfo {
|
|
|
647
673
|
* Page data provided by an external source.
|
|
648
674
|
*/
|
|
649
675
|
interface PageData {
|
|
676
|
+
/**
|
|
677
|
+
* `%%metadata{key}%%`: only registered, readable entries; keys are case-sensitive.
|
|
678
|
+
* Values are literal text. Date values accept strftime; user format is name, |id or |unix.
|
|
679
|
+
* Tag change date/editor may be host-defined keys; WDPR reserves no such keys.
|
|
680
|
+
*/
|
|
681
|
+
metadata?: Readonly<Record<string, PageMetadataValue | null>>;
|
|
682
|
+
/**
|
|
683
|
+
* `%%customrate{key}%%`, `%%customrate_votes{key}%%`, `%%customrate_percent{key}%%`.
|
|
684
|
+
* Supply readable aggregates for requirement.customRateKeys, just as formFields selects
|
|
685
|
+
* form data. Missing keys expand to empty text; a supplied zero remains zero.
|
|
686
|
+
*/
|
|
687
|
+
customRates?: Readonly<Record<string, RatingAggregate | null>>;
|
|
650
688
|
name: string;
|
|
651
689
|
category: string;
|
|
652
690
|
fullname: string;
|
|
@@ -662,6 +700,19 @@ interface PageData {
|
|
|
662
700
|
parentFullname?: string;
|
|
663
701
|
parentTitle?: string;
|
|
664
702
|
content?: string;
|
|
703
|
+
/**
|
|
704
|
+
* Text extracted from this page's resolved AST for preview and
|
|
705
|
+
* `%%excerpt{pattern="..." group="1" match="2" max="200"}%%`.
|
|
706
|
+
* Values stay literal; raw content is never a fallback.
|
|
707
|
+
* The host owns extraction policy, dependency invalidation and recursion limits.
|
|
708
|
+
*/
|
|
709
|
+
readableText?: string;
|
|
710
|
+
/**
|
|
711
|
+
* First nonempty paragraph from extractFirstParagraph, for summary and first_paragraph.
|
|
712
|
+
* Uses the same extraction policy as readableText. Empty when no readable paragraph
|
|
713
|
+
* exists; undefined when unavailable. Headings and appended footnotes are excluded.
|
|
714
|
+
*/
|
|
715
|
+
firstParagraph?: string;
|
|
665
716
|
tags: string[];
|
|
666
717
|
hiddenTags: string[];
|
|
667
718
|
formData?: Record<string, string>;
|
|
@@ -670,7 +721,8 @@ interface PageData {
|
|
|
670
721
|
formHint?: Record<string, string>;
|
|
671
722
|
children: number;
|
|
672
723
|
comments: number;
|
|
673
|
-
|
|
724
|
+
/** Materialized readable character count, computed with countCharacters. */
|
|
725
|
+
size?: number;
|
|
674
726
|
rating: number;
|
|
675
727
|
ratingVotes: number;
|
|
676
728
|
ratingPercent?: number;
|
|
@@ -736,18 +788,25 @@ interface NormalizedCategory {
|
|
|
736
788
|
/**
|
|
737
789
|
* Order field options.
|
|
738
790
|
*/
|
|
739
|
-
type OrderField = "created_at" | "updated_at" | "title" | "fullname" | "rating" | "votes" | "revisions" | "comments" | "size" | "random";
|
|
791
|
+
type OrderField = "created_at" | "updated_at" | "commented_at" | "metadata" | "title" | "fullname" | "rating" | "votes" | "revisions" | "comments" | "size" | "random";
|
|
740
792
|
/**
|
|
741
793
|
* Order direction.
|
|
742
794
|
*/
|
|
743
795
|
type OrderDirection = "asc" | "desc";
|
|
744
796
|
/**
|
|
745
797
|
* Normalized order specification.
|
|
798
|
+
* Providers validate metadata registration, readability and sortability without falling back
|
|
799
|
+
* to another field. Sort before pagination with a stable page ID tie-breaker. For commented_at,
|
|
800
|
+
* put pages without comments last and use the same visible, non-deleted comments as the count.
|
|
746
801
|
*/
|
|
747
|
-
|
|
748
|
-
field: OrderField
|
|
802
|
+
type NormalizedOrder = {
|
|
803
|
+
field: Exclude<OrderField, "metadata">;
|
|
749
804
|
direction: OrderDirection;
|
|
750
|
-
}
|
|
805
|
+
} | {
|
|
806
|
+
field: "metadata";
|
|
807
|
+
key: string;
|
|
808
|
+
direction: OrderDirection;
|
|
809
|
+
};
|
|
751
810
|
/**
|
|
752
811
|
* Normalized parent selector.
|
|
753
812
|
*/
|
|
@@ -813,6 +872,12 @@ interface NormalizedListPagesQuery {
|
|
|
813
872
|
updatedAt?: NormalizedDateSelector;
|
|
814
873
|
createdBy?: string;
|
|
815
874
|
rating?: NormalizedNumericSelector;
|
|
875
|
+
/**
|
|
876
|
+
* `rating-axis` selects the custom aggregate for rating/votes filters and order; omission
|
|
877
|
+
* selects main. Verify registration and read access before filtering, counting or sorting.
|
|
878
|
+
* Unknown keys must not fall back to main. Display variables select their own keys.
|
|
879
|
+
*/
|
|
880
|
+
ratingAxis?: string;
|
|
816
881
|
votes?: NormalizedNumericSelector;
|
|
817
882
|
name?: string;
|
|
818
883
|
fullname?: string;
|
|
@@ -851,6 +916,14 @@ interface ProcessWikitextCallbackContext<TPage extends WikitextPageContext> {
|
|
|
851
916
|
settings: WikitextSettings3;
|
|
852
917
|
}
|
|
853
918
|
interface ProcessWikitextDataProvider<TPage extends WikitextPageContext> {
|
|
919
|
+
/**
|
|
920
|
+
* Read only authorized, registered ratings in context.page, including declarations
|
|
921
|
+
* from its includes. Keys match exactly. Omit no-rate and inaccessible references.
|
|
922
|
+
* Main category policy and custom policies are independent. Votes belong to page + ref.
|
|
923
|
+
* ListPages/ListUsers output cannot declare ratings, including its nested includes.
|
|
924
|
+
* The host owns registration, aggregation and invalidation when included declarations change.
|
|
925
|
+
*/
|
|
926
|
+
fetchRatings?: (refs: readonly RatingRef[], context: ProcessWikitextCallbackContext<TPage>) => Promise<readonly RatingState[]>;
|
|
854
927
|
fetchInclude?: (pageRef: PageRef5, context: ProcessWikitextCallbackContext<TPage>) => Promise<string | null>;
|
|
855
928
|
fetchListPages?: (query: NormalizedListPagesQuery, requirement: ListPagesDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListPagesExternalData | null | undefined>;
|
|
856
929
|
fetchListUsers?: (requirement: ListUsersDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListUsersExternalData | null | undefined>;
|
|
@@ -861,9 +934,14 @@ interface ProcessWikitextOptions<TPage extends WikitextPageContext> {
|
|
|
861
934
|
settings?: WikitextSettings3;
|
|
862
935
|
dataProvider?: ProcessWikitextDataProvider<TPage>;
|
|
863
936
|
includeMaxIterations?: number;
|
|
937
|
+
readableText?: ReadableTextOptions;
|
|
864
938
|
}
|
|
865
939
|
interface ProcessedWikitextDocument<TPage extends WikitextPageContext = WikitextPageContext> {
|
|
866
940
|
ast: SyntaxTree;
|
|
941
|
+
readableText: string;
|
|
942
|
+
/** First nonempty body paragraph, excluding headings and appended footnotes. */
|
|
943
|
+
firstParagraph: string;
|
|
944
|
+
characterCount: number;
|
|
867
945
|
page: TPage;
|
|
868
946
|
settings: WikitextSettings3;
|
|
869
947
|
diagnostics: Diagnostic[];
|
|
@@ -883,6 +961,13 @@ import { ParseResult as ParseResult3, SyntaxTree as SyntaxTree2 } from "@wdprlib
|
|
|
883
961
|
*/
|
|
884
962
|
type ModuleParseResult = SyntaxTree2 | ParseResult3;
|
|
885
963
|
type ParseFunction = (input: string) => ModuleParseResult;
|
|
964
|
+
import { RatingRef as RatingRef2, RatingState as RatingState2 } from "@wdprlib/ast";
|
|
965
|
+
/**
|
|
966
|
+
* Read authorized ratings for the displayed page. Omit unknown, disabled, or
|
|
967
|
+
* inaccessible references. The host owns registration, category policies,
|
|
968
|
+
* access checks, aggregates, and persistence; rendering must never create data.
|
|
969
|
+
*/
|
|
970
|
+
type RatingsFetcher = (refs: readonly RatingRef2[]) => Promise<readonly RatingState2[]>;
|
|
886
971
|
/**
|
|
887
972
|
* Callback to retrieve the current page's tags during the resolve phase.
|
|
888
973
|
*
|
|
@@ -903,6 +988,8 @@ type IfTagsResolver = () => string[];
|
|
|
903
988
|
* @group Module Resolution
|
|
904
989
|
*/
|
|
905
990
|
interface DataProvider {
|
|
991
|
+
/** Read registered ratings for the displayed page; omitted references stay hidden. */
|
|
992
|
+
fetchRatings?: RatingsFetcher;
|
|
906
993
|
/**
|
|
907
994
|
* Fetch page data for `[[module ListPages]]` expansion.
|
|
908
995
|
*
|
|
@@ -1215,4 +1302,4 @@ interface ResolveOptions {
|
|
|
1215
1302
|
*/
|
|
1216
1303
|
declare function resolveModules(ast: SyntaxTree4, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree4>;
|
|
1217
1304
|
import { STYLE_SLOT_PREFIX } from "@wdprlib/ast";
|
|
1218
|
-
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, buildInfo, 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, PageRef7 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 };
|
|
1305
|
+
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, buildInfo, 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, RatingsFetcher, RatingVote, RatingState3 as RatingState, RatingRef3 as RatingRef, RatingAggregate2 as RatingAggregate, ProcessedWikitextDocument, ProcessWikitextOptions, ProcessWikitextDataProvider, ProcessWikitextCallbackContext, Position2 as Position, Point, ParserOptions, Parser, ParseResult4 as ParseResult, ParseFunction, PageRef7 as PageRef, PageMetadataValue, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare const buildInfo: Readonly<{
|
|
|
4
4
|
sha: string | null;
|
|
5
5
|
dirty: boolean | null;
|
|
6
6
|
}>;
|
|
7
|
+
import { RatingRef as RatingRef3, RatingVote, RatingAggregate as RatingAggregate2, RatingState as RatingState3 } from "@wdprlib/ast";
|
|
7
8
|
import { Position as Position2, Point, Version as Version2, Element as Element8, SyntaxTree as SyntaxTree5, ContainerType, ContainerData, AttributeMap, VariableMap, Alignment, LinkType, LinkLocation, LinkLabel, PageRef as PageRef7, 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";
|
|
8
9
|
import { createPoint, createPosition, text, container, paragraph, bold, italics, heading, lineBreak, horizontalRule, link, list, listItemElements, listItemSubList } from "@wdprlib/ast";
|
|
9
10
|
import { WikitextMode, WikitextSettings as WikitextSettings5 } from "@wdprlib/ast";
|
|
@@ -103,6 +104,8 @@ declare class Lexer {
|
|
|
103
104
|
* consume content up to the next `"` or newline.
|
|
104
105
|
*/
|
|
105
106
|
private blockOpenerDepth;
|
|
107
|
+
private rawTagBounds;
|
|
108
|
+
private rawClosesExhausted;
|
|
106
109
|
constructor(source: string, options?: LexerOptions);
|
|
107
110
|
/**
|
|
108
111
|
* Tokenize the entire source
|
|
@@ -234,7 +237,7 @@ declare class Parser {
|
|
|
234
237
|
*/
|
|
235
238
|
declare function parse(source: string, options?: ParserOptions): ParseResult2;
|
|
236
239
|
import { WikitextPageContext as WikitextPageContext2 } from "@wdprlib/ast";
|
|
237
|
-
import { Diagnostic, PageRef as PageRef5, SyntaxTree, WikitextPageContext, WikitextSettings as WikitextSettings3 } from "@wdprlib/ast";
|
|
240
|
+
import { Diagnostic, PageRef as PageRef5, SyntaxTree, WikitextPageContext, WikitextSettings as WikitextSettings3, RatingRef, RatingState, ReadableTextOptions } from "@wdprlib/ast";
|
|
238
241
|
import { PageRef as PageRef4, WikitextSettings as WikitextSettings2 } from "@wdprlib/ast";
|
|
239
242
|
interface IncludeAssignment {
|
|
240
243
|
key: string;
|
|
@@ -410,6 +413,8 @@ interface ListPagesQuery {
|
|
|
410
413
|
createdBy?: string;
|
|
411
414
|
/** Rating selector. @untrusted User input. */
|
|
412
415
|
rating?: string;
|
|
416
|
+
/** Exact registered custom key for rating/votes filters and order; omitted means main. */
|
|
417
|
+
ratingAxis?: string;
|
|
413
418
|
/** Votes selector. @untrusted User input. */
|
|
414
419
|
votes?: string;
|
|
415
420
|
/** Page name selector. @untrusted User input. */
|
|
@@ -434,7 +439,7 @@ interface ListPagesQuery {
|
|
|
434
439
|
/**
|
|
435
440
|
* All supported ListPages template variables.
|
|
436
441
|
*/
|
|
437
|
-
type ListPagesVariable = "created_at" | "created_by" | "created_by_unix" | "created_by_id" | "created_by_linked" | "updated_at" | "updated_by" | "updated_by_unix" | "updated_by_id" | "updated_by_linked" | "commented_at" | "commented_by" | "commented_by_unix" | "commented_by_id" | "commented_by_linked" | "name" | "category" | "fullname" | "title" | "title_linked" | "link" | "parent_name" | "parent_category" | "parent_fullname" | "parent_title" | "parent_title_linked" | "content" | "content_n" | "preview" | "preview_n" | "summary" | "first_paragraph" | "tags" | "tags_linked" | "_tags" | "_tags_linked" | "form_data" | "form_raw" | "form_label" | "form_hint" | "children" | "comments" | "size" | "rating" | "rating_votes" | "rating_percent" | "revisions" | "index" | "total" | "limit" | "total_or_limit" | "site_title" | "site_name" | "site_domain";
|
|
442
|
+
type ListPagesVariable = "metadata" | "customrate" | "customrate_votes" | "customrate_percent" | "created_at" | "created_by" | "created_by_unix" | "created_by_id" | "created_by_linked" | "updated_at" | "updated_by" | "updated_by_unix" | "updated_by_id" | "updated_by_linked" | "commented_at" | "commented_by" | "commented_by_unix" | "commented_by_id" | "commented_by_linked" | "name" | "category" | "fullname" | "title" | "title_linked" | "link" | "parent_name" | "parent_category" | "parent_fullname" | "parent_title" | "parent_title_linked" | "content" | "content_n" | "preview" | "preview_n" | "excerpt" | "summary" | "first_paragraph" | "tags" | "tags_linked" | "_tags" | "_tags_linked" | "form_data" | "form_raw" | "form_label" | "form_hint" | "children" | "comments" | "size" | "rating" | "rating_votes" | "rating_percent" | "revisions" | "index" | "total" | "limit" | "total_or_limit" | "site_title" | "site_name" | "site_domain";
|
|
438
443
|
/**
|
|
439
444
|
*
|
|
440
445
|
* Type definitions for the ListUsers module.
|
|
@@ -612,6 +617,12 @@ interface ListPagesDataRequirement {
|
|
|
612
617
|
previewLengths?: number[];
|
|
613
618
|
/** Field names needed for form_data{field} etc. */
|
|
614
619
|
formFields?: string[];
|
|
620
|
+
/** Exact metadata keys used by display templates. Also validate query.order on the host. */
|
|
621
|
+
metadataKeys?: string[];
|
|
622
|
+
/** Exact custom rating keys needed for display, independent of query.ratingAxis. */
|
|
623
|
+
customRateKeys?: string[];
|
|
624
|
+
/** Supply PageData.readableText and firstParagraph for previews, excerpts, and summaries. */
|
|
625
|
+
needsReadableText?: boolean;
|
|
615
626
|
/** Prefix for tags_linked|prefix */
|
|
616
627
|
tagsLinkPrefix?: string;
|
|
617
628
|
/** Prefix for _tags_linked|prefix */
|
|
@@ -635,6 +646,21 @@ interface DataRequirements {
|
|
|
635
646
|
listUsers: ListUsersDataRequirement[];
|
|
636
647
|
tagCloud: TagCloudDataRequirement[];
|
|
637
648
|
}
|
|
649
|
+
import { RatingAggregate } from "@wdprlib/ast";
|
|
650
|
+
/** Values for host-registered metadata keys. Missing entries remain unavailable. */
|
|
651
|
+
type PageMetadataValue = {
|
|
652
|
+
type: "text";
|
|
653
|
+
value: string;
|
|
654
|
+
} | {
|
|
655
|
+
type: "number";
|
|
656
|
+
value: number;
|
|
657
|
+
} | {
|
|
658
|
+
type: "date";
|
|
659
|
+
value: Date;
|
|
660
|
+
} | {
|
|
661
|
+
type: "user";
|
|
662
|
+
value: UserInfo;
|
|
663
|
+
};
|
|
638
664
|
/**
|
|
639
665
|
* User information.
|
|
640
666
|
*/
|
|
@@ -647,6 +673,18 @@ interface UserInfo {
|
|
|
647
673
|
* Page data provided by an external source.
|
|
648
674
|
*/
|
|
649
675
|
interface PageData {
|
|
676
|
+
/**
|
|
677
|
+
* `%%metadata{key}%%`: only registered, readable entries; keys are case-sensitive.
|
|
678
|
+
* Values are literal text. Date values accept strftime; user format is name, |id or |unix.
|
|
679
|
+
* Tag change date/editor may be host-defined keys; WDPR reserves no such keys.
|
|
680
|
+
*/
|
|
681
|
+
metadata?: Readonly<Record<string, PageMetadataValue | null>>;
|
|
682
|
+
/**
|
|
683
|
+
* `%%customrate{key}%%`, `%%customrate_votes{key}%%`, `%%customrate_percent{key}%%`.
|
|
684
|
+
* Supply readable aggregates for requirement.customRateKeys, just as formFields selects
|
|
685
|
+
* form data. Missing keys expand to empty text; a supplied zero remains zero.
|
|
686
|
+
*/
|
|
687
|
+
customRates?: Readonly<Record<string, RatingAggregate | null>>;
|
|
650
688
|
name: string;
|
|
651
689
|
category: string;
|
|
652
690
|
fullname: string;
|
|
@@ -662,6 +700,19 @@ interface PageData {
|
|
|
662
700
|
parentFullname?: string;
|
|
663
701
|
parentTitle?: string;
|
|
664
702
|
content?: string;
|
|
703
|
+
/**
|
|
704
|
+
* Text extracted from this page's resolved AST for preview and
|
|
705
|
+
* `%%excerpt{pattern="..." group="1" match="2" max="200"}%%`.
|
|
706
|
+
* Values stay literal; raw content is never a fallback.
|
|
707
|
+
* The host owns extraction policy, dependency invalidation and recursion limits.
|
|
708
|
+
*/
|
|
709
|
+
readableText?: string;
|
|
710
|
+
/**
|
|
711
|
+
* First nonempty paragraph from extractFirstParagraph, for summary and first_paragraph.
|
|
712
|
+
* Uses the same extraction policy as readableText. Empty when no readable paragraph
|
|
713
|
+
* exists; undefined when unavailable. Headings and appended footnotes are excluded.
|
|
714
|
+
*/
|
|
715
|
+
firstParagraph?: string;
|
|
665
716
|
tags: string[];
|
|
666
717
|
hiddenTags: string[];
|
|
667
718
|
formData?: Record<string, string>;
|
|
@@ -670,7 +721,8 @@ interface PageData {
|
|
|
670
721
|
formHint?: Record<string, string>;
|
|
671
722
|
children: number;
|
|
672
723
|
comments: number;
|
|
673
|
-
|
|
724
|
+
/** Materialized readable character count, computed with countCharacters. */
|
|
725
|
+
size?: number;
|
|
674
726
|
rating: number;
|
|
675
727
|
ratingVotes: number;
|
|
676
728
|
ratingPercent?: number;
|
|
@@ -736,18 +788,25 @@ interface NormalizedCategory {
|
|
|
736
788
|
/**
|
|
737
789
|
* Order field options.
|
|
738
790
|
*/
|
|
739
|
-
type OrderField = "created_at" | "updated_at" | "title" | "fullname" | "rating" | "votes" | "revisions" | "comments" | "size" | "random";
|
|
791
|
+
type OrderField = "created_at" | "updated_at" | "commented_at" | "metadata" | "title" | "fullname" | "rating" | "votes" | "revisions" | "comments" | "size" | "random";
|
|
740
792
|
/**
|
|
741
793
|
* Order direction.
|
|
742
794
|
*/
|
|
743
795
|
type OrderDirection = "asc" | "desc";
|
|
744
796
|
/**
|
|
745
797
|
* Normalized order specification.
|
|
798
|
+
* Providers validate metadata registration, readability and sortability without falling back
|
|
799
|
+
* to another field. Sort before pagination with a stable page ID tie-breaker. For commented_at,
|
|
800
|
+
* put pages without comments last and use the same visible, non-deleted comments as the count.
|
|
746
801
|
*/
|
|
747
|
-
|
|
748
|
-
field: OrderField
|
|
802
|
+
type NormalizedOrder = {
|
|
803
|
+
field: Exclude<OrderField, "metadata">;
|
|
749
804
|
direction: OrderDirection;
|
|
750
|
-
}
|
|
805
|
+
} | {
|
|
806
|
+
field: "metadata";
|
|
807
|
+
key: string;
|
|
808
|
+
direction: OrderDirection;
|
|
809
|
+
};
|
|
751
810
|
/**
|
|
752
811
|
* Normalized parent selector.
|
|
753
812
|
*/
|
|
@@ -813,6 +872,12 @@ interface NormalizedListPagesQuery {
|
|
|
813
872
|
updatedAt?: NormalizedDateSelector;
|
|
814
873
|
createdBy?: string;
|
|
815
874
|
rating?: NormalizedNumericSelector;
|
|
875
|
+
/**
|
|
876
|
+
* `rating-axis` selects the custom aggregate for rating/votes filters and order; omission
|
|
877
|
+
* selects main. Verify registration and read access before filtering, counting or sorting.
|
|
878
|
+
* Unknown keys must not fall back to main. Display variables select their own keys.
|
|
879
|
+
*/
|
|
880
|
+
ratingAxis?: string;
|
|
816
881
|
votes?: NormalizedNumericSelector;
|
|
817
882
|
name?: string;
|
|
818
883
|
fullname?: string;
|
|
@@ -851,6 +916,14 @@ interface ProcessWikitextCallbackContext<TPage extends WikitextPageContext> {
|
|
|
851
916
|
settings: WikitextSettings3;
|
|
852
917
|
}
|
|
853
918
|
interface ProcessWikitextDataProvider<TPage extends WikitextPageContext> {
|
|
919
|
+
/**
|
|
920
|
+
* Read only authorized, registered ratings in context.page, including declarations
|
|
921
|
+
* from its includes. Keys match exactly. Omit no-rate and inaccessible references.
|
|
922
|
+
* Main category policy and custom policies are independent. Votes belong to page + ref.
|
|
923
|
+
* ListPages/ListUsers output cannot declare ratings, including its nested includes.
|
|
924
|
+
* The host owns registration, aggregation and invalidation when included declarations change.
|
|
925
|
+
*/
|
|
926
|
+
fetchRatings?: (refs: readonly RatingRef[], context: ProcessWikitextCallbackContext<TPage>) => Promise<readonly RatingState[]>;
|
|
854
927
|
fetchInclude?: (pageRef: PageRef5, context: ProcessWikitextCallbackContext<TPage>) => Promise<string | null>;
|
|
855
928
|
fetchListPages?: (query: NormalizedListPagesQuery, requirement: ListPagesDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListPagesExternalData | null | undefined>;
|
|
856
929
|
fetchListUsers?: (requirement: ListUsersDataRequirement, context: ProcessWikitextCallbackContext<TPage>) => Promise<ListUsersExternalData | null | undefined>;
|
|
@@ -861,9 +934,14 @@ interface ProcessWikitextOptions<TPage extends WikitextPageContext> {
|
|
|
861
934
|
settings?: WikitextSettings3;
|
|
862
935
|
dataProvider?: ProcessWikitextDataProvider<TPage>;
|
|
863
936
|
includeMaxIterations?: number;
|
|
937
|
+
readableText?: ReadableTextOptions;
|
|
864
938
|
}
|
|
865
939
|
interface ProcessedWikitextDocument<TPage extends WikitextPageContext = WikitextPageContext> {
|
|
866
940
|
ast: SyntaxTree;
|
|
941
|
+
readableText: string;
|
|
942
|
+
/** First nonempty body paragraph, excluding headings and appended footnotes. */
|
|
943
|
+
firstParagraph: string;
|
|
944
|
+
characterCount: number;
|
|
867
945
|
page: TPage;
|
|
868
946
|
settings: WikitextSettings3;
|
|
869
947
|
diagnostics: Diagnostic[];
|
|
@@ -883,6 +961,13 @@ import { ParseResult as ParseResult3, SyntaxTree as SyntaxTree2 } from "@wdprlib
|
|
|
883
961
|
*/
|
|
884
962
|
type ModuleParseResult = SyntaxTree2 | ParseResult3;
|
|
885
963
|
type ParseFunction = (input: string) => ModuleParseResult;
|
|
964
|
+
import { RatingRef as RatingRef2, RatingState as RatingState2 } from "@wdprlib/ast";
|
|
965
|
+
/**
|
|
966
|
+
* Read authorized ratings for the displayed page. Omit unknown, disabled, or
|
|
967
|
+
* inaccessible references. The host owns registration, category policies,
|
|
968
|
+
* access checks, aggregates, and persistence; rendering must never create data.
|
|
969
|
+
*/
|
|
970
|
+
type RatingsFetcher = (refs: readonly RatingRef2[]) => Promise<readonly RatingState2[]>;
|
|
886
971
|
/**
|
|
887
972
|
* Callback to retrieve the current page's tags during the resolve phase.
|
|
888
973
|
*
|
|
@@ -903,6 +988,8 @@ type IfTagsResolver = () => string[];
|
|
|
903
988
|
* @group Module Resolution
|
|
904
989
|
*/
|
|
905
990
|
interface DataProvider {
|
|
991
|
+
/** Read registered ratings for the displayed page; omitted references stay hidden. */
|
|
992
|
+
fetchRatings?: RatingsFetcher;
|
|
906
993
|
/**
|
|
907
994
|
* Fetch page data for `[[module ListPages]]` expansion.
|
|
908
995
|
*
|
|
@@ -1215,4 +1302,4 @@ interface ResolveOptions {
|
|
|
1215
1302
|
*/
|
|
1216
1303
|
declare function resolveModules(ast: SyntaxTree4, dataProvider: DataProvider, options: ResolveOptions): Promise<SyntaxTree4>;
|
|
1217
1304
|
import { STYLE_SLOT_PREFIX } from "@wdprlib/ast";
|
|
1218
|
-
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, buildInfo, 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, PageRef7 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 };
|
|
1305
|
+
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, buildInfo, 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, RatingsFetcher, RatingVote, RatingState3 as RatingState, RatingRef3 as RatingRef, RatingAggregate2 as RatingAggregate, ProcessedWikitextDocument, ProcessWikitextOptions, ProcessWikitextDataProvider, ProcessWikitextCallbackContext, Position2 as Position, Point, ParserOptions, Parser, ParseResult4 as ParseResult, ParseFunction, PageRef7 as PageRef, PageMetadataValue, 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 };
|