@tiqian/shared 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.
- 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/shared/SnapshotValueStyle.d.ts +11 -0
- package/dist/org/tiqian/shared/SnapshotValueStyle.js +64 -0
- package/dist/org/tiqian/shared/ValueStyleInterner.d.ts +7 -0
- package/dist/org/tiqian/shared/ValueStyleInterner.js +23 -0
- package/dist/org/tiqian/shared/html/CompoundSelector.d.ts +28 -0
- package/dist/org/tiqian/shared/html/CompoundSelector.js +247 -0
- package/dist/org/tiqian/shared/html/DomAttribute.d.ts +5 -0
- package/dist/org/tiqian/shared/html/DomAttribute.js +10 -0
- package/dist/org/tiqian/shared/html/DomNode.d.ts +10 -0
- package/dist/org/tiqian/shared/html/DomNode.js +2 -0
- package/dist/org/tiqian/shared/html/DomParser.d.ts +16 -0
- package/dist/org/tiqian/shared/html/DomParser.js +84 -0
- package/dist/org/tiqian/shared/html/HtmlAttributeInsertion.d.ts +4 -0
- package/dist/org/tiqian/shared/html/HtmlAttributeInsertion.js +2 -0
- package/dist/org/tiqian/shared/html/HtmlError.d.ts +16 -0
- package/dist/org/tiqian/shared/html/HtmlError.js +17 -0
- package/dist/org/tiqian/shared/html/HtmlNameCase.d.ts +3 -0
- package/dist/org/tiqian/shared/html/HtmlNameCase.js +20 -0
- package/dist/org/tiqian/shared/html/HtmlOpeningTag.d.ts +6 -0
- package/dist/org/tiqian/shared/html/HtmlOpeningTag.js +12 -0
- package/dist/org/tiqian/shared/html/HtmlParseException.d.ts +6 -0
- package/dist/org/tiqian/shared/html/HtmlParseException.js +19 -0
- package/dist/org/tiqian/shared/html/HtmlScan.d.ts +16 -0
- package/dist/org/tiqian/shared/html/HtmlScan.js +191 -0
- package/dist/org/tiqian/shared/prepared_dom/AttributeEntry.d.ts +5 -0
- package/dist/org/tiqian/shared/prepared_dom/AttributeEntry.js +10 -0
- package/dist/org/tiqian/shared/prepared_dom/BopomofoPlacement.d.ts +8 -0
- package/dist/org/tiqian/shared/prepared_dom/BopomofoPlacement.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/BopomofoPlacementCss.d.ts +6 -0
- package/dist/org/tiqian/shared/prepared_dom/BopomofoPlacementCss.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/BopomofoZone.d.ts +7 -0
- package/dist/org/tiqian/shared/prepared_dom/BopomofoZone.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/EmphasisDotColorResolver.d.ts +4 -0
- package/dist/org/tiqian/shared/prepared_dom/EmphasisDotColorResolver.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/Evidence.d.ts +33 -0
- package/dist/org/tiqian/shared/prepared_dom/Evidence.js +251 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceDecorationKind.d.ts +12 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceDecorationKind.js +14 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceDecorationSegment.d.ts +7 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceDecorationSegment.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceEmphasisDot.d.ts +6 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceEmphasisDot.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceOverlayOptions.d.ts +4 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceOverlayOptions.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceOverlayPlan.d.ts +9 -0
- package/dist/org/tiqian/shared/prepared_dom/EvidenceOverlayPlan.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/FixedEmphasisDotColor.d.ts +5 -0
- package/dist/org/tiqian/shared/prepared_dom/FixedEmphasisDotColor.js +8 -0
- package/dist/org/tiqian/shared/prepared_dom/InlineBoxEntry.d.ts +6 -0
- package/dist/org/tiqian/shared/prepared_dom/InlineBoxEntry.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/InlineEdgeEntry.d.ts +5 -0
- package/dist/org/tiqian/shared/prepared_dom/InlineEdgeEntry.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/InlineObjectPlaceholderCell.d.ts +6 -0
- package/dist/org/tiqian/shared/prepared_dom/InlineObjectPlaceholderCell.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/Markup.d.ts +30 -0
- package/dist/org/tiqian/shared/prepared_dom/Markup.js +344 -0
- package/dist/org/tiqian/shared/prepared_dom/MarkupArtifact.d.ts +12 -0
- package/dist/org/tiqian/shared/prepared_dom/MarkupArtifact.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/MarkupContainer.d.ts +7 -0
- package/dist/org/tiqian/shared/prepared_dom/MarkupContainer.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/MarkupNode.d.ts +5 -0
- package/dist/org/tiqian/shared/prepared_dom/MarkupNode.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/NumericFeatureContract.d.ts +4 -0
- package/dist/org/tiqian/shared/prepared_dom/NumericFeatureContract.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/NumericFeatures.d.ts +8 -0
- package/dist/org/tiqian/shared/prepared_dom/NumericFeatures.js +50 -0
- package/dist/org/tiqian/shared/prepared_dom/PlanBopomofoZone.d.ts +8 -0
- package/dist/org/tiqian/shared/prepared_dom/PlanBopomofoZone.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PlanRubyAnnotation.d.ts +10 -0
- package/dist/org/tiqian/shared/prepared_dom/PlanRubyAnnotation.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifact.d.ts +23 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifact.js +477 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifactOptions.d.ts +15 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifactOptions.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifactResult.d.ts +8 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifactResult.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifactState.d.ts +11 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedArtifactState.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedCjkStrongSemantic.d.ts +5 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedCjkStrongSemantic.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDom.d.ts +29 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDom.js +191 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDomError.d.ts +15 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDomError.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDomException.d.ts +6 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDomException.js +25 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDomTestSupport.d.ts +11 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedDomTestSupport.js +93 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedEmphasisRange.d.ts +4 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedEmphasisRange.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedLineChild.d.ts +16 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedLineChild.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedPlan.d.ts +19 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedPlan.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedPlanCell.d.ts +26 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedPlanCell.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedPlanLine.d.ts +13 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedPlanLine.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRenderTextSpan.d.ts +6 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRenderTextSpan.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRunRenderInput.d.ts +23 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRunRenderInput.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRunSignature.d.ts +19 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRunSignature.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRunTyped.d.ts +32 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedRunTyped.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedSemanticSpan.d.ts +10 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedSemanticSpan.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedSpacingResult.d.ts +4 -0
- package/dist/org/tiqian/shared/prepared_dom/PreparedSpacingResult.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/RenderedMarkupContainer.d.ts +16 -0
- package/dist/org/tiqian/shared/prepared_dom/RenderedMarkupContainer.js +48 -0
- package/dist/org/tiqian/shared/prepared_dom/RenderedMarkupNode.d.ts +11 -0
- package/dist/org/tiqian/shared/prepared_dom/RenderedMarkupNode.js +21 -0
- package/dist/org/tiqian/shared/prepared_dom/RubyAnnotation.d.ts +9 -0
- package/dist/org/tiqian/shared/prepared_dom/RubyAnnotation.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/StyleClassResolver.d.ts +4 -0
- package/dist/org/tiqian/shared/prepared_dom/StyleClassResolver.js +2 -0
- package/dist/org/tiqian/shared/prepared_dom/StyleDelta.d.ts +5 -0
- package/dist/org/tiqian/shared/prepared_dom/StyleDelta.js +2 -0
- package/dist/org/tiqian/shared/snapshot/SnapshotSource.d.ts +24 -0
- package/dist/org/tiqian/shared/snapshot/SnapshotSource.js +135 -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/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 +22 -4
- package/README.md +0 -3
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
import { UnicodeNumber } from "./../core/UnicodeNumber.js";
|
|
3
|
+
import { UnicodeScriptEvidenceClassifier } from "./../core/UnicodeScriptEvidenceClassifier.js";
|
|
4
|
+
import { UnicodeWordCharacter } from "./../core/UnicodeWordCharacter.js";
|
|
5
|
+
import { FontRoleContext } from "./../font/FontRoleContext.js";
|
|
6
|
+
import { ContextualQuoteRoleResolver } from "./ContextualQuoteRoleResolver.js";
|
|
7
|
+
import { SortedTable, readUnit } from "../../../runtime.js";
|
|
8
|
+
export class QuotePair {
|
|
9
|
+
openIndex;
|
|
10
|
+
closeIndex;
|
|
11
|
+
quoteType;
|
|
12
|
+
constructor(openIndex, closeIndex, quoteType) {
|
|
13
|
+
this.openIndex = openIndex;
|
|
14
|
+
this.closeIndex = closeIndex;
|
|
15
|
+
this.quoteType = quoteType;
|
|
16
|
+
}
|
|
17
|
+
toString() {
|
|
18
|
+
return `QuotePair(openIndex=${this.openIndex}, closeIndex=${this.closeIndex}, quoteType=${this.quoteType.kind})`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function QuotePairquoteTypeOrder(v) {
|
|
22
|
+
if (v.kind === "Double")
|
|
23
|
+
return 0;
|
|
24
|
+
if (v.kind === "Single")
|
|
25
|
+
return 1;
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
export function compareQuotePair(a, b) {
|
|
29
|
+
if (a === b)
|
|
30
|
+
return 0;
|
|
31
|
+
if (a.openIndex !== b.openIndex)
|
|
32
|
+
return a.openIndex - b.openIndex;
|
|
33
|
+
if (a.closeIndex !== b.closeIndex)
|
|
34
|
+
return a.closeIndex - b.closeIndex;
|
|
35
|
+
if (QuotePairquoteTypeOrder(a.quoteType) !== QuotePairquoteTypeOrder(b.quoteType))
|
|
36
|
+
return QuotePairquoteTypeOrder(a.quoteType) - QuotePairquoteTypeOrder(b.quoteType);
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
export class QuoteRoleDecision {
|
|
40
|
+
index;
|
|
41
|
+
role;
|
|
42
|
+
source;
|
|
43
|
+
reason;
|
|
44
|
+
constructor(index, role, source, reason) {
|
|
45
|
+
this.index = index;
|
|
46
|
+
this.role = role;
|
|
47
|
+
this.source = source;
|
|
48
|
+
this.reason = reason;
|
|
49
|
+
}
|
|
50
|
+
toString() {
|
|
51
|
+
return `QuoteRoleDecision(index=${this.index}, role=${this.role.kind}, source=${this.source}, reason=${this.reason})`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function QuoteRoleDecisionroleOrder(v) {
|
|
55
|
+
if (v.kind === "CjkText")
|
|
56
|
+
return 0;
|
|
57
|
+
if (v.kind === "CjkPunctuation")
|
|
58
|
+
return 1;
|
|
59
|
+
if (v.kind === "LatinText")
|
|
60
|
+
return 2;
|
|
61
|
+
if (v.kind === "Symbol")
|
|
62
|
+
return 3;
|
|
63
|
+
if (v.kind === "Emoji")
|
|
64
|
+
return 4;
|
|
65
|
+
if (v.kind === "Unknown")
|
|
66
|
+
return 5;
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
export function compareQuoteRoleDecision(a, b) {
|
|
70
|
+
if (a === b)
|
|
71
|
+
return 0;
|
|
72
|
+
if (a.index !== b.index)
|
|
73
|
+
return a.index - b.index;
|
|
74
|
+
if (QuoteRoleDecisionroleOrder(a.role) !== QuoteRoleDecisionroleOrder(b.role))
|
|
75
|
+
return QuoteRoleDecisionroleOrder(a.role) - QuoteRoleDecisionroleOrder(b.role);
|
|
76
|
+
if (a.source !== b.source)
|
|
77
|
+
return a.source < b.source ? -1 : 1;
|
|
78
|
+
if (a.reason !== b.reason)
|
|
79
|
+
return a.reason < b.reason ? -1 : 1;
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
export class QuotePairAnalyzer {
|
|
83
|
+
constructor() {
|
|
84
|
+
}
|
|
85
|
+
analyze(text) {
|
|
86
|
+
const stack = [];
|
|
87
|
+
const pairs = [];
|
|
88
|
+
let index = 0;
|
|
89
|
+
while (index < text.length) {
|
|
90
|
+
const c = (Number.isNaN(text.charCodeAt(index)) ? null : text.charCodeAt(index));
|
|
91
|
+
if (c === 8220) {
|
|
92
|
+
stack.push({ index, type: QuoteType.Double });
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
if (c === 8216) {
|
|
96
|
+
stack.push({ index, type: QuoteType.Single });
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
if (c === 8221) {
|
|
100
|
+
if (stack.length > 0 && stack[stack.length - 1].type.kind === "Double") {
|
|
101
|
+
const match = stack.pop();
|
|
102
|
+
pairs.push(new QuotePair(match.index, index, QuoteType.Double));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if (c === 8217) {
|
|
107
|
+
if (!QuotePairAnalyzer.isNonCjkInWordApostrophe(text, index) && stack.length > 0 && stack[stack.length - 1].type.kind === "Single") {
|
|
108
|
+
const match2 = stack.pop();
|
|
109
|
+
pairs.push(new QuotePair(match2.index, index, QuoteType.Single));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
index++;
|
|
116
|
+
}
|
|
117
|
+
return pairs;
|
|
118
|
+
}
|
|
119
|
+
classifyPairs(text, pairs, context) {
|
|
120
|
+
context = context ?? null;
|
|
121
|
+
return QuotePairAnalyzer.mapDecisions(this.classifyQuoteRoles(text, pairs, context));
|
|
122
|
+
}
|
|
123
|
+
classifyPairsWithClassifier(text, pairs, _fontRoleClassifier, context) {
|
|
124
|
+
context = context ?? null;
|
|
125
|
+
return this.classifyPairs(text, pairs, context);
|
|
126
|
+
}
|
|
127
|
+
classifyQuoteRoles(text, pairs, context) {
|
|
128
|
+
context = context ?? null;
|
|
129
|
+
return new ContextualQuoteRoleResolver(text, pairs, ((context === null ? new FontRoleContext("zh-Hans", null) : context))).resolve();
|
|
130
|
+
}
|
|
131
|
+
classifyQuoteRolesWithClassifier(text, pairs, _fontRoleClassifier, context) {
|
|
132
|
+
context = context ?? null;
|
|
133
|
+
return this.classifyQuoteRoles(text, pairs, context);
|
|
134
|
+
}
|
|
135
|
+
static mapDecisions(decisions) {
|
|
136
|
+
const out = SortedTable.mapBuilder(SortedTable.compareInts);
|
|
137
|
+
for (let pipeline_index = 0, count = decisions.length; pipeline_index < count; pipeline_index += 1) {
|
|
138
|
+
const d = decisions[pipeline_index];
|
|
139
|
+
out.put(d.index, d.role);
|
|
140
|
+
}
|
|
141
|
+
return out.build();
|
|
142
|
+
}
|
|
143
|
+
static isNonCjkInWordApostrophe(text, index) {
|
|
144
|
+
const before = QuotePairAnalyzer.codePointBefore(text, index);
|
|
145
|
+
if (before === null) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
const after = QuotePairAnalyzer.codePointAtOrNull(text, index + 1);
|
|
149
|
+
if (after === null) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return QuotePairAnalyzer.isNonCjkWordCharacter((before)) && QuotePairAnalyzer.isNonCjkWordCharacter((after)) && (QuotePairAnalyzer.isNonCjkNonNumericWordCharacter((before)) || QuotePairAnalyzer.isNonCjkNonNumericWordCharacter((after)));
|
|
153
|
+
}
|
|
154
|
+
static isDigitBoundClosingQuote(text, index) {
|
|
155
|
+
return ((Number.isNaN(text.charCodeAt(index)) ? null : text.charCodeAt(index)) === 8217 || (Number.isNaN(text.charCodeAt(index)) ? null : text.charCodeAt(index)) === 8221) && QuotePairAnalyzer.codePointBefore(text, index) !== null && UnicodeNumber.contains((QuotePairAnalyzer.codePointBefore(text, index)));
|
|
156
|
+
}
|
|
157
|
+
static isNonCjkWordInternalQuotePair(text, pair) {
|
|
158
|
+
const before = QuotePairAnalyzer.codePointBefore(text, pair.openIndex);
|
|
159
|
+
const after = QuotePairAnalyzer.codePointAtOrNull(text, pair.closeIndex + 1);
|
|
160
|
+
if (before === null || after === null || !QuotePairAnalyzer.isNonCjkNonNumericWordCharacter((before)) || !QuotePairAnalyzer.isNonCjkNonNumericWordCharacter((after))) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
let index = pair.openIndex + 1;
|
|
164
|
+
while (index < pair.closeIndex) {
|
|
165
|
+
const cp = QuotePairAnalyzer.codePointAtOrNull(text, index);
|
|
166
|
+
if (cp === null || !QuotePairAnalyzer.isNonCjkWordCharacter((cp))) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
index += (cp > 65535 ? 2 : 1);
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
static isNonCjkWordCharacter(cp) {
|
|
174
|
+
return UnicodeWordCharacter.contains(cp) && UnicodeScriptEvidenceClassifier.classify(cp).kind !== "EastAsian";
|
|
175
|
+
}
|
|
176
|
+
static isNonCjkNonNumericWordCharacter(cp) {
|
|
177
|
+
return QuotePairAnalyzer.isNonCjkWordCharacter(cp) && !UnicodeNumber.contains(cp) && !QuotePairAnalyzer.isFullwidthEastAsianWidth(cp);
|
|
178
|
+
}
|
|
179
|
+
static isFullwidthEastAsianWidth(cp) {
|
|
180
|
+
return cp === 12288 || cp >= 65281 && cp <= 65376 || cp >= 65504 && cp <= 65510;
|
|
181
|
+
}
|
|
182
|
+
static codePointBefore(text, index) {
|
|
183
|
+
if (index <= 0) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const low = readUnit(text, index - 1);
|
|
187
|
+
if (low < 56320 || low > 57343 || index < 2) {
|
|
188
|
+
return low;
|
|
189
|
+
}
|
|
190
|
+
const high = readUnit(text, index - 2);
|
|
191
|
+
if (high < 55296 || high > 56319) {
|
|
192
|
+
return low;
|
|
193
|
+
}
|
|
194
|
+
return 65536 + (high - 55296 << 10) + (low - 56320);
|
|
195
|
+
}
|
|
196
|
+
static codePointAtOrNull(text, index) {
|
|
197
|
+
if (index < 0 || index >= text.length) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const high = (Number.isNaN(text.charCodeAt(index)) ? null : text.charCodeAt(index));
|
|
201
|
+
if (high < 55296 || high > 56319 || index + 1 >= text.length) {
|
|
202
|
+
return high;
|
|
203
|
+
}
|
|
204
|
+
const low = readUnit(text, index + 1);
|
|
205
|
+
if (low < 56320 || low > 57343) {
|
|
206
|
+
return high;
|
|
207
|
+
}
|
|
208
|
+
return 65536 + (high - 55296 << 10) + (low - 56320);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
export class QuotePairAwareFontRoleClassifier {
|
|
212
|
+
delegate;
|
|
213
|
+
quoteRoles;
|
|
214
|
+
constructor(delegate, quoteRoles) {
|
|
215
|
+
this.delegate = delegate;
|
|
216
|
+
this.quoteRoles = quoteRoles;
|
|
217
|
+
}
|
|
218
|
+
classify(text, range, context) {
|
|
219
|
+
context = context ?? null;
|
|
220
|
+
const role = this.quoteRoles.get(range.start);
|
|
221
|
+
return (role === null ? this.delegate.classify(text, range, context) : role);
|
|
222
|
+
}
|
|
223
|
+
static withContextualQuoteRoles(base, text, context) {
|
|
224
|
+
context = context ?? null;
|
|
225
|
+
const analyzer = new QuotePairAnalyzer();
|
|
226
|
+
const decisions = analyzer.classifyQuoteRoles(text, analyzer.analyze(text), context);
|
|
227
|
+
const count2 = decisions.length;
|
|
228
|
+
if (count2 === 0) {
|
|
229
|
+
return base;
|
|
230
|
+
}
|
|
231
|
+
const roles = SortedTable.mapBuilder(SortedTable.compareInts);
|
|
232
|
+
for (let pipeline_index = 0; pipeline_index < count2; pipeline_index += 1) {
|
|
233
|
+
const decision = decisions[pipeline_index];
|
|
234
|
+
roles.put(decision.index, decision.role);
|
|
235
|
+
}
|
|
236
|
+
return new QuotePairAwareFontRoleClassifier(base, roles.build());
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export const QuoteType = Object.freeze({
|
|
240
|
+
Double: Object.freeze({ kind: "Double" }),
|
|
241
|
+
Single: Object.freeze({ kind: "Single" })
|
|
242
|
+
});
|
|
243
|
+
export function compareQuoteType(a, b) {
|
|
244
|
+
if (a === b)
|
|
245
|
+
return 0;
|
|
246
|
+
if (a.kind === "Double")
|
|
247
|
+
return 0 - (b.kind === "Double" ? 0 : 0);
|
|
248
|
+
if (a.kind === "Single")
|
|
249
|
+
return 1 - (b.kind === "Single" ? 1 : 0);
|
|
250
|
+
return 0;
|
|
251
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface Allowed {
|
|
2
|
+
readonly kind: "Allowed";
|
|
3
|
+
}
|
|
4
|
+
export interface Forbidden {
|
|
5
|
+
readonly kind: "Forbidden";
|
|
6
|
+
}
|
|
7
|
+
export interface Required {
|
|
8
|
+
readonly kind: "Required";
|
|
9
|
+
}
|
|
10
|
+
export interface Problematic {
|
|
11
|
+
readonly kind: "Problematic";
|
|
12
|
+
}
|
|
13
|
+
export type BreakKind = Allowed | Forbidden | Required | Problematic;
|
|
14
|
+
export declare const BreakKind: Readonly<{
|
|
15
|
+
Allowed: Readonly<Allowed>;
|
|
16
|
+
Forbidden: Readonly<Forbidden>;
|
|
17
|
+
Required: Readonly<Required>;
|
|
18
|
+
Problematic: Readonly<Problematic>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function compareBreakKind(a: BreakKind, b: BreakKind): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
export const BreakKind = Object.freeze({
|
|
3
|
+
Allowed: Object.freeze({ kind: "Allowed" }),
|
|
4
|
+
Forbidden: Object.freeze({ kind: "Forbidden" }),
|
|
5
|
+
Required: Object.freeze({ kind: "Required" }),
|
|
6
|
+
Problematic: Object.freeze({ kind: "Problematic" })
|
|
7
|
+
});
|
|
8
|
+
export function compareBreakKind(a, b) {
|
|
9
|
+
if (a === b)
|
|
10
|
+
return 0;
|
|
11
|
+
if (a.kind === "Allowed")
|
|
12
|
+
return 0 - (b.kind === "Allowed" ? 0 : 0);
|
|
13
|
+
if (a.kind === "Forbidden")
|
|
14
|
+
return 1 - (b.kind === "Forbidden" ? 1 : 0);
|
|
15
|
+
if (a.kind === "Required")
|
|
16
|
+
return 2 - (b.kind === "Required" ? 2 : 0);
|
|
17
|
+
if (a.kind === "Problematic")
|
|
18
|
+
return 3 - (b.kind === "Problematic" ? 3 : 0);
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class SnapshotValueStyle {
|
|
2
|
+
static readonly VALUE_STYLE_SCOPE_ATTRIBUTE: string;
|
|
3
|
+
static readonly VALUE_STYLE_ELEMENT_ATTRIBUTE: string;
|
|
4
|
+
static readonly SNAPSHOT_STYLE_OWNER: string;
|
|
5
|
+
static snapshotValueStyleClass(index: number): string;
|
|
6
|
+
static runtimeValueStyleClass(key: string): string;
|
|
7
|
+
static runtimeValueStyleKey(declaration: string): string;
|
|
8
|
+
static toBase36Unsigned(value: number): string;
|
|
9
|
+
private static mulMod32;
|
|
10
|
+
private static mul16Full;
|
|
11
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
export class SnapshotValueStyle {
|
|
3
|
+
static VALUE_STYLE_SCOPE_ATTRIBUTE = "data-tq-value-style-scope";
|
|
4
|
+
static VALUE_STYLE_ELEMENT_ATTRIBUTE = "data-tq-prepared-value-styles";
|
|
5
|
+
static SNAPSHOT_STYLE_OWNER = "tiqian-snapshot-style-owner";
|
|
6
|
+
static snapshotValueStyleClass(index) {
|
|
7
|
+
return `tqv-${SnapshotValueStyle.toBase36Unsigned(index)}`;
|
|
8
|
+
}
|
|
9
|
+
static runtimeValueStyleClass(key) {
|
|
10
|
+
return `tqvr-${key}`;
|
|
11
|
+
}
|
|
12
|
+
static runtimeValueStyleKey(declaration) {
|
|
13
|
+
let a = -2128831035;
|
|
14
|
+
let b = 16777619;
|
|
15
|
+
const len = declaration.length;
|
|
16
|
+
for (let i = 0; i < len; i += 1) {
|
|
17
|
+
const code = (Number.isNaN(declaration.charCodeAt(i)) ? null : declaration.charCodeAt(i));
|
|
18
|
+
a = SnapshotValueStyle.mulMod32(a ^ code, 16777619);
|
|
19
|
+
b = SnapshotValueStyle.mulMod32(b ^ code + i, -2128831035);
|
|
20
|
+
}
|
|
21
|
+
return SnapshotValueStyle.toBase36Unsigned(a) + SnapshotValueStyle.toBase36Unsigned(b);
|
|
22
|
+
}
|
|
23
|
+
static toBase36Unsigned(value) {
|
|
24
|
+
const digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
25
|
+
let n = (value < 0 ? value + 4294967296.0 : value);
|
|
26
|
+
let out = "";
|
|
27
|
+
while (true) {
|
|
28
|
+
const digit = Math.trunc(n % 36);
|
|
29
|
+
out = digits.charAt(digit) + out;
|
|
30
|
+
n = Math.floor(n / 36);
|
|
31
|
+
if (n === 0) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
static mulMod32(value, prime) {
|
|
38
|
+
const vh = (value >>> 16) & 65535;
|
|
39
|
+
const vl = value & 65535;
|
|
40
|
+
const ph = (prime >>> 16) & 65535;
|
|
41
|
+
const pl = prime & 65535;
|
|
42
|
+
const d = SnapshotValueStyle.mul16Full(vl, pl);
|
|
43
|
+
const dLow = d & 65535;
|
|
44
|
+
const dHigh = (d >>> 16) & 65535;
|
|
45
|
+
const xLow = SnapshotValueStyle.mul16Full(vl, ph) & 65535;
|
|
46
|
+
const yLow = SnapshotValueStyle.mul16Full(vh, pl) & 65535;
|
|
47
|
+
const crossLow = xLow + yLow + dHigh & 65535;
|
|
48
|
+
return (crossLow << 16) | dLow;
|
|
49
|
+
}
|
|
50
|
+
static mul16Full(a, b) {
|
|
51
|
+
const ah = a >> 8;
|
|
52
|
+
const al = a & 255;
|
|
53
|
+
const bh = b >> 8;
|
|
54
|
+
const bl = b & 255;
|
|
55
|
+
const t0 = al * bl;
|
|
56
|
+
const t1 = ah * bl + al * bh;
|
|
57
|
+
const t2 = ah * bh;
|
|
58
|
+
const lowAccum = (t1 << 8) + t0;
|
|
59
|
+
const low16 = lowAccum & 65535;
|
|
60
|
+
const carry = (lowAccum >>> 16) & 65535;
|
|
61
|
+
const high16 = t2 + carry & 65535;
|
|
62
|
+
return (high16 << 16) | low16;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
export class ValueStyleInterner {
|
|
3
|
+
declarations;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.declarations = [];
|
|
6
|
+
}
|
|
7
|
+
intern(declaration) {
|
|
8
|
+
for (let i = 0, count = this.declarations.length; i < count; i += 1) {
|
|
9
|
+
if (this.declarations[i] === declaration) {
|
|
10
|
+
return i;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const index = this.declarations.length;
|
|
14
|
+
this.declarations.push(declaration);
|
|
15
|
+
return index;
|
|
16
|
+
}
|
|
17
|
+
at(index) {
|
|
18
|
+
return this.declarations[index];
|
|
19
|
+
}
|
|
20
|
+
size() {
|
|
21
|
+
return this.declarations.length;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type DomNode } from "./DomNode.js";
|
|
2
|
+
import { type DomParser } from "./DomParser.js";
|
|
3
|
+
export declare class CompoundSelector {
|
|
4
|
+
readonly tag: string | null;
|
|
5
|
+
readonly id: string | null;
|
|
6
|
+
readonly classes: string[];
|
|
7
|
+
readonly attributes: CompoundAttribute[];
|
|
8
|
+
constructor(tag: string | null, id: string | null, classes: string[], attributes: CompoundAttribute[]);
|
|
9
|
+
matches(parser: DomParser, element: DomNode): boolean;
|
|
10
|
+
static parseCompoundSelectorList(selector: string): CompoundSelector[];
|
|
11
|
+
private static parseCompoundSelector;
|
|
12
|
+
private static readSelectorWord;
|
|
13
|
+
private static isSelectorWordStart;
|
|
14
|
+
private static isSelectorWordCharacter;
|
|
15
|
+
private static jsSelectorTrim;
|
|
16
|
+
private static isSelectorTrimWhitespace;
|
|
17
|
+
private static splitAsciiWhitespace;
|
|
18
|
+
private static unsupported;
|
|
19
|
+
}
|
|
20
|
+
export interface CompoundAttribute {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface SelectorWord {
|
|
25
|
+
name: string;
|
|
26
|
+
next: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function compareSelectorWord(a: SelectorWord, b: SelectorWord): number;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
import { HtmlError } from "./HtmlError.js";
|
|
3
|
+
import { HtmlNameCase } from "./HtmlNameCase.js";
|
|
4
|
+
import { HtmlParseException } from "./HtmlParseException.js";
|
|
5
|
+
export class CompoundSelector {
|
|
6
|
+
tag;
|
|
7
|
+
id;
|
|
8
|
+
classes;
|
|
9
|
+
attributes;
|
|
10
|
+
constructor(tag, id, classes, attributes) {
|
|
11
|
+
this.tag = tag;
|
|
12
|
+
this.id = id;
|
|
13
|
+
this.classes = classes;
|
|
14
|
+
this.attributes = attributes;
|
|
15
|
+
}
|
|
16
|
+
matches(parser, element) {
|
|
17
|
+
if (this.tag !== null && this.tag !== parser.tagName(element)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (this.id !== null) {
|
|
21
|
+
const actualId = parser.attributeValue(element, "id");
|
|
22
|
+
if (actualId === null || actualId !== this.id) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (this.classes.length > 0) {
|
|
27
|
+
const classAttribute = parser.attributeValue(element, "class");
|
|
28
|
+
const present = CompoundSelector.splitAsciiWhitespace(((classAttribute === null ? "" : classAttribute)));
|
|
29
|
+
{
|
|
30
|
+
const _g1 = this.classes;
|
|
31
|
+
for (let _g_index = 0, count = _g1.length; _g_index < count; _g_index += 1) {
|
|
32
|
+
const className = _g1[_g_index];
|
|
33
|
+
if (present.indexOf(className) < 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
{
|
|
40
|
+
const _g12 = this.attributes;
|
|
41
|
+
for (let _g_index1 = 0, count2 = _g12.length; _g_index1 < count2; _g_index1 += 1) {
|
|
42
|
+
const attribute = _g12[_g_index1];
|
|
43
|
+
const actual = parser.attributeValue(element, attribute.name);
|
|
44
|
+
if (attribute.value === null) {
|
|
45
|
+
if (actual === null) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
if (actual !== attribute.value) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
static parseCompoundSelectorList(selector) {
|
|
59
|
+
const compounds = [];
|
|
60
|
+
{
|
|
61
|
+
const _g1 = selector.split(",");
|
|
62
|
+
for (let _g_index = 0, count3 = _g1.length; _g_index < count3; _g_index += 1) {
|
|
63
|
+
const part = _g1[_g_index];
|
|
64
|
+
const trimmed = CompoundSelector.jsSelectorTrim(part);
|
|
65
|
+
if (trimmed.length === 0) {
|
|
66
|
+
throw CompoundSelector.unsupported();
|
|
67
|
+
}
|
|
68
|
+
compounds.push(CompoundSelector.parseCompoundSelector(trimmed));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return compounds;
|
|
72
|
+
}
|
|
73
|
+
static parseCompoundSelector(input) {
|
|
74
|
+
let tag = null;
|
|
75
|
+
let id = null;
|
|
76
|
+
const classes = [];
|
|
77
|
+
const attributes = [];
|
|
78
|
+
let position = 0;
|
|
79
|
+
while (position < input.length) {
|
|
80
|
+
const code = (Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position));
|
|
81
|
+
if (code === 42 && position === 0 && tag === null) {
|
|
82
|
+
position += 1;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
if (code === 46) {
|
|
86
|
+
position += 1;
|
|
87
|
+
const word = CompoundSelector.readSelectorWord(input, position, false);
|
|
88
|
+
classes.push(word.name);
|
|
89
|
+
position = word.next;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
if (code === 35) {
|
|
93
|
+
position += 1;
|
|
94
|
+
if (id !== null) {
|
|
95
|
+
throw CompoundSelector.unsupported();
|
|
96
|
+
}
|
|
97
|
+
const word2 = CompoundSelector.readSelectorWord(input, position, false);
|
|
98
|
+
id = word2.name;
|
|
99
|
+
position = word2.next;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (code === 91) {
|
|
103
|
+
position += 1;
|
|
104
|
+
const nameWord = CompoundSelector.readSelectorWord(input, position, true);
|
|
105
|
+
const name = nameWord.name;
|
|
106
|
+
position = nameWord.next;
|
|
107
|
+
if (position >= input.length) {
|
|
108
|
+
throw CompoundSelector.unsupported();
|
|
109
|
+
}
|
|
110
|
+
if ((Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position)) === 93) {
|
|
111
|
+
position += 1;
|
|
112
|
+
attributes.push({ name, value: null });
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if ((Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position)) !== 61) {
|
|
116
|
+
throw CompoundSelector.unsupported();
|
|
117
|
+
}
|
|
118
|
+
position += 1;
|
|
119
|
+
let value_b = "";
|
|
120
|
+
if (position < input.length && ((Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position)) === 34 || (Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position)) === 39)) {
|
|
121
|
+
const quote = (Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position));
|
|
122
|
+
position += 1;
|
|
123
|
+
while (true) {
|
|
124
|
+
if (position >= input.length) {
|
|
125
|
+
throw CompoundSelector.unsupported();
|
|
126
|
+
}
|
|
127
|
+
const unit = (Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position));
|
|
128
|
+
if (unit === quote) {
|
|
129
|
+
position += 1;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
{
|
|
133
|
+
const x = input.charAt(position);
|
|
134
|
+
value_b += x;
|
|
135
|
+
}
|
|
136
|
+
position += 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
while (true) {
|
|
141
|
+
if (position >= input.length) {
|
|
142
|
+
throw CompoundSelector.unsupported();
|
|
143
|
+
}
|
|
144
|
+
const unit2 = (Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position));
|
|
145
|
+
if (unit2 === 93) {
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
if (!CompoundSelector.isSelectorWordCharacter(unit2, false)) {
|
|
149
|
+
throw CompoundSelector.unsupported();
|
|
150
|
+
}
|
|
151
|
+
{
|
|
152
|
+
const x2 = input.charAt(position);
|
|
153
|
+
value_b += x2;
|
|
154
|
+
}
|
|
155
|
+
position += 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (position >= input.length || (Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position)) !== 93) {
|
|
159
|
+
throw CompoundSelector.unsupported();
|
|
160
|
+
}
|
|
161
|
+
position += 1;
|
|
162
|
+
attributes.push({ name, value: value_b });
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
if (CompoundSelector.isSelectorWordStart(code)) {
|
|
166
|
+
if (tag !== null || position !== 0) {
|
|
167
|
+
throw CompoundSelector.unsupported();
|
|
168
|
+
}
|
|
169
|
+
const word3 = CompoundSelector.readSelectorWord(input, position, false);
|
|
170
|
+
tag = HtmlNameCase.asciiLower(word3.name);
|
|
171
|
+
position = word3.next;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
throw CompoundSelector.unsupported();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return new CompoundSelector(tag, id, classes, attributes);
|
|
182
|
+
}
|
|
183
|
+
static readSelectorWord(input, position, attributeName) {
|
|
184
|
+
if (position >= input.length || !CompoundSelector.isSelectorWordStart((Number.isNaN(input.charCodeAt(position)) ? null : input.charCodeAt(position)))) {
|
|
185
|
+
throw CompoundSelector.unsupported();
|
|
186
|
+
}
|
|
187
|
+
let index = position;
|
|
188
|
+
while (index < input.length && CompoundSelector.isSelectorWordCharacter((Number.isNaN(input.charCodeAt(index)) ? null : input.charCodeAt(index)), attributeName)) {
|
|
189
|
+
index += 1;
|
|
190
|
+
}
|
|
191
|
+
return { name: input.substring(position, index), next: index };
|
|
192
|
+
}
|
|
193
|
+
static isSelectorWordStart(code) {
|
|
194
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45;
|
|
195
|
+
}
|
|
196
|
+
static isSelectorWordCharacter(code, attributeName) {
|
|
197
|
+
if (CompoundSelector.isSelectorWordStart(code) || code >= 48 && code <= 57) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
return attributeName && code === 58;
|
|
201
|
+
}
|
|
202
|
+
static jsSelectorTrim(value) {
|
|
203
|
+
let start = 0;
|
|
204
|
+
let end = value.length - 1;
|
|
205
|
+
while (start <= end && CompoundSelector.isSelectorTrimWhitespace((Number.isNaN(value.charCodeAt(start)) ? null : value.charCodeAt(start)))) {
|
|
206
|
+
start += 1;
|
|
207
|
+
}
|
|
208
|
+
while (end >= start && CompoundSelector.isSelectorTrimWhitespace((Number.isNaN(value.charCodeAt(end)) ? null : value.charCodeAt(end)))) {
|
|
209
|
+
end -= 1;
|
|
210
|
+
}
|
|
211
|
+
return value.substring(start, end + 1);
|
|
212
|
+
}
|
|
213
|
+
static isSelectorTrimWhitespace(code) {
|
|
214
|
+
return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
|
|
215
|
+
}
|
|
216
|
+
static splitAsciiWhitespace(value) {
|
|
217
|
+
const result = [];
|
|
218
|
+
let start = 0;
|
|
219
|
+
let index = 0;
|
|
220
|
+
while (index < value.length) {
|
|
221
|
+
const code = (Number.isNaN(value.charCodeAt(index)) ? null : value.charCodeAt(index));
|
|
222
|
+
if (code === 9 || code === 10 || code === 12 || code === 13 || code === 32) {
|
|
223
|
+
if (start < index) {
|
|
224
|
+
result.push(value.substring(start, index));
|
|
225
|
+
}
|
|
226
|
+
start = index + 1;
|
|
227
|
+
}
|
|
228
|
+
index += 1;
|
|
229
|
+
}
|
|
230
|
+
if (start < value.length) {
|
|
231
|
+
result.push(value.substring(start, value.length));
|
|
232
|
+
}
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
static unsupported() {
|
|
236
|
+
return new HtmlParseException(HtmlError.UnsupportedHtmlAncestorSelector);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export function compareSelectorWord(a, b) {
|
|
240
|
+
if (a === b)
|
|
241
|
+
return 0;
|
|
242
|
+
if (a.name !== b.name)
|
|
243
|
+
return a.name < b.name ? -1 : 1;
|
|
244
|
+
if (a.next !== b.next)
|
|
245
|
+
return a.next - b.next;
|
|
246
|
+
return 0;
|
|
247
|
+
}
|