@miliastry/quasar 1.0.6 → 1.1.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/Visuals/lyne.css +117 -6
- package/dist/Visuals/osu.css +36 -5
- package/dist/index.js +9664 -3282
- package/dist/index.mjs +9535 -3283
- package/dist/types/Analysis/Contracts/AnalysisReport.d.ts +22 -0
- package/dist/types/Analysis/Contracts/Contribution.d.ts +68 -0
- package/dist/types/Analysis/Contracts/Pass.d.ts +59 -0
- package/dist/types/Analysis/Contracts/PipelineContext.d.ts +34 -0
- package/dist/types/Analysis/Passes/Analysis/ColorUsageAnalyzer.d.ts +56 -0
- package/dist/types/Analysis/Passes/Analysis/GradientAnalyzer.d.ts +111 -0
- package/dist/types/Analysis/Passes/Analysis/MergeableColorAnalyzer.d.ts +26 -0
- package/dist/types/Analysis/Passes/Analysis/RainbowAnalyzer.d.ts +47 -0
- package/dist/types/Analysis/Passes/Analysis/SymbolAnalyzer.d.ts +89 -0
- package/dist/types/Analysis/Passes/Analysis/WaveAnalyzer.d.ts +44 -0
- package/dist/types/Analysis/Passes/Analysis/__tests__/GradientAnalyzer.test.d.ts +4 -0
- package/dist/types/Analysis/Passes/Analysis/__tests__/MergeableColorAnalyzer.test.d.ts +4 -0
- package/dist/types/Analysis/Passes/Analysis/__tests__/RainbowAnalyzer.test.d.ts +4 -0
- package/dist/types/Analysis/Passes/Analysis/__tests__/WaveAnalyzer.test.d.ts +4 -0
- package/dist/types/Analysis/Passes/Decision/DefaultDecision.d.ts +30 -0
- package/dist/types/Analysis/Passes/Decision/PaletteRemapDecision.d.ts +169 -0
- package/dist/types/Analysis/Passes/Decision/__tests__/DefaultDecision.test.d.ts +4 -0
- package/dist/types/Analysis/Passes/Transform/CollapseGradientTransform.d.ts +37 -0
- package/dist/types/Analysis/Passes/Transform/MergeColorsTransform.d.ts +28 -0
- package/dist/types/Analysis/Passes/Transform/RainbowCollapseTransform.d.ts +19 -0
- package/dist/types/Analysis/Passes/Transform/WaveCollapseTransform.d.ts +20 -0
- package/dist/types/Analysis/Passes/Utility/CharacterCountAnalyzer.d.ts +19 -0
- package/dist/types/Analysis/Pipeline/Pipeline.d.ts +69 -0
- package/dist/types/Analysis/Pipeline/PipelineBuilder.d.ts +31 -0
- package/dist/types/Analysis/Pipeline/PipelineStage.d.ts +17 -0
- package/dist/types/Analysis/Utils/color-utils.d.ts +60 -0
- package/dist/types/Analysis/__tests__/Integration.test.d.ts +8 -0
- package/dist/types/Analysis/__tests__/PaletteRemap.test.d.ts +14 -0
- package/dist/types/Analysis/__tests__/Pipeline.test.d.ts +10 -0
- package/dist/types/Analysis/__tests__/RoundTrip.test.d.ts +30 -0
- package/dist/types/Analysis/__tests__/SymbolAnalyzer.test.d.ts +11 -0
- package/dist/types/Analysis/index.d.ts +40 -0
- package/dist/types/BBCode/BBCodeDocumentModel.d.ts +92 -0
- package/dist/types/BBCode/BBCodeToGreenNode.d.ts +111 -0
- package/dist/types/BBCode/Parser.d.ts +78 -0
- package/dist/types/BBCode/index.d.ts +4 -0
- package/dist/types/Collab/positions.d.ts +55 -0
- package/dist/types/Commands/Command.d.ts +37 -0
- package/dist/types/Commands/CommandRegistry.d.ts +48 -0
- package/dist/types/Commands/DeleteNode.d.ts +7 -0
- package/dist/types/Commands/InsertText.d.ts +8 -0
- package/dist/types/Commands/SplitMerge.d.ts +9 -0
- package/dist/types/Commands/WrapInTag.d.ts +8 -0
- package/dist/types/Commands/index.d.ts +6 -0
- package/dist/types/Diff/TreeDiffer.d.ts +52 -0
- package/dist/types/Diff/__tests__/TreeDiffer.test.d.ts +1 -0
- package/dist/types/Diff/index.d.ts +2 -0
- package/dist/types/Edits/EditPlan.d.ts +144 -0
- package/dist/types/Edits/Optimizer.d.ts +78 -0
- package/dist/types/Edits/Rules/Rule.d.ts +91 -0
- package/dist/types/Edits/Rules/dropEmptyTags.d.ts +40 -0
- package/dist/types/Edits/Rules/dropRedundantNesting.d.ts +59 -0
- package/dist/types/Edits/Rules/index.d.ts +9 -0
- package/dist/types/Edits/Rules/mergeAdjacent.d.ts +93 -0
- package/dist/types/Edits/Rules/reorderWrappers.d.ts +42 -0
- package/dist/types/Edits/Rules/shortenHex.d.ts +30 -0
- package/dist/types/Edits/Rules/tagValue.d.ts +56 -0
- package/dist/types/Edits/Rules/unwrapInvisibleColor.d.ts +47 -0
- package/dist/types/Edits/applyEdits.d.ts +36 -0
- package/dist/types/Edits/index.d.ts +6 -0
- package/dist/types/Events/EventBus.d.ts +103 -0
- package/dist/types/Events/index.d.ts +2 -0
- package/dist/types/Formatter/Formatter.d.ts +32 -0
- package/dist/types/Formatter/index.d.ts +2 -0
- package/dist/types/HTML/HTMLDocumentModel.d.ts +13 -0
- package/dist/types/HTML/HTMLToGreenNode.d.ts +4 -0
- package/dist/types/Incremental/BracketIndex.d.ts +101 -0
- package/dist/types/Incremental/ChangeTracker.d.ts +69 -0
- package/dist/types/Incremental/IncrementalParser.d.ts +246 -0
- package/dist/types/Incremental/__tests__/BracketIndex.test.d.ts +1 -0
- package/dist/types/Incremental/__tests__/IncrementalParser.test.d.ts +1 -0
- package/dist/types/Incremental/index.d.ts +4 -0
- package/dist/types/Lexer/BBCodeLexer.d.ts +74 -0
- package/dist/types/Lexer/Lexer.d.ts +54 -0
- package/dist/types/Lexer/index.d.ts +4 -0
- package/dist/types/Linter/Linter.d.ts +58 -0
- package/dist/types/Linter/index.d.ts +2 -0
- package/dist/types/Markdown/MarkdownAST.d.ts +122 -0
- package/dist/types/Markdown/MarkdownDocumentModel.d.ts +15 -0
- package/dist/types/Markdown/MarkdownLexer.d.ts +155 -0
- package/dist/types/Markdown/MarkdownParser.d.ts +42 -0
- package/dist/types/Markdown/MarkdownToGreenNode.d.ts +6 -0
- package/dist/types/MilHibri/MilHibriDocumentModel.d.ts +21 -0
- package/dist/types/Model/DocumentModel.d.ts +318 -0
- package/dist/types/Model/NodeFactory.d.ts +29 -0
- package/dist/types/Model/TagRegistry.d.ts +165 -0
- package/dist/types/Model/index.d.ts +5 -0
- package/dist/types/Plugins/PluginAPI.d.ts +44 -0
- package/dist/types/Plugins/PluginRegistry.d.ts +81 -0
- package/dist/types/Plugins/index.d.ts +3 -0
- package/dist/types/Queries/QueryEngine.d.ts +32 -0
- package/dist/types/Queries/index.d.ts +1 -0
- package/dist/types/Reconciler/SurgicalReconciler.d.ts +23 -0
- package/dist/types/RenderPipeline/RenderPipeline.d.ts +46 -0
- package/dist/types/RenderPipeline/RenderTree.d.ts +55 -0
- package/dist/types/RenderPipeline/index.d.ts +4 -0
- package/dist/types/Repair/NestingRepair.d.ts +48 -0
- package/dist/types/Repair/index.d.ts +1 -0
- package/dist/types/Semantic/SemanticAnalyzer.d.ts +321 -0
- package/dist/types/Semantic/index.d.ts +2 -0
- package/dist/types/Symbols/SymbolTable.d.ts +47 -0
- package/dist/types/Symbols/index.d.ts +1 -0
- package/dist/types/Syntax/GreenNode.d.ts +154 -0
- package/dist/types/Syntax/GreenNodePool.d.ts +134 -0
- package/dist/types/Syntax/NodeMatcher.d.ts +75 -0
- package/dist/types/Syntax/RedNode.d.ts +280 -0
- package/dist/types/Syntax/RedNodeStore.d.ts +116 -0
- package/dist/types/Syntax/TreeBuilder.d.ts +54 -0
- package/dist/types/Syntax/__tests__/GreenNode.test.d.ts +1 -0
- package/dist/types/Syntax/__tests__/RedNode.test.d.ts +1 -0
- package/dist/types/Syntax/__tests__/RedNodeStore.test.d.ts +1 -0
- package/dist/types/Syntax/greenEdit.d.ts +64 -0
- package/dist/types/Syntax/hash.d.ts +17 -0
- package/dist/types/Syntax/index.d.ts +8 -0
- package/dist/types/Syntax/nodeAttr.d.ts +63 -0
- package/dist/types/Syntax/partition.d.ts +67 -0
- package/dist/types/Syntax/preserveNodeIds.d.ts +47 -0
- package/dist/types/Tokens/TokenResolver.d.ts +25 -0
- package/dist/types/Tokens/index.d.ts +1 -0
- package/dist/types/Transactions/Transaction.d.ts +36 -0
- package/dist/types/Transactions/UndoManager.d.ts +63 -0
- package/dist/types/Transactions/index.d.ts +3 -0
- package/dist/types/Transformers/ASTOptimizer.d.ts +34 -0
- package/dist/types/Transformers/GradientTransformer.d.ts +18 -0
- package/dist/types/Transformers/GrowTransformer.d.ts +16 -0
- package/dist/types/Transformers/RainbowTransformer.d.ts +17 -0
- package/dist/types/Transformers/SineWaveTransformer.d.ts +17 -0
- package/dist/types/Transformers/Transformer.d.ts +17 -0
- package/dist/types/Types/core.d.ts +104 -0
- package/dist/types/Types/diagnostics.d.ts +85 -0
- package/dist/types/Types/index.d.ts +11 -0
- package/dist/types/Types/operations.d.ts +109 -0
- package/dist/types/Types/queries.d.ts +67 -0
- package/dist/types/Types/symbols.d.ts +42 -0
- package/dist/types/Types/tokens.d.ts +75 -0
- package/dist/types/Utils/BBCodeGenerator.d.ts +21 -0
- package/dist/types/Utils/ColorMath.d.ts +92 -0
- package/dist/types/Utils/EffectMath.d.ts +643 -0
- package/dist/types/Utils/TagVocabulary.d.ts +104 -0
- package/dist/types/Utils/TagVocabulary.test.d.ts +1 -0
- package/dist/types/Utils/color.d.ts +29 -0
- package/dist/types/Utils/dom-to-svg.d.ts +28 -0
- package/dist/types/Utils/dom-to-svg.test.d.ts +1 -0
- package/dist/types/Utils/treeTransformers.d.ts +160 -0
- package/dist/types/Visitors/BBBlocksExporter.d.ts +27 -0
- package/dist/types/Visitors/BBCodeExporter.d.ts +90 -0
- package/dist/types/Visitors/BlockPatcher.d.ts +91 -0
- package/dist/types/Visitors/DOMMorpher.d.ts +13 -0
- package/dist/types/Visitors/HTMLRenderer.d.ts +380 -0
- package/dist/types/Visitors/JSONExporter.d.ts +42 -0
- package/dist/types/Visitors/MarkdownExporter.d.ts +28 -0
- package/dist/types/Visitors/SVGRenderer.d.ts +16 -0
- package/dist/types/Visitors/TiptapExporter.d.ts +40 -0
- package/dist/types/Visitors/Visitor.d.ts +35 -0
- package/dist/types/Visitors/index.d.ts +9 -0
- package/dist/types/Visuals/BoxDrawer.d.ts +49 -0
- package/dist/types/Visuals/index.d.ts +38 -0
- package/dist/types/index.d.ts +154 -0
- package/package.json +14 -10
- package/src/Analysis/Passes/Analysis/ColorUsageAnalyzer.ts +103 -0
- package/src/Analysis/Passes/Analysis/GradientAnalyzer.ts +294 -20
- package/src/Analysis/Passes/Analysis/SymbolAnalyzer.ts +257 -0
- package/src/Analysis/Passes/Decision/PaletteRemapDecision.ts +425 -0
- package/src/Analysis/Pipeline/Pipeline.ts +15 -2
- package/src/Analysis/index.ts +8 -2
- package/src/BBCode/BBCodeDocumentModel.ts +3 -0
- package/src/BBCode/BBCodeToGreenNode.ts +18 -12
- package/src/BBCode/Parser.ts +38 -1
- package/src/Edits/EditPlan.ts +290 -0
- package/src/Edits/Optimizer.ts +185 -0
- package/src/Edits/Rules/Rule.ts +145 -0
- package/src/Edits/Rules/dropEmptyTags.ts +110 -0
- package/src/Edits/Rules/dropRedundantNesting.ts +120 -0
- package/src/Edits/Rules/index.ts +28 -0
- package/src/Edits/Rules/mergeAdjacent.ts +224 -0
- package/src/Edits/Rules/reorderWrappers.ts +154 -0
- package/src/Edits/Rules/shortenHex.ts +79 -0
- package/src/Edits/Rules/tagValue.ts +105 -0
- package/src/Edits/Rules/unwrapInvisibleColor.ts +93 -0
- package/src/Edits/applyEdits.ts +54 -0
- package/src/Edits/index.ts +22 -0
- package/src/Events/EventBus.ts +18 -0
- package/src/HTML/HTMLToGreenNode.ts +185 -37
- package/src/Incremental/BracketIndex.ts +249 -0
- package/src/Incremental/IncrementalParser.ts +464 -41
- package/src/Lexer/BBCodeLexer.ts +25 -3
- package/src/Lexer/index.ts +1 -1
- package/src/Markdown/MarkdownAST.ts +65 -2
- package/src/Markdown/MarkdownLexer.ts +69 -14
- package/src/Markdown/MarkdownParser.ts +749 -62
- package/src/Markdown/MarkdownToGreenNode.ts +148 -27
- package/src/MilHibri/MilHibriDocumentModel.ts +56 -0
- package/src/Model/DocumentModel.ts +138 -5
- package/src/Model/TagRegistry.ts +129 -134
- package/src/Reconciler/SurgicalReconciler.ts +460 -0
- package/src/Repair/NestingRepair.ts +116 -0
- package/src/Repair/index.ts +1 -0
- package/src/Semantic/SemanticAnalyzer.ts +1802 -65
- package/src/Syntax/GreenNodePool.ts +12 -12
- package/src/Syntax/RedNode.ts +17 -3
- package/src/Syntax/RedNodeStore.ts +9 -1
- package/src/Syntax/nodeAttr.ts +172 -0
- package/src/Tokens/TokenResolver.ts +55 -0
- package/src/Tokens/index.ts +1 -0
- package/src/Types/core.ts +15 -0
- package/src/Utils/ColorMath.ts +276 -55
- package/src/Utils/EffectMath.ts +2462 -0
- package/src/Utils/TagVocabulary.ts +141 -0
- package/src/Utils/dom-to-svg.ts +28 -12
- package/src/Visitors/BBBlocksExporter.ts +15 -1
- package/src/Visitors/BBCodeExporter.ts +319 -32
- package/src/Visitors/BlockPatcher.ts +87 -11
- package/src/Visitors/DOMMorpher.ts +15 -5
- package/src/Visitors/HTMLRenderer.ts +374 -151
- package/src/Visitors/MarkdownExporter.ts +98 -41
- package/src/Visitors/TiptapExporter.ts +1 -0
- package/src/Visuals/index.ts +7 -4
- package/src/Visuals/lyne.css +117 -6
- package/src/Visuals/osu.css +36 -5
- package/src/index.ts +172 -5
- package/dist/index.d.mts +0 -4612
- package/dist/index.d.ts +0 -4612
- package/src/Analysis/Passes/Analysis/__tests__/GradientAnalyzer.test.ts +0 -135
- package/src/Analysis/Passes/Analysis/__tests__/MergeableColorAnalyzer.test.ts +0 -84
- package/src/Analysis/Passes/Analysis/__tests__/RainbowAnalyzer.test.ts +0 -99
- package/src/Analysis/Passes/Analysis/__tests__/WaveAnalyzer.test.ts +0 -119
- package/src/Analysis/Passes/Decision/__tests__/DefaultDecision.test.ts +0 -179
- package/src/Analysis/__tests__/Integration.test.ts +0 -162
- package/src/Analysis/__tests__/Pipeline.test.ts +0 -133
- package/src/Diff/__tests__/TreeDiffer.test.ts +0 -65
- package/src/Incremental/__tests__/IncrementalParser.test.ts +0 -164
- package/src/Syntax/__tests__/GreenNode.test.ts +0 -33
- package/src/Syntax/__tests__/RedNode.test.ts +0 -81
- package/src/Syntax/__tests__/RedNodeStore.test.ts +0 -104
- package/src/Tests/ASTOptimizerIdempotence.test.ts +0 -77
- package/src/Tests/BlockPatcher.test.ts +0 -437
- package/src/Tests/BlockPatcherWindowed.test.ts +0 -364
- package/src/Tests/BoxDrawer.test.ts +0 -217
- package/src/Tests/BoxRichTitle.test.ts +0 -105
- package/src/Tests/Chars500kBenchmark.test.ts +0 -151
- package/src/Tests/Chars500kEdits.test.ts +0 -321
- package/src/Tests/CollabPositions.test.ts +0 -146
- package/src/Tests/CompilerPathProfiling.test.ts +0 -186
- package/src/Tests/DOMMorpher.test.ts +0 -142
- package/src/Tests/DomPatchPerf.test.ts +0 -60
- package/src/Tests/EffectSegments.snapshot.json +0 -616
- package/src/Tests/EffectSegments.test.ts +0 -68
- package/src/Tests/FindNodeAtOffset.test.ts +0 -65
- package/src/Tests/Fuzzer.test.ts +0 -166
- package/src/Tests/GreenNodePool.test.ts +0 -153
- package/src/Tests/Lexer.test.ts +0 -238
- package/src/Tests/LyneMode.test.ts +0 -291
- package/src/Tests/ModelCoherence.test.ts +0 -180
- package/src/Tests/Partition.test.ts +0 -238
- package/src/Tests/PluginTags.test.ts +0 -150
- package/src/Tests/ProblematicSection.test.ts +0 -46
- package/src/Tests/ProblematicSectionHTML.test.ts +0 -58
- package/src/Tests/RedReuse.test.ts +0 -134
- package/src/Tests/ReproDelete20k.test.ts +0 -62
- package/src/Tests/SemanticValidators.test.ts +0 -136
- package/src/Tests/StableNodeIds.test.ts +0 -210
- package/src/Tests/StudioColorBloat.test.ts +0 -25
- package/src/Tests/StudioDebugText.test.ts +0 -27
- package/src/Tests/StudioTrailingChar.test.ts +0 -25
- package/src/Tests/StudioValidText.test.ts +0 -25
- package/src/Tests/UrlImgBug.test.ts +0 -23
- package/src/Tests/VisualBuilderFidelity.test.ts +0 -105
- package/src/Tests/referenceDocument.ts +0 -119
- package/src/Utils/dom-to-svg.test.ts +0 -86
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEngine — BBCodeLexer
|
|
3
|
+
*
|
|
4
|
+
* A purpose-built lexer for BBCode that produces explicit newline tokens.
|
|
5
|
+
* This replaces the old BBCode parser's Tokenizer by producing a cleaner
|
|
6
|
+
* token stream that allows the parser to make semantic decisions about
|
|
7
|
+
* spacing (single vs double newlines → empty_line nodes).
|
|
8
|
+
*
|
|
9
|
+
* Unlike the generic Lexer base class, this is tuned specifically for BBCode
|
|
10
|
+
* syntax: [tag], [/tag], [tag=value], text content, and newlines.
|
|
11
|
+
*
|
|
12
|
+
* Token types:
|
|
13
|
+
* - open: [tag] or [tag=attrs]
|
|
14
|
+
* - close: [/tag]
|
|
15
|
+
* - text: Any content between tags (never includes newlines or brackets)
|
|
16
|
+
* - newline: \n or \r\n (explicit — not mixed into text tokens)
|
|
17
|
+
*
|
|
18
|
+
* Architecture: Pure function, no state, no class. Input → Output.
|
|
19
|
+
* Can be used in workers, SSR, or client-side without initialization.
|
|
20
|
+
*/
|
|
21
|
+
export interface BBCodeOpenToken {
|
|
22
|
+
kind: 'open';
|
|
23
|
+
tag: string;
|
|
24
|
+
attrs: string;
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
}
|
|
28
|
+
export interface BBCodeCloseToken {
|
|
29
|
+
kind: 'close';
|
|
30
|
+
tag: string;
|
|
31
|
+
start: number;
|
|
32
|
+
end: number;
|
|
33
|
+
}
|
|
34
|
+
export interface BBCodeTextToken {
|
|
35
|
+
kind: 'text';
|
|
36
|
+
value: string;
|
|
37
|
+
start: number;
|
|
38
|
+
end: number;
|
|
39
|
+
}
|
|
40
|
+
export interface BBCodeNewlineToken {
|
|
41
|
+
kind: 'newline';
|
|
42
|
+
value: string;
|
|
43
|
+
start: number;
|
|
44
|
+
end: number;
|
|
45
|
+
}
|
|
46
|
+
export type BBCodeToken = BBCodeOpenToken | BBCodeCloseToken | BBCodeTextToken | BBCodeNewlineToken;
|
|
47
|
+
/**
|
|
48
|
+
* Tags whose content is strictly literal: no inner tags, no newline tokens.
|
|
49
|
+
*
|
|
50
|
+
* Exported because the lexer is the ONLY authority on this. Consumers that
|
|
51
|
+
* have to reproduce the rule — a syntax highlighter deciding where to stop
|
|
52
|
+
* tokenising, an editor deciding whether to indent an inserted body — used to
|
|
53
|
+
* carry their own copy of `['code', 'c']`, which is a second lexer waiting to
|
|
54
|
+
* disagree with this one. Adding a raw tag here now reaches them.
|
|
55
|
+
*/
|
|
56
|
+
export declare const BBCODE_RAW_TAGS: readonly string[];
|
|
57
|
+
/**
|
|
58
|
+
* Scan BBCode source text into a flat array of tokens.
|
|
59
|
+
*
|
|
60
|
+
* The lexer distinguishes between:
|
|
61
|
+
* - Valid BBCode tags: [b], [color=red], [/b], [*]
|
|
62
|
+
* - Invalid syntax: [bogus stuff, [unclosed, lone [
|
|
63
|
+
*
|
|
64
|
+
* Invalid syntax is treated as plain text — the parser will never
|
|
65
|
+
* see malformed tokens.
|
|
66
|
+
*
|
|
67
|
+
* Newlines are always emitted as distinct tokens so the parser
|
|
68
|
+
* can precisely determine spacing semantics.
|
|
69
|
+
*/
|
|
70
|
+
export declare function scanBBCode(source: string): BBCodeToken[];
|
|
71
|
+
/**
|
|
72
|
+
* Debug: format tokens for inspection.
|
|
73
|
+
*/
|
|
74
|
+
export declare function formatTokens(tokens: BBCodeToken[]): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEngine — Lexer
|
|
3
|
+
*
|
|
4
|
+
* Tokenizes source text into a stream of Tokens with Trivia.
|
|
5
|
+
* Trivia includes whitespace, newlines, and formatting that is
|
|
6
|
+
* preserved in the token stream but not semantically significant.
|
|
7
|
+
*
|
|
8
|
+
* This is a LANGUAGE-INDEPENDENT lexer framework.
|
|
9
|
+
* Language-specific tokenization is provided via the LexerOptions.
|
|
10
|
+
*
|
|
11
|
+
* Inspired by Roslyn's lexer architecture.
|
|
12
|
+
*/
|
|
13
|
+
import type { Token, TokenStream } from '../Types/tokens';
|
|
14
|
+
import type { TokenKind } from '../Types/tokens';
|
|
15
|
+
export interface LexerRule {
|
|
16
|
+
/** Pattern to match at the current position */
|
|
17
|
+
pattern: RegExp;
|
|
18
|
+
/** Token kind to produce */
|
|
19
|
+
kind: TokenKind;
|
|
20
|
+
/** Optional: extract a name from the match (for tags) */
|
|
21
|
+
name?: (match: RegExpExecArray) => string;
|
|
22
|
+
/** Optional: extract attributes from the match */
|
|
23
|
+
attrs?: (match: RegExpExecArray) => string;
|
|
24
|
+
}
|
|
25
|
+
export interface LexerOptions {
|
|
26
|
+
/** Language-specific tokenization rules */
|
|
27
|
+
rules: LexerRule[];
|
|
28
|
+
/** Characters that count as whitespace trivia */
|
|
29
|
+
whitespaceChars?: RegExp;
|
|
30
|
+
/** Characters that start a newline trivia */
|
|
31
|
+
newlineChars?: RegExp;
|
|
32
|
+
/** Whether to collect trivia */
|
|
33
|
+
collectTrivia?: boolean;
|
|
34
|
+
/** Lexer hooks: called before each token */
|
|
35
|
+
onToken?: (token: Token) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare class Lexer {
|
|
38
|
+
private options;
|
|
39
|
+
private source;
|
|
40
|
+
private pos;
|
|
41
|
+
private tokens;
|
|
42
|
+
constructor(options: LexerOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Tokenize source text into a TokenStream.
|
|
45
|
+
*/
|
|
46
|
+
tokenize(source: string): TokenStream;
|
|
47
|
+
/**
|
|
48
|
+
* Re-tokenize a portion of the source (for incremental parsing).
|
|
49
|
+
* Returns just the new tokens for the affected range.
|
|
50
|
+
*/
|
|
51
|
+
retokenize(source: string, start: number, end: number): Token[];
|
|
52
|
+
private tryRules;
|
|
53
|
+
private scanTrivia;
|
|
54
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Lexer } from './Lexer';
|
|
2
|
+
export type { LexerOptions, LexerRule } from './Lexer';
|
|
3
|
+
export { scanBBCode, formatTokens, BBCODE_RAW_TAGS } from './BBCodeLexer';
|
|
4
|
+
export type { BBCodeToken, BBCodeOpenToken, BBCodeCloseToken, BBCodeTextToken, BBCodeNewlineToken, } from './BBCodeLexer';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEngine — Linter
|
|
3
|
+
*
|
|
4
|
+
* Lints the document tree for issues.
|
|
5
|
+
* Similar to ESLint but for BBCode documents.
|
|
6
|
+
*
|
|
7
|
+
* Rules can be added via the Plugin API.
|
|
8
|
+
*/
|
|
9
|
+
import { RedNode } from '../Syntax/RedNode';
|
|
10
|
+
export type LintSeverity = 'error' | 'warning' | 'info' | 'hint';
|
|
11
|
+
export interface LintRule {
|
|
12
|
+
code: string;
|
|
13
|
+
severity: LintSeverity;
|
|
14
|
+
description: string;
|
|
15
|
+
validate(node: RedNode, context: LintContext): LintIssue | LintIssue[] | null;
|
|
16
|
+
}
|
|
17
|
+
export interface LintContext {
|
|
18
|
+
source: string;
|
|
19
|
+
allNodes: Map<string, RedNode>;
|
|
20
|
+
}
|
|
21
|
+
export interface LintIssue {
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
severity: LintSeverity;
|
|
25
|
+
nodeId: string;
|
|
26
|
+
range: {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
} | null;
|
|
30
|
+
fix?: {
|
|
31
|
+
description: string;
|
|
32
|
+
apply: () => void;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface LintResult {
|
|
36
|
+
issues: LintIssue[];
|
|
37
|
+
errorCount: number;
|
|
38
|
+
warningCount: number;
|
|
39
|
+
infoCount: number;
|
|
40
|
+
hintCount: number;
|
|
41
|
+
}
|
|
42
|
+
export declare class Linter {
|
|
43
|
+
private rules;
|
|
44
|
+
constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Register a lint rule.
|
|
47
|
+
*/
|
|
48
|
+
register(rule: LintRule): void;
|
|
49
|
+
/**
|
|
50
|
+
* Unregister a lint rule.
|
|
51
|
+
*/
|
|
52
|
+
unregister(code: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Lint a RedNode tree.
|
|
55
|
+
*/
|
|
56
|
+
lint(root: RedNode, source: string): LintResult;
|
|
57
|
+
private registerBuiltinRules;
|
|
58
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEngine — Markdown AST Nodes
|
|
3
|
+
*/
|
|
4
|
+
export type MarkdownNode = MarkdownDocument | MarkdownParagraph | MarkdownHeading | MarkdownText | MarkdownCodeBlock | MarkdownCodeInline | MarkdownStrong | MarkdownEmphasis | MarkdownStrikethrough | MarkdownUnderline | MarkdownColor | MarkdownFontSize | MarkdownFont | MarkdownAlign | MarkdownBox | MarkdownSeparator | MarkdownLink | MarkdownImage | MarkdownList | MarkdownListItem | MarkdownBlockquote | MarkdownSpoiler | MarkdownNotice | MarkdownSpacing | MarkdownEmptyLine | MarkdownGenericBBNode;
|
|
5
|
+
export interface MarkdownGenericBBNode {
|
|
6
|
+
type: 'bbcode_tag';
|
|
7
|
+
tagName: string;
|
|
8
|
+
attrValue?: string;
|
|
9
|
+
children: MarkdownNode[];
|
|
10
|
+
}
|
|
11
|
+
export interface MarkdownDocument {
|
|
12
|
+
type: 'document';
|
|
13
|
+
children: MarkdownNode[];
|
|
14
|
+
}
|
|
15
|
+
export interface MarkdownParagraph {
|
|
16
|
+
type: 'paragraph';
|
|
17
|
+
children: MarkdownNode[];
|
|
18
|
+
}
|
|
19
|
+
export interface MarkdownHeading {
|
|
20
|
+
type: 'heading';
|
|
21
|
+
level: number;
|
|
22
|
+
children: MarkdownNode[];
|
|
23
|
+
}
|
|
24
|
+
export interface MarkdownText {
|
|
25
|
+
type: 'text';
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
export interface MarkdownCodeBlock {
|
|
29
|
+
type: 'code_block';
|
|
30
|
+
lang: string;
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MarkdownCodeInline {
|
|
34
|
+
type: 'code_inline';
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MarkdownStrong {
|
|
38
|
+
type: 'strong';
|
|
39
|
+
children: MarkdownNode[];
|
|
40
|
+
}
|
|
41
|
+
export interface MarkdownEmphasis {
|
|
42
|
+
type: 'emphasis';
|
|
43
|
+
children: MarkdownNode[];
|
|
44
|
+
}
|
|
45
|
+
export interface MarkdownLink {
|
|
46
|
+
type: 'link';
|
|
47
|
+
url: string;
|
|
48
|
+
children: MarkdownNode[];
|
|
49
|
+
}
|
|
50
|
+
export interface MarkdownImage {
|
|
51
|
+
type: 'image';
|
|
52
|
+
url: string;
|
|
53
|
+
alt: string;
|
|
54
|
+
}
|
|
55
|
+
export interface MarkdownList {
|
|
56
|
+
type: 'list';
|
|
57
|
+
ordered: boolean;
|
|
58
|
+
children: MarkdownListItem[];
|
|
59
|
+
}
|
|
60
|
+
export interface MarkdownListItem {
|
|
61
|
+
type: 'list_item';
|
|
62
|
+
children: MarkdownNode[];
|
|
63
|
+
}
|
|
64
|
+
export interface MarkdownBlockquote {
|
|
65
|
+
type: 'blockquote';
|
|
66
|
+
source?: string;
|
|
67
|
+
children: MarkdownNode[];
|
|
68
|
+
}
|
|
69
|
+
/** `>!` spoiler block — produced by MarkdownParser, maps to BBCode [spoiler]. */
|
|
70
|
+
export interface MarkdownSpoiler {
|
|
71
|
+
type: 'spoiler';
|
|
72
|
+
children: MarkdownNode[];
|
|
73
|
+
}
|
|
74
|
+
/** `> [!NOTE]` callout — produced by MarkdownParser, maps to BBCode [notice]. */
|
|
75
|
+
export interface MarkdownNotice {
|
|
76
|
+
type: 'notice' | 'wnotice';
|
|
77
|
+
color?: string;
|
|
78
|
+
children: MarkdownNode[];
|
|
79
|
+
}
|
|
80
|
+
export interface MarkdownSpacing {
|
|
81
|
+
type: 'spacing';
|
|
82
|
+
}
|
|
83
|
+
export interface MarkdownEmptyLine {
|
|
84
|
+
type: 'empty_line';
|
|
85
|
+
}
|
|
86
|
+
export interface MarkdownStrikethrough {
|
|
87
|
+
type: 'strikethrough';
|
|
88
|
+
children: MarkdownNode[];
|
|
89
|
+
}
|
|
90
|
+
export interface MarkdownUnderline {
|
|
91
|
+
type: 'underline';
|
|
92
|
+
children: MarkdownNode[];
|
|
93
|
+
}
|
|
94
|
+
export interface MarkdownColor {
|
|
95
|
+
type: 'color';
|
|
96
|
+
color: string;
|
|
97
|
+
children: MarkdownNode[];
|
|
98
|
+
}
|
|
99
|
+
export interface MarkdownFontSize {
|
|
100
|
+
type: 'font_size';
|
|
101
|
+
size: string;
|
|
102
|
+
children: MarkdownNode[];
|
|
103
|
+
}
|
|
104
|
+
export interface MarkdownFont {
|
|
105
|
+
type: 'font';
|
|
106
|
+
font: string;
|
|
107
|
+
children: MarkdownNode[];
|
|
108
|
+
}
|
|
109
|
+
export interface MarkdownAlign {
|
|
110
|
+
type: 'align' | 'center' | 'right' | 'left';
|
|
111
|
+
children: MarkdownNode[];
|
|
112
|
+
}
|
|
113
|
+
export interface MarkdownBox {
|
|
114
|
+
type: 'box' | 'spoilerbox';
|
|
115
|
+
title?: string;
|
|
116
|
+
rawTitle?: string;
|
|
117
|
+
color?: string;
|
|
118
|
+
children: MarkdownNode[];
|
|
119
|
+
}
|
|
120
|
+
export interface MarkdownSeparator {
|
|
121
|
+
type: 'separator';
|
|
122
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DocumentModel, type DocumentModelOptions } from '../Model/DocumentModel';
|
|
2
|
+
import { GreenNode } from '../Syntax/GreenNode';
|
|
3
|
+
import { RedNode } from '../Syntax/RedNode';
|
|
4
|
+
export interface MarkdownDocumentModelOptions extends DocumentModelOptions {
|
|
5
|
+
source?: string;
|
|
6
|
+
language?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class MarkdownDocumentModel extends DocumentModel {
|
|
9
|
+
constructor(options?: MarkdownDocumentModelOptions);
|
|
10
|
+
static fromMarkdown(source: string): MarkdownDocumentModel;
|
|
11
|
+
protected parseToGreen(source: string): GreenNode;
|
|
12
|
+
protected buildRedFromGreen(green: GreenNode): RedNode;
|
|
13
|
+
applyTextUpdate(newSource: string): void;
|
|
14
|
+
applyChange(change: any): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEngine — MarkdownLexer
|
|
3
|
+
*
|
|
4
|
+
* Tokenizes standard Markdown into a flat token stream.
|
|
5
|
+
* Produces explicit newline tokens for the parser to make semantic
|
|
6
|
+
* decisions about paragraph breaks.
|
|
7
|
+
*/
|
|
8
|
+
export interface MarkdownHashToken {
|
|
9
|
+
kind: 'hash';
|
|
10
|
+
value: string;
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}
|
|
14
|
+
export interface MarkdownGtToken {
|
|
15
|
+
kind: 'gt';
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
}
|
|
19
|
+
export interface MarkdownStarToken {
|
|
20
|
+
kind: 'star';
|
|
21
|
+
value: string;
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
}
|
|
25
|
+
export interface MarkdownUnderscoreToken {
|
|
26
|
+
kind: 'underscore';
|
|
27
|
+
value: string;
|
|
28
|
+
start: number;
|
|
29
|
+
end: number;
|
|
30
|
+
}
|
|
31
|
+
export interface MarkdownTildeToken {
|
|
32
|
+
kind: 'tilde';
|
|
33
|
+
value: string;
|
|
34
|
+
start: number;
|
|
35
|
+
end: number;
|
|
36
|
+
}
|
|
37
|
+
export interface MarkdownBacktickToken {
|
|
38
|
+
kind: 'backtick';
|
|
39
|
+
value: string;
|
|
40
|
+
start: number;
|
|
41
|
+
end: number;
|
|
42
|
+
}
|
|
43
|
+
export interface MarkdownBracketOpenToken {
|
|
44
|
+
kind: 'bracket_open';
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
}
|
|
48
|
+
export interface MarkdownBracketCloseToken {
|
|
49
|
+
kind: 'bracket_close';
|
|
50
|
+
start: number;
|
|
51
|
+
end: number;
|
|
52
|
+
}
|
|
53
|
+
export interface MarkdownBraceOpenToken {
|
|
54
|
+
kind: 'brace_open';
|
|
55
|
+
start: number;
|
|
56
|
+
end: number;
|
|
57
|
+
}
|
|
58
|
+
export interface MarkdownBraceCloseToken {
|
|
59
|
+
kind: 'brace_close';
|
|
60
|
+
start: number;
|
|
61
|
+
end: number;
|
|
62
|
+
}
|
|
63
|
+
export interface MarkdownParenOpenToken {
|
|
64
|
+
kind: 'paren_open';
|
|
65
|
+
start: number;
|
|
66
|
+
end: number;
|
|
67
|
+
}
|
|
68
|
+
export interface MarkdownParenCloseToken {
|
|
69
|
+
kind: 'paren_close';
|
|
70
|
+
start: number;
|
|
71
|
+
end: number;
|
|
72
|
+
}
|
|
73
|
+
export interface MarkdownBangToken {
|
|
74
|
+
kind: 'bang';
|
|
75
|
+
start: number;
|
|
76
|
+
end: number;
|
|
77
|
+
}
|
|
78
|
+
export interface MarkdownDashToken {
|
|
79
|
+
kind: 'dash';
|
|
80
|
+
value: string;
|
|
81
|
+
start: number;
|
|
82
|
+
end: number;
|
|
83
|
+
}
|
|
84
|
+
export interface MarkdownPlusToken {
|
|
85
|
+
kind: 'plus';
|
|
86
|
+
value: string;
|
|
87
|
+
start: number;
|
|
88
|
+
end: number;
|
|
89
|
+
}
|
|
90
|
+
export interface MarkdownDotToken {
|
|
91
|
+
kind: 'dot';
|
|
92
|
+
start: number;
|
|
93
|
+
end: number;
|
|
94
|
+
}
|
|
95
|
+
export interface MarkdownColonToken {
|
|
96
|
+
kind: 'colon';
|
|
97
|
+
value: string;
|
|
98
|
+
start: number;
|
|
99
|
+
end: number;
|
|
100
|
+
}
|
|
101
|
+
export interface MarkdownContainerToken {
|
|
102
|
+
kind: 'container';
|
|
103
|
+
value: string;
|
|
104
|
+
info: string;
|
|
105
|
+
start: number;
|
|
106
|
+
end: number;
|
|
107
|
+
}
|
|
108
|
+
export interface MarkdownArrowToken {
|
|
109
|
+
kind: 'arrow_right' | 'arrow_left';
|
|
110
|
+
value: string;
|
|
111
|
+
start: number;
|
|
112
|
+
end: number;
|
|
113
|
+
}
|
|
114
|
+
export interface MarkdownTextToken {
|
|
115
|
+
kind: 'text';
|
|
116
|
+
value: string;
|
|
117
|
+
start: number;
|
|
118
|
+
end: number;
|
|
119
|
+
}
|
|
120
|
+
export interface MarkdownNewlineToken {
|
|
121
|
+
kind: 'newline';
|
|
122
|
+
value: string;
|
|
123
|
+
start: number;
|
|
124
|
+
end: number;
|
|
125
|
+
}
|
|
126
|
+
export interface MarkdownFenceToken {
|
|
127
|
+
kind: 'fence';
|
|
128
|
+
value: string;
|
|
129
|
+
lang: string;
|
|
130
|
+
start: number;
|
|
131
|
+
end: number;
|
|
132
|
+
}
|
|
133
|
+
export interface MarkdownHrToken {
|
|
134
|
+
kind: 'hr';
|
|
135
|
+
start: number;
|
|
136
|
+
end: number;
|
|
137
|
+
}
|
|
138
|
+
export interface MarkdownEscapeToken {
|
|
139
|
+
kind: 'escape';
|
|
140
|
+
value: string;
|
|
141
|
+
start: number;
|
|
142
|
+
end: number;
|
|
143
|
+
}
|
|
144
|
+
export interface MarkdownAngleToken {
|
|
145
|
+
kind: 'angle';
|
|
146
|
+
value: string;
|
|
147
|
+
start: number;
|
|
148
|
+
end: number;
|
|
149
|
+
}
|
|
150
|
+
export type MarkdownToken = MarkdownHashToken | MarkdownGtToken | MarkdownStarToken | MarkdownUnderscoreToken | MarkdownTildeToken | MarkdownBacktickToken | MarkdownBracketOpenToken | MarkdownBracketCloseToken | MarkdownBraceOpenToken | MarkdownBraceCloseToken | MarkdownParenOpenToken | MarkdownParenCloseToken | MarkdownBangToken | MarkdownDashToken | MarkdownPlusToken | MarkdownDotToken | MarkdownColonToken | MarkdownContainerToken | MarkdownArrowToken | MarkdownTextToken | MarkdownNewlineToken | MarkdownFenceToken | MarkdownHrToken | MarkdownEscapeToken | MarkdownAngleToken;
|
|
151
|
+
/**
|
|
152
|
+
* Scan Markdown source text into tokens.
|
|
153
|
+
* Pure function: input → output, no state.
|
|
154
|
+
*/
|
|
155
|
+
export declare function scanMarkdown(source: string): MarkdownToken[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MarkdownToken } from './MarkdownLexer';
|
|
2
|
+
import { MarkdownNode, MarkdownDocument } from './MarkdownAST';
|
|
3
|
+
/**
|
|
4
|
+
* DocumentEngine — MarkdownParser
|
|
5
|
+
*
|
|
6
|
+
* Parses Markdown tokens with hybrid BBCode embedding support into a typed AST.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MarkdownParser {
|
|
9
|
+
private tokens;
|
|
10
|
+
private current;
|
|
11
|
+
constructor(tokens: MarkdownToken[]);
|
|
12
|
+
parse(): MarkdownDocument;
|
|
13
|
+
private parseBlock;
|
|
14
|
+
private parseHeading;
|
|
15
|
+
private parseBlockquote;
|
|
16
|
+
private parseNotice;
|
|
17
|
+
private parseContainer;
|
|
18
|
+
private tokenValue;
|
|
19
|
+
private parseFence;
|
|
20
|
+
private isListStart;
|
|
21
|
+
private isOrderedListStart;
|
|
22
|
+
private parseList;
|
|
23
|
+
private parseParagraph;
|
|
24
|
+
parseInline(terminator?: {
|
|
25
|
+
kind: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
}): MarkdownNode | null;
|
|
28
|
+
private createAttributeSpanNode;
|
|
29
|
+
private peekBBCodeOpenTag;
|
|
30
|
+
private peekBBCodeCloseTag;
|
|
31
|
+
private isMatchingCloseTag;
|
|
32
|
+
private parseBBCodeBlock;
|
|
33
|
+
private parseBBCodeInline;
|
|
34
|
+
private createBBCodeNode;
|
|
35
|
+
private peek;
|
|
36
|
+
private previous;
|
|
37
|
+
private isAtEnd;
|
|
38
|
+
private advance;
|
|
39
|
+
private check;
|
|
40
|
+
private match;
|
|
41
|
+
}
|
|
42
|
+
export declare function parseMarkdown(tokens: MarkdownToken[]): MarkdownDocument;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GreenNode } from '../Syntax/GreenNode';
|
|
2
|
+
import { RedNode } from '../Syntax/RedNode';
|
|
3
|
+
import type { MarkdownNode } from './MarkdownAST';
|
|
4
|
+
export declare function markdownAstToGreenTree(root: MarkdownNode): GreenNode;
|
|
5
|
+
export declare function greenToRedNode(green: GreenNode, parent?: RedNode | null): RedNode;
|
|
6
|
+
export declare function markdownAstToRedTree(root: MarkdownNode): RedNode;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DocumentModel, type DocumentModelOptions } from '../Model/DocumentModel';
|
|
2
|
+
import { GreenNode } from '../Syntax/GreenNode';
|
|
3
|
+
import { RedNode } from '../Syntax/RedNode';
|
|
4
|
+
export interface MilHibriDocumentModelOptions extends DocumentModelOptions {
|
|
5
|
+
source?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* DocumentEngine — MilHibriDocumentModel
|
|
9
|
+
*
|
|
10
|
+
* First-class DocumentModel for the MilHibri language:
|
|
11
|
+
* Unifies 100% of osu! BBCode and 100% of Markdown + Modern Industry Extensions
|
|
12
|
+
* into a single unified, collision-free AST.
|
|
13
|
+
*/
|
|
14
|
+
export declare class MilHibriDocumentModel extends DocumentModel {
|
|
15
|
+
constructor(options?: MilHibriDocumentModelOptions);
|
|
16
|
+
static fromSource(source: string): MilHibriDocumentModel;
|
|
17
|
+
protected parseToGreen(source: string): GreenNode;
|
|
18
|
+
protected buildRedFromGreen(green: GreenNode): RedNode;
|
|
19
|
+
applyTextUpdate(newSource: string): void;
|
|
20
|
+
applyChange(change: any): void;
|
|
21
|
+
}
|