@codepress/design-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/src/kit.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ /** Types for `@codepress/design-kit/kit`, the kit tool's functions. */
2
+
3
+ /** One row of `index.json` (stories) or `routes.json` (pages). */
4
+ export interface KitRow {
5
+ id: string;
6
+ kind?: "story" | "route";
7
+ title?: string;
8
+ component?: string;
9
+ file: string;
10
+ width?: number;
11
+ height?: number;
12
+ bytes?: number;
13
+ slots?: string[];
14
+ source_file?: string;
15
+ body_class?: string;
16
+ html_attrs?: Record<string, string>;
17
+ body_attrs?: Record<string, string>;
18
+ }
19
+
20
+ export interface KitManifest {
21
+ kit_version?: number;
22
+ sha?: string;
23
+ built_at?: string;
24
+ [key: string]: unknown;
25
+ }
26
+
27
+ /** A loaded kit: its folder, manifest and rows, sorted and by id. */
28
+ export interface Kit {
29
+ dir: string;
30
+ manifest: KitManifest | null;
31
+ rows: KitRow[];
32
+ byId: Map<string, KitRow>;
33
+ }
34
+
35
+ export function loadKit(dir: string): Kit;
36
+
37
+ /** Rows whose id, title, component or source file holds every word. */
38
+ export function find(kit: Kit, query: string): KitRow[];
39
+
40
+ /** Up to five candidates, closest first. */
41
+ export function nearMatches(wanted: string, candidates: string[]): string[];
42
+
43
+ /** A markup outline of at most `limit` bytes. */
44
+ export function outline(
45
+ html: string,
46
+ limit?: number,
47
+ ): { lines: string[]; truncated: boolean };
48
+
49
+ /**
50
+ * One self-contained page. Throws an Error whose message starts with
51
+ * `unknown ` (and names near matches) for an unknown frame, slot or snippet,
52
+ * and with `too large: ` when snippets grow the page past `maxBytes`.
53
+ */
54
+ export function compose(
55
+ kit: Kit,
56
+ options: {
57
+ frame: string;
58
+ slots?: { name: string; content: string }[];
59
+ theme?: "light" | "dark";
60
+ showNew?: boolean;
61
+ /** Bytes of markup the page may grow to through snippets. */
62
+ maxBytes?: number;
63
+ },
64
+ ): string;
65
+
66
+ /** The default `maxBytes` of `compose`: 32 MB. */
67
+ export const COMPOSE_MAX_BYTES: number;
68
+
69
+ export function sanitizeMarkup(html: string): string;
70
+ export function sanitizeCss(css: string): string;
71
+
72
+ /** Runs one command line; returns the exit code. */
73
+ export function run(
74
+ argv: string[],
75
+ io?: { out(text: string): void; err(text: string): void },
76
+ env?: Record<string, string | undefined>,
77
+ defaultDir?: string,
78
+ ): number;
79
+
80
+ /** Whether this file is the script node was started with. */
81
+ export function isMain(moduleUrl?: string, script?: string): boolean;