@mark1russell7/layout-contract 0.9.6 → 0.9.8

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.
@@ -117,6 +117,18 @@ declare function pointInRing(x: number, y: number, ring: Ring): boolean;
117
117
  * Thus a point inside the outer ring and inside a hole is out. The answer for a point on a border can be each value.
118
118
  */
119
119
  declare function pointInRings(x: number, y: number, rings: readonly Ring[]): boolean;
120
+ /**
121
+ * This function gives the centroid of the area of a ring, by the shoelace formula. The order of the corners can be
122
+ * clockwise or counterclockwise. A ring with the area 0 gives the mean of its corners. An empty ring is a `RangeError`.
123
+ * The sums use the corners relative to the first corner. Thus a small ring far from the origin keeps its digits.
124
+ */
125
+ declare function ringCentroid(ring: Ring): Point;
126
+ /**
127
+ * This function gives the part of a ring in the half-plane `a * x + b * y <= c`, by the steps of Sutherland and Hodgman.
128
+ * The corners keep their order. A new corner goes where a side crosses the line. A ring with no part in the half-plane
129
+ * gives an empty ring. The part of a convex ring is convex. The part of a concave ring can have sides of length 0 on the line.
130
+ */
131
+ declare function clipRing(ring: Ring, a: number, b: number, c: number): Ring;
120
132
  /** This function gives the distance between the centers of two rectangles. */
121
133
  declare function boxCenterDistance(a: Rect, b: Rect): number;
122
134
  /**
@@ -684,5 +696,5 @@ declare function minEffectOf(spec: Pick<MeasureSpec, "minEffect">, a?: number, b
684
696
  * Two equal values are a tie, also two infinite values. A value `NaN` is an error.
685
697
  */
686
698
  declare function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, "direction" | "minEffect">): Verdict;
687
- export { CorpusEntry as $, shapeKindsOf as A, dropIndex as At, LayoutInput as B, snapRect as Bt, checkShapes as C, SIDES as Ct, ruleLevel as D, boundsOf as Dt, itemShapeOf as E, SizedRect as Et, LayoutBox as F, pointInRings as Ft, PairGap as G, PackInput as H, toSizedRect as Ht, LayoutCell as I, pointSegmentDistance as It, canonicalInput as J, Port as K, LayoutContainer as L, regionArea as Lt, shapeSupportProblems as M, marginSides as Mt, shapesOf as N, overlapOf as Nt, shapeKindOf as O, boxCenterDistance as Ot, Item as P, pointInRing as Pt, ClaimBreak as Q, LayoutEdge as R, scaleRect as Rt, boxArea as S, Ring as St, isShapeKind as T, Sides as Tt, PackInputOptions as U, translate as Ut, Obstacle as V, toRect as Vt, PackLink as W, portPoint as X, packLinks as Y, toPackInput as Z, ShapeKind as _, splitFolds as _t, MeasureSpec as a, FamilyCell as at, ShapeLimit as b, Rect as bt, minEffectOf as c, SplitFold as ct, SHAPE_KINDS as d, corpusHashOf as dt, CorpusSplit as et, SHAPE_KIND_IDS as f, declaredClaimOf as ft, ShapeInput as g, splitFileName as gt, ShapeGeometry as h, leaveOneSeedOut as ht, JointMeasureId as i, FamilyBy as it, shapeLevel as j, grow as jt, shapeKindProblem as k, crossingPoint as kt, DEFAULT_SHAPES as l, checkDeclared as lt, ShapeCheck as m, familyOf as mt, JOINT_MEASURES as n, Declares as nt, Verdict as o, SPLIT_SCHEMA as ot, ShapeBound as p, declaredCounts as pt, Resize as q, JOINT_MOVED_MIN as r, FAMILY_ANY_KIND as rt, compareMeasure as s, SplitCorpus as st, Direction as t, DeclaredClaim as tt, RuleLevel as u, checkSplit as ut, ShapeKindSpec as v, Margin as vt, inputShapeLevel as w, Side as wt, ShapeSupport as x, Region as xt, ShapeLevel as y, Point as yt, LayoutGenerator as z, segmentsCross as zt };
688
- //# sourceMappingURL=measures-Aan-rHz1.d.ts.map
699
+ export { CorpusEntry as $, shapeKindsOf as A, crossingPoint as At, LayoutInput as B, scaleRect as Bt, checkShapes as C, SIDES as Ct, ruleLevel as D, boundsOf as Dt, itemShapeOf as E, SizedRect as Et, LayoutBox as F, pointInRing as Ft, PairGap as G, translate as Gt, PackInput as H, snapRect as Ht, LayoutCell as I, pointInRings as It, canonicalInput as J, Port as K, LayoutContainer as L, pointSegmentDistance as Lt, shapeSupportProblems as M, grow as Mt, shapesOf as N, marginSides as Nt, shapeKindOf as O, boxCenterDistance as Ot, Item as P, overlapOf as Pt, ClaimBreak as Q, LayoutEdge as R, regionArea as Rt, boxArea as S, Ring as St, isShapeKind as T, Sides as Tt, PackInputOptions as U, toRect as Ut, Obstacle as V, segmentsCross as Vt, PackLink as W, toSizedRect as Wt, portPoint as X, packLinks as Y, toPackInput as Z, ShapeKind as _, splitFolds as _t, MeasureSpec as a, FamilyCell as at, ShapeLimit as b, Rect as bt, minEffectOf as c, SplitFold as ct, SHAPE_KINDS as d, corpusHashOf as dt, CorpusSplit as et, SHAPE_KIND_IDS as f, declaredClaimOf as ft, ShapeInput as g, splitFileName as gt, ShapeGeometry as h, leaveOneSeedOut as ht, JointMeasureId as i, FamilyBy as it, shapeLevel as j, dropIndex as jt, shapeKindProblem as k, clipRing as kt, DEFAULT_SHAPES as l, checkDeclared as lt, ShapeCheck as m, familyOf as mt, JOINT_MEASURES as n, Declares as nt, Verdict as o, SPLIT_SCHEMA as ot, ShapeBound as p, declaredCounts as pt, Resize as q, JOINT_MOVED_MIN as r, FAMILY_ANY_KIND as rt, compareMeasure as s, SplitCorpus as st, Direction as t, DeclaredClaim as tt, RuleLevel as u, checkSplit as ut, ShapeKindSpec as v, Margin as vt, inputShapeLevel as w, Side as wt, ShapeSupport as x, Region as xt, ShapeLevel as y, Point as yt, LayoutGenerator as z, ringCentroid as zt };
700
+ //# sourceMappingURL=measures-CJZw-Y3H.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measures-CJZw-Y3H.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/measures.ts"],"mappings":";KAGY;;cAGC,gBAAgB;UAEZ;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;;;iBAIK,OAAO,MAAM,YAAY;;iBAKzB,YAAY,MAAM,OAAO;;;;;iBAWzB,SAAS,MAAM,OAAO;;;;;;iBAWtB,UAAU,MAAM,MAAM,iBAAiB;;UAMtC;WACN;WACA;WACA;W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hC;;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-Aan-rHz1.js";
1
+ import { a as MeasureSpec } from "./measures-CJZw-Y3H.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.9.6",
4
+ "version": "0.9.8",
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",
@@ -63,7 +63,7 @@
63
63
  "@mark1russell7/predicates": "^0.1.1",
64
64
  "@mark1russell7/rigor-generators": "^0.1.8",
65
65
  "@mark1russell7/rigor-statistics": "^0.1.23",
66
- "@mark1russell7/strategy-space": "^0.0.2",
66
+ "@mark1russell7/strategy-space": "^0.0.5",
67
67
  "@mark1russell7/typeset": "^0.2.0"
68
68
  },
69
69
  "scripts": {
package/src/families.ts CHANGED
@@ -6,7 +6,7 @@ import { documentHash } from "./hash.ts";
6
6
  import type { LayoutInput, Obstacle } from "./input.ts";
7
7
  import { mulberry32, randomInt, stepRandom } from "./random.ts";
8
8
  import { SHAPE_KIND_IDS } from "./shapes.ts";
9
- import { paramActive, paramLevels, paramProblem, paramValue, type ParamValue, type SpaceParam } from "./strategy-space.ts";
9
+ import { paramActive, paramAt, paramLevels, paramProblem, paramUnit, paramValue, type ParamValue, type SpaceParam } from "./strategy-space.ts";
10
10
 
11
11
  /**
12
12
  * One dimension of a corpus: a param of `strategy-space.ts` with its meaning and the engines that use it.
@@ -385,26 +385,13 @@ const fromZero = (d: SpaceParam): boolean => d.scale === "log" && (d.min ?? 0) <
385
385
  * A log scale with a `min` of 0 or less is the log of `1 + x - min`. An `int` dimension gives a whole number.
386
386
  */
387
387
  export function dimensionAt(dim: SpaceParam, t: number): number {
388
- const min = dim.min ?? 0;
389
- const max = dim.max ?? min;
390
- const u = Math.min(1, Math.max(0, t));
391
- let v: number;
392
- if (dim.scale !== "log") v = min + u * (max - min);
393
- else if (fromZero(dim)) v = min + Math.expm1(u * Math.log1p(max - min));
394
- else v = Math.exp(Math.log(min) + u * (Math.log(max) - Math.log(min)));
395
- v = Math.min(max, Math.max(min, v));
388
+ const v = paramAt(dim, t);
396
389
  return dim.kind === "int" ? Math.round(v) : (paramValue(dim, v) as number);
397
390
  }
398
391
 
399
392
  /** This function gives the fraction of the range of a numeric dimension at a value, on its scale. It is the inverse of `dimensionAt`. */
400
393
  export function dimensionUnit(dim: SpaceParam, value: number): number {
401
- const min = dim.min ?? 0;
402
- const max = dim.max ?? min;
403
- if (max === min) return 0;
404
- const v = Math.min(max, Math.max(min, value));
405
- if (dim.scale !== "log") return (v - min) / (max - min);
406
- if (fromZero(dim)) return Math.log1p(v - min) / Math.log1p(max - min);
407
- return (Math.log(v) - Math.log(min)) / (Math.log(max) - Math.log(min));
394
+ return paramUnit(dim, value);
408
395
  }
409
396
 
410
397
  /** This function gives the range of the supported values of a numeric dimension: its own `min` and `max` in place of the ends of `supported`. */
package/src/geometry.ts CHANGED
@@ -253,6 +253,57 @@ export function pointInRings(x: number, y: number, rings: readonly Ring[]): bool
253
253
  return inside;
254
254
  }
255
255
 
256
+ /**
257
+ * This function gives the centroid of the area of a ring, by the shoelace formula. The order of the corners can be
258
+ * clockwise or counterclockwise. A ring with the area 0 gives the mean of its corners. An empty ring is a `RangeError`.
259
+ * The sums use the corners relative to the first corner. Thus a small ring far from the origin keeps its digits.
260
+ */
261
+ export function ringCentroid(ring: Ring): Point {
262
+ if (ring.length === 0) throw new RangeError("ringCentroid needs a ring with at least one corner.");
263
+ const [ox, oy] = ring[0]!;
264
+ let twice = 0;
265
+ let sx = 0;
266
+ let sy = 0;
267
+ for (let i = 0; i < ring.length; i++) {
268
+ const a = ring[i]!;
269
+ const b = ring[(i + 1) % ring.length]!;
270
+ const ax = a[0] - ox;
271
+ const ay = a[1] - oy;
272
+ const bx = b[0] - ox;
273
+ const by = b[1] - oy;
274
+ const cross = ax * by - bx * ay;
275
+ twice += cross;
276
+ sx += (ax + bx) * cross;
277
+ sy += (ay + by) * cross;
278
+ }
279
+ if (twice === 0) {
280
+ const mean = (k: 0 | 1): number => ring.reduce((sum, corner) => sum + (corner[k] - ring[0]![k]), 0) / ring.length;
281
+ return { x: ox + mean(0), y: oy + mean(1) };
282
+ }
283
+ return { x: ox + sx / (3 * twice), y: oy + sy / (3 * twice) };
284
+ }
285
+
286
+ /**
287
+ * This function gives the part of a ring in the half-plane `a * x + b * y <= c`, by the steps of Sutherland and Hodgman.
288
+ * The corners keep their order. A new corner goes where a side crosses the line. A ring with no part in the half-plane
289
+ * gives an empty ring. The part of a convex ring is convex. The part of a concave ring can have sides of length 0 on the line.
290
+ */
291
+ export function clipRing(ring: Ring, a: number, b: number, c: number): Ring {
292
+ const out: (readonly [number, number])[] = [];
293
+ for (let i = 0; i < ring.length; i++) {
294
+ const p = ring[i]!;
295
+ const q = ring[(i + 1) % ring.length]!;
296
+ const fp = a * p[0] + b * p[1] - c;
297
+ const fq = a * q[0] + b * q[1] - c;
298
+ if (fp <= 0) out.push(p);
299
+ if ((fp < 0 && fq > 0) || (fp > 0 && fq < 0)) {
300
+ const t = fp / (fp - fq);
301
+ out.push([p[0] + t * (q[0] - p[0]), p[1] + t * (q[1] - p[1])]);
302
+ }
303
+ }
304
+ return out;
305
+ }
306
+
256
307
  /** This function gives the distance between the centers of two rectangles. */
257
308
  export function boxCenterDistance(a: Rect, b: Rect): number {
258
309
  return Math.hypot(b.x + b.w / 2 - (a.x + a.w / 2), b.y + b.h / 2 - (a.y + a.h / 2));
@@ -2,7 +2,7 @@
2
2
  import { canonicalJson } from "./hash.ts";
3
3
  import type { Supports } from "./record.ts";
4
4
  import { type AnyOption, declarationIssues, type ListItem, type NoDefaultReason, optionIssue, type OptionScale, type ValueOption } from "./strategy-space.ts";
5
- import type { ParamValue, StrategySpace } from "./strategy-space.ts";
5
+ import type { ParamValue, SpaceParam, StageOption, StrategySpace } from "./strategy-space.ts";
6
6
 
7
7
  /** The newest schema of a strategy catalog. A new field is a new version of the schema. */
8
8
  export const STRATEGY_CATALOG_SCHEMA = "strategy-catalog/3";
@@ -167,16 +167,22 @@ export interface SupportProbe {
167
167
  *
168
168
  * - `spaceOnly` tells that the place sets no option, with one sentence that tells why. A stage option without an entry can also have this statement.
169
169
  * - `option` names the option of the param, when the option has another name. `value` gives the option value of one param value, and `undefined` when the param value sets no option.
170
+ * - `strategy` is for a stage option that is one value of another strategy. The params of the stage option examine against the declarations of that strategy.
171
+ * `fixed` holds the options that the stage option sets, in the JSON form of their declarations. The params cannot have the name of a fixed option.
170
172
  */
171
173
  export type ParamRoute =
172
174
  | { readonly spaceOnly: string }
175
+ | { readonly strategy: string; readonly fixed?: Readonly<Record<string, unknown>> }
173
176
  | { readonly option?: string; readonly value?: (value: ParamValue) => unknown };
174
177
 
175
178
  /** The options of `checkCatalog`. */
176
179
  export interface CatalogCheckOptions {
177
180
  /** Each param of these spaces is examined against the declaration of its option. */
178
181
  readonly spaces?: readonly StrategySpace[];
179
- /** The routes of the params of `spaces`. The key is `<stage>/<option>.<param>`, or `<stage>/<option>` for a stage option. A route that matches nothing is a fault. */
182
+ /**
183
+ * The routes of the params of `spaces`. The key is `<stage>/<option>.<param>`, or `<stage>/<option>` for a stage option. A route that matches nothing is a fault.
184
+ * Only a stage option can have a `strategy` route.
185
+ */
180
186
  readonly paramRoutes?: Readonly<Record<string, ParamRoute>>;
181
187
  readonly probes?: readonly SupportProbe[];
182
188
  /** This function runs `owner` with `choice` in its option `option`. It gives `true` for a refusal, or `undefined` if the input cannot go to `owner`. */
@@ -888,6 +894,41 @@ function checkParamValues(entry: CatalogEntry, engine: string, place: string, op
888
894
  }
889
895
  }
890
896
 
897
+ /** This function examines each option that a `strategy` route fixes. A fixed option is declared, its value is inside the declaration, and no param has its name. */
898
+ function checkFixed(entry: CatalogEntry, engine: string, name: string, fixed: Readonly<Record<string, unknown>>, params: readonly SpaceParam[], faults: string[]): void {
899
+ for (const [key, value] of Object.entries(fixed)) {
900
+ const declaration = entry.options[key];
901
+ if (declaration === undefined) faults.push(`${entry.key}: the route "${name}" fixes "${key}", and the strategy has no such option.`);
902
+ else {
903
+ const issue = optionIssue(key, value, declaration);
904
+ if (issue !== undefined) faults.push(`${entry.key}: the route "${name}" of the space ${engine} fixes a value outside the declaration. ${issue.message}`);
905
+ }
906
+ if (params.some((p) => p.name === key)) faults.push(`${entry.key}: the route "${name}" fixes "${key}", and the stage option also has the param "${key}".`);
907
+ }
908
+ }
909
+
910
+ /**
911
+ * This function gives the entry of a stage option: its own entry, or the strategy of its `strategy` route.
912
+ * It gives `null` for a stage option without an entry or a `strategy` route, and `undefined` after a fault.
913
+ */
914
+ function stageEntry(space: StrategySpace, name: string, option: StageOption, entries: ReadonlyMap<string, CatalogEntry>, check: SpaceCheck): CatalogEntry | undefined | null {
915
+ const own = entries.get(name) ?? entries.get(option.id);
916
+ const route = check.routes[name];
917
+ if (route === undefined || !("strategy" in route)) return own ?? null;
918
+ check.used.add(name);
919
+ if (own !== undefined) {
920
+ check.faults.push(`${own.key}: the route "${name}" names the strategy "${route.strategy}", and the stage option has its own entry.`);
921
+ return undefined;
922
+ }
923
+ const entry = entries.get(route.strategy);
924
+ if (entry === undefined) {
925
+ check.faults.push(`The route "${name}" names the strategy "${route.strategy}", and the catalog has no such entry.`);
926
+ return undefined;
927
+ }
928
+ checkFixed(entry, space.engine, name, route.fixed ?? {}, option.params, check.faults);
929
+ return entry;
930
+ }
931
+
891
932
  /** This function examines each param of a space against the declaration of its option, with the routes of the engine. */
892
933
  function checkSpaceParams(space: StrategySpace, entries: ReadonlyMap<string, CatalogEntry>, check: SpaceCheck): void {
893
934
  const { routes, used, faults, notMatched, spaceOnly } = check;
@@ -899,8 +940,9 @@ function checkSpaceParams(space: StrategySpace, entries: ReadonlyMap<string, Cat
899
940
  for (const stage of space.stages) {
900
941
  for (const option of stage.options) {
901
942
  const name = `${stage.name}/${option.id}`;
902
- const entry = entries.get(name) ?? entries.get(option.id);
903
- if (entry === undefined) {
943
+ const entry = stageEntry(space, name, option, entries, check);
944
+ if (entry === undefined) continue;
945
+ if (entry === null) {
904
946
  const reason = routes[name];
905
947
  if (reason !== undefined && "spaceOnly" in reason) {
906
948
  used.add(name);
@@ -918,6 +960,10 @@ function checkSpaceParams(space: StrategySpace, entries: ReadonlyMap<string, Cat
918
960
  else faults.push(`${entry.key}: the route "${place}" says that the param is only in the space, and the strategy has this option.`);
919
961
  continue;
920
962
  }
963
+ if (route !== undefined && "strategy" in route) {
964
+ faults.push(`${entry.key}: the route "${place}" names a strategy, and only a stage option can have a strategy route.`);
965
+ continue;
966
+ }
921
967
  const target = route?.option ?? param.name;
922
968
  if (entry.options[target] === undefined) {
923
969
  if (route === undefined) notMatched.push(place);
@@ -47,9 +47,11 @@ export {
47
47
  type OptionSetting,
48
48
  type OptionSupports,
49
49
  paramActive,
50
+ paramAt,
50
51
  type ParamKind,
51
52
  paramLevels,
52
53
  paramProblem,
54
+ paramUnit,
53
55
  type ParamValue,
54
56
  paramValue,
55
57
  type ParamWhen,
@@ -1 +0,0 @@
1
- {"version":3,"file":"measures-Aan-rHz1.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/measures.ts"],"mappings":";KAGY;;cAGC,gBAAgB;UAEZ;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;;;iBAIK,OAAO,MAAM,YAAY;;i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