@tiqian/protocol 0.0.0-stage.1 → 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,657 @@
1
+ // Generated by the reflaxe TypeScript target. Do not edit.
2
+ import { MetricEntry } from "./MetricEntry.js";
3
+ import { StyleRow } from "./StyleRow.js";
4
+ import { TableData } from "./TableData.js";
5
+ import { ValueRow } from "./ValueRow.js";
6
+ import { BytesBuffer, doubleToI64, i64ToDouble } from "../../../runtime.js";
7
+ export class SnapshotTableBinary {
8
+ static encode(table) {
9
+ return SnapshotTableBinary.encodeData(SnapshotTableBinary.lower(table));
10
+ }
11
+ static encodeData(data) {
12
+ const writer = new TableWriter();
13
+ writer.raw(new TextEncoder().encode("TIQTBL03"));
14
+ writer.u32(data.replayStringCount);
15
+ writer.u32(data.strings.length);
16
+ writer.u32(data.metricRows.length);
17
+ writer.u32(data.valuePool.length);
18
+ writer.u32(data.probeTextRefs.length);
19
+ writer.u32(data.advancePool.length);
20
+ writer.u32(data.styleFontSize.length);
21
+ writer.u32(data.featuresPool.length);
22
+ writer.u32(data.faceTexts.length);
23
+ writer.u32(data.typographyTexts.length);
24
+ writer.u32(data.valueStyleTexts.length);
25
+ writer.u32(data.fontPreloadTexts.length);
26
+ SnapshotTableBinary.writeTextRegion(writer, data.strings);
27
+ let indexIdx = 0;
28
+ while (indexIdx < data.metricRows.length) {
29
+ writer.u32(data.metricRows[indexIdx].familiesRef);
30
+ indexIdx++;
31
+ }
32
+ indexIdx = 0;
33
+ while (indexIdx < data.metricRows.length) {
34
+ writer.f64(data.metricRows[indexIdx].weight);
35
+ indexIdx++;
36
+ }
37
+ indexIdx = 0;
38
+ while (indexIdx < data.metricRows.length) {
39
+ writer.u8(data.metricRows[indexIdx].italic);
40
+ indexIdx++;
41
+ }
42
+ indexIdx = 0;
43
+ while (indexIdx < data.metricRows.length) {
44
+ writer.u32(data.metricRows[indexIdx].roleRef);
45
+ indexIdx++;
46
+ }
47
+ indexIdx = 0;
48
+ while (indexIdx < data.metricRows.length) {
49
+ writer.u32(data.metricRows[indexIdx].faceSelectionRef);
50
+ indexIdx++;
51
+ }
52
+ indexIdx = 0;
53
+ while (indexIdx < data.metricRows.length) {
54
+ writer.u32(data.metricRows[indexIdx].valuePoolRef);
55
+ indexIdx++;
56
+ }
57
+ indexIdx = 0;
58
+ while (indexIdx < data.valuePool.length) {
59
+ SnapshotTableBinary.writeValueRow(writer, data.valuePool[indexIdx]);
60
+ indexIdx++;
61
+ }
62
+ indexIdx = 0;
63
+ while (indexIdx < data.probeTextRefs.length) {
64
+ writer.u32(data.probeTextRefs[indexIdx]);
65
+ indexIdx++;
66
+ }
67
+ indexIdx = 0;
68
+ while (indexIdx < data.probeAdvanceRefs.length) {
69
+ writer.u16(data.probeAdvanceRefs[indexIdx]);
70
+ indexIdx++;
71
+ }
72
+ indexIdx = 0;
73
+ while (indexIdx < data.probeStyleRefs.length) {
74
+ writer.u16(data.probeStyleRefs[indexIdx]);
75
+ indexIdx++;
76
+ }
77
+ indexIdx = 0;
78
+ while (indexIdx < data.probeFeatureRefs.length) {
79
+ writer.u16(data.probeFeatureRefs[indexIdx]);
80
+ indexIdx++;
81
+ }
82
+ indexIdx = 0;
83
+ while (indexIdx < data.advancePool.length) {
84
+ writer.f64(data.advancePool[indexIdx]);
85
+ indexIdx++;
86
+ }
87
+ indexIdx = 0;
88
+ while (indexIdx < data.styleFontSize.length) {
89
+ writer.f64(data.styleFontSize[indexIdx]);
90
+ writer.f64(data.styleFontWeight[indexIdx]);
91
+ writer.u8(data.styleItalic[indexIdx]);
92
+ writer.u32(data.styleScriptRefs[indexIdx]);
93
+ writer.u32(data.styleLanguageRefs[indexIdx]);
94
+ indexIdx++;
95
+ }
96
+ indexIdx = 0;
97
+ while (indexIdx < data.featuresPool.length) {
98
+ writer.u32(SnapshotTableBinary.featureRowBytes(data.featuresPool[indexIdx]).length);
99
+ indexIdx++;
100
+ }
101
+ indexIdx = 0;
102
+ while (indexIdx < data.featuresPool.length) {
103
+ writer.raw(SnapshotTableBinary.featureRowBytes(data.featuresPool[indexIdx]));
104
+ indexIdx++;
105
+ }
106
+ SnapshotTableBinary.writeTextRegion(writer, data.faceTexts);
107
+ SnapshotTableBinary.writeTextRegion(writer, data.typographyTexts);
108
+ SnapshotTableBinary.writeTextRegion(writer, data.valueStyleTexts);
109
+ SnapshotTableBinary.writeTextRegion(writer, data.fontPreloadTexts);
110
+ writer.raw(new TextEncoder().encode(data.revisionText));
111
+ return writer.finish();
112
+ }
113
+ static decodeInto(bytes, data) {
114
+ const reader = new TableReader(bytes);
115
+ if (!reader.matchMagic()) {
116
+ return reader.issue;
117
+ }
118
+ data.replayStringCount = reader.u32();
119
+ const stringCount = reader.u32();
120
+ const metricCount = reader.u32();
121
+ const valuePoolCount = reader.u32();
122
+ const probeCount = reader.u32();
123
+ const advancePoolCount = reader.u32();
124
+ const stylePoolCount = reader.u32();
125
+ const featuresPoolCount = reader.u32();
126
+ const faceCount = reader.u32();
127
+ const typographyCount = reader.u32();
128
+ const valueStyleCount = reader.u32();
129
+ const fontPreloadCount = reader.u32();
130
+ data.strings = reader.textRegion(stringCount);
131
+ const famRefs = new Array();
132
+ const weights = new Array();
133
+ const italics = new Array();
134
+ const roleRefs = new Array();
135
+ const faceSelRefs = new Array();
136
+ const poolRefs = new Array();
137
+ let colIdx = 0;
138
+ while (colIdx < metricCount) {
139
+ famRefs.push(reader.u32());
140
+ colIdx++;
141
+ }
142
+ colIdx = 0;
143
+ while (colIdx < metricCount) {
144
+ weights.push(reader.f64());
145
+ colIdx++;
146
+ }
147
+ colIdx = 0;
148
+ while (colIdx < metricCount) {
149
+ italics.push(reader.u8());
150
+ colIdx++;
151
+ }
152
+ colIdx = 0;
153
+ while (colIdx < metricCount) {
154
+ roleRefs.push(reader.u32());
155
+ colIdx++;
156
+ }
157
+ colIdx = 0;
158
+ while (colIdx < metricCount) {
159
+ faceSelRefs.push(reader.u32());
160
+ colIdx++;
161
+ }
162
+ colIdx = 0;
163
+ while (colIdx < metricCount) {
164
+ poolRefs.push(reader.u32());
165
+ colIdx++;
166
+ }
167
+ colIdx = 0;
168
+ while (colIdx < metricCount) {
169
+ data.metricRows.push(new MetricEntry(famRefs[colIdx], weights[colIdx], italics[colIdx], roleRefs[colIdx], faceSelRefs[colIdx], poolRefs[colIdx]));
170
+ colIdx++;
171
+ }
172
+ let indexIdx = 0;
173
+ while (indexIdx < valuePoolCount) {
174
+ data.valuePool.push(SnapshotTableBinary.readValueRow(reader));
175
+ indexIdx++;
176
+ }
177
+ indexIdx = 0;
178
+ while (indexIdx < probeCount) {
179
+ data.probeTextRefs.push(reader.u32());
180
+ indexIdx++;
181
+ }
182
+ indexIdx = 0;
183
+ while (indexIdx < probeCount) {
184
+ data.probeAdvanceRefs.push(reader.u16());
185
+ indexIdx++;
186
+ }
187
+ indexIdx = 0;
188
+ while (indexIdx < probeCount) {
189
+ data.probeStyleRefs.push(reader.u16());
190
+ indexIdx++;
191
+ }
192
+ indexIdx = 0;
193
+ while (indexIdx < probeCount) {
194
+ data.probeFeatureRefs.push(reader.u16());
195
+ indexIdx++;
196
+ }
197
+ indexIdx = 0;
198
+ while (indexIdx < advancePoolCount) {
199
+ data.advancePool.push(reader.f64());
200
+ indexIdx++;
201
+ }
202
+ indexIdx = 0;
203
+ while (indexIdx < stylePoolCount) {
204
+ data.styleFontSize.push(reader.f64());
205
+ data.styleFontWeight.push(reader.f64());
206
+ data.styleItalic.push(reader.u8());
207
+ data.styleScriptRefs.push(reader.u32());
208
+ data.styleLanguageRefs.push(reader.u32());
209
+ indexIdx++;
210
+ }
211
+ indexIdx = 0;
212
+ while (indexIdx < featuresPoolCount) {
213
+ reader.u32();
214
+ indexIdx++;
215
+ }
216
+ for (let indexIdx = 0; indexIdx < featuresPoolCount; indexIdx += 1) {
217
+ data.featuresPool.push(reader.featureRow());
218
+ }
219
+ data.faceTexts = reader.textRegion(faceCount);
220
+ data.typographyTexts = reader.textRegion(typographyCount);
221
+ data.valueStyleTexts = reader.textRegion(valueStyleCount);
222
+ data.fontPreloadTexts = reader.textRegion(fontPreloadCount);
223
+ if (reader.failed) {
224
+ return reader.issue;
225
+ }
226
+ data.revisionText = reader.restText();
227
+ if (reader.failed) {
228
+ return reader.issue;
229
+ }
230
+ return "";
231
+ }
232
+ static sortMetricRows(rows) {
233
+ let writeIdx = 1;
234
+ while (writeIdx < rows.length) {
235
+ const record = rows[writeIdx];
236
+ let readIdx = writeIdx - 1;
237
+ while (readIdx >= 0 && SnapshotTableBinary.metricBefore(record, rows[readIdx])) {
238
+ rows[readIdx + 1] = rows[readIdx];
239
+ readIdx--;
240
+ }
241
+ rows[readIdx + 1] = record;
242
+ writeIdx++;
243
+ }
244
+ return rows;
245
+ }
246
+ static metricBefore(a, b) {
247
+ if (a.familiesRef !== b.familiesRef) {
248
+ return a.familiesRef < b.familiesRef;
249
+ }
250
+ if (a.weight < b.weight) {
251
+ return true;
252
+ }
253
+ if (b.weight < a.weight) {
254
+ return false;
255
+ }
256
+ if (a.italic !== b.italic) {
257
+ return a.italic < b.italic;
258
+ }
259
+ if (a.roleRef !== b.roleRef) {
260
+ return a.roleRef < b.roleRef;
261
+ }
262
+ return a.faceSelectionRef < b.faceSelectionRef;
263
+ }
264
+ static lower(table) {
265
+ const data = new TableData();
266
+ data.replayStringCount = table.replayStrings.length;
267
+ const interner = new StringInterner(table.replayStrings);
268
+ let indexIdx = 0;
269
+ const metricEntries = new Array();
270
+ while (indexIdx < table.metrics.length) {
271
+ const row = table.metrics[indexIdx];
272
+ const entry = new MetricEntry(interner.intern(row.serializedFamilies), row.fontWeight, (row.italic ? 1 : 0), interner.intern(row.role), interner.intern(row.faceSelectionText), 0);
273
+ entry.valuesEm = row.valuesEm;
274
+ metricEntries.push(entry);
275
+ indexIdx++;
276
+ }
277
+ SnapshotTableBinary.sortMetricRows(metricEntries);
278
+ const valuePool = new Array();
279
+ const pooled = new Array();
280
+ indexIdx = 0;
281
+ while (indexIdx < metricEntries.length) {
282
+ const sorted = metricEntries[indexIdx];
283
+ pooled.push(new MetricEntry(sorted.familiesRef, sorted.weight, sorted.italic, sorted.roleRef, sorted.faceSelectionRef, SnapshotTableBinary.poolRefOf(valuePool, sorted.valuesEm)));
284
+ indexIdx++;
285
+ }
286
+ data.metricRows = pooled;
287
+ data.valuePool = valuePool;
288
+ const advancePool = new Array();
289
+ const stylePool = new Array();
290
+ const featuresPool = new Array();
291
+ indexIdx = 0;
292
+ while (indexIdx < table.probes.length) {
293
+ const probe = table.probes[indexIdx];
294
+ const textRef = interner.intern(probe.text);
295
+ const scriptRef = interner.intern(probe.script);
296
+ const languageRef = interner.intern(probe.language);
297
+ const featureRefs = new Array();
298
+ let featureIdx = 0;
299
+ while (featureIdx < probe.features.length) {
300
+ featureRefs.push(interner.intern(probe.features[featureIdx]));
301
+ featureIdx++;
302
+ }
303
+ data.probeTextRefs.push(textRef);
304
+ data.probeAdvanceRefs.push(SnapshotTableBinary.pooledFloat(advancePool, probe.advancePx));
305
+ data.probeStyleRefs.push(SnapshotTableBinary.pooledStyle(stylePool, probe, scriptRef, languageRef));
306
+ data.probeFeatureRefs.push(SnapshotTableBinary.pooledFeatures(featuresPool, featureRefs));
307
+ indexIdx++;
308
+ }
309
+ data.advancePool = advancePool;
310
+ data.featuresPool = featuresPool;
311
+ data.styleFontSize = new Array();
312
+ data.styleFontWeight = new Array();
313
+ data.styleItalic = new Array();
314
+ data.styleScriptRefs = new Array();
315
+ data.styleLanguageRefs = new Array();
316
+ let styleIdx = 0;
317
+ while (styleIdx < stylePool.length) {
318
+ data.styleFontSize.push(stylePool[styleIdx].fontSizePx);
319
+ data.styleFontWeight.push(stylePool[styleIdx].fontWeight);
320
+ data.styleItalic.push(stylePool[styleIdx].italic);
321
+ data.styleScriptRefs.push(stylePool[styleIdx].scriptRef);
322
+ data.styleLanguageRefs.push(stylePool[styleIdx].languageRef);
323
+ styleIdx++;
324
+ }
325
+ data.strings = interner.strings;
326
+ data.faceTexts = SnapshotTableBinary.copyTexts(table.faces);
327
+ data.typographyTexts = SnapshotTableBinary.copyTexts(table.typographies);
328
+ data.valueStyleTexts = SnapshotTableBinary.copyTexts(table.valueStyles);
329
+ data.fontPreloadTexts = SnapshotTableBinary.copyTexts(table.fontPreloads);
330
+ data.revisionText = table.revisionsText;
331
+ return data;
332
+ }
333
+ static copyTexts(texts) {
334
+ const out = new Array();
335
+ let indexIdx = 0;
336
+ while (indexIdx < texts.length) {
337
+ out.push(texts[indexIdx]);
338
+ indexIdx++;
339
+ }
340
+ return out;
341
+ }
342
+ static poolRefOf(pool, values) {
343
+ let indexIdx = 0;
344
+ while (indexIdx < pool.length) {
345
+ if (SnapshotTableBinary.sameValues(pool[indexIdx].values, values)) {
346
+ return indexIdx;
347
+ }
348
+ indexIdx++;
349
+ }
350
+ pool.push(new ValueRow(values));
351
+ return pool.length - 1;
352
+ }
353
+ static sameValues(a, b) {
354
+ if (a.length !== b.length) {
355
+ return false;
356
+ }
357
+ let indexIdx = 0;
358
+ while (indexIdx < a.length) {
359
+ const left = a[indexIdx];
360
+ const right = b[indexIdx];
361
+ if (left === null && right === null) {
362
+ indexIdx++;
363
+ continue;
364
+ }
365
+ if (left === null || right === null) {
366
+ return false;
367
+ }
368
+ if (left !== right) {
369
+ return false;
370
+ }
371
+ indexIdx++;
372
+ }
373
+ return true;
374
+ }
375
+ static f64BitsEqual(a, b) {
376
+ const ab = doubleToI64(a);
377
+ const bb = doubleToI64(b);
378
+ return ab.high === bb.high && ab.low === bb.low;
379
+ }
380
+ static pooledFloat(pool, value) {
381
+ let indexIdx = 0;
382
+ while (indexIdx < pool.length) {
383
+ if (SnapshotTableBinary.f64BitsEqual(pool[indexIdx], value)) {
384
+ return indexIdx;
385
+ }
386
+ indexIdx++;
387
+ }
388
+ pool.push(value);
389
+ return pool.length - 1;
390
+ }
391
+ static pooledStyle(pool, probe, scriptRef, languageRef) {
392
+ let indexIdx = 0;
393
+ while (indexIdx < pool.length) {
394
+ const row = pool[indexIdx];
395
+ if (SnapshotTableBinary.f64BitsEqual(row.fontSizePx, probe.fontSizePx) && SnapshotTableBinary.f64BitsEqual(row.fontWeight, probe.fontWeight) && row.italic === (probe.italic ? 1 : 0) && row.scriptRef === scriptRef && row.languageRef === languageRef) {
396
+ return indexIdx;
397
+ }
398
+ indexIdx++;
399
+ }
400
+ pool.push(new StyleRow(probe.fontSizePx, probe.fontWeight, (probe.italic ? 1 : 0), scriptRef, languageRef));
401
+ return pool.length - 1;
402
+ }
403
+ static pooledFeatures(pool, refs) {
404
+ let indexIdx = 0;
405
+ while (indexIdx < pool.length) {
406
+ if (SnapshotTableBinary.sameRefs(pool[indexIdx], refs)) {
407
+ return indexIdx;
408
+ }
409
+ indexIdx++;
410
+ }
411
+ pool.push(refs);
412
+ return pool.length - 1;
413
+ }
414
+ static sameRefs(a, b) {
415
+ if (a.length !== b.length) {
416
+ return false;
417
+ }
418
+ let indexIdx = 0;
419
+ while (indexIdx < a.length) {
420
+ if (a[indexIdx] !== b[indexIdx]) {
421
+ return false;
422
+ }
423
+ indexIdx++;
424
+ }
425
+ return true;
426
+ }
427
+ static writeTextRegion(writer, texts) {
428
+ let totalIdx = 0;
429
+ while (totalIdx < texts.length) {
430
+ writer.u32(new TextEncoder().encode(texts[totalIdx]).length);
431
+ totalIdx++;
432
+ }
433
+ totalIdx = 0;
434
+ while (totalIdx < texts.length) {
435
+ writer.raw(new TextEncoder().encode(texts[totalIdx]));
436
+ totalIdx++;
437
+ }
438
+ }
439
+ static writeValueRow(writer, row) {
440
+ let slotIdx = 0;
441
+ while (slotIdx < row.values.length) {
442
+ const value = row.values[slotIdx];
443
+ if (value === null) {
444
+ writer.absentF64();
445
+ }
446
+ else {
447
+ writer.f64((value));
448
+ }
449
+ slotIdx++;
450
+ }
451
+ }
452
+ static featureRowBytes(refs) {
453
+ const row = new TableWriter();
454
+ row.u16(refs.length);
455
+ let indexIdx = 0;
456
+ while (indexIdx < refs.length) {
457
+ row.u32(refs[indexIdx]);
458
+ indexIdx++;
459
+ }
460
+ return row.finish();
461
+ }
462
+ static readValueRow(reader) {
463
+ const values = new Array();
464
+ for (let slotIdx = 0; slotIdx < 5; slotIdx += 1) {
465
+ const low = reader.u32();
466
+ const high = reader.u32();
467
+ if (high === 2146959360 && low === 0) {
468
+ values.push((null));
469
+ }
470
+ else {
471
+ values.push(i64ToDouble(low, high));
472
+ }
473
+ }
474
+ return new ValueRow(values);
475
+ }
476
+ }
477
+ export class StringInterner {
478
+ strings;
479
+ constructor(replayStrings) {
480
+ this.strings = new Array();
481
+ let indexIdx = 0;
482
+ while (indexIdx < replayStrings.length) {
483
+ this.strings.push(replayStrings[indexIdx]);
484
+ indexIdx++;
485
+ }
486
+ }
487
+ intern(text) {
488
+ let indexIdx = 0;
489
+ while (indexIdx < this.strings.length) {
490
+ if (this.strings[indexIdx] === text) {
491
+ return indexIdx;
492
+ }
493
+ indexIdx++;
494
+ }
495
+ this.strings.push(text);
496
+ return this.strings.length - 1;
497
+ }
498
+ }
499
+ export class TableWriter {
500
+ buf;
501
+ constructor() {
502
+ this.buf = new BytesBuffer();
503
+ }
504
+ raw(bytes) {
505
+ let indexIdx = 0;
506
+ while (indexIdx < bytes.length) {
507
+ this.buf.addByte(bytes[indexIdx]);
508
+ indexIdx++;
509
+ }
510
+ }
511
+ u8(value) {
512
+ this.buf.addByte(value & 255);
513
+ }
514
+ u16(value) {
515
+ this.buf.addByte(value & 255);
516
+ this.buf.addByte((value >>> 8) & 255);
517
+ }
518
+ u32(value) {
519
+ this.buf.addByte(value & 255);
520
+ this.buf.addByte((value >>> 8) & 255);
521
+ this.buf.addByte((value >>> 16) & 255);
522
+ this.buf.addByte((value >>> 24) & 255);
523
+ }
524
+ f64(value) {
525
+ const bits = doubleToI64(value);
526
+ this.u32(bits.low);
527
+ this.u32(bits.high);
528
+ }
529
+ absentF64() {
530
+ this.u32(0);
531
+ this.u32(2146959360);
532
+ }
533
+ finish() {
534
+ return this.buf.getBytes();
535
+ }
536
+ }
537
+ export class TableReader {
538
+ bytes;
539
+ pos;
540
+ failed;
541
+ issue;
542
+ constructor(bytes) {
543
+ this.bytes = bytes;
544
+ this.pos = 0;
545
+ this.failed = false;
546
+ this.issue = "";
547
+ }
548
+ u8() {
549
+ if (!this.need(1)) {
550
+ return 0;
551
+ }
552
+ const value = this.bytes[this.pos];
553
+ this.pos += 1;
554
+ return value;
555
+ }
556
+ u16() {
557
+ if (!this.need(2)) {
558
+ return 0;
559
+ }
560
+ const value = this.bytes[this.pos] | (this.bytes[this.pos + 1] << 8);
561
+ this.pos += 2;
562
+ return value;
563
+ }
564
+ u32() {
565
+ if (!this.need(4)) {
566
+ return 0;
567
+ }
568
+ const value = (this.bytes[this.pos] | (this.bytes[this.pos + 1] << 8) | (this.bytes[this.pos + 2] << 16)) + this.bytes[this.pos + 3] * 16777216;
569
+ this.pos += 4;
570
+ return value;
571
+ }
572
+ f64() {
573
+ const low = this.u32();
574
+ const high = this.u32();
575
+ if (this.failed) {
576
+ return 0.0;
577
+ }
578
+ return i64ToDouble(low, high);
579
+ }
580
+ matchMagic() {
581
+ if (!this.need(8)) {
582
+ return false;
583
+ }
584
+ const expected = new TextEncoder().encode("TIQTBL03");
585
+ let indexIdx = 0;
586
+ while (indexIdx < 8) {
587
+ if (this.bytes[this.pos + indexIdx] !== expected[indexIdx]) {
588
+ this.failed = true;
589
+ this.issue = "SnapshotTablesInvalid";
590
+ return false;
591
+ }
592
+ indexIdx++;
593
+ }
594
+ this.pos += 8;
595
+ return true;
596
+ }
597
+ featureRow() {
598
+ const refs = new Array();
599
+ const count = this.u16();
600
+ if (this.failed) {
601
+ return refs;
602
+ }
603
+ for (let indexIdx = 0; indexIdx < count; indexIdx += 1) {
604
+ refs.push(this.u32());
605
+ }
606
+ return refs;
607
+ }
608
+ textRegion(count) {
609
+ const texts = new Array();
610
+ if (this.failed) {
611
+ return texts;
612
+ }
613
+ const lengths = new Array();
614
+ let running = 0;
615
+ let indexIdx = 0;
616
+ while (indexIdx < count) {
617
+ const delta = this.u32();
618
+ if (this.failed) {
619
+ return texts;
620
+ }
621
+ running += delta;
622
+ if (running < 0 || this.pos + running > this.bytes.length) {
623
+ this.failed = true;
624
+ this.issue = "SnapshotTablesInvalid";
625
+ return texts;
626
+ }
627
+ lengths.push(delta);
628
+ indexIdx++;
629
+ }
630
+ indexIdx = 0;
631
+ while (indexIdx < lengths.length) {
632
+ texts.push(new TextDecoder().decode(this.bytes.subarray(this.pos, this.pos + lengths[indexIdx])));
633
+ this.pos += lengths[indexIdx];
634
+ indexIdx++;
635
+ }
636
+ return texts;
637
+ }
638
+ restText() {
639
+ if (!this.need(0)) {
640
+ return "";
641
+ }
642
+ const value = new TextDecoder().decode(this.bytes.subarray(this.pos, this.pos + this.bytes.length - this.pos));
643
+ this.pos = this.bytes.length;
644
+ return value;
645
+ }
646
+ need(length) {
647
+ if (this.failed) {
648
+ return false;
649
+ }
650
+ if (length < 0 || this.pos + length > this.bytes.length) {
651
+ this.failed = true;
652
+ this.issue = "SnapshotTablesInvalid";
653
+ return false;
654
+ }
655
+ return true;
656
+ }
657
+ }
@@ -0,0 +1,14 @@
1
+ export interface SnapshotTypography {
2
+ fontFamilies: string[];
3
+ fontSizePx: number;
4
+ lineHeightPx: number;
5
+ locale: string;
6
+ fontWeight: number;
7
+ italic: boolean;
8
+ firstLineIndentIc: number;
9
+ lineLengthGridEnabled: boolean;
10
+ letterSpacingPx: number;
11
+ fontFeatureSettings: string;
12
+ fontVariationSettings: string;
13
+ fontVariantNumeric: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ // Generated by the reflaxe TypeScript target. Do not edit.
2
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare class StyleRow {
2
+ fontSizePx: number;
3
+ fontWeight: number;
4
+ italic: number;
5
+ scriptRef: number;
6
+ languageRef: number;
7
+ constructor(fontSizePx: number, fontWeight: number, italic: number, scriptRef: number, languageRef: number);
8
+ }
@@ -0,0 +1,15 @@
1
+ // Generated by the reflaxe TypeScript target. Do not edit.
2
+ export class StyleRow {
3
+ fontSizePx;
4
+ fontWeight;
5
+ italic;
6
+ scriptRef;
7
+ languageRef;
8
+ constructor(fontSizePx, fontWeight, italic, scriptRef, languageRef) {
9
+ this.fontSizePx = fontSizePx;
10
+ this.fontWeight = fontWeight;
11
+ this.italic = italic;
12
+ this.scriptRef = scriptRef;
13
+ this.languageRef = languageRef;
14
+ }
15
+ }