@supernova-studio/model 0.58.27 → 0.59.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.mjs CHANGED
@@ -1769,15 +1769,26 @@ var stringTokenTypes = /* @__PURE__ */ new Set([
1769
1769
  "FontFamily",
1770
1770
  "FontWeight"
1771
1771
  ]);
1772
- function areTokenTypesCompatible(lhs, rhs) {
1772
+ var fallbackNumberValue = 14;
1773
+ function areTokenTypesCompatible(lhs, rhs, isNonCompatibleTypeChangesEnabled = false) {
1773
1774
  if (lhs === rhs)
1774
1775
  return true;
1775
1776
  if (numberTokenTypes.has(lhs) && numberTokenTypes.has(rhs))
1776
1777
  return true;
1777
1778
  if (stringTokenTypes.has(lhs) && stringTokenTypes.has(rhs))
1778
1779
  return true;
1780
+ if (isNonCompatibleTypeChangesEnabled && stringTokenTypes.has(lhs) && numberTokenTypes.has(rhs))
1781
+ return true;
1779
1782
  return false;
1780
1783
  }
1784
+ function castStringToDimensionValue(lhs, rhs, value) {
1785
+ if (stringTokenTypes.has(lhs) && numberTokenTypes.has(rhs) && value) {
1786
+ const newValue = Number.parseFloat(value?.toString() ?? "");
1787
+ const measure = Number.isNaN(newValue) ? fallbackNumberValue : newValue;
1788
+ return { unit: "Pixels", measure };
1789
+ }
1790
+ return value;
1791
+ }
1781
1792
  var DesignElementCategory = z40.enum([
1782
1793
  "Token",
1783
1794
  "Component",
@@ -3384,13 +3395,17 @@ function extractTokenTypedData(source) {
3384
3395
  data: source.data
3385
3396
  };
3386
3397
  }
3387
- function convertTokenTypedData(source, type) {
3388
- if (!areTokenTypesCompatible(source.type, type)) {
3398
+ function convertTokenTypedData(source, type, isNonCompatibleTypeChangesEnabled) {
3399
+ if (!areTokenTypesCompatible(source.type, type, isNonCompatibleTypeChangesEnabled)) {
3389
3400
  throw SupernovaException.invalidOperation(`Cannot convert token from ${source.type} to ${type}`);
3390
3401
  }
3402
+ const data = source.data;
3403
+ if (isNonCompatibleTypeChangesEnabled) {
3404
+ data.value = castStringToDimensionValue(source.type, type, source.data.value);
3405
+ }
3391
3406
  return {
3392
3407
  type,
3393
- data: source.data
3408
+ data
3394
3409
  };
3395
3410
  }
3396
3411
  function isImportedDesignToken(designToken) {
@@ -3687,7 +3702,8 @@ var FigmaImportBaseContext = z91.object({
3687
3702
  var FeatureFlagsKeepAliases = z91.object({
3688
3703
  isTypographyPropsKeepAliasesEnabled: z91.boolean().default(false),
3689
3704
  isGradientPropsKeepAliasesEnabled: z91.boolean().default(false),
3690
- isShadowPropsKeepAliasesEnabled: z91.boolean().default(false)
3705
+ isShadowPropsKeepAliasesEnabled: z91.boolean().default(false),
3706
+ isNonCompatibleTypeChangesEnabled: z91.boolean().default(false)
3691
3707
  });
3692
3708
  var FigmaImportContextWithSourcesState = FigmaImportBaseContext.extend({
3693
3709
  sourcesWithMissingAccess: z91.array(z91.string()).default([]),
@@ -5397,7 +5413,8 @@ var FlaggedFeature = z170.enum([
5397
5413
  "VariablesOrder",
5398
5414
  "TypographyPropsKeepAliases",
5399
5415
  "GradientPropsKeepAliases",
5400
- "ShadowPropsKeepAliases"
5416
+ "ShadowPropsKeepAliases",
5417
+ "NonCompatibleTypeChanges"
5401
5418
  ]);
5402
5419
  var FeatureFlagMap = z170.record(FlaggedFeature, z170.boolean());
5403
5420
  var FeatureFlag = z170.object({
@@ -6184,6 +6201,7 @@ export {
6184
6201
  areShallowObjectsEqual,
6185
6202
  areTokenTypesCompatible,
6186
6203
  buildConstantEnum,
6204
+ castStringToDimensionValue,
6187
6205
  chunkedArray,
6188
6206
  convertTokenTypedData,
6189
6207
  defaultDocumentationItemConfigurationV1,