@mark1russell7/packing 0.1.6 → 0.1.7
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 +27 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +49 -18
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/check.ts +16 -9
- package/src/contract.ts +2 -0
- package/src/layout-input.ts +2 -0
- package/src/measures.ts +33 -15
package/build/index.d.ts
CHANGED
|
@@ -343,6 +343,8 @@ interface Item {
|
|
|
343
343
|
margin?: number | Margin;
|
|
344
344
|
/** The ports. The packer keeps them, and turns them with the item. */
|
|
345
345
|
ports?: Port[];
|
|
346
|
+
/** The free data of the item. The packer does not read it, and the turn and the converters keep it. */
|
|
347
|
+
data?: Readonly<Record<string, unknown>>;
|
|
346
348
|
}
|
|
347
349
|
/** The input of a packing: a `layout-input/1` file without `edges`, with `items` for `boxes`. */
|
|
348
350
|
interface PackInput {
|
|
@@ -431,6 +433,20 @@ interface MeasureSpec {
|
|
|
431
433
|
min: number;
|
|
432
434
|
/** The highest value. The value `Infinity` tells that the measure has no upper limit. */
|
|
433
435
|
max: number;
|
|
436
|
+
/**
|
|
437
|
+
* The floor is the best value of a guard measure. The floor rule of `docs/PROMOTION.md` of `highways` reads it. Each
|
|
438
|
+
* guard of the packer has the floor 0. A measure without a floor has no floor rule.
|
|
439
|
+
*/
|
|
440
|
+
floor?: number;
|
|
441
|
+
/**
|
|
442
|
+
* The tolerance is the absolute tolerance at the floor. A candidate within the tolerance ties with a default at the floor.
|
|
443
|
+
*
|
|
444
|
+
* - `pack.order.inversions` and `pack.overflow` have the tolerance 0. Thus each new inversion and each new unplaced item is a loss.
|
|
445
|
+
* - `pack.aspectError` has 0.01, approximately 1% of the aspect. An exact tiling gives the default an error of 0.
|
|
446
|
+
* - `pack.stability.mean` has 0.005 container widths, and `pack.stability.q95` has 0.01. The default often moves no item.
|
|
447
|
+
* - `pack.stability.moved` has 0.02: 2% of the items that stay. On a small change, the default often moves no item.
|
|
448
|
+
*/
|
|
449
|
+
tol?: number;
|
|
434
450
|
}
|
|
435
451
|
/** The measures of one layout, by id. `measure` gives them. The values are not rounded. */
|
|
436
452
|
interface LayoutMeasures {
|
|
@@ -460,7 +476,10 @@ interface MeasureOptions {
|
|
|
460
476
|
*/
|
|
461
477
|
rowTolerance?: number;
|
|
462
478
|
}
|
|
463
|
-
/**
|
|
479
|
+
/**
|
|
480
|
+
* The facts of each measure, by id. `docs/MEASURES.md` gives the full definitions. This record is the source of the floor
|
|
481
|
+
* and the tolerance of each guard of the packer.
|
|
482
|
+
*/
|
|
464
483
|
export declare const MEASURE_SPECS: Readonly<Record<MeasureId, MeasureSpec>>;
|
|
465
484
|
/**
|
|
466
485
|
* This function gives the measures of one layout, by the ids of `docs/MEASURES.md`. The values are not rounded. A
|
|
@@ -697,8 +716,11 @@ interface HardBreaks {
|
|
|
697
716
|
* - `no-overlap`: each pair of items with their margins, and each pair of an item and an obstacle, that overlap by more than `tolerance.overlap`.
|
|
698
717
|
* - `in-container`: each item with its margin that goes out of a fixed side by more than `tolerance.overlap`. The inset of
|
|
699
718
|
* the container makes each fixed side smaller (decision 3 of `docs/PACKER.md`).
|
|
700
|
-
* - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no
|
|
701
|
-
* - `complete`: each item with no
|
|
719
|
+
* - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no placement.
|
|
720
|
+
* - `complete`: each item with no placement that is not in the overflow. A locked item breaks `locked-kept` in its place.
|
|
721
|
+
*
|
|
722
|
+
* A locked item with no placement stays at its input position for `no-overlap` and `in-container`. A locked item with no
|
|
723
|
+
* `x` or no `y` in the input is not locked for these rules.
|
|
702
724
|
*
|
|
703
725
|
* The rules read a shape of the container, of an obstacle or of an item as its bounding box (decision 5). The bounding box
|
|
704
726
|
* of an item shape is relative to the position of the item. The result has no tolerance in it.
|
|
@@ -711,6 +733,8 @@ interface Edge {
|
|
|
711
733
|
target: string;
|
|
712
734
|
sourcePort?: string;
|
|
713
735
|
targetPort?: string;
|
|
736
|
+
/** The free data of the edge. The packer does not read it. */
|
|
737
|
+
data?: Readonly<Record<string, unknown>>;
|
|
714
738
|
}
|
|
715
739
|
/** The parameters of a generator: a name and a string or a number for each parameter. */
|
|
716
740
|
type GeneratorParams = Record<string, string | number>;
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/pack.ts","../src/skyline.ts","../src/shelf.ts","../src/free.ts","../src/push.ts","../src/metrics.ts","../src/contract.ts","../src/measures.ts","../src/strategy.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/check.ts","../src/layout-input.ts","../src/generators.ts","../src/corpus.ts"],"mappings":";qBACa;;EAIX,YAAY,YAAO;;MAMf;MACA,EAAE;;MAEF;MACA,EAAE;;EAGN,IAAI,WAAW;;EAMf,MAAM,GAAG;;EAMT,IAAI,OAAO,SAAS;;EAKpB;;EAKA,SAAS;;EAKT,MAAM,KAAK,QAAQ,KAAK,SAAS;;SAQ1B,GAAG,iBAAiB;;SAKpB,IAAI,SAAS,WAAW;;SASxB,IAAI,SAAS,WAAW;;aASpB,YAAY;;;qBCxEZ,KAAK;;;EAKhB,KAAK;;EAEL;;EAEA;;EAEA;;;;;EAKA;;MAGI,YAAY;;MAEZ,QAAQ;;EAGZ;;EAEA;;EAGA,WAAW;;EAOX,YAAY,QAAQ;;EAMpB;;SAGO,OAAO,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKlC,SAAS,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKpC,YAAY,GAAG,OAAO,KAAK;;SAK3B,SAAS,GAAG,OAAO,KAAK;;SAKxB,UAAU,GAAG,OAAO,KAAK;;;;;;KC/DtB;;qBAGC,sBAAsB;;wBAGnB,aAAa,OAAO,aAAa,GAAG,GAAG,KAAK,IAAI,GAA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Q;;EAER;;;UAIe;EACf;EACA,QAAQ;;EAER;IAAS;;;;UAIM;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;;EAEA;EACA;;;UAIe;EACf;EACA;EACA;;EAEA;EACA;EACA;;EAEA,QAAQ;;EAER;EACA;EACA;;EAEA;;EAEA,kBAAkB;;EAElB,QAAQ;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/pack.ts","../src/skyline.ts","../src/shelf.ts","../src/free.ts","../src/push.ts","../src/metrics.ts","../src/contract.ts","../src/measures.ts","../src/strategy.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/check.ts","../src/layout-input.ts","../src/generators.ts","../src/corpus.ts"],"mappings":";qBACa;;EAIX,YAAY,YAAO;;MAMf;MACA,EAAE;;MAEF;MACA,EAAE;;EAGN,IAAI,WAAW;;EAMf,MAAM,GAAG;;EAMT,IAAI,OAAO,SAAS;;EAKpB;;EAKA,SAAS;;EAKT,MAAM,KAAK,QAAQ,KAAK,SAAS;;SAQ1B,GAAG,iBAAiB;;SAKpB,IAAI,SAAS,WAAW;;SASxB,IAAI,SAAS,WAAW;;aASpB,YAAY;;;qBCxEZ,KAAK;;;EAKhB,KAAK;;EAEL;;EAEA;;EAEA;;;;;EAKA;;MAGI,YAAY;;MAEZ,QAAQ;;EAGZ;;EAEA;;EAGA,WAAW;;EAOX,YAAY,QAAQ;;EAMpB;;SAGO,OAAO,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKlC,SAAS,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKpC,YAAY,GAAG,OAAO,KAAK;;SAK3B,SAAS,GAAG,OAAO,KAAK;;SAKxB,UAAU,GAAG,OAAO,KAAK;;;;;;KC/DtB;;qBAGC,sBAAsB;;wBAGnB,aAAa,OAAO,aAAa,GAAG,GAAG,KAAK,IAAI,GAAG,KAAK;;UCLvD;;EAEf,YAAY;;;UAIG,0BAA0B;;;;;EA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Q;;;UAIO;EACf,UAAU;EACV,QAAQ;;;;;;wBAOM,OAAO,cAAc,gBAAgB,eAAe"}
|
package/build/index.js
CHANGED
|
@@ -911,28 +911,50 @@ function toPackInput(file) {
|
|
|
911
911
|
return input;
|
|
912
912
|
}
|
|
913
913
|
// src/measures.ts
|
|
914
|
-
const spec = (id, family, unit, direction, min, max) => ({
|
|
914
|
+
const spec = (id, family, unit, direction, min, max, guard) => ({
|
|
915
915
|
id,
|
|
916
916
|
family,
|
|
917
917
|
unit,
|
|
918
918
|
direction,
|
|
919
919
|
min,
|
|
920
|
-
max
|
|
920
|
+
max,
|
|
921
|
+
...guard
|
|
921
922
|
});
|
|
922
|
-
/**
|
|
923
|
+
/**
|
|
924
|
+
* The facts of each measure, by id. `docs/MEASURES.md` gives the full definitions. This record is the source of the floor
|
|
925
|
+
* and the tolerance of each guard of the packer.
|
|
926
|
+
*/
|
|
923
927
|
const MEASURE_SPECS = Object.freeze({
|
|
924
928
|
"pack.area": spec("pack.area", "density", "square units", "lower", 0, Infinity),
|
|
925
929
|
"pack.fill": spec("pack.fill", "density", "share", "higher", 0, 1),
|
|
926
930
|
"pack.whitespace": spec("pack.whitespace", "density", "share", "lower", 0, 1),
|
|
927
931
|
"pack.aspect": spec("pack.aspect", "aspect", "ratio", "lower", 1, Infinity),
|
|
928
|
-
"pack.aspectError": spec("pack.aspectError", "aspect", "natural log", "lower", 0, Infinity
|
|
929
|
-
|
|
932
|
+
"pack.aspectError": spec("pack.aspectError", "aspect", "natural log", "lower", 0, Infinity, {
|
|
933
|
+
floor: 0,
|
|
934
|
+
tol: .01
|
|
935
|
+
}),
|
|
936
|
+
"pack.order.inversions": spec("pack.order.inversions", "order", "share", "lower", 0, 1, {
|
|
937
|
+
floor: 0,
|
|
938
|
+
tol: 0
|
|
939
|
+
}),
|
|
930
940
|
"pack.order.breaks": spec("pack.order.breaks", "order", "count", "lower", 0, Infinity),
|
|
931
941
|
"pack.raggedness": spec("pack.raggedness", "raggedness", "share", "lower", 0, 1),
|
|
932
|
-
"pack.overflow": spec("pack.overflow", "overflow", "count", "lower", 0, Infinity
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
942
|
+
"pack.overflow": spec("pack.overflow", "overflow", "count", "lower", 0, Infinity, {
|
|
943
|
+
floor: 0,
|
|
944
|
+
tol: 0
|
|
945
|
+
}),
|
|
946
|
+
"pack.stability.moved": spec("pack.stability.moved", "stability", "share", "lower", 0, 1, {
|
|
947
|
+
floor: 0,
|
|
948
|
+
tol: .02
|
|
949
|
+
}),
|
|
950
|
+
"pack.stability.mean": spec("pack.stability.mean", "stability", "container widths", "lower", 0, Infinity, {
|
|
951
|
+
floor: 0,
|
|
952
|
+
tol: .005
|
|
953
|
+
}),
|
|
954
|
+
"pack.stability.q95": spec("pack.stability.q95", "stability", "container widths", "lower", 0, Infinity, {
|
|
955
|
+
floor: 0,
|
|
956
|
+
tol: .01
|
|
957
|
+
}),
|
|
936
958
|
"pack.deterministic": spec("pack.deterministic", "determinism", "boolean", "higher", 0, 1),
|
|
937
959
|
"pack.search.widths": spec("pack.search.widths", "speed", "count", "lower", 0, Infinity),
|
|
938
960
|
"pack.search.ms": spec("pack.search.ms", "speed", "milliseconds", "lower", 0, Infinity)
|
|
@@ -2052,8 +2074,11 @@ function overlap(a, b, tolerance) {
|
|
|
2052
2074
|
* - `no-overlap`: each pair of items with their margins, and each pair of an item and an obstacle, that overlap by more than `tolerance.overlap`.
|
|
2053
2075
|
* - `in-container`: each item with its margin that goes out of a fixed side by more than `tolerance.overlap`. The inset of
|
|
2054
2076
|
* the container makes each fixed side smaller (decision 3 of `docs/PACKER.md`).
|
|
2055
|
-
* - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no
|
|
2056
|
-
* - `complete`: each item with no
|
|
2077
|
+
* - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no placement.
|
|
2078
|
+
* - `complete`: each item with no placement that is not in the overflow. A locked item breaks `locked-kept` in its place.
|
|
2079
|
+
*
|
|
2080
|
+
* A locked item with no placement stays at its input position for `no-overlap` and `in-container`. A locked item with no
|
|
2081
|
+
* `x` or no `y` in the input is not locked for these rules.
|
|
2057
2082
|
*
|
|
2058
2083
|
* The rules read a shape of the container, of an obstacle or of an item as its bounding box (decision 5). The bounding box
|
|
2059
2084
|
* of an item shape is relative to the position of the item. The result has no tolerance in it.
|
|
@@ -2071,14 +2096,20 @@ function checkHard(input, output, tolerance = DEFAULT_TOLERANCE) {
|
|
|
2071
2096
|
};
|
|
2072
2097
|
const boxes = [];
|
|
2073
2098
|
for (const item of input.items) {
|
|
2074
|
-
const
|
|
2099
|
+
const lockedAt = item.locked === true && item.x !== void 0 && item.y !== void 0 ? {
|
|
2100
|
+
x: item.x,
|
|
2101
|
+
y: item.y
|
|
2102
|
+
} : void 0;
|
|
2103
|
+
let p = placements.get(item.id);
|
|
2075
2104
|
if (p === void 0) {
|
|
2076
|
-
if (
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2105
|
+
if (lockedAt === void 0) {
|
|
2106
|
+
if (!overflow.has(item.id)) breaks.complete += 1;
|
|
2107
|
+
continue;
|
|
2108
|
+
}
|
|
2109
|
+
breaks["locked-kept"] += 1;
|
|
2110
|
+
p = lockedAt;
|
|
2111
|
+
} else if (lockedAt !== void 0) {
|
|
2112
|
+
if (Math.abs(p.x - lockedAt.x) > .001 || Math.abs(p.y - lockedAt.y) > .001) breaks["locked-kept"] += 1;
|
|
2082
2113
|
}
|
|
2083
2114
|
const placed = p.turn === 90 ? turnItem(item) : item;
|
|
2084
2115
|
const m = marginOf(placed);
|