@mark1russell7/layout-contract 0.3.0 → 0.3.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.
- package/README.md +2 -2
- package/build/index.d.ts +10 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +55 -14
- package/build/index.js.map +1 -1
- package/build/{measures-CQAuu3T5.d.ts → measures-BLoTbQwB.d.ts} +30 -4
- package/build/{measures-CQAuu3T5.d.ts.map → measures-BLoTbQwB.d.ts.map} +1 -1
- package/build/text.d.ts +1 -1
- package/package.json +4 -1
- package/src/input.ts +50 -2
- package/src/random.ts +10 -9
- package/src/utf8.ts +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The shared contract of two layout engines: [`packing`](https://github.com/mark1russell7/packing) places boxes, and [`highways`](https://github.com/mark1russell7/highways) routes the edges between them. Neither engine depends on the other. Both use this contract, so a placement and a routing compose.
|
|
4
4
|
|
|
5
|
-
The package has
|
|
5
|
+
The package has one runtime dependency: `@mark1russell7/rigor-generators`, the home of the seeded generator `mulberry32`.
|
|
6
6
|
|
|
7
7
|
## The contents
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ The package has no runtime dependencies.
|
|
|
11
11
|
| Geometry | `Point`, `Rect`, `Region`, `Side`, `Sides`, `Margin`, `marginSides`, `grow`, `boundsOf`, `regionArea`, `translate`, `overlapOf` |
|
|
12
12
|
| The shape kinds | `ShapeKind`, `SHAPE_KINDS`, `SHAPE_KIND_IDS`, `ShapeKindSpec`, `ShapeGeometry`, `DEFAULT_SHAPES`, `ShapeSupport`, `ShapeBound`, `RuleLevel`, `ShapeLevel`, `ShapeCheck`, `isShapeKind`, `shapeKindOf`, `shapeKindsOf`, `itemShapeOf`, `shapeKindProblem`, `shapesOf`, `ruleLevel`, `shapeLevel`, `shapeSupportProblems`, `boxArea`, `checkShapes` |
|
|
13
13
|
| The input `layout-input/1` | `LayoutInput`, `LayoutBox` (`Item` for the packer), `Port`, `portPoint`, `LayoutEdge`, `LayoutContainer`, `Obstacle`, `LayoutCell`, `LayoutGenerator`, `PairGap`, `canonicalInput` |
|
|
14
|
-
| The packer | `PackInput`, `toPackInput`, `Placement`, `PackOutput`, `StageTrace`, `applyPack` |
|
|
14
|
+
| The packer | `PackInput`, `PackLink`, `toPackInput`, `packLinks`, `Placement`, `PackOutput`, `StageTrace`, `applyPack` |
|
|
15
15
|
| The record `layout-record/1` | `LayoutRecord`, `Stage`, `Supports`, `RunFacts`, `RunEnv`, `toLayoutRecord`, `checkLayoutRecord`, `parseLayoutRecord` |
|
|
16
16
|
| The strategies | `StrategyInfo` |
|
|
17
17
|
| The measures | `MeasureSpec`, `Direction`, `JointMeasureId`, `JOINT_MEASURES`, `JOINT_MOVED_MIN`, `Verdict`, `compareMeasure`, `minEffectOf` |
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as FAMILY_ANY_KIND, A as shapesOf, B as PackInputOptions, C as itemShapeOf, Ct as marginSides, D as shapeKindsOf, E as shapeKindProblem, Et as translate, F as LayoutEdge, G as packLinks, H as PairGap, I as LayoutGenerator, J as ClaimBreak, K as portPoint, L as LayoutInput, M as LayoutBox, N as LayoutCell, O as shapeLevel, P as LayoutContainer, Q as Declares, R as Obstacle, S as isShapeKind, St as grow, T as shapeKindOf, Tt as regionArea, U as Port, V as PackLink, W as canonicalInput, X as CorpusSplit, Y as CorpusEntry, Z as DeclaredClaim, _ as ShapeKindSpec, _t as Region, a as MeasureSpec, at as checkDeclared, b as boxArea, bt as Sides, c as minEffectOf, ct as declaredClaimOf, d as SHAPE_KINDS, dt as leaveOneSeedOut, et as FamilyBy, f as SHAPE_KIND_IDS, ft as splitFileName, g as ShapeKind, gt as Rect, h as ShapeGeometry, ht as Point, i as JointMeasureId, it as SplitFold, j as Item, k as shapeSupportProblems, l as DEFAULT_SHAPES, lt as declaredCounts, m as ShapeCheck, mt as Margin, n as JOINT_MEASURES, nt as SPLIT_SCHEMA, o as Verdict, ot as checkSplit, p as ShapeBound, pt as splitFolds, q as toPackInput, r as JOINT_MOVED_MIN, rt as SplitCorpus, s as compareMeasure, st as corpusHashOf, t as Direction, tt as FamilyCell, u as RuleLevel, ut as familyOf, v as ShapeLevel, vt as SIDES, w as ruleLevel, wt as overlapOf, x as checkShapes, xt as boundsOf, y as ShapeSupport, yt as Side, z as PackInput } from "./measures-BLoTbQwB.js";
|
|
2
2
|
/** The epsilon for the float compares in an engine. */
|
|
3
3
|
export declare const EPS = 1e-6;
|
|
4
4
|
/**
|
|
@@ -318,9 +318,15 @@ export interface StrategyInfo<O = unknown, S extends Supports = Supports> {
|
|
|
318
318
|
/** The value is `true` when the result depends only on the input, the options and the seed. */
|
|
319
319
|
readonly deterministic: boolean;
|
|
320
320
|
}
|
|
321
|
-
/**
|
|
321
|
+
/**
|
|
322
|
+
* This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`.
|
|
323
|
+
* Its home is `@mark1russell7/rigor-generators`. This function keeps the name and the signature of the API.
|
|
324
|
+
*/
|
|
322
325
|
export declare function mulberry32(seed: number): () => number;
|
|
323
|
-
/**
|
|
326
|
+
/**
|
|
327
|
+
* This function gives the FNV-1a hash of 32 bits of the UTF-8 bytes of a string.
|
|
328
|
+
* It stays here because `fnv1a32` of `@mark1russell7/rigor-generators` encodes a lone surrogate as U+FFFD. This function encodes the 3 bytes of its code.
|
|
329
|
+
*/
|
|
324
330
|
export declare function fnv1a32(text: string): number;
|
|
325
331
|
/** This function gives the generator of one step of a seeded generator: `mulberry32(fnv1a32("<seed>:<step>"))`. */
|
|
326
332
|
export declare function stepRandom(seed: number, step: string): () => number;
|
|
@@ -1146,5 +1152,5 @@ export declare const EDGES_STEP: CorpusStep;
|
|
|
1146
1152
|
* The steps `container`, `obstacles` and `boxes` each have a stream of `stepRandom`. Each value is a whole number, so the family is `exact`.
|
|
1147
1153
|
*/
|
|
1148
1154
|
export declare const RECT_SCATTERED: CorpusFamily<LayoutInput>;
|
|
1149
|
-
export { ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, Declares, Direction, FAMILY_ANY_KIND, FamilyBy, FamilyCell, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, Margin, MeasureSpec, Obstacle, PackInput, PairGap, Point, Port, Rect, Region, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, ShapeBound, ShapeCheck, ShapeGeometry, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeSupport, Side, Sides, SplitCorpus, SplitFold, Verdict, boundsOf, boxArea, canonicalInput, checkDeclared, checkShapes, checkSplit, compareMeasure, corpusHashOf, declaredClaimOf, declaredCounts, familyOf, grow, isShapeKind, itemShapeOf, leaveOneSeedOut, marginSides, minEffectOf, overlapOf, portPoint, regionArea, ruleLevel, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, splitFileName, splitFolds, toPackInput, translate };
|
|
1155
|
+
export { ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, Declares, Direction, FAMILY_ANY_KIND, FamilyBy, FamilyCell, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, Margin, MeasureSpec, Obstacle, PackInput, PackInputOptions, PackLink, PairGap, Point, Port, Rect, Region, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, ShapeBound, ShapeCheck, ShapeGeometry, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeSupport, Side, Sides, SplitCorpus, SplitFold, Verdict, boundsOf, boxArea, canonicalInput, checkDeclared, checkShapes, checkSplit, compareMeasure, corpusHashOf, declaredClaimOf, declaredCounts, familyOf, grow, isShapeKind, itemShapeOf, leaveOneSeedOut, marginSides, minEffectOf, overlapOf, packLinks, portPoint, regionArea, ruleLevel, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, splitFileName, splitFolds, toPackInput, translate };
|
|
1150
1156
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/balance.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBCzBf;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA,WAAW,SAAS;;;iBAId;WACN,qBAAqB;;WAErB;;WAEA;aAAiB;aAAoB;;;WAErC;aAA2B;aAAqB;aAAoB;;WACpE,iBAAiB;;;;;;;wBAQZ,UAAU,OAAO,aAAa,QAAQ,aAAa;;YC/BvD;;iBAGK;WACN;WACA,OAAO;WACP;WACA;;WAEA,SAAS,SAAS;WAClB;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;WAEA,kBAAkB;;WAElB,UAAU,SAAS;;WAEnB,MAAM,SAAS;;WAEf,YAAY,SAAS,QAAQ;;;;;WAK7B;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA,MAAM;;WAEN;WACA;;;;;;YAOC,WAAW,SAAS;;iBAGf;WACN;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC,WAAW,KAAK;;;;;wBAMZ,eAAe,OAAO,aAAa,KAAK,WAAW;;;;;;wBAkDnD,kBAAkB;;;;;;wBA8BlB,kBAAkB,iBAAiB;;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tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/balance.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBCzBf;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA,WAAW,SAAS;;;iBAId;WACN,qBAAqB;;WAErB;;WAEA;aAAiB;aAAoB;;;WAErC;aAA2B;aAAqB;aAAoB;;WACpE,iBAAiB;;;;;;;wBAQZ,UAAU,OAAO,aAAa,QAAQ,aAAa;;YC/BvD;;iBAGK;WACN;WACA,OAAO;WACP;WACA;;WAEA,SAAS,SAAS;WAClB;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;WAEA,kBAAkB;;WAElB,UAAU,SAAS;;WAEnB,MAAM,SAAS;;WAEf,YAAY,SAAS,QAAQ;;;;;WAK7B;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA,MAAM;;WAEN;WACA;;;;;;YAOC,WAAW,SAAS;;iBAGf;WACN;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC,WAAW,KAAK;;;;;wBAMZ,eAAe,OAAO,aAAa,KAAK,WAAW;;;;;;wBAkDnD,kBAAkB;;;;;;wBA8BlB,kBAAkB,iBAAiB;;wBC9JnC,WAAW,KAAK,YAAY;;;;;;;;wBAc5B,cAAc,gBAAgB,aAAa,oBAA+C,oBAAoB;;iBAkD7G;;;;;WAKN;;;;;;;;;;wBAWK,aAAa,OAAO,aAAa,oBAA+C,UAAS;;wBAsBzF,oBAAoB,gBAAgB,aAAa;;iBAehD;WACN;WACA;WACA;WACA;;;;;;;;qBASE,0BAA0B,mBAAmB;;wBAQ1C,eAAe,QAAQ,QAAQ,MAAM;;;;;wBAgCrC,aAAa,QAAQ,QAAQ,MAAM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AAa"}
|
package/build/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mulberry32 as mulberry32$1 } from "@mark1russell7/rigor-generators";
|
|
1
2
|
// src/geometry.ts
|
|
2
3
|
/** The sides in clockwise order, from the top. */
|
|
3
4
|
const SIDES = [
|
|
@@ -388,16 +389,56 @@ function portPoint(box, port) {
|
|
|
388
389
|
};
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
|
-
/**
|
|
392
|
-
function
|
|
392
|
+
/**
|
|
393
|
+
* This function gives the packer input of a file. An input without a container gets `{ fixed: "none" }`, so the packer picks the size.
|
|
394
|
+
* The edges are not in the packer input. With the option `links`, their links are in it.
|
|
395
|
+
*/
|
|
396
|
+
function toPackInput(input, options = {}) {
|
|
393
397
|
return {
|
|
394
398
|
container: input.container ?? { fixed: "none" },
|
|
395
399
|
items: input.boxes,
|
|
396
400
|
...input.obstacles === void 0 ? {} : { obstacles: input.obstacles },
|
|
397
401
|
...input.gap === void 0 ? {} : { gap: input.gap },
|
|
398
|
-
...input.pairGaps === void 0 ? {} : { pairGaps: input.pairGaps }
|
|
402
|
+
...input.pairGaps === void 0 ? {} : { pairGaps: input.pairGaps },
|
|
403
|
+
...options.links === true ? { links: packLinks(input) } : {}
|
|
399
404
|
};
|
|
400
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* This function gives the links of the edges of a file, with indexes into `input.boxes`.
|
|
408
|
+
* - Each link has `a` below `b`. The list is sorted by `a` and then by `b`.
|
|
409
|
+
* - The edges of one pair of boxes make one link. Its weight is the count of the edges, and a link of one edge has no weight.
|
|
410
|
+
* - The function does not use an edge to a box that is not in `input.boxes`, or an edge from a box to the same box.
|
|
411
|
+
*/
|
|
412
|
+
function packLinks(input) {
|
|
413
|
+
const index = /* @__PURE__ */ new Map();
|
|
414
|
+
input.boxes.forEach((box, i) => {
|
|
415
|
+
if (!index.has(box.id)) index.set(box.id, i);
|
|
416
|
+
});
|
|
417
|
+
const count = /* @__PURE__ */ new Map();
|
|
418
|
+
for (const edge of input.edges ?? []) {
|
|
419
|
+
const s = index.get(edge.source);
|
|
420
|
+
const t = index.get(edge.target);
|
|
421
|
+
if (s === void 0 || t === void 0 || s === t) continue;
|
|
422
|
+
const a = Math.min(s, t);
|
|
423
|
+
const b = Math.max(s, t);
|
|
424
|
+
const key = `${a} ${b}`;
|
|
425
|
+
const c = count.get(key);
|
|
426
|
+
if (c === void 0) count.set(key, {
|
|
427
|
+
a,
|
|
428
|
+
b,
|
|
429
|
+
n: 1
|
|
430
|
+
});
|
|
431
|
+
else c.n += 1;
|
|
432
|
+
}
|
|
433
|
+
return [...count.values()].sort((x, y) => x.a - y.a || x.b - y.b).map(({ a, b, n }) => n === 1 ? {
|
|
434
|
+
a,
|
|
435
|
+
b
|
|
436
|
+
} : {
|
|
437
|
+
a,
|
|
438
|
+
b,
|
|
439
|
+
weight: n
|
|
440
|
+
});
|
|
441
|
+
}
|
|
401
442
|
/** This function compares two strings by their UTF-16 code units, as `Array.prototype.sort` does without a compare function. */
|
|
402
443
|
const byCode$1 = (x, y) => x < y ? -1 : x > y ? 1 : 0;
|
|
403
444
|
/**
|
|
@@ -1514,24 +1555,24 @@ function utf8Write(text, out, at = 0) {
|
|
|
1514
1555
|
}
|
|
1515
1556
|
return n;
|
|
1516
1557
|
}
|
|
1517
|
-
/** This function gives the UTF-8 bytes of a string.
|
|
1558
|
+
/** This function gives the UTF-8 bytes of a string. It does not use `TextEncoder`, because `TextEncoder` encodes a lone surrogate as U+FFFD. */
|
|
1518
1559
|
function utf8(text) {
|
|
1519
1560
|
const bytes = new Uint8Array(utf8Write(text));
|
|
1520
1561
|
utf8Write(text, bytes);
|
|
1521
1562
|
return bytes;
|
|
1522
1563
|
}
|
|
1523
1564
|
// src/random.ts
|
|
1524
|
-
/**
|
|
1565
|
+
/**
|
|
1566
|
+
* This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`.
|
|
1567
|
+
* Its home is `@mark1russell7/rigor-generators`. This function keeps the name and the signature of the API.
|
|
1568
|
+
*/
|
|
1525
1569
|
function mulberry32(seed) {
|
|
1526
|
-
|
|
1527
|
-
return () => {
|
|
1528
|
-
s = s + 1831565813 | 0;
|
|
1529
|
-
let t = Math.imul(s ^ s >>> 15, 1 | s);
|
|
1530
|
-
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
1531
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1532
|
-
};
|
|
1570
|
+
return mulberry32$1(seed);
|
|
1533
1571
|
}
|
|
1534
|
-
/**
|
|
1572
|
+
/**
|
|
1573
|
+
* This function gives the FNV-1a hash of 32 bits of the UTF-8 bytes of a string.
|
|
1574
|
+
* It stays here because `fnv1a32` of `@mark1russell7/rigor-generators` encodes a lone surrogate as U+FFFD. This function encodes the 3 bytes of its code.
|
|
1575
|
+
*/
|
|
1535
1576
|
function fnv1a32(text) {
|
|
1536
1577
|
let h = 2166136261;
|
|
1537
1578
|
for (const b of utf8(text)) h = Math.imul(h ^ b, 16777619) >>> 0;
|
|
@@ -4388,6 +4429,6 @@ const RECT_SCATTERED = Object.freeze({
|
|
|
4388
4429
|
};
|
|
4389
4430
|
}
|
|
4390
4431
|
});
|
|
4391
|
-
export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkShapes, checkSpace, checkSplit, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declaredClaimOf, declaredCounts, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeStep, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, marginSides, minEffectOf, mulberry32, nearestGaps, outputGroups, outputHash, overlapOf, ownerDimension, packHard, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, perChange, pickMoves, placedRect, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, toLayoutRecord, toPackInput, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict };
|
|
4432
|
+
export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkShapes, checkSpace, checkSplit, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declaredClaimOf, declaredCounts, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeStep, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, marginSides, minEffectOf, mulberry32, nearestGaps, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, perChange, pickMoves, placedRect, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, toLayoutRecord, toPackInput, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict };
|
|
4392
4433
|
|
|
4393
4434
|
//# sourceMappingURL=index.js.map
|