@yahoo/uds-create-config 2.15.0 → 2.17.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.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/native/NativeConfig.d.ts +6 -5
- package/dist/native/NativeConfig.js +5 -1
- package/dist/native/index.d.ts +4 -3
- package/dist/native/index.js +1 -0
- package/dist/native/modes.d.ts +10 -0
- package/dist/native/modes.js +11 -0
- package/dist/native/types.d.ts +26 -3
- package/dist/native/validation.d.ts +1 -1
- package/dist/native/validation.js +132 -39
- package/dist/native.d.ts +4 -4
- package/dist/native.js +1 -1
- package/dist/token-override-rows.d.ts +3 -1
- package/dist/token-override-rows.js +14 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { ELEMENT_MARKER_KIND, ElementMarker, OpaqueLeafPredicate, hasElementMark
|
|
|
33
33
|
import { collectFontFaceCss, deriveFontFaceCss, familiesInRawCss } from "./font-face.js";
|
|
34
34
|
import { interpolate } from "./interpolate.js";
|
|
35
35
|
import { resolveRegistryDir } from "./registry-dir.js";
|
|
36
|
-
import { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue } from "./token-override-rows.js";
|
|
36
|
+
import { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, ModifierTree, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRow, resolveOverrideRowValue } from "./token-override-rows.js";
|
|
37
37
|
import { rem } from "./units.js";
|
|
38
38
|
import { EntityKind } from "@yahoo/uds-create-types/entity";
|
|
39
|
-
export { ASSET_CLASS_CAPABILITIES, type AnyRef, type AnyStylePropDefinition, type ArbitrarySpec, AssetGroup, type AssetGroupBuilder, type AssetGroupConfig, type AssetGroupDefinition, type AssetGroupName, type AssetGroupRef, type AssetKind, type AssetName, type AssetRef, type BaseStyles, type BooleanMarker, type BoundComponent, type BuildOptions, CSS_GLOBAL_KEYWORDS, CSS_PROPERTY_KEYWORDS, type CanvasRole, type CanvasRoleEntry, type CanvasRoleEntryInput, type CanvasRolesDefinition, type CanvasRolesDefinitionInput, type CanvasRolesInputConstraint, type ColorCssProperty, type ColorExpression, type ColorFn, type ColorKeyword, type ColorSpace, type ColorValue, Component, type ComponentBuilder, type ComponentBuilderMethods, type ComponentDefinition, ComponentGroup, type ComponentGroupDefinition, type ComponentKind, type ComponentMetadata, type ComponentName, type ComponentRef, type ComponentRenderFn, type CompositeInfo, type CompositeName, type CompositeRef, type CompositeRefBuilder, CompositeStyle, type CompositeStyleDefinition, type CompositeStyleObject, type CompoundPropsEntry, Config, type ConfigCallbackHelpers, type ConfigDiagnostic, type ConfigDiagnosticDefinition, ConfigValidationError, type Css, type CssAngle, type CssClassName, type CssColor, type CssDeclaration, type CssGlobalKeyword, type CssLength, CssMotionDef, type CssMotionDefinition, type CssMotionFields, type CssPercentage, type CssPropertyName, type CssPropertyValues, type CssPropertyWithKeywords, type CssRatio, type CssSelector, type CssSlotMotion, type CssTime, type CssValue, type CssValueTypeName, type CssVar, type CssVarRef, type DataAttrs, type DefineComponentFn, type DefinedComponent, type DefinedMotion, type DefinedProvider, type DefinedStyleProp, type DefinedTokenGroup, type DependenciesQuery, type DependencyKind, type DependencyRef, type DependentsQuery, ELEMENT_MARKER_KIND, type ElementMarker, type EntityKind, type FontAssetGroupConfig, type FontAssetGroupDefinition, type FontAssetMember, type FunctionInfo, type GlobalStylesDef, type GradientStop, type GradientValue, type HexColor, type HslColor, type IconAssetGroupConfig, type IconAssetGroupDefinition, type IconAssetMember, type IconAssetMetadata, JsMotionDef, type JsMotionDefinition, type JsMotionFields, type JsSlotMotion, Layer, type LayerInput, type LayerMarker, type LayerPropsMap, type LengthOrPercent, type LineDirection, type LinearGradientExpr, type LinkedComponentsInput, type LinkedSystemEntry, type LiteralFor, MOTION_CSS_DEFINITION_KEYS, MOTION_CSS_DIRECTIONS, MOTION_CSS_FILL_MODES, MOTION_CSS_PLAY_STATES, MOTION_CSS_PROPERTY_PREFIXES, MOTION_JS_DEFINITION_KEYS, MOTION_JS_DRAG_AXES, MOTION_JS_FIELD_KEYS, MOTION_JS_LAYOUT_MODES, MOTION_JS_REPEAT_TYPES, MOTION_JS_SPRING_FIELDS, MOTION_JS_TRANSITION_TYPES, MOTION_JS_TWEEN_FIELDS, type MixExpr, Mode, type ModeBackedModifierDefinition, type ModeBackedModifierInput, type ModeBackedModifierLookup, type ModeDefinition, type ModeName, ModeOption, type ModeOptionDefinition, type ModeRef, Modifier, type ModifierDefinition, type MotionDef, type MotionDefinitionInput, type MotionDragBox, type MotionKeyframes, type MotionMarker, type MotionMetadata, type MotionName, type MotionState, type MotionStateKeyframe, type MotionTransition, type MotionVariants, type MotionViewportOptions, type NumberMarker, type OpacityPairSpec, type OpaqueLeafPredicate, type OverrideModeRef, type OverrideRow, PREVIEW_SEED_KEY, type PlaygroundOptions, type PlaygroundPage, type PlaygroundSpec, type PreviewAxisMarker, type PreviewCallbackHelpers, type PreviewDefinition, type PreviewPropsRule, type PrimitivePropKind, type PropBase, type PropBinding, type PropInfo, type PropKind, Provider, type RadialGradientExpr, type RadialSize, type RawToken, type RegisteredAssetGroups, type RegisteredComponents, type RegisteredCompositeStyles, type RegisteredModes, type RegisteredModifiers, type RegisteredMotion, type RegisteredStyleProps, type RegisteredTokenGroups, type RequiredBrand, type ResolvedCompoundOverrides, type ResolvedTokenLiteral, type RgbColor, SOURCE_PATH_KEY, type SerializedAssetGroup, type SerializedComponentGroup, type SerializedConfig, type SerializedFontAssetGroup, type SerializedIconAssetGroup, type SerializedPlaygroundOptions, type SerializedTokenGroup, type SlotInfo, type SlotMarker, type SlotMotion, type SlotRef, type SlotValueKind, type SlotValueType, type StringMarker, StyleProp, type StylePropDefinition, type StylePropInfo, type StylePropKeyword, type StylePropMetadata, type StylePropName, type StylePropProperty, type StylePropRef, type StylePropTokenUsage, type SystemLink, type TagName, type TagRef, Token, type TokenDefinition, type TokenDefinitionFor, TokenGroup, type TokenGroupDefinition, type TokenGroupDefinitionFor, type TokenGroupMetadata, type TokenGroupName, type TokenGroupRef, type TokenModifierKey, type TokenModifierValue, type TokenName, type TokenQualifiedName, type TokenRawNameRegistry, type TokenRawValue, type TokenRef, type TokenRefToCss, type TokenType, type TokenValue, type TypedSlotRef, type ValuesEntry, type VariantInfo, type VariantMarker, type VariantMarkerArray, type VariantMarkerObject, alpha, asChild, asset, assetGroup, attachSourcePath, boolean, buildModeBackedModifierLookup, buildNestedModifierUpdate, captureCallerPath, collectFontFaceCss, component, composite, createModeBackedModifierLookup, cssClassName, cssDeclaration, cssSelector, cssVar, defineAssetGroup, defineAssetIcon, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineProvider, defineStyleProp, defineTokenGroup, deriveFontFaceCss, familiesInRawCss, findComponentReferrers, hasElementMarkerDeep, interpolate, isAssetGroupRef, isAssetRef, isBoolMarker, isColorExpression, isComponentRef, isCompositeRef, isElementLikeValue, isElementMarker, isLayerMarker, isLinearGradientExpr, isMixExpr, isModeRef, isMotionMarker, isNumberMarker, isPlaceable, isPreviewAxisMarker, isRadialGradientExpr, isSafeClassNameValue, isSlotMarker, isStringMarker, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, isVariantArrayMarker, isVariantMarker, linearGradient, makeTokenRefToCss, matchesPreviewWhen, mergeModifierUpdates, mix, mode, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, motion, number, overrideRowsToModifierTree, parseRegistryKey, radialGradient, readSourcePath, rem, resolveAssetRefCss, resolveColorExpression, resolveFontStack, resolveOverrideRowValue, resolvePreviewRules, resolveRegistryDir, reviveElementMarkersDeep, serializeElementsDeep, slot, string, styleProp, tag, token, tokenGroup, variant };
|
|
39
|
+
export { ASSET_CLASS_CAPABILITIES, type AnyRef, type AnyStylePropDefinition, type ArbitrarySpec, AssetGroup, type AssetGroupBuilder, type AssetGroupConfig, type AssetGroupDefinition, type AssetGroupName, type AssetGroupRef, type AssetKind, type AssetName, type AssetRef, type BaseStyles, type BooleanMarker, type BoundComponent, type BuildOptions, CSS_GLOBAL_KEYWORDS, CSS_PROPERTY_KEYWORDS, type CanvasRole, type CanvasRoleEntry, type CanvasRoleEntryInput, type CanvasRolesDefinition, type CanvasRolesDefinitionInput, type CanvasRolesInputConstraint, type ColorCssProperty, type ColorExpression, type ColorFn, type ColorKeyword, type ColorSpace, type ColorValue, Component, type ComponentBuilder, type ComponentBuilderMethods, type ComponentDefinition, ComponentGroup, type ComponentGroupDefinition, type ComponentKind, type ComponentMetadata, type ComponentName, type ComponentRef, type ComponentRenderFn, type CompositeInfo, type CompositeName, type CompositeRef, type CompositeRefBuilder, CompositeStyle, type CompositeStyleDefinition, type CompositeStyleObject, type CompoundPropsEntry, Config, type ConfigCallbackHelpers, type ConfigDiagnostic, type ConfigDiagnosticDefinition, ConfigValidationError, type Css, type CssAngle, type CssClassName, type CssColor, type CssDeclaration, type CssGlobalKeyword, type CssLength, CssMotionDef, type CssMotionDefinition, type CssMotionFields, type CssPercentage, type CssPropertyName, type CssPropertyValues, type CssPropertyWithKeywords, type CssRatio, type CssSelector, type CssSlotMotion, type CssTime, type CssValue, type CssValueTypeName, type CssVar, type CssVarRef, type DataAttrs, type DefineComponentFn, type DefinedComponent, type DefinedMotion, type DefinedProvider, type DefinedStyleProp, type DefinedTokenGroup, type DependenciesQuery, type DependencyKind, type DependencyRef, type DependentsQuery, ELEMENT_MARKER_KIND, type ElementMarker, type EntityKind, type FontAssetGroupConfig, type FontAssetGroupDefinition, type FontAssetMember, type FunctionInfo, type GlobalStylesDef, type GradientStop, type GradientValue, type HexColor, type HslColor, type IconAssetGroupConfig, type IconAssetGroupDefinition, type IconAssetMember, type IconAssetMetadata, JsMotionDef, type JsMotionDefinition, type JsMotionFields, type JsSlotMotion, Layer, type LayerInput, type LayerMarker, type LayerPropsMap, type LengthOrPercent, type LineDirection, type LinearGradientExpr, type LinkedComponentsInput, type LinkedSystemEntry, type LiteralFor, MOTION_CSS_DEFINITION_KEYS, MOTION_CSS_DIRECTIONS, MOTION_CSS_FILL_MODES, MOTION_CSS_PLAY_STATES, MOTION_CSS_PROPERTY_PREFIXES, MOTION_JS_DEFINITION_KEYS, MOTION_JS_DRAG_AXES, MOTION_JS_FIELD_KEYS, MOTION_JS_LAYOUT_MODES, MOTION_JS_REPEAT_TYPES, MOTION_JS_SPRING_FIELDS, MOTION_JS_TRANSITION_TYPES, MOTION_JS_TWEEN_FIELDS, type MixExpr, Mode, type ModeBackedModifierDefinition, type ModeBackedModifierInput, type ModeBackedModifierLookup, type ModeDefinition, type ModeName, ModeOption, type ModeOptionDefinition, type ModeRef, Modifier, type ModifierDefinition, type ModifierTree, type MotionDef, type MotionDefinitionInput, type MotionDragBox, type MotionKeyframes, type MotionMarker, type MotionMetadata, type MotionName, type MotionState, type MotionStateKeyframe, type MotionTransition, type MotionVariants, type MotionViewportOptions, type NumberMarker, type OpacityPairSpec, type OpaqueLeafPredicate, type OverrideModeRef, type OverrideRow, PREVIEW_SEED_KEY, type PlaygroundOptions, type PlaygroundPage, type PlaygroundSpec, type PreviewAxisMarker, type PreviewCallbackHelpers, type PreviewDefinition, type PreviewPropsRule, type PrimitivePropKind, type PropBase, type PropBinding, type PropInfo, type PropKind, Provider, type RadialGradientExpr, type RadialSize, type RawToken, type RegisteredAssetGroups, type RegisteredComponents, type RegisteredCompositeStyles, type RegisteredModes, type RegisteredModifiers, type RegisteredMotion, type RegisteredStyleProps, type RegisteredTokenGroups, type RequiredBrand, type ResolvedCompoundOverrides, type ResolvedTokenLiteral, type RgbColor, SOURCE_PATH_KEY, type SerializedAssetGroup, type SerializedComponentGroup, type SerializedConfig, type SerializedFontAssetGroup, type SerializedIconAssetGroup, type SerializedPlaygroundOptions, type SerializedTokenGroup, type SlotInfo, type SlotMarker, type SlotMotion, type SlotRef, type SlotValueKind, type SlotValueType, type StringMarker, StyleProp, type StylePropDefinition, type StylePropInfo, type StylePropKeyword, type StylePropMetadata, type StylePropName, type StylePropProperty, type StylePropRef, type StylePropTokenUsage, type SystemLink, type TagName, type TagRef, Token, type TokenDefinition, type TokenDefinitionFor, TokenGroup, type TokenGroupDefinition, type TokenGroupDefinitionFor, type TokenGroupMetadata, type TokenGroupName, type TokenGroupRef, type TokenModifierKey, type TokenModifierValue, type TokenName, type TokenQualifiedName, type TokenRawNameRegistry, type TokenRawValue, type TokenRef, type TokenRefToCss, type TokenType, type TokenValue, type TypedSlotRef, type ValuesEntry, type VariantInfo, type VariantMarker, type VariantMarkerArray, type VariantMarkerObject, alpha, asChild, asset, assetGroup, attachSourcePath, boolean, buildModeBackedModifierLookup, buildNestedModifierUpdate, captureCallerPath, collectFontFaceCss, component, composite, createModeBackedModifierLookup, cssClassName, cssDeclaration, cssSelector, cssVar, defineAssetGroup, defineAssetIcon, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineProvider, defineStyleProp, defineTokenGroup, deriveFontFaceCss, familiesInRawCss, findComponentReferrers, hasElementMarkerDeep, interpolate, isAssetGroupRef, isAssetRef, isBoolMarker, isColorExpression, isComponentRef, isCompositeRef, isElementLikeValue, isElementMarker, isLayerMarker, isLinearGradientExpr, isMixExpr, isModeRef, isMotionMarker, isNumberMarker, isPlaceable, isPreviewAxisMarker, isRadialGradientExpr, isSafeClassNameValue, isSlotMarker, isStringMarker, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, isVariantArrayMarker, isVariantMarker, linearGradient, makeTokenRefToCss, matchesPreviewWhen, mergeModifierUpdates, mix, mode, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, motion, number, overrideRowsToModifierTree, parseRegistryKey, radialGradient, readSourcePath, rem, resolveAssetRefCss, resolveColorExpression, resolveFontStack, resolveOverrideRow, resolveOverrideRowValue, resolvePreviewRules, resolveRegistryDir, reviveElementMarkersDeep, serializeElementsDeep, slot, string, styleProp, tag, token, tokenGroup, variant };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import { collectFontFaceCss, deriveFontFaceCss, familiesInRawCss } from "./font-
|
|
|
28
28
|
import { interpolate } from "./interpolate.js";
|
|
29
29
|
import { MOTION_CSS_DIRECTIONS, MOTION_CSS_FILL_MODES, MOTION_CSS_PLAY_STATES, MOTION_CSS_PROPERTY_PREFIXES, MOTION_JS_DRAG_AXES, MOTION_JS_LAYOUT_MODES, MOTION_JS_REPEAT_TYPES, MOTION_JS_SPRING_FIELDS, MOTION_JS_TRANSITION_TYPES, MOTION_JS_TWEEN_FIELDS } from "./motion-constants.js";
|
|
30
30
|
import { resolveRegistryDir } from "./registry-dir.js";
|
|
31
|
-
import { buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue } from "./token-override-rows.js";
|
|
31
|
+
import { buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRow, resolveOverrideRowValue } from "./token-override-rows.js";
|
|
32
32
|
import { CSS_GLOBAL_KEYWORDS, CSS_PROPERTY_KEYWORDS } from "./types/css-property-keywords.js";
|
|
33
33
|
import { rem } from "./units.js";
|
|
34
|
-
export { ASSET_CLASS_CAPABILITIES, AssetGroup, CSS_GLOBAL_KEYWORDS, CSS_PROPERTY_KEYWORDS, Component, ComponentGroup, CompositeStyle, Config, ConfigValidationError, CssMotionDef, ELEMENT_MARKER_KIND, JsMotionDef, Layer, MOTION_CSS_DEFINITION_KEYS, MOTION_CSS_DIRECTIONS, MOTION_CSS_FILL_MODES, MOTION_CSS_PLAY_STATES, MOTION_CSS_PROPERTY_PREFIXES, MOTION_JS_DEFINITION_KEYS, MOTION_JS_DRAG_AXES, MOTION_JS_FIELD_KEYS, MOTION_JS_LAYOUT_MODES, MOTION_JS_REPEAT_TYPES, MOTION_JS_SPRING_FIELDS, MOTION_JS_TRANSITION_TYPES, MOTION_JS_TWEEN_FIELDS, Mode, ModeOption, Modifier, PREVIEW_SEED_KEY, Provider, SOURCE_PATH_KEY, StyleProp, Token, TokenGroup, alpha, asChild, asset, assetGroup, attachSourcePath, boolean, buildModeBackedModifierLookup, buildNestedModifierUpdate, captureCallerPath, collectFontFaceCss, component, composite, createModeBackedModifierLookup, cssClassName, cssDeclaration, cssSelector, cssVar, defineAssetGroup, defineAssetIcon, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineProvider, defineStyleProp, defineTokenGroup, deriveFontFaceCss, familiesInRawCss, findComponentReferrers, hasElementMarkerDeep, interpolate, isAssetGroupRef, isAssetRef, isBoolMarker, isColorExpression, isComponentRef, isCompositeRef, isElementLikeValue, isElementMarker, isLayerMarker, isLinearGradientExpr, isMixExpr, isModeRef, isMotionMarker, isNumberMarker, isPlaceable, isPreviewAxisMarker, isRadialGradientExpr, isSafeClassNameValue, isSlotMarker, isStringMarker, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, isVariantArrayMarker, isVariantMarker, linearGradient, makeTokenRefToCss, matchesPreviewWhen, mergeModifierUpdates, mix, mode, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, motion, number, overrideRowsToModifierTree, parseRegistryKey, radialGradient, readSourcePath, rem, resolveAssetRefCss, resolveColorExpression, resolveFontStack, resolveOverrideRowValue, resolvePreviewRules, resolveRegistryDir, reviveElementMarkersDeep, serializeElementsDeep, slot, string, styleProp, tag, token, tokenGroup, variant };
|
|
34
|
+
export { ASSET_CLASS_CAPABILITIES, AssetGroup, CSS_GLOBAL_KEYWORDS, CSS_PROPERTY_KEYWORDS, Component, ComponentGroup, CompositeStyle, Config, ConfigValidationError, CssMotionDef, ELEMENT_MARKER_KIND, JsMotionDef, Layer, MOTION_CSS_DEFINITION_KEYS, MOTION_CSS_DIRECTIONS, MOTION_CSS_FILL_MODES, MOTION_CSS_PLAY_STATES, MOTION_CSS_PROPERTY_PREFIXES, MOTION_JS_DEFINITION_KEYS, MOTION_JS_DRAG_AXES, MOTION_JS_FIELD_KEYS, MOTION_JS_LAYOUT_MODES, MOTION_JS_REPEAT_TYPES, MOTION_JS_SPRING_FIELDS, MOTION_JS_TRANSITION_TYPES, MOTION_JS_TWEEN_FIELDS, Mode, ModeOption, Modifier, PREVIEW_SEED_KEY, Provider, SOURCE_PATH_KEY, StyleProp, Token, TokenGroup, alpha, asChild, asset, assetGroup, attachSourcePath, boolean, buildModeBackedModifierLookup, buildNestedModifierUpdate, captureCallerPath, collectFontFaceCss, component, composite, createModeBackedModifierLookup, cssClassName, cssDeclaration, cssSelector, cssVar, defineAssetGroup, defineAssetIcon, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineProvider, defineStyleProp, defineTokenGroup, deriveFontFaceCss, familiesInRawCss, findComponentReferrers, hasElementMarkerDeep, interpolate, isAssetGroupRef, isAssetRef, isBoolMarker, isColorExpression, isComponentRef, isCompositeRef, isElementLikeValue, isElementMarker, isLayerMarker, isLinearGradientExpr, isMixExpr, isModeRef, isMotionMarker, isNumberMarker, isPlaceable, isPreviewAxisMarker, isRadialGradientExpr, isSafeClassNameValue, isSlotMarker, isStringMarker, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, isVariantArrayMarker, isVariantMarker, linearGradient, makeTokenRefToCss, matchesPreviewWhen, mergeModifierUpdates, mix, mode, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, motion, number, overrideRowsToModifierTree, parseRegistryKey, radialGradient, readSourcePath, rem, resolveAssetRefCss, resolveColorExpression, resolveFontStack, resolveOverrideRow, resolveOverrideRowValue, resolvePreviewRules, resolveRegistryDir, reviveElementMarkersDeep, serializeElementsDeep, slot, string, styleProp, tag, token, tokenGroup, variant };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ModeDefinition } from "../types.js";
|
|
2
1
|
import { ConfigValidationError } from "../config-diagnostics.js";
|
|
3
|
-
import { NativeAssetGroupDefinition, NativeFontAssetGroupDefinition, NativeTokenGroupDefinition, SerializedNativeConfig } from "./types.js";
|
|
2
|
+
import { NativeAssetGroupDefinition, NativeDefaultModes, NativeFontAssetGroupDefinition, NativeModeDefinition, NativeTokenGroupDefinition, SerializedNativeConfig } from "./types.js";
|
|
4
3
|
import { NativeConfigDiagnostic } from "./validation.js";
|
|
5
4
|
|
|
6
5
|
//#region src/native/NativeConfig.d.ts
|
|
@@ -9,16 +8,18 @@ declare class NativeConfigValidationError extends ConfigValidationError<NativeCo
|
|
|
9
8
|
}
|
|
10
9
|
declare class NativeConfig {
|
|
11
10
|
#private;
|
|
12
|
-
static readonly SCHEMA_VERSION =
|
|
11
|
+
static readonly SCHEMA_VERSION = 2;
|
|
13
12
|
readonly platform: "native";
|
|
14
13
|
namespace?: string;
|
|
15
|
-
|
|
14
|
+
defaultModes?: NativeDefaultModes;
|
|
15
|
+
readonly modes: Map<string, NativeModeDefinition>;
|
|
16
16
|
readonly tokenGroups: Map<string, NativeTokenGroupDefinition>;
|
|
17
17
|
readonly assetGroups: Map<string, NativeFontAssetGroupDefinition>;
|
|
18
18
|
configure(options: {
|
|
19
19
|
namespace?: string;
|
|
20
|
+
defaultModes?: NativeDefaultModes;
|
|
20
21
|
}): this;
|
|
21
|
-
registerModes(modes: Record<string,
|
|
22
|
+
registerModes(modes: Record<string, NativeModeDefinition>): this;
|
|
22
23
|
registerTokenGroups(groups: Record<string, NativeTokenGroupDefinition>): this;
|
|
23
24
|
registerAssetGroups(groups: Record<string, NativeAssetGroupDefinition>): this;
|
|
24
25
|
validate(): NativeConfigDiagnostic[];
|
|
@@ -8,9 +8,10 @@ var NativeConfigValidationError = class extends ConfigValidationError {
|
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
var NativeConfig = class NativeConfig {
|
|
11
|
-
static SCHEMA_VERSION =
|
|
11
|
+
static SCHEMA_VERSION = 2;
|
|
12
12
|
platform = "native";
|
|
13
13
|
namespace;
|
|
14
|
+
defaultModes;
|
|
14
15
|
modes = /* @__PURE__ */ new Map();
|
|
15
16
|
tokenGroups = /* @__PURE__ */ new Map();
|
|
16
17
|
assetGroups = /* @__PURE__ */ new Map();
|
|
@@ -24,6 +25,7 @@ var NativeConfig = class NativeConfig {
|
|
|
24
25
|
if (diagnostics.length > 0) throw new NativeConfigValidationError(diagnostics);
|
|
25
26
|
this.namespace = options.namespace;
|
|
26
27
|
}
|
|
28
|
+
if (options.defaultModes !== void 0) this.defaultModes = { ...options.defaultModes };
|
|
27
29
|
return this;
|
|
28
30
|
}
|
|
29
31
|
registerModes(modes) {
|
|
@@ -53,6 +55,7 @@ var NativeConfig = class NativeConfig {
|
|
|
53
55
|
const json = input;
|
|
54
56
|
const config = new NativeConfig();
|
|
55
57
|
config.namespace = json.namespace;
|
|
58
|
+
config.defaultModes = json.defaultModes ? { ...json.defaultModes } : void 0;
|
|
56
59
|
for (const [name, mode] of Object.entries(json.modes ?? {})) config.modes.set(name, mode);
|
|
57
60
|
for (const [name, group] of Object.entries(json.tokenGroups ?? {})) config.tokenGroups.set(name, group);
|
|
58
61
|
for (const [name, group] of Object.entries(json.assetGroups ?? {})) config.assetGroups.set(name, group);
|
|
@@ -65,6 +68,7 @@ var NativeConfig = class NativeConfig {
|
|
|
65
68
|
};
|
|
66
69
|
if (meta?.builtAt !== void 0) out.builtAt = meta.builtAt;
|
|
67
70
|
if (this.namespace !== void 0) out.namespace = this.namespace;
|
|
71
|
+
if (this.defaultModes !== void 0) out.defaultModes = { ...this.defaultModes };
|
|
68
72
|
if (this.modes.size > 0) out.modes = Object.fromEntries(this.modes);
|
|
69
73
|
if (this.tokenGroups.size > 0) out.tokenGroups = Object.fromEntries(this.tokenGroups);
|
|
70
74
|
if (this.assetGroups.size > 0) out.assetGroups = Object.fromEntries(this.assetGroups);
|
package/dist/native/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AssetRef, TokenRef, asset, token } from "../refs.js";
|
|
2
2
|
import { ColorSpace, MixExpr, alpha, mix } from "../colorExpressions.js";
|
|
3
|
-
import {
|
|
4
|
-
import { DefinedTokenGroupValue
|
|
5
|
-
import { NativeAssetGroupDefinition, NativeColorExpression, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig } from "./types.js";
|
|
3
|
+
import { SystemLink, TokenType } from "../types.js";
|
|
4
|
+
import { DefinedTokenGroupValue } from "../factories.js";
|
|
5
|
+
import { ModeDefinition, NativeAppearanceModeOption, NativeAssetGroupDefinition, NativeColorExpression, NativeDefaultModes, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeModeDefinition, NativeModeOptionDefinition, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, NativeViewportModeOption, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig } from "./types.js";
|
|
6
6
|
import { NativeAssetGroupBuilder, NativeFontAssetGroupConfig, defineAssetGroup } from "./assets.js";
|
|
7
|
+
import { defineMode } from "./modes.js";
|
|
7
8
|
import { NativeConfigDiagnostic, NativeConfigDiagnosticCode, validateSerializedNativeConfig } from "./validation.js";
|
|
8
9
|
import { NativeConfig, NativeConfigValidationError } from "./NativeConfig.js";
|
|
9
10
|
import { isOperatingSystemValue, operatingSystem } from "./values.js";
|
package/dist/native/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NativeModeDefinition } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/native/modes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Native mode authoring uses the shared option/modifier model while requiring
|
|
6
|
+
* each option to describe the application condition that activates it.
|
|
7
|
+
*/
|
|
8
|
+
declare function defineMode<const T extends NativeModeDefinition>(modes: T): T;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { defineMode };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { attachSourcePath, captureCallerPath } from "../captureCallerPath.js";
|
|
2
|
+
//#region src/native/modes.ts
|
|
3
|
+
/**
|
|
4
|
+
* Native mode authoring uses the shared option/modifier model while requiring
|
|
5
|
+
* each option to describe the application condition that activates it.
|
|
6
|
+
*/
|
|
7
|
+
function defineMode(modes) {
|
|
8
|
+
return attachSourcePath(modes, captureCallerPath());
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { defineMode };
|
package/dist/native/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetRef, TokenRef } from "../refs.js";
|
|
2
2
|
import { MixExpr } from "../colorExpressions.js";
|
|
3
|
-
import {
|
|
3
|
+
import { TokenDefinitionFor, TokenGroupDefinitionFor, TokenModifierKey } from "../types.js";
|
|
4
4
|
|
|
5
5
|
//#region src/native/types.d.ts
|
|
6
6
|
type NativeLiteral = string | number | boolean;
|
|
@@ -27,6 +27,28 @@ interface OperatingSystemValue {
|
|
|
27
27
|
type NativeTokenValue = NativeSelectableValue | OperatingSystemValue;
|
|
28
28
|
type NativeTokenDefinition = TokenDefinitionFor<NativeTokenValue>;
|
|
29
29
|
type NativeTokenGroupDefinition = TokenGroupDefinitionFor<NativeTokenDefinition>;
|
|
30
|
+
interface NativeModeOptionBase {
|
|
31
|
+
/** Modifier contributed by this option. Defaults to `_${optionName}`. */
|
|
32
|
+
modifier?: TokenModifierKey;
|
|
33
|
+
label?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
}
|
|
36
|
+
/** An option driven by the React Native color-scheme condition. */
|
|
37
|
+
type NativeAppearanceModeOption = NativeModeOptionBase & {
|
|
38
|
+
appearance: 'light' | 'dark';
|
|
39
|
+
minWidth?: never;
|
|
40
|
+
};
|
|
41
|
+
/** An option driven by the current React Native window width. */
|
|
42
|
+
type NativeViewportModeOption = NativeModeOptionBase & {
|
|
43
|
+
minWidth: number;
|
|
44
|
+
appearance?: never;
|
|
45
|
+
};
|
|
46
|
+
type NativeModeOptionDefinition = NativeAppearanceModeOption | NativeViewportModeOption;
|
|
47
|
+
type NativeModeDefinition = Record<string, NativeModeOptionDefinition>;
|
|
48
|
+
/** Native-entry compatibility name for the platform-specific mode shape. */
|
|
49
|
+
type ModeDefinition = NativeModeDefinition;
|
|
50
|
+
/** Registered mode selections used when resolveTheme() receives no override. */
|
|
51
|
+
type NativeDefaultModes = Record<string, string>;
|
|
30
52
|
interface NativeFontAssetMember {
|
|
31
53
|
/** Font-family value React Native consumes after the font is installed. */
|
|
32
54
|
postscriptName: string;
|
|
@@ -43,9 +65,10 @@ interface SerializedNativeConfig {
|
|
|
43
65
|
platform: 'native';
|
|
44
66
|
builtAt?: string;
|
|
45
67
|
namespace?: string;
|
|
46
|
-
|
|
68
|
+
defaultModes?: NativeDefaultModes;
|
|
69
|
+
modes?: Record<string, NativeModeDefinition>;
|
|
47
70
|
tokenGroups?: Record<string, NativeTokenGroupDefinition>;
|
|
48
71
|
assetGroups?: Record<string, NativeAssetGroupDefinition>;
|
|
49
72
|
}
|
|
50
73
|
//#endregion
|
|
51
|
-
export { NativeAssetGroupDefinition, NativeColorExpression, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig };
|
|
74
|
+
export { ModeDefinition, NativeAppearanceModeOption, NativeAssetGroupDefinition, NativeColorExpression, NativeDefaultModes, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeModeDefinition, NativeModeOptionDefinition, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, NativeViewportModeOption, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigDiagnostic } from "../config-diagnostics.js";
|
|
2
2
|
|
|
3
3
|
//#region src/native/validation.d.ts
|
|
4
|
-
type NativeConfigDiagnosticCode = 'INVALID_SCHEMA' | 'UNSUPPORTED_SCHEMA_VERSION' | 'PLATFORM_MISMATCH' | 'INVALID_NAMESPACE' | 'INVALID_NATIVE_VALUE' | 'UNSUPPORTED_NATIVE_FIELD' | 'INCOMPLETE_OS_VALUE' | 'NESTED_OS_VALUE' | 'INVALID_REFERENCE' | 'UNRESOLVED_TOKEN_REFERENCE' | 'TOKEN_REFERENCE_CYCLE' | 'UNRESOLVED_ASSET_REFERENCE' | 'UNOWNED_MODIFIER' | 'UNSUPPORTED_COLOR_EXPRESSION';
|
|
4
|
+
type NativeConfigDiagnosticCode = 'INVALID_SCHEMA' | 'UNSUPPORTED_SCHEMA_VERSION' | 'PLATFORM_MISMATCH' | 'INVALID_NAMESPACE' | 'INVALID_NATIVE_VALUE' | 'UNSUPPORTED_NATIVE_FIELD' | 'INCOMPLETE_OS_VALUE' | 'NESTED_OS_VALUE' | 'INVALID_REFERENCE' | 'UNRESOLVED_TOKEN_REFERENCE' | 'TOKEN_REFERENCE_CYCLE' | 'UNRESOLVED_ASSET_REFERENCE' | 'UNOWNED_MODIFIER' | 'DUPLICATE_MODIFIER' | 'INVALID_DEFAULT_MODE' | 'INVALID_MODE_CONDITION' | 'INVALID_MODE_COMBINATION' | 'UNSUPPORTED_COLOR_EXPRESSION';
|
|
5
5
|
type NativeConfigDiagnostic = ConfigDiagnostic<NativeConfigDiagnosticCode>;
|
|
6
6
|
declare function validateSerializedNativeConfig(input: unknown, expectedSchemaVersion?: number): NativeConfigDiagnostic[];
|
|
7
7
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isAssetRef, isTokenRef } from "../refs.js";
|
|
2
2
|
import { isMixExpr } from "../colorExpressions.js";
|
|
3
|
+
import { createModeBackedModifierLookup, modifierTreeToOverrideRows, resolveOverrideRow } from "../token-override-rows.js";
|
|
3
4
|
import { isOperatingSystemValue } from "./values.js";
|
|
4
5
|
//#region src/native/validation.ts
|
|
5
6
|
const TOP_LEVEL_KEYS = new Set([
|
|
@@ -7,6 +8,7 @@ const TOP_LEVEL_KEYS = new Set([
|
|
|
7
8
|
"platform",
|
|
8
9
|
"builtAt",
|
|
9
10
|
"namespace",
|
|
11
|
+
"defaultModes",
|
|
10
12
|
"modes",
|
|
11
13
|
"tokenGroups",
|
|
12
14
|
"assetGroups"
|
|
@@ -27,9 +29,12 @@ const MODE_OPTION_KEYS = new Set([
|
|
|
27
29
|
"modifier",
|
|
28
30
|
"label",
|
|
29
31
|
"description",
|
|
32
|
+
"appearance",
|
|
33
|
+
"minWidth",
|
|
30
34
|
"css",
|
|
31
35
|
"media"
|
|
32
36
|
]);
|
|
37
|
+
const APPEARANCES = new Set(["light", "dark"]);
|
|
33
38
|
const OS_KEYS = new Set([
|
|
34
39
|
"__kind",
|
|
35
40
|
"default",
|
|
@@ -54,7 +59,7 @@ const COLOR_SPACES = new Set([
|
|
|
54
59
|
"hsl",
|
|
55
60
|
"hwb"
|
|
56
61
|
]);
|
|
57
|
-
function validateSerializedNativeConfig(input, expectedSchemaVersion =
|
|
62
|
+
function validateSerializedNativeConfig(input, expectedSchemaVersion = 2) {
|
|
58
63
|
const diagnostics = [];
|
|
59
64
|
const configDefinition = { kind: "config" };
|
|
60
65
|
if (!isRecord(input)) {
|
|
@@ -67,6 +72,7 @@ function validateSerializedNativeConfig(input, expectedSchemaVersion = 1) {
|
|
|
67
72
|
if (input.builtAt !== void 0 && typeof input.builtAt !== "string") push(diagnostics, "INVALID_SCHEMA", ["builtAt"], configDefinition, "builtAt must be a string when present.");
|
|
68
73
|
validateNamespace(input.namespace, diagnostics);
|
|
69
74
|
validateModes(input.modes, diagnostics);
|
|
75
|
+
validateDefaultModes(input.defaultModes, input.modes, diagnostics);
|
|
70
76
|
validateAssetGroups(input.assetGroups, diagnostics);
|
|
71
77
|
validateTokenGroups(input.tokenGroups, diagnostics);
|
|
72
78
|
validateReferences(input, diagnostics);
|
|
@@ -83,6 +89,8 @@ function validateModes(value, diagnostics) {
|
|
|
83
89
|
push(diagnostics, "INVALID_SCHEMA", ["modes"], { kind: "config" }, "modes must be a record.");
|
|
84
90
|
return;
|
|
85
91
|
}
|
|
92
|
+
const kindOwners = /* @__PURE__ */ new Map();
|
|
93
|
+
const modifierOwners = /* @__PURE__ */ new Map();
|
|
86
94
|
for (const [modeName, options] of Object.entries(value)) {
|
|
87
95
|
const definition = {
|
|
88
96
|
kind: "mode",
|
|
@@ -93,6 +101,9 @@ function validateModes(value, diagnostics) {
|
|
|
93
101
|
push(diagnostics, "INVALID_SCHEMA", modePath, definition, `Mode "${modeName}" must be an option record.`);
|
|
94
102
|
continue;
|
|
95
103
|
}
|
|
104
|
+
if (Object.keys(options).length === 0) push(diagnostics, "INVALID_MODE_CONDITION", modePath, definition, `Native mode "${modeName}" must define at least one appearance or viewport option.`);
|
|
105
|
+
let modeKind;
|
|
106
|
+
const conditionValues = /* @__PURE__ */ new Map();
|
|
96
107
|
for (const [optionName, option] of Object.entries(options)) {
|
|
97
108
|
const optionPath = [...modePath, optionName];
|
|
98
109
|
if (!isRecord(option)) {
|
|
@@ -105,10 +116,61 @@ function validateModes(value, diagnostics) {
|
|
|
105
116
|
"label",
|
|
106
117
|
"description"
|
|
107
118
|
]) if (option[key] !== void 0 && typeof option[key] !== "string") push(diagnostics, "INVALID_SCHEMA", [...optionPath, key], definition, `${key} must be a string when present.`);
|
|
119
|
+
if (typeof option.modifier === "string" && !option.modifier.startsWith("_")) push(diagnostics, "INVALID_SCHEMA", [...optionPath, "modifier"], definition, "Native mode modifiers must start with \"_\".");
|
|
108
120
|
for (const key of ["css", "media"]) if (option[key] !== void 0) push(diagnostics, "UNSUPPORTED_NATIVE_FIELD", [...optionPath, key], definition, `Mode option field "${key}" is web-only and is not supported by NativeConfig.`);
|
|
121
|
+
const hasAppearance = option.appearance !== void 0;
|
|
122
|
+
if (hasAppearance === (option.minWidth !== void 0)) {
|
|
123
|
+
push(diagnostics, "INVALID_MODE_CONDITION", optionPath, definition, `Native mode option "${modeName}/${optionName}" must define exactly one condition: appearance or minWidth.`);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const optionKind = hasAppearance ? "appearance" : "viewport";
|
|
127
|
+
if (modeKind !== void 0 && modeKind !== optionKind) push(diagnostics, "INVALID_MODE_CONDITION", optionPath, definition, `Native mode "${modeName}" cannot mix appearance and viewport options.`);
|
|
128
|
+
else modeKind = optionKind;
|
|
129
|
+
let conditionValue;
|
|
130
|
+
if (hasAppearance) if (typeof option.appearance !== "string" || !APPEARANCES.has(option.appearance)) push(diagnostics, "INVALID_MODE_CONDITION", [...optionPath, "appearance"], definition, "Native appearance must be \"light\" or \"dark\".");
|
|
131
|
+
else conditionValue = option.appearance;
|
|
132
|
+
else if (typeof option.minWidth !== "number" || !Number.isFinite(option.minWidth) || option.minWidth < 0) push(diagnostics, "INVALID_MODE_CONDITION", [...optionPath, "minWidth"], definition, "Native minWidth must be a finite, non-negative number.");
|
|
133
|
+
else conditionValue = option.minWidth;
|
|
134
|
+
if (conditionValue !== void 0) {
|
|
135
|
+
const previous = conditionValues.get(conditionValue);
|
|
136
|
+
if (previous !== void 0) push(diagnostics, "INVALID_MODE_CONDITION", optionPath, definition, `Native mode options "${modeName}/${previous}" and "${modeName}/${optionName}" describe the same condition.`);
|
|
137
|
+
else conditionValues.set(conditionValue, optionName);
|
|
138
|
+
}
|
|
139
|
+
const modifier = typeof option.modifier === "string" ? option.modifier : `_${optionName}`;
|
|
140
|
+
const previousModifierOwner = modifierOwners.get(modifier);
|
|
141
|
+
if (previousModifierOwner !== void 0) push(diagnostics, "DUPLICATE_MODIFIER", [...optionPath, "modifier"], definition, `Modifier "${modifier}" is already owned by mode option "${previousModifierOwner}".`);
|
|
142
|
+
else modifierOwners.set(modifier, `${modeName}/${optionName}`);
|
|
143
|
+
}
|
|
144
|
+
if (modeKind !== void 0) {
|
|
145
|
+
const previousKindOwner = kindOwners.get(modeKind);
|
|
146
|
+
if (previousKindOwner !== void 0) push(diagnostics, "INVALID_MODE_CONDITION", modePath, definition, `Native ${modeKind} conditions are already registered by mode "${previousKindOwner}".`);
|
|
147
|
+
else kindOwners.set(modeKind, modeName);
|
|
109
148
|
}
|
|
110
149
|
}
|
|
111
150
|
}
|
|
151
|
+
function validateDefaultModes(value, modes, diagnostics) {
|
|
152
|
+
if (value === void 0) return;
|
|
153
|
+
if (!isRecord(value)) {
|
|
154
|
+
push(diagnostics, "INVALID_DEFAULT_MODE", ["defaultModes"], { kind: "config" }, "defaultModes must be a record of registered mode selections.");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const registeredModes = isRecord(modes) ? modes : {};
|
|
158
|
+
for (const [modeName, optionName] of Object.entries(value)) {
|
|
159
|
+
const path = ["defaultModes", modeName];
|
|
160
|
+
const options = registeredModes[modeName];
|
|
161
|
+
if (!isRecord(options)) {
|
|
162
|
+
push(diagnostics, "INVALID_DEFAULT_MODE", path, {
|
|
163
|
+
kind: "mode",
|
|
164
|
+
name: modeName
|
|
165
|
+
}, `Default mode "${modeName}" is not registered.`);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (typeof optionName !== "string" || !isRecord(options[optionName])) push(diagnostics, "INVALID_DEFAULT_MODE", path, {
|
|
169
|
+
kind: "mode",
|
|
170
|
+
name: modeName
|
|
171
|
+
}, `Default mode "${modeName}" must select a registered option.`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
112
174
|
function validateAssetGroups(value, diagnostics) {
|
|
113
175
|
if (value === void 0) return;
|
|
114
176
|
if (!isRecord(value)) {
|
|
@@ -180,10 +242,10 @@ function validateTokenGroups(value, diagnostics) {
|
|
|
180
242
|
], {
|
|
181
243
|
kind: "token",
|
|
182
244
|
name: `${groupName}/${tokenName}`
|
|
183
|
-
}, diagnostics
|
|
245
|
+
}, diagnostics);
|
|
184
246
|
}
|
|
185
247
|
}
|
|
186
|
-
function validateTokenDefinition(value, path, definition, diagnostics
|
|
248
|
+
function validateTokenDefinition(value, path, definition, diagnostics) {
|
|
187
249
|
if (!isRecord(value)) {
|
|
188
250
|
push(diagnostics, "INVALID_SCHEMA", path, definition, `Native token "${definition.name ?? ""}" must be an object.`);
|
|
189
251
|
return;
|
|
@@ -198,8 +260,7 @@ function validateTokenDefinition(value, path, definition, diagnostics, allowModi
|
|
|
198
260
|
push(diagnostics, "INVALID_SCHEMA", [...path, key], definition, `Unknown token definition field "${key}"; modifier fields must start with "_".`);
|
|
199
261
|
continue;
|
|
200
262
|
}
|
|
201
|
-
if (
|
|
202
|
-
if (looksLikeTokenDefinition(modifier)) validateTokenDefinition(modifier, [...path, key], definition, diagnostics, false);
|
|
263
|
+
if (looksLikeTokenDefinition(modifier)) validateTokenDefinition(modifier, [...path, key], definition, diagnostics);
|
|
203
264
|
else validateNativeValue(modifier, [...path, key], definition, diagnostics, true);
|
|
204
265
|
}
|
|
205
266
|
}
|
|
@@ -305,15 +366,14 @@ function validateReferences(config, diagnostics) {
|
|
|
305
366
|
}
|
|
306
367
|
}
|
|
307
368
|
const assets = isRecord(config.assetGroups) ? config.assetGroups : {};
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
const contexts = [void 0, ...modifiers];
|
|
369
|
+
const modifierLookup = createNativeModifierLookup(config.modes);
|
|
370
|
+
const contexts = buildModifierContexts(config.modes);
|
|
311
371
|
for (const [tokenRef, token] of tokens) {
|
|
312
372
|
collectAllReferences(token.definition, token.path, {
|
|
313
373
|
kind: "token",
|
|
314
374
|
name: tokenRef
|
|
315
375
|
}, tokens, assets, diagnostics);
|
|
316
|
-
for (const
|
|
376
|
+
for (const modifiers of contexts) resolveTokenContext(tokenRef, modifiers, modifierLookup, tokens, diagnostics, [], token.path);
|
|
317
377
|
}
|
|
318
378
|
}
|
|
319
379
|
function collectAllReferences(value, path, definition, tokens, assets, diagnostics) {
|
|
@@ -330,7 +390,7 @@ function collectAllReferences(value, path, definition, tokens, assets, diagnosti
|
|
|
330
390
|
if (!groupName || !memberName || !group || group.assetKind !== "font" || !isRecord(group.members) || !group.members[memberName]) push(diagnostics, "UNRESOLVED_ASSET_REFERENCE", entryPath, definition, `Asset reference "${entry.ref}" does not resolve to a registered native font asset.`);
|
|
331
391
|
});
|
|
332
392
|
}
|
|
333
|
-
function resolveTokenContext(ref,
|
|
393
|
+
function resolveTokenContext(ref, activeModes, modifierLookup, tokens, diagnostics, stack, sourcePath) {
|
|
334
394
|
if (stack.includes(ref)) {
|
|
335
395
|
const cycle = [...stack.slice(stack.indexOf(ref)), ref].join(" -> ");
|
|
336
396
|
push(diagnostics, "TOKEN_REFERENCE_CYCLE", sourcePath, {
|
|
@@ -341,38 +401,62 @@ function resolveTokenContext(ref, modifier, tokens, diagnostics, stack, sourcePa
|
|
|
341
401
|
}
|
|
342
402
|
const token = tokens.get(ref);
|
|
343
403
|
if (!token) return;
|
|
344
|
-
const selected = selectTokenValue(token.definition, token.path,
|
|
404
|
+
const selected = selectTokenValue(token.definition, token.path, activeModes, modifierLookup);
|
|
345
405
|
const nextStack = [...stack, ref];
|
|
346
406
|
walkValues(selected.value, selected.path, (entry, entryPath) => {
|
|
347
|
-
if (isTokenRef(entry) && typeof entry.ref === "string") resolveTokenContext(entry.ref,
|
|
407
|
+
if (isTokenRef(entry) && typeof entry.ref === "string") resolveTokenContext(entry.ref, activeModes, modifierLookup, tokens, diagnostics, nextStack, entryPath);
|
|
348
408
|
});
|
|
349
409
|
}
|
|
350
|
-
function selectTokenValue(definition, path,
|
|
351
|
-
const
|
|
352
|
-
if (
|
|
410
|
+
function selectTokenValue(definition, path, activeModes, modifierLookup) {
|
|
411
|
+
const selected = resolveOverrideRow(modifierTreeToOverrideRows(definition, modifierLookup), activeModes);
|
|
412
|
+
if (!selected) return {
|
|
353
413
|
value: definition.value,
|
|
354
414
|
path: [...path, "value"]
|
|
355
415
|
};
|
|
356
|
-
|
|
357
|
-
|
|
416
|
+
let source = definition;
|
|
417
|
+
for (const modifier of selected.sourceModifierPath) source = source[modifier];
|
|
418
|
+
return {
|
|
419
|
+
value: selected.value,
|
|
358
420
|
path: [
|
|
359
421
|
...path,
|
|
360
|
-
|
|
361
|
-
"value"
|
|
422
|
+
...selected.sourceModifierPath,
|
|
423
|
+
...looksLikeTokenDefinition(source) ? ["value"] : []
|
|
362
424
|
]
|
|
363
425
|
};
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
426
|
+
}
|
|
427
|
+
function buildModifierContexts(modes) {
|
|
428
|
+
let contexts = [/* @__PURE__ */ new Set()];
|
|
429
|
+
for (const [modeName, options] of Object.entries(modes ?? {})) {
|
|
430
|
+
if (!isRecord(options)) continue;
|
|
431
|
+
const modeRefs = Object.entries(options).filter((entry) => isRecord(entry[1])).map(([optionName]) => `${modeName}.${optionName}`);
|
|
432
|
+
contexts = contexts.flatMap((context) => [context, ...modeRefs.map((modeRef) => new Set([...context, modeRef]))]);
|
|
433
|
+
}
|
|
434
|
+
return contexts;
|
|
435
|
+
}
|
|
436
|
+
function createNativeModifierLookup(modes) {
|
|
437
|
+
return createModeBackedModifierLookup(Object.entries(modes ?? {}).flatMap(([modeName, options], modeOrder) => {
|
|
438
|
+
if (!isRecord(options)) return [];
|
|
439
|
+
return Object.entries(options).flatMap(([optionName, option], optionOrder) => {
|
|
440
|
+
if (!isRecord(option)) return [];
|
|
441
|
+
return [{
|
|
442
|
+
modifier: typeof option.modifier === "string" ? option.modifier : `_${optionName}`,
|
|
443
|
+
mode: modeName,
|
|
444
|
+
option: optionName,
|
|
445
|
+
label: typeof option.label === "string" ? option.label : void 0,
|
|
446
|
+
modeOrder,
|
|
447
|
+
optionOrder
|
|
448
|
+
}];
|
|
449
|
+
});
|
|
450
|
+
}));
|
|
368
451
|
}
|
|
369
452
|
function validateModifierOwnership(config, diagnostics) {
|
|
370
|
-
const
|
|
371
|
-
if (isRecord(config.modes)) for (const options of Object.
|
|
453
|
+
const owners = /* @__PURE__ */ new Map();
|
|
454
|
+
if (isRecord(config.modes)) for (const [modeName, options] of Object.entries(config.modes)) {
|
|
372
455
|
if (!isRecord(options)) continue;
|
|
373
456
|
for (const [optionName, option] of Object.entries(options)) {
|
|
374
457
|
if (!isRecord(option)) continue;
|
|
375
|
-
|
|
458
|
+
const modifier = typeof option.modifier === "string" ? option.modifier : `_${optionName}`;
|
|
459
|
+
if (!owners.has(modifier)) owners.set(modifier, modeName);
|
|
376
460
|
}
|
|
377
461
|
}
|
|
378
462
|
if (!isRecord(config.tokenGroups)) return;
|
|
@@ -380,20 +464,29 @@ function validateModifierOwnership(config, diagnostics) {
|
|
|
380
464
|
if (!isRecord(group) || !isRecord(group.tokens)) continue;
|
|
381
465
|
for (const [tokenName, definition] of Object.entries(group.tokens)) {
|
|
382
466
|
if (!isRecord(definition)) continue;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
467
|
+
validateDefinitionModifiers(definition, [
|
|
468
|
+
"tokenGroups",
|
|
469
|
+
groupName,
|
|
470
|
+
"tokens",
|
|
471
|
+
tokenName
|
|
472
|
+
], {
|
|
473
|
+
kind: "token",
|
|
474
|
+
name: `${groupName}/${tokenName}`
|
|
475
|
+
}, owners, /* @__PURE__ */ new Set(), diagnostics);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function validateDefinitionModifiers(definition, path, tokenDefinition, owners, activeModeGroups, diagnostics) {
|
|
480
|
+
for (const [modifier, value] of Object.entries(definition)) {
|
|
481
|
+
if (!modifier.startsWith("_")) continue;
|
|
482
|
+
const modifierPath = [...path, modifier];
|
|
483
|
+
const owner = owners.get(modifier);
|
|
484
|
+
if (owner === void 0) {
|
|
485
|
+
push(diagnostics, "UNOWNED_MODIFIER", modifierPath, tokenDefinition, `Modifier "${modifier}" is not owned by a registered mode option.`);
|
|
486
|
+
continue;
|
|
396
487
|
}
|
|
488
|
+
if (activeModeGroups.has(owner)) push(diagnostics, "INVALID_MODE_COMBINATION", modifierPath, tokenDefinition, `Compound native token overrides cannot select more than one option from mode "${owner}".`);
|
|
489
|
+
if (looksLikeTokenDefinition(value)) validateDefinitionModifiers(value, modifierPath, tokenDefinition, owners, new Set([...activeModeGroups, owner]), diagnostics);
|
|
397
490
|
}
|
|
398
491
|
}
|
|
399
492
|
function walkValues(value, path, visit) {
|
package/dist/native.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AssetRef, TokenRef, asset, token } from "./refs.js";
|
|
2
2
|
import { ColorSpace, MixExpr, alpha, mix } from "./colorExpressions.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { NativeAssetGroupDefinition, NativeColorExpression, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig } from "./native/types.js";
|
|
3
|
+
import { SystemLink, TokenType } from "./types.js";
|
|
4
|
+
import { ModeDefinition, NativeAppearanceModeOption, NativeAssetGroupDefinition, NativeColorExpression, NativeDefaultModes, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeModeDefinition, NativeModeOptionDefinition, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, NativeViewportModeOption, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig } from "./native/types.js";
|
|
6
5
|
import { NativeAssetGroupBuilder, NativeFontAssetGroupConfig, defineAssetGroup } from "./native/assets.js";
|
|
6
|
+
import { defineMode } from "./native/modes.js";
|
|
7
7
|
import { NativeConfigDiagnostic, NativeConfigDiagnosticCode, validateSerializedNativeConfig } from "./native/validation.js";
|
|
8
8
|
import { NativeConfig, NativeConfigValidationError } from "./native/NativeConfig.js";
|
|
9
9
|
import { isOperatingSystemValue, operatingSystem } from "./native/values.js";
|
|
10
10
|
import { DefinedNativeTokenGroup, defineTokenGroup } from "./native/index.js";
|
|
11
|
-
export { AssetRef, ColorSpace, DefinedNativeTokenGroup, MixExpr, ModeDefinition, NativeAssetGroupBuilder, NativeAssetGroupDefinition, NativeColorExpression, NativeConfig, NativeConfigDiagnostic, NativeConfigDiagnosticCode, NativeConfigValidationError, NativeFontAssetGroupConfig, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig, SystemLink, TokenRef, TokenType, alpha, asset, defineAssetGroup, defineMode, defineTokenGroup, isOperatingSystemValue, mix, operatingSystem, token, validateSerializedNativeConfig };
|
|
11
|
+
export { AssetRef, ColorSpace, DefinedNativeTokenGroup, MixExpr, ModeDefinition, NativeAppearanceModeOption, NativeAssetGroupBuilder, NativeAssetGroupDefinition, NativeColorExpression, NativeConfig, NativeConfigDiagnostic, NativeConfigDiagnosticCode, NativeConfigValidationError, NativeDefaultModes, NativeFontAssetGroupConfig, NativeFontAssetGroupDefinition, NativeFontAssetMember, NativeLiteral, NativeModeDefinition, NativeModeOptionDefinition, NativeSelectableValue, NativeTokenDefinition, NativeTokenGroupDefinition, NativeTokenValue, NativeViewportModeOption, OperatingSystemInput, OperatingSystemValue, SerializedNativeConfig, SystemLink, TokenRef, TokenType, alpha, asset, defineAssetGroup, defineMode, defineTokenGroup, isOperatingSystemValue, mix, operatingSystem, token, validateSerializedNativeConfig };
|
package/dist/native.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { asset, token } from "./refs.js";
|
|
2
2
|
import { alpha, mix } from "./colorExpressions.js";
|
|
3
|
-
import { defineMode } from "./factories.js";
|
|
4
3
|
import { defineAssetGroup } from "./native/assets.js";
|
|
4
|
+
import { defineMode } from "./native/modes.js";
|
|
5
5
|
import { isOperatingSystemValue, operatingSystem } from "./native/values.js";
|
|
6
6
|
import { validateSerializedNativeConfig } from "./native/validation.js";
|
|
7
7
|
import { NativeConfig, NativeConfigValidationError } from "./native/NativeConfig.js";
|
|
@@ -51,6 +51,8 @@ declare function buildModeBackedModifierLookup(modes: readonly ModeBackedModeMet
|
|
|
51
51
|
declare function modifierTreeToOverrideRows<TValue>(modifiers: ModifierTree<TValue> | undefined, lookup: ModeBackedModifierLookup): OverrideRow<TValue>[];
|
|
52
52
|
declare function overrideRowsToModifierTree<TValue>(rows: readonly OverrideRow<TValue>[], lookup: ModeBackedModifierLookup): ModifierTree<TValue>;
|
|
53
53
|
declare function resolveOverrideRowValue<TValue>(baseValue: TValue, rows: readonly Pick<OverrideRow<TValue>, 'modes' | 'value'>[], activeModes: Iterable<OverrideModeRef>): TValue;
|
|
54
|
+
/** Return the winning authored row using shared specificity/order semantics. */
|
|
55
|
+
declare function resolveOverrideRow<TRow extends Pick<OverrideRow<unknown>, 'modes' | 'value'>>(rows: readonly TRow[], activeModes: Iterable<OverrideModeRef>): TRow | undefined;
|
|
54
56
|
declare function modifierPathToId(path: readonly TokenModifierKey[]): string;
|
|
55
57
|
declare function modifierIdToPath(id: string): TokenModifierKey[];
|
|
56
58
|
declare function buildNestedModifierUpdate<TValue>(modifierPath: readonly TokenModifierKey[], value: ModifierUpdateValue<TValue>): Record<TokenModifierKey, ModifierUpdateValue<TValue>>;
|
|
@@ -63,4 +65,4 @@ declare function buildNestedModifierUpdate<TValue>(modifierPath: readonly TokenM
|
|
|
63
65
|
*/
|
|
64
66
|
declare function mergeModifierUpdates<TValue>(...updates: readonly ModifierUpdate<TValue>[]): Record<string, ModifierUpdateValue<TValue>>;
|
|
65
67
|
//#endregion
|
|
66
|
-
export { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue };
|
|
68
|
+
export { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, ModifierTree, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRow, resolveOverrideRowValue };
|
|
@@ -45,7 +45,7 @@ function modifierTreeToOverrideRows(modifiers, lookup) {
|
|
|
45
45
|
const rows = [];
|
|
46
46
|
let sourceOrder = 0;
|
|
47
47
|
const visit = (value, modifierPath) => {
|
|
48
|
-
const node =
|
|
48
|
+
const node = asModeModifierNode(value);
|
|
49
49
|
const modes = canonicalizeModifierPath(modifierPath, lookup);
|
|
50
50
|
if (!node) {
|
|
51
51
|
rows.push({
|
|
@@ -89,8 +89,13 @@ function overrideRowsToModifierTree(rows, lookup) {
|
|
|
89
89
|
return tree;
|
|
90
90
|
}
|
|
91
91
|
function resolveOverrideRowValue(baseValue, rows, activeModes) {
|
|
92
|
+
const resolved = resolveOverrideRow(rows, activeModes);
|
|
93
|
+
return resolved === void 0 ? baseValue : resolved.value;
|
|
94
|
+
}
|
|
95
|
+
/** Return the winning authored row using shared specificity/order semantics. */
|
|
96
|
+
function resolveOverrideRow(rows, activeModes) {
|
|
92
97
|
const active = new Set(activeModes);
|
|
93
|
-
let resolved
|
|
98
|
+
let resolved;
|
|
94
99
|
let bestSpecificity = -1;
|
|
95
100
|
let bestOrder = -1;
|
|
96
101
|
rows.forEach((row, order) => {
|
|
@@ -98,7 +103,7 @@ function resolveOverrideRowValue(baseValue, rows, activeModes) {
|
|
|
98
103
|
const specificity = row.modes.length;
|
|
99
104
|
if (specificity < bestSpecificity) return;
|
|
100
105
|
if (specificity === bestSpecificity && order < bestOrder) return;
|
|
101
|
-
resolved = row
|
|
106
|
+
resolved = row;
|
|
102
107
|
bestSpecificity = specificity;
|
|
103
108
|
bestOrder = order;
|
|
104
109
|
});
|
|
@@ -191,6 +196,11 @@ function mergeLeafValue(current, value) {
|
|
|
191
196
|
value
|
|
192
197
|
};
|
|
193
198
|
}
|
|
199
|
+
function asModeModifierNode(value) {
|
|
200
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
201
|
+
if (Object.hasOwn(value, "__kind")) return null;
|
|
202
|
+
return asModifierNode(value);
|
|
203
|
+
}
|
|
194
204
|
function asWritableModifierNode(current) {
|
|
195
205
|
const node = asModifierNode(current);
|
|
196
206
|
if (node) return { ...node };
|
|
@@ -220,4 +230,4 @@ function compareModeBackedModifiersByRef(a, b, lookup) {
|
|
|
220
230
|
return a.localeCompare(b);
|
|
221
231
|
}
|
|
222
232
|
//#endregion
|
|
223
|
-
export { buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue };
|
|
233
|
+
export { buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRow, resolveOverrideRowValue };
|