@tiqian/protocol 0.0.0-stage → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/haxe/crypto/Sha256.d.ts +19 -0
- package/dist/haxe/crypto/Sha256.js +194 -0
- package/dist/org/tiqian/clreq/AdjustmentStylePolicy.d.ts +11 -0
- package/dist/org/tiqian/clreq/AdjustmentStylePolicy.js +21 -0
- package/dist/org/tiqian/clreq/AutoSpaceMode.d.ts +16 -0
- package/dist/org/tiqian/clreq/AutoSpaceMode.js +17 -0
- package/dist/org/tiqian/clreq/AutoSpacePolicy.d.ts +13 -0
- package/dist/org/tiqian/clreq/AutoSpacePolicy.js +23 -0
- package/dist/org/tiqian/clreq/BopomofoReading.d.ts +12 -0
- package/dist/org/tiqian/clreq/BopomofoReading.js +86 -0
- package/dist/org/tiqian/clreq/BopomofoTone.d.ts +28 -0
- package/dist/org/tiqian/clreq/BopomofoTone.js +26 -0
- package/dist/org/tiqian/clreq/CjkPunctuationGlyphPolicy.d.ts +16 -0
- package/dist/org/tiqian/clreq/CjkPunctuationGlyphPolicy.js +17 -0
- package/dist/org/tiqian/clreq/ClreqProfile.d.ts +27 -0
- package/dist/org/tiqian/clreq/ClreqProfile.js +58 -0
- package/dist/org/tiqian/clreq/ClreqRegion.d.ts +20 -0
- package/dist/org/tiqian/clreq/ClreqRegion.js +20 -0
- package/dist/org/tiqian/clreq/ClreqStrictness.d.ts +16 -0
- package/dist/org/tiqian/clreq/ClreqStrictness.js +17 -0
- package/dist/org/tiqian/clreq/GlueSide.d.ts +16 -0
- package/dist/org/tiqian/clreq/GlueSide.js +17 -0
- package/dist/org/tiqian/clreq/HangingPunctuationStyle.d.ts +12 -0
- package/dist/org/tiqian/clreq/HangingPunctuationStyle.js +14 -0
- package/dist/org/tiqian/clreq/InteriorPunctuationStyle.d.ts +12 -0
- package/dist/org/tiqian/clreq/InteriorPunctuationStyle.js +14 -0
- package/dist/org/tiqian/clreq/KinsokuLevel.d.ts +20 -0
- package/dist/org/tiqian/clreq/KinsokuLevel.js +20 -0
- package/dist/org/tiqian/clreq/KinsokuMode.d.ts +14 -0
- package/dist/org/tiqian/clreq/KinsokuMode.js +2 -0
- package/dist/org/tiqian/clreq/KinsokuModes.d.ts +11 -0
- package/dist/org/tiqian/clreq/KinsokuModes.js +71 -0
- package/dist/org/tiqian/clreq/LineAdjustmentStrategy.d.ts +16 -0
- package/dist/org/tiqian/clreq/LineAdjustmentStrategy.js +17 -0
- package/dist/org/tiqian/clreq/LineEndPunctuationStyle.d.ts +12 -0
- package/dist/org/tiqian/clreq/LineEndPunctuationStyle.js +14 -0
- package/dist/org/tiqian/clreq/PunctuationClass.d.ts +44 -0
- package/dist/org/tiqian/clreq/PunctuationClass.js +38 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacement.d.ts +12 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacement.js +14 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacements.d.ts +9 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacements.js +49 -0
- package/dist/org/tiqian/clreq/PunctuationWidthPolicy.d.ts +8 -0
- package/dist/org/tiqian/clreq/PunctuationWidthPolicy.js +16 -0
- package/dist/org/tiqian/clreq/ResolvedKinsoku.d.ts +12 -0
- package/dist/org/tiqian/clreq/ResolvedKinsoku.js +43 -0
- package/dist/org/tiqian/core/Cluster.d.ts +13 -0
- package/dist/org/tiqian/core/Cluster.js +24 -0
- package/dist/org/tiqian/core/EastAsianSpacingData.d.ts +4 -0
- package/dist/org/tiqian/core/EastAsianSpacingData.js +399 -0
- package/dist/org/tiqian/core/EastAsianSpacingEdges.d.ts +8 -0
- package/dist/org/tiqian/core/EastAsianSpacingEdges.js +14 -0
- package/dist/org/tiqian/core/EastAsianSpacingValue.d.ts +20 -0
- package/dist/org/tiqian/core/EastAsianSpacingValue.js +20 -0
- package/dist/org/tiqian/core/Ic.d.ts +7 -0
- package/dist/org/tiqian/core/Ic.js +17 -0
- package/dist/org/tiqian/core/IllegalStateException.d.ts +4 -0
- package/dist/org/tiqian/core/IllegalStateException.js +8 -0
- package/dist/org/tiqian/core/IntRange.d.ts +12 -0
- package/dist/org/tiqian/core/IntRange.js +30 -0
- package/dist/org/tiqian/core/LineEndReason.d.ts +16 -0
- package/dist/org/tiqian/core/LineEndReason.js +17 -0
- package/dist/org/tiqian/core/SourceBoundaryBias.d.ts +16 -0
- package/dist/org/tiqian/core/SourceBoundaryBias.js +17 -0
- package/dist/org/tiqian/core/SourceInteractionBoundaries.d.ts +29 -0
- package/dist/org/tiqian/core/SourceInteractionBoundaries.js +193 -0
- package/dist/org/tiqian/core/TextRange.d.ts +11 -0
- package/dist/org/tiqian/core/TextRange.js +40 -0
- package/dist/org/tiqian/core/TextRangeError.d.ts +11 -0
- package/dist/org/tiqian/core/TextRangeError.js +2 -0
- package/dist/org/tiqian/core/TiqianIllegalArgumentException.d.ts +6 -0
- package/dist/org/tiqian/core/TiqianIllegalArgumentException.js +21 -0
- package/dist/org/tiqian/core/TiqianNoSuchElementException.d.ts +10 -0
- package/dist/org/tiqian/core/TiqianNoSuchElementException.js +16 -0
- package/dist/org/tiqian/core/UnicodeCombiningMarkData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeCombiningMarkData.js +109 -0
- package/dist/org/tiqian/core/UnicodeEastAsianSpacing.d.ts +16 -0
- package/dist/org/tiqian/core/UnicodeEastAsianSpacing.js +88 -0
- package/dist/org/tiqian/core/UnicodeEmojiModifierBaseData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeEmojiModifierBaseData.js +35 -0
- package/dist/org/tiqian/core/UnicodeExtendedPictographicData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeExtendedPictographicData.js +64 -0
- package/dist/org/tiqian/core/UnicodeNumber.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeNumber.js +14 -0
- package/dist/org/tiqian/core/UnicodeNumberData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeNumberData.js +64 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidence.d.ts +16 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidence.js +17 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceClassifier.d.ts +7 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceClassifier.js +17 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceData.d.ts +4 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceData.js +295 -0
- package/dist/org/tiqian/core/UnicodeWordCharacter.d.ts +6 -0
- package/dist/org/tiqian/core/UnicodeWordCharacter.js +17 -0
- package/dist/org/tiqian/core/UnicodeWordCharacterData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeWordCharacterData.js +234 -0
- package/dist/org/tiqian/font/FontRole.d.ts +28 -0
- package/dist/org/tiqian/font/FontRole.js +26 -0
- package/dist/org/tiqian/font/FontRoleContext.d.ts +13 -0
- package/dist/org/tiqian/font/FontRoleContext.js +28 -0
- package/dist/org/tiqian/layout/ContextualQuoteRoleResolver.d.ts +51 -0
- package/dist/org/tiqian/layout/ContextualQuoteRoleResolver.js +305 -0
- package/dist/org/tiqian/layout/LineOptimization.d.ts +124 -0
- package/dist/org/tiqian/layout/LineOptimization.js +298 -0
- package/dist/org/tiqian/layout/ProgressiveBreakDecisions.d.ts +86 -0
- package/dist/org/tiqian/layout/ProgressiveBreakDecisions.js +415 -0
- package/dist/org/tiqian/layout/ProgressiveBreakTierPriority.d.ts +5 -0
- package/dist/org/tiqian/layout/ProgressiveBreakTierPriority.js +33 -0
- package/dist/org/tiqian/layout/QuotePairAnalyzer.d.ts +63 -0
- package/dist/org/tiqian/layout/QuotePairAnalyzer.js +251 -0
- package/dist/org/tiqian/linebreak/BreakKind.d.ts +20 -0
- package/dist/org/tiqian/linebreak/BreakKind.js +20 -0
- package/dist/org/tiqian/protocol/Canonical.d.ts +55 -0
- package/dist/org/tiqian/protocol/Canonical.js +471 -0
- package/dist/org/tiqian/protocol/DecorationInput.d.ts +6 -0
- package/dist/org/tiqian/protocol/DecorationInput.js +12 -0
- package/dist/org/tiqian/protocol/EncodeResult.d.ts +9 -0
- package/dist/org/tiqian/protocol/EncodeResult.js +2 -0
- package/dist/org/tiqian/protocol/FaceInfo.d.ts +13 -0
- package/dist/org/tiqian/protocol/FaceInfo.js +2 -0
- package/dist/org/tiqian/protocol/FontContract.d.ts +25 -0
- package/dist/org/tiqian/protocol/FontContract.js +317 -0
- package/dist/org/tiqian/protocol/FontFaceRecord.d.ts +6 -0
- package/dist/org/tiqian/protocol/FontFaceRecord.js +2 -0
- package/dist/org/tiqian/protocol/FontFaceSpec.d.ts +11 -0
- package/dist/org/tiqian/protocol/FontFaceSpec.js +2 -0
- package/dist/org/tiqian/protocol/FontWeightSpec.d.ts +10 -0
- package/dist/org/tiqian/protocol/FontWeightSpec.js +2 -0
- package/dist/org/tiqian/protocol/InlineBoxInput.d.ts +7 -0
- package/dist/org/tiqian/protocol/InlineBoxInput.js +2 -0
- package/dist/org/tiqian/protocol/InlineObjectInput.d.ts +7 -0
- package/dist/org/tiqian/protocol/InlineObjectInput.js +2 -0
- package/dist/org/tiqian/protocol/JsCoerce.d.ts +19 -0
- package/dist/org/tiqian/protocol/JsCoerce.js +394 -0
- package/dist/org/tiqian/protocol/LayoutAttribute.d.ts +5 -0
- package/dist/org/tiqian/protocol/LayoutAttribute.js +10 -0
- package/dist/org/tiqian/protocol/LayoutFloatShape.d.ts +14 -0
- package/dist/org/tiqian/protocol/LayoutFloatShape.js +2 -0
- package/dist/org/tiqian/protocol/LayoutTree.d.ts +23 -0
- package/dist/org/tiqian/protocol/LayoutTree.js +2 -0
- package/dist/org/tiqian/protocol/LayoutVertex.d.ts +4 -0
- package/dist/org/tiqian/protocol/LayoutVertex.js +2 -0
- package/dist/org/tiqian/protocol/LineBreakSpanInput.d.ts +6 -0
- package/dist/org/tiqian/protocol/LineBreakSpanInput.js +12 -0
- package/dist/org/tiqian/protocol/MetricEntry.d.ts +11 -0
- package/dist/org/tiqian/protocol/MetricEntry.js +21 -0
- package/dist/org/tiqian/protocol/NamedError.d.ts +88 -0
- package/dist/org/tiqian/protocol/NamedError.js +71 -0
- package/dist/org/tiqian/protocol/NamedErrorNames.d.ts +5 -0
- package/dist/org/tiqian/protocol/NamedErrorNames.js +53 -0
- package/dist/org/tiqian/protocol/ParagraphRequest.d.ts +25 -0
- package/dist/org/tiqian/protocol/ParagraphRequest.js +2 -0
- package/dist/org/tiqian/protocol/ParagraphRequestChecks.d.ts +8 -0
- package/dist/org/tiqian/protocol/ParagraphRequestChecks.js +145 -0
- package/dist/org/tiqian/protocol/ParagraphRequestException.d.ts +6 -0
- package/dist/org/tiqian/protocol/ParagraphRequestException.js +55 -0
- package/dist/org/tiqian/protocol/ParagraphRequestFields.d.ts +3 -0
- package/dist/org/tiqian/protocol/ParagraphRequestFields.js +4 -0
- package/dist/org/tiqian/protocol/Plan.d.ts +101 -0
- package/dist/org/tiqian/protocol/Plan.js +10 -0
- package/dist/org/tiqian/protocol/PlanEndReason.d.ts +16 -0
- package/dist/org/tiqian/protocol/PlanEndReason.js +17 -0
- package/dist/org/tiqian/protocol/PlanJsonNumber.d.ts +43 -0
- package/dist/org/tiqian/protocol/PlanJsonNumber.js +362 -0
- package/dist/org/tiqian/protocol/PlanSchema.d.ts +4 -0
- package/dist/org/tiqian/protocol/PlanSchema.js +5 -0
- package/dist/org/tiqian/protocol/PlanStyleDelta.d.ts +5 -0
- package/dist/org/tiqian/protocol/PlanStyleDelta.js +2 -0
- package/dist/org/tiqian/protocol/Revision.d.ts +11 -0
- package/dist/org/tiqian/protocol/Revision.js +12 -0
- package/dist/org/tiqian/protocol/SessionFaceSpec.d.ts +5 -0
- package/dist/org/tiqian/protocol/SessionFaceSpec.js +2 -0
- package/dist/org/tiqian/protocol/SnapshotTableBinary.d.ts +55 -0
- package/dist/org/tiqian/protocol/SnapshotTableBinary.js +657 -0
- package/dist/org/tiqian/protocol/SnapshotTypography.d.ts +14 -0
- package/dist/org/tiqian/protocol/SnapshotTypography.js +2 -0
- package/dist/org/tiqian/protocol/StyleRow.d.ts +8 -0
- package/dist/org/tiqian/protocol/StyleRow.js +15 -0
- package/dist/org/tiqian/protocol/TableData.d.ts +25 -0
- package/dist/org/tiqian/protocol/TableData.js +45 -0
- package/dist/org/tiqian/protocol/TableInput.d.ts +13 -0
- package/dist/org/tiqian/protocol/TableInput.js +21 -0
- package/dist/org/tiqian/protocol/TableMetricRow.d.ts +9 -0
- package/dist/org/tiqian/protocol/TableMetricRow.js +17 -0
- package/dist/org/tiqian/protocol/TableProbe.d.ts +11 -0
- package/dist/org/tiqian/protocol/TableProbe.js +21 -0
- package/dist/org/tiqian/protocol/TextSpanInput.d.ts +9 -0
- package/dist/org/tiqian/protocol/TextSpanInput.js +2 -0
- package/dist/org/tiqian/protocol/ValueRow.d.ts +4 -0
- package/dist/org/tiqian/protocol/ValueRow.js +7 -0
- package/dist/org/tiqian/protocol/WireField.d.ts +5 -0
- package/dist/org/tiqian/protocol/WireField.js +2 -0
- package/dist/org/tiqian/protocol/WireValue.d.ts +25 -0
- package/dist/org/tiqian/protocol/WireValue.js +2 -0
- package/dist/org/tiqian/test/TestHelpers.d.ts +5 -0
- package/dist/org/tiqian/test/TestHelpers.js +27 -0
- package/dist/org/tiqian/test/trace/TestTrace.d.ts +6 -0
- package/dist/org/tiqian/test/trace/TestTrace.js +8 -0
- package/dist/org/tiqian/test/trace/TestTracePlatform.d.ts +6 -0
- package/dist/org/tiqian/test/trace/TestTracePlatform.js +78 -0
- package/dist/org/tiqian/test/trace/TestTraceRecorder.d.ts +9 -0
- package/dist/org/tiqian/test/trace/TestTraceRecorder.js +36 -0
- package/dist/org/tiqian/test/trace/TestTraceRender.d.ts +47 -0
- package/dist/org/tiqian/test/trace/TestTraceRender.js +690 -0
- package/dist/org/tiqian/test/trace/TestTraceStore.d.ts +18 -0
- package/dist/org/tiqian/test/trace/TestTraceStore.js +149 -0
- package/dist/org/tiqian/test/trace/TraceAssertionError.d.ts +5 -0
- package/dist/org/tiqian/test/trace/TraceAssertionError.js +2 -0
- package/dist/org/tiqian/test/trace/TraceAssertionException.d.ts +6 -0
- package/dist/org/tiqian/test/trace/TraceAssertionException.js +16 -0
- package/dist/org/tiqian/test/trace/TraceField.d.ts +5 -0
- package/dist/org/tiqian/test/trace/TraceField.js +10 -0
- package/dist/org/tiqian/test/trace/TraceFormat.d.ts +21 -0
- package/dist/org/tiqian/test/trace/TraceFormat.js +184 -0
- package/dist/org/tiqian/test/trace/TracedAssertions.d.ts +78 -0
- package/dist/org/tiqian/test/trace/TracedAssertions.js +749 -0
- package/dist/runtime.d.ts +96 -0
- package/dist/runtime.js +1612 -0
- package/dist/std/FsError.d.ts +48 -0
- package/dist/std/FsError.js +2 -0
- package/dist/std/FsException.d.ts +6 -0
- package/dist/std/FsException.js +45 -0
- package/dist/std/UStringException.d.ts +6 -0
- package/dist/std/UStringException.js +21 -0
- package/dist/std/UStringFault.d.ts +9 -0
- package/dist/std/UStringFault.js +2 -0
- package/package.json +26 -4
- package/README.md +0 -3
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
import { Canonical } from "./Canonical.js";
|
|
3
|
+
import { JsCoerce } from "./JsCoerce.js";
|
|
4
|
+
import { readUnit } from "../../../runtime.js";
|
|
5
|
+
export class FontContract {
|
|
6
|
+
static requiredCjkDashContractInput(key, text, textSpans, typography) {
|
|
7
|
+
const textString = (FontContract.isWireNull(text) ? "" : JsCoerce.toString(text));
|
|
8
|
+
const spans = FontContract.arrOf(textSpans);
|
|
9
|
+
const order = [];
|
|
10
|
+
const signatures = [];
|
|
11
|
+
const styles = [];
|
|
12
|
+
const dashesPerGroup = [];
|
|
13
|
+
let offset = 0.0;
|
|
14
|
+
let i = 0;
|
|
15
|
+
const len = textString.length;
|
|
16
|
+
while (i < len) {
|
|
17
|
+
const code = (Number.isNaN(textString.charCodeAt(i)) ? null : textString.charCodeAt(i));
|
|
18
|
+
let dash = "";
|
|
19
|
+
if (code === 8212 && i + 1 < len && readUnit(textString, i + 1) === 8212) {
|
|
20
|
+
dash = "——";
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
if (code === 11834) {
|
|
24
|
+
dash = "⸺";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (dash !== "") {
|
|
28
|
+
const style = FontContract.resolvedStyleAt(offset, spans, typography);
|
|
29
|
+
const signature = JsCoerce.renderJson(FontContract.dashStyleToJson(style));
|
|
30
|
+
let index = 0;
|
|
31
|
+
let found = false;
|
|
32
|
+
let searchIdx = 0;
|
|
33
|
+
while (searchIdx < signatures.length) {
|
|
34
|
+
if (signatures[searchIdx] === signature) {
|
|
35
|
+
index = searchIdx;
|
|
36
|
+
found = true;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
searchIdx++;
|
|
40
|
+
}
|
|
41
|
+
if (!found) {
|
|
42
|
+
index = styles.length;
|
|
43
|
+
styles.push(style);
|
|
44
|
+
dashesPerGroup.push([]);
|
|
45
|
+
order.push(index);
|
|
46
|
+
signatures.push(signature);
|
|
47
|
+
}
|
|
48
|
+
let seen = false;
|
|
49
|
+
let dashIdx = 0;
|
|
50
|
+
while (dashIdx < dashesPerGroup[index].length) {
|
|
51
|
+
if (dashesPerGroup[index][dashIdx] === dash) {
|
|
52
|
+
seen = true;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
dashIdx++;
|
|
56
|
+
}
|
|
57
|
+
if (!seen) {
|
|
58
|
+
dashesPerGroup[index].push(dash);
|
|
59
|
+
}
|
|
60
|
+
if (dash === "——") {
|
|
61
|
+
offset += 2.0;
|
|
62
|
+
i += 2;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
offset += 1.0;
|
|
66
|
+
i += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (code >= 55296 && code <= 56319) {
|
|
71
|
+
offset += 2.0;
|
|
72
|
+
i += 2;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
offset += 1.0;
|
|
76
|
+
i += 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (styles.length === 0) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
let probe = "";
|
|
84
|
+
let probeLen = 0.0;
|
|
85
|
+
const outSpans = [];
|
|
86
|
+
for (let _g_index = 0, count = order.length; _g_index < count; _g_index += 1) {
|
|
87
|
+
const index2 = order[_g_index];
|
|
88
|
+
{
|
|
89
|
+
let _g = 0;
|
|
90
|
+
const _g1 = dashesPerGroup[index2];
|
|
91
|
+
while (_g < _g1.length) {
|
|
92
|
+
const dash2 = _g1[_g];
|
|
93
|
+
_g++;
|
|
94
|
+
const start = probeLen;
|
|
95
|
+
probe += dash2;
|
|
96
|
+
probeLen += (dash2 === "——" ? 2.0 : 1.0);
|
|
97
|
+
const end = probeLen;
|
|
98
|
+
const styleFields = FontContract.objFields(FontContract.dashStyleToJson(styles[index2]));
|
|
99
|
+
const fields = [{ name: "start", value: { kind: "WNum", value: start } }, { name: "end", value: { kind: "WNum", value: end } }];
|
|
100
|
+
{
|
|
101
|
+
let _g2 = 0;
|
|
102
|
+
while (_g2 < styleFields.length) {
|
|
103
|
+
const sf = styleFields[_g2];
|
|
104
|
+
_g2++;
|
|
105
|
+
fields.push(sf);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
outSpans.push({ kind: "WObj", fields });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { kind: "WObj", fields: [{ name: "key", value: { kind: "WStr", value: (FontContract.isWireNull(key) ? "" : JsCoerce.toString(key)) } }, { name: "text", value: { kind: "WStr", value: probe } }, { name: "textSpans", value: { kind: "WArr", items: outSpans } }] };
|
|
113
|
+
}
|
|
114
|
+
static matchedSpanAt(textOffset, spans) {
|
|
115
|
+
const n = spans.length;
|
|
116
|
+
let k = 0;
|
|
117
|
+
while (k < n) {
|
|
118
|
+
const candidate = spans[n - 1 - k];
|
|
119
|
+
const startRaw = Canonical.member(candidate, "start");
|
|
120
|
+
const endRaw = Canonical.member(candidate, "end");
|
|
121
|
+
if (FontContract.isRawNumber(startRaw) && FontContract.isRawNumber(endRaw)) {
|
|
122
|
+
const start = FontContract.rawNumber(startRaw);
|
|
123
|
+
const end = FontContract.rawNumber(endRaw);
|
|
124
|
+
if (FontContract.isSafeInteger(start) && FontContract.isSafeInteger(end) && textOffset >= start && textOffset < end) {
|
|
125
|
+
return candidate;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
k++;
|
|
129
|
+
}
|
|
130
|
+
return { kind: "WNull" };
|
|
131
|
+
}
|
|
132
|
+
static resolvedStyleAt(textOffset, spans, typography) {
|
|
133
|
+
const matched = FontContract.matchedSpanAt(textOffset, spans);
|
|
134
|
+
let fontFamilies = typography.fontFamilies;
|
|
135
|
+
const familiesRaw = Canonical.member(matched, "fontFamilies");
|
|
136
|
+
if (FontContract.isWireArr(familiesRaw)) {
|
|
137
|
+
fontFamilies = FontContract.mapStrings(FontContract.arrOf(familiesRaw));
|
|
138
|
+
}
|
|
139
|
+
const fontSizePx = FontContract.coerceNumberOr(Canonical.member(matched, "fontSizePx"), typography.fontSizePx);
|
|
140
|
+
const fontWeight = FontContract.coerceNumberOr(Canonical.member(matched, "fontWeight"), typography.fontWeight * 1.0);
|
|
141
|
+
const italic = FontContract.italicOr(Canonical.member(matched, "italic"), typography.italic);
|
|
142
|
+
const baselineShiftPx = FontContract.coerceNumberOr(Canonical.member(matched, "baselineShiftPx"), 0.0);
|
|
143
|
+
return { fontFamilies, fontSizePx, fontWeight, italic, baselineShiftPx };
|
|
144
|
+
}
|
|
145
|
+
static dashStyleToJson(style) {
|
|
146
|
+
const families = [];
|
|
147
|
+
{
|
|
148
|
+
const _g1 = style.fontFamilies;
|
|
149
|
+
for (let _g_index = 0, count2 = _g1.length; _g_index < count2; _g_index += 1) {
|
|
150
|
+
const family = _g1[_g_index];
|
|
151
|
+
families.push({ kind: "WStr", value: family });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { kind: "WObj", fields: [{ name: "fontFamilies", value: { kind: "WArr", items: families } }, { name: "fontSizePx", value: { kind: "WNum", value: style.fontSizePx } }, { name: "fontWeight", value: { kind: "WNum", value: style.fontWeight } }, { name: "italic", value: style.italic }, { name: "baselineShiftPx", value: { kind: "WNum", value: style.baselineShiftPx } }] };
|
|
155
|
+
}
|
|
156
|
+
static mapStrings(items) {
|
|
157
|
+
const out = [];
|
|
158
|
+
for (let _g_index = 0, count3 = items.length; _g_index < count3; _g_index += 1) {
|
|
159
|
+
const item = items[_g_index];
|
|
160
|
+
out.push(JsCoerce.toString(item));
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
static isWireNull(value) {
|
|
165
|
+
switch (value.kind) {
|
|
166
|
+
case "WNull":
|
|
167
|
+
return true;
|
|
168
|
+
case "WBool":
|
|
169
|
+
return false;
|
|
170
|
+
case "WNum":
|
|
171
|
+
return false;
|
|
172
|
+
case "WStr":
|
|
173
|
+
return false;
|
|
174
|
+
case "WArr":
|
|
175
|
+
return false;
|
|
176
|
+
case "WObj":
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
static isWireArr(value) {
|
|
181
|
+
switch (value.kind) {
|
|
182
|
+
case "WNull":
|
|
183
|
+
return false;
|
|
184
|
+
case "WBool":
|
|
185
|
+
return false;
|
|
186
|
+
case "WNum":
|
|
187
|
+
return false;
|
|
188
|
+
case "WStr":
|
|
189
|
+
return false;
|
|
190
|
+
case "WArr":
|
|
191
|
+
return true;
|
|
192
|
+
case "WObj":
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
static arrOf(value) {
|
|
197
|
+
switch (value.kind) {
|
|
198
|
+
case "WNull":
|
|
199
|
+
return new Array();
|
|
200
|
+
case "WBool":
|
|
201
|
+
return new Array();
|
|
202
|
+
case "WNum":
|
|
203
|
+
return new Array();
|
|
204
|
+
case "WStr":
|
|
205
|
+
return new Array();
|
|
206
|
+
case "WArr":
|
|
207
|
+
{
|
|
208
|
+
return value.items;
|
|
209
|
+
}
|
|
210
|
+
case "WObj":
|
|
211
|
+
return new Array();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
static objFields(value) {
|
|
215
|
+
switch (value.kind) {
|
|
216
|
+
case "WNull":
|
|
217
|
+
return new Array();
|
|
218
|
+
case "WBool":
|
|
219
|
+
return new Array();
|
|
220
|
+
case "WNum":
|
|
221
|
+
return new Array();
|
|
222
|
+
case "WStr":
|
|
223
|
+
return new Array();
|
|
224
|
+
case "WArr":
|
|
225
|
+
return new Array();
|
|
226
|
+
case "WObj":
|
|
227
|
+
{
|
|
228
|
+
return value.fields;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
static isRawNumber(value) {
|
|
233
|
+
switch (value.kind) {
|
|
234
|
+
case "WNull":
|
|
235
|
+
return false;
|
|
236
|
+
case "WBool":
|
|
237
|
+
return false;
|
|
238
|
+
case "WNum":
|
|
239
|
+
return true;
|
|
240
|
+
case "WStr":
|
|
241
|
+
return false;
|
|
242
|
+
case "WArr":
|
|
243
|
+
return false;
|
|
244
|
+
case "WObj":
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
static rawNumber(value) {
|
|
249
|
+
switch (value.kind) {
|
|
250
|
+
case "WNull":
|
|
251
|
+
return 0.0;
|
|
252
|
+
case "WBool":
|
|
253
|
+
return 0.0;
|
|
254
|
+
case "WNum":
|
|
255
|
+
{
|
|
256
|
+
return value.value;
|
|
257
|
+
}
|
|
258
|
+
case "WStr":
|
|
259
|
+
return 0.0;
|
|
260
|
+
case "WArr":
|
|
261
|
+
return 0.0;
|
|
262
|
+
case "WObj":
|
|
263
|
+
return 0.0;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
static coerceNumberOr(value, fallback) {
|
|
267
|
+
switch (value.kind) {
|
|
268
|
+
case "WNull":
|
|
269
|
+
return fallback;
|
|
270
|
+
case "WBool":
|
|
271
|
+
{
|
|
272
|
+
return (value.value ? 1.0 : 0.0);
|
|
273
|
+
}
|
|
274
|
+
case "WNum":
|
|
275
|
+
{
|
|
276
|
+
return value.value;
|
|
277
|
+
}
|
|
278
|
+
case "WStr":
|
|
279
|
+
{
|
|
280
|
+
return JsCoerce.toNumberFromString(value.value);
|
|
281
|
+
}
|
|
282
|
+
case "WArr":
|
|
283
|
+
return JsCoerce.toNumber(value);
|
|
284
|
+
case "WObj":
|
|
285
|
+
return JsCoerce.toNumber(value);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
static italicOr(value, fallback) {
|
|
289
|
+
switch (value.kind) {
|
|
290
|
+
case "WNull":
|
|
291
|
+
return { kind: "WBool", value: fallback };
|
|
292
|
+
case "WBool":
|
|
293
|
+
{
|
|
294
|
+
return { kind: "WBool", value: value.value };
|
|
295
|
+
}
|
|
296
|
+
case "WNum":
|
|
297
|
+
{
|
|
298
|
+
return { kind: "WNum", value: value.value };
|
|
299
|
+
}
|
|
300
|
+
case "WStr":
|
|
301
|
+
{
|
|
302
|
+
return { kind: "WStr", value: value.value };
|
|
303
|
+
}
|
|
304
|
+
case "WArr":
|
|
305
|
+
{
|
|
306
|
+
return { kind: "WArr", items: value.items };
|
|
307
|
+
}
|
|
308
|
+
case "WObj":
|
|
309
|
+
{
|
|
310
|
+
return { kind: "WObj", fields: value.fields };
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
static isSafeInteger(value) {
|
|
315
|
+
return value % 1.0 === 0.0 && Math.abs(value) <= 9007199254740991.0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FontWeightSpec } from "./FontWeightSpec.js";
|
|
2
|
+
export interface FontFaceSpec {
|
|
3
|
+
family: string;
|
|
4
|
+
publicUrl: string;
|
|
5
|
+
source: Uint8Array;
|
|
6
|
+
faceIndex: number | null;
|
|
7
|
+
weight: FontWeightSpec;
|
|
8
|
+
style: string;
|
|
9
|
+
unicodeRange: string | null;
|
|
10
|
+
sourceOrder: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type WireValue } from "./WireValue.js";
|
|
2
|
+
export declare class JsCoerce {
|
|
3
|
+
static toNumber(value: WireValue): number;
|
|
4
|
+
static toString(value: WireValue): string;
|
|
5
|
+
private static joinItems;
|
|
6
|
+
private static itemText;
|
|
7
|
+
static numberToString(value: number): string;
|
|
8
|
+
static toNumberFromString(text: string): number;
|
|
9
|
+
private static radixPrefix;
|
|
10
|
+
private static hexDigit;
|
|
11
|
+
private static isStrictDecimal;
|
|
12
|
+
private static isDecimalDigit;
|
|
13
|
+
private static jsTrim;
|
|
14
|
+
private static isJsWhitespace;
|
|
15
|
+
static renderJson(value: WireValue): string;
|
|
16
|
+
private static renderArray;
|
|
17
|
+
private static renderObject;
|
|
18
|
+
private static quoteJson;
|
|
19
|
+
}
|