@open-pencil/scene-graph 0.16.0 → 0.17.0-beta.2
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 +286 -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 +62 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
- 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 +43 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +48 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +156 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +228 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +86 -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 +6 -29
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +26 -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 +42 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +249 -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 +32 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +180 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +33 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +58 -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 +47 -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 +156 -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 +264 -2
- package/dist/copy.js.map +1 -0
- package/dist/css/blend.d.ts +11 -0
- package/dist/css/blend.d.ts.map +1 -0
- package/dist/css/blend.js +30 -0
- package/dist/css/blend.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 +7 -0
- package/dist/css/index.js +7 -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/cubic.d.ts +7 -0
- package/dist/cubic.d.ts.map +1 -0
- package/dist/cubic.js +17 -0
- package/dist/cubic.js.map +1 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +25 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +47 -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 +64 -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 +270 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +439 -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 +43 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +135 -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 +89 -2
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +306 -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 +178 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +625 -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 +21 -2
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +5 -1
- 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 +75 -57
- 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 +90 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +38 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +180 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/kept-overrides.js +204 -0
- package/dist/instances/kept-overrides.js.map +1 -0
- package/dist/instances/main-component.d.ts +13 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +50 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/overrides.d.ts +51 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +158 -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/swap.js +288 -0
- package/dist/instances/swap.js.map +1 -0
- package/dist/instances/sync.js +327 -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/outline/flatten.d.ts +15 -0
- package/dist/outline/flatten.d.ts.map +1 -0
- package/dist/outline/flatten.js +189 -0
- package/dist/outline/flatten.js.map +1 -0
- package/dist/outline/heads.js +34 -0
- package/dist/outline/heads.js.map +1 -0
- package/dist/outline/hit.d.ts +21 -0
- package/dist/outline/hit.d.ts.map +1 -0
- package/dist/outline/hit.js +276 -0
- package/dist/outline/hit.js.map +1 -0
- package/dist/outline/index.d.ts +5 -0
- package/dist/outline/index.js +5 -0
- package/dist/outline/point.d.ts +16 -0
- package/dist/outline/point.d.ts.map +1 -0
- package/dist/outline/point.js +42 -0
- package/dist/outline/point.js.map +1 -0
- package/dist/outline/shapes.d.ts +35 -0
- package/dist/outline/shapes.d.ts.map +1 -0
- package/dist/outline/shapes.js +181 -0
- package/dist/outline/shapes.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 +143 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +168 -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 +51 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +186 -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 +105 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +40 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +118 -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 +24 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +49 -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} +3 -4
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +38 -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 +78 -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 +195 -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 +83 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +314 -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 +43 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +104 -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 +238 -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 +303 -137
- package/src/arrow-caps.ts +279 -62
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +51 -34
- package/src/behaviours/layers.ts +5 -3
- package/src/behaviours/model.ts +25 -22
- package/src/behaviours/schema.ts +64 -13
- package/src/behaviours/spec.ts +11 -50
- package/src/bindings.ts +11 -2
- package/src/checkpoint.ts +252 -5
- 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 +94 -4
- package/src/components/variants.ts +52 -31
- 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 +49 -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 +141 -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 +71 -31
- package/src/css/blend.ts +27 -0
- package/src/css/index.ts +2 -0
- package/src/css/text.ts +84 -0
- package/src/cubic.ts +14 -0
- package/src/export-format.ts +30 -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 +32 -1
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +473 -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 +157 -0
- package/src/generated/sticky.ts +213 -0
- package/src/geometry.ts +102 -312
- package/src/gradient.ts +14 -0
- package/src/graph.ts +849 -0
- package/src/group-bounds.ts +59 -12
- package/src/guides.ts +6 -1
- package/src/hit-test.ts +118 -74
- 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 +47 -92
- package/src/{instances.ts → instances/index.ts} +69 -44
- package/src/instances/kept-overrides.ts +280 -0
- package/src/instances/main-component.ts +55 -1
- package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
- package/src/instances/placement.ts +1 -1
- package/src/instances/source-walk.ts +3 -9
- package/src/instances/swap.ts +451 -0
- package/src/instances/sync.ts +166 -177
- 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 +43 -3
- package/src/outline/flatten.ts +190 -0
- package/src/outline/heads.ts +52 -0
- package/src/outline/hit.ts +369 -0
- package/src/outline/index.ts +4 -0
- package/src/outline/point.ts +59 -0
- package/src/outline/shapes.ts +207 -0
- 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 +69 -77
- 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 +169 -17
- package/src/slots/authoring.ts +1 -1
- package/src/slots/content.ts +10 -5
- package/src/slots/frames.ts +12 -10
- 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 +44 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/picture.ts +0 -4
- 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 +18 -19
- 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 +246 -13
- package/src/undo.ts +64 -2
- package/src/variables/bindings.ts +166 -66
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +83 -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} +86 -146
- 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 +0 -18
- package/dist/chunks/bindings.js.map +0 -1
- package/dist/chunks/buffered-events.js.map +0 -1
- package/dist/chunks/checkpoint.js +0 -78
- 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 +0 -32
- 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/buffered-events.js → buffered-events.js} +0 -0
- /package/dist/{chunks/events.js → events.js} +0 -0
- /package/dist/{chunks/fields → fields}/geometry.js +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/font-style.d.ts
|
|
2
|
+
interface FontFamilyStyle {
|
|
3
|
+
family: string;
|
|
4
|
+
style: string;
|
|
5
|
+
}
|
|
6
|
+
interface ParsedFontStyle {
|
|
7
|
+
weight: number;
|
|
8
|
+
italic: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The standard weights by the names Google Fonts gives them, which most fonts and Figma's font
|
|
12
|
+
* list use; a font's own names can differ ("Semi Bold", "Book", "Heavy").
|
|
13
|
+
*/
|
|
14
|
+
declare const FONT_WEIGHT_NAMES: Record<number, string>;
|
|
15
|
+
declare function parseFontStyle(style: string | undefined): ParsedFontStyle;
|
|
16
|
+
declare function styleToWeight(style: string | undefined): number;
|
|
17
|
+
declare function normalizeFontFamily(family: string): string;
|
|
18
|
+
declare function faceLoadKey(weight: number, italic?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* The name Google Fonts gives the face at `weight` and slant ("SemiBold Italic", and "Italic"
|
|
21
|
+
* for the regular weight), for a face whose font has not said its own.
|
|
22
|
+
*/
|
|
23
|
+
declare function standardStyleName(weight: number, italic?: boolean): string;
|
|
24
|
+
/** A style name compared without case or spaces, so "Semi Bold" and "SemiBold" name one face. */
|
|
25
|
+
declare function styleSpelling(style: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether `style` only names a weight and slant ("Bold Italic", "Semi Bold"), so any face of that
|
|
28
|
+
* weight is it; a name such as "Book" or "Condensed Bold" is one face of its own.
|
|
29
|
+
*/
|
|
30
|
+
declare function namesWeight(style: string): boolean;
|
|
31
|
+
/** A face as text sets it: a weight and slant, and the name it was given, if any. */
|
|
32
|
+
interface NamedFace {
|
|
33
|
+
fontWeight: number;
|
|
34
|
+
italic: boolean;
|
|
35
|
+
fontStyle: string | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The style a face loads and draws as. A name that only spells its weight and slant ("Semi Bold",
|
|
39
|
+
* "Italic") loads as the weight's key, so whichever font of the family draws that weight draws
|
|
40
|
+
* it; any other name ("Book", "Condensed Bold", "Retina") is a face the weight cannot pick, and
|
|
41
|
+
* it loads and draws by that name.
|
|
42
|
+
*/
|
|
43
|
+
declare function faceStyleKey({ fontWeight, italic, fontStyle }: NamedFace): string;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { FONT_WEIGHT_NAMES, FontFamilyStyle, NamedFace, ParsedFontStyle, faceLoadKey, faceStyleKey, namesWeight, normalizeFontFamily, parseFontStyle, standardStyleName, styleSpelling, styleToWeight };
|
|
46
|
+
//# sourceMappingURL=font-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-style.d.ts","names":[],"sources":["../src/font-style.ts"],"mappings":";UAAiB;EACf;EACA;;UAGe;EACf;EACA;;;;;;cAOW,mBAAmB;iBAmChB,eAAe,4BAA4B;iBAW3C,cAAc;iBAId,oBAAoB;iBAIpB,YAAY,gBAAgB;;;;;iBAU5B,kBAAkB,gBAAgB;;iBAOlC,cAAc;;;;;iBAQd,YAAY;;UASX;EACf;EACA;EACA;;;;;;;;iBASc,eAAe,YAAY,QAAQ,aAAa"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region src/font-style.ts
|
|
2
|
+
/**
|
|
3
|
+
* The standard weights by the names Google Fonts gives them, which most fonts and Figma's font
|
|
4
|
+
* list use; a font's own names can differ ("Semi Bold", "Book", "Heavy").
|
|
5
|
+
*/
|
|
6
|
+
const FONT_WEIGHT_NAMES = {
|
|
7
|
+
100: "Thin",
|
|
8
|
+
200: "ExtraLight",
|
|
9
|
+
300: "Light",
|
|
10
|
+
400: "Regular",
|
|
11
|
+
500: "Medium",
|
|
12
|
+
600: "SemiBold",
|
|
13
|
+
700: "Bold",
|
|
14
|
+
800: "ExtraBold",
|
|
15
|
+
900: "Black"
|
|
16
|
+
};
|
|
17
|
+
const FONT_WEIGHT_BY_STYLE = new Map([
|
|
18
|
+
{
|
|
19
|
+
weight: 100,
|
|
20
|
+
names: [
|
|
21
|
+
"thin",
|
|
22
|
+
"hairline",
|
|
23
|
+
"extrathin",
|
|
24
|
+
"ultrathin"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
weight: 200,
|
|
29
|
+
names: ["extralight", "ultralight"]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
weight: 300,
|
|
33
|
+
names: ["light"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
weight: 400,
|
|
37
|
+
names: [
|
|
38
|
+
"regular",
|
|
39
|
+
"normal",
|
|
40
|
+
"book",
|
|
41
|
+
"roman",
|
|
42
|
+
"plain"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
weight: 500,
|
|
47
|
+
names: ["medium"]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
weight: 600,
|
|
51
|
+
names: ["semibold", "demibold"]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
weight: 700,
|
|
55
|
+
names: ["bold"]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
weight: 800,
|
|
59
|
+
names: ["extrabold", "ultrabold"]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
weight: 900,
|
|
63
|
+
names: ["black", "heavy"]
|
|
64
|
+
}
|
|
65
|
+
].flatMap(({ names, weight }) => names.map((name) => [name, weight])));
|
|
66
|
+
function normalizeFontStyleName(style) {
|
|
67
|
+
return style.toLowerCase().replace(/italic|oblique/u, "").replace(/[^a-z0-9]+/gu, "");
|
|
68
|
+
}
|
|
69
|
+
function parseFontStyle(style) {
|
|
70
|
+
const raw = style ?? "";
|
|
71
|
+
const italic = /(?:italic|oblique)/iu.test(raw);
|
|
72
|
+
const normalized = normalizeFontStyleName(raw);
|
|
73
|
+
const numericWeight = normalized.match(/(?:^|[^0-9])([1-9]00)(?:[^0-9]|$)/u)?.[1];
|
|
74
|
+
return {
|
|
75
|
+
weight: numericWeight ? Number(numericWeight) : FONT_WEIGHT_BY_STYLE.get(normalized) ?? 400,
|
|
76
|
+
italic
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function styleToWeight(style) {
|
|
80
|
+
return parseFontStyle(style).weight;
|
|
81
|
+
}
|
|
82
|
+
function normalizeFontFamily(family) {
|
|
83
|
+
return family.replace(/\s+(Variable|\d+(?:pt|px|em))$/i, "");
|
|
84
|
+
}
|
|
85
|
+
function faceLoadKey(weight, italic = false) {
|
|
86
|
+
const rounded = Math.round(weight / 100) * 100;
|
|
87
|
+
const label = FONT_WEIGHT_NAMES[rounded] ?? "Regular";
|
|
88
|
+
return italic ? `${label} Italic` : label;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The name Google Fonts gives the face at `weight` and slant ("SemiBold Italic", and "Italic"
|
|
92
|
+
* for the regular weight), for a face whose font has not said its own.
|
|
93
|
+
*/
|
|
94
|
+
function standardStyleName(weight, italic = false) {
|
|
95
|
+
const label = FONT_WEIGHT_NAMES[Math.round(weight / 100) * 100] ?? "Regular";
|
|
96
|
+
if (!italic) return label;
|
|
97
|
+
return label === "Regular" ? "Italic" : `${label} Italic`;
|
|
98
|
+
}
|
|
99
|
+
/** A style name compared without case or spaces, so "Semi Bold" and "SemiBold" name one face. */
|
|
100
|
+
function styleSpelling(style) {
|
|
101
|
+
return style.toLowerCase().replace(/\s+/gu, "");
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Whether `style` only names a weight and slant ("Bold Italic", "Semi Bold"), so any face of that
|
|
105
|
+
* weight is it; a name such as "Book" or "Condensed Bold" is one face of its own.
|
|
106
|
+
*/
|
|
107
|
+
function namesWeight(style) {
|
|
108
|
+
const { weight, italic } = parseFontStyle(style);
|
|
109
|
+
const spelling = styleSpelling(style);
|
|
110
|
+
return [faceLoadKey(weight, italic), standardStyleName(weight, italic)].map(styleSpelling).includes(spelling);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The style a face loads and draws as. A name that only spells its weight and slant ("Semi Bold",
|
|
114
|
+
* "Italic") loads as the weight's key, so whichever font of the family draws that weight draws
|
|
115
|
+
* it; any other name ("Book", "Condensed Bold", "Retina") is a face the weight cannot pick, and
|
|
116
|
+
* it loads and draws by that name.
|
|
117
|
+
*/
|
|
118
|
+
function faceStyleKey({ fontWeight, italic, fontStyle }) {
|
|
119
|
+
const key = faceLoadKey(fontWeight, italic);
|
|
120
|
+
if (!fontStyle) return key;
|
|
121
|
+
const spelling = styleSpelling(fontStyle);
|
|
122
|
+
return [key, standardStyleName(fontWeight, italic)].map(styleSpelling).includes(spelling) ? key : fontStyle;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { FONT_WEIGHT_NAMES, faceLoadKey, faceStyleKey, namesWeight, normalizeFontFamily, parseFontStyle, standardStyleName, styleSpelling, styleToWeight };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=font-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-style.js","names":[],"sources":["../src/font-style.ts"],"sourcesContent":["export interface FontFamilyStyle {\n family: string\n style: string\n}\n\nexport interface ParsedFontStyle {\n weight: number\n italic: boolean\n}\n\n/**\n * The standard weights by the names Google Fonts gives them, which most fonts and Figma's font\n * list use; a font's own names can differ (\"Semi Bold\", \"Book\", \"Heavy\").\n */\nexport const FONT_WEIGHT_NAMES: Record<number, string> = {\n 100: 'Thin',\n 200: 'ExtraLight',\n 300: 'Light',\n 400: 'Regular',\n 500: 'Medium',\n 600: 'SemiBold',\n 700: 'Bold',\n 800: 'ExtraBold',\n 900: 'Black'\n}\n\nconst FONT_WEIGHT_ALIASES = [\n { weight: 100, names: ['thin', 'hairline', 'extrathin', 'ultrathin'] },\n { weight: 200, names: ['extralight', 'ultralight'] },\n { weight: 300, names: ['light'] },\n { weight: 400, names: ['regular', 'normal', 'book', 'roman', 'plain'] },\n { weight: 500, names: ['medium'] },\n { weight: 600, names: ['semibold', 'demibold'] },\n { weight: 700, names: ['bold'] },\n { weight: 800, names: ['extrabold', 'ultrabold'] },\n { weight: 900, names: ['black', 'heavy'] }\n] as const\n\nconst FONT_WEIGHT_BY_STYLE: ReadonlyMap<string, number> = new Map(\n FONT_WEIGHT_ALIASES.flatMap(({ names, weight }) => names.map((name) => [name, weight] as const))\n)\n\nfunction normalizeFontStyleName(style: string): string {\n return style\n .toLowerCase()\n .replace(/italic|oblique/u, '')\n .replace(/[^a-z0-9]+/gu, '')\n}\n\nexport function parseFontStyle(style: string | undefined): ParsedFontStyle {\n const raw = style ?? ''\n const italic = /(?:italic|oblique)/iu.test(raw)\n const normalized = normalizeFontStyleName(raw)\n const numericWeight = normalized.match(/(?:^|[^0-9])([1-9]00)(?:[^0-9]|$)/u)?.[1]\n return {\n weight: numericWeight ? Number(numericWeight) : (FONT_WEIGHT_BY_STYLE.get(normalized) ?? 400),\n italic\n }\n}\n\nexport function styleToWeight(style: string | undefined): number {\n return parseFontStyle(style).weight\n}\n\nexport function normalizeFontFamily(family: string): string {\n return family.replace(/\\s+(Variable|\\d+(?:pt|px|em))$/i, '')\n}\n\nexport function faceLoadKey(weight: number, italic = false): string {\n const rounded = Math.round(weight / 100) * 100\n const label = FONT_WEIGHT_NAMES[rounded] ?? 'Regular'\n return italic ? `${label} Italic` : label\n}\n\n/**\n * The name Google Fonts gives the face at `weight` and slant (\"SemiBold Italic\", and \"Italic\"\n * for the regular weight), for a face whose font has not said its own.\n */\nexport function standardStyleName(weight: number, italic = false): string {\n const label = FONT_WEIGHT_NAMES[Math.round(weight / 100) * 100] ?? 'Regular'\n if (!italic) return label\n return label === 'Regular' ? 'Italic' : `${label} Italic`\n}\n\n/** A style name compared without case or spaces, so \"Semi Bold\" and \"SemiBold\" name one face. */\nexport function styleSpelling(style: string): string {\n return style.toLowerCase().replace(/\\s+/gu, '')\n}\n\n/**\n * Whether `style` only names a weight and slant (\"Bold Italic\", \"Semi Bold\"), so any face of that\n * weight is it; a name such as \"Book\" or \"Condensed Bold\" is one face of its own.\n */\nexport function namesWeight(style: string): boolean {\n const { weight, italic } = parseFontStyle(style)\n const spelling = styleSpelling(style)\n return [faceLoadKey(weight, italic), standardStyleName(weight, italic)]\n .map(styleSpelling)\n .includes(spelling)\n}\n\n/** A face as text sets it: a weight and slant, and the name it was given, if any. */\nexport interface NamedFace {\n fontWeight: number\n italic: boolean\n fontStyle: string | null\n}\n\n/**\n * The style a face loads and draws as. A name that only spells its weight and slant (\"Semi Bold\",\n * \"Italic\") loads as the weight's key, so whichever font of the family draws that weight draws\n * it; any other name (\"Book\", \"Condensed Bold\", \"Retina\") is a face the weight cannot pick, and\n * it loads and draws by that name.\n */\nexport function faceStyleKey({ fontWeight, italic, fontStyle }: NamedFace): string {\n const key = faceLoadKey(fontWeight, italic)\n if (!fontStyle) return key\n const spelling = styleSpelling(fontStyle)\n const weightNames = [key, standardStyleName(fontWeight, italic)].map(styleSpelling)\n return weightNames.includes(spelling) ? key : fontStyle\n}\n"],"mappings":";;;;;AAcA,MAAa,oBAA4C;CACvD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAcA,MAAM,uBAAoD,IAAI,IAC5D;CAZA;EAAE,QAAQ;EAAK,OAAO;GAAC;GAAQ;GAAY;GAAa;EAAW;CAAE;CACrE;EAAE,QAAQ;EAAK,OAAO,CAAC,cAAc,YAAY;CAAE;CACnD;EAAE,QAAQ;EAAK,OAAO,CAAC,OAAO;CAAE;CAChC;EAAE,QAAQ;EAAK,OAAO;GAAC;GAAW;GAAU;GAAQ;GAAS;EAAO;CAAE;CACtE;EAAE,QAAQ;EAAK,OAAO,CAAC,QAAQ;CAAE;CACjC;EAAE,QAAQ;EAAK,OAAO,CAAC,YAAY,UAAU;CAAE;CAC/C;EAAE,QAAQ;EAAK,OAAO,CAAC,MAAM;CAAE;CAC/B;EAAE,QAAQ;EAAK,OAAO,CAAC,aAAa,WAAW;CAAE;CACjD;EAAE,QAAQ;EAAK,OAAO,CAAC,SAAS,OAAO;CAAE;AAIvB,CAAC,CAAC,SAAS,EAAE,OAAO,aAAa,MAAM,KAAK,SAAS,CAAC,MAAM,MAAM,CAAU,CAAC,CACjG;AAEA,SAAS,uBAAuB,OAAuB;CACrD,OAAO,MACJ,YAAY,CAAC,CACb,QAAQ,mBAAmB,EAAE,CAAC,CAC9B,QAAQ,gBAAgB,EAAE;AAC/B;AAEA,SAAgB,eAAe,OAA4C;CACzE,MAAM,MAAM,SAAS;CACrB,MAAM,SAAS,uBAAuB,KAAK,GAAG;CAC9C,MAAM,aAAa,uBAAuB,GAAG;CAC7C,MAAM,gBAAgB,WAAW,MAAM,oCAAoC,CAAC,GAAG;CAC/E,OAAO;EACL,QAAQ,gBAAgB,OAAO,aAAa,IAAK,qBAAqB,IAAI,UAAU,KAAK;EACzF;CACF;AACF;AAEA,SAAgB,cAAc,OAAmC;CAC/D,OAAO,eAAe,KAAK,CAAC,CAAC;AAC/B;AAEA,SAAgB,oBAAoB,QAAwB;CAC1D,OAAO,OAAO,QAAQ,mCAAmC,EAAE;AAC7D;AAEA,SAAgB,YAAY,QAAgB,SAAS,OAAe;CAClE,MAAM,UAAU,KAAK,MAAM,SAAS,GAAG,IAAI;CAC3C,MAAM,QAAQ,kBAAkB,YAAY;CAC5C,OAAO,SAAS,GAAG,MAAM,WAAW;AACtC;;;;;AAMA,SAAgB,kBAAkB,QAAgB,SAAS,OAAe;CACxE,MAAM,QAAQ,kBAAkB,KAAK,MAAM,SAAS,GAAG,IAAI,QAAQ;CACnE,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,UAAU,YAAY,WAAW,GAAG,MAAM;AACnD;;AAGA,SAAgB,cAAc,OAAuB;CACnD,OAAO,MAAM,YAAY,CAAC,CAAC,QAAQ,SAAS,EAAE;AAChD;;;;;AAMA,SAAgB,YAAY,OAAwB;CAClD,MAAM,EAAE,QAAQ,WAAW,eAAe,KAAK;CAC/C,MAAM,WAAW,cAAc,KAAK;CACpC,OAAO,CAAC,YAAY,QAAQ,MAAM,GAAG,kBAAkB,QAAQ,MAAM,CAAC,CAAC,CACpE,IAAI,aAAa,CAAC,CAClB,SAAS,QAAQ;AACtB;;;;;;;AAeA,SAAgB,aAAa,EAAE,YAAY,QAAQ,aAAgC;CACjF,MAAM,MAAM,YAAY,YAAY,MAAM;CAC1C,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,WAAW,cAAc,SAAS;CAExC,OADoB,CAAC,KAAK,kBAAkB,YAAY,MAAM,CAAC,CAAC,CAAC,IAAI,aACpD,CAAC,CAAC,SAAS,QAAQ,IAAI,MAAM;AAChD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { NodeType, SceneNode } from "../types.js";
|
|
3
|
+
import { GeneratedFrameKind } from "./kind.js";
|
|
4
|
+
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields } from "./shape-with-text.js";
|
|
5
|
+
import { DEFAULT_STICKY_COLOR, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, StickyContent, StickySublayers, StickyTextRole, buildStickySublayers, createSticky, isWideSticky, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth } from "./sticky.js";
|
|
6
|
+
//#region src/generated/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Layers Figma generates from a template, which it calls immutable frames: their sublayers come
|
|
9
|
+
* from the type and its settings, and a user edits them only through the frame. A sticky note's
|
|
10
|
+
* body and author are such sublayers. They are real children here, so layout, drawing and text
|
|
11
|
+
* editing treat them as any other layer, but nothing may add, move or remove them.
|
|
12
|
+
*
|
|
13
|
+
* Each type is described once, here; the editor and file formats ask it instead of testing for
|
|
14
|
+
* the type.
|
|
15
|
+
*/
|
|
16
|
+
declare const GENERATED_FRAME_KINDS: {
|
|
17
|
+
SHAPE_WITH_TEXT: GeneratedFrameKind;
|
|
18
|
+
STICKY: GeneratedFrameKind;
|
|
19
|
+
CONNECTOR: GeneratedFrameKind;
|
|
20
|
+
};
|
|
21
|
+
/** The layer types that are generated frames, for tables that must cover each of them. */
|
|
22
|
+
type GeneratedFrameType = keyof typeof GENERATED_FRAME_KINDS;
|
|
23
|
+
declare const GENERATED_FRAME_TYPES: ReadonlySet<NodeType>;
|
|
24
|
+
/** What a generated frame's type says about it, or undefined for any other layer. */
|
|
25
|
+
declare function generatedFrameKind(node: Pick<SceneNode, 'type'>): GeneratedFrameKind | undefined;
|
|
26
|
+
declare function isGeneratedFrame<N extends Pick<SceneNode, 'type'>>(node: N): node is N & {
|
|
27
|
+
type: GeneratedFrameType;
|
|
28
|
+
};
|
|
29
|
+
/** The generated frame a layer belongs to, if it is one of its sublayers. */
|
|
30
|
+
declare function generatedFrameOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined;
|
|
31
|
+
/** The text a generated frame edits in place: a sticky note's body or a connector's label. */
|
|
32
|
+
declare function generatedFrameText(graph: SceneGraph, node: SceneNode): SceneNode | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* `changes` with what a width or height in them also sets on a generated frame
|
|
35
|
+
* (`GeneratedFrameKind.sized`); fields `changes` sets itself, such as an undo restoring them, win.
|
|
36
|
+
*/
|
|
37
|
+
declare function withGeneratedFrameSize(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
38
|
+
/** Whether a layer turns: any layer but a generated frame that stays upright. */
|
|
39
|
+
declare function layerRotates(node: Pick<SceneNode, 'type'>): boolean;
|
|
40
|
+
/** Whether a layer's resize handles and W and H fields resize it freely. */
|
|
41
|
+
declare function layerResizes(node: Pick<SceneNode, 'type'>): boolean;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { DEFAULT_STICKY_COLOR, GENERATED_FRAME_TYPES, type GeneratedFrameKind, GeneratedFrameType, SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, StickyContent, StickySublayers, StickyTextRole, buildShapeWithTextLabel, buildStickySublayers, createShapeWithText, createSticky, generatedFrameKind, generatedFrameOwner, generatedFrameText, isGeneratedFrame, isWideSticky, layerResizes, layerRotates, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth, withGeneratedFrameSize };
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/generated/index.ts"],"mappings":";;;;;;;;;;;;;;;cAgBM;;;;;;KAOM,kCAAkC;cAEjC,uBAAuB,YAAY;;iBAKhC,mBAAmB,MAAM,KAAK,qBAAqB;iBAInD,iBAAiB,UAAU,KAAK,oBAC9C,MAAM,IACL,QAAQ;EAAM,MAAM;;;iBAKP,oBAAoB,OAAO,YAAY,MAAM,YAAY;;iBAKzD,mBAAmB,OAAO,YAAY,MAAM,YAAY;;;;;iBAQxD,uBACd,MAAM,WACN,SAAS,QAAQ,aAChB,QAAQ;;iBAOK,aAAa,MAAM,KAAK;;iBAKxB,aAAa,MAAM,KAAK"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CONNECTOR_KIND } from "../connectors/sublayers.js";
|
|
2
|
+
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields } from "./shape-with-text.js";
|
|
3
|
+
import { DEFAULT_STICKY_COLOR, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, buildStickySublayers, createSticky, isWideSticky, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth } from "./sticky.js";
|
|
4
|
+
//#region src/generated/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Layers Figma generates from a template, which it calls immutable frames: their sublayers come
|
|
7
|
+
* from the type and its settings, and a user edits them only through the frame. A sticky note's
|
|
8
|
+
* body and author are such sublayers. They are real children here, so layout, drawing and text
|
|
9
|
+
* editing treat them as any other layer, but nothing may add, move or remove them.
|
|
10
|
+
*
|
|
11
|
+
* Each type is described once, here; the editor and file formats ask it instead of testing for
|
|
12
|
+
* the type.
|
|
13
|
+
*/
|
|
14
|
+
const GENERATED_FRAME_KINDS = {
|
|
15
|
+
SHAPE_WITH_TEXT: SHAPE_WITH_TEXT_KIND,
|
|
16
|
+
STICKY: STICKY_KIND,
|
|
17
|
+
CONNECTOR: CONNECTOR_KIND
|
|
18
|
+
};
|
|
19
|
+
const GENERATED_FRAME_TYPES = new Set(Object.keys(GENERATED_FRAME_KINDS));
|
|
20
|
+
/** What a generated frame's type says about it, or undefined for any other layer. */
|
|
21
|
+
function generatedFrameKind(node) {
|
|
22
|
+
return isGeneratedFrame(node) ? GENERATED_FRAME_KINDS[node.type] : void 0;
|
|
23
|
+
}
|
|
24
|
+
function isGeneratedFrame(node) {
|
|
25
|
+
return GENERATED_FRAME_TYPES.has(node.type);
|
|
26
|
+
}
|
|
27
|
+
/** The generated frame a layer belongs to, if it is one of its sublayers. */
|
|
28
|
+
function generatedFrameOwner(graph, node) {
|
|
29
|
+
return node.parentId ? graph.closest(node.parentId, isGeneratedFrame) : void 0;
|
|
30
|
+
}
|
|
31
|
+
/** The text a generated frame edits in place: a sticky note's body or a connector's label. */
|
|
32
|
+
function generatedFrameText(graph, node) {
|
|
33
|
+
return generatedFrameKind(node)?.text(graph, node);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `changes` with what a width or height in them also sets on a generated frame
|
|
37
|
+
* (`GeneratedFrameKind.sized`); fields `changes` sets itself, such as an undo restoring them, win.
|
|
38
|
+
*/
|
|
39
|
+
function withGeneratedFrameSize(node, changes) {
|
|
40
|
+
const kind = generatedFrameKind(node);
|
|
41
|
+
if (!kind?.sized || changes.width === void 0 && changes.height === void 0) return changes;
|
|
42
|
+
return {
|
|
43
|
+
...kind.sized(changes, node),
|
|
44
|
+
...changes
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Whether a layer turns: any layer but a generated frame that stays upright. */
|
|
48
|
+
function layerRotates(node) {
|
|
49
|
+
return generatedFrameKind(node)?.rotates ?? true;
|
|
50
|
+
}
|
|
51
|
+
/** Whether a layer's resize handles and W and H fields resize it freely. */
|
|
52
|
+
function layerResizes(node) {
|
|
53
|
+
return generatedFrameKind(node)?.resizes ?? true;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { DEFAULT_STICKY_COLOR, GENERATED_FRAME_TYPES, SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, buildShapeWithTextLabel, buildStickySublayers, createShapeWithText, createSticky, generatedFrameKind, generatedFrameOwner, generatedFrameText, isGeneratedFrame, isWideSticky, layerResizes, layerRotates, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth, withGeneratedFrameSize };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/generated/index.ts"],"sourcesContent":["import { CONNECTOR_KIND } from '../connectors/sublayers'\nimport type { SceneGraph } from '../graph'\nimport type { NodeType, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\nimport { SHAPE_WITH_TEXT_KIND } from './shape-with-text'\nimport { STICKY_KIND } from './sticky'\n\n/**\n * Layers Figma generates from a template, which it calls immutable frames: their sublayers come\n * from the type and its settings, and a user edits them only through the frame. A sticky note's\n * body and author are such sublayers. They are real children here, so layout, drawing and text\n * editing treat them as any other layer, but nothing may add, move or remove them.\n *\n * Each type is described once, here; the editor and file formats ask it instead of testing for\n * the type.\n */\nconst GENERATED_FRAME_KINDS = {\n SHAPE_WITH_TEXT: SHAPE_WITH_TEXT_KIND,\n STICKY: STICKY_KIND,\n CONNECTOR: CONNECTOR_KIND\n} satisfies Partial<Record<NodeType, GeneratedFrameKind>>\n\n/** The layer types that are generated frames, for tables that must cover each of them. */\nexport type GeneratedFrameType = keyof typeof GENERATED_FRAME_KINDS\n\nexport const GENERATED_FRAME_TYPES: ReadonlySet<NodeType> = new Set(\n Object.keys(GENERATED_FRAME_KINDS) as GeneratedFrameType[]\n)\n\n/** What a generated frame's type says about it, or undefined for any other layer. */\nexport function generatedFrameKind(node: Pick<SceneNode, 'type'>): GeneratedFrameKind | undefined {\n return isGeneratedFrame(node) ? GENERATED_FRAME_KINDS[node.type] : undefined\n}\n\nexport function isGeneratedFrame<N extends Pick<SceneNode, 'type'>>(\n node: N\n): node is N & { type: GeneratedFrameType } {\n return GENERATED_FRAME_TYPES.has(node.type)\n}\n\n/** The generated frame a layer belongs to, if it is one of its sublayers. */\nexport function generatedFrameOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n return node.parentId ? graph.closest(node.parentId, isGeneratedFrame) : undefined\n}\n\n/** The text a generated frame edits in place: a sticky note's body or a connector's label. */\nexport function generatedFrameText(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n return generatedFrameKind(node)?.text(graph, node)\n}\n\n/**\n * `changes` with what a width or height in them also sets on a generated frame\n * (`GeneratedFrameKind.sized`); fields `changes` sets itself, such as an undo restoring them, win.\n */\nexport function withGeneratedFrameSize(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const kind = generatedFrameKind(node)\n if (!kind?.sized || (changes.width === undefined && changes.height === undefined)) return changes\n return { ...kind.sized(changes, node), ...changes }\n}\n\n/** Whether a layer turns: any layer but a generated frame that stays upright. */\nexport function layerRotates(node: Pick<SceneNode, 'type'>): boolean {\n return generatedFrameKind(node)?.rotates ?? true\n}\n\n/** Whether a layer's resize handles and W and H fields resize it freely. */\nexport function layerResizes(node: Pick<SceneNode, 'type'>): boolean {\n return generatedFrameKind(node)?.resizes ?? true\n}\n\nexport type { GeneratedFrameKind } from './kind'\nexport * from './shape-with-text'\nexport * from './sticky'\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,wBAAwB;CAC5B,iBAAiB;CACjB,QAAQ;CACR,WAAW;AACb;AAKA,MAAa,wBAA+C,IAAI,IAC9D,OAAO,KAAK,qBAAqB,CACnC;;AAGA,SAAgB,mBAAmB,MAA+D;CAChG,OAAO,iBAAiB,IAAI,IAAI,sBAAsB,KAAK,QAAQ,KAAA;AACrE;AAEA,SAAgB,iBACd,MAC0C;CAC1C,OAAO,sBAAsB,IAAI,KAAK,IAAI;AAC5C;;AAGA,SAAgB,oBAAoB,OAAmB,MAAwC;CAC7F,OAAO,KAAK,WAAW,MAAM,QAAQ,KAAK,UAAU,gBAAgB,IAAI,KAAA;AAC1E;;AAGA,SAAgB,mBAAmB,OAAmB,MAAwC;CAC5F,OAAO,mBAAmB,IAAI,CAAC,EAAE,KAAK,OAAO,IAAI;AACnD;;;;;AAMA,SAAgB,uBACd,MACA,SACoB;CACpB,MAAM,OAAO,mBAAmB,IAAI;CACpC,IAAI,CAAC,MAAM,SAAU,QAAQ,UAAU,KAAA,KAAa,QAAQ,WAAW,KAAA,GAAY,OAAO;CAC1F,OAAO;EAAE,GAAG,KAAK,MAAM,SAAS,IAAI;EAAG,GAAG;CAAQ;AACpD;;AAGA,SAAgB,aAAa,MAAwC;CACnE,OAAO,mBAAmB,IAAI,CAAC,EAAE,WAAW;AAC9C;;AAGA,SAAgB,aAAa,MAAwC;CACnE,OAAO,mBAAmB,IAAI,CAAC,EAAE,WAAW;AAC9C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { SceneNode } from "../types.js";
|
|
3
|
+
//#region src/generated/kind.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* What the editor and file formats need to know about one type of generated frame, so they ask
|
|
6
|
+
* the type rather than test for it. Each type defines one in its own module.
|
|
7
|
+
*/
|
|
8
|
+
interface GeneratedFrameKind {
|
|
9
|
+
/** Whether the frame still has its template's layers; one that lost them is a plain frame. */
|
|
10
|
+
complete(graph: SceneGraph, frame: SceneNode): boolean;
|
|
11
|
+
/** The text a user types into in place: on double-click or Enter, and as a script's `text`. */
|
|
12
|
+
text(graph: SceneGraph, frame: SceneNode): SceneNode | undefined;
|
|
13
|
+
/** Whether the frame turns; FigJam keeps sticky notes upright. */
|
|
14
|
+
rotates: boolean;
|
|
15
|
+
/** Whether the frame's resize handles and W and H fields resize it freely. */
|
|
16
|
+
resizes: boolean;
|
|
17
|
+
/** Whether it takes its name from its text until the user names it, as a sticky note does. */
|
|
18
|
+
namedByText: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* What a width or height set on `frame` from outside layout also sets on it, such as the height
|
|
21
|
+
* a shape with text was given, which layout grows it from.
|
|
22
|
+
*/
|
|
23
|
+
sized?(changes: Partial<SceneNode>, frame: SceneNode): Partial<SceneNode>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { GeneratedFrameKind };
|
|
27
|
+
//# sourceMappingURL=kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind.d.ts","names":[],"sources":["../../src/generated/kind.ts"],"mappings":";;;;;;;UAOiB;;EAEf,SAAS,OAAO,YAAY,OAAO;;EAEnC,KAAK,OAAO,YAAY,OAAO,YAAY;;EAE3C;;EAEA;;EAEA;;;;;EAKA,OAAO,SAAS,QAAQ,YAAY,OAAO,YAAY,QAAQ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { ShapeWithTextType } from "../shape-with-text/kinds.js";
|
|
3
|
+
import { SceneNode } from "../types.js";
|
|
4
|
+
import { GeneratedFrameKind } from "./kind.js";
|
|
5
|
+
//#region src/generated/shape-with-text.d.ts
|
|
6
|
+
/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */
|
|
7
|
+
declare const SHAPE_WITH_TEXT_SIZE = 176;
|
|
8
|
+
/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */
|
|
9
|
+
declare const SHAPE_WITH_TEXT_CORNER_RADIUS = 6;
|
|
10
|
+
/** How the label sits in its shape: as wide as the label box, as tall as its text. */
|
|
11
|
+
declare const SHAPE_WITH_TEXT_LABEL_LAYOUT: {
|
|
12
|
+
readonly textAutoResize: "HEIGHT";
|
|
13
|
+
readonly layoutAlignSelf: "STRETCH";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The shape's own layout: a vertical auto layout that centres the label in the label box of its
|
|
17
|
+
* kind, which the padding leaves free. The padding follows the kind and size, so it is set again
|
|
18
|
+
* whenever either changes.
|
|
19
|
+
*/
|
|
20
|
+
declare function shapeWithTextFrameFields(kind: ShapeWithTextType, width: number, height: number): Partial<SceneNode>;
|
|
21
|
+
/**
|
|
22
|
+
* What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the
|
|
23
|
+
* label area, and the corners a rounded rectangle leaves go back to FigJam's 6.
|
|
24
|
+
*/
|
|
25
|
+
declare function shapeWithTextKindFields(shape: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>, kind: ShapeWithTextType): Partial<SceneNode>;
|
|
26
|
+
/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */
|
|
27
|
+
declare function shapeWithTextLabelFields(): Partial<SceneNode>;
|
|
28
|
+
/** A shape's label: its one text sublayer. */
|
|
29
|
+
declare function shapeWithTextLabel(graph: SceneGraph, shape: SceneNode): SceneNode | null;
|
|
30
|
+
/**
|
|
31
|
+
* A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes
|
|
32
|
+
* its name from its label until it is named. A height set on it by a resize, a field or a script
|
|
33
|
+
* is the height it was given, which layout grows it from when its label needs more room; once
|
|
34
|
+
* that height changes, FigJam keeps it and truncates the label instead.
|
|
35
|
+
*/
|
|
36
|
+
declare const SHAPE_WITH_TEXT_KIND: GeneratedFrameKind;
|
|
37
|
+
/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */
|
|
38
|
+
declare function buildShapeWithTextLabel(graph: SceneGraph, shape: SceneNode, props?: Partial<SceneNode>): SceneNode;
|
|
39
|
+
/** A new shape with text and its label; the caller lays it out to grow it to its text. */
|
|
40
|
+
declare function createShapeWithText(graph: SceneGraph, parentId: string, props?: Partial<SceneNode>, label?: Partial<SceneNode>): SceneNode;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
43
|
+
//# sourceMappingURL=shape-with-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-with-text.d.ts","names":[],"sources":["../../src/generated/shape-with-text.ts"],"mappings":";;;;;;cAUa;;cAEA;;cAWA;WAAA;WAAA;;;;;;;iBAUG,yBACd,MAAM,mBACN,eACA,iBACC,QAAQ;;;;;iBAwBK,wBACd,OAAO,KAAK,sDACZ,MAAM,oBACL,QAAQ;;iBAWK,4BAA4B,QAAQ;;iBAcpC,mBAAmB,OAAO,YAAY,OAAO,YAAY;;;;;;;cAc5D,sBAAsB;;iBAanB,wBACd,OAAO,YACP,OAAO,WACP,QAAO,QAAQ,aACd;;iBAea,oBACd,OAAO,YACP,kBACA,QAAO,QAAQ,YACf,QAAO,QAAQ,aACd"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { BLACK } from "../constants.js";
|
|
2
|
+
import { lineHeightPixels } from "../text/lengths.js";
|
|
3
|
+
import { FIGJAM_TYPEFACES, figJamTextSizeFields } from "../figjam/text.js";
|
|
4
|
+
import { shapeWithTextLabelBox } from "../shape-with-text/fit.js";
|
|
5
|
+
//#region src/generated/shape-with-text.ts
|
|
6
|
+
/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */
|
|
7
|
+
const SHAPE_WITH_TEXT_SIZE = 176;
|
|
8
|
+
/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */
|
|
9
|
+
const SHAPE_WITH_TEXT_CORNER_RADIUS = 6;
|
|
10
|
+
/**
|
|
11
|
+
* FigJam keeps a rounded rectangle's corner radius at 0.4 of its shorter side, through resizes,
|
|
12
|
+
* measured in FigJam; Figma draws the shape from that radius.
|
|
13
|
+
*/
|
|
14
|
+
const ROUNDED_RECTANGLE_RADIUS = .4;
|
|
15
|
+
const LABEL_FILL = {
|
|
16
|
+
type: "SOLID",
|
|
17
|
+
color: { ...BLACK },
|
|
18
|
+
opacity: .8,
|
|
19
|
+
visible: true
|
|
20
|
+
};
|
|
21
|
+
/** How the label sits in its shape: as wide as the label box, as tall as its text. */
|
|
22
|
+
const SHAPE_WITH_TEXT_LABEL_LAYOUT = {
|
|
23
|
+
textAutoResize: "HEIGHT",
|
|
24
|
+
layoutAlignSelf: "STRETCH"
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The shape's own layout: a vertical auto layout that centres the label in the label box of its
|
|
28
|
+
* kind, which the padding leaves free. The padding follows the kind and size, so it is set again
|
|
29
|
+
* whenever either changes.
|
|
30
|
+
*/
|
|
31
|
+
function shapeWithTextFrameFields(kind, width, height) {
|
|
32
|
+
const box = shapeWithTextLabelBox(kind, width, height);
|
|
33
|
+
return {
|
|
34
|
+
layoutMode: "VERTICAL",
|
|
35
|
+
primaryAxisAlign: "CENTER",
|
|
36
|
+
counterAxisAlign: "CENTER",
|
|
37
|
+
primaryAxisSizing: "FIXED",
|
|
38
|
+
counterAxisSizing: "FIXED",
|
|
39
|
+
itemSpacing: 0,
|
|
40
|
+
paddingTop: box.y,
|
|
41
|
+
paddingRight: Math.max(0, width - box.x - box.width),
|
|
42
|
+
paddingBottom: Math.max(0, height - box.y - box.height),
|
|
43
|
+
paddingLeft: box.x,
|
|
44
|
+
clipsContent: false,
|
|
45
|
+
...kind === "ROUNDED_RECTANGLE" ? { cornerRadius: ROUNDED_RECTANGLE_RADIUS * Math.min(width, height) } : {}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the
|
|
50
|
+
* label area, and the corners a rounded rectangle leaves go back to FigJam's 6.
|
|
51
|
+
*/
|
|
52
|
+
function shapeWithTextKindFields(shape, kind) {
|
|
53
|
+
return {
|
|
54
|
+
shapeWithTextType: kind,
|
|
55
|
+
...shape.shapeWithTextType === "ROUNDED_RECTANGLE" && kind !== shape.shapeWithTextType ? { cornerRadius: 6 } : {},
|
|
56
|
+
...shapeWithTextFrameFields(kind, shape.width, shape.height)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */
|
|
60
|
+
function shapeWithTextLabelFields() {
|
|
61
|
+
return {
|
|
62
|
+
name: "Text",
|
|
63
|
+
fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,
|
|
64
|
+
fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,
|
|
65
|
+
...figJamTextSizeFields("small"),
|
|
66
|
+
textAlignHorizontal: "CENTER",
|
|
67
|
+
textAlignVertical: "TOP",
|
|
68
|
+
fills: [{
|
|
69
|
+
...LABEL_FILL,
|
|
70
|
+
color: { ...LABEL_FILL.color }
|
|
71
|
+
}],
|
|
72
|
+
...SHAPE_WITH_TEXT_LABEL_LAYOUT
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** A shape's label: its one text sublayer. */
|
|
76
|
+
function shapeWithTextLabel(graph, shape) {
|
|
77
|
+
if (shape.type !== "SHAPE_WITH_TEXT") return null;
|
|
78
|
+
const children = graph.getChildren(shape.id);
|
|
79
|
+
if (children.length !== 1) return null;
|
|
80
|
+
const [label] = children;
|
|
81
|
+
return label.type === "TEXT" ? label : null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes
|
|
85
|
+
* its name from its label until it is named. A height set on it by a resize, a field or a script
|
|
86
|
+
* is the height it was given, which layout grows it from when its label needs more room; once
|
|
87
|
+
* that height changes, FigJam keeps it and truncates the label instead.
|
|
88
|
+
*/
|
|
89
|
+
const SHAPE_WITH_TEXT_KIND = {
|
|
90
|
+
complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,
|
|
91
|
+
text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? void 0,
|
|
92
|
+
rotates: true,
|
|
93
|
+
resizes: true,
|
|
94
|
+
namedByText: true,
|
|
95
|
+
sized: ({ height }, shape) => height === void 0 || height === shape.height ? {} : {
|
|
96
|
+
shapeUserHeight: height,
|
|
97
|
+
shapeTruncates: true
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */
|
|
101
|
+
function buildShapeWithTextLabel(graph, shape, props = {}) {
|
|
102
|
+
const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height);
|
|
103
|
+
const fields = shapeWithTextLabelFields();
|
|
104
|
+
return graph.createNode("TEXT", shape.id, {
|
|
105
|
+
...fields,
|
|
106
|
+
x: box.x,
|
|
107
|
+
y: box.y,
|
|
108
|
+
width: box.width,
|
|
109
|
+
height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? void 0,
|
|
110
|
+
text: "",
|
|
111
|
+
...props
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/** A new shape with text and its label; the caller lays it out to grow it to its text. */
|
|
115
|
+
function createShapeWithText(graph, parentId, props = {}, label = {}) {
|
|
116
|
+
const kind = props.shapeWithTextType ?? "SQUARE";
|
|
117
|
+
const width = props.width ?? 176;
|
|
118
|
+
const height = props.height ?? 176;
|
|
119
|
+
const shape = graph.createNode("SHAPE_WITH_TEXT", parentId, {
|
|
120
|
+
name: "Shape with text",
|
|
121
|
+
cornerRadius: 6,
|
|
122
|
+
...props,
|
|
123
|
+
shapeWithTextType: kind,
|
|
124
|
+
width,
|
|
125
|
+
height,
|
|
126
|
+
shapeUserHeight: props.shapeUserHeight ?? height,
|
|
127
|
+
...shapeWithTextFrameFields(kind, width, height)
|
|
128
|
+
});
|
|
129
|
+
buildShapeWithTextLabel(graph, shape, label);
|
|
130
|
+
return shape;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=shape-with-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-with-text.js","names":[],"sources":["../../src/generated/shape-with-text.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport { FIGJAM_TYPEFACES, figJamTextSizeFields } from '../figjam/text'\nimport type { SceneGraph } from '../index'\nimport { shapeWithTextLabelBox } from '../shape-with-text/fit'\nimport type { ShapeWithTextType } from '../shape-with-text/kinds'\nimport { lineHeightPixels } from '../text/lengths'\nimport type { Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */\nexport const SHAPE_WITH_TEXT_SIZE = 176\n/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */\nexport const SHAPE_WITH_TEXT_CORNER_RADIUS = 6\n\n/**\n * FigJam keeps a rounded rectangle's corner radius at 0.4 of its shorter side, through resizes,\n * measured in FigJam; Figma draws the shape from that radius.\n */\nconst ROUNDED_RECTANGLE_RADIUS = 0.4\n\nconst LABEL_FILL: Fill = { type: 'SOLID', color: { ...BLACK }, opacity: 0.8, visible: true }\n\n/** How the label sits in its shape: as wide as the label box, as tall as its text. */\nexport const SHAPE_WITH_TEXT_LABEL_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/**\n * The shape's own layout: a vertical auto layout that centres the label in the label box of its\n * kind, which the padding leaves free. The padding follows the kind and size, so it is set again\n * whenever either changes.\n */\nexport function shapeWithTextFrameFields(\n kind: ShapeWithTextType,\n width: number,\n height: number\n): Partial<SceneNode> {\n const box = shapeWithTextLabelBox(kind, width, height)\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'CENTER',\n counterAxisAlign: 'CENTER',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n paddingTop: box.y,\n paddingRight: Math.max(0, width - box.x - box.width),\n paddingBottom: Math.max(0, height - box.y - box.height),\n paddingLeft: box.x,\n clipsContent: false,\n ...(kind === 'ROUNDED_RECTANGLE'\n ? { cornerRadius: ROUNDED_RECTANGLE_RADIUS * Math.min(width, height) }\n : {})\n }\n}\n\n/**\n * What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the\n * label area, and the corners a rounded rectangle leaves go back to FigJam's 6.\n */\nexport function shapeWithTextKindFields(\n shape: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>,\n kind: ShapeWithTextType\n): Partial<SceneNode> {\n const leavesRounded =\n shape.shapeWithTextType === 'ROUNDED_RECTANGLE' && kind !== shape.shapeWithTextType\n return {\n shapeWithTextType: kind,\n ...(leavesRounded ? { cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS } : {}),\n ...shapeWithTextFrameFields(kind, shape.width, shape.height)\n }\n}\n\n/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */\nexport function shapeWithTextLabelFields(): Partial<SceneNode> {\n return {\n name: 'Text',\n fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,\n fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,\n ...figJamTextSizeFields('small'),\n textAlignHorizontal: 'CENTER',\n textAlignVertical: 'TOP',\n fills: [{ ...LABEL_FILL, color: { ...LABEL_FILL.color } }],\n ...SHAPE_WITH_TEXT_LABEL_LAYOUT\n }\n}\n\n/** A shape's label: its one text sublayer. */\nexport function shapeWithTextLabel(graph: SceneGraph, shape: SceneNode): SceneNode | null {\n if (shape.type !== 'SHAPE_WITH_TEXT') return null\n const children = graph.getChildren(shape.id)\n if (children.length !== 1) return null\n const [label] = children\n return label.type === 'TEXT' ? label : null\n}\n\n/**\n * A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes\n * its name from its label until it is named. A height set on it by a resize, a field or a script\n * is the height it was given, which layout grows it from when its label needs more room; once\n * that height changes, FigJam keeps it and truncates the label instead.\n */\nexport const SHAPE_WITH_TEXT_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,\n text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? undefined,\n rotates: true,\n resizes: true,\n namedByText: true,\n sized: ({ height }, shape) =>\n height === undefined || height === shape.height\n ? {}\n : { shapeUserHeight: height, shapeTruncates: true }\n}\n\n/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */\nexport function buildShapeWithTextLabel(\n graph: SceneGraph,\n shape: SceneNode,\n props: Partial<SceneNode> = {}\n): SceneNode {\n const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height)\n const fields = shapeWithTextLabelFields()\n return graph.createNode('TEXT', shape.id, {\n ...fields,\n x: box.x,\n y: box.y,\n width: box.width,\n height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? undefined,\n text: '',\n ...props\n })\n}\n\n/** A new shape with text and its label; the caller lays it out to grow it to its text. */\nexport function createShapeWithText(\n graph: SceneGraph,\n parentId: string,\n props: Partial<SceneNode> = {},\n label: Partial<SceneNode> = {}\n): SceneNode {\n const kind = props.shapeWithTextType ?? 'SQUARE'\n const width = props.width ?? SHAPE_WITH_TEXT_SIZE\n const height = props.height ?? SHAPE_WITH_TEXT_SIZE\n const shape = graph.createNode('SHAPE_WITH_TEXT', parentId, {\n name: 'Shape with text',\n cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS,\n ...props,\n shapeWithTextType: kind,\n width,\n height,\n shapeUserHeight: props.shapeUserHeight ?? height,\n ...shapeWithTextFrameFields(kind, width, height)\n })\n buildShapeWithTextLabel(graph, shape, label)\n return shape\n}\n"],"mappings":";;;;;;AAUA,MAAa,uBAAuB;;AAEpC,MAAa,gCAAgC;;;;;AAM7C,MAAM,2BAA2B;AAEjC,MAAM,aAAmB;CAAE,MAAM;CAAS,OAAO,EAAE,GAAG,MAAM;CAAG,SAAS;CAAK,SAAS;AAAK;;AAG3F,MAAa,+BAA+B;CAC1C,gBAAgB;CAChB,iBAAiB;AACnB;;;;;;AAOA,SAAgB,yBACd,MACA,OACA,QACoB;CACpB,MAAM,MAAM,sBAAsB,MAAM,OAAO,MAAM;CACrD,OAAO;EACL,YAAY;EACZ,kBAAkB;EAClB,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;EACb,YAAY,IAAI;EAChB,cAAc,KAAK,IAAI,GAAG,QAAQ,IAAI,IAAI,IAAI,KAAK;EACnD,eAAe,KAAK,IAAI,GAAG,SAAS,IAAI,IAAI,IAAI,MAAM;EACtD,aAAa,IAAI;EACjB,cAAc;EACd,GAAI,SAAS,sBACT,EAAE,cAAc,2BAA2B,KAAK,IAAI,OAAO,MAAM,EAAE,IACnE,CAAC;CACP;AACF;;;;;AAMA,SAAgB,wBACd,OACA,MACoB;CAGpB,OAAO;EACL,mBAAmB;EACnB,GAHA,MAAM,sBAAsB,uBAAuB,SAAS,MAAM,oBAG9C,EAAE,cAAA,EAA4C,IAAI,CAAC;EACvE,GAAG,yBAAyB,MAAM,MAAM,OAAO,MAAM,MAAM;CAC7D;AACF;;AAGA,SAAgB,2BAA+C;CAC7D,OAAO;EACL,MAAM;EACN,YAAY,iBAAiB,OAAO;EACpC,YAAY,iBAAiB,OAAO;EACpC,GAAG,qBAAqB,OAAO;EAC/B,qBAAqB;EACrB,mBAAmB;EACnB,OAAO,CAAC;GAAE,GAAG;GAAY,OAAO,EAAE,GAAG,WAAW,MAAM;EAAE,CAAC;EACzD,GAAG;CACL;AACF;;AAGA,SAAgB,mBAAmB,OAAmB,OAAoC;CACxF,IAAI,MAAM,SAAS,mBAAmB,OAAO;CAC7C,MAAM,WAAW,MAAM,YAAY,MAAM,EAAE;CAC3C,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,MAAM,CAAC,SAAS;CAChB,OAAO,MAAM,SAAS,SAAS,QAAQ;AACzC;;;;;;;AAQA,MAAa,uBAA2C;CACtD,WAAW,OAAO,UAAU,mBAAmB,OAAO,KAAK,MAAM;CACjE,OAAO,OAAO,UAAU,mBAAmB,OAAO,KAAK,KAAK,KAAA;CAC5D,SAAS;CACT,SAAS;CACT,aAAa;CACb,QAAQ,EAAE,UAAU,UAClB,WAAW,KAAA,KAAa,WAAW,MAAM,SACrC,CAAC,IACD;EAAE,iBAAiB;EAAQ,gBAAgB;CAAK;AACxD;;AAGA,SAAgB,wBACd,OACA,OACA,QAA4B,CAAC,GAClB;CACX,MAAM,MAAM,sBAAsB,MAAM,mBAAmB,MAAM,OAAO,MAAM,MAAM;CACpF,MAAM,SAAS,yBAAyB;CACxC,OAAO,MAAM,WAAW,QAAQ,MAAM,IAAI;EACxC,GAAG;EACH,GAAG,IAAI;EACP,GAAG,IAAI;EACP,OAAO,IAAI;EACX,QAAQ,iBAAiB,OAAO,cAAc,MAAM,OAAO,YAAY,CAAC,KAAK,KAAA;EAC7E,MAAM;EACN,GAAG;CACL,CAAC;AACH;;AAGA,SAAgB,oBACd,OACA,UACA,QAA4B,CAAC,GAC7B,QAA4B,CAAC,GAClB;CACX,MAAM,OAAO,MAAM,qBAAqB;CACxC,MAAM,QAAQ,MAAM,SAAA;CACpB,MAAM,SAAS,MAAM,UAAA;CACrB,MAAM,QAAQ,MAAM,WAAW,mBAAmB,UAAU;EAC1D,MAAM;EACN,cAAA;EACA,GAAG;EACH,mBAAmB;EACnB;EACA;EACA,iBAAiB,MAAM,mBAAmB;EAC1C,GAAG,yBAAyB,MAAM,OAAO,MAAM;CACjD,CAAC;CACD,wBAAwB,OAAO,OAAO,KAAK;CAC3C,OAAO;AACT"}
|