@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
@@ -0,0 +1,616 @@
1
+ [
2
+ {
3
+ "kind": "gradient",
4
+ "text": "Hola Mundo",
5
+ "bb": "[color=#FF0000]H[/color][color=#C63900]o[/color][color=#8E7100]l[/color][color=#55AA00]a[/color][color=#1CE300] [/color][color=#00E31C]M[/color][color=#00AA55]u[/color][color=#00718E]n[/color][color=#0039C6]d[/color][color=#0000FF]o[/color]",
6
+ "rn": {
7
+ "kind": "gradient",
8
+ "text": "",
9
+ "children": [
10
+ {
11
+ "kind": "text",
12
+ "text": "H",
13
+ "children": [],
14
+ "props": {},
15
+ "style": {
16
+ "color": "#FF0000"
17
+ }
18
+ },
19
+ {
20
+ "kind": "text",
21
+ "text": "o",
22
+ "children": [],
23
+ "props": {},
24
+ "style": {
25
+ "color": "#C63900"
26
+ }
27
+ },
28
+ {
29
+ "kind": "text",
30
+ "text": "l",
31
+ "children": [],
32
+ "props": {},
33
+ "style": {
34
+ "color": "#8E7100"
35
+ }
36
+ },
37
+ {
38
+ "kind": "text",
39
+ "text": "a",
40
+ "children": [],
41
+ "props": {},
42
+ "style": {
43
+ "color": "#55AA00"
44
+ }
45
+ },
46
+ {
47
+ "kind": "text",
48
+ "text": " ",
49
+ "children": [],
50
+ "props": {},
51
+ "style": {
52
+ "color": "#1CE300"
53
+ }
54
+ },
55
+ {
56
+ "kind": "text",
57
+ "text": "M",
58
+ "children": [],
59
+ "props": {},
60
+ "style": {
61
+ "color": "#00E31C"
62
+ }
63
+ },
64
+ {
65
+ "kind": "text",
66
+ "text": "u",
67
+ "children": [],
68
+ "props": {},
69
+ "style": {
70
+ "color": "#00AA55"
71
+ }
72
+ },
73
+ {
74
+ "kind": "text",
75
+ "text": "n",
76
+ "children": [],
77
+ "props": {},
78
+ "style": {
79
+ "color": "#00718E"
80
+ }
81
+ },
82
+ {
83
+ "kind": "text",
84
+ "text": "d",
85
+ "children": [],
86
+ "props": {},
87
+ "style": {
88
+ "color": "#0039C6"
89
+ }
90
+ },
91
+ {
92
+ "kind": "text",
93
+ "text": "o",
94
+ "children": [],
95
+ "props": {},
96
+ "style": {
97
+ "color": "#0000FF"
98
+ }
99
+ }
100
+ ],
101
+ "props": {}
102
+ }
103
+ },
104
+ {
105
+ "kind": "gradient",
106
+ "text": "uno dos tres",
107
+ "bb": "[color=#112233]uno[/color][color=#1E2F40] [/color][color=#2B3C4D]dos[/color][color=#374859] [/color][color=#445566]tres[/color]",
108
+ "rn": {
109
+ "kind": "gradient",
110
+ "text": "",
111
+ "children": [
112
+ {
113
+ "kind": "text",
114
+ "text": "uno",
115
+ "children": [],
116
+ "props": {},
117
+ "style": {
118
+ "color": "#112233"
119
+ }
120
+ },
121
+ {
122
+ "kind": "text",
123
+ "text": " ",
124
+ "children": [],
125
+ "props": {},
126
+ "style": {
127
+ "color": "#1E2F40"
128
+ }
129
+ },
130
+ {
131
+ "kind": "text",
132
+ "text": "dos",
133
+ "children": [],
134
+ "props": {},
135
+ "style": {
136
+ "color": "#2B3C4D"
137
+ }
138
+ },
139
+ {
140
+ "kind": "text",
141
+ "text": " ",
142
+ "children": [],
143
+ "props": {},
144
+ "style": {
145
+ "color": "#374859"
146
+ }
147
+ },
148
+ {
149
+ "kind": "text",
150
+ "text": "tres",
151
+ "children": [],
152
+ "props": {},
153
+ "style": {
154
+ "color": "#445566"
155
+ }
156
+ }
157
+ ],
158
+ "props": {}
159
+ }
160
+ },
161
+ {
162
+ "kind": "gradient",
163
+ "text": "abcdef",
164
+ "bb": "[color=#FF66AB]a[/color][color=#FF66AB]b[/color][color=#FF66AB]c[/color][color=#FF66AB]d[/color][color=#FF66AB]e[/color][color=#FF66AB]f[/color]",
165
+ "rn": {
166
+ "kind": "gradient",
167
+ "text": "",
168
+ "children": [
169
+ {
170
+ "kind": "text",
171
+ "text": "a",
172
+ "children": [],
173
+ "props": {},
174
+ "style": {
175
+ "color": "#FF66AB"
176
+ }
177
+ },
178
+ {
179
+ "kind": "text",
180
+ "text": "b",
181
+ "children": [],
182
+ "props": {},
183
+ "style": {
184
+ "color": "#FF66AB"
185
+ }
186
+ },
187
+ {
188
+ "kind": "text",
189
+ "text": "c",
190
+ "children": [],
191
+ "props": {},
192
+ "style": {
193
+ "color": "#FF66AB"
194
+ }
195
+ },
196
+ {
197
+ "kind": "text",
198
+ "text": "d",
199
+ "children": [],
200
+ "props": {},
201
+ "style": {
202
+ "color": "#FF66AB"
203
+ }
204
+ },
205
+ {
206
+ "kind": "text",
207
+ "text": "e",
208
+ "children": [],
209
+ "props": {},
210
+ "style": {
211
+ "color": "#FF66AB"
212
+ }
213
+ },
214
+ {
215
+ "kind": "text",
216
+ "text": "f",
217
+ "children": [],
218
+ "props": {},
219
+ "style": {
220
+ "color": "#FF66AB"
221
+ }
222
+ }
223
+ ],
224
+ "props": {}
225
+ }
226
+ },
227
+ {
228
+ "kind": "sinewave",
229
+ "text": "ola marina",
230
+ "bb": "[size=60]o[/size][size=74]l[/size][size=85]a[/size][size=90] [/size][size=87]m[/size][size=78]a[/size][size=64]r[/size][size=49]i[/size][size=37]n[/size][size=31]a[/size]",
231
+ "rn": {
232
+ "kind": "sinewave",
233
+ "text": "",
234
+ "children": [
235
+ {
236
+ "kind": "text",
237
+ "text": "o",
238
+ "children": [],
239
+ "props": {},
240
+ "style": {
241
+ "fontSize": "60%"
242
+ }
243
+ },
244
+ {
245
+ "kind": "text",
246
+ "text": "l",
247
+ "children": [],
248
+ "props": {},
249
+ "style": {
250
+ "fontSize": "74%"
251
+ }
252
+ },
253
+ {
254
+ "kind": "text",
255
+ "text": "a",
256
+ "children": [],
257
+ "props": {},
258
+ "style": {
259
+ "fontSize": "85%"
260
+ }
261
+ },
262
+ {
263
+ "kind": "text",
264
+ "text": " ",
265
+ "children": [],
266
+ "props": {},
267
+ "style": {
268
+ "fontSize": "90%"
269
+ }
270
+ },
271
+ {
272
+ "kind": "text",
273
+ "text": "m",
274
+ "children": [],
275
+ "props": {},
276
+ "style": {
277
+ "fontSize": "87%"
278
+ }
279
+ },
280
+ {
281
+ "kind": "text",
282
+ "text": "a",
283
+ "children": [],
284
+ "props": {},
285
+ "style": {
286
+ "fontSize": "78%"
287
+ }
288
+ },
289
+ {
290
+ "kind": "text",
291
+ "text": "r",
292
+ "children": [],
293
+ "props": {},
294
+ "style": {
295
+ "fontSize": "64%"
296
+ }
297
+ },
298
+ {
299
+ "kind": "text",
300
+ "text": "i",
301
+ "children": [],
302
+ "props": {},
303
+ "style": {
304
+ "fontSize": "49%"
305
+ }
306
+ },
307
+ {
308
+ "kind": "text",
309
+ "text": "n",
310
+ "children": [],
311
+ "props": {},
312
+ "style": {
313
+ "fontSize": "37%"
314
+ }
315
+ },
316
+ {
317
+ "kind": "text",
318
+ "text": "a",
319
+ "children": [],
320
+ "props": {},
321
+ "style": {
322
+ "fontSize": "31%"
323
+ }
324
+ }
325
+ ],
326
+ "props": {}
327
+ }
328
+ },
329
+ {
330
+ "kind": "sinewave",
331
+ "text": "una frase con olas",
332
+ "bb": "[size=80]una[/size] [size=109]frase[/size] [size=120]con[/size] [size=107]olas[/size]",
333
+ "rn": {
334
+ "kind": "sinewave",
335
+ "text": "",
336
+ "children": [
337
+ {
338
+ "kind": "text",
339
+ "text": "una",
340
+ "children": [],
341
+ "props": {},
342
+ "style": {
343
+ "fontSize": "80%"
344
+ }
345
+ },
346
+ {
347
+ "kind": "text",
348
+ "text": " ",
349
+ "children": [],
350
+ "props": {},
351
+ "style": {}
352
+ },
353
+ {
354
+ "kind": "text",
355
+ "text": "frase",
356
+ "children": [],
357
+ "props": {},
358
+ "style": {
359
+ "fontSize": "109%"
360
+ }
361
+ },
362
+ {
363
+ "kind": "text",
364
+ "text": " ",
365
+ "children": [],
366
+ "props": {},
367
+ "style": {}
368
+ },
369
+ {
370
+ "kind": "text",
371
+ "text": "con",
372
+ "children": [],
373
+ "props": {},
374
+ "style": {
375
+ "fontSize": "120%"
376
+ }
377
+ },
378
+ {
379
+ "kind": "text",
380
+ "text": " ",
381
+ "children": [],
382
+ "props": {},
383
+ "style": {}
384
+ },
385
+ {
386
+ "kind": "text",
387
+ "text": "olas",
388
+ "children": [],
389
+ "props": {},
390
+ "style": {
391
+ "fontSize": "107%"
392
+ }
393
+ }
394
+ ],
395
+ "props": {}
396
+ }
397
+ },
398
+ {
399
+ "kind": "grow",
400
+ "text": "creciendo",
401
+ "bb": "[size=125]c[/size][size=200]r[/size][size=125]e[/size][size=50]c[/size][size=125]i[/size][size=200]e[/size][size=125]n[/size][size=50]d[/size][size=125]o[/size]",
402
+ "rn": {
403
+ "kind": "grow",
404
+ "text": "",
405
+ "children": [
406
+ {
407
+ "kind": "text",
408
+ "text": "c",
409
+ "children": [],
410
+ "props": {},
411
+ "style": {
412
+ "fontSize": "125%"
413
+ }
414
+ },
415
+ {
416
+ "kind": "text",
417
+ "text": "r",
418
+ "children": [],
419
+ "props": {},
420
+ "style": {
421
+ "fontSize": "200%"
422
+ }
423
+ },
424
+ {
425
+ "kind": "text",
426
+ "text": "e",
427
+ "children": [],
428
+ "props": {},
429
+ "style": {
430
+ "fontSize": "125%"
431
+ }
432
+ },
433
+ {
434
+ "kind": "text",
435
+ "text": "c",
436
+ "children": [],
437
+ "props": {},
438
+ "style": {
439
+ "fontSize": "50%"
440
+ }
441
+ },
442
+ {
443
+ "kind": "text",
444
+ "text": "i",
445
+ "children": [],
446
+ "props": {},
447
+ "style": {
448
+ "fontSize": "125%"
449
+ }
450
+ },
451
+ {
452
+ "kind": "text",
453
+ "text": "e",
454
+ "children": [],
455
+ "props": {},
456
+ "style": {
457
+ "fontSize": "200%"
458
+ }
459
+ },
460
+ {
461
+ "kind": "text",
462
+ "text": "n",
463
+ "children": [],
464
+ "props": {},
465
+ "style": {
466
+ "fontSize": "125%"
467
+ }
468
+ },
469
+ {
470
+ "kind": "text",
471
+ "text": "d",
472
+ "children": [],
473
+ "props": {},
474
+ "style": {
475
+ "fontSize": "50%"
476
+ }
477
+ },
478
+ {
479
+ "kind": "text",
480
+ "text": "o",
481
+ "children": [],
482
+ "props": {},
483
+ "style": {
484
+ "fontSize": "125%"
485
+ }
486
+ }
487
+ ],
488
+ "props": {}
489
+ }
490
+ },
491
+ {
492
+ "kind": "grow",
493
+ "text": "x",
494
+ "bb": "[size=114]x[/size]",
495
+ "rn": {
496
+ "kind": "grow",
497
+ "text": "",
498
+ "children": [
499
+ {
500
+ "kind": "text",
501
+ "text": "x",
502
+ "children": [],
503
+ "props": {},
504
+ "style": {
505
+ "fontSize": "114%"
506
+ }
507
+ }
508
+ ],
509
+ "props": {}
510
+ }
511
+ },
512
+ {
513
+ "kind": "rainbow",
514
+ "text": "arcoiris!",
515
+ "bb": "[color=#F45925]a[/color][color=#F4E225]r[/color][color=#7BF425]c[/color][color=#25F459]o[/color][color=#25F4E2]i[/color][color=#257BF4]r[/color][color=#5925F4]i[/color][color=#E225F4]s[/color][color=#F4257B]![/color]",
516
+ "rn": {
517
+ "kind": "rainbow",
518
+ "text": "",
519
+ "children": [
520
+ {
521
+ "kind": "text",
522
+ "text": "a",
523
+ "children": [],
524
+ "props": {},
525
+ "style": {
526
+ "color": "#F45925"
527
+ }
528
+ },
529
+ {
530
+ "kind": "text",
531
+ "text": "r",
532
+ "children": [],
533
+ "props": {},
534
+ "style": {
535
+ "color": "#F4E225"
536
+ }
537
+ },
538
+ {
539
+ "kind": "text",
540
+ "text": "c",
541
+ "children": [],
542
+ "props": {},
543
+ "style": {
544
+ "color": "#7BF425"
545
+ }
546
+ },
547
+ {
548
+ "kind": "text",
549
+ "text": "o",
550
+ "children": [],
551
+ "props": {},
552
+ "style": {
553
+ "color": "#25F459"
554
+ }
555
+ },
556
+ {
557
+ "kind": "text",
558
+ "text": "i",
559
+ "children": [],
560
+ "props": {},
561
+ "style": {
562
+ "color": "#25F4E2"
563
+ }
564
+ },
565
+ {
566
+ "kind": "text",
567
+ "text": "r",
568
+ "children": [],
569
+ "props": {},
570
+ "style": {
571
+ "color": "#257BF4"
572
+ }
573
+ },
574
+ {
575
+ "kind": "text",
576
+ "text": "i",
577
+ "children": [],
578
+ "props": {},
579
+ "style": {
580
+ "color": "#5925F4"
581
+ }
582
+ },
583
+ {
584
+ "kind": "text",
585
+ "text": "s",
586
+ "children": [],
587
+ "props": {},
588
+ "style": {
589
+ "color": "#E225F4"
590
+ }
591
+ },
592
+ {
593
+ "kind": "text",
594
+ "text": "!",
595
+ "children": [],
596
+ "props": {},
597
+ "style": {
598
+ "color": "#F4257B"
599
+ }
600
+ }
601
+ ],
602
+ "props": {}
603
+ }
604
+ },
605
+ {
606
+ "kind": "gradient",
607
+ "text": "",
608
+ "bb": "FALLBACK",
609
+ "rn": {
610
+ "kind": "gradient",
611
+ "text": "",
612
+ "children": [],
613
+ "props": {}
614
+ }
615
+ }
616
+ ]
@@ -0,0 +1,68 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { readFileSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
+ import { TagRegistry, type TagHandlerContext } from '../Model/TagRegistry'
5
+ import { RedNode } from '../Syntax/RedNode'
6
+ import { greenNode, greenLeaf } from '../Syntax/GreenNode'
7
+ import type { NodeKind, NodeMetadata } from '../Types/core'
8
+
9
+ /**
10
+ * The four effect tags (gradient, sinewave, grow, rainbow) serialize through
11
+ * ONE segment function each, presented two ways (toBBCode / toRenderNode).
12
+ * Before the consolidation, each handler carried its own copy of the math.
13
+ *
14
+ * The expected outputs in `EffectSegments.snapshot.json` were captured from
15
+ * the PRE-consolidation handlers, so this suite pins the refactor to byte
16
+ * equality with the originals — colors, sizes, word/whitespace handling,
17
+ * globalOffset/documentLength, empty-text fallbacks, everything.
18
+ *
19
+ * The inputs here must stay in sync with the snapshot's cases by index.
20
+ */
21
+
22
+ const CASES: Array<{ kind: string; text: string; metadata: NodeMetadata }> = [
23
+ { kind: 'gradient', text: 'Hola Mundo', metadata: { colors: ['#FF0000', '#00FF00', '#0000FF'], unit: 'character', easing: 'linear' } },
24
+ { kind: 'gradient', text: 'uno dos tres', metadata: { colors: ['#112233', '#445566'], unit: 'word', easing: 'ease-in' } },
25
+ { kind: 'gradient', text: 'abcdef', metadata: { colors: ['#FF66AB'], unit: 'character', easing: 'linear', globalOffset: 3, documentLength: 20 } },
26
+ { kind: 'sinewave', text: 'ola marina', metadata: { min: 30, max: 90, freq: 0.5, step: 'char' } },
27
+ { kind: 'sinewave', text: 'una frase con olas', metadata: { min: 40, max: 120, freq: 0.8, step: 'word' } },
28
+ { kind: 'grow', text: 'creciendo', metadata: { min: 50, max: 200, cycles: 2 } },
29
+ { kind: 'grow', text: 'x', metadata: { min: 50, max: 150, cycles: 1, globalOffset: 5, documentLength: 12 } },
30
+ { kind: 'rainbow', text: 'arcoiris!', metadata: { saturation: 90, lightness: 55, spread: 320, offset: 15 } },
31
+ { kind: 'gradient', text: '', metadata: { colors: ['#FF0000', '#00FF00'] } },
32
+ ]
33
+
34
+ interface SnapshotCase { kind: string; text: string; bb: string; rn: unknown }
35
+ const SNAPSHOT: SnapshotCase[] = JSON.parse(
36
+ readFileSync(join(__dirname, 'EffectSegments.snapshot.json'), 'utf8'),
37
+ )
38
+
39
+ function effectNode(kind: string, text: string, metadata: NodeMetadata): RedNode {
40
+ const leaf = greenLeaf('text', text)
41
+ const parent = new RedNode(greenNode(kind, '', [leaf]), { kind: kind as NodeKind, metadata })
42
+ parent.initChildren([new RedNode(leaf, { kind: 'text' })])
43
+ return parent
44
+ }
45
+
46
+ describe('effect handlers match the pre-consolidation outputs exactly', () => {
47
+ const registry = new TagRegistry()
48
+
49
+ CASES.forEach((c, i) => {
50
+ it(`${c.kind} ${JSON.stringify(c.text)}`, () => {
51
+ const expected = SNAPSHOT[i]
52
+ expect(expected.kind).toBe(c.kind)
53
+ expect(expected.text).toBe(c.text)
54
+
55
+ const node = effectNode(c.kind, c.text, c.metadata)
56
+ const def = registry.getByKind(c.kind as NodeKind)!
57
+ const ctx: TagHandlerContext = {
58
+ node,
59
+ source: '',
60
+ visitChildren: () => 'FALLBACK',
61
+ renderChild: () => ({ kind: 'text', text: '', children: [], props: {} }),
62
+ }
63
+
64
+ expect(def.toBBCode!(ctx)).toBe(expected.bb)
65
+ expect(JSON.parse(JSON.stringify(def.toRenderNode!(ctx)))).toEqual(expected.rn)
66
+ })
67
+ })
68
+ })