@tiqian/protocol 0.0.0-stage.1 → 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,305 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
import { UnicodeEastAsianSpacing } from "./../core/UnicodeEastAsianSpacing.js";
|
|
3
|
+
import { UnicodeNumber } from "./../core/UnicodeNumber.js";
|
|
4
|
+
import { UnicodeScriptEvidenceClassifier } from "./../core/UnicodeScriptEvidenceClassifier.js";
|
|
5
|
+
import { UnicodeWordCharacter } from "./../core/UnicodeWordCharacter.js";
|
|
6
|
+
import { FontRole } from "./../font/FontRole.js";
|
|
7
|
+
import { QuoteRoleDecision } from "./QuotePairAnalyzer.js";
|
|
8
|
+
import { SortedTable, dictKey, readUnit } from "../../../runtime.js";
|
|
9
|
+
export class ContextualQuoteRoleResolver {
|
|
10
|
+
text;
|
|
11
|
+
pairs;
|
|
12
|
+
context;
|
|
13
|
+
pairByOpen;
|
|
14
|
+
pairByClose;
|
|
15
|
+
parentByPair;
|
|
16
|
+
constructor(text, pairs, context) {
|
|
17
|
+
this.text = text;
|
|
18
|
+
this.pairs = pairs;
|
|
19
|
+
this.context = context;
|
|
20
|
+
const openBuilder = SortedTable.mapBuilder(SortedTable.compareInts);
|
|
21
|
+
const closeBuilder = SortedTable.mapBuilder(SortedTable.compareInts);
|
|
22
|
+
let pi = 0;
|
|
23
|
+
while (pi < pairs.length) {
|
|
24
|
+
const pair = pairs[pi];
|
|
25
|
+
pi++;
|
|
26
|
+
openBuilder.put(pair.openIndex, pair);
|
|
27
|
+
closeBuilder.put(pair.closeIndex, pair);
|
|
28
|
+
}
|
|
29
|
+
this.pairByOpen = openBuilder.build();
|
|
30
|
+
this.pairByClose = closeBuilder.build();
|
|
31
|
+
const parentBuilder = SortedTable.mapBuilder(SortedTable.compareInts);
|
|
32
|
+
pi = 0;
|
|
33
|
+
while (pi < pairs.length) {
|
|
34
|
+
const pair2 = pairs[pi];
|
|
35
|
+
pi++;
|
|
36
|
+
parentBuilder.put(pair2.openIndex, (this.findParent(pair2)));
|
|
37
|
+
}
|
|
38
|
+
this.parentByPair = parentBuilder.build();
|
|
39
|
+
}
|
|
40
|
+
resolve() {
|
|
41
|
+
const decisions = [];
|
|
42
|
+
const resolvedPairs = SortedTable.mapBuilder(SortedTable.compareInts);
|
|
43
|
+
const pipeline_result = this.pairs.slice().sort((_a, _b) => { const _ka = _a.openIndex; const _kb = _b.openIndex; return _ka < _kb ? -1 : (_ka > _kb ? 1 : 0); });
|
|
44
|
+
const ordered = pipeline_result;
|
|
45
|
+
for (let _g_index = 0, count = ordered.length; _g_index < count; _g_index += 1) {
|
|
46
|
+
const pair = ordered[_g_index];
|
|
47
|
+
const resolution = this.resolvePair(pair, resolvedPairs);
|
|
48
|
+
resolvedPairs.put(pair.openIndex, resolution.role);
|
|
49
|
+
decisions.push(new QuoteRoleDecision(pair.openIndex, resolution.role, resolution.source, resolution.reason));
|
|
50
|
+
decisions.push(new QuoteRoleDecision(pair.closeIndex, resolution.role, resolution.source, resolution.reason));
|
|
51
|
+
}
|
|
52
|
+
const pairedIndicesBuilder = SortedTable.setBuilder(SortedTable.compareInts);
|
|
53
|
+
let pi = 0;
|
|
54
|
+
while (pi < this.pairs.length) {
|
|
55
|
+
const pair2 = this.pairs[pi];
|
|
56
|
+
pi++;
|
|
57
|
+
pairedIndicesBuilder.put(pair2.openIndex);
|
|
58
|
+
pairedIndicesBuilder.put(pair2.closeIndex);
|
|
59
|
+
}
|
|
60
|
+
const pairedIndices = pairedIndicesBuilder.build();
|
|
61
|
+
for (let index = 0, count2 = this.text.length; index < count2; index += 1) {
|
|
62
|
+
if (pairedIndices.has(index) || !ContextualQuoteRoleResolver.isAmbiguousCurlyQuote((Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index)))) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const resolution2 = this.resolveUnmatched(index);
|
|
66
|
+
decisions.push(new QuoteRoleDecision(index, resolution2.role, resolution2.source, resolution2.reason));
|
|
67
|
+
}
|
|
68
|
+
const pipeline_result1 = decisions.slice().sort((_a, _b) => { const _ka = _a.index; const _kb = _b.index; return _ka < _kb ? -1 : (_ka > _kb ? 1 : 0); });
|
|
69
|
+
const sorted = pipeline_result1;
|
|
70
|
+
return sorted;
|
|
71
|
+
}
|
|
72
|
+
resolvePair(pair, resolvedPairs) {
|
|
73
|
+
const parent = this.parentByPair.get(pair.openIndex);
|
|
74
|
+
const enclosingStart = (parent === null ? 0 : parent.openIndex + 1);
|
|
75
|
+
const enclosingEnd = (parent === null ? this.text.length : parent.closeIndex);
|
|
76
|
+
const outerEvidence = new ScriptEvidence(this);
|
|
77
|
+
outerEvidence.addRange(enclosingStart, pair.openIndex);
|
|
78
|
+
outerEvidence.addRange(pair.closeIndex + 1, enclosingEnd);
|
|
79
|
+
const contentEvidence = new ScriptEvidence(this);
|
|
80
|
+
contentEvidence.addRange(pair.openIndex + 1, pair.closeIndex);
|
|
81
|
+
if (this.charAt(pair.openIndex - 1) !== null && ContextualQuoteRoleResolver.isAsciiSpaceOrTab(this.charAt(pair.openIndex - 1)) && contentEvidence.hasWestern && !contentEvidence.hasCjk) {
|
|
82
|
+
return new Resolution(FontRole.LatinText, "DelimitedWesternQuotationRun", "whitespace-delimited-wholly-western-quotation");
|
|
83
|
+
}
|
|
84
|
+
if (this.isNonCjkWordInternalQuotePair(pair)) {
|
|
85
|
+
return new Resolution(FontRole.LatinText, "NonCjkWordInternalQuotePair", "non-cjk-word-internal-quotation");
|
|
86
|
+
}
|
|
87
|
+
const outerRole = outerEvidence.unambiguousRole();
|
|
88
|
+
if (outerRole !== null) {
|
|
89
|
+
return new Resolution((outerRole), "PairedPunctuationOuterScriptContext", "quote-pair-inherits-enclosing-level-script");
|
|
90
|
+
}
|
|
91
|
+
if (outerEvidence.isMixed) {
|
|
92
|
+
return this.paragraphLanguageResolution("mixed-enclosing-level-script");
|
|
93
|
+
}
|
|
94
|
+
if (parent !== null) {
|
|
95
|
+
const enclosingRole = resolvedPairs.get(parent.openIndex);
|
|
96
|
+
if (enclosingRole !== null) {
|
|
97
|
+
return new Resolution((enclosingRole), "PairedPunctuationEnclosingQuoteContext", "quote-pair-inherits-enclosing-quotation");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const contentRole = contentEvidence.unambiguousRole();
|
|
101
|
+
if (contentRole !== null) {
|
|
102
|
+
return new Resolution((contentRole), "PairedPunctuationContentScriptContext", "quoted-content-script");
|
|
103
|
+
}
|
|
104
|
+
return this.paragraphLanguageResolution((contentEvidence.isMixed ? "mixed-quoted-content" : "no-strong-script-context"));
|
|
105
|
+
}
|
|
106
|
+
resolveUnmatched(index) {
|
|
107
|
+
if ((Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index)) === 8217 && this.isNonCjkInWordApostrophe(index)) {
|
|
108
|
+
return new Resolution(FontRole.LatinText, "NonCjkInWordApostrophe", "non-cjk-in-word-apostrophe");
|
|
109
|
+
}
|
|
110
|
+
if (this.isDigitBoundClosingQuote(index)) {
|
|
111
|
+
return new Resolution(FontRole.LatinText, "NumericPrimeUnmatchedQuote", "digit-bound-unmatched-quote-as-prime");
|
|
112
|
+
}
|
|
113
|
+
const leftRole = this.nearestStrongScriptRole(index - 1, -1);
|
|
114
|
+
const rightRole = this.nearestStrongScriptRole(index + 1, 1);
|
|
115
|
+
if (ContextualQuoteRoleResolver.isAsciiSpaceOrTab(this.charAt(index - 1)) && (rightRole !== null && rightRole.kind === "LatinText")) {
|
|
116
|
+
return new Resolution(FontRole.LatinText, "DelimitedUnmatchedWesternQuote", "whitespace-delimited-unmatched-western-quote");
|
|
117
|
+
}
|
|
118
|
+
if (leftRole !== null && (rightRole === null || rightRole === leftRole)) {
|
|
119
|
+
return new Resolution((leftRole), "UnmatchedQuoteSurroundingScriptContext", "unmatched-quote-surrounding-script");
|
|
120
|
+
}
|
|
121
|
+
if (rightRole !== null && leftRole === null) {
|
|
122
|
+
return new Resolution((rightRole), "UnmatchedQuoteSurroundingScriptContext", "unmatched-quote-surrounding-script");
|
|
123
|
+
}
|
|
124
|
+
const reason = (leftRole !== null && rightRole !== null ? "conflicting-unmatched-quote-context" : "no-unmatched-quote-context");
|
|
125
|
+
return this.paragraphLanguageResolution(reason);
|
|
126
|
+
}
|
|
127
|
+
nearestStrongScriptRole(startIndex, direction) {
|
|
128
|
+
let index = startIndex;
|
|
129
|
+
while (index >= 0 && index < this.text.length) {
|
|
130
|
+
if (direction < 0) {
|
|
131
|
+
const pair = this.pairByClose.get(index);
|
|
132
|
+
if (pair !== null) {
|
|
133
|
+
index = pair.openIndex - 1;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const pair2 = this.pairByOpen.get(index);
|
|
139
|
+
if (pair2 !== null) {
|
|
140
|
+
index = pair2.closeIndex + 1;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const scalarStart = (direction < 0 && ContextualQuoteRoleResolver.isLowSurrogate((Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index))) && index > 0 && ContextualQuoteRoleResolver.isHighSurrogate(readUnit(this.text, index - 1)) ? index - 1 : index);
|
|
145
|
+
const length = this.codePointLengthAt(scalarStart, this.text.length);
|
|
146
|
+
const role = this.strongScriptRole(scalarStart, length);
|
|
147
|
+
if (role !== null) {
|
|
148
|
+
return role;
|
|
149
|
+
}
|
|
150
|
+
index = (direction < 0 ? scalarStart - 1 : scalarStart + length);
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
paragraphLanguageResolution(reason) {
|
|
155
|
+
const role = (UnicodeEastAsianSpacing.isChineseLanguageContext(this.context.locale) ? FontRole.CjkPunctuation : FontRole.LatinText);
|
|
156
|
+
return new Resolution(role, "ParagraphLanguageQuoteContext", reason + "; paragraph-language=" + this.context.locale);
|
|
157
|
+
}
|
|
158
|
+
findParent(pair) {
|
|
159
|
+
let result = null;
|
|
160
|
+
let ci = 0;
|
|
161
|
+
while (ci < this.pairs.length) {
|
|
162
|
+
const candidate = this.pairs[ci];
|
|
163
|
+
ci++;
|
|
164
|
+
if (dictKey(candidate) !== dictKey(pair) && candidate.openIndex < pair.openIndex && candidate.closeIndex > pair.closeIndex && (result === null || candidate.closeIndex - candidate.openIndex < result.closeIndex - result.openIndex)) {
|
|
165
|
+
result = candidate;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
strongScriptRole(index, length) {
|
|
171
|
+
const evidence = UnicodeScriptEvidenceClassifier.classify(this.codePointAt(index, index + length));
|
|
172
|
+
switch (evidence.kind) {
|
|
173
|
+
case "Neutral":
|
|
174
|
+
return null;
|
|
175
|
+
case "EastAsian":
|
|
176
|
+
return FontRole.CjkPunctuation;
|
|
177
|
+
case "Other":
|
|
178
|
+
return FontRole.LatinText;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
isNonCjkInWordApostrophe(index) {
|
|
182
|
+
const before = this.codePointBefore(index);
|
|
183
|
+
const after = this.codePointAtOrNull(index + 1);
|
|
184
|
+
return before !== null && after !== null && this.isNonCjkWordCharacter((before)) && this.isNonCjkWordCharacter((after)) && (this.isNonCjkNonNumericWordCharacter((before)) || this.isNonCjkNonNumericWordCharacter((after)));
|
|
185
|
+
}
|
|
186
|
+
isDigitBoundClosingQuote(index) {
|
|
187
|
+
const before = this.codePointBefore(index);
|
|
188
|
+
return ((Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index)) === 8217 || (Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index)) === 8221) && before !== null && UnicodeNumber.contains((before));
|
|
189
|
+
}
|
|
190
|
+
isNonCjkWordInternalQuotePair(pair) {
|
|
191
|
+
const before = this.codePointBefore(pair.openIndex);
|
|
192
|
+
const after = this.codePointAtOrNull(pair.closeIndex + 1);
|
|
193
|
+
if (before === null || after === null || !this.isNonCjkNonNumericWordCharacter((before)) || !this.isNonCjkNonNumericWordCharacter((after))) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
let index = pair.openIndex + 1;
|
|
197
|
+
while (index < pair.closeIndex) {
|
|
198
|
+
const codePoint = this.codePointAtOrNull(index);
|
|
199
|
+
if (codePoint === null || !this.isNonCjkWordCharacter((codePoint))) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
index += (codePoint > 65535 ? 2 : 1);
|
|
203
|
+
}
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
isNonCjkWordCharacter(codePoint) {
|
|
207
|
+
return UnicodeWordCharacter.contains(codePoint) && UnicodeScriptEvidenceClassifier.classify(codePoint).kind !== "EastAsian";
|
|
208
|
+
}
|
|
209
|
+
isNonCjkNonNumericWordCharacter(codePoint) {
|
|
210
|
+
return this.isNonCjkWordCharacter(codePoint) && !UnicodeNumber.contains(codePoint) && !this.isFullwidth(codePoint);
|
|
211
|
+
}
|
|
212
|
+
isFullwidth(codePoint) {
|
|
213
|
+
return codePoint === 12288 || codePoint >= 65281 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510;
|
|
214
|
+
}
|
|
215
|
+
charAt(index) {
|
|
216
|
+
return (index >= 0 && index < this.text.length ? (Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index)) : null);
|
|
217
|
+
}
|
|
218
|
+
codePointAt(index, end) {
|
|
219
|
+
const high = (Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index));
|
|
220
|
+
if (!ContextualQuoteRoleResolver.isHighSurrogate(high) || index + 1 >= end) {
|
|
221
|
+
return high;
|
|
222
|
+
}
|
|
223
|
+
const low = readUnit(this.text, index + 1);
|
|
224
|
+
return (ContextualQuoteRoleResolver.isLowSurrogate(low) ? 65536 + (high - 55296 << 10) + low - 56320 : high);
|
|
225
|
+
}
|
|
226
|
+
codePointLengthAt(index, end) {
|
|
227
|
+
return (ContextualQuoteRoleResolver.isHighSurrogate((Number.isNaN(this.text.charCodeAt(index)) ? null : this.text.charCodeAt(index))) && index + 1 < end && ContextualQuoteRoleResolver.isLowSurrogate(readUnit(this.text, index + 1)) ? 2 : 1);
|
|
228
|
+
}
|
|
229
|
+
codePointBefore(index) {
|
|
230
|
+
if (index <= 0) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
const low = readUnit(this.text, index - 1);
|
|
234
|
+
if (!ContextualQuoteRoleResolver.isLowSurrogate(low) || index < 2) {
|
|
235
|
+
return low;
|
|
236
|
+
}
|
|
237
|
+
const high = readUnit(this.text, index - 2);
|
|
238
|
+
return (ContextualQuoteRoleResolver.isHighSurrogate(high) ? 65536 + (high - 55296 << 10) + low - 56320 : low);
|
|
239
|
+
}
|
|
240
|
+
codePointAtOrNull(index) {
|
|
241
|
+
return (index < 0 || index >= this.text.length ? null : this.codePointAt(index, this.text.length));
|
|
242
|
+
}
|
|
243
|
+
static isAmbiguousCurlyQuote(codePoint) {
|
|
244
|
+
return codePoint === 8216 || codePoint === 8217 || codePoint === 8220 || codePoint === 8221;
|
|
245
|
+
}
|
|
246
|
+
static isAsciiSpaceOrTab(codePoint) {
|
|
247
|
+
return codePoint !== null && (codePoint === 32 || codePoint === 9);
|
|
248
|
+
}
|
|
249
|
+
static isHighSurrogate(codePoint) {
|
|
250
|
+
return codePoint >= 55296 && codePoint <= 56319;
|
|
251
|
+
}
|
|
252
|
+
static isLowSurrogate(codePoint) {
|
|
253
|
+
return codePoint >= 56320 && codePoint <= 57343;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
export class ScriptEvidence {
|
|
257
|
+
hasCjk;
|
|
258
|
+
hasWestern;
|
|
259
|
+
resolver;
|
|
260
|
+
constructor(resolver) {
|
|
261
|
+
this.hasWestern = false;
|
|
262
|
+
this.hasCjk = false;
|
|
263
|
+
this.resolver = resolver;
|
|
264
|
+
}
|
|
265
|
+
get isMixed() {
|
|
266
|
+
return this.get_isMixed();
|
|
267
|
+
}
|
|
268
|
+
get_isMixed() {
|
|
269
|
+
return this.hasCjk && this.hasWestern;
|
|
270
|
+
}
|
|
271
|
+
addRange(start, end) {
|
|
272
|
+
let index = start;
|
|
273
|
+
while (index < end) {
|
|
274
|
+
const nested = this.resolver.pairByOpen.get(index);
|
|
275
|
+
if (nested !== null && nested.closeIndex < end) {
|
|
276
|
+
index = nested.closeIndex + 1;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const length = this.resolver.codePointLengthAt(index, end);
|
|
280
|
+
const role = this.resolver.strongScriptRole(index, length);
|
|
281
|
+
if ((role !== null && role.kind === "CjkPunctuation")) {
|
|
282
|
+
this.hasCjk = true;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
if ((role !== null && role.kind === "LatinText")) {
|
|
286
|
+
this.hasWestern = true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
index += length;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
unambiguousRole() {
|
|
293
|
+
return (this.hasCjk && !this.hasWestern ? FontRole.CjkPunctuation : (this.hasWestern && !this.hasCjk ? FontRole.LatinText : null));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
export class Resolution {
|
|
297
|
+
role;
|
|
298
|
+
source;
|
|
299
|
+
reason;
|
|
300
|
+
constructor(role, source, reason) {
|
|
301
|
+
this.role = role;
|
|
302
|
+
this.source = source;
|
|
303
|
+
this.reason = reason;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { IntRange } from "./../core/IntRange.js";
|
|
2
|
+
import { LineEndReason } from "./../core/LineEndReason.js";
|
|
3
|
+
import { type TextRange } from "./../core/TextRange.js";
|
|
4
|
+
import { ShrinkChannel } from "./ProgressiveBreakDecisions.js";
|
|
5
|
+
import { type BreakKind } from "./../linebreak/BreakKind.js";
|
|
6
|
+
import { SortedSetTable } from "../../../runtime.js";
|
|
7
|
+
export declare class BreakCandidate {
|
|
8
|
+
readonly index: number;
|
|
9
|
+
readonly kind: BreakKind;
|
|
10
|
+
readonly naturalWidth: number;
|
|
11
|
+
readonly compressedWidth: number;
|
|
12
|
+
readonly expandedWidth: number;
|
|
13
|
+
readonly forbiddenReason: string | null;
|
|
14
|
+
readonly repairOptions: RepairOption[];
|
|
15
|
+
constructor(index: number, kind: BreakKind, naturalWidth: number, compressedWidth: number, expandedWidth: number, forbiddenReason?: string | null, repairOptions?: RepairOption[] | null);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class RepairOptions {
|
|
19
|
+
static penalty(o: RepairOption): number;
|
|
20
|
+
static reason(o: RepairOption): string;
|
|
21
|
+
static hangOffender(o: RepairOption): number | null;
|
|
22
|
+
static pushInReasonOf(o: RepairOption): string | null;
|
|
23
|
+
static pushInAllocations(o: RepairOption): PushInAllocation[] | null;
|
|
24
|
+
}
|
|
25
|
+
export declare class PushInAllocation {
|
|
26
|
+
readonly clusterIndex: number;
|
|
27
|
+
readonly shrink: number;
|
|
28
|
+
readonly availableCapacity: number;
|
|
29
|
+
readonly channel: ShrinkChannel;
|
|
30
|
+
constructor(clusterIndex: number, shrink: number, availableCapacity: number, channel?: ShrinkChannel | null);
|
|
31
|
+
toString(): string;
|
|
32
|
+
}
|
|
33
|
+
export declare class LineCandidate {
|
|
34
|
+
readonly clusterRange: IntRange;
|
|
35
|
+
readonly sourceRange: TextRange;
|
|
36
|
+
readonly naturalWidth: number;
|
|
37
|
+
readonly adjustedWidth: number;
|
|
38
|
+
readonly endReason: LineEndReason;
|
|
39
|
+
readonly repair: RepairOption | null;
|
|
40
|
+
readonly repairCandidates: RepairCandidate[];
|
|
41
|
+
readonly hangingClusterIndices: SortedSetTable<number>;
|
|
42
|
+
constructor(clusterRange: IntRange, sourceRange: TextRange, naturalWidth: number, adjustedWidth: number, endReason?: LineEndReason | null, repair?: RepairOption | null, repairCandidates?: RepairCandidate[] | null, hangingClusterIndices?: SortedSetTable<number> | null);
|
|
43
|
+
get hangingClusterIndex(): number | null;
|
|
44
|
+
get_hangingClusterIndex(): number | null;
|
|
45
|
+
get inMeasureClusterRange(): IntRange;
|
|
46
|
+
get_inMeasureClusterRange(): IntRange;
|
|
47
|
+
toString(): string;
|
|
48
|
+
static emptyHanging(): SortedSetTable<number>;
|
|
49
|
+
}
|
|
50
|
+
export declare class LineCandidates {
|
|
51
|
+
static renderRange(r: IntRange): string;
|
|
52
|
+
}
|
|
53
|
+
export declare class RepairCandidate {
|
|
54
|
+
readonly kind: string;
|
|
55
|
+
readonly reasonCode: string;
|
|
56
|
+
readonly offenderClusterIndex: number;
|
|
57
|
+
readonly penalty: number;
|
|
58
|
+
readonly accepted: boolean;
|
|
59
|
+
readonly rejectionReason: string | null;
|
|
60
|
+
readonly targetClusterIndex: number | null;
|
|
61
|
+
readonly carriedClusterIndex: number | null;
|
|
62
|
+
readonly shrink: number;
|
|
63
|
+
readonly requiredShrink: number;
|
|
64
|
+
readonly availableCapacity: number;
|
|
65
|
+
constructor(kind: string, reasonCode: string, offenderClusterIndex: number, penalty: number, accepted: boolean, rejectionReason?: string | null, targetClusterIndex?: number | null, carriedClusterIndex?: number | null, shrink?: number | null, requiredShrink?: number | null, availableCapacity?: number | null);
|
|
66
|
+
toString(): string;
|
|
67
|
+
}
|
|
68
|
+
export declare class LineSolution {
|
|
69
|
+
readonly lines: LineCandidate[];
|
|
70
|
+
readonly totalBadness: number;
|
|
71
|
+
constructor(lines?: LineCandidate[] | null, totalBadness?: number | null);
|
|
72
|
+
toString(): string;
|
|
73
|
+
}
|
|
74
|
+
export interface PushIn {
|
|
75
|
+
readonly kind: "PushIn";
|
|
76
|
+
readonly penalty: number;
|
|
77
|
+
readonly reason: string;
|
|
78
|
+
readonly offenderClusterIndex: number;
|
|
79
|
+
readonly allocations: PushInAllocation[];
|
|
80
|
+
readonly totalShrink: number;
|
|
81
|
+
readonly totalAvailableCapacity: number;
|
|
82
|
+
}
|
|
83
|
+
export interface Hang {
|
|
84
|
+
readonly kind: "Hang";
|
|
85
|
+
readonly penalty: number;
|
|
86
|
+
readonly reason: string;
|
|
87
|
+
readonly offenderClusterIndex: number;
|
|
88
|
+
}
|
|
89
|
+
export interface CarryPrevious {
|
|
90
|
+
readonly kind: "CarryPrevious";
|
|
91
|
+
readonly penalty: number;
|
|
92
|
+
readonly reason: string;
|
|
93
|
+
readonly offenderClusterIndex: number;
|
|
94
|
+
readonly carriedClusterIndex: number;
|
|
95
|
+
}
|
|
96
|
+
export interface CarryNext {
|
|
97
|
+
readonly kind: "CarryNext";
|
|
98
|
+
readonly penalty: number;
|
|
99
|
+
readonly reason: string;
|
|
100
|
+
readonly movedClusterIndex: number;
|
|
101
|
+
}
|
|
102
|
+
export interface LeaveRagged {
|
|
103
|
+
readonly kind: "LeaveRagged";
|
|
104
|
+
readonly penalty: number;
|
|
105
|
+
readonly reason: string;
|
|
106
|
+
readonly offenderClusterIndex: number;
|
|
107
|
+
}
|
|
108
|
+
export type RepairOption = PushIn | Hang | CarryPrevious | CarryNext | LeaveRagged;
|
|
109
|
+
export interface Greedy {
|
|
110
|
+
readonly kind: "Greedy";
|
|
111
|
+
}
|
|
112
|
+
export interface Lookahead {
|
|
113
|
+
readonly kind: "Lookahead";
|
|
114
|
+
}
|
|
115
|
+
export interface ParagraphDynamicProgramming {
|
|
116
|
+
readonly kind: "ParagraphDynamicProgramming";
|
|
117
|
+
}
|
|
118
|
+
export type LineOptimizationStrategy = Greedy | Lookahead | ParagraphDynamicProgramming;
|
|
119
|
+
export declare const LineOptimizationStrategy: Readonly<{
|
|
120
|
+
Greedy: Readonly<Greedy>;
|
|
121
|
+
Lookahead: Readonly<Lookahead>;
|
|
122
|
+
ParagraphDynamicProgramming: Readonly<ParagraphDynamicProgramming>;
|
|
123
|
+
}>;
|
|
124
|
+
export declare function compareLineOptimizationStrategy(a: LineOptimizationStrategy, b: LineOptimizationStrategy): number;
|