@safe-vanity-blockie/core 0.4.1 → 0.5.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/templates.d.ts +28 -6
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +45 -16
- package/dist/templates.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/templates.ts +45 -15
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { createKeccak256, type Keccak256 } from './keccak.js';
|
|
|
5
5
|
export { type Candidate, compareCandidates, createMiner, Leaderboard, type MineOptions, type MineResult, } from './miner.js';
|
|
6
6
|
export { apportion, colorContrast, compileFace, describeMatch, hslToRgb, isTwoColor, makeScorer, } from './scoring.js';
|
|
7
7
|
export { filterCandidates, formatScore, type SelectReportedResult, scorePercent, selectReported, } from './select.js';
|
|
8
|
-
export { BASE_TARGET, BASE_WEIGHTS, faceSpecForTarget, faceWithMouths, getTemplate, MOUTH_BG_WEIGHT, MOUTH_BUDGET, MOUTH_INDICES, MOUTH_STROKE_WEIGHT, MOUTHS, parseFaceSpec, TEMPLATES, targetNameForMouths, } from './templates.js';
|
|
8
|
+
export { BASE_TARGET, BASE_WEIGHTS, faceSpecForTarget, faceWithMouths, getTemplate, MOUTH_BG_WEIGHT, MOUTH_BUDGET, MOUTH_INDICES, MOUTH_STROKE_WEIGHT, MOUTHS, mouthNamesForTarget, parseFaceSpec, TEMPLATES, targetNameForMouths, } from './templates.js';
|
|
9
9
|
export type { BloImage, CompiledFace, FaceRegion, FaceSpec, FixedCell, Hsl, Palette, RegionAlternative, } from './types.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EACL,KAAK,SAAS,EACd,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,oBAAoB,EACzB,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,SAAS,EACT,mBAAmB,GACpB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,GAAG,EACH,OAAO,EACP,iBAAiB,GAClB,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EACL,KAAK,SAAS,EACd,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,oBAAoB,EACzB,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,mBAAmB,GACpB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,GAAG,EACH,OAAO,EACP,iBAAiB,GAClB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,5 +5,5 @@ export { createKeccak256 } from './keccak.js';
|
|
|
5
5
|
export { compareCandidates, createMiner, Leaderboard, } from './miner.js';
|
|
6
6
|
export { apportion, colorContrast, compileFace, describeMatch, hslToRgb, isTwoColor, makeScorer, } from './scoring.js';
|
|
7
7
|
export { filterCandidates, formatScore, scorePercent, selectReported, } from './select.js';
|
|
8
|
-
export { BASE_TARGET, BASE_WEIGHTS, faceSpecForTarget, faceWithMouths, getTemplate, MOUTH_BG_WEIGHT, MOUTH_BUDGET, MOUTH_INDICES, MOUTH_STROKE_WEIGHT, MOUTHS, parseFaceSpec, TEMPLATES, targetNameForMouths, } from './templates.js';
|
|
8
|
+
export { BASE_TARGET, BASE_WEIGHTS, faceSpecForTarget, faceWithMouths, getTemplate, MOUTH_BG_WEIGHT, MOUTH_BUDGET, MOUTH_INDICES, MOUTH_STROKE_WEIGHT, MOUTHS, mouthNamesForTarget, parseFaceSpec, TEMPLATES, targetNameForMouths, } from './templates.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,oBAAoB,EAAsB,MAAM,cAAc,CAAA;AAC5F,OAAO,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAA;AAC7D,OAAO,EAEL,iBAAiB,EACjB,WAAW,EACX,WAAW,GAGZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEX,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,SAAS,EACT,mBAAmB,GACpB,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,oBAAoB,EAAsB,MAAM,cAAc,CAAA;AAC5F,OAAO,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAA;AAC7D,OAAO,EAEL,iBAAiB,EACjB,WAAW,EACX,WAAW,GAGZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEX,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,mBAAmB,GACpB,MAAM,gBAAgB,CAAA"}
|
package/dist/templates.d.ts
CHANGED
|
@@ -20,15 +20,34 @@ export declare function getTemplate(name: string): FaceSpec;
|
|
|
20
20
|
* Commas because that is the one list separator the CLI already has — `--owners 0x..,0x..` — and a
|
|
21
21
|
* second convention for a second list is one more thing to remember at the prompt for no gain.
|
|
22
22
|
*
|
|
23
|
-
* Lives beside TEMPLATES rather than in the app that needs it, because it is one
|
|
24
|
-
* round-trip whose other
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* Lives beside TEMPLATES rather than in the app that needs it, because it is one side of a
|
|
24
|
+
* round-trip whose other two sides are `faceSpecForTarget` (name → spec) and `mouthNamesForTarget`
|
|
25
|
+
* below (name → names) — the app names a selection with this, hands that name to the CLI or a URL,
|
|
26
|
+
* and either resolves it back to the same set of expressions. Split across two packages, the sides
|
|
27
|
+
* would be free to drift apart with nothing failing.
|
|
27
28
|
*
|
|
28
29
|
* Validates nothing: the caller builds the spec from the same names, and `faceWithMouths` is where
|
|
29
30
|
* an unknown one is caught, with the error that lists the expressions.
|
|
30
31
|
*/
|
|
31
32
|
export declare function targetNameForMouths(mouthNames: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* The expressions a `--target` name accepts.
|
|
35
|
+
*
|
|
36
|
+
* The third side of the round-trip whose other two are `targetNameForMouths` (names → name) and
|
|
37
|
+
* `faceSpecForTarget` (name → spec). It exists because a caller reading a name back needs the
|
|
38
|
+
* NAMES, not a spec: the browser app's state is the accepted expressions, and it builds its own
|
|
39
|
+
* spec from them (see the web package's `faceSpecFromSelection`). Handed a FaceSpec it would have
|
|
40
|
+
* to take that object apart again to find out what is in it, or keep a second parser of its own —
|
|
41
|
+
* and a second parser is how a `--target` at the prompt and a `target=` in a URL come to disagree
|
|
42
|
+
* about what `smile,open` means.
|
|
43
|
+
*
|
|
44
|
+
* Lives here for the reason `targetNameForMouths` gives: split across packages, the halves of a
|
|
45
|
+
* round-trip are free to drift apart with nothing failing.
|
|
46
|
+
*
|
|
47
|
+
* A repeat is deduped rather than rejected — it names the same expression twice, which is not
|
|
48
|
+
* ambiguous, and a second identical alternative is scoring work for no wider target.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mouthNamesForTarget(target: string): string[];
|
|
32
51
|
/**
|
|
33
52
|
* A `--target` name: a builtin template, or a comma-separated list of expressions — so
|
|
34
53
|
* `smile,frown` accepts either of those two mouths and nothing else.
|
|
@@ -38,8 +57,11 @@ export declare function targetNameForMouths(mouthNames: string[]): string;
|
|
|
38
57
|
* name to be handed to the CLI at all, and the command the app offered for "run this same search
|
|
39
58
|
* natively" quietly searched a wider target than the screen it was copied from.
|
|
40
59
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
60
|
+
* The TEMPLATES lookup stays a fast path rather than being folded into the parse below, and not
|
|
61
|
+
* for speed: it returns the MEMOISED spec for a builtin name, and identity is load-bearing for the
|
|
62
|
+
* browser app, which keys a run's identity on the spec object (see MiningView's `sameRun`).
|
|
63
|
+
* Rebuilding an equal one here would restart a run over nothing. Its `hasOwn` also keeps the
|
|
64
|
+
* null-prototype guard exactly where the TEMPLATES comment explains it.
|
|
43
65
|
*/
|
|
44
66
|
export declare function faceSpecForTarget(target: string): FaceSpec;
|
|
45
67
|
/** Validates untrusted JSON (a `--target file.json`, or a future web designer export). */
|
package/dist/templates.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,QAAQ,EAAa,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEpF,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC,iGAAiG;AACjG,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,EAEzC,CAAA;AAED,mHAAmH;AACnH,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAEzC,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAAqD,CAAA;AAEhG,eAAO,MAAM,MAAM,EAAE,SAAS,iBAAiB,EAO9C,CAAA;AAiBD,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,QAAQ,CAW3E;AAKD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAQ7C,CAAA;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAKlD;AAED
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,QAAQ,EAAa,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEpF,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC,iGAAiG;AACjG,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,EAEzC,CAAA;AAED,mHAAmH;AACnH,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAEzC,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAAqD,CAAA;AAEhG,eAAO,MAAM,MAAM,EAAE,SAAS,iBAAiB,EAO9C,CAAA;AAiBD,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,QAAQ,CAW3E;AAKD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAQ7C,CAAA;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAKlD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAKhE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAyB5D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAO1D;AAkBD,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAoEtD"}
|
package/dist/templates.js
CHANGED
|
@@ -63,10 +63,11 @@ export function getTemplate(name) {
|
|
|
63
63
|
* Commas because that is the one list separator the CLI already has — `--owners 0x..,0x..` — and a
|
|
64
64
|
* second convention for a second list is one more thing to remember at the prompt for no gain.
|
|
65
65
|
*
|
|
66
|
-
* Lives beside TEMPLATES rather than in the app that needs it, because it is one
|
|
67
|
-
* round-trip whose other
|
|
68
|
-
*
|
|
69
|
-
*
|
|
66
|
+
* Lives beside TEMPLATES rather than in the app that needs it, because it is one side of a
|
|
67
|
+
* round-trip whose other two sides are `faceSpecForTarget` (name → spec) and `mouthNamesForTarget`
|
|
68
|
+
* below (name → names) — the app names a selection with this, hands that name to the CLI or a URL,
|
|
69
|
+
* and either resolves it back to the same set of expressions. Split across two packages, the sides
|
|
70
|
+
* would be free to drift apart with nothing failing.
|
|
70
71
|
*
|
|
71
72
|
* Validates nothing: the caller builds the spec from the same names, and `faceWithMouths` is where
|
|
72
73
|
* an unknown one is caught, with the error that lists the expressions.
|
|
@@ -77,22 +78,27 @@ export function targetNameForMouths(mouthNames) {
|
|
|
77
78
|
return isEveryMouth ? 'faces' : unique.join(',');
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
|
-
*
|
|
81
|
-
* `smile,frown` accepts either of those two mouths and nothing else.
|
|
81
|
+
* The expressions a `--target` name accepts.
|
|
82
82
|
*
|
|
83
|
-
* The
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
83
|
+
* The third side of the round-trip whose other two are `targetNameForMouths` (names → name) and
|
|
84
|
+
* `faceSpecForTarget` (name → spec). It exists because a caller reading a name back needs the
|
|
85
|
+
* NAMES, not a spec: the browser app's state is the accepted expressions, and it builds its own
|
|
86
|
+
* spec from them (see the web package's `faceSpecFromSelection`). Handed a FaceSpec it would have
|
|
87
|
+
* to take that object apart again to find out what is in it, or keep a second parser of its own —
|
|
88
|
+
* and a second parser is how a `--target` at the prompt and a `target=` in a URL come to disagree
|
|
89
|
+
* about what `smile,open` means.
|
|
90
|
+
*
|
|
91
|
+
* Lives here for the reason `targetNameForMouths` gives: split across packages, the halves of a
|
|
92
|
+
* round-trip are free to drift apart with nothing failing.
|
|
87
93
|
*
|
|
88
|
-
* A repeat is deduped rather than rejected
|
|
94
|
+
* A repeat is deduped rather than rejected — it names the same expression twice, which is not
|
|
89
95
|
* ambiguous, and a second identical alternative is scoring work for no wider target.
|
|
90
96
|
*/
|
|
91
|
-
export function
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
if (
|
|
95
|
-
return
|
|
97
|
+
export function mouthNamesForTarget(target) {
|
|
98
|
+
// The only builtin that is not simply a list of expressions. Every other TEMPLATES key IS a
|
|
99
|
+
// mouth name, which the list branch below already reads, so this is the whole special case.
|
|
100
|
+
if (target === 'faces')
|
|
101
|
+
return MOUTHS.map((mouth) => mouth.name);
|
|
96
102
|
const known = new Set(MOUTHS.map((mouth) => mouth.name));
|
|
97
103
|
const names = [
|
|
98
104
|
...new Set(target
|
|
@@ -108,6 +114,29 @@ export function faceSpecForTarget(target) {
|
|
|
108
114
|
throw new Error(`unknown target "${target}"; expected a template (${Object.keys(TEMPLATES).join(', ')}) ` +
|
|
109
115
|
`or a comma-separated list of expressions (${MOUTHS.map((mouth) => mouth.name).join(', ')})`);
|
|
110
116
|
}
|
|
117
|
+
return names;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A `--target` name: a builtin template, or a comma-separated list of expressions — so
|
|
121
|
+
* `smile,frown` accepts either of those two mouths and nothing else.
|
|
122
|
+
*
|
|
123
|
+
* The list form exists because the builtins name only the two ends of the range, one expression or
|
|
124
|
+
* all five, while the browser app accepts any subset of them. A narrowed selection therefore had no
|
|
125
|
+
* name to be handed to the CLI at all, and the command the app offered for "run this same search
|
|
126
|
+
* natively" quietly searched a wider target than the screen it was copied from.
|
|
127
|
+
*
|
|
128
|
+
* The TEMPLATES lookup stays a fast path rather than being folded into the parse below, and not
|
|
129
|
+
* for speed: it returns the MEMOISED spec for a builtin name, and identity is load-bearing for the
|
|
130
|
+
* browser app, which keys a run's identity on the spec object (see MiningView's `sameRun`).
|
|
131
|
+
* Rebuilding an equal one here would restart a run over nothing. Its `hasOwn` also keeps the
|
|
132
|
+
* null-prototype guard exactly where the TEMPLATES comment explains it.
|
|
133
|
+
*/
|
|
134
|
+
export function faceSpecForTarget(target) {
|
|
135
|
+
// Same null-prototype reasoning as TEMPLATES: `hasOwn`, so a URL- or argv-supplied
|
|
136
|
+
// "constructor" cannot resolve to an inherited key.
|
|
137
|
+
if (Object.hasOwn(TEMPLATES, target))
|
|
138
|
+
return TEMPLATES[target];
|
|
139
|
+
const names = mouthNamesForTarget(target);
|
|
111
140
|
return faceWithMouths(targetNameForMouths(names), names);
|
|
112
141
|
}
|
|
113
142
|
/** Guards the `entry as Record<string, unknown>` casts below: a null or primitive entry would
|
package/dist/templates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAEhC,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;CAC3D,CAAA;AAED,mHAAmH;AACnH,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,E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,CAAC;YAChE,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,KAAK,eAAe,CAAC;YAClF,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,KAAK,WAAW,CAAC;YACtE,YAAY;SACb,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AACjC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/templates.ts
CHANGED
|
@@ -82,10 +82,11 @@ export function getTemplate(name: string): FaceSpec {
|
|
|
82
82
|
* Commas because that is the one list separator the CLI already has — `--owners 0x..,0x..` — and a
|
|
83
83
|
* second convention for a second list is one more thing to remember at the prompt for no gain.
|
|
84
84
|
*
|
|
85
|
-
* Lives beside TEMPLATES rather than in the app that needs it, because it is one
|
|
86
|
-
* round-trip whose other
|
|
87
|
-
*
|
|
88
|
-
*
|
|
85
|
+
* Lives beside TEMPLATES rather than in the app that needs it, because it is one side of a
|
|
86
|
+
* round-trip whose other two sides are `faceSpecForTarget` (name → spec) and `mouthNamesForTarget`
|
|
87
|
+
* below (name → names) — the app names a selection with this, hands that name to the CLI or a URL,
|
|
88
|
+
* and either resolves it back to the same set of expressions. Split across two packages, the sides
|
|
89
|
+
* would be free to drift apart with nothing failing.
|
|
89
90
|
*
|
|
90
91
|
* Validates nothing: the caller builds the spec from the same names, and `faceWithMouths` is where
|
|
91
92
|
* an unknown one is caught, with the error that lists the expressions.
|
|
@@ -98,21 +99,26 @@ export function targetNameForMouths(mouthNames: string[]): string {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
|
-
*
|
|
102
|
-
* `smile,frown` accepts either of those two mouths and nothing else.
|
|
102
|
+
* The expressions a `--target` name accepts.
|
|
103
103
|
*
|
|
104
|
-
* The
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
104
|
+
* The third side of the round-trip whose other two are `targetNameForMouths` (names → name) and
|
|
105
|
+
* `faceSpecForTarget` (name → spec). It exists because a caller reading a name back needs the
|
|
106
|
+
* NAMES, not a spec: the browser app's state is the accepted expressions, and it builds its own
|
|
107
|
+
* spec from them (see the web package's `faceSpecFromSelection`). Handed a FaceSpec it would have
|
|
108
|
+
* to take that object apart again to find out what is in it, or keep a second parser of its own —
|
|
109
|
+
* and a second parser is how a `--target` at the prompt and a `target=` in a URL come to disagree
|
|
110
|
+
* about what `smile,open` means.
|
|
111
|
+
*
|
|
112
|
+
* Lives here for the reason `targetNameForMouths` gives: split across packages, the halves of a
|
|
113
|
+
* round-trip are free to drift apart with nothing failing.
|
|
108
114
|
*
|
|
109
|
-
* A repeat is deduped rather than rejected
|
|
115
|
+
* A repeat is deduped rather than rejected — it names the same expression twice, which is not
|
|
110
116
|
* ambiguous, and a second identical alternative is scoring work for no wider target.
|
|
111
117
|
*/
|
|
112
|
-
export function
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
if (
|
|
118
|
+
export function mouthNamesForTarget(target: string): string[] {
|
|
119
|
+
// The only builtin that is not simply a list of expressions. Every other TEMPLATES key IS a
|
|
120
|
+
// mouth name, which the list branch below already reads, so this is the whole special case.
|
|
121
|
+
if (target === 'faces') return MOUTHS.map((mouth) => mouth.name)
|
|
116
122
|
|
|
117
123
|
const known = new Set(MOUTHS.map((mouth) => mouth.name))
|
|
118
124
|
const names = [
|
|
@@ -133,6 +139,30 @@ export function faceSpecForTarget(target: string): FaceSpec {
|
|
|
133
139
|
`or a comma-separated list of expressions (${MOUTHS.map((mouth) => mouth.name).join(', ')})`,
|
|
134
140
|
)
|
|
135
141
|
}
|
|
142
|
+
return names
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A `--target` name: a builtin template, or a comma-separated list of expressions — so
|
|
147
|
+
* `smile,frown` accepts either of those two mouths and nothing else.
|
|
148
|
+
*
|
|
149
|
+
* The list form exists because the builtins name only the two ends of the range, one expression or
|
|
150
|
+
* all five, while the browser app accepts any subset of them. A narrowed selection therefore had no
|
|
151
|
+
* name to be handed to the CLI at all, and the command the app offered for "run this same search
|
|
152
|
+
* natively" quietly searched a wider target than the screen it was copied from.
|
|
153
|
+
*
|
|
154
|
+
* The TEMPLATES lookup stays a fast path rather than being folded into the parse below, and not
|
|
155
|
+
* for speed: it returns the MEMOISED spec for a builtin name, and identity is load-bearing for the
|
|
156
|
+
* browser app, which keys a run's identity on the spec object (see MiningView's `sameRun`).
|
|
157
|
+
* Rebuilding an equal one here would restart a run over nothing. Its `hasOwn` also keeps the
|
|
158
|
+
* null-prototype guard exactly where the TEMPLATES comment explains it.
|
|
159
|
+
*/
|
|
160
|
+
export function faceSpecForTarget(target: string): FaceSpec {
|
|
161
|
+
// Same null-prototype reasoning as TEMPLATES: `hasOwn`, so a URL- or argv-supplied
|
|
162
|
+
// "constructor" cannot resolve to an inherited key.
|
|
163
|
+
if (Object.hasOwn(TEMPLATES, target)) return TEMPLATES[target]
|
|
164
|
+
|
|
165
|
+
const names = mouthNamesForTarget(target)
|
|
136
166
|
return faceWithMouths(targetNameForMouths(names), names)
|
|
137
167
|
}
|
|
138
168
|
|