@mark1russell7/layout-contract 0.5.4 → 0.5.6
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 +36 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +99 -12
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/hash.ts +74 -5
- package/src/strategy-catalog.ts +20 -7
package/build/index.d.ts
CHANGED
|
@@ -481,17 +481,45 @@ export interface HashOptions {
|
|
|
481
481
|
* The value `0` keeps the exact numbers. A negative value or a value that is not finite causes a `RangeError`.
|
|
482
482
|
*/
|
|
483
483
|
readonly grid?: number;
|
|
484
|
+
/**
|
|
485
|
+
* The names of the fields that the hash does not read, at each depth. Use it for report fields, for example a trace or a time.
|
|
486
|
+
* A field with one of these names is out of the form in each object of the value, also in an object in a list.
|
|
487
|
+
*/
|
|
488
|
+
readonly skip?: readonly string[];
|
|
484
489
|
}
|
|
485
490
|
/**
|
|
486
491
|
* This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.
|
|
487
492
|
* Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.
|
|
488
493
|
* With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.
|
|
489
|
-
* The function throws a `RangeError` for `NaN` and for an infinite number.
|
|
494
|
+
* The function throws a `RangeError` for `NaN` and for an infinite number. The fields of `options.skip` are out of the form.
|
|
490
495
|
*
|
|
491
496
|
* The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.
|
|
492
497
|
* The grid can also merge two outputs whose numbers go to the same points. This merge is intentional: it removes the noise of floating-point numbers.
|
|
493
498
|
*/
|
|
494
499
|
export declare function outputHash(value: unknown, options?: HashOptions): string;
|
|
500
|
+
/**
|
|
501
|
+
* This function gives the normal form of the output of a packer, for a fingerprint.
|
|
502
|
+
* The form has the placements, the overflow, the size and the moved obstacles. It does not have the trace.
|
|
503
|
+
* The placements, the moved obstacles and the overflow are in the order of their ids. A placement without `turn` gets `turn: 0`.
|
|
504
|
+
* Thus two packers with the same result in a different order have the same form.
|
|
505
|
+
* The function throws a `RangeError` when `placements`, `overflow` or `moved` has an id two times.
|
|
506
|
+
*/
|
|
507
|
+
export declare function packOutputForm(output: PackOutput): unknown;
|
|
508
|
+
/** The hash of a probe that the strategy refused or does not support. It has no reason text, so a new text of a refusal does not change a fingerprint. */
|
|
509
|
+
export declare const REFUSED_PROBE = "refused";
|
|
510
|
+
/**
|
|
511
|
+
* This function gives the hash of one probe of a strategy. It calls `run` and gives `outputHash` of its result, with exact numbers by default.
|
|
512
|
+
* When `run` throws an error that `refused` accepts, the function gives `REFUSED_PROBE`. It throws each other error again.
|
|
513
|
+
* The option `grid` of `options` puts the numbers on a grid. Its default here is `0`, so a change in a number changes the hash.
|
|
514
|
+
*/
|
|
515
|
+
export declare function probeHash(run: () => unknown, refused: (error: unknown) => boolean, options?: HashOptions): string;
|
|
516
|
+
/**
|
|
517
|
+
* This function gives the fingerprint of the outputs of one strategy: one hash of the hashes of its probes.
|
|
518
|
+
* The key of `hashes` is the id of a probe, and its value is the hash of the probe, from `probeHash`.
|
|
519
|
+
* The order of the keys does not change the fingerprint. A new probe, a probe less or a changed hash changes it.
|
|
520
|
+
* The function throws a `RangeError` when there is no probe.
|
|
521
|
+
*/
|
|
522
|
+
export declare function fingerprintOf(hashes: Readonly<Record<string, string>>): string;
|
|
495
523
|
/**
|
|
496
524
|
* This function gives the hash of a document. It uses the rule of `outputHash`, but the form does not include the field `hash` of the document.
|
|
497
525
|
* With the default grid, it is the input hash of `docs/FORMAT.md` of `packing`.
|
|
@@ -1092,9 +1120,9 @@ export declare function declarationIssues(key: string, d: AnyOption): string[];
|
|
|
1092
1120
|
*/
|
|
1093
1121
|
export declare function checkSchema(strategy: DeclaredStrategy): string[];
|
|
1094
1122
|
/** The newest schema of a strategy catalog. A new field is a new version of the schema. */
|
|
1095
|
-
export declare const STRATEGY_CATALOG_SCHEMA = "strategy-catalog/
|
|
1096
|
-
/** The schemas that `parseStrategyCatalog` reads, oldest first. Schema 2 adds the field `output` of an entry
|
|
1097
|
-
export declare const STRATEGY_CATALOG_SCHEMAS: readonly ["strategy-catalog/1", "strategy-catalog/2"];
|
|
1123
|
+
export declare const STRATEGY_CATALOG_SCHEMA = "strategy-catalog/3";
|
|
1124
|
+
/** The schemas that `parseStrategyCatalog` reads, oldest first. Schema 2 adds the field `output` of an entry, and schema 3 adds the field `fingerprint`. */
|
|
1125
|
+
export declare const STRATEGY_CATALOG_SCHEMAS: readonly ["strategy-catalog/1", "strategy-catalog/2", "strategy-catalog/3"];
|
|
1098
1126
|
/** The name of one schema of a strategy catalog. */
|
|
1099
1127
|
export type StrategyCatalogSchema = (typeof STRATEGY_CATALOG_SCHEMAS)[number];
|
|
1100
1128
|
/**
|
|
@@ -1182,6 +1210,8 @@ export interface CatalogEntry {
|
|
|
1182
1210
|
readonly baseline?: true;
|
|
1183
1211
|
/** The reads of the output of the strategy. A file with this field has the schema 2. */
|
|
1184
1212
|
readonly output?: readonly OutputRow[];
|
|
1213
|
+
/** The fingerprint of the outputs of the strategy on the probes of its engine, from `fingerprintOf`. A file with this field has the schema 3. */
|
|
1214
|
+
readonly fingerprint?: string;
|
|
1185
1215
|
/** The declarations of the options, in the order of a form. */
|
|
1186
1216
|
readonly options: Readonly<Record<string, AnyOption>>;
|
|
1187
1217
|
}
|
|
@@ -1299,7 +1329,8 @@ export declare function decodeOptionValue(value: unknown, declaration: AnyOption
|
|
|
1299
1329
|
export declare function encodeOptionValue(value: unknown, declaration: AnyOption | ListItem): unknown;
|
|
1300
1330
|
/**
|
|
1301
1331
|
* This function gives the text of the catalog file, sorted by key. The same source and version give the same bytes.
|
|
1302
|
-
* The file has the oldest schema that holds it
|
|
1332
|
+
* The file has the oldest schema that holds it. A catalog with no `output` and no `fingerprint` stays valid for a reader of the schema 1.
|
|
1333
|
+
* A catalog with no `fingerprint` stays valid for a reader of the schema 2.
|
|
1303
1334
|
* The caller gives the version from `package.json`. The function throws an error if the file breaks a rule of the format.
|
|
1304
1335
|
*/
|
|
1305
1336
|
export declare function writeStrategyCatalog(source: StrategyCatalogSource, version: string): string;
|
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/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;qBAGA;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBC5Bf;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;;WAE7B;;;;;;;WAOA;;WAEA;;WAEA;;WAEA;;;;;;WAMA;;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,WAAW,QAAQ,KAAK;;;;;;wBASxB,kBAAkB;;;;;;wBAmClB,kBAAkB,iBAAiB;;wBC5LnC,WA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DnD;;WAEN;;WAEA;;;;;;;wBAQK,aAAa,eAAe,aAAa,eAAe,aAAa,SAAS;;;;;wBAwC9E,UAAU,cAAc,iBAAiB;;wBAOzC,gBAAgB,kBAAkB,OAAO,GAAG,SAAS,UAAU,UAAU,KAAK;;;;;wBAc9E,oBAAoB,kBAAkB,OAAO,aAAa,eAAe,KAAK;;;;;iBCtN7E,aAAa,aAAa,UAAU,WAAW;;WAErD;;WAEA;;WAEA;;WAEA,UAAU;;WAEV,UAAU;;WAEV;;;;;;wBCXK,WAAW;;;;;wBAQX,QAAQ;;wBAOR,WAAW,cAAc;;wBAKzB,UAAU,iBAAiB,YAAY;;;;;YCnB3C;;iBAGK;WACN;WACA,WAAW;;WAEX;;WAEA;;WAEA;;;;;;;;YASC;;iBAGK;WACN,SAAS;;;qBAIP,cAAc,SAAS,OAAO;;qBAG9B;;qBAGA;;;;;;wBAoCG,SAAS,OAAO,aAAa,QAAQ,gBAAgB,gBAAiC;;;;;;;;wBAiJtF,YAAY,OAAO,aAAa,QAAQ,eAAe,gBAAiC;;;;;
|
|
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/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;qBAGA;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBC5Bf;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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wCnB,mBAAmB,SAAS,eAAe;;;;;wBA4BxC,gBAAgB,cAAc,QAAO,QAAQ,mBAAwB;;YAUzE,qBAAqB,KAAK;;;;;;wBAOtB,eAAe,cAAc,MAAM,qBAAqB;;;;;wBA+BxD,kBAAkB,KAAK,iBAAiB;;;;;wBA+FxC,YAAY,KAAK,YAAY;;wBAa7B,cAAc,KAAK,YAAY;;;;;;wBAsB/B,SAAS,KAAK,iBAAiB,iBAAiB;;;;;;;;wBAsChD,kBACd,qBAAqB,mBACrB,OAAM,SAAS,eAAe,cAC9B,gBACA,cACC;;wBA8Ha,qBAAqB,IAAI,aAAa,WAAU,SAAS,aAAa,MAAW,eAAe;;iBA2G/F;WACN;WACA;;WAEA;WACA;;WAEA,qBAAqB;;WAErB;WACA,aAAa;;WAEb,cAAc,MAAM;;EAE7B,MAAM,OAAO,aAAa,cAAc,MAAM,kBAAkB;;;iBAIjD;;WAEN;;WAEA;WACA;;WAEA,QAAQ,OAAO;;;;;;;wBAWV,cAAc,MAAM,aAAa,cAAc,gBAAgB,cAAc,UAAS,iBAAsB,aAAa;;;;;qBA+D5H,YAAY;;;;qBA0BZ,eAAe;;;;;;;;;qBAuBf,kBAAkB,aAAa;;;;;;qBAqD/B,gBAAgB,aAAa"}
|
package/build/index.js
CHANGED
|
@@ -2339,7 +2339,7 @@ function gridFactor(options) {
|
|
|
2339
2339
|
* This function gives a copy of a value with each number on the grid. The value `-0` becomes `0`.
|
|
2340
2340
|
* It throws a `RangeError` for a number that is not finite.
|
|
2341
2341
|
*/
|
|
2342
|
-
function onGrid(value, path, k) {
|
|
2342
|
+
function onGrid(value, path, k, skip) {
|
|
2343
2343
|
if (typeof value === "number") {
|
|
2344
2344
|
if (!Number.isFinite(value)) throw new RangeError(`The value has the number ${value} at ${path}. JSON has no form for it.`);
|
|
2345
2345
|
if (k === void 0) return value;
|
|
@@ -2348,23 +2348,95 @@ function onGrid(value, path, k) {
|
|
|
2348
2348
|
return r === 0 ? 0 : r;
|
|
2349
2349
|
}
|
|
2350
2350
|
if (value === null || typeof value !== "object") return value;
|
|
2351
|
-
if (Array.isArray(value)) return value.map((v, i) => onGrid(v, `${path}[${i}]`, k));
|
|
2351
|
+
if (Array.isArray(value)) return value.map((v, i) => onGrid(v, `${path}[${i}]`, k, skip));
|
|
2352
2352
|
const o = value;
|
|
2353
2353
|
const out = {};
|
|
2354
|
-
for (const key of Object.keys(o)) out[key] = onGrid(o[key], `${path}.${key}`, k);
|
|
2354
|
+
for (const key of Object.keys(o)) if (!skip.has(key)) out[key] = onGrid(o[key], `${path}.${key}`, k, skip);
|
|
2355
2355
|
return out;
|
|
2356
2356
|
}
|
|
2357
2357
|
/**
|
|
2358
2358
|
* This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.
|
|
2359
2359
|
* Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.
|
|
2360
2360
|
* With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.
|
|
2361
|
-
* The function throws a `RangeError` for `NaN` and for an infinite number.
|
|
2361
|
+
* The function throws a `RangeError` for `NaN` and for an infinite number. The fields of `options.skip` are out of the form.
|
|
2362
2362
|
*
|
|
2363
2363
|
* The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.
|
|
2364
2364
|
* The grid can also merge two outputs whose numbers go to the same points. This merge is intentional: it removes the noise of floating-point numbers.
|
|
2365
2365
|
*/
|
|
2366
2366
|
function outputHash(value, options = {}) {
|
|
2367
|
-
return sha256Hex(canonicalJson(onGrid(value, "$", gridFactor(options)))).slice(0, 16);
|
|
2367
|
+
return sha256Hex(canonicalJson(onGrid(value, "$", gridFactor(options), new Set(options.skip ?? [])))).slice(0, 16);
|
|
2368
|
+
}
|
|
2369
|
+
/** This function throws a `RangeError` when a list of the output has an id two times. A packer with this output has a bug. */
|
|
2370
|
+
function uniqueIds(list, ids) {
|
|
2371
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2372
|
+
for (const id of ids) {
|
|
2373
|
+
if (seen.has(id)) throw new RangeError(`The list ${list} of the output has the id "${id}" two times.`);
|
|
2374
|
+
seen.add(id);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
/** The order of two ids by their UTF-16 code units. It does not change with the locale. */
|
|
2378
|
+
function byId(a, b) {
|
|
2379
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
* This function gives the normal form of the output of a packer, for a fingerprint.
|
|
2383
|
+
* The form has the placements, the overflow, the size and the moved obstacles. It does not have the trace.
|
|
2384
|
+
* The placements, the moved obstacles and the overflow are in the order of their ids. A placement without `turn` gets `turn: 0`.
|
|
2385
|
+
* Thus two packers with the same result in a different order have the same form.
|
|
2386
|
+
* The function throws a `RangeError` when `placements`, `overflow` or `moved` has an id two times.
|
|
2387
|
+
*/
|
|
2388
|
+
function packOutputForm(output) {
|
|
2389
|
+
uniqueIds("placements", output.placements.map((p) => p.id));
|
|
2390
|
+
uniqueIds("overflow", output.overflow);
|
|
2391
|
+
uniqueIds("moved", output.moved.map((m) => m.id));
|
|
2392
|
+
return {
|
|
2393
|
+
placements: output.placements.map((p) => ({
|
|
2394
|
+
id: p.id,
|
|
2395
|
+
x: p.x,
|
|
2396
|
+
y: p.y,
|
|
2397
|
+
turn: p.turn ?? 0
|
|
2398
|
+
})).sort(byId),
|
|
2399
|
+
overflow: [...output.overflow].sort(),
|
|
2400
|
+
size: {
|
|
2401
|
+
w: output.size.w,
|
|
2402
|
+
h: output.size.h
|
|
2403
|
+
},
|
|
2404
|
+
moved: output.moved.map((m) => ({
|
|
2405
|
+
id: m.id,
|
|
2406
|
+
x: m.x,
|
|
2407
|
+
y: m.y
|
|
2408
|
+
})).sort(byId)
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
/** The hash of a probe that the strategy refused or does not support. It has no reason text, so a new text of a refusal does not change a fingerprint. */
|
|
2412
|
+
const REFUSED_PROBE = "refused";
|
|
2413
|
+
/**
|
|
2414
|
+
* This function gives the hash of one probe of a strategy. It calls `run` and gives `outputHash` of its result, with exact numbers by default.
|
|
2415
|
+
* When `run` throws an error that `refused` accepts, the function gives `REFUSED_PROBE`. It throws each other error again.
|
|
2416
|
+
* The option `grid` of `options` puts the numbers on a grid. Its default here is `0`, so a change in a number changes the hash.
|
|
2417
|
+
*/
|
|
2418
|
+
function probeHash(run, refused, options = {}) {
|
|
2419
|
+
let value;
|
|
2420
|
+
try {
|
|
2421
|
+
value = run();
|
|
2422
|
+
} catch (error) {
|
|
2423
|
+
if (refused(error)) return REFUSED_PROBE;
|
|
2424
|
+
throw error;
|
|
2425
|
+
}
|
|
2426
|
+
return outputHash(value, {
|
|
2427
|
+
...options,
|
|
2428
|
+
grid: options.grid ?? 0
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* This function gives the fingerprint of the outputs of one strategy: one hash of the hashes of its probes.
|
|
2433
|
+
* The key of `hashes` is the id of a probe, and its value is the hash of the probe, from `probeHash`.
|
|
2434
|
+
* The order of the keys does not change the fingerprint. A new probe, a probe less or a changed hash changes it.
|
|
2435
|
+
* The function throws a `RangeError` when there is no probe.
|
|
2436
|
+
*/
|
|
2437
|
+
function fingerprintOf(hashes) {
|
|
2438
|
+
if (Object.keys(hashes).length === 0) throw new RangeError("A fingerprint needs one probe or more.");
|
|
2439
|
+
return sha256Hex(canonicalJson(hashes)).slice(0, 16);
|
|
2368
2440
|
}
|
|
2369
2441
|
/**
|
|
2370
2442
|
* This function gives the hash of a document. It uses the rule of `outputHash`, but the form does not include the field `hash` of the document.
|
|
@@ -4165,9 +4237,15 @@ function checkSchema(strategy) {
|
|
|
4165
4237
|
}
|
|
4166
4238
|
// src/strategy-catalog.ts
|
|
4167
4239
|
/** The newest schema of a strategy catalog. A new field is a new version of the schema. */
|
|
4168
|
-
const STRATEGY_CATALOG_SCHEMA = "strategy-catalog/
|
|
4169
|
-
/** The schemas that `parseStrategyCatalog` reads, oldest first. Schema 2 adds the field `output` of an entry
|
|
4170
|
-
const STRATEGY_CATALOG_SCHEMAS = [
|
|
4240
|
+
const STRATEGY_CATALOG_SCHEMA = "strategy-catalog/3";
|
|
4241
|
+
/** The schemas that `parseStrategyCatalog` reads, oldest first. Schema 2 adds the field `output` of an entry, and schema 3 adds the field `fingerprint`. */
|
|
4242
|
+
const STRATEGY_CATALOG_SCHEMAS = [
|
|
4243
|
+
"strategy-catalog/1",
|
|
4244
|
+
"strategy-catalog/2",
|
|
4245
|
+
STRATEGY_CATALOG_SCHEMA
|
|
4246
|
+
];
|
|
4247
|
+
/** The form of the field `fingerprint` of an entry: the 16 lowercase hex digits that `fingerprintOf` gives. */
|
|
4248
|
+
const FINGERPRINT = /^[0-9a-f]{16}$/u;
|
|
4171
4249
|
/**
|
|
4172
4250
|
* The dimension of `supports` that tells who owns the positions of the nodes. The value `host` means that the strategy keeps the positions that the host gives.
|
|
4173
4251
|
* The value `engine` means that the strategy can set them. A strategy that moves nodes has only `engine`. A `SupportProbe` tests the claim with a run.
|
|
@@ -4220,6 +4298,7 @@ const ENTRY_FIELDS = [
|
|
|
4220
4298
|
"optIn",
|
|
4221
4299
|
"baseline",
|
|
4222
4300
|
"output",
|
|
4301
|
+
"fingerprint",
|
|
4223
4302
|
"options"
|
|
4224
4303
|
];
|
|
4225
4304
|
const COMMON_FIELDS = [
|
|
@@ -4562,7 +4641,7 @@ function checkEvidence(at, property, rowClass, raw, faults) {
|
|
|
4562
4641
|
}
|
|
4563
4642
|
/** This function adds the faults of the field `output` of one entry. */
|
|
4564
4643
|
function checkOutput(at, raw, schema, faults) {
|
|
4565
|
-
if (schema === STRATEGY_CATALOG_SCHEMAS[0]) faults.push(`${at}: the field "output" needs the schema ${
|
|
4644
|
+
if (schema === STRATEGY_CATALOG_SCHEMAS[0]) faults.push(`${at}: the field "output" needs the schema ${STRATEGY_CATALOG_SCHEMAS[1]} or a newer schema.`);
|
|
4566
4645
|
if (!Array.isArray(raw) || raw.length === 0) {
|
|
4567
4646
|
faults.push(`${at}: "output" is not a list with rows.`);
|
|
4568
4647
|
return;
|
|
@@ -4606,6 +4685,10 @@ function readEntry(at, raw, schema, faults) {
|
|
|
4606
4685
|
if (!isFields(raw["supports"]) || !Object.values(raw["supports"]).every(isTextList)) faults.push(`${at}: "supports" is not a record of text lists.`);
|
|
4607
4686
|
checkLimits(at, raw["limits"], faults);
|
|
4608
4687
|
if (raw["output"] !== void 0) checkOutput(at, raw["output"], schema, faults);
|
|
4688
|
+
if (raw["fingerprint"] !== void 0) {
|
|
4689
|
+
if (schema !== STRATEGY_CATALOG_SCHEMAS[2]) faults.push(`${at}: the field "fingerprint" needs the schema ${STRATEGY_CATALOG_SCHEMAS[2]}.`);
|
|
4690
|
+
if (!isText(raw["fingerprint"]) || !FINGERPRINT.test(raw["fingerprint"])) faults.push(`${at}: "fingerprint" is not 16 lowercase hex digits.`);
|
|
4691
|
+
}
|
|
4609
4692
|
if (isText(raw["id"]) && raw["key"] !== catalogKey(raw["id"], raw["step"])) faults.push(`${at}: the key does not follow from "step" and "id".`);
|
|
4610
4693
|
if (!isFields(raw["options"])) {
|
|
4611
4694
|
faults.push(`${at}: "options" is not an object.`);
|
|
@@ -4639,6 +4722,7 @@ function readEntry(at, raw, schema, faults) {
|
|
|
4639
4722
|
optIn: raw["optIn"],
|
|
4640
4723
|
...raw["baseline"] === true ? { baseline: true } : {},
|
|
4641
4724
|
...raw["output"] === void 0 ? {} : { output: raw["output"] },
|
|
4725
|
+
...raw["fingerprint"] === void 0 ? {} : { fingerprint: raw["fingerprint"] },
|
|
4642
4726
|
options
|
|
4643
4727
|
};
|
|
4644
4728
|
}
|
|
@@ -4809,6 +4893,7 @@ function writeEntry(e) {
|
|
|
4809
4893
|
optIn: e.optIn,
|
|
4810
4894
|
...e.baseline === true ? { baseline: true } : {},
|
|
4811
4895
|
...e.output === void 0 ? {} : { output: e.output.map(writeRow) },
|
|
4896
|
+
...e.fingerprint === void 0 ? {} : { fingerprint: e.fingerprint },
|
|
4812
4897
|
options
|
|
4813
4898
|
};
|
|
4814
4899
|
}
|
|
@@ -4822,13 +4907,15 @@ function unsafeValues(v, at) {
|
|
|
4822
4907
|
}
|
|
4823
4908
|
/**
|
|
4824
4909
|
* This function gives the text of the catalog file, sorted by key. The same source and version give the same bytes.
|
|
4825
|
-
* The file has the oldest schema that holds it
|
|
4910
|
+
* The file has the oldest schema that holds it. A catalog with no `output` and no `fingerprint` stays valid for a reader of the schema 1.
|
|
4911
|
+
* A catalog with no `fingerprint` stays valid for a reader of the schema 2.
|
|
4826
4912
|
* The caller gives the version from `package.json`. The function throws an error if the file breaks a rule of the format.
|
|
4827
4913
|
*/
|
|
4828
4914
|
function writeStrategyCatalog(source, version) {
|
|
4829
4915
|
const strategies = [...source.strategies].sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0).map(writeEntry);
|
|
4916
|
+
const has = (field) => source.strategies.some((e) => e[field] !== void 0);
|
|
4830
4917
|
const doc = {
|
|
4831
|
-
schema:
|
|
4918
|
+
schema: has("fingerprint") ? STRATEGY_CATALOG_SCHEMAS[2] : has("output") ? STRATEGY_CATALOG_SCHEMAS[1] : STRATEGY_CATALOG_SCHEMAS[0],
|
|
4832
4919
|
engine: source.engine,
|
|
4833
4920
|
version,
|
|
4834
4921
|
strategies
|
|
@@ -6173,6 +6260,6 @@ const RECT_SCATTERED = /* @__PURE__ */ Object.freeze({
|
|
|
6173
6260
|
};
|
|
6174
6261
|
}
|
|
6175
6262
|
});
|
|
6176
|
-
export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, HARD_RULE_VERSION, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, NODE_POSITIONS_DIMENSION, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, catalogChoices, catalogDefaults, catalogKey, catalogOptions, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkSchema, checkShapes, checkSpace, checkSplit, circleOverlaps, circlesOutside, clampOptions, compareMeasure, composeFamily, configId, corpusHashOf, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, crossingPoint, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, hardRuleOf, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, listOptions, marginSides, minEffectOf, mulberry32, nearestGaps, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, parseStrategyCatalog, perChange, pickMoves, placedCircle, placedRect, pointSegmentDistance, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict, writeStrategyCatalog };
|
|
6263
|
+
export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, HARD_RULE_VERSION, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, NODE_POSITIONS_DIMENSION, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, REFUSED_PROBE, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, catalogChoices, catalogDefaults, catalogKey, catalogOptions, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkSchema, checkShapes, checkSpace, checkSplit, circleOverlaps, circlesOutside, clampOptions, compareMeasure, composeFamily, configId, corpusHashOf, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, crossingPoint, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fingerprintOf, fnv1a32, grow, hardRuleOf, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, listOptions, marginSides, minEffectOf, mulberry32, nearestGaps, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, packOutputForm, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, parseStrategyCatalog, perChange, pickMoves, placedCircle, placedRect, pointSegmentDistance, portPoint, portfolio, probeHash, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict, writeStrategyCatalog };
|
|
6177
6264
|
|
|
6178
6265
|
//# sourceMappingURL=index.js.map
|