@open-pencil/scene-graph 0.16.0 → 0.17.0-beta.1
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/arrow-caps.d.ts +35 -14
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +289 -55
- package/dist/arrow-caps.js.map +1 -1
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +56 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +42 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +45 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +149 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +114 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +71 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/spec.js +4 -28
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +13 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +17 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/{chunks/color → color}/contrast.js +2 -24
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/document.js +2 -1
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/merge.js +1 -1
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/{chunks/comments/list.js → comments/threads.js} +3 -53
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/properties.d.ts +20 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +125 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +27 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +53 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +159 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +208 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +11 -2
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +94 -2
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +268 -1
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +49 -2
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +270 -2
- package/dist/copy.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/{chunks/css → css}/grid.js +2 -33
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +6 -0
- package/dist/css/index.js +6 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +12 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +22 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +63 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +259 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +411 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +70 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +95 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +44 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +58 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +27 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +38 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +118 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +233 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +105 -2
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +374 -2
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +9 -2
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +13 -1
- package/dist/gradient.js.map +1 -1
- package/dist/graph.d.ts +177 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +613 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/{chunks/group-bounds.js → group-bounds.js} +56 -14
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +19 -2
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts +48 -2
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +34 -29
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/{chunks/icons → icons}/glyph.js +2 -40
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -2
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +67 -9
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -23
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +161 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +82 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +40 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +174 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/main-component.d.ts +11 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +42 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/overrides.d.ts +48 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +142 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/sync.js +275 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/{layout.js → layout/index.js} +4 -3
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +59 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -2
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +119 -1
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/node-defaults.d.ts +22 -2
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +254 -2
- package/dist/node-defaults.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +77 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +56 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +9 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +39 -2
- package/dist/parse-path.js.map +1 -1
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +73 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +142 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +153 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +3 -0
- package/dist/plugin-data/index.js +3 -0
- package/dist/polygon.d.ts +4 -2
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +17 -2
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +12 -2
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +62 -1
- package/dist/preview.js.map +1 -0
- package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.js +24 -1
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +6 -4
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +287 -2
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +148 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +7 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +47 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/shaders/index.d.ts +4 -0
- package/dist/shaders/index.js +4 -0
- package/dist/shaders/model.d.ts +41 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +71 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +41 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +36 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +38 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +125 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +77 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +103 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +38 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +113 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +21 -2
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +109 -1
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.js +10 -1
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/{text-direction.d.ts → text/direction.d.ts} +2 -2
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/{text-direction.js → text/direction.js} +1 -1
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +19 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +40 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/{text-picture.d.ts → text/picture.d.ts} +2 -2
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +41 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +8 -0
- package/dist/transfer/index.js +8 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +74 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +169 -2007
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +89 -2
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -2
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +235 -1
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +60 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +224 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +25 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +69 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +223 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +16 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +49 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/vector-network.d.ts +65 -2
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +375 -2
- package/dist/vector-network.js.map +1 -0
- package/package.json +297 -137
- package/src/arrow-caps.ts +282 -62
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/layers.ts +1 -1
- package/src/behaviours/model.ts +3 -11
- package/src/behaviours/schema.ts +44 -9
- package/src/behaviours/spec.ts +4 -49
- package/src/checkpoint.ts +1 -1
- package/src/clipping.ts +112 -0
- package/src/color/index.ts +1 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +1 -1
- package/src/comments/index.ts +5 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +1 -1
- package/src/components/exposure.ts +1 -1
- package/src/components/index.ts +8 -0
- package/src/components/properties.ts +2 -2
- package/src/components/variants.ts +1 -1
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +60 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +144 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +203 -0
- package/src/coordinate.ts +10 -3
- package/src/copy.ts +63 -17
- package/src/css/index.ts +1 -0
- package/src/css/text.ts +84 -0
- package/src/export-format.ts +1 -1
- package/src/fields/appearance.ts +35 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +29 -0
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +445 -0
- package/src/figjam/text.ts +83 -0
- package/src/font-style.ts +58 -14
- package/src/generated/index.ts +76 -0
- package/src/generated/kind.ts +24 -0
- package/src/generated/shape-with-text.ts +131 -0
- package/src/generated/sticky.ts +213 -0
- package/src/geometry.ts +40 -130
- package/src/gradient.ts +14 -0
- package/src/graph.ts +825 -0
- package/src/group-bounds.ts +59 -12
- package/src/guides.ts +1 -1
- package/src/hit-test.ts +52 -21
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +9 -0
- package/src/icons/schema.ts +19 -3
- package/src/ids.ts +34 -0
- package/src/images.ts +71 -8
- package/src/index.ts +2 -976
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +23 -2
- package/src/instances/copies.ts +7 -10
- package/src/instances/cycles.ts +1 -1
- package/src/instances/fields.ts +39 -92
- package/src/{instances.ts → instances/index.ts} +13 -15
- package/src/instances/main-component.ts +43 -1
- package/src/{instance-overrides.ts → instances/overrides.ts} +31 -1
- package/src/instances/placement.ts +1 -1
- package/src/instances/source-walk.ts +3 -9
- package/src/instances/sync.ts +30 -140
- package/src/instances/vector-geometry.ts +3 -3
- package/src/layout/aspect-ratio.ts +1 -1
- package/src/layout/sizing.ts +1 -1
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +1 -1
- package/src/mutation-impact.ts +1 -1
- package/src/node-defaults.ts +41 -2
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +67 -0
- package/src/parse-path.ts +49 -4
- package/src/plugin-data/fields.ts +54 -75
- package/src/plugin-data/index.ts +2 -0
- package/src/polygon.ts +17 -0
- package/src/preview.ts +1 -1
- package/src/{primitives.ts → primitives/index.ts} +2 -0
- package/src/primitives/schema.ts +14 -0
- package/src/resize.ts +32 -6
- package/src/scaling/node.ts +10 -6
- package/src/scaling/tree.ts +2 -1
- package/src/shaders/index.ts +3 -0
- package/src/shaders/schema.ts +3 -3
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +89 -18
- package/src/slots/authoring.ts +1 -1
- package/src/slots/content.ts +8 -5
- package/src/slots/frames.ts +3 -3
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +1 -1
- package/src/snap.ts +3 -1
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/index.ts +3 -0
- package/src/text/lengths.ts +34 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +1 -1
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/history.ts +1 -1
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +11 -14
- package/src/transfer/plan.ts +1 -1
- package/src/transfer/remove.ts +1 -1
- package/src/transfer/validation.ts +1 -1
- package/src/transfer/variables.ts +7 -6
- package/src/types.ts +218 -13
- package/src/undo.ts +64 -2
- package/src/variables/bindings.ts +44 -55
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +38 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/{variables.ts → variables/index.ts} +52 -145
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +51 -0
- package/src/variables/token.ts +27 -1
- package/src/variables/value.ts +92 -0
- package/src/vector-network.ts +263 -22
- package/dist/chunks/asset-keys.js.map +0 -1
- package/dist/chunks/behaviours/kinds.js.map +0 -1
- package/dist/chunks/behaviours/layers.js +0 -611
- package/dist/chunks/behaviours/layers.js.map +0 -1
- package/dist/chunks/behaviours/spec.js.map +0 -1
- package/dist/chunks/bindings.js.map +0 -1
- package/dist/chunks/buffered-events.js.map +0 -1
- package/dist/chunks/checkpoint.js.map +0 -1
- package/dist/chunks/color/contrast.js.map +0 -1
- package/dist/chunks/color/index.js +0 -1662
- package/dist/chunks/color/index.js.map +0 -1
- package/dist/chunks/comments/document.js.map +0 -1
- package/dist/chunks/comments/list.js.map +0 -1
- package/dist/chunks/comments/merge.js.map +0 -1
- package/dist/chunks/components/exposure.js +0 -2291
- package/dist/chunks/components/exposure.js.map +0 -1
- package/dist/chunks/components/variants.js.map +0 -1
- package/dist/chunks/coordinate.js +0 -385
- package/dist/chunks/coordinate.js.map +0 -1
- package/dist/chunks/css/grid.js.map +0 -1
- package/dist/chunks/css/index.js +0 -160
- package/dist/chunks/css/index.js.map +0 -1
- package/dist/chunks/events.js.map +0 -1
- package/dist/chunks/fields/geometry.js.map +0 -1
- package/dist/chunks/font-style.js +0 -96
- package/dist/chunks/font-style.js.map +0 -1
- package/dist/chunks/group-bounds.js.map +0 -1
- package/dist/chunks/icons/glyph.js.map +0 -1
- package/dist/chunks/index.js +0 -2430
- package/dist/chunks/index.js.map +0 -1
- package/dist/color.d.ts +0 -78
- package/dist/color.d.ts.map +0 -1
- package/dist/color.js +0 -3
- package/dist/constants2.d.ts +0 -11
- package/dist/constants2.d.ts.map +0 -1
- package/dist/css.d.ts +0 -39
- package/dist/css.d.ts.map +0 -1
- package/dist/css.js +0 -3
- package/dist/images2.d.ts +0 -16
- package/dist/images2.d.ts.map +0 -1
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +0 -2
- package/dist/layout.d.ts +0 -2
- package/dist/matrix2.d.ts +0 -16
- package/dist/matrix2.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -2
- package/dist/primitives.js +0 -0
- package/dist/primitives2.d.ts.map +0 -1
- package/dist/text-direction.d.ts.map +0 -1
- package/dist/text-direction.js.map +0 -1
- package/dist/text-picture.d.ts.map +0 -1
- package/dist/text-picture.js +0 -2
- package/dist/text.d.ts +0 -2
- package/dist/text.js +0 -3
- package/dist/types2.d.ts +0 -2
- package/dist/undo2.d.ts +0 -73
- package/dist/undo2.d.ts.map +0 -1
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -2
- /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
- /package/dist/{chunks/behaviours → behaviours}/kinds.js +0 -0
- /package/dist/{chunks/bindings.js → bindings.js} +0 -0
- /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
- /package/dist/{chunks/checkpoint.js → checkpoint.js} +0 -0
- /package/dist/{chunks/components → components}/variants.js +0 -0
- /package/dist/{chunks/events.js → events.js} +0 -0
- /package/dist/{chunks/fields → fields}/geometry.js +0 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { omit } from 'es-toolkit'
|
|
2
|
+
|
|
3
|
+
import { parseColor } from '../color'
|
|
4
|
+
import { BLACK, WHITE } from '../constants'
|
|
5
|
+
import type { Color } from '../primitives'
|
|
6
|
+
import type { Fill, SceneNode, Stroke } from '../types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* FigJam's board palette, in its menus' order, as its colour menu paints a shape with text: each
|
|
10
|
+
* fill pairs with a darker stroke, a light label on the darkest fills, and, made transparent, a
|
|
11
|
+
* lighter fill and its own stroke. Its line menu and connectors take the fills as line colours, and
|
|
12
|
+
* a section takes a pale tint of each with the colour itself as its outline.
|
|
13
|
+
*/
|
|
14
|
+
const PALETTE = {
|
|
15
|
+
black: {
|
|
16
|
+
fill: '#1e1e1e',
|
|
17
|
+
stroke: '#242424',
|
|
18
|
+
lightLabel: true,
|
|
19
|
+
transparent: 0.5,
|
|
20
|
+
transparentStroke: '#929292',
|
|
21
|
+
sectionFill: '#dddddd',
|
|
22
|
+
sectionStroke: '#2c2c2c'
|
|
23
|
+
},
|
|
24
|
+
darkGray: {
|
|
25
|
+
fill: '#757575',
|
|
26
|
+
stroke: '#424242',
|
|
27
|
+
lightLabel: true,
|
|
28
|
+
transparent: 0.5,
|
|
29
|
+
transparentStroke: '#a1a1a1',
|
|
30
|
+
sectionFill: '#eaeaea',
|
|
31
|
+
sectionStroke: '#757575'
|
|
32
|
+
},
|
|
33
|
+
red: {
|
|
34
|
+
fill: '#f24822',
|
|
35
|
+
stroke: '#bd2915',
|
|
36
|
+
lightLabel: true,
|
|
37
|
+
transparent: 0.5,
|
|
38
|
+
transparentStroke: '#c7968f',
|
|
39
|
+
sectionFill: '#ffe2e0',
|
|
40
|
+
sectionStroke: '#f24822'
|
|
41
|
+
},
|
|
42
|
+
orange: {
|
|
43
|
+
fill: '#ff9e42',
|
|
44
|
+
stroke: '#eb7500',
|
|
45
|
+
lightLabel: false,
|
|
46
|
+
transparent: 0.5,
|
|
47
|
+
transparentStroke: '#e9b780',
|
|
48
|
+
sectionFill: '#ffead6',
|
|
49
|
+
sectionStroke: '#ff9e42'
|
|
50
|
+
},
|
|
51
|
+
yellow: {
|
|
52
|
+
fill: '#ffc943',
|
|
53
|
+
stroke: '#e8a302',
|
|
54
|
+
lightLabel: false,
|
|
55
|
+
transparent: 0.5,
|
|
56
|
+
transparentStroke: '#f5d280',
|
|
57
|
+
sectionFill: '#fff3d6',
|
|
58
|
+
sectionStroke: '#ffc943'
|
|
59
|
+
},
|
|
60
|
+
green: {
|
|
61
|
+
fill: '#66d575',
|
|
62
|
+
stroke: '#3e9b4b',
|
|
63
|
+
lightLabel: false,
|
|
64
|
+
transparent: 0.5,
|
|
65
|
+
transparentStroke: '#80c79e',
|
|
66
|
+
sectionFill: '#ddf8e2',
|
|
67
|
+
sectionStroke: '#66d575'
|
|
68
|
+
},
|
|
69
|
+
teal: {
|
|
70
|
+
fill: '#5ad8cc',
|
|
71
|
+
stroke: '#369e94',
|
|
72
|
+
lightLabel: false,
|
|
73
|
+
transparent: 0.5,
|
|
74
|
+
transparentStroke: '#80c9c6',
|
|
75
|
+
sectionFill: '#defcfa',
|
|
76
|
+
sectionStroke: '#5ad8cc'
|
|
77
|
+
},
|
|
78
|
+
blue: {
|
|
79
|
+
fill: '#3dadff',
|
|
80
|
+
stroke: '#007ad2',
|
|
81
|
+
lightLabel: true,
|
|
82
|
+
transparent: 0.7,
|
|
83
|
+
transparentStroke: '#4d99d3',
|
|
84
|
+
sectionFill: '#dbf0ff',
|
|
85
|
+
sectionStroke: '#3dadff'
|
|
86
|
+
},
|
|
87
|
+
violet: {
|
|
88
|
+
fill: '#874fff',
|
|
89
|
+
stroke: '#5427b4',
|
|
90
|
+
lightLabel: true,
|
|
91
|
+
transparent: 0.5,
|
|
92
|
+
transparentStroke: '#a792d0',
|
|
93
|
+
sectionFill: '#eae1ff',
|
|
94
|
+
sectionStroke: '#874fff'
|
|
95
|
+
},
|
|
96
|
+
pink: {
|
|
97
|
+
fill: '#f849c1',
|
|
98
|
+
stroke: '#b42487',
|
|
99
|
+
lightLabel: true,
|
|
100
|
+
transparent: 0.5,
|
|
101
|
+
transparentStroke: '#ce92bb',
|
|
102
|
+
sectionFill: '#ffd6f2',
|
|
103
|
+
sectionStroke: '#f849c1'
|
|
104
|
+
},
|
|
105
|
+
white: {
|
|
106
|
+
fill: '#ffffff',
|
|
107
|
+
stroke: '#757575',
|
|
108
|
+
lightLabel: false,
|
|
109
|
+
transparent: 0.5,
|
|
110
|
+
transparentStroke: '#f1f1f1',
|
|
111
|
+
sectionFill: '#ffffff',
|
|
112
|
+
sectionStroke: '#e6e6e6'
|
|
113
|
+
},
|
|
114
|
+
gray: {
|
|
115
|
+
fill: '#b3b3b3',
|
|
116
|
+
stroke: '#797979',
|
|
117
|
+
lightLabel: false,
|
|
118
|
+
transparent: 0.5,
|
|
119
|
+
transparentStroke: '#bcbcbc',
|
|
120
|
+
sectionFill: '#f4f4f4',
|
|
121
|
+
sectionStroke: '#b3b3b3'
|
|
122
|
+
},
|
|
123
|
+
lightGray: {
|
|
124
|
+
fill: '#d9d9d9',
|
|
125
|
+
stroke: '#a5a5a5',
|
|
126
|
+
lightLabel: false,
|
|
127
|
+
transparent: 0.7,
|
|
128
|
+
transparentStroke: '#c0c0c0',
|
|
129
|
+
sectionFill: '#f9f9f9',
|
|
130
|
+
sectionStroke: '#d9d9d9'
|
|
131
|
+
},
|
|
132
|
+
lightRed: {
|
|
133
|
+
fill: '#ffc7c2',
|
|
134
|
+
stroke: '#f24822',
|
|
135
|
+
lightLabel: false,
|
|
136
|
+
transparent: 0.7,
|
|
137
|
+
transparentStroke: '#ff9d8f',
|
|
138
|
+
sectionFill: '#fff5f5',
|
|
139
|
+
sectionStroke: '#ffc7c2'
|
|
140
|
+
},
|
|
141
|
+
lightOrange: {
|
|
142
|
+
fill: '#ffe0c2',
|
|
143
|
+
stroke: '#ff9e42',
|
|
144
|
+
lightLabel: false,
|
|
145
|
+
transparent: 0.7,
|
|
146
|
+
transparentStroke: '#f6c34d',
|
|
147
|
+
sectionFill: '#fff7f0',
|
|
148
|
+
sectionStroke: '#ffe0c2'
|
|
149
|
+
},
|
|
150
|
+
lightYellow: {
|
|
151
|
+
fill: '#ffecbd',
|
|
152
|
+
stroke: '#ffc943',
|
|
153
|
+
lightLabel: false,
|
|
154
|
+
transparent: 0.7,
|
|
155
|
+
transparentStroke: '#efd54d',
|
|
156
|
+
sectionFill: '#fffbf0',
|
|
157
|
+
sectionStroke: '#ffecbd'
|
|
158
|
+
},
|
|
159
|
+
lightGreen: {
|
|
160
|
+
fill: '#cdf4d3',
|
|
161
|
+
stroke: '#66d575',
|
|
162
|
+
lightLabel: false,
|
|
163
|
+
transparent: 0.7,
|
|
164
|
+
transparentStroke: '#a8d7b4',
|
|
165
|
+
sectionFill: '#ebffee',
|
|
166
|
+
sectionStroke: '#cdf4d3'
|
|
167
|
+
},
|
|
168
|
+
lightTeal: {
|
|
169
|
+
fill: '#c6faf6',
|
|
170
|
+
stroke: '#5ad8cc',
|
|
171
|
+
lightLabel: false,
|
|
172
|
+
transparent: 0.5,
|
|
173
|
+
transparentStroke: '#bcebeb',
|
|
174
|
+
sectionFill: '#f1fefd',
|
|
175
|
+
sectionStroke: '#c6faf6'
|
|
176
|
+
},
|
|
177
|
+
lightBlue: {
|
|
178
|
+
fill: '#c2e5ff',
|
|
179
|
+
stroke: '#3dadff',
|
|
180
|
+
lightLabel: false,
|
|
181
|
+
transparent: 0.7,
|
|
182
|
+
transparentStroke: '#76ccff',
|
|
183
|
+
sectionFill: '#f5fbff',
|
|
184
|
+
sectionStroke: '#c2e5ff'
|
|
185
|
+
},
|
|
186
|
+
lightViolet: {
|
|
187
|
+
fill: '#dcccff',
|
|
188
|
+
stroke: '#874fff',
|
|
189
|
+
lightLabel: false,
|
|
190
|
+
transparent: 0.7,
|
|
191
|
+
transparentStroke: '#d5a3ff',
|
|
192
|
+
sectionFill: '#f8f5ff',
|
|
193
|
+
sectionStroke: '#dcccff'
|
|
194
|
+
},
|
|
195
|
+
lightPink: {
|
|
196
|
+
fill: '#ffc2ec',
|
|
197
|
+
stroke: '#f849c1',
|
|
198
|
+
lightLabel: false,
|
|
199
|
+
transparent: 0.5,
|
|
200
|
+
transparentStroke: '#ffaaeb',
|
|
201
|
+
sectionFill: '#fff0fa',
|
|
202
|
+
sectionStroke: '#ffc2ec'
|
|
203
|
+
}
|
|
204
|
+
} as const
|
|
205
|
+
|
|
206
|
+
export type FigJamColorName = keyof typeof PALETTE
|
|
207
|
+
|
|
208
|
+
export const FIGJAM_COLOR_NAMES = Object.keys(PALETTE) as FigJamColorName[]
|
|
209
|
+
|
|
210
|
+
/** How a shape's colour fills it: solid, see-through, or not at all, as FigJam's menu sets it. */
|
|
211
|
+
export type FigJamFillMode = 'fill' | 'transparent' | 'none'
|
|
212
|
+
|
|
213
|
+
/** How a shape's outline is drawn, as FigJam's line menu sets it. */
|
|
214
|
+
export type FigJamLineStyle = 'solid' | 'dashed' | 'none'
|
|
215
|
+
|
|
216
|
+
/** The dash FigJam's line menu draws a shape's outline with. */
|
|
217
|
+
export const FIGJAM_SHAPE_DASH = [16, 10] as const
|
|
218
|
+
|
|
219
|
+
/** A palette colour as a colour. */
|
|
220
|
+
export function figJamColor(name: FigJamColorName): Color {
|
|
221
|
+
return parseColor(PALETTE[name].fill)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function sameColor(a: Color | undefined, b: Color): boolean {
|
|
225
|
+
if (!a) return false
|
|
226
|
+
const close = (x: number, y: number) => Math.abs(x - y) < 1 / 512
|
|
227
|
+
return close(a.r, b.r) && close(a.g, b.g) && close(a.b, b.b)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The palette colour a paint is, if any. */
|
|
231
|
+
export function figJamColorName(color: Color | undefined): FigJamColorName | null {
|
|
232
|
+
return FIGJAM_COLOR_NAMES.find((name) => sameColor(color, figJamColor(name))) ?? null
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The palette colour an outline is drawn in: a colour itself, or the outline a section of that
|
|
237
|
+
* colour takes, which is darker for black and lighter for white.
|
|
238
|
+
*/
|
|
239
|
+
export function figJamOutlineColorName(color: Color | undefined): FigJamColorName | null {
|
|
240
|
+
return (
|
|
241
|
+
figJamColorName(color) ??
|
|
242
|
+
FIGJAM_COLOR_NAMES.find((name) => sameColor(color, parseColor(PALETTE[name].sectionStroke))) ??
|
|
243
|
+
null
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** The fill mode a shape's first fill shows. */
|
|
248
|
+
export function figJamFillMode(fill: Fill | undefined): FigJamFillMode {
|
|
249
|
+
if (!fill || !fill.visible || fill.opacity === 0) return 'none'
|
|
250
|
+
return fill.opacity < 1 ? 'transparent' : 'fill'
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The outline FigJam pairs with a colour in a fill mode. */
|
|
254
|
+
export function figJamPairedStroke(name: FigJamColorName, mode: FigJamFillMode): Color {
|
|
255
|
+
const entry = PALETTE[name]
|
|
256
|
+
return parseColor(mode === 'fill' ? entry.stroke : entry.transparentStroke)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** The label paint FigJam pairs with a colour in a fill mode. */
|
|
260
|
+
function pairedLabel(name: FigJamColorName, mode: FigJamFillMode): Fill {
|
|
261
|
+
const light = PALETTE[name].lightLabel && (mode === 'fill' || name === 'black') && mode !== 'none'
|
|
262
|
+
return light
|
|
263
|
+
? { type: 'SOLID', color: { ...WHITE }, opacity: 1, visible: true }
|
|
264
|
+
: { type: 'SOLID', color: { ...BLACK }, opacity: 0.8, visible: true }
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** How opaque FigJam fills a colour in a fill mode. */
|
|
268
|
+
function fillOpacity(name: FigJamColorName, mode: FigJamFillMode): number {
|
|
269
|
+
if (mode === 'transparent') return PALETTE[name].transparent
|
|
270
|
+
return mode === 'fill' ? 1 : 0
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** What a shape with text and its label become when painted `name` in `mode`. */
|
|
274
|
+
export interface FigJamShapePaint {
|
|
275
|
+
shape: Partial<SceneNode>
|
|
276
|
+
label: Partial<SceneNode>
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* A shape painted `name` in `mode`, as FigJam's colour menu paints it. The stroke and label follow
|
|
281
|
+
* the colour only while they are still the ones FigJam paired with the current paint: a line or
|
|
282
|
+
* text colour set by hand stays.
|
|
283
|
+
*/
|
|
284
|
+
export function figJamShapePaint(
|
|
285
|
+
shape: Pick<SceneNode, 'fills' | 'strokes'>,
|
|
286
|
+
label: Pick<SceneNode, 'fills'> | null,
|
|
287
|
+
name: FigJamColorName,
|
|
288
|
+
mode: FigJamFillMode
|
|
289
|
+
): FigJamShapePaint {
|
|
290
|
+
const fill = shape.fills.at(0)
|
|
291
|
+
const current = figJamColorName(fill?.color)
|
|
292
|
+
const currentMode = figJamFillMode(fill)
|
|
293
|
+
const opacity = fillOpacity(name, mode)
|
|
294
|
+
const result: FigJamShapePaint = {
|
|
295
|
+
shape: { fills: [{ type: 'SOLID', color: figJamColor(name), opacity, visible: true }] },
|
|
296
|
+
label: {}
|
|
297
|
+
}
|
|
298
|
+
const stroke = shape.strokes.at(0)
|
|
299
|
+
const strokeFollows =
|
|
300
|
+
!stroke || !current || sameColor(stroke.color, figJamPairedStroke(current, currentMode))
|
|
301
|
+
if (stroke && strokeFollows) {
|
|
302
|
+
result.shape.strokes = [
|
|
303
|
+
{ ...stroke, color: figJamPairedStroke(name, mode) },
|
|
304
|
+
...shape.strokes.slice(1)
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
const labelFill = label?.fills.at(0)
|
|
308
|
+
const paired = current ? pairedLabel(current, currentMode) : null
|
|
309
|
+
const labelFollows =
|
|
310
|
+
!labelFill ||
|
|
311
|
+
!paired ||
|
|
312
|
+
(sameColor(labelFill.color, paired.color) &&
|
|
313
|
+
Math.abs(labelFill.opacity - paired.opacity) < 0.01)
|
|
314
|
+
if (label && labelFollows) result.label = { fills: [pairedLabel(name, mode)] }
|
|
315
|
+
return result
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A shape's outline drawn `style`, as FigJam's line menu draws it; the weight stays. The dash is
|
|
320
|
+
* the layer's, as files keep it, and each stroke's, as it is drawn.
|
|
321
|
+
*/
|
|
322
|
+
export function figJamLineStyleFields(
|
|
323
|
+
shape: Pick<SceneNode, 'strokes'>,
|
|
324
|
+
style: FigJamLineStyle
|
|
325
|
+
): Partial<SceneNode> {
|
|
326
|
+
const dashPattern = style === 'dashed' ? [...FIGJAM_SHAPE_DASH] : []
|
|
327
|
+
const strokes = shape.strokes.map((stroke): Stroke => ({
|
|
328
|
+
...stroke,
|
|
329
|
+
opacity: style === 'none' ? 0 : 1,
|
|
330
|
+
dashPattern: [...dashPattern]
|
|
331
|
+
}))
|
|
332
|
+
return { strokes, dashPattern }
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** The line style a shape's outline shows. */
|
|
336
|
+
export function figJamLineStyle(shape: Pick<SceneNode, 'strokes'>): FigJamLineStyle {
|
|
337
|
+
const stroke = shape.strokes.at(0)
|
|
338
|
+
if (!stroke || !stroke.visible || stroke.opacity === 0) return 'none'
|
|
339
|
+
return (stroke.dashPattern?.length ?? 0) > 0 ? 'dashed' : 'solid'
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* A shape's outline in palette colour `name`, as FigJam's line menu colours it; a hidden outline
|
|
344
|
+
* shows again, keeping its dash.
|
|
345
|
+
*/
|
|
346
|
+
export function figJamLineColorFields(
|
|
347
|
+
shape: Pick<SceneNode, 'strokes'>,
|
|
348
|
+
name: FigJamColorName
|
|
349
|
+
): Partial<SceneNode> {
|
|
350
|
+
const color = figJamColor(name)
|
|
351
|
+
const strokes =
|
|
352
|
+
shape.strokes.length > 0
|
|
353
|
+
? shape.strokes.map((stroke): Stroke => ({ ...stroke, color, opacity: 1 }))
|
|
354
|
+
: [
|
|
355
|
+
{
|
|
356
|
+
type: 'SOLID',
|
|
357
|
+
color,
|
|
358
|
+
opacity: 1,
|
|
359
|
+
visible: true,
|
|
360
|
+
weight: 4,
|
|
361
|
+
align: 'CENTER'
|
|
362
|
+
} satisfies Stroke
|
|
363
|
+
]
|
|
364
|
+
return { strokes }
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** How heavy FigJam outlines a coloured section, and a coloured layer that had no stroke. */
|
|
368
|
+
const SECTION_STROKE_WEIGHT = 2
|
|
369
|
+
const LAYER_STROKE_WEIGHT = 1
|
|
370
|
+
|
|
371
|
+
/** `strokes` recoloured, or a new stroke of `weight` when there are none. */
|
|
372
|
+
function strokesIn(strokes: Stroke[], color: Color, weight: number): Stroke[] {
|
|
373
|
+
if (strokes.length > 0) return strokes.map((stroke) => ({ ...stroke, type: 'SOLID', color }))
|
|
374
|
+
return [{ type: 'SOLID', color, opacity: 1, visible: true, weight, align: 'INSIDE' }]
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** A section painted `name`, as FigJam's colour menu paints one: a pale tint outlined in the colour. */
|
|
378
|
+
export function figJamSectionColorFields(
|
|
379
|
+
section: Pick<SceneNode, 'strokes'>,
|
|
380
|
+
name: FigJamColorName
|
|
381
|
+
): Partial<SceneNode> {
|
|
382
|
+
const { sectionFill, sectionStroke } = PALETTE[name]
|
|
383
|
+
return {
|
|
384
|
+
fills: [{ type: 'SOLID', color: parseColor(sectionFill), opacity: 1, visible: true }],
|
|
385
|
+
strokes: strokesIn(section.strokes, parseColor(sectionStroke), SECTION_STROKE_WEIGHT),
|
|
386
|
+
strokeWeight: SECTION_STROKE_WEIGHT
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The paint of `paints` the canvas shows on top: the last it draws, skipping hidden and fully
|
|
392
|
+
* transparent ones, which show nothing.
|
|
393
|
+
*/
|
|
394
|
+
function drawnPaint<P extends Fill>(paints: readonly P[]): P | undefined {
|
|
395
|
+
return paints.findLast((paint) => paint.visible && paint.opacity > 0)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** The palette colour a section is painted, by its tint. */
|
|
399
|
+
export function figJamSectionColorName(section: Pick<SceneNode, 'fills'>): FigJamColorName | null {
|
|
400
|
+
const fill = drawnPaint(section.fills)?.color
|
|
401
|
+
return (
|
|
402
|
+
FIGJAM_COLOR_NAMES.find((name) => sameColor(fill, parseColor(PALETTE[name].sectionFill))) ??
|
|
403
|
+
null
|
|
404
|
+
)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Whether a layer takes a palette colour as its stroke alone: a line, or a pen stroke, which is a
|
|
409
|
+
* vector with nothing filled. A filled vector takes it as any other layer does.
|
|
410
|
+
*/
|
|
411
|
+
function colorsStroke(node: Pick<SceneNode, 'type' | 'fills'>): boolean {
|
|
412
|
+
if (node.type === 'LINE') return true
|
|
413
|
+
return node.type === 'VECTOR' && !drawnPaint(node.fills)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* A plain layer painted `name`, as FigJam's colour menu paints one: text takes it as its fill, a
|
|
418
|
+
* line or a pen stroke as its stroke, and any other layer as its fill and a stroke of the same
|
|
419
|
+
* colour.
|
|
420
|
+
*/
|
|
421
|
+
export function figJamLayerColorFields(
|
|
422
|
+
node: Pick<SceneNode, 'type' | 'fills' | 'strokes' | 'styleRuns'>,
|
|
423
|
+
name: FigJamColorName
|
|
424
|
+
): Partial<SceneNode> {
|
|
425
|
+
const color = figJamColor(name)
|
|
426
|
+
const fills: Fill[] = [{ type: 'SOLID', color, opacity: 1, visible: true }]
|
|
427
|
+
if (node.type === 'TEXT') {
|
|
428
|
+
// The whole text takes the colour, ranges coloured on their own included.
|
|
429
|
+
const styleRuns = node.styleRuns.map((run) => ({
|
|
430
|
+
...run,
|
|
431
|
+
style: omit(run.style, ['fills', 'fillStyleId'])
|
|
432
|
+
}))
|
|
433
|
+
return { fills, styleRuns }
|
|
434
|
+
}
|
|
435
|
+
const strokes = strokesIn(node.strokes, color, LAYER_STROKE_WEIGHT)
|
|
436
|
+
return colorsStroke(node) ? { strokes } : { fills, strokes }
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** The palette colour a plain layer shows, read where {@link figJamLayerColorFields} paints it. */
|
|
440
|
+
export function figJamLayerColorName(
|
|
441
|
+
node: Pick<SceneNode, 'type' | 'fills' | 'strokes'>
|
|
442
|
+
): FigJamColorName | null {
|
|
443
|
+
const paints: Fill[] = colorsStroke(node) ? node.strokes : node.fills
|
|
444
|
+
return figJamColorName(drawnPaint(paints)?.color)
|
|
445
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { percentLength } from '../text/lengths'
|
|
2
|
+
import type { SceneNode } from '../types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FigJam's text sizes for sticky notes and shapes, each with the tracking it sets, as a percent
|
|
6
|
+
* of the size; the line stays one and a half times the size.
|
|
7
|
+
*/
|
|
8
|
+
export const FIGJAM_TEXT_SIZES = {
|
|
9
|
+
small: { fontSize: 16, tracking: -1.1 },
|
|
10
|
+
medium: { fontSize: 24, tracking: -1.9 },
|
|
11
|
+
large: { fontSize: 40, tracking: -2.2 },
|
|
12
|
+
extraLarge: { fontSize: 64, tracking: -2.2 },
|
|
13
|
+
huge: { fontSize: 96, tracking: -2.3 }
|
|
14
|
+
} as const
|
|
15
|
+
|
|
16
|
+
export type FigJamTextSize = keyof typeof FIGJAM_TEXT_SIZES
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* FigJam's typefaces, as its text menus name them, and the face each sets. Scribbled is Figma's
|
|
20
|
+
* own hand font, which FigJam sets without tracking.
|
|
21
|
+
*/
|
|
22
|
+
export const FIGJAM_TYPEFACES = {
|
|
23
|
+
simple: { fontFamily: 'Inter', fontWeight: 500, tracked: true },
|
|
24
|
+
bookish: { fontFamily: 'Merriweather', fontWeight: 400, tracked: true },
|
|
25
|
+
technical: { fontFamily: 'Roboto Mono', fontWeight: 500, tracked: true },
|
|
26
|
+
scribbled: { fontFamily: 'Figma Hand', fontWeight: 400, tracked: false }
|
|
27
|
+
} as const
|
|
28
|
+
|
|
29
|
+
export type FigJamTypeface = keyof typeof FIGJAM_TYPEFACES
|
|
30
|
+
|
|
31
|
+
export function isFigJamTypeface(value: unknown): value is FigJamTypeface {
|
|
32
|
+
return typeof value === 'string' && Object.hasOwn(FIGJAM_TYPEFACES, value)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Text at a size preset in `typeface`. */
|
|
36
|
+
export function figJamTextSizeFields(
|
|
37
|
+
size: FigJamTextSize,
|
|
38
|
+
typeface: FigJamTypeface = 'simple'
|
|
39
|
+
): Pick<SceneNode, 'fontSize' | 'lineHeight' | 'letterSpacing'> {
|
|
40
|
+
const { fontSize, tracking } = FIGJAM_TEXT_SIZES[size]
|
|
41
|
+
const tracked = FIGJAM_TYPEFACES[typeface].tracked
|
|
42
|
+
return {
|
|
43
|
+
fontSize,
|
|
44
|
+
// FigJam writes both relative to the size, a line at 150% and tracking in percent.
|
|
45
|
+
lineHeight: percentLength(150),
|
|
46
|
+
letterSpacing: percentLength(tracked ? tracking : 0)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The preset a text is closest to, as FigJam's size menu shows a rescaled one. */
|
|
51
|
+
export function figJamTextSize(text: Pick<SceneNode, 'fontSize'>): FigJamTextSize {
|
|
52
|
+
const sizes = Object.entries(FIGJAM_TEXT_SIZES) as [FigJamTextSize, { fontSize: number }][]
|
|
53
|
+
return sizes.reduce((best, entry) =>
|
|
54
|
+
Math.abs(entry[1].fontSize - text.fontSize) < Math.abs(best[1].fontSize - text.fontSize)
|
|
55
|
+
? entry
|
|
56
|
+
: best
|
|
57
|
+
)[0]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The typeface a text is set in, or null for a face FigJam's menu does not offer. */
|
|
61
|
+
export function figJamTypeface(text: Pick<SceneNode, 'fontFamily'>): FigJamTypeface | null {
|
|
62
|
+
const entries = Object.entries(FIGJAM_TYPEFACES) as [FigJamTypeface, { fontFamily: string }][]
|
|
63
|
+
return entries.find(([, face]) => face.fontFamily === text.fontFamily)?.[0] ?? null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Text set in `typeface` at its current size, as FigJam's typeface menu sets it. */
|
|
67
|
+
export function figJamTypefaceFields(
|
|
68
|
+
typeface: FigJamTypeface,
|
|
69
|
+
text: Pick<SceneNode, 'fontSize'>
|
|
70
|
+
): Partial<SceneNode> {
|
|
71
|
+
return {
|
|
72
|
+
...figJamTypefaceFaceFields(typeface),
|
|
73
|
+
...figJamTextSizeFields(figJamTextSize(text), typeface)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The face `typeface` sets, without the size and spacing it sets with it. */
|
|
78
|
+
export function figJamTypefaceFaceFields(
|
|
79
|
+
typeface: FigJamTypeface
|
|
80
|
+
): Pick<SceneNode, 'fontFamily' | 'fontWeight' | 'italic'> {
|
|
81
|
+
const { fontFamily, fontWeight } = FIGJAM_TYPEFACES[typeface]
|
|
82
|
+
return { fontFamily, fontWeight, italic: false }
|
|
83
|
+
}
|
package/src/font-style.ts
CHANGED
|
@@ -8,15 +8,19 @@ export interface ParsedFontStyle {
|
|
|
8
8
|
italic: boolean
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The standard weights by the names Google Fonts gives them, which most fonts and Figma's font
|
|
13
|
+
* list use; a font's own names can differ ("Semi Bold", "Book", "Heavy").
|
|
14
|
+
*/
|
|
11
15
|
export const FONT_WEIGHT_NAMES: Record<number, string> = {
|
|
12
16
|
100: 'Thin',
|
|
13
|
-
200: '
|
|
17
|
+
200: 'ExtraLight',
|
|
14
18
|
300: 'Light',
|
|
15
19
|
400: 'Regular',
|
|
16
20
|
500: 'Medium',
|
|
17
|
-
600: '
|
|
21
|
+
600: 'SemiBold',
|
|
18
22
|
700: 'Bold',
|
|
19
|
-
800: '
|
|
23
|
+
800: 'ExtraBold',
|
|
20
24
|
900: 'Black'
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -36,7 +40,7 @@ const FONT_WEIGHT_BY_STYLE: ReadonlyMap<string, number> = new Map(
|
|
|
36
40
|
FONT_WEIGHT_ALIASES.flatMap(({ names, weight }) => names.map((name) => [name, weight] as const))
|
|
37
41
|
)
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
function normalizeFontStyleName(style: string): string {
|
|
40
44
|
return style
|
|
41
45
|
.toLowerCase()
|
|
42
46
|
.replace(/italic|oblique/u, '')
|
|
@@ -62,16 +66,56 @@ export function normalizeFontFamily(family: string): string {
|
|
|
62
66
|
return family.replace(/\s+(Variable|\d+(?:pt|px|em))$/i, '')
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
export function
|
|
66
|
-
const weight = styleToWeight(style)
|
|
67
|
-
const italic = style.toLowerCase().includes('italic')
|
|
68
|
-
if (weight === 400 && !italic) return 'regular'
|
|
69
|
-
if (weight === 400 && italic) return 'italic'
|
|
70
|
-
return italic ? `${weight}italic` : `${weight}`
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function weightToStyle(weight: number, italic = false): string {
|
|
69
|
+
export function faceLoadKey(weight: number, italic = false): string {
|
|
74
70
|
const rounded = Math.round(weight / 100) * 100
|
|
75
|
-
const label =
|
|
71
|
+
const label = FONT_WEIGHT_NAMES[rounded] ?? 'Regular'
|
|
76
72
|
return italic ? `${label} Italic` : label
|
|
77
73
|
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The name Google Fonts gives the face at `weight` and slant ("SemiBold Italic", and "Italic"
|
|
77
|
+
* for the regular weight), for a face whose font has not said its own.
|
|
78
|
+
*/
|
|
79
|
+
export function standardStyleName(weight: number, italic = false): string {
|
|
80
|
+
const label = FONT_WEIGHT_NAMES[Math.round(weight / 100) * 100] ?? 'Regular'
|
|
81
|
+
if (!italic) return label
|
|
82
|
+
return label === 'Regular' ? 'Italic' : `${label} Italic`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** A style name compared without case or spaces, so "Semi Bold" and "SemiBold" name one face. */
|
|
86
|
+
export function styleSpelling(style: string): string {
|
|
87
|
+
return style.toLowerCase().replace(/\s+/gu, '')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Whether `style` only names a weight and slant ("Bold Italic", "Semi Bold"), so any face of that
|
|
92
|
+
* weight is it; a name such as "Book" or "Condensed Bold" is one face of its own.
|
|
93
|
+
*/
|
|
94
|
+
export function namesWeight(style: string): boolean {
|
|
95
|
+
const { weight, italic } = parseFontStyle(style)
|
|
96
|
+
const spelling = styleSpelling(style)
|
|
97
|
+
return [faceLoadKey(weight, italic), standardStyleName(weight, italic)]
|
|
98
|
+
.map(styleSpelling)
|
|
99
|
+
.includes(spelling)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A face as text sets it: a weight and slant, and the name it was given, if any. */
|
|
103
|
+
export interface NamedFace {
|
|
104
|
+
fontWeight: number
|
|
105
|
+
italic: boolean
|
|
106
|
+
fontStyle: string | null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The style a face loads and draws as. A name that only spells its weight and slant ("Semi Bold",
|
|
111
|
+
* "Italic") loads as the weight's key, so whichever font of the family draws that weight draws
|
|
112
|
+
* it; any other name ("Book", "Condensed Bold", "Retina") is a face the weight cannot pick, and
|
|
113
|
+
* it loads and draws by that name.
|
|
114
|
+
*/
|
|
115
|
+
export function faceStyleKey({ fontWeight, italic, fontStyle }: NamedFace): string {
|
|
116
|
+
const key = faceLoadKey(fontWeight, italic)
|
|
117
|
+
if (!fontStyle) return key
|
|
118
|
+
const spelling = styleSpelling(fontStyle)
|
|
119
|
+
const weightNames = [key, standardStyleName(fontWeight, italic)].map(styleSpelling)
|
|
120
|
+
return weightNames.includes(spelling) ? key : fontStyle
|
|
121
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { CONNECTOR_KIND } from '../connectors/sublayers'
|
|
2
|
+
import type { SceneGraph } from '../graph'
|
|
3
|
+
import type { NodeType, SceneNode } from '../types'
|
|
4
|
+
import type { GeneratedFrameKind } from './kind'
|
|
5
|
+
import { SHAPE_WITH_TEXT_KIND } from './shape-with-text'
|
|
6
|
+
import { STICKY_KIND } from './sticky'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Layers Figma generates from a template, which it calls immutable frames: their sublayers come
|
|
10
|
+
* from the type and its settings, and a user edits them only through the frame. A sticky note's
|
|
11
|
+
* body and author are such sublayers. They are real children here, so layout, drawing and text
|
|
12
|
+
* editing treat them as any other layer, but nothing may add, move or remove them.
|
|
13
|
+
*
|
|
14
|
+
* Each type is described once, here; the editor and file formats ask it instead of testing for
|
|
15
|
+
* the type.
|
|
16
|
+
*/
|
|
17
|
+
const GENERATED_FRAME_KINDS = {
|
|
18
|
+
SHAPE_WITH_TEXT: SHAPE_WITH_TEXT_KIND,
|
|
19
|
+
STICKY: STICKY_KIND,
|
|
20
|
+
CONNECTOR: CONNECTOR_KIND
|
|
21
|
+
} satisfies Partial<Record<NodeType, GeneratedFrameKind>>
|
|
22
|
+
|
|
23
|
+
/** The layer types that are generated frames, for tables that must cover each of them. */
|
|
24
|
+
export type GeneratedFrameType = keyof typeof GENERATED_FRAME_KINDS
|
|
25
|
+
|
|
26
|
+
export const GENERATED_FRAME_TYPES: ReadonlySet<NodeType> = new Set(
|
|
27
|
+
Object.keys(GENERATED_FRAME_KINDS) as GeneratedFrameType[]
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
/** What a generated frame's type says about it, or undefined for any other layer. */
|
|
31
|
+
export function generatedFrameKind(node: Pick<SceneNode, 'type'>): GeneratedFrameKind | undefined {
|
|
32
|
+
return isGeneratedFrame(node) ? GENERATED_FRAME_KINDS[node.type] : undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isGeneratedFrame<N extends Pick<SceneNode, 'type'>>(
|
|
36
|
+
node: N
|
|
37
|
+
): node is N & { type: GeneratedFrameType } {
|
|
38
|
+
return GENERATED_FRAME_TYPES.has(node.type)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The generated frame a layer belongs to, if it is one of its sublayers. */
|
|
42
|
+
export function generatedFrameOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined {
|
|
43
|
+
return node.parentId ? graph.closest(node.parentId, isGeneratedFrame) : undefined
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The text a generated frame edits in place: a sticky note's body or a connector's label. */
|
|
47
|
+
export function generatedFrameText(graph: SceneGraph, node: SceneNode): SceneNode | undefined {
|
|
48
|
+
return generatedFrameKind(node)?.text(graph, node)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `changes` with what a width or height in them also sets on a generated frame
|
|
53
|
+
* (`GeneratedFrameKind.sized`); fields `changes` sets itself, such as an undo restoring them, win.
|
|
54
|
+
*/
|
|
55
|
+
export function withGeneratedFrameSize(
|
|
56
|
+
node: SceneNode,
|
|
57
|
+
changes: Partial<SceneNode>
|
|
58
|
+
): Partial<SceneNode> {
|
|
59
|
+
const kind = generatedFrameKind(node)
|
|
60
|
+
if (!kind?.sized || (changes.width === undefined && changes.height === undefined)) return changes
|
|
61
|
+
return { ...kind.sized(changes, node), ...changes }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Whether a layer turns: any layer but a generated frame that stays upright. */
|
|
65
|
+
export function layerRotates(node: Pick<SceneNode, 'type'>): boolean {
|
|
66
|
+
return generatedFrameKind(node)?.rotates ?? true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Whether a layer's resize handles and W and H fields resize it freely. */
|
|
70
|
+
export function layerResizes(node: Pick<SceneNode, 'type'>): boolean {
|
|
71
|
+
return generatedFrameKind(node)?.resizes ?? true
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type { GeneratedFrameKind } from './kind'
|
|
75
|
+
export * from './shape-with-text'
|
|
76
|
+
export * from './sticky'
|