@unpunnyfuns/swatchbook-blocks 0.54.0 → 0.56.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/dist/index.d.mts +72 -31
- package/dist/index.mjs +243 -168
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _$react from "react";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
import { Axis,
|
|
3
|
+
import { Axis, AxisVarianceResult, Diagnostic, Preset } from "@unpunnyfuns/swatchbook-core";
|
|
4
|
+
import { SlimListedToken } from "@unpunnyfuns/swatchbook-core/snapshot-for-wire";
|
|
4
5
|
|
|
5
6
|
//#region src/format-color.d.ts
|
|
6
7
|
/**
|
|
@@ -65,15 +66,27 @@ declare function formatColor(value: unknown, format: ColorFormat, fallback?: str
|
|
|
65
66
|
* in `packages/addon/src/virtual.d.ts` describe the same payload.
|
|
66
67
|
*/
|
|
67
68
|
type VirtualAxisShape = Axis;
|
|
68
|
-
type VirtualPermutationShape = Permutation;
|
|
69
69
|
type VirtualDiagnosticShape = Diagnostic;
|
|
70
70
|
interface VirtualTokenShape {
|
|
71
|
-
$type?: string;
|
|
71
|
+
$type?: string | undefined;
|
|
72
72
|
$value?: unknown;
|
|
73
|
-
$description?: string;
|
|
74
|
-
aliasOf?: string;
|
|
75
|
-
aliasChain?: readonly string[];
|
|
76
|
-
aliasedBy?: readonly string[];
|
|
73
|
+
$description?: string | undefined;
|
|
74
|
+
aliasOf?: string | undefined;
|
|
75
|
+
aliasChain?: readonly string[] | undefined;
|
|
76
|
+
aliasedBy?: readonly string[] | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Per-sub-field alias map for composite tokens whose value blends
|
|
79
|
+
* primitives with aliased fragments — Terrazzo populates this when
|
|
80
|
+
* one or more component fields of a composite ($type: 'border',
|
|
81
|
+
* 'shadow', 'typography', 'gradient', 'transition') resolve through
|
|
82
|
+
* an alias. The `CompositeBreakdown` block reads it to render the
|
|
83
|
+
* source path beside each component value. Typed as `unknown` because
|
|
84
|
+
* the shape varies per composite type (color carries a
|
|
85
|
+
* `{components: (string | undefined)[]}` sub-shape; typography/border
|
|
86
|
+
* carry a flat `Record<string, string | undefined>`); the block
|
|
87
|
+
* narrows it at the consumer.
|
|
88
|
+
*/
|
|
89
|
+
partialAliasOf?: unknown;
|
|
77
90
|
}
|
|
78
91
|
/**
|
|
79
92
|
* Subset of `@terrazzo/plugin-token-listing`'s `ListedToken` that the
|
|
@@ -81,29 +94,27 @@ interface VirtualTokenShape {
|
|
|
81
94
|
* variable name and `previewValue` for the display-ready CSS string.
|
|
82
95
|
* `source.loc` enables "jump to authoring source" affordances.
|
|
83
96
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
97
|
+
* Aliases `SlimListedToken` from core's `/snapshot-for-wire` subpath —
|
|
98
|
+
* the single canonical wire shape; both the addon's plugin (server-side
|
|
99
|
+
* emit) and blocks (consumer-side read) reference the same definition.
|
|
86
100
|
*/
|
|
87
|
-
|
|
88
|
-
names: Record<string, string>;
|
|
89
|
-
previewValue?: string | number;
|
|
90
|
-
source?: {
|
|
91
|
-
resource: string;
|
|
92
|
-
loc?: {
|
|
93
|
-
start: {
|
|
94
|
-
line: number;
|
|
95
|
-
column: number;
|
|
96
|
-
offset: number;
|
|
97
|
-
};
|
|
98
|
-
end: {
|
|
99
|
-
line: number;
|
|
100
|
-
column: number;
|
|
101
|
-
offset: number;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
}
|
|
101
|
+
type VirtualTokenListingShape = SlimListedToken;
|
|
106
102
|
type VirtualPresetShape = Preset;
|
|
103
|
+
/**
|
|
104
|
+
* Wire shape of one `Project.jointOverrides` entry — same as core's
|
|
105
|
+
* `JointOverride` but with the block's `VirtualTokenShape` for the
|
|
106
|
+
* token values that ship over the wire.
|
|
107
|
+
*/
|
|
108
|
+
interface VirtualJointOverrideShape {
|
|
109
|
+
axes: Record<string, string>;
|
|
110
|
+
tokens: Record<string, VirtualTokenShape>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Map from path → cached `AxisVarianceResult`. Snapshot carries this
|
|
114
|
+
* so the `AxisVariance` block can O(1) look up which axes affect a
|
|
115
|
+
* token instead of re-running variance analysis on every render.
|
|
116
|
+
*/
|
|
117
|
+
type VirtualVarianceByPathShape = Record<string, AxisVarianceResult>;
|
|
107
118
|
/**
|
|
108
119
|
* Full project data read by blocks. Populated by the addon's preview
|
|
109
120
|
* decorator (from the virtual module) or constructed by hand in
|
|
@@ -114,8 +125,6 @@ interface ProjectSnapshot {
|
|
|
114
125
|
/** Axis names suppressed via `config.disabledAxes` — pinned to their defaults, hidden from the toolbar. */
|
|
115
126
|
disabledAxes: readonly string[];
|
|
116
127
|
presets: readonly VirtualPresetShape[];
|
|
117
|
-
permutations: readonly VirtualPermutationShape[];
|
|
118
|
-
permutationsResolved: Record<string, Record<string, VirtualTokenShape>>;
|
|
119
128
|
activePermutation: string;
|
|
120
129
|
activeAxes: Readonly<Record<string, string>>;
|
|
121
130
|
cssVarPrefix: string;
|
|
@@ -129,6 +138,38 @@ interface ProjectSnapshot {
|
|
|
129
138
|
* absent.
|
|
130
139
|
*/
|
|
131
140
|
listing?: Readonly<Record<string, VirtualTokenListingShape>>;
|
|
141
|
+
/**
|
|
142
|
+
* Per-axis cell maps — `cells[axis][context]` is the resolved token
|
|
143
|
+
* data for `{ ...defaults, [axis]: context }`. Bounded by
|
|
144
|
+
* `Σ(axes × contexts)` regardless of cartesian product size.
|
|
145
|
+
* Non-default cells store only the tokens whose value differs from
|
|
146
|
+
* the default-cell baseline (delta cells).
|
|
147
|
+
*/
|
|
148
|
+
cells: Record<string, Record<string, Record<string, VirtualTokenShape>>>;
|
|
149
|
+
/**
|
|
150
|
+
* `Project.jointOverrides` flattened to entries for wire transport.
|
|
151
|
+
* Same ascending-arity iteration order the Map carries on the
|
|
152
|
+
* server side. Empty array when no joint divergences exist.
|
|
153
|
+
*/
|
|
154
|
+
jointOverrides: readonly (readonly [string, VirtualJointOverrideShape])[];
|
|
155
|
+
/**
|
|
156
|
+
* Cached per-path variance results. Blocks read this for O(1) axis
|
|
157
|
+
* variance lookup instead of recomputing on each render.
|
|
158
|
+
*/
|
|
159
|
+
varianceByPath?: VirtualVarianceByPathShape;
|
|
160
|
+
/** The default tuple — `{ axis: axis.default }` for every axis. */
|
|
161
|
+
defaultTuple: Record<string, string>;
|
|
162
|
+
/**
|
|
163
|
+
* Pre-built `resolveAt(tuple)` accessor. The addon's preview
|
|
164
|
+
* decorator instantiates this once per iframe lifetime — the
|
|
165
|
+
* underlying virtual-module exports (cells, jointOverrides, axes,
|
|
166
|
+
* defaultTuple) are stable, so a single resolver instance with
|
|
167
|
+
* internal per-tuple memoization is correct and avoids the
|
|
168
|
+
* per-render rebuild dance the blocks side used to do. Hand-built
|
|
169
|
+
* snapshots (tests, MDX) can omit this; blocks fall back to
|
|
170
|
+
* building locally from `cells` / `permutationsResolved`.
|
|
171
|
+
*/
|
|
172
|
+
resolveAt?: (tuple: Record<string, string>) => Record<string, VirtualTokenShape>;
|
|
132
173
|
}
|
|
133
174
|
/**
|
|
134
175
|
* Context carrying the full {@link ProjectSnapshot}. `null` sentinel lets
|
|
@@ -842,5 +883,5 @@ declare function TypographyScale({
|
|
|
842
883
|
sortDir
|
|
843
884
|
}: TypographyScaleProps): ReactElement;
|
|
844
885
|
//#endregion
|
|
845
|
-
export { AliasChain, type AliasChainProps, AliasedBy, type AliasedByProps, AxesContext, AxisVariance, type AxisVarianceProps, BorderPreview, type BorderPreviewProps, BorderSample, type BorderSampleProps, COLOR_FORMATS, type ColorFormat, ColorFormatContext, ColorPalette, type ColorPaletteProps, ColorTable, type ColorTableProps, CompositeBreakdown, type CompositeBreakdownProps, CompositePreview, type CompositePreviewProps, ConsumerOutput, type ConsumerOutputProps, Diagnostics, type DiagnosticsProps, DimensionBar, type DimensionBarProps, type DimensionKind, DimensionScale, type DimensionScaleProps, FontFamilySample, type FontFamilySampleProps, FontWeightScale, type FontWeightScaleProps, type FormatColorResult, GradientPalette, type GradientPaletteProps, MotionPreview, type MotionPreviewProps, MotionSample, type MotionSampleProps, type MotionSpeed, type NormalizedColor, OpacityScale, type OpacityScaleProps, PermutationContext, type ProjectSnapshot, ShadowPreview, type ShadowPreviewProps, ShadowSample, type ShadowSampleProps, StrokeStyleSample, type StrokeStyleSampleProps, SwatchbookContext, SwatchbookProvider, type SwatchbookProviderProps, TokenDetail, type TokenDetailProps, TokenHeader, type TokenHeaderProps, TokenNavigator, type TokenNavigatorProps, TokenTable, type TokenTableProps, TokenUsageSnippet, type TokenUsageSnippetProps, TypographyScale, type TypographyScaleProps, type VirtualAxisShape as VirtualAxis, type VirtualAxisShape, type VirtualDiagnosticShape as VirtualDiagnostic, type VirtualDiagnosticShape, type
|
|
886
|
+
export { AliasChain, type AliasChainProps, AliasedBy, type AliasedByProps, AxesContext, AxisVariance, type AxisVarianceProps, BorderPreview, type BorderPreviewProps, BorderSample, type BorderSampleProps, COLOR_FORMATS, type ColorFormat, ColorFormatContext, ColorPalette, type ColorPaletteProps, ColorTable, type ColorTableProps, CompositeBreakdown, type CompositeBreakdownProps, CompositePreview, type CompositePreviewProps, ConsumerOutput, type ConsumerOutputProps, Diagnostics, type DiagnosticsProps, DimensionBar, type DimensionBarProps, type DimensionKind, DimensionScale, type DimensionScaleProps, FontFamilySample, type FontFamilySampleProps, FontWeightScale, type FontWeightScaleProps, type FormatColorResult, GradientPalette, type GradientPaletteProps, MotionPreview, type MotionPreviewProps, MotionSample, type MotionSampleProps, type MotionSpeed, type NormalizedColor, OpacityScale, type OpacityScaleProps, PermutationContext, type ProjectSnapshot, ShadowPreview, type ShadowPreviewProps, ShadowSample, type ShadowSampleProps, StrokeStyleSample, type StrokeStyleSampleProps, SwatchbookContext, SwatchbookProvider, type SwatchbookProviderProps, TokenDetail, type TokenDetailProps, TokenHeader, type TokenHeaderProps, TokenNavigator, type TokenNavigatorProps, TokenTable, type TokenTableProps, TokenUsageSnippet, type TokenUsageSnippetProps, TypographyScale, type TypographyScaleProps, type VirtualAxisShape as VirtualAxis, type VirtualAxisShape, type VirtualDiagnosticShape as VirtualDiagnostic, type VirtualDiagnosticShape, type VirtualPresetShape as VirtualPreset, type VirtualPresetShape, type VirtualTokenShape as VirtualToken, type VirtualTokenShape, type VirtualTokenListingShape, formatColor, useActiveAxes, useActivePermutation, useColorFormat, useOptionalSwatchbookData, useSwatchbookData };
|
|
846
887
|
//# sourceMappingURL=index.d.mts.map
|