@weasel-js/theme 1.5.2 → 1.6.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/README.md +39 -1
- package/dist/{chunk-XFCWYN2L.js → chunk-4EIPTWJA.js} +914 -60
- package/dist/chunk-4EIPTWJA.js.map +1 -0
- package/dist/chunk-C3S4A65R.js +557 -0
- package/dist/chunk-C3S4A65R.js.map +1 -0
- package/dist/chunk-EINHFDWI.js +12 -0
- package/dist/chunk-EINHFDWI.js.map +1 -0
- package/dist/colorMode-CoklZomJ.d.ts +12 -0
- package/dist/{resolveTheme-CF8i5IHy.d.ts → definition-DLdTdFWs.d.ts} +584 -51
- package/dist/engine.d.ts +76 -8
- package/dist/engine.js +183 -427
- package/dist/engine.js.map +1 -1
- package/dist/faces.css +19 -0
- package/dist/fonts.css +4 -18
- package/dist/index.d.ts +49 -5
- package/dist/index.js +172 -20
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +50 -6
- package/dist/react.js +68 -6
- package/dist/react.js.map +1 -1
- package/dist/tokens.css +103 -1
- package/fonts/README.md +5 -6
- package/package.json +4 -3
- package/dist/chunk-LL2ERJPZ.js +0 -175
- package/dist/chunk-LL2ERJPZ.js.map +0 -1
- package/dist/chunk-PJMTWM34.js +0 -6
- package/dist/chunk-PJMTWM34.js.map +0 -1
- package/dist/chunk-XFCWYN2L.js.map +0 -1
- package/dist/theme-DAZcQi_L.d.ts +0 -191
package/dist/engine.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OklchDeg, oklchDegToHex } from '@weasel-js/paint';
|
|
2
|
-
import {
|
|
3
|
-
export { C as CategoricalRampDef,
|
|
2
|
+
import { T as ThemeDefinition, L as Lookup, F as FlatTokens, R as RawToken, S as Selection, B as BakedTheme, A as AxisDefs, a as Theme } from './definition-DLdTdFWs.js';
|
|
3
|
+
export { C as CategoricalRampDef, b as ContrastRule, c as LightnessRampDef, d as LiteralRule, N as NumberParam, O as OffsetRule, P as PinObject, e as PinValue, f as RampDef, g as RefRule, h as ScaleDef, i as SemanticRule, j as StepRule, k as bake, l as bakeChain, m as mergeChain } from './definition-DLdTdFWs.js';
|
|
4
4
|
|
|
5
5
|
/** A color in OKLCH: lightness 0–1, chroma, hue in degrees. paint's own type,
|
|
6
6
|
* under the name this engine has always called it. */
|
|
@@ -218,6 +218,10 @@ interface LightnessParams {
|
|
|
218
218
|
/**
|
|
219
219
|
* Step name → hex. Lightness walks from `lightness[0]` to `lightness[1]`, `curve` blending an even walk toward a
|
|
220
220
|
* smoothstep; chroma is `peak` scaled by the envelope `sin(πt) + lightBias·(1−t) + darkBias·t` normalized to a maximum of 1.
|
|
221
|
+
*
|
|
222
|
+
* An anchored step emits its anchor exactly, and the anchor replaces `hue` and `peak`: its OKLCH hue becomes the hue and
|
|
223
|
+
* its chroma becomes the peak, unscaled by the envelope. With several anchors, both blend linearly by step between
|
|
224
|
+
* consecutive anchors, hue along the shorter arc; steps before the first anchor or after the last take that anchor's.
|
|
221
225
|
*/
|
|
222
226
|
declare function lightnessRamp(p: LightnessParams): Record<string, string>;
|
|
223
227
|
declare function categoricalRamp(steps: readonly string[], gates: Partial<Constraints>, anchors: readonly Anchor[]): {
|
|
@@ -243,6 +247,28 @@ interface EmitInput {
|
|
|
243
247
|
declare function cssValue(name: string, token: RawToken): string;
|
|
244
248
|
declare function emitCss(themes: readonly EmitInput[]): string;
|
|
245
249
|
|
|
250
|
+
/** The `$extensions` key on a DTCG export's root that carries every axis besides mode. */
|
|
251
|
+
declare const AXES_EXT = "com.weasel.axes";
|
|
252
|
+
/** The token groups of one layer: plain values, and values per mode. */
|
|
253
|
+
interface DtcgLayer {
|
|
254
|
+
readonly primitives: Record<string, Record<string, unknown>>;
|
|
255
|
+
readonly modes: Record<string, Record<string, Record<string, unknown>>>;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* What `toDTCG` writes under `$extensions["com.weasel.axes"]`.
|
|
259
|
+
*
|
|
260
|
+
* - `axes`: every axis the theme resolves with, mode included.
|
|
261
|
+
* - `varies`: token name → the non-mode axes its value depends on.
|
|
262
|
+
* - `overrides`: a layer per combination of non-default values, keyed like
|
|
263
|
+
* `selectionKey` but naming only the axes off their default
|
|
264
|
+
* (`density=compact`, `contrast=high,density=roomy` in axis order).
|
|
265
|
+
*/
|
|
266
|
+
interface DtcgAxesExtension {
|
|
267
|
+
readonly axes: AxisDefs;
|
|
268
|
+
readonly varies: Record<string, readonly string[]>;
|
|
269
|
+
readonly overrides: Record<string, DtcgLayer>;
|
|
270
|
+
}
|
|
271
|
+
|
|
246
272
|
type Group = Record<string, unknown> & {
|
|
247
273
|
$type: string;
|
|
248
274
|
};
|
|
@@ -251,17 +277,21 @@ interface DtcgExport {
|
|
|
251
277
|
readonly defaultMode?: string;
|
|
252
278
|
readonly primitives: Record<string, Group>;
|
|
253
279
|
readonly modes: Record<string, Record<string, Group>>;
|
|
280
|
+
readonly $extensions?: {
|
|
281
|
+
readonly [AXES_EXT]?: DtcgAxesExtension;
|
|
282
|
+
};
|
|
254
283
|
}
|
|
255
284
|
/**
|
|
256
285
|
* A theme's own tokens as a DTCG document `loadDTCG` reads back. `extends` is
|
|
257
286
|
* not carried; pass it to `loadDTCG`. Every mode the chain declares is written,
|
|
258
287
|
* so a token that leaves one out still falls through to the parent on the way back.
|
|
259
288
|
*
|
|
260
|
-
* DTCG has one variant dimension
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
289
|
+
* DTCG has one variant dimension, so the plain groups hold mode, with every
|
|
290
|
+
* other axis at its default value: what a tool that ignores extensions reads.
|
|
291
|
+
* The other values travel under `$extensions["com.weasel.axes"]` (see
|
|
292
|
+
* `DtcgAxesExtension`), one override layer per combination of non-default values
|
|
293
|
+
* some token actually varies by — axes that vary independently cost one layer
|
|
294
|
+
* per value, not their cross-product.
|
|
265
295
|
*/
|
|
266
296
|
declare function toDTCG(theme: Theme): DtcgExport;
|
|
267
297
|
|
|
@@ -290,4 +320,42 @@ type GeneratedTokens = {
|
|
|
290
320
|
/** Every generated token file for a set of definitions, the one that extends nothing being the default. Any derive issue refuses the whole set. */
|
|
291
321
|
declare function generateTokens(definitions: readonly ThemeDefinition[]): GeneratedTokens;
|
|
292
322
|
|
|
293
|
-
|
|
323
|
+
/** A theme definition file as a theme store serves it: the dev-server endpoint at `__theme/<name>`. */
|
|
324
|
+
interface StoredTheme {
|
|
325
|
+
readonly name: string;
|
|
326
|
+
/** sha-256 of the file's bytes: what a save sends back to prove it saw the file as it is. */
|
|
327
|
+
readonly hash: string;
|
|
328
|
+
/** Saving it regenerates `packages/theme/src/generated/`. */
|
|
329
|
+
readonly emits: boolean;
|
|
330
|
+
readonly definition: ThemeDefinition;
|
|
331
|
+
}
|
|
332
|
+
interface IssueReport {
|
|
333
|
+
readonly selection: Selection;
|
|
334
|
+
readonly issue: Issue;
|
|
335
|
+
}
|
|
336
|
+
type PutResult = {
|
|
337
|
+
readonly status: 'saved';
|
|
338
|
+
readonly hash: string;
|
|
339
|
+
readonly issues: readonly IssueReport[];
|
|
340
|
+
readonly regenerated: boolean;
|
|
341
|
+
/** Why the generated files were left alone, when the definition emits and they were. */
|
|
342
|
+
readonly problems: readonly string[];
|
|
343
|
+
} | {
|
|
344
|
+
readonly status: 'conflict';
|
|
345
|
+
readonly hash: string | null;
|
|
346
|
+
} | {
|
|
347
|
+
readonly status: 'invalid';
|
|
348
|
+
readonly message: string;
|
|
349
|
+
};
|
|
350
|
+
/** Record order is emission order, so keys are never sorted. */
|
|
351
|
+
declare const serializeDefinition: (definition: ThemeDefinition) => string;
|
|
352
|
+
interface ThemeApi {
|
|
353
|
+
list(): Promise<StoredTheme[]>;
|
|
354
|
+
get(name: string): Promise<StoredTheme>;
|
|
355
|
+
put(name: string, definition: ThemeDefinition, baseHash: string | null): Promise<PutResult>;
|
|
356
|
+
}
|
|
357
|
+
type Fetch = (input: string, init?: RequestInit) => Promise<Response>;
|
|
358
|
+
/** The dev server's theme store, addressed relative to the page so the app's base path carries over. */
|
|
359
|
+
declare function httpThemeApi(base?: string, fetchImpl?: Fetch): ThemeApi;
|
|
360
|
+
|
|
361
|
+
export { type Anchor, type AxisDependency, BakedTheme, CHROMA_WEIGHT, type Constraints, DEFAULT_CONSTRAINTS, type DeriveResult, type DtcgExport, type EmitInput, type GeneratedTokens, type Issue, type IssueReport, type Layer, type Lch, type LightnessParams, Lookup, type Palette, type Provenance, type PutResult, type ScaleParams, type Stats, type StoredTheme, type Swatch, type ThemeApi, ThemeDefinition, type ThemesInput, anchorFromHex, axisDependencies, categoricalRamp, chromaCap, contrast, cssValue, declaredSteps, deltaE, derive, emitCss, emitManifest, emitThemes, floorDegrees, generate, generateTokens, hexToRgb, httpThemeApi, hueGap, hueName, lightnessRamp, luminance, scale, serializeDefinition, toDTCG, toHex, toHexPreview, toLab, toLch, vividAt };
|