@mark1russell7/layout-contract 0.6.1 → 0.7.0
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/build/index.d.ts +2 -2
- package/build/index.js +23 -1
- package/build/index.js.map +1 -1
- package/build/{measures-COqcrCzv.d.ts → measures-DGKAulWv.d.ts} +17 -2
- package/build/measures-DGKAulWv.d.ts.map +1 -0
- package/build/text.d.ts +1 -1
- package/package.json +2 -2
- package/src/geometry.ts +23 -0
- package/build/measures-COqcrCzv.d.ts.map +0 -1
|
@@ -95,6 +95,21 @@ declare function segmentsCross(a: Point, b: Point, c: Point, d: Point): boolean;
|
|
|
95
95
|
declare function crossingPoint(a: Point, b: Point, c: Point, d: Point): Point | undefined;
|
|
96
96
|
/** This function gives the shortest distance from `p` to the segment `ab`. A segment of length 0 is the point `a`. */
|
|
97
97
|
declare function pointSegmentDistance(p: Point, a: Point, b: Point): number;
|
|
98
|
+
/**
|
|
99
|
+
* This function gives the index at which a point goes among the items of a list on the screen.
|
|
100
|
+
* The reading order is the rows from top to bottom, and each row from left to right.
|
|
101
|
+
* The index is that of the first item whose center comes after the point, from 0 to the number of items.
|
|
102
|
+
* A center within `rowTolerance` of the point on the vertical axis is in the row of the point.
|
|
103
|
+
* The tolerance has the units of the points: on a screen, the default 24 is 24 pixels.
|
|
104
|
+
*
|
|
105
|
+
* Give the centers in reading order and without the item that moves.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const index = dropIndex(pointer, others.map(centerOf));
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function dropIndex(point: Point, centers: readonly Point[], rowTolerance?: number): number;
|
|
98
113
|
/** One broken claim of a corpus, with the ids of the inputs that break it. */
|
|
99
114
|
interface ClaimBreak {
|
|
100
115
|
/** The name of the claim, for example `declared`, `split` or `index`. */
|
|
@@ -631,5 +646,5 @@ declare function minEffectOf(spec: Pick<MeasureSpec, "minEffect">, a?: number, b
|
|
|
631
646
|
* Two equal values are a tie, also two infinite values. A value `NaN` is an error.
|
|
632
647
|
*/
|
|
633
648
|
declare function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, "direction" | "minEffect">): Verdict;
|
|
634
|
-
export { CorpusSplit as $, shapeKindsOf as A,
|
|
635
|
-
//# sourceMappingURL=measures-
|
|
649
|
+
export { CorpusSplit as $, shapeKindsOf as A, overlapOf as At, LayoutInput as B, checkShapes as C, Sides as Ct, ruleLevel as D, dropIndex as Dt, itemShapeOf as E, crossingPoint as Et, LayoutBox as F, toSizedRect as Ft, PairGap as G, PackInput as H, LayoutCell as I, translate as It, packLinks as J, Port as K, LayoutContainer as L, shapeSupportProblems as M, regionArea as Mt, shapesOf as N, segmentsCross as Nt, shapeKindOf as O, grow as Ot, Item as P, toRect as Pt, CorpusEntry as Q, LayoutEdge as R, boxArea as S, Side as St, isShapeKind as T, boundsOf as Tt, PackInputOptions as U, Obstacle as V, PackLink as W, toPackInput as X, portPoint as Y, ClaimBreak as Z, ShapeKind as _, Margin as _t, MeasureSpec as a, SPLIT_SCHEMA as at, ShapeLimit as b, Region as bt, minEffectOf as c, checkDeclared as ct, SHAPE_KINDS as d, declaredClaimOf as dt, DeclaredClaim as et, SHAPE_KIND_IDS as f, declaredCounts as ft, ShapeInput as g, splitFolds as gt, ShapeGeometry as h, splitFileName as ht, JointMeasureId as i, FamilyCell as it, shapeLevel as j, pointSegmentDistance as jt, shapeKindProblem as k, marginSides as kt, DEFAULT_SHAPES as l, checkSplit as lt, ShapeCheck as m, leaveOneSeedOut as mt, JOINT_MEASURES as n, FAMILY_ANY_KIND as nt, Verdict as o, SplitCorpus as ot, ShapeBound as p, familyOf as pt, canonicalInput as q, JOINT_MOVED_MIN as r, FamilyBy as rt, compareMeasure as s, SplitFold as st, Direction as t, Declares as tt, RuleLevel as u, corpusHashOf as ut, ShapeKindSpec as v, Point as vt, inputShapeLevel as w, SizedRect as wt, ShapeSupport as x, SIDES as xt, ShapeLevel as y, Rect as yt, LayoutGenerator as z };
|
|
650
|
+
//# sourceMappingURL=measures-DGKAulWv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measures-DGKAulWv.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/measures.ts"],"mappings":";KACY;;cAGC,gBAAgB;UAEZ;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;;;iBAIK,OAAO,MAAM,YAAY;;iBAKzB,YAAY,MAAM,OAAO;;UAKxB;WACN;WACA;WACA;WACA;;;;;;KAOC;WACG;WAAuB;WAAoB;WAAoB;WAAoB;;WAEnF;WACA;WACA;;WAEA;WAAyB;WAAqB;WAAqB;;WACnE;WAA0B;WAAqB;WAAqB;WAAqB;;;KAG5F,kBAAkB;;iBAGd,YAAY,QAAQ,qBAAqB;;iBAOzC,KAAK,MAAM,MAAM,QAAQ,qBAAqB;;iBAM9C,SAAS,QAAQ,SAAS;;;;;iBA4B1B,WAAW,QAAQ;;iBAyBnB,UAAU,QAAQ,QAAQ,YAAY,aAAa;;;;;iBAoBnD,UAAU,GAAG,MAAM,GAAG;WAAkB;WAAoB;;;;;;iBAqB5D,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG;;;;;iBAQ/C,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ;;iBAQvD,qBAAqB,GAAG,OAAO,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;iBAsB5C,UAAU,OAAO,OAAO,kBAAkB,SAAS;;UC/MlD;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA,QAAQ,SAAS;;WAEjB,WAAW;;WAEX;;;;;;;;KASC;;;;KAGA,aAAa,SAAS;;cAGrB;;;;;;iBA4CG,SAAS,MAAM,YAAY,UAAU;;KAazC,SAAS,MAAM,OAAO;;;;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gBAAgB,UAAS,aAAkB;;KCtQ7F;;;;;;UAOK,YAAY;WAClB,IAAI;WACJ;WACA,WAAW;;WAEX;;WAEA;;WAEA;;WAEA;;WAEA;;;;;WAKA;aAAgC;;;WAEhC;;WAEA,kBAAkB;;;;;WAKlB,QAAQ;;;KAIP;;;;;cAqBC,yBAAyB,YAAY;;cAcrC;;KAGD;;;;;;iBAOI,YAAY,MAAM,KAAK,2BAA2B,YAAO;;;;;;;iBAezD,eAAe,mBAAmB,kBAAkB,MAAM,KAAK,0CAA0C"}
|
package/build/text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MeasureSpec } from "./measures-
|
|
1
|
+
import { a as MeasureSpec } from "./measures-DGKAulWv.js";
|
|
2
2
|
/**
|
|
3
3
|
* The advance function of a host: the width of a run of text in a font, in pixels.
|
|
4
4
|
* A browser host gives `canvasAdvance(context)`. A test or a server host gives a function of a font file.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/layout-contract",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "The shared contract of the packing and highways layout engines: the input and record formats, the turn rule, margins, tolerances and hard rules.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"layout",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@mark1russell7/rigor-generators": "^0.1.0",
|
|
63
|
-
"@mark1russell7/typeset": "^0.
|
|
63
|
+
"@mark1russell7/typeset": "^0.2.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsdown",
|
package/src/geometry.ts
CHANGED
|
@@ -194,3 +194,26 @@ export function pointSegmentDistance(p: Point, a: Point, b: Point): number {
|
|
|
194
194
|
const t = l2 === 0 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / l2));
|
|
195
195
|
return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
|
|
196
196
|
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* This function gives the index at which a point goes among the items of a list on the screen.
|
|
200
|
+
* The reading order is the rows from top to bottom, and each row from left to right.
|
|
201
|
+
* The index is that of the first item whose center comes after the point, from 0 to the number of items.
|
|
202
|
+
* A center within `rowTolerance` of the point on the vertical axis is in the row of the point.
|
|
203
|
+
* The tolerance has the units of the points: on a screen, the default 24 is 24 pixels.
|
|
204
|
+
*
|
|
205
|
+
* Give the centers in reading order and without the item that moves.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const index = dropIndex(pointer, others.map(centerOf));
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export function dropIndex(point: Point, centers: readonly Point[], rowTolerance = 24): number {
|
|
213
|
+
for (let i = 0; i < centers.length; i++) {
|
|
214
|
+
const c = centers[i] as Point;
|
|
215
|
+
if (point.y < c.y - rowTolerance) return i;
|
|
216
|
+
if (Math.abs(point.y - c.y) <= rowTolerance && point.x < c.x) return i;
|
|
217
|
+
}
|
|
218
|
+
return centers.length;
|
|
219
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"measures-COqcrCzv.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/measures.ts"],"mappings":";KACY;;cAGC,gBAAgB;UAEZ;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;;;iBAIK,OAAO,MAAM,YAAY;;iBAKzB,YAAY,MAAM,OAAO;;UAKxB;WACN;WACA;WACA;WACA;;;;;;KAOC;WACG;WAAuB;WAAoB;WAAoB;WAAoB;;WAEnF;WACA;WACA;;WAEA;WAAyB;WAAqB;WAAqB;;WACnE;WAA0B;WAAq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