@dloizides/logo-kit 0.0.0-stage → 0.1.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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +13 -2
- package/dist/cli.js +1487 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +363 -0
- package/dist/index.js +1624 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
declare const enum MotionPreset {
|
|
2
|
+
Draw = "draw",
|
|
3
|
+
Flood = "flood",
|
|
4
|
+
StaggerRise = "stagger-rise",
|
|
5
|
+
ScalePop = "scale-pop",
|
|
6
|
+
Orbit = "orbit",
|
|
7
|
+
Wipe = "wipe",
|
|
8
|
+
MorphFromCircle = "morph-from-circle",
|
|
9
|
+
Sweep = "sweep",
|
|
10
|
+
Pulse = "pulse",
|
|
11
|
+
Spread = "spread"
|
|
12
|
+
}
|
|
13
|
+
declare const INTRO_PRESETS: readonly MotionPreset[];
|
|
14
|
+
declare const MICRO_PRESETS: readonly MotionPreset[];
|
|
15
|
+
|
|
16
|
+
interface Pt {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}
|
|
20
|
+
interface PaintItem {
|
|
21
|
+
fill?: string;
|
|
22
|
+
stroke?: string;
|
|
23
|
+
width?: number;
|
|
24
|
+
}
|
|
25
|
+
interface LayerPaint {
|
|
26
|
+
light: PaintItem[];
|
|
27
|
+
dark: PaintItem[];
|
|
28
|
+
}
|
|
29
|
+
interface MarkLayer {
|
|
30
|
+
name: string;
|
|
31
|
+
d: string;
|
|
32
|
+
paint: LayerPaint;
|
|
33
|
+
transform?: string;
|
|
34
|
+
evenOdd?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface Mark {
|
|
37
|
+
id: string;
|
|
38
|
+
viewBox: string;
|
|
39
|
+
layers: MarkLayer[];
|
|
40
|
+
}
|
|
41
|
+
type ModeColours = Readonly<Record<string, string>>;
|
|
42
|
+
interface Palette {
|
|
43
|
+
name: string;
|
|
44
|
+
light: ModeColours;
|
|
45
|
+
dark: ModeColours;
|
|
46
|
+
mono: string;
|
|
47
|
+
}
|
|
48
|
+
interface MotionBeat {
|
|
49
|
+
preset: MotionPreset;
|
|
50
|
+
durationMs: number;
|
|
51
|
+
layers?: string[];
|
|
52
|
+
delayMs?: number;
|
|
53
|
+
stepMs?: number;
|
|
54
|
+
easing?: string;
|
|
55
|
+
settleEasing?: string;
|
|
56
|
+
stops?: number[];
|
|
57
|
+
fadeIn?: string[];
|
|
58
|
+
scale?: number;
|
|
59
|
+
distance?: number;
|
|
60
|
+
share?: number;
|
|
61
|
+
width?: number;
|
|
62
|
+
colour?: string;
|
|
63
|
+
}
|
|
64
|
+
interface MotionConfig {
|
|
65
|
+
intro: MotionBeat[];
|
|
66
|
+
micro: MotionBeat[];
|
|
67
|
+
allowLongIntro?: string;
|
|
68
|
+
}
|
|
69
|
+
interface GenerateConfig {
|
|
70
|
+
seed: number;
|
|
71
|
+
count: number;
|
|
72
|
+
}
|
|
73
|
+
interface Wordmark {
|
|
74
|
+
fontFamily: string;
|
|
75
|
+
fontFile?: string;
|
|
76
|
+
}
|
|
77
|
+
interface IconStyle {
|
|
78
|
+
dark: boolean;
|
|
79
|
+
share: number;
|
|
80
|
+
radius: number;
|
|
81
|
+
}
|
|
82
|
+
interface SmallMark {
|
|
83
|
+
viewBox: string;
|
|
84
|
+
d: string;
|
|
85
|
+
light: string;
|
|
86
|
+
dark: string;
|
|
87
|
+
}
|
|
88
|
+
interface Brand {
|
|
89
|
+
icons: IconStyle;
|
|
90
|
+
smallMark?: SmallMark;
|
|
91
|
+
name: string;
|
|
92
|
+
slug: string;
|
|
93
|
+
wordmark: Wordmark;
|
|
94
|
+
mark: Mark;
|
|
95
|
+
palette: Palette;
|
|
96
|
+
motion: MotionConfig;
|
|
97
|
+
generate: GenerateConfig;
|
|
98
|
+
tokens: string;
|
|
99
|
+
baseDir: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare const enum Mode {
|
|
103
|
+
Light = "light",
|
|
104
|
+
Dark = "dark"
|
|
105
|
+
}
|
|
106
|
+
declare const MODES: readonly Mode[];
|
|
107
|
+
|
|
108
|
+
declare const enum CvdKind {
|
|
109
|
+
Protan = "protan",
|
|
110
|
+
Deutan = "deutan",
|
|
111
|
+
Tritan = "tritan"
|
|
112
|
+
}
|
|
113
|
+
declare const CVD_KINDS: readonly CvdKind[];
|
|
114
|
+
|
|
115
|
+
/** Returns the colour as a viewer with full protan, deutan or tritan colour blindness sees it (Machado 2009). */
|
|
116
|
+
declare function simulateCvd(hex: string, kind: CvdKind): string;
|
|
117
|
+
/** Returns the CIE76 colour difference of two colours. */
|
|
118
|
+
declare function deltaE(a: string, b: string): number;
|
|
119
|
+
/** Returns the WCAG contrast ratio of two colours. */
|
|
120
|
+
declare function contrast(a: string, b: string): number;
|
|
121
|
+
|
|
122
|
+
/** Returns the path as closed polygons (one per subpath), arcs and curves flattened. */
|
|
123
|
+
declare function flattenPath(d: string): Pt[][];
|
|
124
|
+
|
|
125
|
+
interface Bitmap {
|
|
126
|
+
width: number;
|
|
127
|
+
height: number;
|
|
128
|
+
data: Uint8Array;
|
|
129
|
+
}
|
|
130
|
+
/** Renders an SVG string at a pixel width, fonts only from the given files (no system lookup, no network). */
|
|
131
|
+
declare function renderSvg(svg: string, width: number, fontFiles?: string[]): Bitmap;
|
|
132
|
+
/** Renders an SVG string to PNG bytes at a pixel width. */
|
|
133
|
+
declare function renderPng(svg: string, width: number, fontFiles?: string[]): Buffer;
|
|
134
|
+
/** Returns 1 where the pixel is mostly opaque, else 0. */
|
|
135
|
+
declare function alphaMask(bmp: Bitmap): Uint8Array;
|
|
136
|
+
/** Returns the share of pixels inside the marks' joint ink box that differ by more than 24 in any channel (both on white). */
|
|
137
|
+
declare function pixelDiff(a: Bitmap, b: Bitmap): number;
|
|
138
|
+
/** Returns the width and height stored in a PNG header. */
|
|
139
|
+
declare function pngSize(png: Uint8Array): {
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
interface MarkSvgOptions {
|
|
145
|
+
label: string;
|
|
146
|
+
size?: number;
|
|
147
|
+
style?: string;
|
|
148
|
+
overlay?: string;
|
|
149
|
+
drawLayers?: ReadonlySet<string>;
|
|
150
|
+
colourOverride?: string;
|
|
151
|
+
}
|
|
152
|
+
/** Returns a standalone SVG of the mark in one mode, with optional motion style and overlay. */
|
|
153
|
+
declare function markSvg(mark: Mark, palette: Palette, mode: Mode, opts: MarkSvgOptions): string;
|
|
154
|
+
|
|
155
|
+
interface RawLayer {
|
|
156
|
+
name: string;
|
|
157
|
+
d: string;
|
|
158
|
+
role?: string;
|
|
159
|
+
paint?: LayerPaint;
|
|
160
|
+
transform?: string;
|
|
161
|
+
evenOdd?: boolean;
|
|
162
|
+
}
|
|
163
|
+
interface RawBrand {
|
|
164
|
+
name: string;
|
|
165
|
+
slug: string;
|
|
166
|
+
tokens?: string;
|
|
167
|
+
wordmark?: {
|
|
168
|
+
fontFamily: string;
|
|
169
|
+
fontFile?: string;
|
|
170
|
+
};
|
|
171
|
+
mark: {
|
|
172
|
+
viewBox: string;
|
|
173
|
+
layers: RawLayer[];
|
|
174
|
+
};
|
|
175
|
+
palette: {
|
|
176
|
+
light: Record<string, string>;
|
|
177
|
+
dark: Record<string, string>;
|
|
178
|
+
mono?: string;
|
|
179
|
+
};
|
|
180
|
+
motion?: Partial<MotionConfig>;
|
|
181
|
+
generate?: {
|
|
182
|
+
seed: number;
|
|
183
|
+
count: number;
|
|
184
|
+
};
|
|
185
|
+
icons?: Partial<IconStyle>;
|
|
186
|
+
smallMark?: SmallMark;
|
|
187
|
+
}
|
|
188
|
+
/** Returns the brand from a parsed brand.json object, token references resolved to colours. */
|
|
189
|
+
declare function parseBrand(raw: RawBrand, baseDir: string): Brand;
|
|
190
|
+
/** Reads and parses a brand.json file. */
|
|
191
|
+
declare function loadBrand(file: string): Brand;
|
|
192
|
+
|
|
193
|
+
/** Returns a colour for a token reference such as "mooncube.primary" or "mooncube.dark.text"; a "#hex" passes through. */
|
|
194
|
+
declare function resolveToken(ref: string): string;
|
|
195
|
+
|
|
196
|
+
interface Variant {
|
|
197
|
+
id: string;
|
|
198
|
+
recipe: string;
|
|
199
|
+
mark: Mark;
|
|
200
|
+
}
|
|
201
|
+
/** Returns count mark variants built from primitives and combinators; the same seed gives the same marks. */
|
|
202
|
+
declare function generateVariants(seed: number, count: number): Variant[];
|
|
203
|
+
/** Returns a mark made of one primitive at full size. */
|
|
204
|
+
declare function primitiveMark(name: string): Mark;
|
|
205
|
+
|
|
206
|
+
type Polys = Pt[][];
|
|
207
|
+
/** Shape builders in a unit frame (about -1..1), one entry per primitive; multi-part shapes return one polygon per part. */
|
|
208
|
+
declare const PRIMITIVES: Readonly<Record<string, () => Polys>>;
|
|
209
|
+
|
|
210
|
+
interface CheckResult {
|
|
211
|
+
pass: boolean;
|
|
212
|
+
reasons: string[];
|
|
213
|
+
}
|
|
214
|
+
/** Runs every check on a mark in a palette: 16/32 px, one colour, reversed, contrast, colour-blind and symbol lookalike. */
|
|
215
|
+
declare function runChecks(mark: Mark, palette: Palette): CheckResult;
|
|
216
|
+
interface ChecksReport {
|
|
217
|
+
seed: number;
|
|
218
|
+
count: number;
|
|
219
|
+
passed: string[];
|
|
220
|
+
dropped: {
|
|
221
|
+
id: string;
|
|
222
|
+
recipe: string;
|
|
223
|
+
reasons: string[];
|
|
224
|
+
}[];
|
|
225
|
+
}
|
|
226
|
+
/** Returns the checks report for generated variants: passing ids, and each dropped id with its reasons. */
|
|
227
|
+
declare function checkVariants(seed: number, variants: readonly {
|
|
228
|
+
id: string;
|
|
229
|
+
recipe: string;
|
|
230
|
+
mark: Mark;
|
|
231
|
+
}[], palette: Palette): ChecksReport;
|
|
232
|
+
|
|
233
|
+
interface SymbolMatch {
|
|
234
|
+
symbol: string;
|
|
235
|
+
score: number;
|
|
236
|
+
}
|
|
237
|
+
declare const LOOKALIKE_THRESHOLD = 0.7;
|
|
238
|
+
/** Returns how much the mark resembles each sensitive symbol (0..1), highest first. */
|
|
239
|
+
declare function symbolScores(mark: Mark): SymbolMatch[];
|
|
240
|
+
/** Returns the sensitive symbols the mark resembles at or over the lookalike threshold. */
|
|
241
|
+
declare function symbolMatches(mark: Mark): SymbolMatch[];
|
|
242
|
+
|
|
243
|
+
interface SensitiveSymbol {
|
|
244
|
+
id: string;
|
|
245
|
+
label: string;
|
|
246
|
+
silhouettes: string[];
|
|
247
|
+
}
|
|
248
|
+
/** The sensitive religious, political and protected symbols a mark must not resemble (silhouettes in a 100 x 100 box). */
|
|
249
|
+
declare const SYMBOLS: readonly SensitiveSymbol[];
|
|
250
|
+
|
|
251
|
+
/** Returns up to count palettes from a design-tokens preset, each passing contrast and colour-blind checks for the mark. */
|
|
252
|
+
declare function paletteVariants(mark: Mark, tokensId: string, count?: number): Palette[];
|
|
253
|
+
/** Returns the default two-role palette of a preset for generated marks (roles "a" and "b"). */
|
|
254
|
+
declare function generatorPalette(tokensId: string): Palette;
|
|
255
|
+
|
|
256
|
+
declare const INTRO_CAP_MS = 1200;
|
|
257
|
+
declare const MICRO_CAP_MS = 300;
|
|
258
|
+
/** Default beat for each preset, timed so a four-layer mark stays inside the intro and micro caps. */
|
|
259
|
+
declare const PRESET_DEFAULTS: Readonly<Partial<Record<MotionPreset, MotionBeat>>>;
|
|
260
|
+
|
|
261
|
+
interface Slot {
|
|
262
|
+
target: string;
|
|
263
|
+
delayMs: number;
|
|
264
|
+
durationMs: number;
|
|
265
|
+
}
|
|
266
|
+
/** Returns when each target of a beat starts and how long it runs: delay plus one step per target. */
|
|
267
|
+
declare function schedule(beat: MotionBeat, layerNames: readonly string[]): Slot[];
|
|
268
|
+
/** Returns when the last target of all beats ends. */
|
|
269
|
+
declare function totalMs(beats: readonly MotionBeat[], layerNames: readonly string[]): number;
|
|
270
|
+
/** Returns the beat with its step shortened so n targets end inside the cap. */
|
|
271
|
+
declare function fitBeat(beat: MotionBeat, n: number, capMs: number): MotionBeat;
|
|
272
|
+
interface MotionReport {
|
|
273
|
+
introMs: number;
|
|
274
|
+
microMs: number;
|
|
275
|
+
errors: string[];
|
|
276
|
+
warnings: string[];
|
|
277
|
+
}
|
|
278
|
+
/** Checks a motion config: known presets, intro <= 1200 ms (or a named reason), micro <= 300 ms, no morph clash. */
|
|
279
|
+
declare function validateMotion(config: MotionConfig, layerNames: readonly string[]): MotionReport;
|
|
280
|
+
|
|
281
|
+
interface MotionSvgOptions {
|
|
282
|
+
label: string;
|
|
283
|
+
size?: number;
|
|
284
|
+
}
|
|
285
|
+
/** Returns the mark with its intro motion; with reduced motion, or in a static renderer, it shows the final still. */
|
|
286
|
+
declare function introSvg(mark: Mark, palette: Palette, mode: Mode, beats: readonly MotionBeat[], opts: MotionSvgOptions): string;
|
|
287
|
+
/** Returns the mark with its hover micro-interaction. */
|
|
288
|
+
declare function microSvg(mark: Mark, palette: Palette, mode: Mode, beats: readonly MotionBeat[], opts: MotionSvgOptions): string;
|
|
289
|
+
/** Returns the mark with the intro and the hover micro together. */
|
|
290
|
+
declare function animatedSvg(mark: Mark, palette: Palette, mode: Mode, motion: {
|
|
291
|
+
intro: readonly MotionBeat[];
|
|
292
|
+
micro: readonly MotionBeat[];
|
|
293
|
+
}, opts: MotionSvgOptions): string;
|
|
294
|
+
|
|
295
|
+
interface StopTiming {
|
|
296
|
+
at: number;
|
|
297
|
+
opacity: number | null;
|
|
298
|
+
easing: string | null;
|
|
299
|
+
}
|
|
300
|
+
interface AnimationTiming {
|
|
301
|
+
durationMs: number;
|
|
302
|
+
delayMs: number;
|
|
303
|
+
stops: StopTiming[];
|
|
304
|
+
}
|
|
305
|
+
type TimingMap = Record<string, AnimationTiming[]>;
|
|
306
|
+
/** Returns each animated target's animations (duration, delay, keyframe stops) read from an SVG's style. */
|
|
307
|
+
declare function parseTiming(svg: string): TimingMap;
|
|
308
|
+
|
|
309
|
+
interface ExportedFile {
|
|
310
|
+
file: string;
|
|
311
|
+
width: number;
|
|
312
|
+
height: number;
|
|
313
|
+
}
|
|
314
|
+
/** Writes every asset of a brand into outDir and returns each file with its real pixel size; throws on a motion error. */
|
|
315
|
+
declare function exportBrand(brand: Brand, outDir: string): ExportedFile[];
|
|
316
|
+
|
|
317
|
+
/** Returns a brand-package markGeometry.ts: the viewBox, each layer's path by name, and transforms when any layer has one. */
|
|
318
|
+
declare function geometryModule(mark: Mark): string;
|
|
319
|
+
|
|
320
|
+
declare const TARGET_BOX: {
|
|
321
|
+
x: number;
|
|
322
|
+
y: number;
|
|
323
|
+
w: number;
|
|
324
|
+
h: number;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
interface PickOption {
|
|
328
|
+
name: string;
|
|
329
|
+
why: string;
|
|
330
|
+
image: string;
|
|
331
|
+
inventory: string;
|
|
332
|
+
aligned: string;
|
|
333
|
+
targetBox?: typeof TARGET_BOX;
|
|
334
|
+
motion?: string;
|
|
335
|
+
}
|
|
336
|
+
interface PickStep {
|
|
337
|
+
screen: string;
|
|
338
|
+
viewport: string;
|
|
339
|
+
target: string;
|
|
340
|
+
title: string;
|
|
341
|
+
question: string;
|
|
342
|
+
kind?: string;
|
|
343
|
+
options: PickOption[];
|
|
344
|
+
}
|
|
345
|
+
interface PickSpec {
|
|
346
|
+
docKey: string;
|
|
347
|
+
title: string;
|
|
348
|
+
brand: string;
|
|
349
|
+
intro: string;
|
|
350
|
+
beforeAfter: string;
|
|
351
|
+
noloss: string;
|
|
352
|
+
steps: PickStep[];
|
|
353
|
+
}
|
|
354
|
+
/** Writes the frames and spec.json of a three-step pick (shape, then colour, then motion) and returns the spec. */
|
|
355
|
+
declare function buildPickSpec(brand: Brand, outDir: string): PickSpec;
|
|
356
|
+
/** Builds the pick page with the house builder (build-pick-page.mjs) from a written spec. */
|
|
357
|
+
declare function buildPickPage(builder: string, outDir: string): string;
|
|
358
|
+
|
|
359
|
+
type Out = (line: string) => void;
|
|
360
|
+
/** Runs the logo-kit command line and returns its exit code. */
|
|
361
|
+
declare function runCli(args: readonly string[], out?: Out): number;
|
|
362
|
+
|
|
363
|
+
export { type AnimationTiming, type Bitmap, type Brand, CVD_KINDS, type CheckResult, type ChecksReport, CvdKind, type ExportedFile, INTRO_CAP_MS, INTRO_PRESETS, LOOKALIKE_THRESHOLD, type LayerPaint, MICRO_CAP_MS, MICRO_PRESETS, MODES, type Mark, type MarkLayer, Mode, type MotionBeat, type MotionConfig, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, type PaintItem, type Palette, type PickSpec, type Pt, SYMBOLS, type TimingMap, type Variant, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introSvg, loadBrand, markSvg, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
|