@moondraft/import 0.1.0 → 0.3.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +2 -2
  3. package/SOURCE.md +343 -4
  4. package/dist/adapter/convert.d.ts +26 -2
  5. package/dist/adapter/convert.js +817 -217
  6. package/dist/adapter/figma-descriptions.d.ts +7 -0
  7. package/dist/adapter/figma-descriptions.js +34 -0
  8. package/dist/adapter/figma-grids.d.ts +12 -0
  9. package/dist/adapter/figma-grids.js +175 -0
  10. package/dist/adapter/figma-handoff.d.ts +34 -0
  11. package/dist/adapter/figma-handoff.js +188 -0
  12. package/dist/adapter/figma-hyperlinks.d.ts +13 -0
  13. package/dist/adapter/figma-hyperlinks.js +77 -0
  14. package/dist/adapter/figma.d.ts +4 -1
  15. package/dist/adapter/figma.js +15 -4
  16. package/dist/adapter/file-components.d.ts +10 -3
  17. package/dist/adapter/file-components.js +126 -33
  18. package/dist/adapter/file-resources.js +545 -47
  19. package/dist/adapter/file-typography.d.ts +6 -0
  20. package/dist/adapter/file-typography.js +44 -0
  21. package/dist/adapter/image-crop.d.ts +18 -0
  22. package/dist/adapter/image-crop.js +30 -0
  23. package/dist/adapter/link.d.ts +12 -1
  24. package/dist/adapter/link.js +380 -113
  25. package/dist/adapter/payload.js +3 -3
  26. package/dist/adapter/variables.d.ts +2 -1
  27. package/dist/adapter/variables.js +5 -2
  28. package/dist/figma-file.d.ts +1 -0
  29. package/dist/figma-file.js +1 -0
  30. package/dist/figma.d.ts +1 -0
  31. package/dist/figma.js +191 -35
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +1 -0
  34. package/dist/report.d.ts +59 -1
  35. package/dist/report.js +176 -30
  36. package/dist/serialize.d.ts +7 -0
  37. package/dist/serialize.js +79 -0
  38. package/dist/taco/figma-import/container/kiwiContainer.d.ts +3 -0
  39. package/dist/taco/figma-import/container/kiwiContainer.js +1 -1
  40. package/dist/taco/figma-import/figFile.js +3 -0
  41. package/dist/taco/figma-import/import/carry.d.ts +14 -1
  42. package/dist/taco/figma-import/import/carry.js +34 -1
  43. package/dist/taco/figma-import/import/componentProps.d.ts +10 -4
  44. package/dist/taco/figma-import/import/componentProps.js +29 -13
  45. package/dist/taco/figma-import/import/componentSets.d.ts +2 -0
  46. package/dist/taco/figma-import/import/componentSets.js +1 -1
  47. package/dist/taco/figma-import/import/converters/effects.d.ts +3 -13
  48. package/dist/taco/figma-import/import/converters/effects.js +4 -34
  49. package/dist/taco/figma-import/import/converters/exportSettings.d.ts +4 -0
  50. package/dist/taco/figma-import/import/converters/exportSettings.js +75 -0
  51. package/dist/taco/figma-import/import/converters/frame.d.ts +1 -1
  52. package/dist/taco/figma-import/import/converters/frame.js +15 -6
  53. package/dist/taco/figma-import/import/converters/gradient.d.ts +2 -0
  54. package/dist/taco/figma-import/import/converters/gradient.js +3 -1
  55. package/dist/taco/figma-import/import/converters/grid.d.ts +12 -0
  56. package/dist/taco/figma-import/import/converters/grid.js +97 -0
  57. package/dist/taco/figma-import/import/converters/group.d.ts +2 -4
  58. package/dist/taco/figma-import/import/converters/group.js +6 -15
  59. package/dist/taco/figma-import/import/converters/image.d.ts +2 -1
  60. package/dist/taco/figma-import/import/converters/image.js +60 -16
  61. package/dist/taco/figma-import/import/converters/layout.d.ts +8 -7
  62. package/dist/taco/figma-import/import/converters/layout.js +66 -37
  63. package/dist/taco/figma-import/import/converters/rectangle.d.ts +1 -1
  64. package/dist/taco/figma-import/import/converters/rectangle.js +3 -3
  65. package/dist/taco/figma-import/import/converters/section.d.ts +2 -3
  66. package/dist/taco/figma-import/import/converters/section.js +5 -11
  67. package/dist/taco/figma-import/import/converters/shared.d.ts +9 -5
  68. package/dist/taco/figma-import/import/converters/shared.js +23 -10
  69. package/dist/taco/figma-import/import/converters/text.d.ts +38 -1
  70. package/dist/taco/figma-import/import/converters/text.js +248 -32
  71. package/dist/taco/figma-import/import/converters/vector.d.ts +36 -15
  72. package/dist/taco/figma-import/import/converters/vector.js +214 -73
  73. package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +19 -3
  74. package/dist/taco/figma-import/import/converters/vectorNetwork.js +147 -29
  75. package/dist/taco/figma-import/import/instances.d.ts +32 -5
  76. package/dist/taco/figma-import/import/instances.js +613 -130
  77. package/dist/taco/figma-import/import/styles.d.ts +2 -0
  78. package/dist/taco/figma-import/import/styles.js +6 -0
  79. package/dist/taco/figma-import/import/types.d.ts +8 -0
  80. package/dist/taco/figma-import/import/variables.d.ts +5 -2
  81. package/dist/taco/figma-import/import/variables.js +65 -31
  82. package/dist/taco/figma-import/import/variantTrees.d.ts +1 -1
  83. package/dist/taco/figma-import/import/variantTrees.js +46 -4
  84. package/dist/taco/figma-import/import/walk.d.ts +62 -7
  85. package/dist/taco/figma-import/import/walk.js +328 -122
  86. package/dist/taco/figma-import/kiwi/message.d.ts +4 -2
  87. package/dist/taco/figma-import/kiwi/message.js +59 -15
  88. package/dist/taco/model/codec.d.ts +2 -2
  89. package/dist/taco/model/codec.js +72 -8
  90. package/dist/taco/model/component-evaluation.d.ts +2 -0
  91. package/dist/taco/model/component-evaluation.js +7 -0
  92. package/dist/taco/model/instance-resolver.d.ts +6 -2
  93. package/dist/taco/model/instance-resolver.js +50 -18
  94. package/dist/taco/model/sha256.js +13 -8
  95. package/dist/taco/model/types.d.ts +57 -5
  96. package/dist/taco/model/types.js +4 -0
  97. package/dist/taco/svg-import/style/computed.js +1 -0
  98. package/package.json +3 -2
@@ -166,9 +166,10 @@ export interface PaintVisibility {
166
166
  */
167
167
  readonly visible?: boolean;
168
168
  /**
169
- * How the paint blends with the paints below it on the same layer: the
170
- * fills under a fill, or the fills and strokes under a stroke. Uses the
171
- * same modes as a node's `blendMode`. Defaults to `"normal"`.
169
+ * How the paint blends with what is below it: the paints under it on the
170
+ * same layer (the fills under a fill, or the fills and strokes under a
171
+ * stroke) and the layers behind. Uses the same modes as a node's
172
+ * `blendMode`. Defaults to `"normal"`.
172
173
  * @since 0.18.0
173
174
  */
174
175
  readonly blendMode?: BlendMode;
@@ -456,6 +457,11 @@ export interface TextStyle {
456
457
  * @since 0.2.0
457
458
  */
458
459
  readonly strikethrough?: boolean;
460
+ /**
461
+ * Case the glyphs are drawn in, leaving the characters as typed. `original` draws them as typed.
462
+ * @since 0.2.1
463
+ */
464
+ readonly textCase?: TextCase;
459
465
  /**
460
466
  * Explicit deviations from a font's OpenType feature defaults.
461
467
  * @since 0.2.0
@@ -467,6 +473,8 @@ export interface TextStyle {
467
473
  */
468
474
  readonly fontVariations?: Readonly<Record<string, number>>;
469
475
  }
476
+ /** A text style's case transform of the drawn glyphs. */
477
+ export type TextCase = "original" | "upper" | "lower" | "title" | "smallCaps" | "smallCapsForced";
470
478
  /**
471
479
  * Direct text formatting authored on one run or list marker.
472
480
  *
@@ -635,8 +643,19 @@ export interface StackAutoLayout extends AutoLayoutConstraints {
635
643
  */
636
644
  readonly alignContent?: "auto" | "space-between";
637
645
  }
646
+ export type GridTrack = {
647
+ kind: "fixed";
648
+ size: number;
649
+ } | {
650
+ kind: "auto";
651
+ } | {
652
+ kind: "fill";
653
+ weight?: number;
654
+ };
638
655
  export interface GridAutoLayout extends AutoLayoutConstraints {
639
656
  readonly kind: "grid";
657
+ readonly rowTracks?: readonly GridTrack[];
658
+ readonly columnTracks?: readonly GridTrack[];
640
659
  readonly columns: number;
641
660
  readonly columnGap: number;
642
661
  readonly rowGap: number;
@@ -646,9 +665,11 @@ export type AutoLayout = StackAutoLayout | GridAutoLayout;
646
665
  export type Layout = AbsoluteLayout | AutoLayout;
647
666
  /**
648
667
  * Separable and non-separable compositing modes, in CSS `mix-blend-mode` terms.
668
+ * `plus-lighter` (Figma's linear dodge) and `plus-darker` (linear burn) are
669
+ * node modes only; the importers never give them to a paint.
649
670
  * @since 0.8.0
650
671
  */
651
- export declare const BLEND_MODES: readonly ["normal", "darken", "multiply", "color-burn", "lighten", "screen", "color-dodge", "overlay", "soft-light", "hard-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
672
+ export declare const BLEND_MODES: readonly ["normal", "darken", "multiply", "color-burn", "lighten", "screen", "color-dodge", "overlay", "soft-light", "hard-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity", "plus-lighter", "plus-darker"];
652
673
  export type BlendMode = (typeof BLEND_MODES)[number];
653
674
  /**
654
675
  * File formats a layer can export to.
@@ -972,6 +993,14 @@ export interface GroupNode extends FramedNodeBase {
972
993
  /** A span of text sharing one style. */
973
994
  export interface TextRun {
974
995
  readonly text: string;
996
+ /** A web address or a target GUID to resolve when adapting a Figma document. */
997
+ readonly hyperlink?: {
998
+ readonly kind: "url";
999
+ readonly url: string;
1000
+ } | {
1001
+ readonly kind: "target";
1002
+ readonly guid: string;
1003
+ };
975
1004
  /** The theme text style; the theme's `defaultTextStyleId` when omitted. */
976
1005
  readonly styleId?: TextStyleId;
977
1006
  /** Direct formatting on top of the style. */
@@ -1031,6 +1060,10 @@ export interface TextNode extends FramedNodeBase {
1031
1060
  * @since 0.40.0
1032
1061
  */
1033
1062
  readonly paragraphSpacing?: number;
1063
+ /** The most lines drawn, a positive integer; every line when left out. */
1064
+ readonly maxLines?: number;
1065
+ /** `ellipsis` ends the last drawn line with an ellipsis when `maxLines` hides lines. */
1066
+ readonly truncate?: "ellipsis";
1034
1067
  }
1035
1068
  /** Nodes that hold editable rich text. Currently only `TextNode`. */
1036
1069
  export type TextualNode = TextNode;
@@ -1702,7 +1735,7 @@ export type LayerOverrideVariableBindings = Readonly<Partial<Record<VariableProp
1702
1735
  * The changes one instance makes to one layer of its component, stored in
1703
1736
  * `InstanceNode.overrides` under the layer's path. Every field replaces the
1704
1737
  * layer's resolved value as a whole (`padding` side by side, `textStyle` member by member); a field that is
1705
- * absent follows the component. Structure (layers, layout kind and gaps, geometry of inner
1738
+ * absent follows the component. Structure (layers, geometry of inner
1706
1739
  * layers, masks, blend modes) is not overridable: that needs an edit to the
1707
1740
  * component, or Detach.
1708
1741
  *
@@ -1769,6 +1802,10 @@ export interface LayerOverride {
1769
1802
  * @since 0.36.0
1770
1803
  */
1771
1804
  readonly textAlign?: TextParagraph["align"];
1805
+ /** Text: the layer's `maxLines`; `null` takes the component's away. */
1806
+ readonly maxLines?: number | null;
1807
+ /** Text: the layer's `truncate`; `null` takes the component's away. */
1808
+ readonly truncate?: "ellipsis" | null;
1772
1809
  /** Frames and shapes: the node style to use; `null` clears the layer's. */
1773
1810
  readonly styleId?: NodeStyleId | null;
1774
1811
  readonly fills?: readonly Paint[];
@@ -1780,6 +1817,21 @@ export interface LayerOverride {
1780
1817
  readonly imageAssetId?: AssetId;
1781
1818
  /** Nested instance layers: the component to show instead (a swap). */
1782
1819
  readonly componentId?: ComponentId;
1820
+ readonly clipContent?: boolean;
1821
+ readonly cornerSmoothing?: number;
1822
+ /** Per-member stack settings. Padding sides and sizing axes have their own overrides. */
1823
+ readonly layout?: Partial<Omit<StackAutoLayout, "kind" | "padding" | "widthSizing" | "heightSizing">> & Partial<Pick<GridAutoLayout, "columns" | "rowTracks" | "columnTracks" | "rowGap" | "columnGap">> & {
1824
+ readonly kind?: Layout["kind"];
1825
+ };
1826
+ /** Cell settings authored on a grid child in this occurrence. */
1827
+ readonly gridCell?: {
1828
+ row?: number;
1829
+ column?: number;
1830
+ rowSpan?: number;
1831
+ columnSpan?: number;
1832
+ alignX?: "start" | "center" | "end" | "stretch";
1833
+ alignY?: "start" | "center" | "end" | "stretch";
1834
+ };
1783
1835
  /** Frame layers, and the component root for the instance's own size. */
1784
1836
  readonly sizing?: LayerSizingOverride;
1785
1837
  /**
@@ -77,6 +77,8 @@ export const DASH_CAPS = ["none", "round", "square"];
77
77
  export const DEFAULT_STROKE_MITER_ANGLE = (2 * Math.asin(1 / 4) * 180) / Math.PI;
78
78
  /**
79
79
  * Separable and non-separable compositing modes, in CSS `mix-blend-mode` terms.
80
+ * `plus-lighter` (Figma's linear dodge) and `plus-darker` (linear burn) are
81
+ * node modes only; the importers never give them to a paint.
80
82
  * @since 0.8.0
81
83
  */
82
84
  export const BLEND_MODES = [
@@ -96,6 +98,8 @@ export const BLEND_MODES = [
96
98
  "saturation",
97
99
  "color",
98
100
  "luminosity",
101
+ "plus-lighter",
102
+ "plus-darker",
99
103
  ];
100
104
  /**
101
105
  * File formats a layer can export to.
@@ -99,6 +99,7 @@ const BLEND_MODES = new Set([
99
99
  "normal", "darken", "multiply", "color-burn", "lighten", "screen",
100
100
  "color-dodge", "overlay", "soft-light", "hard-light", "difference",
101
101
  "exclusion", "hue", "saturation", "color", "luminosity",
102
+ "plus-lighter", "plus-darker",
102
103
  ]);
103
104
  /** Each `overflow` keyword, and whether it draws content outside the viewport. */
104
105
  const OVERFLOW_VISIBLE = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moondraft/import",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Editable SVG and Figma import for Moondraft.",
6
6
  "sideEffects": false,
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@chenglou/pretext": "0.0.8",
33
+ "entities": "6.0.1",
33
34
  "fflate": "0.8.3",
34
35
  "fzstd": "0.1.1",
35
36
  "svg-pathdata": "9.0.0"
@@ -51,6 +52,6 @@
51
52
  "access": "public"
52
53
  },
53
54
  "peerDependencies": {
54
- "@moondraft/editor": ">=0.3.0 <0.4.0"
55
+ "@moondraft/editor": ">=0.5.0 <0.6.0"
55
56
  }
56
57
  }