chore(deps): update dependency style-dictionary to v5 #208
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^3.9.0→^5.0.0Release Notes
style-dictionary/style-dictionary (style-dictionary)
v5.1.3Compare Source
Patch Changes
6e306bc: Upgrade glob@11.1.0 forked package to fix vulnerability in origin package.v5.1.1Compare Source
Patch Changes
65745da: Fix outputReferences for tokens with 'value' in their name. Previously, references to tokens likeobject_type.value_chainwere incorrectly resolved because the code removed the first occurrence of.valueinstead of only the trailing suffix.v5.1.0Compare Source
Minor Changes
97a209a: Add new size/compose/{sp,dp} transformsPatch Changes
dbcdae3: Fix fontName parsing to handle double quotesc47600d: Export expand DTCGTypesMap for extension use cases.v5.0.4Compare Source
Patch Changes
7a238af: Fix an issue with token collisions being way to eager about complaining when values that are identical are "colliding". This cuts collision warnings by 75% or more.v5.0.3Compare Source
Patch Changes
3d070f5: Move patch-package to devDependencies and run in prepare instead of postinstall, so it only runs when npm installing locally and not for consumers.71614da: Wrap structuredClone in loadFile in a try catch, in case we have a JS/TS config file with dynamic content.v5.0.2Compare Source
Patch Changes
8e413a2: Fix vulnerable dependencies, patch-package and its transitivetmpdependency in particular.9f84a81: Remove node-sass from create-react-app example, dart-sass is used now usually.da19c8f: Small patch to allow no-destination "files" to not cause errors when using clean methods.v5.0.1Compare Source
Patch Changes
463b456: Simplify internalcleanFile(s)utils, fix a bug that would still attempt to unlink non-existent files in verbosity"silent"mode.8f7c522: FixloadFileto deep clone ES module exports to avoid unintended mutationsv5.0.0Compare Source
Major Changes
02300b1: No longer allow references to non-token leaf nodes. References only work when referencing a Design Token (its value).Non-token nodes will also not make it to the output, because they are filtered out during the flattening process to
tokenMapandtokenArray.Remove allowing references with
.valuesuffix.f19a0cb: BREAKING: no longer possible to pass options to change the reference syntax{ref.foo}. The opening, closing and separator characters are now set to be aligned with the DTCG spec.02300b1: BREAKING: minimum NodeJS version required is now v22.0.0 (LTS, at time of writing this). This is to supportSet.prototype.unionwhich we utilize in our token reference resolution utility, and it's important to use the cheaper built-in versus doing a union manually.Minor Changes
02300b1: Support passing Token Map structure togetReferencesandresolveReferencesutils.b80e75b: When transform hooks throw errors, they will now be caught and error-handled by Style Dictionary.Instead of causing a fatal failure, the error is collected and logged as a warning at the end.
With verbosity turned to
"verbose", information about which tokens in which files are causing an error in which transform, to help debugging the problem.Sensible fallbacks are used when a transform cannot complete.
Patch Changes
a23f353: SD will use posix style paths ('/') as much as possible and rely onnode:fsto translate to win32 paths whenever a call to the filesystem is done. The exception is for dynamic imports of JS files (SD config, token files).a23f353: Allow buildPaths without a trailing slash, by making use ofpath.join()utility.9bbbc8a: Dynamically import prettier and plugins so that they can be chunked separately by bundlers, and only imported on demand. This will significantly improve bundle size for users of Style Dictionary.v4.4.0Compare Source
Minor Changes
f2395f3: Add a 'flat' option to the javascriptEsm format2f13dcb: Added support for using the selector option as a string or string array in the css/variables formatter. When an array is provided, the CSS variables will be nested within the specified selectors in orderPatch Changes
ee85609: fix misaligned comments in typescript/es6-declarations6ff17ec: If several preprocessors are defined in the SD configuration, the execution of the preprocessors is now guaranteed in the exact order in which they were configured in the SD configuration.v4.3.3Compare Source
Patch Changes
ea0ec73: Fix convertToDTCG for sets that are already (partially) DTCG.1d4389a: -'color/hex'(colorHexenum) built-in transform can now handle alpha channels properly by outputting hex8 format if needed. This also affects the transformGroupslessandjswhich apply this transform.'color/hex8'(colorHex8enum) built-in transform is now deprecated, use'color/hex'(colorHexenum) instead.e77feb4: Move the tinycolor2 patch from a patch file to a 3-liner fix in our source code, so it gets correctly published and usable by consumers.177c25e: Account for multiline comments in javascript/es6 formatv4.3.2Compare Source
Patch Changes
7d60069: Hotfix for'size/rem'=>sizeRemtransform to not change values with'px'units to'rem'. Regression was added inv4.3.1(commit sha1684a8e).v4.3.1Compare Source
Patch Changes
1684a8e: Fix sizeRem to allow negative values803d1f8: Fix gradients with rgba values returning rgba(0, 0, 0, 0)6cc1da3: Add and check types to CLI file, fix typo for --platform flag.v4.3.0Compare Source
Minor Changes
302b466: Introduce a new entrypoint:style-dictionary/enumsfor most of the library's hard-coded string values. Most of these are built-in hooks names. This provides better type-safety for consumers as well as various maintainability related benefits for this library. See documentation for more info.5aad797: Add tailwind preset example, remove unused .editorconfig filebd8be17: Add support for native .TS token & config file processing.209085d: AddtokenMapproperties to Dictionary, which is a JavaScript Map structure of the tokens, which makes it easy to iterate as well as access tokens. Also addconvertTokenDatautility that allows to seemlessly convert between Map, Object or Array of tokens, and deprecate theflattenTokensutility in favor of that one.Patch Changes
2966cfd: handle DTCG-format tokens in typescript/es6-declarations formatter4a7bca7: add accessControl field to Android Compose templatef694f67: Fix Prettier imports, see https://prettier.io/docs/en/api#custom-parser-api-removed for more info.fd8cdb4: handle DTCG-format tokens in javascript/es6 formatter6a6a409: Move prettier to dependencies since style-dictionary isn't really a prettier plugin and a direct dependency seems more accurate here.8a9cfa0: FixoutputReferencesTransformedutil, would returntruefor tokens which original values were not strings.7a661bb: Fix font-style and font-weight logic for fonts.css.template.jsv4.2.0Compare Source
Minor Changes
0fcf229: Add a new built-in format javascript/esm that outputs an ES module JS default export.d7b5836: Mark javascript/esm as nested, use Prettier on all JavaScript/TypeScript formats, use 3.x.x peerDependency so the user's installation is used when possible.4bf68a3: Apply stripMeta from "json" format to the new "javascript/esm" as well.8f1b4f0: Add new utility instyle-dictionary/utils->stripMetafor stripping metadata from tokens.This utility is used now as an opt-in for the built-in
'json'format by usingoptions.stripMeta, which if set totruewill strip Style Dictionary meta props.You can specify
keep/strip(allow/blocklist) for granular control about which properties to keep or strip.Patch Changes
5e3a5af: Update .d.ts/js files type imports to use correct extensions rather than extensionless. This fixes some incompatibilities with latest TypeScript "NodeNext" moduleResolution.v4.1.4Compare Source
Patch Changes
a67ed31: Pass PlatformConfig as options param to platform-applied preprocessors.19aee32: FixconvertToBase64util to support converting binary files such as fonts, for both Browser and NodeJS.v4.1.3Compare Source
Patch Changes
9376247: MakedefaultMessageparam in FileHeader type optional.43ccb42: (#1305): fix reference sorting insortByReferencefunction for DTCG token format, ensuring token references are declared after their targets26728b9: FixfilterTokensutility to deal with random metadata properties throughout token groups, without throwing errors.v4.1.2Compare Source
Patch Changes
e9cce6a: Reuse static hooks in the constructor to set instance hooks prop, to avoid discarding built-in hooks overwrites by consumers.b48d0e9: Add missing type interfaces, most notably the ExpandConfig types.v4.1.1Compare Source
Patch Changes
5db3521: AddiosSwiftEnumOpts.classNameandiosSwiftAnyOpts.classNameformats property documentation23f8a25: Use cp and rmdir commands forcopy_assetsdo and undo methods, since they affect directories, not files.v4.1.0Compare Source
Minor Changes
ccf27b7: Prevent duplicate redundant calls to StyleDictionary class methods by caching platform specific config & tokens results.Added reusable methods:
getPlatformTokens()-> grabs thetokens/allTokens(new!exportPlatformdoes not return this) for a specific platform, after running platform specific preprocessors and transforms. This replaces the oldexportPlatformmethod which is now deprecated and will be removed in v6.getPlatformConfig()-> grabs the processed/transformedPlatformConfigfor a specific platform, replaces the now deprecatedgetPlatformmethod which will be removed in v6.The reasons for deprecating those methods and replacing them with new ones is to reduce method ambiguity and make them more pure.
Add new options object to methods:
getPlatformTokensgetPlatformConfigexportPlatform(deprecated, see above)getPlatform(deprecated, see above)formatPlatformformatAllPlatformsbuildPlatformbuildAllPlatformscleanPlatformcleanAllPlatformswith property
cache, which if set tofalse, will disable this caching of generating the platform specific config / tokens, e.g.:Expectation is that this is usually not useful for majority of users, unless for example you're testing multiple runs of StyleDictionary while changing tokens or platform configs in between those runs.
Patch Changes
2ec9a44:size/remtransform to leave 0 (string or number) values as is, since 0 doesn't need a unit.f317430: Added link to logging documentation inside all of the warnings and errors that refer to verbosity.6275983: Respectformattingoptions in scss map-deep/map-flat formats, those that make sense:commentPositioncommentStyleindentationAlso export a new type interface
FormattingOverrides, which is a limited version ofFormattingOptions.These contain the formatting options that can be overridden by users, whereas the full version is meant for the format helper utilities such as
createPropertyFormatter/formattedVariables.v4.0.1Compare Source
Patch Changes
e6cbf73: Fix type information for Config.parsere8aea2f: Fix transitive color transform advanced example, migrate chroma-js to colorjs.io7afcffd: Fix bugs with expand tokens where they would run before instead of after user-configured preprocessors, and would fatally error on broken references. Broken refs should be tolerated at the expand stage, and errors will be thrown after preprocessor lifecycle if the refs are still broken at that point.922b6aa: Update memfs esm-fork dependency to allow named import Volume.61b6984: Fix 'filePath' missing from falsy token values3ae67e3: Upgrade memfs esm fork to publish types and bumping stream to fix unclear licensing issue with transitive dependency.v4.0.0Compare Source
Major Changes
6cc7f31: BREAKING:usesReferenceutil function is nowusesReferencesto be consistent plural form like the other reference util functions.getReferencesfirst and second parameters have been swapped to be consistent withresolveReferences, so value first, then the full token object (instead of the entire dictionary instance).getReferencesaccepts a third options parameter which can be used to set reference Regex options as well as an unfilteredTokens object which can be used as a fallback when references are made to tokens that have been filtered out. There will be warnings logged for this.format.formatterremoved old function signature of(dictionary, platform, file)in favor of({ dictionary, platform, options, file }).Types changes:
.d.tsfiles published next to every file, this means that if you import from one of Style Dictionary's entrypoints, you automatically get the types implicitly with it. This is a big win for people using TypeScript, as the majority of the codebase now has much better types, with much feweranys.index.d.tsanymore that exposes all type interfaces on itself. This means that you can no longer grab types that aren't members of the Style Dictionary class directly from the default export of the main entrypoint. External types such asParser,Transform,DesignTokens, etc. can be imported from the newly added types entrypoint:Please raise an issue if you find anything missing or suddenly broken.
Matcher,Transformer,Formatter, etc. are still available, although no longer directly but rather as properties on their parents, soFilter['matcher'],Transform['transformer'],Format['formatter']dcbe2fb: - The project has been fully converted to ESM format, which is also the format that the browser uses.For users, this means you'll have to either use Style Dictionary in ESM JavaScript code, or dynamically import it into your CommonJS code.
StyleDictionary.extend()method is now asynchronous, which means it returnsPromise<StyleDictionary.Core>instead ofStyleDictionary.Core.allProperties/propertieswas deprecated in v3, and is now removed fromStyleDictionary.Core, useallTokensandtokensinstead.registerTemplatewere deprecated in v3, now removed. Use Formats instead.style-dictionary&style-dictionary/fs. If more is needed, please raise an issue explaining which file you were importing and why you need it to be public API.f2ed88b: BREAKING: File headers, when registered, are put inside thehooks.fileHeadersproperty now, as opposed tofileHeader.Note the change from singular to plural form here.
Before:
After:
79bb201: BREAKING: Logging has been redesigned a fair bit and is more configurable now.Before:
{ "log": "error" // 'error' | 'warn' -> 'warn' is the default value }After:
{ "log": { "warnings": "error", // 'error' | 'warn' -> 'warn' is the default value "verbosity": "verbose", // 'default' | 'verbose' | 'silent' -> 'default' is the default value "errors": { "brokenReferences": "console" // 'console' | 'throw' -> 'throw' is the default value } } }Log is now and object and the old "log" option is now "warnings".
This configures whether the following five warnings will be thrown as errors instead of being logged as warnings:
Verbosity configures whether the following warnings/errors should display in a verbose manner:
And it also configures whether success/neutral logs should be logged at all.
Using "silent" (or --silent in the CLI) means no logs are shown apart from fatal errors.
f2ed88b: BREAKING: Actions, when registered, are put inside thehooks.actionsproperty now, as opposed toaction.Note the change from singular to plural form here.
Before:
After:
a4542f4: BREAKING: StyleDictionaryInstance.properties & .allProperties have been removed. They were deprecated in v3 in favor of .tokens and .allTokens.5e167de: BREAKING: movedformatHelpersaway from the StyleDictionary class and export them in'style-dictionary/utils'entrypoint instead.Before
After
f2ed88b: Filters, when registered, are put inside thehooks.filtersproperty now, as opposed tofilter.Note the change from singular to plural form here.
Before:
After:
In addition, when using
registerFiltermethod, the name of the filter function is nowfilterinstead ofmatcher.Before:
After:
f2ed88b: BREAKING: Transform groups, when registered, are put inside thehooks.transformGroupsproperty now, as opposed totransformGroup.Before:
After:
502dbd1: BREAKING: All of our hooks, parsers, preprocessors, transforms, formats, actions, fileHeaders and filters, support async functions as well now. This means that the formatHelpers -> fileHeader helper method is now asynchronous, to support async fileheader functions.f2ed88b: BREAKING: Formats, when registered, are put inside thehooks.formatsproperty now, as opposed toformat.The
formatterhandler function has been renamed toformatfor consistency.The importable type interfaces have also been renamed,
Formatteris nowFormatFnandFormatterArgumentsis nowFormatFnArguments.Note that you can also use
Format['format']instead ofFormatFn, orParameters<Format['format']>instead ofFormatFnArguments, so these renames may not matter.Before:
After:
e83886c: BREAKING: preprocessors must now also be explicitly applied on global or platform level, rather than only registering it. This is more consistent with how the other hooks work and allows applying it on a platform level rather than only on the global level.preprocessorsproperty that contains the registered preprocessors has been moved under a wrapping property calledhooks.Before:
After:
2f80da2: BREAKING:className,packageName,mapName,type,name,resourceTypeandresourceMapoptions for a bunch of built-in formats have been moved fromfileto go inside thefile.optionsobject, for API consistency reasons.Before:
{ "files": [ { "destination": "tokenmap.scss", "format": "scss/map-deep", "mapName": "tokens" } ] }After:
{ "files": [ { "destination": "tokenmap.scss", "format": "scss/map-deep", "options": { "mapName": "tokens" } } ] }f2ed88b: BREAKING: Transforms, when registered, are put inside thehooks.transformsproperty now, as opposed totransform.The
matcherproperty has been renamed tofilter(to align with the Filter hook change), and thetransformerhandler function has been renamed totransformfor consistency.Before:
After
90095a6: BREAKING: Allow specifying afunctionforoutputReferences, conditionally outputting a ref or not per token. Also exposesoutputReferencesFilterutility function which will determine whether a token should be outputting refs based on whether those referenced tokens were filtered out or not.If you are maintaining a custom format that allows
outputReferencesoption, you'll need to take into account that it can be a function, and pass the correct options to it.Before:
After
122c8f6: BREAKING: expose getReferences and usesReference utilities as standalone utils rather than requiring them to be bound to dictionary object. This makes it easier to use.0b81a08: BREAKING: no longer wraps tokens of type asset in double quotes. Rather, we added a transformasset/urlthat will wrap such tokens insideurl("")statements, this transform is applied to transformGroups scss, css and less.a4542f4: BREAKING: StyleDictionary to be initialized with a new API and have async methods. Use:You can still extend a dictionary instance with an extended config, but
.extend()is only used for this, it is no longer used to initialize the first instance:To ensure your initialized StyleDictionary instance is fully ready and has imported all your tokens, you can await
hasInitialized:For error handling and testing purposes, you can also manually initialize the style-dictionary config:
The main reason for an initialize step after class instantiation is that async constructors are not a thing in JavaScript, and if you return a promise from a constructor to "hack it", TypeScript will eventually trip over it.
Due to being able to dynamically (asynchronously) import ES Modules rather than synchronously require CommonJS modules, we had to make the APIs asynchronous, so the following methods are now async:
In a future release, most other methods will be made async or support async as well, such as parsers, transforms, formats etc.
f2ed88b: BREAKING: Parsers, when registered, are put inside thehooks.parsersproperty now, as opposed toparsers.parsersproperty has been repurposed: you will now also need to explicitly apply registered parsers by name in theparsersproperty, they no longer apply by default.When registering a parser, you must also supply a
nameproperty just like with all other hooks, and theparsefunction has been renamed toparserfor consistency.Before:
After:
bcb5ef3: Remove reliance on CTI token structure across transforms, actions and formats.Breaking changes:
attributes.categoryas the token type indicator.name/cti/casingto justname/casing.name/ti/camelandname/ti/constanthave been removed. For examplename/cti/kebabtransform is nowname/kebab.content/iconhas been renamed tohtml/iconsince it targets HTML entity strings, not just any icon content.font/objC/literal,font/swift/literalandfont/flutter/literalhave been removed in favor offont/objC/literal,font/swift/literalandfont/flutter/literal, as they do he exact same transformations.typescript/module-declarationsformat to be updated with current DesignToken type interface.Before:
{ "color": { "red": { "value": "#FF0000" } } }After:
{ "color": { // <-- this no longer needs to be "color" in order for the tokens inside this group to be considered of type "color" "red": { "value": "#FF0000", "type": "color" } } }7b82150: BREAKING: For formats using thefileHeaderformatHelpersutility, it will no longer display a timestamp in the fileHeader output by default. This is now an opt-in by settingfile.formatting.fileHeaderTimestamptotrue. The reason for making this opt-in now is that using Style Dictionary in the context of a CI (continuous integration) pipeline is a common use-case, and when running on pull request event, output files always show a diff in git due to the timestamp changing, which often just means that the diff is bloated by redundancy.New:
{ "platforms": { "css": { "files": [ { "destination": "variables.css", "format": "css/variables", "options": { "formatting": { "fileHeaderTimestamp": true } } } ] } } }or:
Minor Changes
39f0220: Allow not throwing fatal errors on broken token references/aliases, butconsole.errorinstead.You can also configure this on global/platform
logproperty:{ "log": { "errors": { "brokenReferences": "console" } } }This setting defaults to
"error"when not configured.resolveReferencesandgetReferenceswarnImmediatelyoption is set totruewhich causes an error to be thrown/warned immediately by default, which can be configured tofalseif you know those utils are running in the transform/format hooks respectively, where the errors are collected and grouped, then thrown as 1 error/warning instead of multiple.Some minor grammatical improvements to some of the error logs were also done.
8450a45: Some fixes for Expand utility:dashArrayproperty ofstrokeStyletokens no longer get expanded unintentionally,typeof 'object'check changed toisPlainObjectcheck.styleproperty insidebordertokens) will now also be expanded.This is because if the reference is to an object value, the expansion might break the reference.
c06661d: Re-add and update example basic, fix copySync command in CLI, fix android templates to use $type for DTCG tokens.dcbe2fb: FileSystem that is used by Style Dictionary can now be customized:By default, it uses an in-memory filesystem shim
@bundled-es-modules/memfsin browser context,node:fsbuilt-in module in Node context.3485467: Fix some inconsistencies in some of the templates, usually with regards to spaces/newlines606af51: RenametypeW3CDelegateutility function totypeDtcgDelegate, as using "W3C" is highly discouraged when the standard isn't a W3C standard yet.4225d78: Added the following transforms for CSS, and added them to thescss,cssandlesstransformGroups:fontFamily/css-> wraps font names with spaces in'quotescubicBezier/css-> array value, put insidecubic-bezier()CSS functionstrokeStyle/css/shorthand-> object value, transform to CSS shorthandborder/css/shorthand-> object value, transform to CSS shorthandtypography/css/shorthand-> object value, transform to CSS shorthandtransition/css/shorthand-> object value, transform to CSS shorthandshadow/css/shorthand-> object value (or array of objects), transform to CSS shorthandThe main intention here is to ensure that Style Dictionary is compliant with DTCG draft specification out of the box with regards to exporting to CSS, where object-value tokens are not supported without transforming them to shorthands (or expanding them, which is a different feature that was added in
4.0.0-prerelease.27).cedf8a0: Preprocessors are a new feature added to style-dictionary, which allows you to do any type of processing of the token dictionary after parsing, before resolving and transforming.See preprocessor docs for more information.
cb94554: 'size/rem' transform to not transform tokens that already have a unit, such as"4px", this should not be transformed to"4rem".a4542f4: options.log to be respected in all error logging, including platform specific logs.122c8f6: Expose a new utility called resolveReferences which takes a value containing references, the dictionary object, and resolves the value's references for you.0410295: Improve and test the error handling of standalone usage of reference utilities.8b6fff3: Fixes some noisy warnings still being outputted even when verbosity is set to default.We also added log.warning "disabled" option for turning off warnings altogether, meaning you only get success logs and fatal errors.
This option can be used from the CLI as well using the
--no-warnflag.2da5130: AddedoutputReferencesTransformedutility function to pass into outputReferences option, which will not output references for values that have been transitively transformed.606af51: Support the use of "value"/"type"/"description" as token names or token group names, at the sacrifice of now no longer being able to combine non-DTCG and DTCG syntax within the same token dictionary.7418c97: Add a couple of utilities for converting a regular Style Dictionary tokens object/file(s) to DTCG formatted tokens:convertToDTCGconvertJSONToDTCGconvertZIPToDTCGDocumentation of these utilities
294fd0e: Support Design Token Community Group Draft specification for Design Tokens, by adding support for $value, $type and $description properties.aff6646: Allow passing a custom FileSystem Volume to your Style Dictionary instances, to ensure input/output files are read/written from/to that specific volume.Useful in case you want multiple Style Dictionary instances that are isolated from one another in terms of inputs/outputs.
This also works when using extend:
261a2cb: Handle transition timingFunction prop in cubicBezier/css transform. Handle typography fontFamily prop in fontFamily/css transform.e83886c: Allow expanding tokens on a global or platform-specific level. Supports conditionally expanding per token type, or using a function to determine this per individual token.af5cc94: CreateformatPlatformandformatAllPlatformsmethods.This will return the outputs and destinations from the format hook for your dictionary, without building these outputs and persisting them to the filesystem.
Additionally, formats can now return any data type instead of requiring it to be a
stringanddestinationproperty infilesis now optional.This allows users to create formats intended for only formatting tokens and letting users do stuff with it during runtime rather than writing to files.
c06661d: Re-add and update example basic, fix copySync command in CLI, fix android templates to use $type for DTCG tokens.4556712:Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.