@wdprlib/ast 4.2.0 → 4.3.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 CHANGED
@@ -40,6 +40,7 @@ __export(exports_src, {
40
40
  isTruthy: () => isTruthy,
41
41
  isStringContainerType: () => isStringContainerType,
42
42
  isParagraphSafe: () => isParagraphSafe,
43
+ isPageButtonAction: () => isPageButtonAction,
43
44
  isHeaderType: () => isHeaderType,
44
45
  isContainerTypeParagraphSafe: () => isContainerTypeParagraphSafe,
45
46
  isAlignType: () => isAlignType,
@@ -62,8 +63,8 @@ module.exports = __toCommonJS(exports_src);
62
63
 
63
64
  // packages/ast/src/build-info.generated.ts
64
65
  var buildInfo = Object.freeze({
65
- version: "4.2.0",
66
- sha: "b71b84c705e05717f5ea12fd89684a91b669dbff",
66
+ version: "4.3.0",
67
+ sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
67
68
  dirty: false
68
69
  });
69
70
  // packages/ast/src/position.ts
@@ -159,6 +160,7 @@ function isContainerTypeParagraphSafe(type) {
159
160
  case "size":
160
161
  return true;
161
162
  case "div":
163
+ case "note":
162
164
  case "blockquote":
163
165
  case "paragraph":
164
166
  case "heading":
@@ -218,7 +220,10 @@ function isParagraphSafe(element) {
218
220
  case "user":
219
221
  return true;
220
222
  case "date":
223
+ case "social":
221
224
  return true;
225
+ case "button":
226
+ return isPageButtonAction(element.data.action);
222
227
  case "color":
223
228
  return true;
224
229
  case "code":
@@ -259,6 +264,30 @@ function isParagraphSafe(element) {
259
264
  return false;
260
265
  }
261
266
  }
267
+ function isPageButtonAction(action) {
268
+ switch (action) {
269
+ case "edit":
270
+ case "edit-append":
271
+ case "edit-sections":
272
+ case "history":
273
+ case "print":
274
+ case "files":
275
+ case "tags":
276
+ case "source":
277
+ case "backlinks":
278
+ case "talk":
279
+ case "delete":
280
+ case "rename":
281
+ case "site-tools":
282
+ case "edit-meta":
283
+ case "watchers":
284
+ case "parent":
285
+ case "lock-page":
286
+ return true;
287
+ default:
288
+ return false;
289
+ }
290
+ }
262
291
  // packages/ast/src/constants.ts
263
292
  var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
264
293
  var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
package/dist/index.d.cts CHANGED
@@ -171,7 +171,7 @@ interface AlignType {
171
171
  *
172
172
  * @group Container Types
173
173
  */
174
- type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
174
+ type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "note" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
175
175
  /**
176
176
  * Union of all container type discriminators.
177
177
  * Every container element in the AST carries one of these to identify
@@ -799,9 +799,29 @@ interface DateData {
799
799
  value: DateItem;
800
800
  /** strftime-style format string, or null for default */
801
801
  format: string | null;
802
- /** Whether to show a tooltip with the full date on hover */
802
+ /** Whether to show elapsed time in a tooltip on hover */
803
803
  hover: boolean;
804
804
  }
805
+ /** Standalone page-option action, used by [[button action]].
806
+ * @group Element Data
807
+ */
808
+ type PageButtonAction = "edit" | "edit-append" | "edit-sections" | "history" | "print" | "files" | "tags" | "source" | "backlinks" | "talk" | "delete" | "rename" | "site-tools" | "edit-meta" | "watchers" | "parent" | "lock-page";
809
+ /** Data for a standalone [[button]] element.
810
+ * @group Element Data
811
+ */
812
+ interface PageButtonData {
813
+ /** Unknown actions remain representable so the renderer can display the error. */
814
+ action: string;
815
+ text: string | null;
816
+ attributes: AttributeMap;
817
+ }
818
+ /** Data for [[social]], with null selecting the default services.
819
+ * @group Element Data
820
+ */
821
+ interface SocialData {
822
+ /** Unsupported names remain representable, but produce no share link. */
823
+ sites: string[] | null;
824
+ }
805
825
  /**
806
826
  * Data for `##color|text##` inline color syntax.
807
827
  *
@@ -958,6 +978,8 @@ type ElementDataMap = {
958
978
  "bibliography-block": BibliographyBlockData;
959
979
  user: UserData;
960
980
  date: DateData;
981
+ button: PageButtonData;
982
+ social: SocialData;
961
983
  color: ColorData;
962
984
  code: CodeBlockData;
963
985
  math: MathData;
@@ -1162,6 +1184,8 @@ declare function isContainerTypeParagraphSafe(type: ContainerType): boolean;
1162
1184
  * @group Utilities
1163
1185
  */
1164
1186
  declare function isParagraphSafe(element: Element): boolean;
1187
+ /** Whether a standalone button names a supported page action. */
1188
+ declare function isPageButtonAction(action: string): action is PageButtonAction;
1165
1189
  /**
1166
1190
  * Severity level of a diagnostic.
1167
1191
  *
@@ -1454,4 +1478,4 @@ interface WikitextPageContext {
1454
1478
  * @group Core
1455
1479
  */
1456
1480
  type Version = "wikidot";
1457
- export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PagerData, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
1481
+ export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isPageButtonAction, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, SocialData, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PagerData, PageRef, PageButtonData, PageButtonAction, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
package/dist/index.d.ts CHANGED
@@ -171,7 +171,7 @@ interface AlignType {
171
171
  *
172
172
  * @group Container Types
173
173
  */
174
- type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
174
+ type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "note" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
175
175
  /**
176
176
  * Union of all container type discriminators.
177
177
  * Every container element in the AST carries one of these to identify
@@ -799,9 +799,29 @@ interface DateData {
799
799
  value: DateItem;
800
800
  /** strftime-style format string, or null for default */
801
801
  format: string | null;
802
- /** Whether to show a tooltip with the full date on hover */
802
+ /** Whether to show elapsed time in a tooltip on hover */
803
803
  hover: boolean;
804
804
  }
805
+ /** Standalone page-option action, used by [[button action]].
806
+ * @group Element Data
807
+ */
808
+ type PageButtonAction = "edit" | "edit-append" | "edit-sections" | "history" | "print" | "files" | "tags" | "source" | "backlinks" | "talk" | "delete" | "rename" | "site-tools" | "edit-meta" | "watchers" | "parent" | "lock-page";
809
+ /** Data for a standalone [[button]] element.
810
+ * @group Element Data
811
+ */
812
+ interface PageButtonData {
813
+ /** Unknown actions remain representable so the renderer can display the error. */
814
+ action: string;
815
+ text: string | null;
816
+ attributes: AttributeMap;
817
+ }
818
+ /** Data for [[social]], with null selecting the default services.
819
+ * @group Element Data
820
+ */
821
+ interface SocialData {
822
+ /** Unsupported names remain representable, but produce no share link. */
823
+ sites: string[] | null;
824
+ }
805
825
  /**
806
826
  * Data for `##color|text##` inline color syntax.
807
827
  *
@@ -958,6 +978,8 @@ type ElementDataMap = {
958
978
  "bibliography-block": BibliographyBlockData;
959
979
  user: UserData;
960
980
  date: DateData;
981
+ button: PageButtonData;
982
+ social: SocialData;
961
983
  color: ColorData;
962
984
  code: CodeBlockData;
963
985
  math: MathData;
@@ -1162,6 +1184,8 @@ declare function isContainerTypeParagraphSafe(type: ContainerType): boolean;
1162
1184
  * @group Utilities
1163
1185
  */
1164
1186
  declare function isParagraphSafe(element: Element): boolean;
1187
+ /** Whether a standalone button names a supported page action. */
1188
+ declare function isPageButtonAction(action: string): action is PageButtonAction;
1165
1189
  /**
1166
1190
  * Severity level of a diagnostic.
1167
1191
  *
@@ -1454,4 +1478,4 @@ interface WikitextPageContext {
1454
1478
  * @group Core
1455
1479
  */
1456
1480
  type Version = "wikidot";
1457
- export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PagerData, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
1481
+ export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isPageButtonAction, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, SocialData, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PagerData, PageRef, PageButtonData, PageButtonAction, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // packages/ast/src/build-info.generated.ts
2
2
  var buildInfo = Object.freeze({
3
- version: "4.2.0",
4
- sha: "b71b84c705e05717f5ea12fd89684a91b669dbff",
3
+ version: "4.3.0",
4
+ sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
5
5
  dirty: false
6
6
  });
7
7
  // packages/ast/src/position.ts
@@ -97,6 +97,7 @@ function isContainerTypeParagraphSafe(type) {
97
97
  case "size":
98
98
  return true;
99
99
  case "div":
100
+ case "note":
100
101
  case "blockquote":
101
102
  case "paragraph":
102
103
  case "heading":
@@ -156,7 +157,10 @@ function isParagraphSafe(element) {
156
157
  case "user":
157
158
  return true;
158
159
  case "date":
160
+ case "social":
159
161
  return true;
162
+ case "button":
163
+ return isPageButtonAction(element.data.action);
160
164
  case "color":
161
165
  return true;
162
166
  case "code":
@@ -197,6 +201,30 @@ function isParagraphSafe(element) {
197
201
  return false;
198
202
  }
199
203
  }
204
+ function isPageButtonAction(action) {
205
+ switch (action) {
206
+ case "edit":
207
+ case "edit-append":
208
+ case "edit-sections":
209
+ case "history":
210
+ case "print":
211
+ case "files":
212
+ case "tags":
213
+ case "source":
214
+ case "backlinks":
215
+ case "talk":
216
+ case "delete":
217
+ case "rename":
218
+ case "site-tools":
219
+ case "edit-meta":
220
+ case "watchers":
221
+ case "parent":
222
+ case "lock-page":
223
+ return true;
224
+ default:
225
+ return false;
226
+ }
227
+ }
200
228
  // packages/ast/src/constants.ts
201
229
  var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
202
230
  var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
@@ -687,6 +715,7 @@ export {
687
715
  isTruthy,
688
716
  isStringContainerType,
689
717
  isParagraphSafe,
718
+ isPageButtonAction,
690
719
  isHeaderType,
691
720
  isContainerTypeParagraphSafe,
692
721
  isAlignType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdprlib/ast",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "AST types for Wikidot markup",
5
5
  "keywords": [
6
6
  "ast",
@@ -5,7 +5,7 @@ export const buildInfo: Readonly<{
5
5
  sha: string | null;
6
6
  dirty: boolean | null;
7
7
  }> = Object.freeze({
8
- version: "4.2.0",
9
- sha: "b71b84c705e05717f5ea12fd89684a91b669dbff",
8
+ version: "4.3.0",
9
+ sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
10
10
  dirty: false,
11
11
  });
package/src/element.ts CHANGED
@@ -122,6 +122,7 @@ export type StringContainerType =
122
122
  | "monospace"
123
123
  | "span"
124
124
  | "div"
125
+ | "note"
125
126
  | "blockquote"
126
127
  | "size"
127
128
  | "paragraph"
@@ -814,10 +815,50 @@ export interface DateData {
814
815
  value: DateItem;
815
816
  /** strftime-style format string, or null for default */
816
817
  format: string | null;
817
- /** Whether to show a tooltip with the full date on hover */
818
+ /** Whether to show elapsed time in a tooltip on hover */
818
819
  hover: boolean;
819
820
  }
820
821
 
822
+ /** Standalone page-option action, used by [[button action]].
823
+ * @group Element Data
824
+ */
825
+ export type PageButtonAction =
826
+ | "edit"
827
+ | "edit-append"
828
+ | "edit-sections"
829
+ | "history"
830
+ | "print"
831
+ | "files"
832
+ | "tags"
833
+ | "source"
834
+ | "backlinks"
835
+ | "talk"
836
+ | "delete"
837
+ | "rename"
838
+ | "site-tools"
839
+ | "edit-meta"
840
+ | "watchers"
841
+ | "parent"
842
+ | "lock-page";
843
+
844
+ /** Data for a standalone [[button]] element.
845
+ * @group Element Data
846
+ */
847
+ export interface PageButtonData {
848
+ /** Unknown actions remain representable so the renderer can display the error. */
849
+ action: string;
850
+ text: string | null;
851
+ attributes: AttributeMap;
852
+ }
853
+
854
+ /** Data for [[social]], with null selecting the default services.
855
+ * @group Element Data
856
+ */
857
+ export interface SocialData {
858
+ /** Unsupported names remain representable, but produce no share link. */
859
+ sites: string[] | null;
860
+ }
861
+
821
862
  /**
822
863
  * Data for `##color|text##` inline color syntax.
823
864
  *
@@ -989,6 +1030,8 @@ export type ElementDataMap = {
989
1030
  "bibliography-block": BibliographyBlockData;
990
1031
  user: UserData;
991
1032
  date: DateData;
1033
+ button: PageButtonData;
1034
+ social: SocialData;
992
1035
  color: ColorData;
993
1036
  code: CodeBlockData;
994
1037
  math: MathData;
@@ -1282,6 +1325,7 @@ export function isContainerTypeParagraphSafe(type: ContainerType): boolean {
1282
1325
  case "size":
1283
1326
  return true;
1284
1327
  case "div":
1328
+ case "note":
1285
1329
  case "blockquote":
1286
1330
  case "paragraph":
1287
1331
  case "heading":
@@ -1354,7 +1398,10 @@ export function isParagraphSafe(element: Element): boolean {
1354
1398
  case "user":
1355
1399
  return true;
1356
1400
  case "date":
1401
+ case "social":
1357
1402
  return true;
1403
+ case "button":
1404
+ return isPageButtonAction(element.data.action);
1358
1405
  case "color":
1359
1406
  return true;
1360
1407
  case "code":
@@ -1395,3 +1442,29 @@ export function isParagraphSafe(element: Element): boolean {
1395
1442
  return false;
1396
1443
  }
1397
1444
  }
1445
+
1446
+ /** Whether a standalone button names a supported page action. */
1447
+ export function isPageButtonAction(action: string): action is PageButtonAction {
1448
+ switch (action) {
1449
+ case "edit":
1450
+ case "edit-append":
1451
+ case "edit-sections":
1452
+ case "history":
1453
+ case "print":
1454
+ case "files":
1455
+ case "tags":
1456
+ case "source":
1457
+ case "backlinks":
1458
+ case "talk":
1459
+ case "delete":
1460
+ case "rename":
1461
+ case "site-tools":
1462
+ case "edit-meta":
1463
+ case "watchers":
1464
+ case "parent":
1465
+ case "lock-page":
1466
+ return true;
1467
+ default:
1468
+ return false;
1469
+ }
1470
+ }
package/src/index.ts CHANGED
@@ -81,6 +81,9 @@ export type {
81
81
  BibliographyBlockData,
82
82
  UserData,
83
83
  DateData,
84
+ PageButtonAction,
85
+ PageButtonData,
86
+ SocialData,
84
87
  ColorData,
85
88
  MathData,
86
89
  MathInlineData,
@@ -110,6 +113,7 @@ export {
110
113
  isAlignType,
111
114
  isContainerTypeParagraphSafe,
112
115
  isParagraphSafe,
116
+ isPageButtonAction,
113
117
  } from "./element";
114
118
 
115
119
  // Diagnostics