@miliastry/quasar 1.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.
Files changed (172) hide show
  1. package/LICENSE +119 -0
  2. package/README.md +45 -0
  3. package/dist/Visuals/lyne.css +1027 -0
  4. package/dist/Visuals/osu.css +257 -0
  5. package/dist/index.d.mts +4563 -0
  6. package/dist/index.d.ts +4563 -0
  7. package/dist/index.js +11291 -0
  8. package/dist/index.mjs +11197 -0
  9. package/package.json +51 -0
  10. package/src/Analysis/Contracts/AnalysisReport.ts +26 -0
  11. package/src/Analysis/Contracts/Contribution.ts +76 -0
  12. package/src/Analysis/Contracts/Pass.ts +76 -0
  13. package/src/Analysis/Contracts/PipelineContext.ts +48 -0
  14. package/src/Analysis/Passes/Analysis/GradientAnalyzer.ts +292 -0
  15. package/src/Analysis/Passes/Analysis/MergeableColorAnalyzer.ts +112 -0
  16. package/src/Analysis/Passes/Analysis/RainbowAnalyzer.ts +233 -0
  17. package/src/Analysis/Passes/Analysis/WaveAnalyzer.ts +211 -0
  18. package/src/Analysis/Passes/Analysis/__tests__/GradientAnalyzer.test.ts +135 -0
  19. package/src/Analysis/Passes/Analysis/__tests__/MergeableColorAnalyzer.test.ts +84 -0
  20. package/src/Analysis/Passes/Analysis/__tests__/RainbowAnalyzer.test.ts +99 -0
  21. package/src/Analysis/Passes/Analysis/__tests__/WaveAnalyzer.test.ts +119 -0
  22. package/src/Analysis/Passes/Decision/DefaultDecision.ts +139 -0
  23. package/src/Analysis/Passes/Decision/__tests__/DefaultDecision.test.ts +179 -0
  24. package/src/Analysis/Passes/Transform/CollapseGradientTransform.ts +176 -0
  25. package/src/Analysis/Passes/Transform/MergeColorsTransform.ts +126 -0
  26. package/src/Analysis/Passes/Transform/RainbowCollapseTransform.ts +83 -0
  27. package/src/Analysis/Passes/Transform/WaveCollapseTransform.ts +88 -0
  28. package/src/Analysis/Passes/Utility/CharacterCountAnalyzer.ts +45 -0
  29. package/src/Analysis/Pipeline/Pipeline.ts +133 -0
  30. package/src/Analysis/Pipeline/PipelineBuilder.ts +55 -0
  31. package/src/Analysis/Pipeline/PipelineStage.ts +19 -0
  32. package/src/Analysis/Utils/color-utils.ts +132 -0
  33. package/src/Analysis/__tests__/Integration.test.ts +162 -0
  34. package/src/Analysis/__tests__/Pipeline.test.ts +133 -0
  35. package/src/Analysis/index.ts +52 -0
  36. package/src/BBCode/BBCodeDocumentModel.ts +175 -0
  37. package/src/BBCode/BBCodeToGreenNode.ts +755 -0
  38. package/src/BBCode/Parser.ts +384 -0
  39. package/src/BBCode/index.ts +12 -0
  40. package/src/Collab/positions.ts +91 -0
  41. package/src/Commands/Command.ts +44 -0
  42. package/src/Commands/CommandRegistry.ts +78 -0
  43. package/src/Commands/DeleteNode.ts +20 -0
  44. package/src/Commands/InsertText.ts +21 -0
  45. package/src/Commands/SplitMerge.ts +28 -0
  46. package/src/Commands/WrapInTag.ts +21 -0
  47. package/src/Commands/index.ts +6 -0
  48. package/src/Diff/TreeDiffer.ts +264 -0
  49. package/src/Diff/__tests__/TreeDiffer.test.ts +65 -0
  50. package/src/Diff/index.ts +2 -0
  51. package/src/Events/EventBus.ts +160 -0
  52. package/src/Events/index.ts +2 -0
  53. package/src/Formatter/Formatter.ts +54 -0
  54. package/src/Formatter/index.ts +2 -0
  55. package/src/HTML/HTMLDocumentModel.ts +35 -0
  56. package/src/HTML/HTMLToGreenNode.ts +290 -0
  57. package/src/Incremental/ChangeTracker.ts +105 -0
  58. package/src/Incremental/IncrementalParser.ts +591 -0
  59. package/src/Incremental/__tests__/IncrementalParser.test.ts +164 -0
  60. package/src/Incremental/index.ts +4 -0
  61. package/src/Lexer/BBCodeLexer.ts +382 -0
  62. package/src/Lexer/Lexer.ts +181 -0
  63. package/src/Lexer/index.ts +10 -0
  64. package/src/Linter/Linter.ts +193 -0
  65. package/src/Linter/index.ts +2 -0
  66. package/src/Markdown/MarkdownAST.ts +112 -0
  67. package/src/Markdown/MarkdownDocumentModel.ts +55 -0
  68. package/src/Markdown/MarkdownLexer.ts +203 -0
  69. package/src/Markdown/MarkdownParser.ts +455 -0
  70. package/src/Markdown/MarkdownToGreenNode.ts +153 -0
  71. package/src/Model/DocumentModel.ts +694 -0
  72. package/src/Model/NodeFactory.ts +117 -0
  73. package/src/Model/TagRegistry.ts +495 -0
  74. package/src/Model/index.ts +5 -0
  75. package/src/Plugins/PluginAPI.ts +119 -0
  76. package/src/Plugins/PluginRegistry.ts +132 -0
  77. package/src/Plugins/index.ts +3 -0
  78. package/src/Queries/QueryEngine.ts +152 -0
  79. package/src/Queries/index.ts +1 -0
  80. package/src/RenderPipeline/RenderPipeline.ts +125 -0
  81. package/src/RenderPipeline/RenderTree.ts +134 -0
  82. package/src/RenderPipeline/index.ts +4 -0
  83. package/src/Semantic/SemanticAnalyzer.ts +506 -0
  84. package/src/Semantic/index.ts +2 -0
  85. package/src/Symbols/SymbolTable.ts +124 -0
  86. package/src/Symbols/index.ts +1 -0
  87. package/src/Syntax/GreenNode.ts +324 -0
  88. package/src/Syntax/GreenNodePool.ts +269 -0
  89. package/src/Syntax/NodeMatcher.ts +370 -0
  90. package/src/Syntax/RedNode.ts +569 -0
  91. package/src/Syntax/RedNodeStore.ts +184 -0
  92. package/src/Syntax/TreeBuilder.ts +214 -0
  93. package/src/Syntax/__tests__/GreenNode.test.ts +33 -0
  94. package/src/Syntax/__tests__/RedNode.test.ts +81 -0
  95. package/src/Syntax/__tests__/RedNodeStore.test.ts +104 -0
  96. package/src/Syntax/greenEdit.ts +110 -0
  97. package/src/Syntax/hash.ts +30 -0
  98. package/src/Syntax/index.ts +12 -0
  99. package/src/Syntax/partition.ts +161 -0
  100. package/src/Syntax/preserveNodeIds.ts +201 -0
  101. package/src/Tests/ASTOptimizerIdempotence.test.ts +77 -0
  102. package/src/Tests/BlockPatcher.test.ts +437 -0
  103. package/src/Tests/BlockPatcherWindowed.test.ts +364 -0
  104. package/src/Tests/BoxDrawer.test.ts +217 -0
  105. package/src/Tests/BoxRichTitle.test.ts +105 -0
  106. package/src/Tests/Chars500kBenchmark.test.ts +151 -0
  107. package/src/Tests/Chars500kEdits.test.ts +321 -0
  108. package/src/Tests/CollabPositions.test.ts +146 -0
  109. package/src/Tests/CompilerPathProfiling.test.ts +186 -0
  110. package/src/Tests/DOMMorpher.test.ts +142 -0
  111. package/src/Tests/DomPatchPerf.test.ts +60 -0
  112. package/src/Tests/EffectSegments.snapshot.json +616 -0
  113. package/src/Tests/EffectSegments.test.ts +68 -0
  114. package/src/Tests/FindNodeAtOffset.test.ts +65 -0
  115. package/src/Tests/Fuzzer.test.ts +166 -0
  116. package/src/Tests/GreenNodePool.test.ts +153 -0
  117. package/src/Tests/Lexer.test.ts +238 -0
  118. package/src/Tests/LyneMode.test.ts +187 -0
  119. package/src/Tests/ModelCoherence.test.ts +180 -0
  120. package/src/Tests/Partition.test.ts +238 -0
  121. package/src/Tests/PluginTags.test.ts +150 -0
  122. package/src/Tests/ProblematicSection.test.ts +46 -0
  123. package/src/Tests/ProblematicSectionHTML.test.ts +58 -0
  124. package/src/Tests/RedReuse.test.ts +134 -0
  125. package/src/Tests/ReproDelete20k.test.ts +62 -0
  126. package/src/Tests/SemanticValidators.test.ts +136 -0
  127. package/src/Tests/StableNodeIds.test.ts +210 -0
  128. package/src/Tests/StudioColorBloat.test.ts +25 -0
  129. package/src/Tests/StudioDebugText.test.ts +27 -0
  130. package/src/Tests/StudioTrailingChar.test.ts +25 -0
  131. package/src/Tests/StudioValidText.test.ts +25 -0
  132. package/src/Tests/UrlImgBug.test.ts +23 -0
  133. package/src/Tests/VisualBuilderFidelity.test.ts +105 -0
  134. package/src/Tests/referenceDocument.ts +119 -0
  135. package/src/Transactions/Transaction.ts +176 -0
  136. package/src/Transactions/UndoManager.ts +111 -0
  137. package/src/Transactions/index.ts +3 -0
  138. package/src/Transformers/ASTOptimizer.ts +315 -0
  139. package/src/Transformers/GradientTransformer.ts +143 -0
  140. package/src/Transformers/GrowTransformer.ts +115 -0
  141. package/src/Transformers/RainbowTransformer.ts +121 -0
  142. package/src/Transformers/SineWaveTransformer.ts +130 -0
  143. package/src/Transformers/Transformer.ts +22 -0
  144. package/src/Types/core.ts +270 -0
  145. package/src/Types/diagnostics.ts +156 -0
  146. package/src/Types/index.ts +23 -0
  147. package/src/Types/operations.ts +180 -0
  148. package/src/Types/queries.ts +121 -0
  149. package/src/Types/symbols.ts +69 -0
  150. package/src/Types/tokens.ts +186 -0
  151. package/src/Utils/BBCodeGenerator.ts +126 -0
  152. package/src/Utils/ColorMath.ts +276 -0
  153. package/src/Utils/color.ts +112 -0
  154. package/src/Utils/dom-to-svg.test.ts +86 -0
  155. package/src/Utils/dom-to-svg.ts +615 -0
  156. package/src/Utils/treeTransformers.ts +717 -0
  157. package/src/Visitors/BBBlocksExporter.ts +69 -0
  158. package/src/Visitors/BBCodeExporter.ts +318 -0
  159. package/src/Visitors/BlockPatcher.ts +963 -0
  160. package/src/Visitors/DOMMorpher.ts +134 -0
  161. package/src/Visitors/HTMLRenderer.ts +1077 -0
  162. package/src/Visitors/JSONExporter.ts +66 -0
  163. package/src/Visitors/MarkdownExporter.ts +99 -0
  164. package/src/Visitors/SVGRenderer.ts +35 -0
  165. package/src/Visitors/TiptapExporter.ts +145 -0
  166. package/src/Visitors/Visitor.ts +48 -0
  167. package/src/Visitors/index.ts +9 -0
  168. package/src/Visuals/BoxDrawer.ts +175 -0
  169. package/src/Visuals/index.ts +42 -0
  170. package/src/Visuals/lyne.css +1027 -0
  171. package/src/Visuals/osu.css +257 -0
  172. package/src/index.ts +197 -0
package/LICENSE ADDED
@@ -0,0 +1,119 @@
1
+ MILIASTRY SOURCE LICENSE
2
+ Version 1.0 (MSL-1.0)
3
+
4
+ Copyright (c) 2026 hxovc / Miliastry Team
5
+
6
+ This license governs use of the software accompanying this license.
7
+ By using the software, you agree to the terms of this license.
8
+
9
+ 1. DEFINITIONS
10
+
11
+ "Software" means the source code and other materials distributed under
12
+ this license.
13
+
14
+ "Miliastry Nova" means the Miliastry Nova product, including its
15
+ integrated visual editing environment, user interface, workspace
16
+ architecture, and associated visual authoring capabilities, as
17
+ distributed by the copyright holder.
18
+
19
+ "Competing Product" means a software product or service whose primary
20
+ purpose is to compete directly with Miliastry Nova as an integrated
21
+ visual BBCode authoring environment or IDE, or to compete directly
22
+ with the Software itself.
23
+
24
+ A product is not a Competing Product merely because it:
25
+
26
+ (a) uses, depends upon, or incorporates the Software;
27
+
28
+ (b) provides BBCode editing capabilities;
29
+
30
+ (c) provides visual BBCode editing capabilities;
31
+
32
+ (d) provides tools for osu! profile creation or customization; or
33
+
34
+ (e) provides functionality that is technically similar to an individual
35
+ feature of Miliastry Nova.
36
+
37
+ The determination of whether a product is a Competing Product shall be
38
+ based on the product as a whole, including its primary purpose,
39
+ positioning, and intended use, rather than on the presence of individual
40
+ features.
41
+
42
+ 2. COPYRIGHT GRANT
43
+
44
+ Subject to the terms and limitations of this license, each contributor
45
+ grants you a perpetual, worldwide, non-exclusive, royalty-free license
46
+ to reproduce, modify, create derivative works from, and distribute the
47
+ Software and such derivative works.
48
+
49
+ 3. PATENT GRANT
50
+
51
+ Each contributor grants you a worldwide, non-exclusive, royalty-free
52
+ license under patent claims owned or controlled by that contributor
53
+ that necessarily read on their contribution to make, use, sell, offer
54
+ for sale, import, and otherwise distribute the Software.
55
+
56
+ 4. COMPETITION RESTRICTION
57
+
58
+ During the Restricted Period, you may not use the Software, or a
59
+ derivative work of the Software, as a substantial part of a Competing
60
+ Product.
61
+
62
+ This restriction applies only where the Software is used with the
63
+ purpose of creating, operating, or providing a product that directly
64
+ competes with Miliastry Nova.
65
+
66
+ This restriction does not prohibit the creation, distribution, or use of
67
+ general-purpose BBCode editors, osu! profile tools, BBCode libraries,
68
+ renderers, parsers, visual editors, authoring tools, or other software
69
+ that does not directly compete with Miliastry Nova or the Software itself.
70
+
71
+ 5. NO TRADEMARK RIGHTS
72
+
73
+ This license does not grant permission to use the names, logos,
74
+ trademarks, or other branding of Miliastry, Miliastry Nova, or any
75
+ contributor.
76
+
77
+ 6. RESTRICTED PERIOD
78
+
79
+ The restrictions in Section 4 apply for two (2) years beginning on the
80
+ date on which the applicable version of the Software is first publicly
81
+ released under this license.
82
+
83
+ After the Restricted Period expires, the Software is automatically
84
+ relicensed under the MIT License.
85
+
86
+ 7. CONTRIBUTIONS
87
+
88
+ Each contributor grants its contribution under this license unless the
89
+ contributor explicitly states otherwise.
90
+
91
+ Contributors do not receive any rights to use the trademarks or branding
92
+ of Miliastry.
93
+
94
+ 8. DISCLAIMER
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
97
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
98
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
99
+ NON-INFRINGEMENT.
100
+
101
+ 9. LIMITATION OF LIABILITY
102
+
103
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, NO CONTRIBUTOR SHALL BE LIABLE
104
+ FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM THE USE OF THE
105
+ SOFTWARE.
106
+
107
+ 10. TERMINATION
108
+
109
+ If you violate the restrictions of this license, the rights granted to
110
+ you under this license terminate automatically.
111
+
112
+ Rights that have already permanently converted to the MIT License are
113
+ not affected.
114
+
115
+ 11. GOVERNING INTERPRETATION
116
+
117
+ This license shall be interpreted to preserve the broad permission to
118
+ use the Software for purposes that do not directly compete with
119
+ Miliastry Nova.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ <div align="center">
2
+ <h1>🌌 Quasar Document Engine</h1>
3
+ <p><strong>Compiler-grade AST infrastructure for real-time document editing.</strong></p>
4
+ </div>
5
+
6
+ ---
7
+
8
+ > Traditional BBCode or Markdown parsers rely on brittle Regex that destroy user formatting, collapse on invalid syntax, and freeze the UI on large documents. **Quasar is different.**
9
+
10
+ Quasar is the official document engine powering **Miliastry Nova**. It brings the architectural patterns used by modern language compilers (like C#'s *Roslyn* and Apple's *SwiftSyntax*) directly into the browser and desktop using pure TypeScript.
11
+
12
+ Instead of translating strings to HTML, Quasar builds a living, immutable **Red-Green Syntax Tree**. It parses documents incrementally in microseconds, guarantees perfect round-tripping (preserving every single space and newline), and allows for real-time visual editing at 140 FPS.
13
+
14
+ ## ✨ The Core Philosophy
15
+
16
+ - 🌳 **Red-Green Syntax Tree**: An immutable, flyweight `GreenNode` core for structural sharing and memory deduplication, paired with a stateful `RedNode` facade for UI binding and cursor tracking.
17
+ - ⚡ **Incremental Parsing**: When a user types a single character in a 50KB document, Quasar only re-parses the affected span. Average mutation latency: `< 0.15ms`.
18
+ - 🛡️ **Error-Tolerant by Design**: The parser never crashes. Invalid syntax, unclosed tags, or malformed attributes simply produce `ErrorNodes` with diagnostics, keeping the rest of the AST intact.
19
+ - 🔄 **Perfect Round-Tripping**: "Trivia" (spaces, newlines, raw formatting) is strictly preserved. What the user types is exactly what is saved.
20
+ - 🔌 **Agnostic & Multi-Format**: While heavily optimized for BBCode, Quasar's Bridges support ingestion and emission of HTML, Markdown, and JSON ASTs.
21
+ - 📦 **Zero Runtime Dependencies**: Pure TypeScript. Runs natively in the Browser, Node.js, Deno, Bun, or Tauri.
22
+
23
+ ## 🚀 Installation
24
+
25
+ ```bash
26
+ npm install github:hxovc/Miliastry-Quasar#main
27
+ ```
28
+
29
+ *(Note: Quasar is currently distributed as a git submodule for Miliastry Nova)*
30
+
31
+ ## 📚 Documentation & Architecture
32
+
33
+ Quasar's internal architecture is highly advanced. If you want to understand how the parser pipeline works, how memory deduplication is achieved, or how to build AST transformers, start here:
34
+
35
+ - [**Naked Architecture (QuasarArch.MD)**](./QuasarArch.MD): Deep forensic analysis of the internal architecture, parsing pipeline, and modules.
36
+ - [**Roadmap (QuasarRoadmap.MD)**](./QuasarRoadmap.MD): Current and future state of the engine.
37
+ - [**Collaboration (QuasarCollab.MD)**](./QuasarCollab.MD): Contribution guidelines.
38
+
39
+ ---
40
+
41
+ ## 📜 License
42
+
43
+ [**Miliastry Source License (MSL-1.0)**](LICENSE) — Copyright (c) 2026 hxovc / Miliastry Team.
44
+
45
+ Quasar is Source-Available under a custom license designed to protect the Miliastry ecosystem. You can use, modify, and distribute the engine for any project—including standard visual BBCode editors or osu! profile tools—**except** for creating a Competing Product (i.e., a direct clone of Miliastry Nova as an integrated IDE, or a competing standalone engine based on this code). The license automatically converts to a standard MIT License 2 years after each commit.