@sushichan044/kg-core 0.11.3 → 0.12.1

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.
@@ -914,7 +914,7 @@ declare const ParsedManuscriptSchema: v.SchemaWithPipe<readonly [v.StrictObjectS
914
914
  }>;
915
915
  mark: string;
916
916
  }>]>], undefined>, undefined>, v.ReadonlyAction<(Readonly<{
917
- kind: "italic";
917
+ kind: "ruby";
918
918
  readonly range: Readonly<{
919
919
  source: Readonly<{
920
920
  start: number;
@@ -929,8 +929,18 @@ declare const ParsedManuscriptSchema: v.SchemaWithPipe<readonly [v.StrictObjectS
929
929
  end: number;
930
930
  }> & v.Brand<"GraphemeRange">;
931
931
  }>;
932
+ reading: Readonly<{
933
+ kind: "group";
934
+ text: string;
935
+ }> | Readonly<{
936
+ kind: "mono";
937
+ readonly segments: readonly string[];
938
+ }> | Readonly<{
939
+ kind: "jukugo";
940
+ readonly segments: readonly string[];
941
+ }>;
932
942
  }> | Readonly<{
933
- kind: "ruby";
943
+ kind: "bold";
934
944
  readonly range: Readonly<{
935
945
  source: Readonly<{
936
946
  start: number;
@@ -945,18 +955,8 @@ declare const ParsedManuscriptSchema: v.SchemaWithPipe<readonly [v.StrictObjectS
945
955
  end: number;
946
956
  }> & v.Brand<"GraphemeRange">;
947
957
  }>;
948
- reading: Readonly<{
949
- kind: "group";
950
- text: string;
951
- }> | Readonly<{
952
- kind: "mono";
953
- readonly segments: readonly string[];
954
- }> | Readonly<{
955
- kind: "jukugo";
956
- readonly segments: readonly string[];
957
- }>;
958
958
  }> | Readonly<{
959
- kind: "bold";
959
+ kind: "italic";
960
960
  readonly range: Readonly<{
961
961
  source: Readonly<{
962
962
  start: number;
@@ -1010,7 +1010,7 @@ declare const ParsedManuscriptSchema: v.SchemaWithPipe<readonly [v.StrictObjectS
1010
1010
  }>;
1011
1011
  }>[];
1012
1012
  readonly annotations: readonly (Readonly<{
1013
- kind: "italic";
1013
+ kind: "ruby";
1014
1014
  readonly range: Readonly<{
1015
1015
  source: Readonly<{
1016
1016
  start: number;
@@ -1025,8 +1025,18 @@ declare const ParsedManuscriptSchema: v.SchemaWithPipe<readonly [v.StrictObjectS
1025
1025
  end: number;
1026
1026
  }> & v.Brand<"GraphemeRange">;
1027
1027
  }>;
1028
+ reading: Readonly<{
1029
+ kind: "group";
1030
+ text: string;
1031
+ }> | Readonly<{
1032
+ kind: "mono";
1033
+ readonly segments: readonly string[];
1034
+ }> | Readonly<{
1035
+ kind: "jukugo";
1036
+ readonly segments: readonly string[];
1037
+ }>;
1028
1038
  }> | Readonly<{
1029
- kind: "ruby";
1039
+ kind: "bold";
1030
1040
  readonly range: Readonly<{
1031
1041
  source: Readonly<{
1032
1042
  start: number;
@@ -1041,18 +1051,8 @@ declare const ParsedManuscriptSchema: v.SchemaWithPipe<readonly [v.StrictObjectS
1041
1051
  end: number;
1042
1052
  }> & v.Brand<"GraphemeRange">;
1043
1053
  }>;
1044
- reading: Readonly<{
1045
- kind: "group";
1046
- text: string;
1047
- }> | Readonly<{
1048
- kind: "mono";
1049
- readonly segments: readonly string[];
1050
- }> | Readonly<{
1051
- kind: "jukugo";
1052
- readonly segments: readonly string[];
1053
- }>;
1054
1054
  }> | Readonly<{
1055
- kind: "bold";
1055
+ kind: "italic";
1056
1056
  readonly range: Readonly<{
1057
1057
  source: Readonly<{
1058
1058
  start: number;
@@ -1503,7 +1503,7 @@ declare const ParsedManuscript: {
1503
1503
  }>;
1504
1504
  mark: string;
1505
1505
  }>]>], undefined>, undefined>, v.ReadonlyAction<(Readonly<{
1506
- kind: "italic";
1506
+ kind: "ruby";
1507
1507
  readonly range: Readonly<{
1508
1508
  source: Readonly<{
1509
1509
  start: number;
@@ -1518,8 +1518,18 @@ declare const ParsedManuscript: {
1518
1518
  end: number;
1519
1519
  }> & v.Brand<"GraphemeRange">;
1520
1520
  }>;
1521
+ reading: Readonly<{
1522
+ kind: "group";
1523
+ text: string;
1524
+ }> | Readonly<{
1525
+ kind: "mono";
1526
+ readonly segments: readonly string[];
1527
+ }> | Readonly<{
1528
+ kind: "jukugo";
1529
+ readonly segments: readonly string[];
1530
+ }>;
1521
1531
  }> | Readonly<{
1522
- kind: "ruby";
1532
+ kind: "bold";
1523
1533
  readonly range: Readonly<{
1524
1534
  source: Readonly<{
1525
1535
  start: number;
@@ -1534,18 +1544,8 @@ declare const ParsedManuscript: {
1534
1544
  end: number;
1535
1545
  }> & v.Brand<"GraphemeRange">;
1536
1546
  }>;
1537
- reading: Readonly<{
1538
- kind: "group";
1539
- text: string;
1540
- }> | Readonly<{
1541
- kind: "mono";
1542
- readonly segments: readonly string[];
1543
- }> | Readonly<{
1544
- kind: "jukugo";
1545
- readonly segments: readonly string[];
1546
- }>;
1547
1547
  }> | Readonly<{
1548
- kind: "bold";
1548
+ kind: "italic";
1549
1549
  readonly range: Readonly<{
1550
1550
  source: Readonly<{
1551
1551
  start: number;
@@ -1599,7 +1599,7 @@ declare const ParsedManuscript: {
1599
1599
  }>;
1600
1600
  }>[];
1601
1601
  readonly annotations: readonly (Readonly<{
1602
- kind: "italic";
1602
+ kind: "ruby";
1603
1603
  readonly range: Readonly<{
1604
1604
  source: Readonly<{
1605
1605
  start: number;
@@ -1614,8 +1614,18 @@ declare const ParsedManuscript: {
1614
1614
  end: number;
1615
1615
  }> & v.Brand<"GraphemeRange">;
1616
1616
  }>;
1617
+ reading: Readonly<{
1618
+ kind: "group";
1619
+ text: string;
1620
+ }> | Readonly<{
1621
+ kind: "mono";
1622
+ readonly segments: readonly string[];
1623
+ }> | Readonly<{
1624
+ kind: "jukugo";
1625
+ readonly segments: readonly string[];
1626
+ }>;
1617
1627
  }> | Readonly<{
1618
- kind: "ruby";
1628
+ kind: "bold";
1619
1629
  readonly range: Readonly<{
1620
1630
  source: Readonly<{
1621
1631
  start: number;
@@ -1630,18 +1640,8 @@ declare const ParsedManuscript: {
1630
1640
  end: number;
1631
1641
  }> & v.Brand<"GraphemeRange">;
1632
1642
  }>;
1633
- reading: Readonly<{
1634
- kind: "group";
1635
- text: string;
1636
- }> | Readonly<{
1637
- kind: "mono";
1638
- readonly segments: readonly string[];
1639
- }> | Readonly<{
1640
- kind: "jukugo";
1641
- readonly segments: readonly string[];
1642
- }>;
1643
1643
  }> | Readonly<{
1644
- kind: "bold";
1644
+ kind: "italic";
1645
1645
  readonly range: Readonly<{
1646
1646
  source: Readonly<{
1647
1647
  start: number;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as ManuscriptResult, c as DiagnosticSeverity, d as ManuscriptRangeInput, i as ParsedManuscript, l as DiagnosticOrigin, n as ValidationIssue, o as ManuscriptDiagnostic, r as NamespacedId, s as ManuscriptDiagnosticInput, t as ComposedManuscript, u as ManuscriptRange } from "./composed-manuscript-C0f3mxKs.mjs";
2
- import { d as PaperSizeId, f as ManuscriptComposer, i as novelComposer, l as NovelLayout, n as NovelComposedManuscript, p as ManuscriptParser, t as PresentationKind, u as NovelCompositionSettings } from "./presentation-kind-BmW1Edu7.mjs";
1
+ import { a as ManuscriptResult, c as DiagnosticSeverity, d as ManuscriptRangeInput, i as ParsedManuscript, l as DiagnosticOrigin, n as ValidationIssue, o as ManuscriptDiagnostic, r as NamespacedId, s as ManuscriptDiagnosticInput, t as ComposedManuscript, u as ManuscriptRange } from "./composed-manuscript-QgIdae8p.mjs";
2
+ import { d as PaperSizeId, f as ManuscriptComposer, i as novelComposer, l as NovelLayout, n as NovelComposedManuscript, p as ManuscriptParser, t as PresentationKind, u as NovelCompositionSettings } from "./presentation-kind-PauRP22i.mjs";
3
3
  import * as v from "valibot";
4
4
  //#region src/parser/parse-error.d.ts
5
5
  /**
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { _ as ManuscriptRange, d as graphemeSegmenter, f as ValidationIssue, g as NamespacedId, m as ManuscriptDiagnostic, p as ManuscriptResult, u as assertNever, x as readonlyObject } from "./question-or-exclamation-spacing-D7TSDUG8.mjs";
2
- import { _ as ParsedManuscript, c as NovelFlowSettings, d as ManuscriptPageSettings, f as PaperSize, g as FontPresetId, h as FontSizeQ, l as ManuscriptOffsets, m as PaperSizeId, n as novelComposer, p as ManuscriptAppearanceSettings, s as NovelCompositionSettings, u as ManuscriptGeometry } from "./novel-composer-DNsKrJIP.mjs";
2
+ import { _ as ParsedManuscript, c as NovelFlowSettings, d as ManuscriptPageSettings, f as PaperSize, g as FontPresetId, h as FontSizeQ, l as ManuscriptOffsets, m as PaperSizeId, n as novelComposer, p as ManuscriptAppearanceSettings, s as NovelCompositionSettings, u as ManuscriptGeometry } from "./novel-composer-Dz7b30nf.mjs";
3
3
  import { t as describeCause } from "./describe-cause-SABI_1ex.mjs";
4
4
  import * as v from "valibot";
5
5
  const Rejection = { schema: readonlyObject({ reason: v.string() }) };
package/dist/lint.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ManuscriptResult, i as ParsedManuscript, n as ValidationIssue, o as ManuscriptDiagnostic, r as NamespacedId, t as ComposedManuscript } from "./composed-manuscript-C0f3mxKs.mjs";
1
+ import { a as ManuscriptResult, i as ParsedManuscript, n as ValidationIssue, o as ManuscriptDiagnostic, r as NamespacedId, t as ComposedManuscript } from "./composed-manuscript-QgIdae8p.mjs";
2
2
  import * as v from "valibot";
3
3
  //#region src/proofreading/invalid-rule-options.d.ts
4
4
  /**
@@ -854,7 +854,8 @@ const CandidateLine = { resolve: (context, lineLengthEm) => {
854
854
  break: { kind: "paragraph-end" },
855
855
  hangingIndex: null,
856
856
  deformationRatio: 0,
857
- deformationCost: 0
857
+ deformationCost: 0,
858
+ finalExpansionBadness: 0
858
859
  };
859
860
  if (Math.abs(overflow) <= EPSILON$5) return {
860
861
  start,
@@ -866,7 +867,8 @@ const CandidateLine = { resolve: (context, lineLengthEm) => {
866
867
  break: { kind: "natural" },
867
868
  hangingIndex: null,
868
869
  deformationRatio: 0,
869
- deformationCost: 0
870
+ deformationCost: 0,
871
+ finalExpansionBadness: 0
870
872
  };
871
873
  const shrunk = overflow > 0 && overflow <= capacity + EPSILON$5 ? resolveSpacings(pairValues, units, "shrink", overflow, finalExpansion) : null;
872
874
  if (shrunk !== null && shrunk.unabsorbedEm <= EPSILON$5) {
@@ -882,7 +884,8 @@ const CandidateLine = { resolve: (context, lineLengthEm) => {
882
884
  break: { kind: "shrunk" },
883
885
  hangingIndex: null,
884
886
  deformationRatio: chargeableCapacity <= EPSILON$5 ? 0 : chargeableShrink / chargeableCapacity,
885
- deformationCost: shrunk.deformationCost
887
+ deformationCost: shrunk.deformationCost,
888
+ finalExpansionBadness: 0
886
889
  };
887
890
  }
888
891
  if (!terminal && overflow > 0 && lastVisible !== void 0 && canHang && naturalSizeEm - lastAdvance - trailingSpacing <= lineLengthEm + EPSILON$5) return {
@@ -895,7 +898,8 @@ const CandidateLine = { resolve: (context, lineLengthEm) => {
895
898
  break: { kind: "hanging" },
896
899
  hangingIndex: lastVisible,
897
900
  deformationRatio: overflow / Math.max(lastAdvance, EPSILON$5),
898
- deformationCost: 0
901
+ deformationCost: 0,
902
+ finalExpansionBadness: 0
899
903
  };
900
904
  const stretched = !terminal && underflow > EPSILON$5 && (underflow <= capacity + EPSILON$5 || hasFinalStretch) ? resolveSpacings(pairValues, units, "stretch", underflow, finalExpansion) : null;
901
905
  if (stretched !== null && stretched.unabsorbedEm <= EPSILON$5) return {
@@ -908,7 +912,8 @@ const CandidateLine = { resolve: (context, lineLengthEm) => {
908
912
  break: { kind: "stretched" },
909
913
  hangingIndex: null,
910
914
  deformationRatio: stretched.finalStretchPerSlotEm > 0 ? 1 + stretched.finalStretchPerSlotEm : capacity === 0 ? 0 : underflow / capacity,
911
- deformationCost: stretched.deformationCost
915
+ deformationCost: stretched.deformationCost,
916
+ finalExpansionBadness: finalExpansion.slots.length * stretched.finalStretchPerSlotEm ** 3
912
917
  };
913
918
  return {
914
919
  start,
@@ -920,7 +925,8 @@ const CandidateLine = { resolve: (context, lineLengthEm) => {
920
925
  break: { kind: "forced" },
921
926
  hangingIndex: null,
922
927
  deformationRatio: Math.abs(naturalSizeEm - lineLengthEm) / Math.max(lineLengthEm, EPSILON$5),
923
- deformationCost: 0
928
+ deformationCost: 0,
929
+ finalExpansionBadness: 0
924
930
  };
925
931
  } };
926
932
  //#endregion
@@ -2180,6 +2186,7 @@ function scoreFor(line, previousFitness) {
2180
2186
  return {
2181
2187
  score: [
2182
2188
  modeCounts.forced,
2189
+ line.finalExpansionBadness,
2183
2190
  modeCounts.stretched,
2184
2191
  modeCounts.hanging,
2185
2192
  modeCounts.shrunk,
@@ -2198,7 +2205,8 @@ function addScore(left, right) {
2198
2205
  left[3] + right[3],
2199
2206
  left[4] + right[4],
2200
2207
  left[5] + right[5],
2201
- left[6] + right[6]
2208
+ left[6] + right[6],
2209
+ left[7] + right[7]
2202
2210
  ];
2203
2211
  }
2204
2212
  const defaultParagraphEvaluation = { scoreFor };
@@ -2249,7 +2257,9 @@ function compareBreaks(left, right) {
2249
2257
  function isBetter(candidateState, current, states) {
2250
2258
  if (current === void 0) return true;
2251
2259
  for (let index = 0; index < candidateState.score.length; index += 1) {
2252
- const difference = (candidateState.score[index] ?? 0) - (current.score[index] ?? 0);
2260
+ const candidate = candidateState.score[index] ?? 0;
2261
+ const existing = current.score[index] ?? 0;
2262
+ const difference = index === 1 ? Math.cbrt(candidate) - Math.cbrt(existing) : candidate - existing;
2253
2263
  if (Math.abs(difference) > EPSILON$2) return difference < 0;
2254
2264
  }
2255
2265
  return compareBreaks(breaksOf(candidateState, states), breaksOf(current, states)) < 0;
@@ -2265,6 +2275,7 @@ function layoutParagraph(atoms, lineLengthEm, resolveCandidate, boundaryAllowed,
2265
2275
  0,
2266
2276
  0,
2267
2277
  0,
2278
+ 0,
2268
2279
  0
2269
2280
  ],
2270
2281
  fitness: 0,
package/dist/plugin.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as ManuscriptResult, i as ParsedManuscript, n as ValidationIssue, r as NamespacedId } from "./composed-manuscript-C0f3mxKs.mjs";
2
- import { a as RunMeasurer, c as MeasurementRequest, f as ManuscriptComposer, m as Rejection, o as logicalRunMeasurer, p as ManuscriptParser, r as createNovelComposer, s as RunMeasurement, t as PresentationKind } from "./presentation-kind-BmW1Edu7.mjs";
1
+ import { a as ManuscriptResult, i as ParsedManuscript, n as ValidationIssue, r as NamespacedId } from "./composed-manuscript-QgIdae8p.mjs";
2
+ import { a as RunMeasurer, c as MeasurementRequest, f as ManuscriptComposer, m as Rejection, o as logicalRunMeasurer, p as ManuscriptParser, r as createNovelComposer, s as RunMeasurement, t as PresentationKind } from "./presentation-kind-PauRP22i.mjs";
3
3
  import * as v from "valibot";
4
4
  //#region src/composer/measurement-text-range.d.ts
5
5
  declare const MeasurementTextRangeSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
package/dist/plugin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { f as ValidationIssue, g as NamespacedId, p as ManuscriptResult, x as readonlyObject } from "./question-or-exclamation-spacing-D7TSDUG8.mjs";
2
- import { _ as ParsedManuscript, a as MeasuredCluster, g as FontPresetId, h as FontSizeQ, i as RunMeasurement, o as MeasurementTextRange, r as logicalRunMeasurer, t as createNovelComposer } from "./novel-composer-DNsKrJIP.mjs";
2
+ import { _ as ParsedManuscript, a as MeasuredCluster, g as FontPresetId, h as FontSizeQ, i as RunMeasurement, o as MeasurementTextRange, r as logicalRunMeasurer, t as createNovelComposer } from "./novel-composer-Dz7b30nf.mjs";
3
3
  import * as v from "valibot";
4
4
  const PresentationKind = { schema: v.picklist([
5
5
  "mixed",
@@ -1,4 +1,4 @@
1
- import { a as ManuscriptResult, i as ParsedManuscript, t as ComposedManuscript } from "./composed-manuscript-C0f3mxKs.mjs";
1
+ import { a as ManuscriptResult, i as ParsedManuscript, t as ComposedManuscript } from "./composed-manuscript-QgIdae8p.mjs";
2
2
  import * as v from "valibot";
3
3
  //#region src/result/rejection.d.ts
4
4
  declare const RejectionSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sushichan044/kg-core",
3
- "version": "0.11.3",
3
+ "version": "0.12.1",
4
4
  "description": "Framework-independent parsing, composition, and proofreading for Japanese manuscripts",
5
5
  "keywords": [
6
6
  "japanese",