logomarks 1.0.0 → 2.0.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/CHANGELOG.md +44 -0
- package/README.md +10 -2
- package/docs/api.md +9 -2
- package/docs/commands.md +19 -3
- package/docs/data.md +84 -0
- package/docs/mcp.md +3 -3
- package/package.json +9 -9
- package/src/brand/mark.js +2 -2
- package/src/cli/commands/combine.d.ts +2 -0
- package/src/cli/commands/combine.js +3 -0
- package/src/cli/commands/cover.d.ts +2 -0
- package/src/cli/commands/cover.js +3 -0
- package/src/cli/commands/edit.d.ts +2 -0
- package/src/cli/commands/edit.js +3 -0
- package/src/cli/commands/find.d.ts +2 -0
- package/src/cli/commands/find.js +4 -1
- package/src/cli/commands/get.d.ts +2 -0
- package/src/cli/commands/get.js +4 -1
- package/src/cli/commands/glitch.d.ts +2 -0
- package/src/cli/commands/glitch.js +3 -0
- package/src/cli/commands/index.d.ts +5 -3
- package/src/cli/commands/index.js +2 -1
- package/src/cli/commands/kit.d.ts +2 -0
- package/src/cli/commands/kit.js +3 -0
- package/src/cli/commands/mcp.d.ts +3 -2
- package/src/cli/commands/mcp.js +7 -3
- package/src/cli/commands/mockup.d.ts +2 -0
- package/src/cli/commands/mockup.js +3 -0
- package/src/cli/commands/parts.d.ts +2 -0
- package/src/cli/commands/parts.js +3 -0
- package/src/cli/commands/sheet.d.ts +2 -0
- package/src/cli/commands/sheet.js +3 -0
- package/src/cli/commands/similar.d.ts +2 -0
- package/src/cli/commands/similar.js +5 -2
- package/src/cli/commands/social.d.ts +2 -0
- package/src/cli/commands/social.js +3 -0
- package/src/cli/commands/update.d.ts +10 -0
- package/src/cli/commands/update.js +54 -0
- package/src/cli/help.js +1 -0
- package/src/cli/index.d.ts +6 -0
- package/src/cli/index.js +14 -3
- package/src/cli/options.js +3 -0
- package/src/find/index.d.ts +1 -1
- package/src/find/index.js +3 -3
- package/src/index.d.ts +3 -1
- package/src/index.js +4 -1
- package/src/live/build.d.ts +36 -0
- package/src/live/build.js +55 -0
- package/src/live/cache.d.ts +25 -0
- package/src/live/cache.js +75 -0
- package/src/live/current.d.ts +9 -0
- package/src/live/current.js +54 -0
- package/src/live/ensure.d.ts +43 -0
- package/src/live/ensure.js +92 -0
- package/src/live/errors.d.ts +16 -0
- package/src/live/errors.js +19 -0
- package/src/live/format.d.ts +13 -0
- package/src/live/format.js +113 -0
- package/src/live/index.d.ts +7 -0
- package/src/live/index.js +12 -0
- package/src/live/paths.d.ts +17 -0
- package/src/live/paths.js +64 -0
- package/src/live/remote.d.ts +24 -0
- package/src/live/remote.js +109 -0
- package/src/mcp/index.d.ts +5 -3
- package/src/mcp/index.js +26 -13
- package/src/mcp/tools/find.js +2 -2
- package/src/sheet/index.d.ts +1 -1
- package/src/similar/folder.js +2 -2
- package/src/similar/nearest.d.ts +1 -1
- package/src/similar/store.d.ts +9 -6
- package/src/similar/store.js +23 -62
- package/data/index.bin +0 -0
package/src/similar/nearest.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface SimilarOptions {
|
|
|
22
22
|
top?: number;
|
|
23
23
|
/** Compare the candidate's knocked-out letter (its holes) instead of its outline (false). */
|
|
24
24
|
letters?: boolean;
|
|
25
|
-
/** The live marks (the
|
|
25
|
+
/** The live marks (the cached index). */
|
|
26
26
|
index?: MarkIndex;
|
|
27
27
|
/** A slug to leave out (the candidate itself). */
|
|
28
28
|
exclude?: string;
|
package/src/similar/store.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface MarkAbout {
|
|
|
12
12
|
mood: string[];
|
|
13
13
|
/** The letter or number it shows, for letter marks. */
|
|
14
14
|
letter?: string;
|
|
15
|
+
/** What it depicts: subject ids (letter, animal, food-drink …), the main one first. */
|
|
16
|
+
subject?: string[];
|
|
15
17
|
/** What it looks like, in a sentence. */
|
|
16
18
|
description: string;
|
|
17
19
|
/** The kinds of business it suits, best fit first (may be empty). */
|
|
@@ -45,7 +47,7 @@ export interface MarkIndex {
|
|
|
45
47
|
built: string;
|
|
46
48
|
marks: IndexedMark[];
|
|
47
49
|
letters: IndexedLetter[];
|
|
48
|
-
/** The board's search over `marks`, in the same order (a packed @arraypress/search index); only the
|
|
50
|
+
/** The board's search over `marks`, in the same order (a packed @arraypress/search index); only the live set's index has it, not a folder's. */
|
|
49
51
|
search?: Packed;
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -59,9 +61,10 @@ export interface IndexInput {
|
|
|
59
61
|
search: Packed;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
/**
|
|
63
|
-
export
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
/** Writes an index file (brotli) and returns its size in bytes. */
|
|
65
|
+
export function writeIndex(input: IndexInput, file: string | URL): number;
|
|
66
|
+
/**
|
|
67
|
+
* Reads an index, once per file. With no file, the process's: the one `ensureIndex` settled on, else
|
|
68
|
+
* `LOGOMARKS_INDEX`, else the cached one. Throws an `IndexError` when there's none or it's in another format.
|
|
69
|
+
*/
|
|
67
70
|
export function loadIndex(file?: string | URL): MarkIndex;
|
package/src/similar/store.js
CHANGED
|
@@ -1,88 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module logomarks/similar/store
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
4
|
+
* The live set's index: each mark's slug, name and SVG, what it is (tags,
|
|
5
|
+
* collection, style, mood, letter, subject, description, industries: what
|
|
6
6
|
* `findMarks` searches), its 48 px coverage (the outline signature before its
|
|
7
|
-
* blur),
|
|
8
|
-
* @arraypress/search index
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* the signature bytes.
|
|
7
|
+
* blur), for badges and letter marks a letter signature, and the board's
|
|
8
|
+
* search over them (a packed @arraypress/search index). It isn't bundled: the
|
|
9
|
+
* site serves it, and `ensureIndex` (../live/ensure.js) downloads and caches
|
|
10
|
+
* it. The format is ../live/format.js.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
import fs from 'node:fs';
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import { blur } from './signature.js';
|
|
18
|
-
|
|
19
|
-
/** Where the bundled index lives. */
|
|
20
|
-
export const INDEX_FILE = new URL('../../data/index.bin', import.meta.url);
|
|
21
|
-
|
|
22
|
-
/** The file format's version. */
|
|
23
|
-
const VERSION = 3;
|
|
24
|
-
|
|
25
|
-
/** Letter signatures are quarters (2×2 supersampling): stored ×4. */
|
|
26
|
-
const QUARTERS = 4;
|
|
14
|
+
import { encodeIndex, decodeIndex } from '../live/format.js';
|
|
15
|
+
import { currentIndexFile } from '../live/current.js';
|
|
27
16
|
|
|
17
|
+
/** Each file's index, read once. */
|
|
28
18
|
/** @type {Map<string, import('./store.js').MarkIndex>} */
|
|
29
19
|
const cache = new Map();
|
|
30
20
|
|
|
31
21
|
/**
|
|
32
|
-
* Writes an index.
|
|
22
|
+
* Writes an index file (the monorepo's `npm run index`; the site builds its own with `buildIndex`).
|
|
33
23
|
*
|
|
34
|
-
* @param {import('./store.js').IndexInput} input The marks and
|
|
35
|
-
* @param {string | URL}
|
|
24
|
+
* @param {import('./store.js').IndexInput} input The marks, their signatures and the packed search.
|
|
25
|
+
* @param {string | URL} file Where.
|
|
36
26
|
* @returns {number} The file's size in bytes.
|
|
37
27
|
*/
|
|
38
|
-
export function writeIndex(
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
size: SIMILAR.size,
|
|
43
|
-
letterSize: LETTERS.size,
|
|
44
|
-
marks: marks.map(({ slug, name, svg, ...about }) => [slug, name, svg, about]),
|
|
45
|
-
letters: letters.map((l) => [l.mark, l.kind]),
|
|
46
|
-
search,
|
|
47
|
-
}));
|
|
48
|
-
const length = Buffer.alloc(4);
|
|
49
|
-
length.writeUInt32LE(head.length);
|
|
50
|
-
const bytes = (/** @type {ArrayLike<number>} */ a, /** @type {number} */ k) => Uint8Array.from(a, (v) => Math.round(v * k));
|
|
51
|
-
const body = Buffer.concat([length, head, ...coverages.map((c) => bytes(c, 255)), ...letters.map((l) => bytes(l.sig, QUARTERS))]);
|
|
52
|
-
const out = zlib.brotliCompressSync(body, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 11 } });
|
|
53
|
-
fs.writeFileSync(file, out);
|
|
54
|
-
return out.length;
|
|
28
|
+
export function writeIndex(input, file) {
|
|
29
|
+
const bytes = encodeIndex(input);
|
|
30
|
+
fs.writeFileSync(file, bytes);
|
|
31
|
+
return bytes.length;
|
|
55
32
|
}
|
|
56
33
|
|
|
57
34
|
/**
|
|
58
|
-
* Reads an index (once per file) and blurs its coverages into outline signatures.
|
|
35
|
+
* Reads an index (once per file) and blurs its coverages into outline signatures. With no file, the process's
|
|
36
|
+
* index: the one `ensureIndex` settled on, else `LOGOMARKS_INDEX`, else the cached one.
|
|
59
37
|
*
|
|
60
|
-
* @param {string | URL} [file] Which
|
|
38
|
+
* @param {string | URL} [file] Which.
|
|
61
39
|
* @returns {import('./store.js').MarkIndex} The index.
|
|
62
|
-
* @throws {Error} When
|
|
40
|
+
* @throws {Error} When there's none (an `IndexError` saying how to get it), or it's in another format.
|
|
63
41
|
*/
|
|
64
|
-
export function loadIndex(file
|
|
65
|
-
const key = String(file);
|
|
42
|
+
export function loadIndex(file) {
|
|
43
|
+
const key = String(file ?? currentIndexFile());
|
|
66
44
|
const hit = cache.get(key);
|
|
67
45
|
if (hit) return hit;
|
|
68
|
-
const
|
|
69
|
-
const n = body.readUInt32LE(0);
|
|
70
|
-
const raw = JSON.parse(body.toString('utf8', 4, 4 + n));
|
|
71
|
-
if (raw.version !== VERSION) throw new Error(`index version ${raw.version}, expected ${VERSION}: run npm run index`);
|
|
72
|
-
const S = raw.size * raw.size, L = raw.letterSize * raw.letterSize;
|
|
73
|
-
let at = 4 + n;
|
|
74
|
-
const take = (/** @type {number} */ len, /** @type {number} */ k) => {
|
|
75
|
-
const a = Float32Array.from(body.subarray(at, at + len), (v) => v / k);
|
|
76
|
-
at += len;
|
|
77
|
-
return a;
|
|
78
|
-
};
|
|
79
|
-
/** @type {import('./store.js').MarkIndex} */
|
|
80
|
-
const index = {
|
|
81
|
-
built: raw.built,
|
|
82
|
-
marks: raw.marks.map((/** @type {[string, string, string, import('./store.js').MarkAbout]} */ [slug, name, svg, about]) => ({ slug, name, svg, ...about, outline: blur(take(S, 255), raw.size) })),
|
|
83
|
-
letters: raw.letters.map((/** @type {[number, 'hole' | 'ink']} */ [mark, kind]) => ({ mark, kind, sig: take(L, QUARTERS) })),
|
|
84
|
-
search: raw.search,
|
|
85
|
-
};
|
|
46
|
+
const index = decodeIndex(fs.readFileSync(key.startsWith('file:') ? new URL(key) : key));
|
|
86
47
|
cache.set(key, index);
|
|
87
48
|
return index;
|
|
88
49
|
}
|
package/data/index.bin
DELETED
|
Binary file
|