@tiqian/protocol 0.0.0-stage → 0.1.0-alpha.10

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 (228) hide show
  1. package/dist/haxe/crypto/Sha256.d.ts +19 -0
  2. package/dist/haxe/crypto/Sha256.js +194 -0
  3. package/dist/org/tiqian/clreq/AdjustmentStylePolicy.d.ts +11 -0
  4. package/dist/org/tiqian/clreq/AdjustmentStylePolicy.js +21 -0
  5. package/dist/org/tiqian/clreq/AutoSpaceMode.d.ts +16 -0
  6. package/dist/org/tiqian/clreq/AutoSpaceMode.js +17 -0
  7. package/dist/org/tiqian/clreq/AutoSpacePolicy.d.ts +13 -0
  8. package/dist/org/tiqian/clreq/AutoSpacePolicy.js +23 -0
  9. package/dist/org/tiqian/clreq/BopomofoReading.d.ts +12 -0
  10. package/dist/org/tiqian/clreq/BopomofoReading.js +86 -0
  11. package/dist/org/tiqian/clreq/BopomofoTone.d.ts +28 -0
  12. package/dist/org/tiqian/clreq/BopomofoTone.js +26 -0
  13. package/dist/org/tiqian/clreq/CjkPunctuationGlyphPolicy.d.ts +16 -0
  14. package/dist/org/tiqian/clreq/CjkPunctuationGlyphPolicy.js +17 -0
  15. package/dist/org/tiqian/clreq/ClreqProfile.d.ts +27 -0
  16. package/dist/org/tiqian/clreq/ClreqProfile.js +58 -0
  17. package/dist/org/tiqian/clreq/ClreqRegion.d.ts +20 -0
  18. package/dist/org/tiqian/clreq/ClreqRegion.js +20 -0
  19. package/dist/org/tiqian/clreq/ClreqStrictness.d.ts +16 -0
  20. package/dist/org/tiqian/clreq/ClreqStrictness.js +17 -0
  21. package/dist/org/tiqian/clreq/GlueSide.d.ts +16 -0
  22. package/dist/org/tiqian/clreq/GlueSide.js +17 -0
  23. package/dist/org/tiqian/clreq/HangingPunctuationStyle.d.ts +12 -0
  24. package/dist/org/tiqian/clreq/HangingPunctuationStyle.js +14 -0
  25. package/dist/org/tiqian/clreq/InteriorPunctuationStyle.d.ts +12 -0
  26. package/dist/org/tiqian/clreq/InteriorPunctuationStyle.js +14 -0
  27. package/dist/org/tiqian/clreq/KinsokuLevel.d.ts +20 -0
  28. package/dist/org/tiqian/clreq/KinsokuLevel.js +20 -0
  29. package/dist/org/tiqian/clreq/KinsokuMode.d.ts +14 -0
  30. package/dist/org/tiqian/clreq/KinsokuMode.js +2 -0
  31. package/dist/org/tiqian/clreq/KinsokuModes.d.ts +11 -0
  32. package/dist/org/tiqian/clreq/KinsokuModes.js +71 -0
  33. package/dist/org/tiqian/clreq/LineAdjustmentStrategy.d.ts +16 -0
  34. package/dist/org/tiqian/clreq/LineAdjustmentStrategy.js +17 -0
  35. package/dist/org/tiqian/clreq/LineEndPunctuationStyle.d.ts +12 -0
  36. package/dist/org/tiqian/clreq/LineEndPunctuationStyle.js +14 -0
  37. package/dist/org/tiqian/clreq/PunctuationClass.d.ts +44 -0
  38. package/dist/org/tiqian/clreq/PunctuationClass.js +38 -0
  39. package/dist/org/tiqian/clreq/PunctuationGluePlacement.d.ts +12 -0
  40. package/dist/org/tiqian/clreq/PunctuationGluePlacement.js +14 -0
  41. package/dist/org/tiqian/clreq/PunctuationGluePlacements.d.ts +9 -0
  42. package/dist/org/tiqian/clreq/PunctuationGluePlacements.js +49 -0
  43. package/dist/org/tiqian/clreq/PunctuationWidthPolicy.d.ts +8 -0
  44. package/dist/org/tiqian/clreq/PunctuationWidthPolicy.js +16 -0
  45. package/dist/org/tiqian/clreq/ResolvedKinsoku.d.ts +12 -0
  46. package/dist/org/tiqian/clreq/ResolvedKinsoku.js +43 -0
  47. package/dist/org/tiqian/core/Cluster.d.ts +13 -0
  48. package/dist/org/tiqian/core/Cluster.js +24 -0
  49. package/dist/org/tiqian/core/EastAsianSpacingData.d.ts +4 -0
  50. package/dist/org/tiqian/core/EastAsianSpacingData.js +399 -0
  51. package/dist/org/tiqian/core/EastAsianSpacingEdges.d.ts +8 -0
  52. package/dist/org/tiqian/core/EastAsianSpacingEdges.js +14 -0
  53. package/dist/org/tiqian/core/EastAsianSpacingValue.d.ts +20 -0
  54. package/dist/org/tiqian/core/EastAsianSpacingValue.js +20 -0
  55. package/dist/org/tiqian/core/Ic.d.ts +7 -0
  56. package/dist/org/tiqian/core/Ic.js +17 -0
  57. package/dist/org/tiqian/core/IllegalStateException.d.ts +4 -0
  58. package/dist/org/tiqian/core/IllegalStateException.js +8 -0
  59. package/dist/org/tiqian/core/IntRange.d.ts +12 -0
  60. package/dist/org/tiqian/core/IntRange.js +30 -0
  61. package/dist/org/tiqian/core/LineEndReason.d.ts +16 -0
  62. package/dist/org/tiqian/core/LineEndReason.js +17 -0
  63. package/dist/org/tiqian/core/SourceBoundaryBias.d.ts +16 -0
  64. package/dist/org/tiqian/core/SourceBoundaryBias.js +17 -0
  65. package/dist/org/tiqian/core/SourceInteractionBoundaries.d.ts +29 -0
  66. package/dist/org/tiqian/core/SourceInteractionBoundaries.js +193 -0
  67. package/dist/org/tiqian/core/TextRange.d.ts +11 -0
  68. package/dist/org/tiqian/core/TextRange.js +40 -0
  69. package/dist/org/tiqian/core/TextRangeError.d.ts +11 -0
  70. package/dist/org/tiqian/core/TextRangeError.js +2 -0
  71. package/dist/org/tiqian/core/TiqianIllegalArgumentException.d.ts +6 -0
  72. package/dist/org/tiqian/core/TiqianIllegalArgumentException.js +21 -0
  73. package/dist/org/tiqian/core/TiqianNoSuchElementException.d.ts +10 -0
  74. package/dist/org/tiqian/core/TiqianNoSuchElementException.js +16 -0
  75. package/dist/org/tiqian/core/UnicodeCombiningMarkData.d.ts +3 -0
  76. package/dist/org/tiqian/core/UnicodeCombiningMarkData.js +109 -0
  77. package/dist/org/tiqian/core/UnicodeEastAsianSpacing.d.ts +16 -0
  78. package/dist/org/tiqian/core/UnicodeEastAsianSpacing.js +88 -0
  79. package/dist/org/tiqian/core/UnicodeEmojiModifierBaseData.d.ts +3 -0
  80. package/dist/org/tiqian/core/UnicodeEmojiModifierBaseData.js +35 -0
  81. package/dist/org/tiqian/core/UnicodeExtendedPictographicData.d.ts +3 -0
  82. package/dist/org/tiqian/core/UnicodeExtendedPictographicData.js +64 -0
  83. package/dist/org/tiqian/core/UnicodeNumber.d.ts +3 -0
  84. package/dist/org/tiqian/core/UnicodeNumber.js +14 -0
  85. package/dist/org/tiqian/core/UnicodeNumberData.d.ts +3 -0
  86. package/dist/org/tiqian/core/UnicodeNumberData.js +64 -0
  87. package/dist/org/tiqian/core/UnicodeScriptEvidence.d.ts +16 -0
  88. package/dist/org/tiqian/core/UnicodeScriptEvidence.js +17 -0
  89. package/dist/org/tiqian/core/UnicodeScriptEvidenceClassifier.d.ts +7 -0
  90. package/dist/org/tiqian/core/UnicodeScriptEvidenceClassifier.js +17 -0
  91. package/dist/org/tiqian/core/UnicodeScriptEvidenceData.d.ts +4 -0
  92. package/dist/org/tiqian/core/UnicodeScriptEvidenceData.js +295 -0
  93. package/dist/org/tiqian/core/UnicodeWordCharacter.d.ts +6 -0
  94. package/dist/org/tiqian/core/UnicodeWordCharacter.js +17 -0
  95. package/dist/org/tiqian/core/UnicodeWordCharacterData.d.ts +3 -0
  96. package/dist/org/tiqian/core/UnicodeWordCharacterData.js +234 -0
  97. package/dist/org/tiqian/font/FontRole.d.ts +28 -0
  98. package/dist/org/tiqian/font/FontRole.js +26 -0
  99. package/dist/org/tiqian/font/FontRoleContext.d.ts +13 -0
  100. package/dist/org/tiqian/font/FontRoleContext.js +28 -0
  101. package/dist/org/tiqian/layout/ContextualQuoteRoleResolver.d.ts +51 -0
  102. package/dist/org/tiqian/layout/ContextualQuoteRoleResolver.js +305 -0
  103. package/dist/org/tiqian/layout/LineOptimization.d.ts +124 -0
  104. package/dist/org/tiqian/layout/LineOptimization.js +298 -0
  105. package/dist/org/tiqian/layout/ProgressiveBreakDecisions.d.ts +86 -0
  106. package/dist/org/tiqian/layout/ProgressiveBreakDecisions.js +415 -0
  107. package/dist/org/tiqian/layout/ProgressiveBreakTierPriority.d.ts +5 -0
  108. package/dist/org/tiqian/layout/ProgressiveBreakTierPriority.js +33 -0
  109. package/dist/org/tiqian/layout/QuotePairAnalyzer.d.ts +63 -0
  110. package/dist/org/tiqian/layout/QuotePairAnalyzer.js +251 -0
  111. package/dist/org/tiqian/linebreak/BreakKind.d.ts +20 -0
  112. package/dist/org/tiqian/linebreak/BreakKind.js +20 -0
  113. package/dist/org/tiqian/protocol/Canonical.d.ts +55 -0
  114. package/dist/org/tiqian/protocol/Canonical.js +471 -0
  115. package/dist/org/tiqian/protocol/DecorationInput.d.ts +6 -0
  116. package/dist/org/tiqian/protocol/DecorationInput.js +12 -0
  117. package/dist/org/tiqian/protocol/EncodeResult.d.ts +9 -0
  118. package/dist/org/tiqian/protocol/EncodeResult.js +2 -0
  119. package/dist/org/tiqian/protocol/FaceInfo.d.ts +13 -0
  120. package/dist/org/tiqian/protocol/FaceInfo.js +2 -0
  121. package/dist/org/tiqian/protocol/FontContract.d.ts +25 -0
  122. package/dist/org/tiqian/protocol/FontContract.js +317 -0
  123. package/dist/org/tiqian/protocol/FontFaceRecord.d.ts +6 -0
  124. package/dist/org/tiqian/protocol/FontFaceRecord.js +2 -0
  125. package/dist/org/tiqian/protocol/FontFaceSpec.d.ts +11 -0
  126. package/dist/org/tiqian/protocol/FontFaceSpec.js +2 -0
  127. package/dist/org/tiqian/protocol/FontWeightSpec.d.ts +10 -0
  128. package/dist/org/tiqian/protocol/FontWeightSpec.js +2 -0
  129. package/dist/org/tiqian/protocol/InlineBoxInput.d.ts +7 -0
  130. package/dist/org/tiqian/protocol/InlineBoxInput.js +2 -0
  131. package/dist/org/tiqian/protocol/InlineObjectInput.d.ts +7 -0
  132. package/dist/org/tiqian/protocol/InlineObjectInput.js +2 -0
  133. package/dist/org/tiqian/protocol/JsCoerce.d.ts +19 -0
  134. package/dist/org/tiqian/protocol/JsCoerce.js +394 -0
  135. package/dist/org/tiqian/protocol/LayoutAttribute.d.ts +5 -0
  136. package/dist/org/tiqian/protocol/LayoutAttribute.js +10 -0
  137. package/dist/org/tiqian/protocol/LayoutFloatShape.d.ts +14 -0
  138. package/dist/org/tiqian/protocol/LayoutFloatShape.js +2 -0
  139. package/dist/org/tiqian/protocol/LayoutTree.d.ts +23 -0
  140. package/dist/org/tiqian/protocol/LayoutTree.js +2 -0
  141. package/dist/org/tiqian/protocol/LayoutVertex.d.ts +4 -0
  142. package/dist/org/tiqian/protocol/LayoutVertex.js +2 -0
  143. package/dist/org/tiqian/protocol/LineBreakSpanInput.d.ts +6 -0
  144. package/dist/org/tiqian/protocol/LineBreakSpanInput.js +12 -0
  145. package/dist/org/tiqian/protocol/MetricEntry.d.ts +11 -0
  146. package/dist/org/tiqian/protocol/MetricEntry.js +21 -0
  147. package/dist/org/tiqian/protocol/NamedError.d.ts +88 -0
  148. package/dist/org/tiqian/protocol/NamedError.js +71 -0
  149. package/dist/org/tiqian/protocol/NamedErrorNames.d.ts +5 -0
  150. package/dist/org/tiqian/protocol/NamedErrorNames.js +53 -0
  151. package/dist/org/tiqian/protocol/ParagraphRequest.d.ts +25 -0
  152. package/dist/org/tiqian/protocol/ParagraphRequest.js +2 -0
  153. package/dist/org/tiqian/protocol/ParagraphRequestChecks.d.ts +8 -0
  154. package/dist/org/tiqian/protocol/ParagraphRequestChecks.js +145 -0
  155. package/dist/org/tiqian/protocol/ParagraphRequestException.d.ts +6 -0
  156. package/dist/org/tiqian/protocol/ParagraphRequestException.js +55 -0
  157. package/dist/org/tiqian/protocol/ParagraphRequestFields.d.ts +3 -0
  158. package/dist/org/tiqian/protocol/ParagraphRequestFields.js +4 -0
  159. package/dist/org/tiqian/protocol/Plan.d.ts +101 -0
  160. package/dist/org/tiqian/protocol/Plan.js +10 -0
  161. package/dist/org/tiqian/protocol/PlanEndReason.d.ts +16 -0
  162. package/dist/org/tiqian/protocol/PlanEndReason.js +17 -0
  163. package/dist/org/tiqian/protocol/PlanJsonNumber.d.ts +43 -0
  164. package/dist/org/tiqian/protocol/PlanJsonNumber.js +362 -0
  165. package/dist/org/tiqian/protocol/PlanSchema.d.ts +4 -0
  166. package/dist/org/tiqian/protocol/PlanSchema.js +5 -0
  167. package/dist/org/tiqian/protocol/PlanStyleDelta.d.ts +5 -0
  168. package/dist/org/tiqian/protocol/PlanStyleDelta.js +2 -0
  169. package/dist/org/tiqian/protocol/Revision.d.ts +11 -0
  170. package/dist/org/tiqian/protocol/Revision.js +12 -0
  171. package/dist/org/tiqian/protocol/SessionFaceSpec.d.ts +5 -0
  172. package/dist/org/tiqian/protocol/SessionFaceSpec.js +2 -0
  173. package/dist/org/tiqian/protocol/SnapshotTableBinary.d.ts +55 -0
  174. package/dist/org/tiqian/protocol/SnapshotTableBinary.js +657 -0
  175. package/dist/org/tiqian/protocol/SnapshotTypography.d.ts +14 -0
  176. package/dist/org/tiqian/protocol/SnapshotTypography.js +2 -0
  177. package/dist/org/tiqian/protocol/StyleRow.d.ts +8 -0
  178. package/dist/org/tiqian/protocol/StyleRow.js +15 -0
  179. package/dist/org/tiqian/protocol/TableData.d.ts +25 -0
  180. package/dist/org/tiqian/protocol/TableData.js +45 -0
  181. package/dist/org/tiqian/protocol/TableInput.d.ts +13 -0
  182. package/dist/org/tiqian/protocol/TableInput.js +21 -0
  183. package/dist/org/tiqian/protocol/TableMetricRow.d.ts +9 -0
  184. package/dist/org/tiqian/protocol/TableMetricRow.js +17 -0
  185. package/dist/org/tiqian/protocol/TableProbe.d.ts +11 -0
  186. package/dist/org/tiqian/protocol/TableProbe.js +21 -0
  187. package/dist/org/tiqian/protocol/TextSpanInput.d.ts +9 -0
  188. package/dist/org/tiqian/protocol/TextSpanInput.js +2 -0
  189. package/dist/org/tiqian/protocol/ValueRow.d.ts +4 -0
  190. package/dist/org/tiqian/protocol/ValueRow.js +7 -0
  191. package/dist/org/tiqian/protocol/WireField.d.ts +5 -0
  192. package/dist/org/tiqian/protocol/WireField.js +2 -0
  193. package/dist/org/tiqian/protocol/WireValue.d.ts +25 -0
  194. package/dist/org/tiqian/protocol/WireValue.js +2 -0
  195. package/dist/org/tiqian/test/TestHelpers.d.ts +5 -0
  196. package/dist/org/tiqian/test/TestHelpers.js +27 -0
  197. package/dist/org/tiqian/test/trace/TestTrace.d.ts +6 -0
  198. package/dist/org/tiqian/test/trace/TestTrace.js +8 -0
  199. package/dist/org/tiqian/test/trace/TestTracePlatform.d.ts +6 -0
  200. package/dist/org/tiqian/test/trace/TestTracePlatform.js +78 -0
  201. package/dist/org/tiqian/test/trace/TestTraceRecorder.d.ts +9 -0
  202. package/dist/org/tiqian/test/trace/TestTraceRecorder.js +36 -0
  203. package/dist/org/tiqian/test/trace/TestTraceRender.d.ts +47 -0
  204. package/dist/org/tiqian/test/trace/TestTraceRender.js +690 -0
  205. package/dist/org/tiqian/test/trace/TestTraceStore.d.ts +18 -0
  206. package/dist/org/tiqian/test/trace/TestTraceStore.js +149 -0
  207. package/dist/org/tiqian/test/trace/TraceAssertionError.d.ts +5 -0
  208. package/dist/org/tiqian/test/trace/TraceAssertionError.js +2 -0
  209. package/dist/org/tiqian/test/trace/TraceAssertionException.d.ts +6 -0
  210. package/dist/org/tiqian/test/trace/TraceAssertionException.js +16 -0
  211. package/dist/org/tiqian/test/trace/TraceField.d.ts +5 -0
  212. package/dist/org/tiqian/test/trace/TraceField.js +10 -0
  213. package/dist/org/tiqian/test/trace/TraceFormat.d.ts +21 -0
  214. package/dist/org/tiqian/test/trace/TraceFormat.js +184 -0
  215. package/dist/org/tiqian/test/trace/TracedAssertions.d.ts +78 -0
  216. package/dist/org/tiqian/test/trace/TracedAssertions.js +749 -0
  217. package/dist/runtime.d.ts +96 -0
  218. package/dist/runtime.js +1612 -0
  219. package/dist/std/FsError.d.ts +48 -0
  220. package/dist/std/FsError.js +2 -0
  221. package/dist/std/FsException.d.ts +6 -0
  222. package/dist/std/FsException.js +45 -0
  223. package/dist/std/UStringException.d.ts +6 -0
  224. package/dist/std/UStringException.js +21 -0
  225. package/dist/std/UStringFault.d.ts +9 -0
  226. package/dist/std/UStringFault.js +2 -0
  227. package/package.json +26 -4
  228. package/README.md +0 -3
@@ -0,0 +1,415 @@
1
+ // Generated by the reflaxe TypeScript target. Do not edit.
2
+ import { ProgressiveBreakTierPriority } from "./ProgressiveBreakTierPriority.js";
3
+ import { SortedTable } from "../../../runtime.js";
4
+ export class ProgressiveBreakOpportunity {
5
+ tier;
6
+ spanRange;
7
+ precedingWhitespaceStretchCapacity;
8
+ constructor(tier, spanRange, precedingWhitespaceStretchCapacity = null) {
9
+ this.tier = tier;
10
+ this.spanRange = spanRange;
11
+ this.precedingWhitespaceStretchCapacity = precedingWhitespaceStretchCapacity ?? 0.0;
12
+ }
13
+ toString() {
14
+ return `ProgressiveBreakOpportunity(tier=${this.tier.kind}, spanRange=${this.spanRange.toString()}, precedingWhitespaceStretchCapacity=${this.precedingWhitespaceStretchCapacity})`;
15
+ }
16
+ }
17
+ export function lineLimit(maxWidth, firstLineIndent, lineStartCluster) {
18
+ return (lineStartCluster === 0 ? maxWidth - firstLineIndent : maxWidth);
19
+ }
20
+ export class ProgressiveBreakDecisions {
21
+ static decideProgressiveBreak(lineStart, overflowAt, opportunities, adjustedClusters, lineLimit, cjkInterCharBoundaries, maxCjkStretchPerGap, sinoWesternBoundaries, sinoWesternStretchCap) {
22
+ adjustedClusters = adjustedClusters ?? null;
23
+ lineLimit = lineLimit ?? null;
24
+ cjkInterCharBoundaries = cjkInterCharBoundaries ?? null;
25
+ maxCjkStretchPerGap = maxCjkStretchPerGap ?? null;
26
+ sinoWesternBoundaries = sinoWesternBoundaries ?? null;
27
+ sinoWesternStretchCap = sinoWesternStretchCap ?? null;
28
+ const limit = lineLimit ?? Infinity;
29
+ const cjk = cjkInterCharBoundaries ?? SortedTable.setBuilder(SortedTable.compareInts).build();
30
+ const max = maxCjkStretchPerGap ?? Infinity;
31
+ const sino = sinoWesternBoundaries ?? SortedTable.setBuilder(SortedTable.compareInts).build();
32
+ const cap = sinoWesternStretchCap ?? 0.0;
33
+ const active = opportunities.get(overflowAt);
34
+ if (active === null) {
35
+ return overflowAt;
36
+ }
37
+ const bestPriority = ProgressiveBreakDecisions.progressiveBreakPriorityForLine(lineStart, overflowAt, (active), opportunities, adjustedClusters, (limit), (cjk), (max), (sino), (cap));
38
+ let best = null;
39
+ let boundary = lineStart + 1;
40
+ while (boundary <= overflowAt) {
41
+ const o = opportunities.get(boundary);
42
+ if (o !== null && o.spanRange.start === active.spanRange.start && o.spanRange.end === active.spanRange.end && ProgressiveBreakTierPriority.priority(o.tier) === bestPriority && (best === null || boundary > best)) {
43
+ best = boundary;
44
+ }
45
+ boundary++;
46
+ }
47
+ return (best === null ? overflowAt : best);
48
+ }
49
+ static progressiveCandidateAllowed(lineStart, rawGreedy, candidateEnd, opportunities, adjustedClusters, lineLimit, cjkInterCharBoundaries, maxCjkStretchPerGap, sinoWesternBoundaries, sinoWesternStretchCap) {
50
+ adjustedClusters = adjustedClusters ?? null;
51
+ lineLimit = lineLimit ?? null;
52
+ cjkInterCharBoundaries = cjkInterCharBoundaries ?? null;
53
+ maxCjkStretchPerGap = maxCjkStretchPerGap ?? null;
54
+ sinoWesternBoundaries = sinoWesternBoundaries ?? null;
55
+ sinoWesternStretchCap = sinoWesternStretchCap ?? null;
56
+ const limit = lineLimit ?? Infinity;
57
+ const cjk = cjkInterCharBoundaries ?? SortedTable.setBuilder(SortedTable.compareInts).build();
58
+ const max = maxCjkStretchPerGap ?? Infinity;
59
+ const sino = sinoWesternBoundaries ?? SortedTable.setBuilder(SortedTable.compareInts).build();
60
+ const cap = sinoWesternStretchCap ?? 0.0;
61
+ const active = opportunities.get(rawGreedy);
62
+ if (active === null) {
63
+ return true;
64
+ }
65
+ const candidate = opportunities.get(candidateEnd);
66
+ if (candidate === null) {
67
+ if (adjustedClusters === null || candidateEnd < 0 || candidateEnd >= adjustedClusters.length) {
68
+ return true;
69
+ }
70
+ const source = adjustedClusters[candidateEnd].range.start;
71
+ return source <= active.spanRange.start || source >= active.spanRange.end;
72
+ }
73
+ if (candidate.spanRange.start !== active.spanRange.start || candidate.spanRange.end !== active.spanRange.end) {
74
+ return true;
75
+ }
76
+ if (candidateEnd > rawGreedy) {
77
+ return ProgressiveBreakTierPriority.priority(candidate.tier) <= ProgressiveBreakTierPriority.priority(active.tier);
78
+ }
79
+ const selected = ProgressiveBreakDecisions.decideProgressiveBreak(lineStart, rawGreedy, opportunities, adjustedClusters, limit, cjk, max, sino, cap);
80
+ return candidateEnd === selected;
81
+ }
82
+ static progressiveBreakPriorityForLine(lineStart, overflowAt, active, opportunities, adjustedClusters, lineLimit, cjkInterCharBoundaries, maxCjkStretchPerGap, sinoWesternBoundaries, sinoWesternStretchCap) {
83
+ const prioritiesBuilder = SortedTable.setBuilder(SortedTable.compareInts);
84
+ let i = lineStart + 1;
85
+ while (i <= overflowAt) {
86
+ const o = opportunities.get(i);
87
+ if (o !== null && o.spanRange.start === active.spanRange.start && o.spanRange.end === active.spanRange.end) {
88
+ prioritiesBuilder.put(ProgressiveBreakTierPriority.priority(o.tier));
89
+ }
90
+ i++;
91
+ }
92
+ const priorities = prioritiesBuilder.build();
93
+ if (priorities.size() === 0) {
94
+ return ProgressiveBreakTierPriority.priority(active.tier);
95
+ }
96
+ if (adjustedClusters === null || !Number.isFinite(lineLimit) || !Number.isFinite(maxCjkStretchPerGap)) {
97
+ return priorities.at(0);
98
+ }
99
+ const stretch = maxCjkStretchPerGap * 0.0;
100
+ let least = priorities.at(0);
101
+ let density = Infinity;
102
+ let leastBoundary = lineStart + 1;
103
+ let pi = 0;
104
+ while (pi < priorities.size()) {
105
+ const priority = priorities.at(pi);
106
+ let b = 0;
107
+ i = lineStart + 1;
108
+ while (i <= overflowAt) {
109
+ const o2 = opportunities.get(i);
110
+ if (o2 !== null && o2.spanRange.start === active.spanRange.start && o2.spanRange.end === active.spanRange.end && ProgressiveBreakTierPriority.priority(o2.tier) === priority) {
111
+ b = i;
112
+ }
113
+ i++;
114
+ }
115
+ if (b === 0) {
116
+ pi++;
117
+ continue;
118
+ }
119
+ const d = ProgressiveBreakDecisions.progressiveCandidateStretchDensity(lineStart, b, opportunities, (adjustedClusters), lineLimit, cjkInterCharBoundaries, sinoWesternBoundaries, sinoWesternStretchCap);
120
+ if (d < density) {
121
+ density = d;
122
+ least = priority;
123
+ leastBoundary = b;
124
+ }
125
+ if (d <= stretch) {
126
+ return priority;
127
+ }
128
+ pi++;
129
+ }
130
+ let emergency = 0;
131
+ i = lineStart + 1;
132
+ while (i <= overflowAt) {
133
+ const o3 = opportunities.get(i);
134
+ if (o3 !== null && o3.spanRange.start === active.spanRange.start && o3.spanRange.end === active.spanRange.end && o3.tier.kind === "Emergency") {
135
+ emergency = i;
136
+ }
137
+ i++;
138
+ }
139
+ return (emergency !== 0 && emergency >= leastBoundary ? ProgressiveBreakTierPriority.priority(ProgressiveBreakTier.Emergency) : least);
140
+ }
141
+ static progressiveCandidateStretchDensity(lineStart, boundary, opportunities, adjustedClusters, lineLimit, cjkInterCharBoundaries, sinoWesternBoundaries, sinoWesternStretchCap) {
142
+ let width = 0.0;
143
+ let i = lineStart;
144
+ while (i < boundary) {
145
+ width += adjustedClusters[i].advance;
146
+ i++;
147
+ }
148
+ const deficit = Math.max(lineLimit - width, 0);
149
+ let technical = 0.0;
150
+ i = lineStart + 1;
151
+ while (i < boundary) {
152
+ const o = opportunities.get(i);
153
+ if (o !== null && o.tier.kind === "Whitespace") {
154
+ technical += o.precedingWhitespaceStretchCapacity;
155
+ }
156
+ i++;
157
+ }
158
+ let sino = 0;
159
+ i = lineStart + 1;
160
+ while (i < boundary) {
161
+ if (sinoWesternBoundaries.has(i)) {
162
+ sino++;
163
+ }
164
+ i++;
165
+ }
166
+ const cjkDeficit = Math.max(deficit - technical - sino * sinoWesternStretchCap, 0);
167
+ const active = opportunities.get(boundary);
168
+ let units = 0;
169
+ if (active !== null) {
170
+ i = lineStart;
171
+ while (i < boundary) {
172
+ const c = adjustedClusters[i];
173
+ if (c.range.start >= active.spanRange.start && c.range.end <= active.spanRange.end && !ProgressiveBreakDecisions.hasWhitespaceUnit(c.text)) {
174
+ units += c.text.length;
175
+ }
176
+ i++;
177
+ }
178
+ }
179
+ const technicalGaps = Math.max(units - 1, 0);
180
+ if (technicalGaps > 0) {
181
+ return cjkDeficit / technicalGaps;
182
+ }
183
+ let gaps = 0;
184
+ i = lineStart + 1;
185
+ while (i < boundary) {
186
+ if (cjkInterCharBoundaries.has(i)) {
187
+ gaps++;
188
+ }
189
+ i++;
190
+ }
191
+ return (gaps === 0 ? cjkDeficit : cjkDeficit / gaps);
192
+ }
193
+ static hasWhitespaceUnit(s) {
194
+ let i = 0;
195
+ while (i < s.length) {
196
+ const c = (Number.isNaN(s.charCodeAt(i)) ? null : s.charCodeAt(i));
197
+ if (c >= 9 && c <= 13 || c >= 28 && c <= 32 || c === 160 || c === 5760 || c >= 8192 && c <= 8202 || c === 8232 || c === 8233 || c === 8239 || c === 8287 || c === 12288) {
198
+ return true;
199
+ }
200
+ i++;
201
+ }
202
+ return false;
203
+ }
204
+ static decideHyphenBreak(lineStart, overflowAt, adjustedClusters, lineLimit, hyphenBreakClusters, cjkInterCharBoundaries, maxCjkStretchPerGap, sinoWesternBoundaries, sinoWesternStretchCap) {
205
+ sinoWesternBoundaries = sinoWesternBoundaries ?? null;
206
+ sinoWesternStretchCap = sinoWesternStretchCap ?? null;
207
+ const sino = sinoWesternBoundaries ?? SortedTable.setBuilder(SortedTable.compareInts).build();
208
+ const cap = sinoWesternStretchCap ?? 0.0;
209
+ if (!hyphenBreakClusters.has(overflowAt)) {
210
+ return overflowAt;
211
+ }
212
+ let whole = overflowAt;
213
+ while (whole > lineStart && hyphenBreakClusters.has(whole)) {
214
+ whole--;
215
+ }
216
+ if (whole <= lineStart) {
217
+ return overflowAt;
218
+ }
219
+ let width = 0.0;
220
+ let k = lineStart;
221
+ while (k < whole) {
222
+ width += adjustedClusters[k].advance;
223
+ k++;
224
+ }
225
+ const deficit = lineLimit - width;
226
+ if (deficit <= 0) {
227
+ return whole;
228
+ }
229
+ let sw = 0;
230
+ k = lineStart + 1;
231
+ while (k < whole) {
232
+ if (sino.has(k)) {
233
+ sw++;
234
+ }
235
+ k++;
236
+ }
237
+ const cjk = Math.max(deficit - sw * cap, 0);
238
+ let gaps = 0;
239
+ k = lineStart + 1;
240
+ while (k < whole) {
241
+ if (cjkInterCharBoundaries.has(k)) {
242
+ gaps++;
243
+ }
244
+ k++;
245
+ }
246
+ return (gaps === 0 || cjk / gaps > maxCjkStretchPerGap ? overflowAt : whole);
247
+ }
248
+ static adjustBreakForLineEnd(breakAt, lineStart, forbiddenLineEndClusters) {
249
+ let b = breakAt;
250
+ while (b - 1 > lineStart && forbiddenLineEndClusters.has(b - 1)) {
251
+ b--;
252
+ }
253
+ return b;
254
+ }
255
+ static adjustBreakForUnbreakables(breakAt, lineStart, unbreakableRanges) {
256
+ let candidate = breakAt;
257
+ while (true) {
258
+ const containing = unbreakableRanges.containingOrNull(candidate);
259
+ if (containing === null) {
260
+ return candidate;
261
+ }
262
+ if (containing.start <= lineStart) {
263
+ return breakAt;
264
+ }
265
+ candidate = containing.start;
266
+ }
267
+ }
268
+ }
269
+ export class ShrinkOpportunity {
270
+ clusterIndex;
271
+ tier;
272
+ capacity;
273
+ channel;
274
+ lineEndOnly;
275
+ constructor(clusterIndex, tier, capacity, channel, lineEndOnly = null) {
276
+ this.clusterIndex = clusterIndex;
277
+ this.tier = tier;
278
+ this.capacity = capacity;
279
+ this.channel = channel;
280
+ this.lineEndOnly = lineEndOnly ?? false;
281
+ }
282
+ toString() {
283
+ return `ShrinkOpportunity(clusterIndex=${this.clusterIndex}, tier=${this.tier}, capacity=${this.capacity}, channel=${this.channel.kind}, lineEndOnly=${this.lineEndOnly})`;
284
+ }
285
+ }
286
+ export class UnbreakableRanges {
287
+ ranges;
288
+ byStart;
289
+ startsSorted;
290
+ prefixMaxLast;
291
+ static Empty = new UnbreakableRanges([]);
292
+ constructor(ranges) {
293
+ this.ranges = ranges;
294
+ this.byStart = ranges.slice();
295
+ let s0 = 1;
296
+ while (s0 < this.byStart.length) {
297
+ const key = this.byStart[s0];
298
+ let s1 = s0;
299
+ while (s1 > 0 && this.byStart[s1 - 1].start > key.start) {
300
+ this.byStart[s1] = this.byStart[s1 - 1];
301
+ s1--;
302
+ }
303
+ this.byStart[s1] = key;
304
+ s0++;
305
+ }
306
+ this.startsSorted = [];
307
+ let si = 0;
308
+ while (si < this.byStart.length) {
309
+ this.startsSorted.push(this.byStart[si].start);
310
+ si++;
311
+ }
312
+ this.prefixMaxLast = [];
313
+ let running = -2147483648;
314
+ let sj = 0;
315
+ while (sj < this.byStart.length) {
316
+ running = Math.trunc(Math.max(running, this.byStart[sj].end));
317
+ this.prefixMaxLast.push(running);
318
+ sj++;
319
+ }
320
+ }
321
+ containsBoundary(candidate) {
322
+ let low = 0;
323
+ let high = this.startsSorted.length;
324
+ while (low < high) {
325
+ const mid = low + high >> 1;
326
+ if (this.startsSorted[mid] < candidate) {
327
+ low = mid + 1;
328
+ }
329
+ else {
330
+ high = mid;
331
+ }
332
+ }
333
+ return low > 0 && this.prefixMaxLast[low - 1] >= candidate;
334
+ }
335
+ containingOrNull(candidate) {
336
+ if (!this.containsBoundary(candidate)) {
337
+ return null;
338
+ }
339
+ let ri = 0;
340
+ while (ri < this.ranges.length) {
341
+ const r = this.ranges[ri];
342
+ if (candidate > r.start && candidate <= r.end) {
343
+ return r;
344
+ }
345
+ ri++;
346
+ }
347
+ return null;
348
+ }
349
+ containingFromClosedStartOrNull(index) {
350
+ let low = 0;
351
+ let high = this.startsSorted.length;
352
+ while (low < high) {
353
+ const mid = low + high >> 1;
354
+ if (this.startsSorted[mid] <= index) {
355
+ low = mid + 1;
356
+ }
357
+ else {
358
+ high = mid;
359
+ }
360
+ }
361
+ if (low === 0 || this.prefixMaxLast[low - 1] <= index) {
362
+ return null;
363
+ }
364
+ let rj = 0;
365
+ while (rj < this.ranges.length) {
366
+ const r = this.ranges[rj];
367
+ if (index >= r.start && index <= r.end && r.end > index) {
368
+ return r;
369
+ }
370
+ rj++;
371
+ }
372
+ return null;
373
+ }
374
+ }
375
+ export const ProgressiveBreakTier = Object.freeze({
376
+ Whitespace: Object.freeze({ kind: "Whitespace" }),
377
+ Structural: Object.freeze({ kind: "Structural" }),
378
+ Syllable: Object.freeze({ kind: "Syllable" }),
379
+ WholeToken: Object.freeze({ kind: "WholeToken" }),
380
+ Emergency: Object.freeze({ kind: "Emergency" })
381
+ });
382
+ export function compareProgressiveBreakTier(a, b) {
383
+ if (a === b)
384
+ return 0;
385
+ if (a.kind === "Whitespace")
386
+ return 0 - (b.kind === "Whitespace" ? 0 : 0);
387
+ if (a.kind === "Structural")
388
+ return 1 - (b.kind === "Structural" ? 1 : 0);
389
+ if (a.kind === "Syllable")
390
+ return 2 - (b.kind === "Syllable" ? 2 : 0);
391
+ if (a.kind === "WholeToken")
392
+ return 3 - (b.kind === "WholeToken" ? 3 : 0);
393
+ if (a.kind === "Emergency")
394
+ return 4 - (b.kind === "Emergency" ? 4 : 0);
395
+ return 0;
396
+ }
397
+ export const ShrinkChannel = Object.freeze({
398
+ TrailingGlue: Object.freeze({ kind: "TrailingGlue" }),
399
+ LeadingGlue: Object.freeze({ kind: "LeadingGlue" }),
400
+ LeadingAndTrailingGlue: Object.freeze({ kind: "LeadingAndTrailingGlue" }),
401
+ RawAdvance: Object.freeze({ kind: "RawAdvance" })
402
+ });
403
+ export function compareShrinkChannel(a, b) {
404
+ if (a === b)
405
+ return 0;
406
+ if (a.kind === "TrailingGlue")
407
+ return 0 - (b.kind === "TrailingGlue" ? 0 : 0);
408
+ if (a.kind === "LeadingGlue")
409
+ return 1 - (b.kind === "LeadingGlue" ? 1 : 0);
410
+ if (a.kind === "LeadingAndTrailingGlue")
411
+ return 2 - (b.kind === "LeadingAndTrailingGlue" ? 2 : 0);
412
+ if (a.kind === "RawAdvance")
413
+ return 3 - (b.kind === "RawAdvance" ? 3 : 0);
414
+ return 0;
415
+ }
@@ -0,0 +1,5 @@
1
+ import { ProgressiveBreakTier } from "./ProgressiveBreakDecisions.js";
2
+ export declare class ProgressiveBreakTierPriority {
3
+ static priority(tier: ProgressiveBreakTier): number;
4
+ static fromPriority(value: number): ProgressiveBreakTier;
5
+ }
@@ -0,0 +1,33 @@
1
+ // Generated by the reflaxe TypeScript target. Do not edit.
2
+ import { ProgressiveBreakTier } from "./ProgressiveBreakDecisions.js";
3
+ export class ProgressiveBreakTierPriority {
4
+ static priority(tier) {
5
+ switch (tier.kind) {
6
+ case "Whitespace":
7
+ return 0;
8
+ case "Structural":
9
+ return 1;
10
+ case "Syllable":
11
+ return 2;
12
+ case "WholeToken":
13
+ return 3;
14
+ case "Emergency":
15
+ return 4;
16
+ }
17
+ }
18
+ static fromPriority(value) {
19
+ if (value === 0) {
20
+ return ProgressiveBreakTier.Whitespace;
21
+ }
22
+ if (value === 1) {
23
+ return ProgressiveBreakTier.Structural;
24
+ }
25
+ if (value === 2) {
26
+ return ProgressiveBreakTier.Syllable;
27
+ }
28
+ if (value === 3) {
29
+ return ProgressiveBreakTier.WholeToken;
30
+ }
31
+ return ProgressiveBreakTier.Emergency;
32
+ }
33
+ }
@@ -0,0 +1,63 @@
1
+ import { type TextRange } from "./../core/TextRange.js";
2
+ import { type FontRole } from "./../font/FontRole.js";
3
+ import { type FontRoleClassifier, FontRoleContext } from "./../font/FontRoleContext.js";
4
+ import { SortedMapTable } from "../../../runtime.js";
5
+ export declare class QuotePair {
6
+ readonly openIndex: number;
7
+ readonly closeIndex: number;
8
+ readonly quoteType: QuoteType;
9
+ constructor(openIndex: number, closeIndex: number, quoteType: QuoteType);
10
+ toString(): string;
11
+ }
12
+ export declare function QuotePairquoteTypeOrder(v: QuoteType): number;
13
+ export declare function compareQuotePair(a: QuotePair, b: QuotePair): number;
14
+ export declare class QuoteRoleDecision {
15
+ readonly index: number;
16
+ readonly role: FontRole;
17
+ readonly source: string;
18
+ readonly reason: string;
19
+ constructor(index: number, role: FontRole, source: string, reason: string);
20
+ toString(): string;
21
+ }
22
+ export declare function QuoteRoleDecisionroleOrder(v: FontRole): number;
23
+ export declare function compareQuoteRoleDecision(a: QuoteRoleDecision, b: QuoteRoleDecision): number;
24
+ export declare class QuotePairAnalyzer {
25
+ constructor();
26
+ analyze(text: string): QuotePair[];
27
+ classifyPairs(text: string, pairs: QuotePair[], context?: FontRoleContext | null): SortedMapTable<number, FontRole>;
28
+ classifyPairsWithClassifier(text: string, pairs: QuotePair[], _fontRoleClassifier: FontRoleClassifier, context?: FontRoleContext | null): SortedMapTable<number, FontRole>;
29
+ classifyQuoteRoles(text: string, pairs: QuotePair[], context?: FontRoleContext | null): QuoteRoleDecision[];
30
+ classifyQuoteRolesWithClassifier(text: string, pairs: QuotePair[], _fontRoleClassifier: FontRoleClassifier, context?: FontRoleContext | null): QuoteRoleDecision[];
31
+ private static mapDecisions;
32
+ static isNonCjkInWordApostrophe(text: string, index: number): boolean;
33
+ static isDigitBoundClosingQuote(text: string, index: number): boolean;
34
+ static isNonCjkWordInternalQuotePair(text: string, pair: QuotePair): boolean;
35
+ private static isNonCjkWordCharacter;
36
+ private static isNonCjkNonNumericWordCharacter;
37
+ private static isFullwidthEastAsianWidth;
38
+ static codePointBefore(text: string, index: number): number | null;
39
+ static codePointAtOrNull(text: string, index: number): number | null;
40
+ }
41
+ export declare class QuotePairAwareFontRoleClassifier implements FontRoleClassifier {
42
+ private readonly delegate;
43
+ private readonly quoteRoles;
44
+ constructor(delegate: FontRoleClassifier, quoteRoles: SortedMapTable<number, FontRole>);
45
+ classify(text: string, range: TextRange, context?: FontRoleContext | null): FontRole;
46
+ static withContextualQuoteRoles(base: FontRoleClassifier, text: string, context?: FontRoleContext | null): FontRoleClassifier;
47
+ }
48
+ export interface Double {
49
+ readonly kind: "Double";
50
+ }
51
+ export interface Single {
52
+ readonly kind: "Single";
53
+ }
54
+ export type QuoteType = Double | Single;
55
+ export declare const QuoteType: Readonly<{
56
+ Double: Readonly<Double>;
57
+ Single: Readonly<Single>;
58
+ }>;
59
+ export declare function compareQuoteType(a: QuoteType, b: QuoteType): number;
60
+ export interface OpenQuoteEntry {
61
+ index: number;
62
+ type: QuoteType;
63
+ }