@astryxdesign/core 0.6.1 → 0.6.2-canary.023c3e4
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/CHANGELOG.md +33 -0
- package/dist/BottomSheet/BottomSheet.d.ts +1 -1
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +3 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts +7 -5
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +56 -19
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -2
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +12 -2
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +6 -1
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +1 -1
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +1 -1
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +4 -4
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +16 -16
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +2 -2
- package/dist/DateRangeInput/DateRangeInput.d.ts +3 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +20 -13
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +8 -8
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +4 -4
- package/dist/DateTimeInput/nativePickerSegmentStyles.d.ts +9 -3
- package/dist/DateTimeInput/nativePickerSegmentStyles.d.ts.map +1 -1
- package/dist/DateTimeInput/nativePickerSegmentStyles.js +3 -3
- package/dist/Dialog/DialogHeader.d.ts +1 -1
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +10 -7
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +1 -1
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +16 -10
- package/dist/Kbd/Kbd.d.ts +5 -3
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +36 -42
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +6 -2
- package/dist/Markdown/Markdown.d.ts +18 -4
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.fr23.bench.d.ts +2 -0
- package/dist/Markdown/Markdown.fr23.bench.d.ts.map +1 -0
- package/dist/Markdown/Markdown.fr23.bench.js +150 -0
- package/dist/Markdown/Markdown.fr23.sampling.d.ts +2 -0
- package/dist/Markdown/Markdown.fr23.sampling.d.ts.map +1 -0
- package/dist/Markdown/Markdown.fr23.sampling.js +43 -0
- package/dist/Markdown/Markdown.js +311 -114
- package/dist/Markdown/ast.d.ts +162 -0
- package/dist/Markdown/ast.d.ts.map +1 -0
- package/dist/Markdown/ast.js +74 -0
- package/dist/Markdown/index.d.ts +5 -3
- package/dist/Markdown/index.d.ts.map +1 -1
- package/dist/Markdown/index.js +3 -2
- package/dist/Markdown/parser/index.d.ts +10 -0
- package/dist/Markdown/parser/index.d.ts.map +1 -0
- package/dist/Markdown/parser/index.js +10 -0
- package/dist/Markdown/parser.d.ts +220 -38
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +1072 -188
- package/dist/Markdown/plugins/frontmatter.d.ts +32 -0
- package/dist/Markdown/plugins/frontmatter.d.ts.map +1 -0
- package/dist/Markdown/plugins/frontmatter.js +132 -0
- package/dist/Markdown/plugins/index.d.ts +16 -0
- package/dist/Markdown/plugins/index.d.ts.map +1 -0
- package/dist/Markdown/plugins/index.js +13 -0
- package/dist/Markdown/plugins/protocol.d.ts +191 -0
- package/dist/Markdown/plugins/protocol.d.ts.map +1 -0
- package/dist/Markdown/plugins/protocol.js +957 -0
- package/dist/Markdown/plugins/semanticFence.d.ts +36 -0
- package/dist/Markdown/plugins/semanticFence.d.ts.map +1 -0
- package/dist/Markdown/plugins/semanticFence.js +213 -0
- package/dist/Markdown/plugins/sourceDecoration.d.ts +76 -0
- package/dist/Markdown/plugins/sourceDecoration.d.ts.map +1 -0
- package/dist/Markdown/plugins/sourceDecoration.js +393 -0
- package/dist/Markdown/plugins/textTransform.d.ts +30 -0
- package/dist/Markdown/plugins/textTransform.d.ts.map +1 -0
- package/dist/Markdown/plugins/textTransform.js +374 -0
- package/dist/Markdown/remark.d.ts +196 -0
- package/dist/Markdown/remark.d.ts.map +1 -0
- package/dist/Markdown/remark.js +1062 -0
- package/dist/Markdown/url.d.ts +4 -0
- package/dist/Markdown/url.d.ts.map +1 -0
- package/dist/Markdown/url.js +25 -0
- package/dist/Markdown/utils.d.ts +4 -2
- package/dist/Markdown/utils.d.ts.map +1 -1
- package/dist/Markdown/utils.js +2 -1
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +4 -4
- package/dist/Outline/index.d.ts +1 -0
- package/dist/Outline/index.d.ts.map +1 -1
- package/dist/Outline/parseOutlineFromMarkdown.d.ts +7 -1
- package/dist/Outline/parseOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/parseOutlineFromMarkdown.js +14 -8
- package/dist/Outline/useOutlineFromMarkdown.d.ts +3 -1
- package/dist/Outline/useOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/useOutlineFromMarkdown.js +8 -3
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +46 -30
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +36 -31
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +13 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +5 -5
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +1 -1
- package/dist/SideNav/SideNav.d.ts +2 -1
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +9 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +19 -10
- package/dist/Spinner/Spinner.d.ts +1 -1
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +45 -21
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +11 -0
- package/dist/TabList/Tab.d.ts +1 -1
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +20 -7
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +1 -1
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +2 -2
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +4 -4
- package/dist/ToggleButton/ToggleButton.d.ts +2 -1
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +7 -1
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +16 -7
- package/dist/astryx.css +19 -8
- package/dist/hooks/scrollKeyboardDelegation.d.ts +3 -0
- package/dist/hooks/scrollKeyboardDelegation.d.ts.map +1 -0
- package/dist/hooks/scrollKeyboardDelegation.js +146 -0
- package/dist/hooks/useScrollableArea.d.ts +6 -2
- package/dist/hooks/useScrollableArea.d.ts.map +1 -1
- package/dist/hooks/useScrollableArea.js +17 -5
- package/dist/utils/interactionOverlay.stylex.d.ts +8 -0
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +9 -0
- package/locales/en.json +16 -0
- package/locales/pseudo.json +12 -0
- package/package.json +22 -5
- package/scripts/agent-doc-state.mjs +1 -1
- package/src/BottomSheet/BottomSheet.doc.mjs +8 -1
- package/src/BottomSheet/BottomSheet.spec.md +46 -20
- package/src/BottomSheet/BottomSheet.test.tsx +6 -3
- package/src/BottomSheet/BottomSheet.tsx +3 -1
- package/src/BottomSheet/BottomSheetKeyboard.test.tsx +195 -0
- package/src/BottomSheet/BottomSheetPanel.test.tsx +11 -1
- package/src/BottomSheet/BottomSheetPanel.tsx +49 -16
- package/src/BottomSheet/__tests__/BottomSheetKeyboard.a11y.browser.spec.ts +344 -0
- package/src/Button/__tests__/Button.a11y.chromium.spec.ts +17 -1
- package/src/Button/__tests__/Button.a11y.known-failures.ts +0 -29
- package/src/Button/__tests__/Button.a11y.renders.tsx +9 -2
- package/src/Button/__tests__/Button.a11y.states.ts +9 -0
- package/src/Chat/ChatComposerInput.doc.mjs +3 -3
- package/src/Chat/ChatComposerInput.tsx +10 -2
- package/src/CheckboxInput/CheckboxInput.doc.mjs +11 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
- package/src/CheckboxInput/CheckboxInput.tsx +21 -1
- package/src/ClickableCard/ClickableCard.test.tsx +102 -5
- package/src/Collapsible/Collapsible.doc.mjs +11 -0
- package/src/Collapsible/Collapsible.test.tsx +21 -0
- package/src/Collapsible/Collapsible.tsx +5 -0
- package/src/CommandPalette/CommandPaletteInput.tsx +6 -1
- package/src/ComplexSelector/ComplexSelector.tsx +6 -1
- package/src/DateInput/DateInput.tsx +6 -1
- package/src/DateInput/NativeDateField.tsx +24 -8
- package/src/DateInput/TouchDateField.tsx +6 -2
- package/src/DateRangeInput/DateRangeInput.doc.mjs +35 -7
- package/src/DateRangeInput/DateRangeInput.spec.md +203 -0
- package/src/DateRangeInput/DateRangeInput.test.tsx +100 -4
- package/src/DateRangeInput/DateRangeInput.tsx +35 -21
- package/src/DateTimeInput/DateTimeInput.tsx +6 -1
- package/src/DateTimeInput/TouchDateTimeField.tsx +6 -1
- package/src/DateTimeInput/nativePickerSegmentStyles.ts +24 -8
- package/src/Dialog/Dialog.doc.mjs +3 -0
- package/src/Dialog/Dialog.spec.md +1 -1
- package/src/Dialog/DialogHeader.doc.mjs +38 -0
- package/src/Dialog/DialogHeader.test.tsx +49 -0
- package/src/Dialog/DialogHeader.tsx +23 -4
- package/src/Dialog/modules/DialogHeader.spec.md +152 -0
- package/src/Field/PanelSearchInput.tsx +5 -2
- package/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts +1 -1
- package/src/FileInput/FileInput.doc.mjs +2 -0
- package/src/FileInput/FileInput.spec.md +199 -0
- package/src/FileInput/FileInput.test.tsx +14 -0
- package/src/FileInput/FileInput.tsx +24 -5
- package/src/Kbd/Kbd.doc.mjs +3 -3
- package/src/Kbd/Kbd.test.tsx +57 -1
- package/src/Kbd/Kbd.tsx +57 -37
- package/src/Layout/LayoutFooter.doc.mjs +17 -0
- package/src/Link/Link.doc.mjs +11 -0
- package/src/Link/Link.test.tsx +24 -0
- package/src/Link/Link.tsx +5 -0
- package/src/Markdown/Markdown.doc.mjs +439 -42
- package/src/Markdown/Markdown.fr23.bench.ts +174 -0
- package/src/Markdown/Markdown.fr23.perf.test.ts +249 -0
- package/src/Markdown/Markdown.fr23.sampling.ts +49 -0
- package/src/Markdown/Markdown.helpers.perf.test.ts +489 -0
- package/src/Markdown/Markdown.public.test.ts +280 -0
- package/src/Markdown/Markdown.spec.md +304 -72
- package/src/Markdown/Markdown.test.tsx +118 -3
- package/src/Markdown/Markdown.tsx +489 -129
- package/src/Markdown/ast.test.ts +307 -0
- package/src/Markdown/ast.ts +337 -0
- package/src/Markdown/incremental.test.ts +187 -7
- package/src/Markdown/index.ts +43 -1
- package/src/Markdown/modules/remark.spec.md +269 -0
- package/src/Markdown/parser/index.ts +64 -0
- package/src/Markdown/parser.perf.test.ts +3 -1
- package/src/Markdown/parser.public.test.ts +103 -0
- package/src/Markdown/parser.test.ts +122 -0
- package/src/Markdown/parser.ts +1721 -248
- package/src/Markdown/plugins/frontmatter.test.tsx +125 -0
- package/src/Markdown/plugins/frontmatter.ts +198 -0
- package/src/Markdown/plugins/index.ts +53 -0
- package/src/Markdown/plugins/protocol.test.tsx +1022 -0
- package/src/Markdown/plugins/protocol.ts +1618 -0
- package/src/Markdown/plugins/semanticFence.test.tsx +546 -0
- package/src/Markdown/plugins/semanticFence.ts +424 -0
- package/src/Markdown/plugins/sourceDecoration.test.tsx +799 -0
- package/src/Markdown/plugins/sourceDecoration.ts +539 -0
- package/src/Markdown/plugins/textTransform.test.ts +467 -0
- package/src/Markdown/plugins/textTransform.ts +554 -0
- package/src/Markdown/remark.test.tsx +1877 -0
- package/src/Markdown/remark.ts +1574 -0
- package/src/Markdown/url.ts +30 -0
- package/src/Markdown/utils.ts +19 -1
- package/src/MultiSelector/MultiSelector.test.tsx +1 -35
- package/src/MultiSelector/__tests__/MultiSelector.listbox.a11y.test.tsx +128 -0
- package/src/NumberInput/NumberInput.tsx +6 -1
- package/src/Outline/Outline.doc.mjs +7 -5
- package/src/Outline/Outline.spec.md +1 -1
- package/src/Outline/index.ts +1 -0
- package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +142 -0
- package/src/Outline/parseOutlineFromMarkdown.ts +40 -10
- package/src/Outline/useOutlineFromMarkdown.ts +15 -3
- package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
- package/src/PowerSearch/PowerSearchEditPopover.test.tsx +150 -1
- package/src/PowerSearch/PowerSearchEditPopover.tsx +51 -28
- package/src/ProgressBar/ProgressBar.test.tsx +29 -11
- package/src/ProgressBar/ProgressBar.tsx +59 -72
- package/src/RadioList/RadioList.doc.mjs +11 -0
- package/src/RadioList/RadioList.test.tsx +32 -0
- package/src/RadioList/RadioListItem.tsx +25 -1
- package/src/ScrollableArea/modules/useScrollableArea.spec.md +50 -22
- package/src/SegmentedControl/SegmentedControl.doc.mjs +2 -2
- package/src/SegmentedControl/SegmentedControl.test.tsx +31 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +6 -9
- package/src/Selector/Selector.spec.md +12 -9
- package/src/Selector/Selector.tsx +6 -1
- package/src/Selector/__tests__/Listbox.a11y.chromium.spec.ts +130 -0
- package/src/Selector/__tests__/Listbox.a11y.dom.ts +38 -0
- package/src/Selector/__tests__/Listbox.a11y.inventory.test.ts +63 -0
- package/src/Selector/__tests__/Listbox.a11y.known-failures.ts +37 -0
- package/src/Selector/__tests__/Listbox.a11y.states.ts +232 -0
- package/src/Selector/__tests__/Selector.listbox.a11y.test.tsx +121 -0
- package/src/SideNav/SideNav.doc.mjs +1 -1
- package/src/SideNav/SideNav.test.tsx +10 -0
- package/src/SideNav/SideNav.tsx +14 -2
- package/src/Slider/Slider.doc.mjs +27 -0
- package/src/Slider/Slider.spec.md +61 -47
- package/src/Slider/Slider.test.tsx +146 -0
- package/src/Slider/Slider.tsx +37 -13
- package/src/Spinner/Spinner.doc.mjs +6 -3
- package/src/Spinner/Spinner.test.tsx +41 -0
- package/src/Spinner/Spinner.tsx +62 -32
- package/src/Switch/Switch.doc.mjs +11 -0
- package/src/Switch/Switch.test.tsx +16 -0
- package/src/Switch/Switch.tsx +28 -0
- package/src/TabList/Tab.tsx +35 -7
- package/src/TabList/TabList.doc.mjs +11 -0
- package/src/TabList/TabList.test.tsx +66 -0
- package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +1 -34
- package/src/TextArea/TextArea.tsx +6 -1
- package/src/TextInput/TextInput.test.tsx +20 -1
- package/src/TextInput/TextInput.tsx +6 -1
- package/src/TimeInput/TimeInput.tsx +6 -1
- package/src/ToggleButton/ToggleButton.test.tsx +133 -0
- package/src/ToggleButton/ToggleButton.tsx +9 -2
- package/src/ToggleButton/__tests__/ToggleButton.a11y.chromium.spec.ts +209 -0
- package/src/Tokenizer/Tokenizer.spec.md +142 -75
- package/src/TreeList/TreeList.spec.md +123 -75
- package/src/Typeahead/BaseTypeahead.spec.md +4 -3
- package/src/Typeahead/BaseTypeahead.tsx +21 -7
- package/src/Typeahead/Typeahead.test.tsx +53 -0
- package/src/__tests__/PressedState.a11y.chromium.spec.ts +813 -0
- package/src/__tests__/pressState.ts +93 -0
- package/src/hooks/scrollKeyboardDelegation.test.ts +155 -0
- package/src/hooks/scrollKeyboardDelegation.ts +233 -0
- package/src/hooks/useScrollableArea.doc.mjs +15 -3
- package/src/hooks/useScrollableArea.test.tsx +59 -1
- package/src/hooks/useScrollableArea.ts +34 -10
- package/src/inputFontFloor.test.ts +106 -0
- package/src/theme/derivedVarRegistry.test.ts +6 -4
- package/src/utils/interactionOverlay.stylex.ts +20 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file index.ts
|
|
5
|
+
* @input Markdown source and public parser options
|
|
6
|
+
* @output Server-safe legacy and canonical Markdown parser entry points and types
|
|
7
|
+
* @position Public subpath entry point: `@astryxdesign/core/Markdown/parser`
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
createIncrementalState,
|
|
12
|
+
parseInline,
|
|
13
|
+
parseInlineAst,
|
|
14
|
+
parseMarkdown,
|
|
15
|
+
parseMarkdownAst,
|
|
16
|
+
parseMarkdownIncremental,
|
|
17
|
+
} from '../parser';
|
|
18
|
+
export type {
|
|
19
|
+
BlockNode,
|
|
20
|
+
BlockNodeWithMath,
|
|
21
|
+
MathBlockNode,
|
|
22
|
+
InlineNode,
|
|
23
|
+
InlineNodeWithMath,
|
|
24
|
+
MathInlineNode,
|
|
25
|
+
SourceRange,
|
|
26
|
+
ListItemNode,
|
|
27
|
+
TableCellNode,
|
|
28
|
+
TableAlignment,
|
|
29
|
+
ParseOptions,
|
|
30
|
+
MathParseOptions,
|
|
31
|
+
IncrementalParseOptions,
|
|
32
|
+
IncrementalMathParseOptions,
|
|
33
|
+
IncrementalState as IncrementalParseState,
|
|
34
|
+
} from '../parser';
|
|
35
|
+
export type {
|
|
36
|
+
MarkdownAstPoint,
|
|
37
|
+
MarkdownAstDataValue,
|
|
38
|
+
MarkdownAstPosition,
|
|
39
|
+
MarkdownAstNodeBase,
|
|
40
|
+
MarkdownAstExtensionNode,
|
|
41
|
+
MarkdownAstText,
|
|
42
|
+
MarkdownAstInlineCode,
|
|
43
|
+
MarkdownAstInlineMath,
|
|
44
|
+
MarkdownAstLink,
|
|
45
|
+
MarkdownAstImage,
|
|
46
|
+
MarkdownAstCitation,
|
|
47
|
+
MarkdownAstBreak,
|
|
48
|
+
MarkdownAstPhrasingContent,
|
|
49
|
+
MarkdownAstHeading,
|
|
50
|
+
MarkdownAstParagraph,
|
|
51
|
+
MarkdownAstCode,
|
|
52
|
+
MarkdownAstMath,
|
|
53
|
+
MarkdownAstBlockquote,
|
|
54
|
+
MarkdownAstList,
|
|
55
|
+
MarkdownAstListItem,
|
|
56
|
+
MarkdownAstTable,
|
|
57
|
+
MarkdownAstTableRow,
|
|
58
|
+
MarkdownAstTableCell,
|
|
59
|
+
MarkdownAstThematicBreak,
|
|
60
|
+
MarkdownAstBlockContent,
|
|
61
|
+
MarkdownAstRoot,
|
|
62
|
+
MarkdownAstNodeMap,
|
|
63
|
+
MarkdownAstNode,
|
|
64
|
+
} from '../ast';
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from './parser';
|
|
10
10
|
import type {BlockNode, ParseOptions} from './parser';
|
|
11
11
|
|
|
12
|
+
type PerfParseOptions = ParseOptions;
|
|
13
|
+
|
|
12
14
|
function generateAIResponse(paragraphs: number): string {
|
|
13
15
|
const sections: string[] = [];
|
|
14
16
|
for (let i = 0; i < paragraphs; i++) {
|
|
@@ -81,7 +83,7 @@ function simulateStreamingIncremental(
|
|
|
81
83
|
function blocksBuiltPerChunk(
|
|
82
84
|
fullText: string,
|
|
83
85
|
chunkSize: number,
|
|
84
|
-
options?:
|
|
86
|
+
options?: PerfParseOptions,
|
|
85
87
|
): number[] {
|
|
86
88
|
const state = createIncrementalState();
|
|
87
89
|
let previous: ReadonlySet<BlockNode> = new Set();
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file parser.public.test.ts
|
|
5
|
+
* @input Imports the documented Markdown parser-only package subpath
|
|
6
|
+
* @output Runtime and type evidence for its canonical server-safe contract
|
|
7
|
+
* @position Public package-contract test for @astryxdesign/core/Markdown/parser
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {readFileSync} from 'node:fs';
|
|
11
|
+
import {join} from 'node:path';
|
|
12
|
+
import {describe, expect, expectTypeOf, it} from 'vitest';
|
|
13
|
+
import {
|
|
14
|
+
createMarkdownFrontmatter,
|
|
15
|
+
createMarkdownPlugin,
|
|
16
|
+
} from '@astryxdesign/core/Markdown/plugins';
|
|
17
|
+
import {
|
|
18
|
+
createIncrementalState,
|
|
19
|
+
parseInline,
|
|
20
|
+
parseInlineAst,
|
|
21
|
+
parseMarkdown,
|
|
22
|
+
parseMarkdownAst,
|
|
23
|
+
parseMarkdownIncremental,
|
|
24
|
+
} from '@astryxdesign/core/Markdown/parser';
|
|
25
|
+
import type {
|
|
26
|
+
BlockNode,
|
|
27
|
+
InlineNode,
|
|
28
|
+
MarkdownAstPhrasingContent,
|
|
29
|
+
MarkdownAstRoot,
|
|
30
|
+
} from '@astryxdesign/core/Markdown/parser';
|
|
31
|
+
|
|
32
|
+
describe('@astryxdesign/core/Markdown/parser', () => {
|
|
33
|
+
it('is a generated public package subpath', () => {
|
|
34
|
+
const packageJson = JSON.parse(
|
|
35
|
+
readFileSync(join(process.cwd(), 'packages/core/package.json'), 'utf8'),
|
|
36
|
+
) as {
|
|
37
|
+
exports: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
const entrySources = [
|
|
40
|
+
'packages/core/src/Markdown/parser/index.ts',
|
|
41
|
+
'packages/core/src/Markdown/parser.ts',
|
|
42
|
+
'packages/core/src/Markdown/plugins/index.ts',
|
|
43
|
+
'packages/core/src/Markdown/plugins/protocol.ts',
|
|
44
|
+
'packages/core/src/Markdown/plugins/frontmatter.ts',
|
|
45
|
+
].map(path => readFileSync(join(process.cwd(), path), 'utf8'));
|
|
46
|
+
|
|
47
|
+
expect(packageJson.exports['./Markdown/parser']).toEqual({
|
|
48
|
+
source: './src/Markdown/parser/index.ts',
|
|
49
|
+
types: './dist/Markdown/parser/index.d.ts',
|
|
50
|
+
default: './dist/Markdown/parser/index.js',
|
|
51
|
+
});
|
|
52
|
+
for (const entrySource of entrySources) {
|
|
53
|
+
expect(entrySource).not.toMatch(/^\s*['"]use client['"]/m);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('exposes legacy and canonical parser results from a server-only entry point', () => {
|
|
58
|
+
const source = '# Heading\n\nParagraph';
|
|
59
|
+
const blockAst = parseMarkdownAst(source);
|
|
60
|
+
const inlineAst = parseInlineAst('**bold**');
|
|
61
|
+
|
|
62
|
+
expect(blockAst).toMatchObject({
|
|
63
|
+
type: 'root',
|
|
64
|
+
children: [{type: 'heading', depth: 1}, {type: 'paragraph'}],
|
|
65
|
+
});
|
|
66
|
+
expect(inlineAst).toMatchObject([{type: 'strong'}]);
|
|
67
|
+
expect(parseMarkdown(source)[0]).toMatchObject({type: 'heading', level: 1});
|
|
68
|
+
expect(parseInline('**bold**')[0]).toMatchObject({type: 'bold'});
|
|
69
|
+
expect(parseMarkdownIncremental(source, createIncrementalState())).toEqual(
|
|
70
|
+
parseMarkdown(source),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const canonicalBlockAst: MarkdownAstRoot = blockAst;
|
|
74
|
+
const canonicalInlineAst: ReadonlyArray<MarkdownAstPhrasingContent> =
|
|
75
|
+
inlineAst;
|
|
76
|
+
expect(canonicalBlockAst).toBe(blockAst);
|
|
77
|
+
expect(canonicalInlineAst).toBe(inlineAst);
|
|
78
|
+
expectTypeOf(parseMarkdown(source)).toEqualTypeOf<BlockNode[]>();
|
|
79
|
+
expectTypeOf(parseInline('text')).toEqualTypeOf<InlineNode[]>();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('runs typed plugins through the server-safe parser boundary', () => {
|
|
83
|
+
const frontmatter = createMarkdownFrontmatter({
|
|
84
|
+
name: 'server-document-metadata',
|
|
85
|
+
parse: fields => ({title: fields.title ?? 'Untitled'}),
|
|
86
|
+
});
|
|
87
|
+
let title: string | undefined;
|
|
88
|
+
const observer = createMarkdownPlugin({
|
|
89
|
+
name: 'server-metadata-observer',
|
|
90
|
+
apiVersion: 1,
|
|
91
|
+
transform(root) {
|
|
92
|
+
title = frontmatter.getMetadata(root)?.title;
|
|
93
|
+
return root;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const root = parseMarkdownAst('---\ntitle: Server proof\n---\n# Body', {
|
|
97
|
+
plugins: [frontmatter.plugin, observer],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(title).toBe('Server proof');
|
|
101
|
+
expect(root.children).toMatchObject([{type: 'heading', depth: 1}]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -42,6 +42,73 @@ describe('parseInline', () => {
|
|
|
42
42
|
expect(result).toEqual([{type: 'code', content: 'const x'}]);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
it('leaves math delimiters as literal text by default', () => {
|
|
46
|
+
expect(parseInline('Euler: $e^{i * pi} + 1 = 0$.')).toEqual([
|
|
47
|
+
{type: 'text', content: 'Euler: $e^{i * pi} + 1 = 0$.'},
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('parses inline math before Markdown formatting when explicitly enabled', () => {
|
|
52
|
+
expect(parseInline('Euler: $e^{i * pi} + 1 = 0$.', {math: true})).toEqual([
|
|
53
|
+
{type: 'text', content: 'Euler: '},
|
|
54
|
+
{type: 'math', value: 'e^{i * pi} + 1 = 0'},
|
|
55
|
+
{type: 'text', content: '.'},
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('preserves escaped delimiters inside math and leaves escaped openers literal', () => {
|
|
60
|
+
expect(
|
|
61
|
+
parseInline('Price: \\$5; formula: $x \\$ y$.', {math: true}),
|
|
62
|
+
).toEqual([
|
|
63
|
+
{type: 'text', content: 'Price: '},
|
|
64
|
+
{type: 'text', content: '$5; formula: '},
|
|
65
|
+
{type: 'math', value: 'x \\$ y'},
|
|
66
|
+
{type: 'text', content: '.'},
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('leaves an unmatched inline math delimiter literal', () => {
|
|
71
|
+
expect(parseInline('The value is $x + 1.', {math: true})).toEqual([
|
|
72
|
+
{type: 'text', content: 'The value is $x + 1.'},
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('does not mistake paired currency amounts for inline math', () => {
|
|
77
|
+
expect(
|
|
78
|
+
parseInline('Tickets cost $20 and $30 today.', {math: true}),
|
|
79
|
+
).toEqual([{type: 'text', content: 'Tickets cost $20 and $30 today.'}]);
|
|
80
|
+
expect(parseInline('$x$5 and $y$', {math: true})).toEqual([
|
|
81
|
+
{type: 'text', content: '$x$5 and '},
|
|
82
|
+
{type: 'math', value: 'y'},
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('allows an inline expression to begin with a number', () => {
|
|
87
|
+
expect(parseInline('Result: $2 + 2$.', {math: true})).toEqual([
|
|
88
|
+
{type: 'text', content: 'Result: '},
|
|
89
|
+
{type: 'math', value: '2 + 2'},
|
|
90
|
+
{type: 'text', content: '.'},
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('does not treat non-block double-dollar runs as inline math', () => {
|
|
95
|
+
expect(parseInline('Keep $$x + y$$ literal.', {math: true})).toEqual([
|
|
96
|
+
{type: 'text', content: 'Keep $$x + y$$ literal.'},
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('keeps code and link destinations opaque while parsing math in link labels', () => {
|
|
101
|
+
expect(parseInline('`$code$` [$label$](/price/$5)', {math: true})).toEqual([
|
|
102
|
+
{type: 'code', content: '$code$'},
|
|
103
|
+
{type: 'text', content: ' '},
|
|
104
|
+
{
|
|
105
|
+
type: 'link',
|
|
106
|
+
href: '/price/$5',
|
|
107
|
+
children: [{type: 'math', value: 'label'}],
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
|
|
45
112
|
it('parses links', () => {
|
|
46
113
|
const result = parseInline('[click](https://example.com)');
|
|
47
114
|
expect(result[0].type).toBe('link');
|
|
@@ -270,6 +337,61 @@ describe('parseMarkdown', () => {
|
|
|
270
337
|
}
|
|
271
338
|
});
|
|
272
339
|
|
|
340
|
+
it('parses display math only when explicitly enabled', () => {
|
|
341
|
+
const source = '$$\n\\int_0^1 x^2 \\, dx\n$$';
|
|
342
|
+
expect(parseMarkdown(source)).not.toContainEqual({
|
|
343
|
+
type: 'math',
|
|
344
|
+
value: '\\int_0^1 x^2 \\, dx',
|
|
345
|
+
});
|
|
346
|
+
expect(parseMarkdown(source, {math: true})).toEqual([
|
|
347
|
+
{type: 'math', value: '\\int_0^1 x^2 \\, dx'},
|
|
348
|
+
]);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('parses a same-line display math block', () => {
|
|
352
|
+
expect(parseMarkdown('$$E = mc^2$$', {math: true})).toEqual([
|
|
353
|
+
{type: 'math', value: 'E = mc^2'},
|
|
354
|
+
]);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it('keeps empty display delimiters literal', () => {
|
|
358
|
+
const source = '$$\n$$';
|
|
359
|
+
expect(parseMarkdown(source, {math: true})).toEqual(parseMarkdown(source));
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('leaves unmatched display math delimiters literal', () => {
|
|
363
|
+
const source = '$$\nx + y';
|
|
364
|
+
expect(parseMarkdown(source, {math: true})).toEqual(parseMarkdown(source));
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('leaves escaped display delimiters literal', () => {
|
|
368
|
+
const blocks = parseMarkdown('\\$\\$\nx + y\n\\$\\$', {math: true});
|
|
369
|
+
expect(blocks.some(block => block.type === 'math')).toBe(false);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('reports a display-math source range including its delimiters', () => {
|
|
373
|
+
const source = 'Before.\n\n$$\nx + y\n$$\n\nAfter.';
|
|
374
|
+
const blocks = parseMarkdown(source, {math: true, sourceRanges: true});
|
|
375
|
+
expect(blocks[1]?.range).toEqual({start: 9, end: 20});
|
|
376
|
+
expect(source.slice(blocks[1].range?.start, blocks[1].range?.end)).toBe(
|
|
377
|
+
'$$\nx + y\n$$',
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('keeps fenced code opaque when math parsing is enabled', () => {
|
|
382
|
+
expect(parseMarkdown('```tex\n$x$\n$$y$$\n```', {math: true})).toEqual([
|
|
383
|
+
{type: 'codeblock', language: 'tex', content: '$x$\n$$y$$'},
|
|
384
|
+
]);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('does not collect link definitions from display math', () => {
|
|
388
|
+
const blocks = parseMarkdown('$$\n[x]: /not-a-link\n$$\n\n[x]', {
|
|
389
|
+
math: true,
|
|
390
|
+
});
|
|
391
|
+
expect(blocks[0]).toEqual({type: 'math', value: '[x]: /not-a-link'});
|
|
392
|
+
expect(JSON.stringify(blocks[1])).not.toContain('"type":"link"');
|
|
393
|
+
});
|
|
394
|
+
|
|
273
395
|
it('parses blockquotes', () => {
|
|
274
396
|
const result = parseMarkdown('> This is a quote');
|
|
275
397
|
expect(result[0].type).toBe('blockquote');
|