@svgsketch/cli 0.6.1 → 0.7.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/README.md CHANGED
@@ -71,8 +71,85 @@ An encrypted file opens with `--password`, or without it when its password only
71
71
  Transcoder diagnostics print to stderr as `severity: pdf:code: message` and `severity: illustrator:code: message` lines beside the ingest diagnostics.
72
72
  `--fail-on-warnings` counts them along with the ingest warnings.
73
73
 
74
+ ## Inspect, recolor, and tokenize
75
+
76
+ These commands accept SVG, `.svgs`, Illustrator, PDF, and EPS through the same importer as `convert`.
77
+ Recoloring and token conversion are free features.
78
+
79
+ ```bash
80
+ svgsketch colors poster.svg --json --report colors.json
81
+ svgsketch recolor poster.svg -o teal.svg --replace '#2563eb=#0f766e'
82
+ svgsketch recolor design.svgs -o edited.svgs --replace-token brand='#0f766e'
83
+ svgsketch recolor design.svgs --select SHAPE_ID --hue-shift 30 --dry-run --json
84
+ svgsketch tokenize poster.svg -o tokens.svgs --prefix poster
85
+ svgsketch tokenize poster.svg -o tokens.svg --prefix poster --color-output compatible
86
+ ```
87
+
88
+ `colors` lists groups, token identities, native locations, eligibility, exclusions, and outside consumers.
89
+ `--replace` addresses an absolute literal-color group, independently of token groups with the same color.
90
+ `--replace-token` addresses a case-sensitive document token name without `--`.
91
+ Both preserve each source occurrence's alpha.
92
+ Transforms run before explicit replacements, followed by optional token conversion.
93
+
94
+ Repeat `--select` to restrict the request to native IDs from the inventory.
95
+ Document edits default to `--sharing shared`; selection edits default to `--sharing fork`.
96
+ Reference closure discovers dependencies without granting permission to edit outside the selection.
97
+ Use `--sharing shared` deliberately when outside consumers should change too.
98
+
99
+ | Option | Behavior |
100
+ | --------------------------------------------------------- | ----------------------------------------------------------------------------- |
101
+ | `--grouping exact\|similar`, `--jnd 0.5..10` | Exact by default; Similar defaults to 1 JND (deltaEOK 0.02). |
102
+ | `--hue-shift`, `--chroma-scale`, `--lightness-shift` | Existing OKLCH adjustments, taking finite numbers. |
103
+ | `--grayscale`, `--invert-lightness` | Existing core color transforms. |
104
+ | `--notation preserve\|hex\|oklch`, `--gamut source\|srgb` | Preserve source notation and gamut by default. |
105
+ | `--include REASON` | Explicitly include a supported soft exclusion; never bypasses core preflight. |
106
+ | `tokenize --prefix NAME`, `--no-reuse` | Shared token naming and equivalent-definition reuse rules. |
107
+ | `--dry-run`, `--json`, `--report PATH` | Preflight without writing artwork, or produce a versioned machine report. |
108
+ | `--fail-on-warnings` | For these new mutation commands, fail before writing artwork. |
109
+ | `--color-output authored\|compatible\|resolved` | Shared SVG output conversion; default authored. |
110
+
111
+ Mutation commands require `-o` unless using `--dry-run`.
112
+ Output must be `.svgs` or `.svg`, must differ from input/report/recipe files, and is written atomically after preflight.
113
+ Native output retains token IDs and metadata; SVG retains the supported recoverable token declarations and generated fallbacks.
114
+ Invalid requests, stale recipes, refusals, and strict-warning failures leave existing artwork output untouched.
115
+ Diagnostics use stderr, keeping `--json` stdout parseable.
116
+ Machine reports describe inventory, allocations, impact, and diagnostics; they are not executable serialized plans.
117
+ The `changed` field describes the planned snapshot difference, while `written` reports whether artwork was written and `warningsAsFailure` identifies strict-warning rejection.
118
+
119
+ Advanced requests use `--request recipe.json`, exclusively with respect to recolor behavior flags.
120
+ The version-1 recipe has `version`, optional `sourceFingerprint`, `inventoryOptions`, and `request`.
121
+ The request accepts the serializable core `RecolorRequest` fields, with replacement colors written as strings.
122
+ Inventory options accept `scope`, `grouping`, and the existing concrete analysis `colorScheme`.
123
+ Group-addressed replacements or conversion names/group IDs require the fingerprint from `colors --json` for the same input and inventory options.
124
+ A supplied fingerprint must always match.
125
+ Re-inspect changed artwork instead of moving old group choices onto new groups.
126
+
127
+ ```json
128
+ {
129
+ "version": 1,
130
+ "inventoryOptions": {},
131
+ "request": { "transform": { "hueShift": 30 } }
132
+ }
133
+ ```
134
+
135
+ Scripts, raster pixels, masks, opaque data, uncertain consumers, and unsupported sources retain the core exclusions and refusals.
136
+ Authored CSS remains authored when its effect cannot be proved.
137
+ Tokens retain one default value; a separate light/dark token system is deferred.
138
+
74
139
  ## Render diagnostics
75
140
 
141
+ `render` and `convert` accept `--color-output authored|compatible|resolved`, defaulting to `authored`.
142
+ Authored SVG retains themeable tokens with derived use-site fallbacks.
143
+ Compatible output adds legacy sRGB floors while retaining variable expressions.
144
+ Resolved output bakes supported static colors for consumers that do not evaluate CSS variables.
145
+ Uncertain and animated sites remain authored with their dependencies and warnings; imports are never fetched.
146
+ Overrides share core name/type validation, and invalid overrides leave an existing output file unchanged.
147
+
148
+ ```bash
149
+ svgsketch render design.svgs -o portable.svg --color-output compatible
150
+ svgsketch render design.svgs -o static.svg --color-output resolved --var brand=#2255cc
151
+ ```
152
+
76
153
  `import`, `convert`, `render`, and `codegen` report machine-readable diagnostics as `warning:` / `error:` lines on stderr.
77
154
  Import diagnostics also include their stable diagnostic code.
78
155
  Malformed SVG never produces a partial `.svgs` file.
package/dist/index.d.ts CHANGED
@@ -1 +1,28 @@
1
1
  #!/usr/bin/env node
2
+ import { HistorySnapshot, IngestDiagnostic, ForeignImportReport } from '@svgsketch/core';
3
+
4
+ type ArtboardSelection = 'all' | number[];
5
+ declare const TEXT_MODES: readonly ["editable", "outline"];
6
+ declare const HIDDEN_LAYER_MODES: readonly ["import", "skip"];
7
+ interface ForeignImportOptions {
8
+ artboards?: ArtboardSelection;
9
+ text?: (typeof TEXT_MODES)[number];
10
+ hiddenLayers?: (typeof HIDDEN_LAYER_MODES)[number];
11
+ password?: string;
12
+ }
13
+ interface LoadedDocument {
14
+ snapshot: HistorySnapshot;
15
+ /** Every diagnostic the load produced, already printed to stderr. */
16
+ diagnostics: readonly IngestDiagnostic[];
17
+ producerDiagnostics?: readonly {
18
+ readonly code: string;
19
+ readonly message: string;
20
+ readonly severity: string;
21
+ }[];
22
+ /** Warnings counted for `--fail-on-warnings`, including transcoder warnings. */
23
+ warningCount: number;
24
+ /** Set when the input was an Illustrator or PDF document. */
25
+ report: ForeignImportReport | null;
26
+ }
27
+
28
+ export type { ForeignImportOptions, LoadedDocument };