@pairdraw/scene-graph 0.0.0-stage → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/agent-notes/index.d.ts +3 -0
- package/dist/agent-notes/index.js +3 -0
- package/dist/agent-notes/model.d.ts +23 -0
- package/dist/agent-notes/model.d.ts.map +1 -0
- package/dist/agent-notes/model.js +36 -0
- package/dist/agent-notes/model.js.map +1 -0
- package/dist/agent-notes/schema.d.ts +19 -0
- package/dist/agent-notes/schema.d.ts.map +1 -0
- package/dist/agent-notes/schema.js +17 -0
- package/dist/agent-notes/schema.js.map +1 -0
- package/dist/arrow-caps.d.ts +65 -0
- package/dist/arrow-caps.d.ts.map +1 -0
- package/dist/arrow-caps.js +365 -0
- package/dist/arrow-caps.js.map +1 -0
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js +27 -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 +273 -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/behaviours/spec.js +157 -0
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +18 -0
- package/dist/bindings.js.map +1 -0
- package/dist/browser-node/index.d.ts +3 -0
- package/dist/browser-node/index.js +3 -0
- package/dist/browser-node/model.d.ts +18 -0
- package/dist/browser-node/model.d.ts.map +1 -0
- package/dist/browser-node/model.js +31 -0
- package/dist/browser-node/model.js.map +1 -0
- package/dist/browser-node/schema.d.ts +23 -0
- package/dist/browser-node/schema.d.ts.map +1 -0
- package/dist/browser-node/schema.js +44 -0
- package/dist/browser-node/schema.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 +57 -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 +78 -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 +20 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/color/contrast.js +69 -0
- 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/comments/document.js +33 -0
- 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/comments/merge.js +58 -0
- 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/comments/threads.js +132 -0
- 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 +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/library-page.d.ts +11 -0
- package/dist/components/library-page.d.ts.map +1 -0
- package/dist/components/library-page.js +21 -0
- package/dist/components/library-page.js.map +1 -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 +32 -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 +209 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +31 -0
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +99 -0
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +276 -0
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +45 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +256 -0
- 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/css/grid.js +63 -0
- 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 +18 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +19 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +33 -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 +14 -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 +199 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +277 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +68 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +89 -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 +46 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +62 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +29 -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 +119 -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 +234 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +105 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +374 -0
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +74 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +211 -0
- package/dist/gradient.js.map +1 -0
- package/dist/graph.d.ts +186 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +630 -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/group-bounds.js +146 -0
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +19 -0
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +39 -0
- package/dist/guides.js.map +1 -0
- package/dist/hit-test.d.ts +49 -0
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +315 -0
- package/dist/hit-test.js.map +1 -0
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/icons/glyph.js +109 -0
- 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 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +85 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- 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 +162 -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 +63 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +305 -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/modes.js +26 -0
- package/dist/instances/modes.js.map +1 -0
- package/dist/instances/overrides.d.ts +63 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +164 -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/replacements.d.ts +19 -0
- package/dist/instances/replacements.d.ts.map +1 -0
- package/dist/instances/replacements.js +67 -0
- package/dist/instances/replacements.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 +305 -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/index.js +5 -0
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +60 -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 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +120 -0
- 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/naming.d.ts +9 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +16 -0
- package/dist/naming.js.map +1 -0
- package/dist/node-defaults.d.ts +19 -0
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +243 -0
- package/dist/node-defaults.js.map +1 -0
- package/dist/order-keys.d.ts +39 -0
- package/dist/order-keys.d.ts.map +1 -0
- package/dist/order-keys.js +136 -0
- package/dist/order-keys.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 +103 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +64 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +36 -0
- package/dist/parse-path.d.ts.map +1 -0
- package/dist/parse-path.js +200 -0
- package/dist/parse-path.js.map +1 -0
- package/dist/plugin-data/citation.d.ts +13 -0
- package/dist/plugin-data/citation.d.ts.map +1 -0
- package/dist/plugin-data/citation.js +23 -0
- package/dist/plugin-data/citation.js.map +1 -0
- 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 +79 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +220 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +214 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +5 -0
- package/dist/plugin-data/index.js +5 -0
- package/dist/plugin-data/schema.d.ts +18 -0
- package/dist/plugin-data/schema.d.ts.map +1 -0
- package/dist/plugin-data/schema.js +29 -0
- package/dist/plugin-data/schema.js.map +1 -0
- package/dist/polygon.d.ts +55 -0
- package/dist/polygon.d.ts.map +1 -0
- package/dist/polygon.js +220 -0
- package/dist/polygon.js.map +1 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +63 -0
- package/dist/preview.js.map +1 -0
- package/dist/primitives/index.d.ts +43 -0
- 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.d.ts +7 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +25 -0
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +41 -0
- package/dist/resize.d.ts.map +1 -0
- package/dist/resize.js +288 -0
- 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 +150 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +22 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +71 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/script/index.d.ts +2 -0
- package/dist/script/index.js +2 -0
- package/dist/script/schema.d.ts +29 -0
- package/dist/script/schema.d.ts.map +1 -0
- package/dist/script/schema.js +51 -0
- package/dist/script/schema.js.map +1 -0
- package/dist/shaders/directives.d.ts +43 -0
- package/dist/shaders/directives.d.ts.map +1 -0
- package/dist/shaders/directives.js +293 -0
- package/dist/shaders/directives.js.map +1 -0
- package/dist/shaders/index.d.ts +5 -0
- package/dist/shaders/index.js +5 -0
- package/dist/shaders/model.d.ts +58 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +109 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +86 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +65 -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 +36 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +116 -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 +74 -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 +61 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +264 -0
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.d.ts +6 -0
- package/dist/source-metadata.d.ts.map +1 -0
- package/dist/source-metadata.js +11 -0
- 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 +13 -0
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/text/direction.js +31 -0
- 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 +18 -0
- 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/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 +7 -0
- package/dist/transfer/index.js +7 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +82 -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 +910 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +89 -0
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -0
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +236 -0
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +66 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +251 -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 +30 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +89 -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 +246 -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 +21 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +58 -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/variant-name.d.ts +6 -0
- package/dist/variant-name.d.ts.map +1 -0
- package/dist/variant-name.js +17 -0
- package/dist/variant-name.js.map +1 -0
- package/dist/variant-properties.d.ts +18 -0
- package/dist/variant-properties.d.ts.map +1 -0
- package/dist/variant-properties.js +74 -0
- package/dist/variant-properties.js.map +1 -0
- package/dist/vector-network.d.ts +48 -0
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +352 -0
- package/dist/vector-network.js.map +1 -0
- package/package.json +352 -4
- package/src/agent-notes/index.ts +2 -0
- package/src/agent-notes/model.ts +46 -0
- package/src/agent-notes/schema.ts +28 -0
- package/src/arrow-caps.ts +364 -0
- package/src/asset-keys.ts +25 -0
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +185 -0
- package/src/behaviours/layers.ts +51 -0
- package/src/behaviours/model.ts +184 -0
- package/src/behaviours/schema.ts +93 -0
- package/src/behaviours/spec.ts +178 -0
- package/src/bindings.ts +20 -0
- package/src/browser-node/index.ts +2 -0
- package/src/browser-node/model.ts +35 -0
- package/src/browser-node/schema.ts +62 -0
- package/src/buffered-events.ts +64 -0
- package/src/checkpoint.ts +123 -0
- package/src/clipping.ts +112 -0
- package/src/color/contrast.ts +71 -0
- package/src/color/index.ts +89 -0
- package/src/color/management.ts +210 -0
- package/src/color/normalize.ts +7 -0
- package/src/color/okhcl.ts +201 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +51 -0
- package/src/comments/index.ts +5 -0
- package/src/comments/list.ts +52 -0
- package/src/comments/merge.ts +63 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +156 -0
- package/src/components/exposure.ts +61 -0
- package/src/components/index.ts +9 -0
- package/src/components/library-page.ts +17 -0
- package/src/components/properties.ts +241 -0
- package/src/components/variants.ts +53 -0
- 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 +204 -0
- package/src/constants.ts +13 -0
- package/src/coordinate.ts +298 -0
- package/src/copy.ts +341 -0
- package/src/css/grid.ts +70 -0
- package/src/css/index.ts +10 -0
- package/src/css/layout.ts +53 -0
- package/src/css/shadows.ts +68 -0
- package/src/css/text.ts +84 -0
- package/src/css/values.ts +42 -0
- package/src/events.ts +21 -0
- package/src/export-format.ts +33 -0
- package/src/export-scale.ts +16 -0
- package/src/fields/appearance.ts +35 -0
- package/src/fields/geometry.ts +11 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +64 -0
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +308 -0
- package/src/figjam/text.ts +78 -0
- package/src/font-style.ts +121 -0
- package/src/generated/index.ts +81 -0
- package/src/generated/kind.ts +26 -0
- package/src/generated/shape-with-text.ts +132 -0
- package/src/generated/sticky.ts +214 -0
- package/src/geometry.ts +490 -0
- package/src/gradient.ts +275 -0
- package/src/graph.ts +842 -0
- package/src/group-bounds.ts +178 -0
- package/src/guides.ts +47 -0
- package/src/hit-test.ts +501 -0
- package/src/icons/glyph.ts +128 -0
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +63 -0
- package/src/icons/schema.ts +34 -0
- package/src/ids.ts +34 -0
- package/src/images.ts +89 -0
- package/src/index.ts +4 -0
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +84 -0
- package/src/instances/copies.ts +244 -0
- package/src/instances/cycles.ts +73 -0
- package/src/instances/fields.ts +90 -0
- package/src/instances/index.ts +467 -0
- package/src/instances/main-component.ts +61 -0
- package/src/instances/modes.ts +39 -0
- package/src/instances/overrides.ts +240 -0
- package/src/instances/placement.ts +29 -0
- package/src/instances/replacements.ts +80 -0
- package/src/instances/source-walk.ts +35 -0
- package/src/instances/sync.ts +556 -0
- package/src/instances/vector-geometry.ts +81 -0
- package/src/layout/aspect-ratio.ts +51 -0
- package/src/layout/guides.ts +132 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/keywords.ts +74 -0
- package/src/layout/sizing.ts +196 -0
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +116 -0
- package/src/mutation-impact.ts +85 -0
- package/src/naming.ts +11 -0
- package/src/node-defaults.ts +260 -0
- package/src/order-keys.ts +162 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +72 -0
- package/src/parse-path.ts +244 -0
- package/src/plugin-data/citation.ts +27 -0
- package/src/plugin-data/field.ts +140 -0
- package/src/plugin-data/fields.ts +306 -0
- package/src/plugin-data/index.ts +3 -0
- package/src/plugin-data/schema.ts +35 -0
- package/src/polygon.ts +228 -0
- package/src/preview.ts +80 -0
- package/src/primitives/index.ts +44 -0
- package/src/primitives/schema.ts +14 -0
- package/src/random.ts +28 -0
- package/src/resize.ts +415 -0
- package/src/scaling/index.ts +9 -0
- package/src/scaling/node.ts +168 -0
- package/src/scaling/tree.ts +85 -0
- package/src/script/index.ts +1 -0
- package/src/script/schema.ts +65 -0
- package/src/shaders/directives.ts +366 -0
- package/src/shaders/index.ts +4 -0
- package/src/shaders/model.ts +147 -0
- package/src/shaders/schema.ts +84 -0
- package/src/shaders/still.ts +41 -0
- 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 +137 -0
- package/src/slots/authoring.ts +101 -0
- package/src/slots/content.ts +127 -0
- package/src/slots/frames.ts +160 -0
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +49 -0
- package/src/snap.ts +349 -0
- package/src/source-metadata.ts +8 -0
- 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/direction.ts +55 -0
- package/src/text/index.ts +6 -0
- package/src/text/lengths.ts +34 -0
- package/src/text/lists.ts +138 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/paragraphs.ts +241 -0
- package/src/text/picture.ts +57 -0
- package/src/text/references.ts +50 -0
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +84 -0
- package/src/transfer/history.ts +49 -0
- package/src/transfer/identity.ts +16 -0
- package/src/transfer/index.ts +6 -0
- package/src/transfer/nodes.ts +128 -0
- package/src/transfer/plan.ts +130 -0
- package/src/transfer/references.ts +9 -0
- package/src/transfer/remove.ts +39 -0
- package/src/transfer/validation.ts +59 -0
- package/src/transfer/variables.ts +83 -0
- package/src/types.ts +1205 -0
- package/src/undo.ts +285 -0
- package/src/variables/bindings.ts +310 -0
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +109 -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/index.ts +400 -0
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +61 -0
- package/src/variables/token.ts +40 -0
- package/src/variables/units.ts +15 -0
- package/src/variables/value.ts +92 -0
- package/src/variant-name.ts +15 -0
- package/src/variant-properties.ts +98 -0
- package/src/vector-network.ts +489 -0
|
@@ -0,0 +1,119 @@
|
|
|
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. */
|
|
9
|
+
const SHAPE_WITH_TEXT_CORNER_RADIUS = 6;
|
|
10
|
+
const LABEL_FILL = {
|
|
11
|
+
type: "SOLID",
|
|
12
|
+
color: { ...BLACK },
|
|
13
|
+
opacity: .8,
|
|
14
|
+
visible: true
|
|
15
|
+
};
|
|
16
|
+
/** How the label sits in its shape: as wide as the label box, as tall as its text. */
|
|
17
|
+
const SHAPE_WITH_TEXT_LABEL_LAYOUT = {
|
|
18
|
+
textAutoResize: "HEIGHT",
|
|
19
|
+
layoutAlignSelf: "STRETCH"
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The shape's own layout: a vertical auto layout that centres the label in the label box of its
|
|
23
|
+
* kind, which the padding leaves free. The padding follows the kind and size, so it is set again
|
|
24
|
+
* whenever either changes.
|
|
25
|
+
*/
|
|
26
|
+
function shapeWithTextFrameFields(kind, width, height) {
|
|
27
|
+
const box = shapeWithTextLabelBox(kind, width, height);
|
|
28
|
+
return {
|
|
29
|
+
layoutMode: "VERTICAL",
|
|
30
|
+
primaryAxisAlign: "CENTER",
|
|
31
|
+
counterAxisAlign: "CENTER",
|
|
32
|
+
primaryAxisSizing: "FIXED",
|
|
33
|
+
counterAxisSizing: "FIXED",
|
|
34
|
+
itemSpacing: 0,
|
|
35
|
+
paddingTop: box.y,
|
|
36
|
+
paddingRight: Math.max(0, width - box.x - box.width),
|
|
37
|
+
paddingBottom: Math.max(0, height - box.y - box.height),
|
|
38
|
+
paddingLeft: box.x,
|
|
39
|
+
clipsContent: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */
|
|
43
|
+
function shapeWithTextLabelFields() {
|
|
44
|
+
return {
|
|
45
|
+
name: "Text",
|
|
46
|
+
fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,
|
|
47
|
+
fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,
|
|
48
|
+
...figJamTextSizeFields("small"),
|
|
49
|
+
textAlignHorizontal: "CENTER",
|
|
50
|
+
textAlignVertical: "TOP",
|
|
51
|
+
fills: [{
|
|
52
|
+
...LABEL_FILL,
|
|
53
|
+
color: { ...LABEL_FILL.color }
|
|
54
|
+
}],
|
|
55
|
+
...SHAPE_WITH_TEXT_LABEL_LAYOUT
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** A shape's label: its one text sublayer. */
|
|
59
|
+
function shapeWithTextLabel(graph, shape) {
|
|
60
|
+
if (shape.type !== "SHAPE_WITH_TEXT") return null;
|
|
61
|
+
const children = graph.getChildren(shape.id);
|
|
62
|
+
if (children.length !== 1) return null;
|
|
63
|
+
const [label] = children;
|
|
64
|
+
return label.type === "TEXT" ? label : null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes
|
|
68
|
+
* its name from its label until it is named. A height set on it by a resize, a field or a script
|
|
69
|
+
* is the height it was given, which layout grows it from when its label needs more room; once
|
|
70
|
+
* that height changes, FigJam keeps it and truncates the label instead.
|
|
71
|
+
*/
|
|
72
|
+
const SHAPE_WITH_TEXT_KIND = {
|
|
73
|
+
complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,
|
|
74
|
+
text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? void 0,
|
|
75
|
+
rotates: true,
|
|
76
|
+
resizes: true,
|
|
77
|
+
strokesAndEffects: true,
|
|
78
|
+
namedByText: true,
|
|
79
|
+
sized: ({ height }, shape) => height === void 0 || height === shape.height ? {} : {
|
|
80
|
+
shapeUserHeight: height,
|
|
81
|
+
shapeTruncates: true
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */
|
|
85
|
+
function buildShapeWithTextLabel(graph, shape, props = {}) {
|
|
86
|
+
const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height);
|
|
87
|
+
const fields = shapeWithTextLabelFields();
|
|
88
|
+
return graph.createNode("TEXT", shape.id, {
|
|
89
|
+
...fields,
|
|
90
|
+
x: box.x,
|
|
91
|
+
y: box.y,
|
|
92
|
+
width: box.width,
|
|
93
|
+
height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? void 0,
|
|
94
|
+
text: "",
|
|
95
|
+
...props
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** A new shape with text and its label; the caller lays it out to grow it to its text. */
|
|
99
|
+
function createShapeWithText(graph, parentId, props = {}, label = {}) {
|
|
100
|
+
const kind = props.shapeWithTextType ?? "SQUARE";
|
|
101
|
+
const width = props.width ?? 176;
|
|
102
|
+
const height = props.height ?? 176;
|
|
103
|
+
const shape = graph.createNode("SHAPE_WITH_TEXT", parentId, {
|
|
104
|
+
name: "Shape with text",
|
|
105
|
+
cornerRadius: 6,
|
|
106
|
+
...props,
|
|
107
|
+
shapeWithTextType: kind,
|
|
108
|
+
width,
|
|
109
|
+
height,
|
|
110
|
+
shapeUserHeight: props.shapeUserHeight ?? height,
|
|
111
|
+
...shapeWithTextFrameFields(kind, width, height)
|
|
112
|
+
});
|
|
113
|
+
buildShapeWithTextLabel(graph, shape, label);
|
|
114
|
+
return shape;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
118
|
+
|
|
119
|
+
//# 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. */\nexport const SHAPE_WITH_TEXT_CORNER_RADIUS = 6\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 }\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 strokesAndEffects: 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;AAE7C,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;CAChB;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,mBAAmB;CACnB,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"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Color } from "../primitives/index.js";
|
|
2
|
+
import { SceneGraph } from "../graph.js";
|
|
3
|
+
import { Effect, SceneNode } from "../types.js";
|
|
4
|
+
import { GeneratedFrameKind } from "./kind.js";
|
|
5
|
+
//#region src/generated/sticky.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with
|
|
8
|
+
* the author pinned to the bottom. Every length scales with the note, which `rescale` changes;
|
|
9
|
+
* the values here are those of a note at scale 1, measured in Figma.
|
|
10
|
+
*/
|
|
11
|
+
declare const STICKY_SIZE = 240;
|
|
12
|
+
declare const STICKY_WIDE_WIDTH = 416;
|
|
13
|
+
declare const STICKY_FONT_FAMILY = "Inter";
|
|
14
|
+
declare const STICKY_FONT_WEIGHT = 500;
|
|
15
|
+
declare const STICKY_BODY_FONT_SIZE = 16;
|
|
16
|
+
declare const STICKY_AUTHOR_FONT_SIZE = 12;
|
|
17
|
+
/** FigJam's sticky palette, in its picker's order. */
|
|
18
|
+
declare const STICKY_COLORS: {
|
|
19
|
+
readonly white: {
|
|
20
|
+
readonly r: 1;
|
|
21
|
+
readonly g: 1;
|
|
22
|
+
readonly b: 1;
|
|
23
|
+
readonly a: 1;
|
|
24
|
+
};
|
|
25
|
+
readonly gray: {
|
|
26
|
+
readonly r: number;
|
|
27
|
+
readonly g: number;
|
|
28
|
+
readonly b: number;
|
|
29
|
+
readonly a: 1;
|
|
30
|
+
};
|
|
31
|
+
readonly red: {
|
|
32
|
+
readonly r: 1;
|
|
33
|
+
readonly g: number;
|
|
34
|
+
readonly b: number;
|
|
35
|
+
readonly a: 1;
|
|
36
|
+
};
|
|
37
|
+
readonly orange: {
|
|
38
|
+
readonly r: 1;
|
|
39
|
+
readonly g: number;
|
|
40
|
+
readonly b: number;
|
|
41
|
+
readonly a: 1;
|
|
42
|
+
};
|
|
43
|
+
readonly yellow: {
|
|
44
|
+
readonly r: 1;
|
|
45
|
+
readonly g: number;
|
|
46
|
+
readonly b: number;
|
|
47
|
+
readonly a: 1;
|
|
48
|
+
};
|
|
49
|
+
readonly green: {
|
|
50
|
+
readonly r: number;
|
|
51
|
+
readonly g: number;
|
|
52
|
+
readonly b: number;
|
|
53
|
+
readonly a: 1;
|
|
54
|
+
};
|
|
55
|
+
readonly teal: {
|
|
56
|
+
readonly r: number;
|
|
57
|
+
readonly g: number;
|
|
58
|
+
readonly b: number;
|
|
59
|
+
readonly a: 1;
|
|
60
|
+
};
|
|
61
|
+
readonly blue: {
|
|
62
|
+
readonly r: number;
|
|
63
|
+
readonly g: number;
|
|
64
|
+
readonly b: 1;
|
|
65
|
+
readonly a: 1;
|
|
66
|
+
};
|
|
67
|
+
readonly violet: {
|
|
68
|
+
readonly r: number;
|
|
69
|
+
readonly g: number;
|
|
70
|
+
readonly b: 1;
|
|
71
|
+
readonly a: 1;
|
|
72
|
+
};
|
|
73
|
+
readonly pink: {
|
|
74
|
+
readonly r: 1;
|
|
75
|
+
readonly g: number;
|
|
76
|
+
readonly b: number;
|
|
77
|
+
readonly a: 1;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
declare const DEFAULT_STICKY_COLOR: Color;
|
|
81
|
+
/** The three soft shadows Figma gives every sticky. */
|
|
82
|
+
declare function stickyShadows(): Effect[];
|
|
83
|
+
/**
|
|
84
|
+
* The note's own fields: a vertical auto layout that hugs its sublayers above a minimum height,
|
|
85
|
+
* spreading them apart so the author sits at the bottom. A generated frame keeps its gap with
|
|
86
|
+
* space between, which keeps the author clear of a long body.
|
|
87
|
+
*/
|
|
88
|
+
declare function stickyFrameFields(scale?: number): Partial<SceneNode>;
|
|
89
|
+
type StickyTextRole = 'body' | 'author';
|
|
90
|
+
/** How a sublayer sits in the note: as wide as the padding allows, as tall as its text. */
|
|
91
|
+
declare const STICKY_SUBLAYER_LAYOUT: {
|
|
92
|
+
readonly textAutoResize: "HEIGHT";
|
|
93
|
+
readonly layoutAlignSelf: "STRETCH";
|
|
94
|
+
};
|
|
95
|
+
/** A sublayer's text style; the body follows the size preset, the author only the scale. */
|
|
96
|
+
declare function stickyTextFields(role: StickyTextRole, scale?: number, fontSize?: number): Partial<SceneNode>;
|
|
97
|
+
/** The scale a note was drawn at, read from its author line, whose size only the scale sets. */
|
|
98
|
+
declare function stickyScale(author: Pick<SceneNode, 'fontSize'> | undefined): number;
|
|
99
|
+
/** A note's width at a scale, square or wide, as FigJam's side handles switch between them. */
|
|
100
|
+
declare function stickyWidth(scale: number, wide: boolean): number;
|
|
101
|
+
/** Whether a note is wide: nearer FigJam's wide width than its square one at its scale. */
|
|
102
|
+
declare function isWideSticky(graph: SceneGraph, sticky: SceneNode): boolean;
|
|
103
|
+
interface StickySublayers {
|
|
104
|
+
body: SceneNode;
|
|
105
|
+
author: SceneNode;
|
|
106
|
+
}
|
|
107
|
+
/** A note's body and author, in the order Figma generates them. */
|
|
108
|
+
declare function stickySublayers(graph: SceneGraph, sticky: SceneNode): StickySublayers | null;
|
|
109
|
+
/** A sticky note scales as a whole from its own handles and stays upright, as in FigJam. */
|
|
110
|
+
declare const STICKY_KIND: GeneratedFrameKind;
|
|
111
|
+
interface StickyContent {
|
|
112
|
+
text?: string;
|
|
113
|
+
author?: string;
|
|
114
|
+
authorVisible?: boolean;
|
|
115
|
+
color?: Color;
|
|
116
|
+
wide?: boolean;
|
|
117
|
+
scale?: number;
|
|
118
|
+
}
|
|
119
|
+
/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */
|
|
120
|
+
declare function buildStickySublayers(graph: SceneGraph, sticky: SceneNode, content?: Pick<StickyContent, 'text' | 'author' | 'authorVisible' | 'scale'>, overrides?: {
|
|
121
|
+
body?: Partial<SceneNode>;
|
|
122
|
+
author?: Partial<SceneNode>;
|
|
123
|
+
}): StickySublayers;
|
|
124
|
+
/** A new note with its sublayers; the caller lays it out to grow it to its text. */
|
|
125
|
+
declare function createSticky(graph: SceneGraph, parentId: string, content?: StickyContent, props?: Partial<SceneNode>): SceneNode;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { 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 };
|
|
128
|
+
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.d.ts","names":[],"sources":["../../src/generated/sticky.ts"],"mappings":";;;;;;;;;;cAYa;cACA;cAIA;cACA;cACA;cACA;;cAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAaA,sBAAsB;;iBAoBnB,iBAAiB;;;;;;iBASjB,kBAAkB,iBAAY,QAAQ;KAmB1C;;cAGC;WAAA;WAAA;;;iBAMG,iBACd,MAAM,gBACN,gBACA,oBACC,QAAQ;;iBAiBK,YAAY,QAAQ,KAAK;;iBAKzB,YAAY,eAAe;;iBAK3B,aAAa,OAAO,YAAY,QAAQ;UAKvC;EACf,MAAM;EACN,QAAQ;;;iBAIM,gBAAgB,OAAO,YAAY,QAAQ,YAAY;;cAS1D,aAAa;UAST;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA;;;iBAIc,qBACd,OAAO,YACP,QAAQ,WACR,UAAS,KAAK,+DACd;EAAa,OAAO,QAAQ;EAAY,SAAS,QAAQ;IACxD;;iBA0Ba,aACd,OAAO,YACP,kBACA,UAAS,eACT,QAAO,QAAQ,aACd"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { BLACK } from "../constants.js";
|
|
2
|
+
import { lineHeightPixels, percentLength, pixelLength } from "../text/lengths.js";
|
|
3
|
+
//#region src/generated/sticky.ts
|
|
4
|
+
/**
|
|
5
|
+
* A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with
|
|
6
|
+
* the author pinned to the bottom. Every length scales with the note, which `rescale` changes;
|
|
7
|
+
* the values here are those of a note at scale 1, measured in Figma.
|
|
8
|
+
*/
|
|
9
|
+
const STICKY_SIZE = 240;
|
|
10
|
+
const STICKY_WIDE_WIDTH = 416;
|
|
11
|
+
const STICKY_PADDING = 20;
|
|
12
|
+
const STICKY_GAP = 16;
|
|
13
|
+
const STICKY_FONT_FAMILY = "Inter";
|
|
14
|
+
const STICKY_FONT_WEIGHT = 500;
|
|
15
|
+
const STICKY_BODY_FONT_SIZE = 16;
|
|
16
|
+
const STICKY_AUTHOR_FONT_SIZE = 12;
|
|
17
|
+
/** FigJam's sticky palette, in its picker's order. */
|
|
18
|
+
const STICKY_COLORS = {
|
|
19
|
+
white: {
|
|
20
|
+
r: 1,
|
|
21
|
+
g: 1,
|
|
22
|
+
b: 1,
|
|
23
|
+
a: 1
|
|
24
|
+
},
|
|
25
|
+
gray: {
|
|
26
|
+
r: 230 / 255,
|
|
27
|
+
g: 230 / 255,
|
|
28
|
+
b: 230 / 255,
|
|
29
|
+
a: 1
|
|
30
|
+
},
|
|
31
|
+
red: {
|
|
32
|
+
r: 1,
|
|
33
|
+
g: 175 / 255,
|
|
34
|
+
b: 163 / 255,
|
|
35
|
+
a: 1
|
|
36
|
+
},
|
|
37
|
+
orange: {
|
|
38
|
+
r: 1,
|
|
39
|
+
g: 211 / 255,
|
|
40
|
+
b: 168 / 255,
|
|
41
|
+
a: 1
|
|
42
|
+
},
|
|
43
|
+
yellow: {
|
|
44
|
+
r: 1,
|
|
45
|
+
g: 226 / 255,
|
|
46
|
+
b: 153 / 255,
|
|
47
|
+
a: 1
|
|
48
|
+
},
|
|
49
|
+
green: {
|
|
50
|
+
r: 179 / 255,
|
|
51
|
+
g: 239 / 255,
|
|
52
|
+
b: 189 / 255,
|
|
53
|
+
a: 1
|
|
54
|
+
},
|
|
55
|
+
teal: {
|
|
56
|
+
r: 179 / 255,
|
|
57
|
+
g: 244 / 255,
|
|
58
|
+
b: 239 / 255,
|
|
59
|
+
a: 1
|
|
60
|
+
},
|
|
61
|
+
blue: {
|
|
62
|
+
r: 168 / 255,
|
|
63
|
+
g: 218 / 255,
|
|
64
|
+
b: 1,
|
|
65
|
+
a: 1
|
|
66
|
+
},
|
|
67
|
+
violet: {
|
|
68
|
+
r: 211 / 255,
|
|
69
|
+
g: 189 / 255,
|
|
70
|
+
b: 1,
|
|
71
|
+
a: 1
|
|
72
|
+
},
|
|
73
|
+
pink: {
|
|
74
|
+
r: 1,
|
|
75
|
+
g: 168 / 255,
|
|
76
|
+
b: 219 / 255,
|
|
77
|
+
a: 1
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const DEFAULT_STICKY_COLOR = STICKY_COLORS.blue;
|
|
81
|
+
function solid(color, opacity = 1) {
|
|
82
|
+
return {
|
|
83
|
+
type: "SOLID",
|
|
84
|
+
color: { ...color },
|
|
85
|
+
opacity,
|
|
86
|
+
visible: true
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function dropShadow(y, radius, alpha) {
|
|
90
|
+
return {
|
|
91
|
+
type: "DROP_SHADOW",
|
|
92
|
+
color: {
|
|
93
|
+
...BLACK,
|
|
94
|
+
a: alpha
|
|
95
|
+
},
|
|
96
|
+
offset: {
|
|
97
|
+
x: 0,
|
|
98
|
+
y
|
|
99
|
+
},
|
|
100
|
+
radius,
|
|
101
|
+
spread: 0,
|
|
102
|
+
visible: true,
|
|
103
|
+
blendMode: "NORMAL",
|
|
104
|
+
showShadowBehindNode: true
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** The three soft shadows Figma gives every sticky. */
|
|
108
|
+
function stickyShadows() {
|
|
109
|
+
return [
|
|
110
|
+
dropShadow(2.5, 2, .02),
|
|
111
|
+
dropShadow(3, 5, .04),
|
|
112
|
+
dropShadow(8, 10, .08)
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The note's own fields: a vertical auto layout that hugs its sublayers above a minimum height,
|
|
117
|
+
* spreading them apart so the author sits at the bottom. A generated frame keeps its gap with
|
|
118
|
+
* space between, which keeps the author clear of a long body.
|
|
119
|
+
*/
|
|
120
|
+
function stickyFrameFields(scale = 1) {
|
|
121
|
+
const padding = STICKY_PADDING * scale;
|
|
122
|
+
return {
|
|
123
|
+
layoutMode: "VERTICAL",
|
|
124
|
+
primaryAxisAlign: "SPACE_BETWEEN",
|
|
125
|
+
counterAxisAlign: "MIN",
|
|
126
|
+
primaryAxisSizing: "HUG",
|
|
127
|
+
counterAxisSizing: "FIXED",
|
|
128
|
+
itemSpacing: STICKY_GAP * scale,
|
|
129
|
+
paddingTop: padding,
|
|
130
|
+
paddingRight: padding,
|
|
131
|
+
paddingBottom: padding,
|
|
132
|
+
paddingLeft: padding,
|
|
133
|
+
minHeight: 240 * scale,
|
|
134
|
+
cornerRadius: 0,
|
|
135
|
+
clipsContent: false
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** How a sublayer sits in the note: as wide as the padding allows, as tall as its text. */
|
|
139
|
+
const STICKY_SUBLAYER_LAYOUT = {
|
|
140
|
+
textAutoResize: "HEIGHT",
|
|
141
|
+
layoutAlignSelf: "STRETCH"
|
|
142
|
+
};
|
|
143
|
+
/** A sublayer's text style; the body follows the size preset, the author only the scale. */
|
|
144
|
+
function stickyTextFields(role, scale = 1, fontSize = role === "body" ? 16 * scale : 12 * scale) {
|
|
145
|
+
return {
|
|
146
|
+
name: role === "body" ? "Text" : "Author",
|
|
147
|
+
fontFamily: STICKY_FONT_FAMILY,
|
|
148
|
+
fontWeight: 500,
|
|
149
|
+
fontSize,
|
|
150
|
+
lineHeight: role === "body" ? percentLength(150) : pixelLength(16 * scale),
|
|
151
|
+
letterSpacing: percentLength(-1.1),
|
|
152
|
+
textAlignHorizontal: "LEFT",
|
|
153
|
+
textAlignVertical: "TOP",
|
|
154
|
+
...STICKY_SUBLAYER_LAYOUT,
|
|
155
|
+
fills: [solid(BLACK, role === "body" ? .8 : 128 / 255)]
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** The scale a note was drawn at, read from its author line, whose size only the scale sets. */
|
|
159
|
+
function stickyScale(author) {
|
|
160
|
+
return author ? author.fontSize / 12 : 1;
|
|
161
|
+
}
|
|
162
|
+
/** A note's width at a scale, square or wide, as FigJam's side handles switch between them. */
|
|
163
|
+
function stickyWidth(scale, wide) {
|
|
164
|
+
return (wide ? 416 : 240) * scale;
|
|
165
|
+
}
|
|
166
|
+
/** Whether a note is wide: nearer FigJam's wide width than its square one at its scale. */
|
|
167
|
+
function isWideSticky(graph, sticky) {
|
|
168
|
+
const scale = stickyScale(stickySublayers(graph, sticky)?.author);
|
|
169
|
+
return sticky.width > 328 * scale;
|
|
170
|
+
}
|
|
171
|
+
/** A note's body and author, in the order Figma generates them. */
|
|
172
|
+
function stickySublayers(graph, sticky) {
|
|
173
|
+
const children = graph.getChildren(sticky.id);
|
|
174
|
+
if (children.length !== 2) return null;
|
|
175
|
+
const [body, author] = children;
|
|
176
|
+
if (body.type !== "TEXT" || author.type !== "TEXT") return null;
|
|
177
|
+
return {
|
|
178
|
+
body,
|
|
179
|
+
author
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/** A sticky note scales as a whole from its own handles and stays upright, as in FigJam. */
|
|
183
|
+
const STICKY_KIND = {
|
|
184
|
+
complete: (graph, frame) => stickySublayers(graph, frame) !== null,
|
|
185
|
+
text: (graph, frame) => stickySublayers(graph, frame)?.body,
|
|
186
|
+
rotates: false,
|
|
187
|
+
resizes: false,
|
|
188
|
+
strokesAndEffects: false,
|
|
189
|
+
namedByText: true
|
|
190
|
+
};
|
|
191
|
+
/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */
|
|
192
|
+
function buildStickySublayers(graph, sticky, content = {}, overrides = {}) {
|
|
193
|
+
const scale = content.scale ?? 1;
|
|
194
|
+
const inner = sticky.width - 40 * scale;
|
|
195
|
+
const bodyFields = stickyTextFields("body", scale);
|
|
196
|
+
const authorFields = stickyTextFields("author", scale);
|
|
197
|
+
return {
|
|
198
|
+
body: graph.createNode("TEXT", sticky.id, {
|
|
199
|
+
...bodyFields,
|
|
200
|
+
width: inner,
|
|
201
|
+
height: lineHeightPixels(bodyFields.lineHeight ?? null, bodyFields.fontSize ?? 0) ?? void 0,
|
|
202
|
+
text: content.text ?? "",
|
|
203
|
+
...overrides.body
|
|
204
|
+
}),
|
|
205
|
+
author: graph.createNode("TEXT", sticky.id, {
|
|
206
|
+
...authorFields,
|
|
207
|
+
width: inner,
|
|
208
|
+
height: lineHeightPixels(authorFields.lineHeight ?? null, authorFields.fontSize ?? 0) ?? void 0,
|
|
209
|
+
text: content.author ?? "",
|
|
210
|
+
visible: content.authorVisible ?? true,
|
|
211
|
+
...overrides.author
|
|
212
|
+
})
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/** A new note with its sublayers; the caller lays it out to grow it to its text. */
|
|
216
|
+
function createSticky(graph, parentId, content = {}, props = {}) {
|
|
217
|
+
const scale = content.scale ?? 1;
|
|
218
|
+
const size = 240 * scale;
|
|
219
|
+
const sticky = graph.createNode("STICKY", parentId, {
|
|
220
|
+
name: "Sticky",
|
|
221
|
+
width: (content.wide ? 416 : 240) * scale,
|
|
222
|
+
height: size,
|
|
223
|
+
fills: [solid(content.color ?? DEFAULT_STICKY_COLOR)],
|
|
224
|
+
effects: stickyShadows(),
|
|
225
|
+
...stickyFrameFields(scale),
|
|
226
|
+
...props
|
|
227
|
+
});
|
|
228
|
+
buildStickySublayers(graph, sticky, content);
|
|
229
|
+
return sticky;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { 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 };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=sticky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.js","names":[],"sources":["../../src/generated/sticky.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport type { SceneGraph } from '../graph'\nimport type { Color } from '../primitives'\nimport { lineHeightPixels, percentLength, pixelLength } from '../text/lengths'\nimport type { Effect, Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/**\n * A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with\n * the author pinned to the bottom. Every length scales with the note, which `rescale` changes;\n * the values here are those of a note at scale 1, measured in Figma.\n */\nexport const STICKY_SIZE = 240\nexport const STICKY_WIDE_WIDTH = 416\nconst STICKY_PADDING = 20\nconst STICKY_GAP = 16\n\nexport const STICKY_FONT_FAMILY = 'Inter'\nexport const STICKY_FONT_WEIGHT = 500\nexport const STICKY_BODY_FONT_SIZE = 16\nexport const STICKY_AUTHOR_FONT_SIZE = 12\n\n/** FigJam's sticky palette, in its picker's order. */\nexport const STICKY_COLORS = {\n white: { r: 1, g: 1, b: 1, a: 1 },\n gray: { r: 230 / 255, g: 230 / 255, b: 230 / 255, a: 1 },\n red: { r: 1, g: 175 / 255, b: 163 / 255, a: 1 },\n orange: { r: 1, g: 211 / 255, b: 168 / 255, a: 1 },\n yellow: { r: 1, g: 226 / 255, b: 153 / 255, a: 1 },\n green: { r: 179 / 255, g: 239 / 255, b: 189 / 255, a: 1 },\n teal: { r: 179 / 255, g: 244 / 255, b: 239 / 255, a: 1 },\n blue: { r: 168 / 255, g: 218 / 255, b: 1, a: 1 },\n violet: { r: 211 / 255, g: 189 / 255, b: 1, a: 1 },\n pink: { r: 1, g: 168 / 255, b: 219 / 255, a: 1 }\n} as const satisfies Record<string, Color>\n\nexport const DEFAULT_STICKY_COLOR: Color = STICKY_COLORS.blue\n\nfunction solid(color: Color, opacity = 1): Fill {\n return { type: 'SOLID', color: { ...color }, opacity, visible: true }\n}\n\nfunction dropShadow(y: number, radius: number, alpha: number): Effect {\n return {\n type: 'DROP_SHADOW',\n color: { ...BLACK, a: alpha },\n offset: { x: 0, y },\n radius,\n spread: 0,\n visible: true,\n blendMode: 'NORMAL',\n showShadowBehindNode: true\n }\n}\n\n/** The three soft shadows Figma gives every sticky. */\nexport function stickyShadows(): Effect[] {\n return [dropShadow(2.5, 2, 0.02), dropShadow(3, 5, 0.04), dropShadow(8, 10, 0.08)]\n}\n\n/**\n * The note's own fields: a vertical auto layout that hugs its sublayers above a minimum height,\n * spreading them apart so the author sits at the bottom. A generated frame keeps its gap with\n * space between, which keeps the author clear of a long body.\n */\nexport function stickyFrameFields(scale = 1): Partial<SceneNode> {\n const padding = STICKY_PADDING * scale\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'SPACE_BETWEEN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'FIXED',\n itemSpacing: STICKY_GAP * scale,\n paddingTop: padding,\n paddingRight: padding,\n paddingBottom: padding,\n paddingLeft: padding,\n minHeight: STICKY_SIZE * scale,\n cornerRadius: 0,\n clipsContent: false\n }\n}\n\nexport type StickyTextRole = 'body' | 'author'\n\n/** How a sublayer sits in the note: as wide as the padding allows, as tall as its text. */\nexport const STICKY_SUBLAYER_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/** A sublayer's text style; the body follows the size preset, the author only the scale. */\nexport function stickyTextFields(\n role: StickyTextRole,\n scale = 1,\n fontSize = role === 'body' ? STICKY_BODY_FONT_SIZE * scale : STICKY_AUTHOR_FONT_SIZE * scale\n): Partial<SceneNode> {\n return {\n name: role === 'body' ? 'Text' : 'Author',\n fontFamily: STICKY_FONT_FAMILY,\n fontWeight: STICKY_FONT_WEIGHT,\n fontSize,\n // As Figma writes a note: the body at 150% and the author at 16 px a scale, tracked -1.1%.\n lineHeight: role === 'body' ? percentLength(150) : pixelLength(16 * scale),\n letterSpacing: percentLength(-1.1),\n textAlignHorizontal: 'LEFT',\n textAlignVertical: 'TOP',\n ...STICKY_SUBLAYER_LAYOUT,\n fills: [solid(BLACK, role === 'body' ? 0.8 : 128 / 255)]\n }\n}\n\n/** The scale a note was drawn at, read from its author line, whose size only the scale sets. */\nexport function stickyScale(author: Pick<SceneNode, 'fontSize'> | undefined): number {\n return author ? author.fontSize / STICKY_AUTHOR_FONT_SIZE : 1\n}\n\n/** A note's width at a scale, square or wide, as FigJam's side handles switch between them. */\nexport function stickyWidth(scale: number, wide: boolean): number {\n return (wide ? STICKY_WIDE_WIDTH : STICKY_SIZE) * scale\n}\n\n/** Whether a note is wide: nearer FigJam's wide width than its square one at its scale. */\nexport function isWideSticky(graph: SceneGraph, sticky: SceneNode): boolean {\n const scale = stickyScale(stickySublayers(graph, sticky)?.author)\n return sticky.width > ((STICKY_SIZE + STICKY_WIDE_WIDTH) / 2) * scale\n}\n\nexport interface StickySublayers {\n body: SceneNode\n author: SceneNode\n}\n\n/** A note's body and author, in the order Figma generates them. */\nexport function stickySublayers(graph: SceneGraph, sticky: SceneNode): StickySublayers | null {\n const children = graph.getChildren(sticky.id)\n if (children.length !== 2) return null\n const [body, author] = children\n if (body.type !== 'TEXT' || author.type !== 'TEXT') return null\n return { body, author }\n}\n\n/** A sticky note scales as a whole from its own handles and stays upright, as in FigJam. */\nexport const STICKY_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => stickySublayers(graph, frame) !== null,\n text: (graph, frame) => stickySublayers(graph, frame)?.body,\n rotates: false,\n resizes: false,\n strokesAndEffects: false,\n namedByText: true\n}\n\nexport interface StickyContent {\n text?: string\n author?: string\n authorVisible?: boolean\n color?: Color\n wide?: boolean\n scale?: number\n}\n\n/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */\nexport function buildStickySublayers(\n graph: SceneGraph,\n sticky: SceneNode,\n content: Pick<StickyContent, 'text' | 'author' | 'authorVisible' | 'scale'> = {},\n overrides: { body?: Partial<SceneNode>; author?: Partial<SceneNode> } = {}\n): StickySublayers {\n const scale = content.scale ?? 1\n const inner = sticky.width - 2 * STICKY_PADDING * scale\n // One line tall until text is measured, so a note laid out without fonts keeps Figma's square.\n const bodyFields = stickyTextFields('body', scale)\n const authorFields = stickyTextFields('author', scale)\n const body = graph.createNode('TEXT', sticky.id, {\n ...bodyFields,\n width: inner,\n height: lineHeightPixels(bodyFields.lineHeight ?? null, bodyFields.fontSize ?? 0) ?? undefined,\n text: content.text ?? '',\n ...overrides.body\n })\n const author = graph.createNode('TEXT', sticky.id, {\n ...authorFields,\n width: inner,\n height:\n lineHeightPixels(authorFields.lineHeight ?? null, authorFields.fontSize ?? 0) ?? undefined,\n text: content.author ?? '',\n visible: content.authorVisible ?? true,\n ...overrides.author\n })\n return { body, author }\n}\n\n/** A new note with its sublayers; the caller lays it out to grow it to its text. */\nexport function createSticky(\n graph: SceneGraph,\n parentId: string,\n content: StickyContent = {},\n props: Partial<SceneNode> = {}\n): SceneNode {\n const scale = content.scale ?? 1\n const size = STICKY_SIZE * scale\n const sticky = graph.createNode('STICKY', parentId, {\n name: 'Sticky',\n width: (content.wide ? STICKY_WIDE_WIDTH : STICKY_SIZE) * scale,\n height: size,\n fills: [solid(content.color ?? DEFAULT_STICKY_COLOR)],\n effects: stickyShadows(),\n ...stickyFrameFields(scale),\n ...props\n })\n buildStickySublayers(graph, sticky, content)\n return sticky\n}\n"],"mappings":";;;;;;;;AAYA,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAM,iBAAiB;AACvB,MAAM,aAAa;AAEnB,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;;AAGvC,MAAa,gBAAgB;CAC3B,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,MAAM;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACvD,KAAK;EAAE,GAAG;EAAG,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CAC9C,QAAQ;EAAE,GAAG;EAAG,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACjD,QAAQ;EAAE,GAAG;EAAG,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACjD,OAAO;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACxD,MAAM;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACvD,MAAM;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;EAAG,GAAG;CAAE;CAC/C,QAAQ;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;EAAG,GAAG;CAAE;CACjD,MAAM;EAAE,GAAG;EAAG,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;AACjD;AAEA,MAAa,uBAA8B,cAAc;AAEzD,SAAS,MAAM,OAAc,UAAU,GAAS;CAC9C,OAAO;EAAE,MAAM;EAAS,OAAO,EAAE,GAAG,MAAM;EAAG;EAAS,SAAS;CAAK;AACtE;AAEA,SAAS,WAAW,GAAW,QAAgB,OAAuB;CACpE,OAAO;EACL,MAAM;EACN,OAAO;GAAE,GAAG;GAAO,GAAG;EAAM;EAC5B,QAAQ;GAAE,GAAG;GAAG;EAAE;EAClB;EACA,QAAQ;EACR,SAAS;EACT,WAAW;EACX,sBAAsB;CACxB;AACF;;AAGA,SAAgB,gBAA0B;CACxC,OAAO;EAAC,WAAW,KAAK,GAAG,GAAI;EAAG,WAAW,GAAG,GAAG,GAAI;EAAG,WAAW,GAAG,IAAI,GAAI;CAAC;AACnF;;;;;;AAOA,SAAgB,kBAAkB,QAAQ,GAAuB;CAC/D,MAAM,UAAU,iBAAiB;CACjC,OAAO;EACL,YAAY;EACZ,kBAAkB;EAClB,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,aAAa,aAAa;EAC1B,YAAY;EACZ,cAAc;EACd,eAAe;EACf,aAAa;EACb,WAAA,MAAyB;EACzB,cAAc;EACd,cAAc;CAChB;AACF;;AAKA,MAAa,yBAAyB;CACpC,gBAAgB;CAChB,iBAAiB;AACnB;;AAGA,SAAgB,iBACd,MACA,QAAQ,GACR,WAAW,SAAS,SAAA,KAAiC,QAAA,KAAkC,OACnE;CACpB,OAAO;EACL,MAAM,SAAS,SAAS,SAAS;EACjC,YAAY;EACZ,YAAA;EACA;EAEA,YAAY,SAAS,SAAS,cAAc,GAAG,IAAI,YAAY,KAAK,KAAK;EACzE,eAAe,cAAc,IAAI;EACjC,qBAAqB;EACrB,mBAAmB;EACnB,GAAG;EACH,OAAO,CAAC,MAAM,OAAO,SAAS,SAAS,KAAM,MAAM,GAAG,CAAC;CACzD;AACF;;AAGA,SAAgB,YAAY,QAAyD;CACnF,OAAO,SAAS,OAAO,WAAA,KAAqC;AAC9D;;AAGA,SAAgB,YAAY,OAAe,MAAuB;CAChE,QAAQ,OAAA,MAAA,OAA0C;AACpD;;AAGA,SAAgB,aAAa,OAAmB,QAA4B;CAC1E,MAAM,QAAQ,YAAY,gBAAgB,OAAO,MAAM,CAAC,EAAE,MAAM;CAChE,OAAO,OAAO,QAAS,MAAyC;AAClE;;AAQA,SAAgB,gBAAgB,OAAmB,QAA2C;CAC5F,MAAM,WAAW,MAAM,YAAY,OAAO,EAAE;CAC5C,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,MAAM,CAAC,MAAM,UAAU;CACvB,IAAI,KAAK,SAAS,UAAU,OAAO,SAAS,QAAQ,OAAO;CAC3D,OAAO;EAAE;EAAM;CAAO;AACxB;;AAGA,MAAa,cAAkC;CAC7C,WAAW,OAAO,UAAU,gBAAgB,OAAO,KAAK,MAAM;CAC9D,OAAO,OAAO,UAAU,gBAAgB,OAAO,KAAK,CAAC,EAAE;CACvD,SAAS;CACT,SAAS;CACT,mBAAmB;CACnB,aAAa;AACf;;AAYA,SAAgB,qBACd,OACA,QACA,UAA8E,CAAC,GAC/E,YAAwE,CAAC,GACxD;CACjB,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,QAAQ,OAAO,QAAQ,KAAqB;CAElD,MAAM,aAAa,iBAAiB,QAAQ,KAAK;CACjD,MAAM,eAAe,iBAAiB,UAAU,KAAK;CAiBrD,OAAO;EAAE,MAhBI,MAAM,WAAW,QAAQ,OAAO,IAAI;GAC/C,GAAG;GACH,OAAO;GACP,QAAQ,iBAAiB,WAAW,cAAc,MAAM,WAAW,YAAY,CAAC,KAAK,KAAA;GACrF,MAAM,QAAQ,QAAQ;GACtB,GAAG,UAAU;EACf,CAUY;EAAG,QATA,MAAM,WAAW,QAAQ,OAAO,IAAI;GACjD,GAAG;GACH,OAAO;GACP,QACE,iBAAiB,aAAa,cAAc,MAAM,aAAa,YAAY,CAAC,KAAK,KAAA;GACnF,MAAM,QAAQ,UAAU;GACxB,SAAS,QAAQ,iBAAiB;GAClC,GAAG,UAAU;EACf,CACoB;CAAE;AACxB;;AAGA,SAAgB,aACd,OACA,UACA,UAAyB,CAAC,GAC1B,QAA4B,CAAC,GAClB;CACX,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,OAAA,MAAqB;CAC3B,MAAM,SAAS,MAAM,WAAW,UAAU,UAAU;EAClD,MAAM;EACN,QAAQ,QAAQ,OAAA,MAAA,OAA0C;EAC1D,QAAQ;EACR,OAAO,CAAC,MAAM,QAAQ,SAAS,oBAAoB,CAAC;EACpD,SAAS,cAAc;EACvB,GAAG,kBAAkB,KAAK;EAC1B,GAAG;CACL,CAAC;CACD,qBAAqB,OAAO,QAAQ,OAAO;CAC3C,OAAO;AACT"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Rect, Vector } from "./primitives/index.js";
|
|
2
|
+
import { Effect, Stroke, StrokeCap, StrokeJoin, VectorNetwork } from "./types.js";
|
|
3
|
+
//#region src/geometry.d.ts
|
|
4
|
+
declare function degToRad(degrees: number): number;
|
|
5
|
+
declare function radToDeg(radians: number): number;
|
|
6
|
+
declare function rotatePoint(px: number, py: number, cx: number, cy: number, rad: number): Vector;
|
|
7
|
+
declare function rotatedCorners(cx: number, cy: number, hw: number, hh: number, rotationDeg: number): [Vector, Vector, Vector, Vector];
|
|
8
|
+
declare function rotatedBBox(x: number, y: number, w: number, h: number, rotationDeg: number): {
|
|
9
|
+
left: number;
|
|
10
|
+
right: number;
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
centerX: number;
|
|
14
|
+
centerY: number;
|
|
15
|
+
};
|
|
16
|
+
interface VisualBounds {
|
|
17
|
+
minX: number;
|
|
18
|
+
minY: number;
|
|
19
|
+
maxX: number;
|
|
20
|
+
maxY: number;
|
|
21
|
+
}
|
|
22
|
+
declare function computeBounds(items: Iterable<Rect>): Rect;
|
|
23
|
+
declare function polygonVertices(node: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
pointCount: number;
|
|
27
|
+
type: string;
|
|
28
|
+
starInnerRadius: number;
|
|
29
|
+
}): Vector[];
|
|
30
|
+
/**
|
|
31
|
+
* What shapes how far a layer's stroke reaches past its box: its type, since a line is stroked to
|
|
32
|
+
* one side, and its join and miter limit, for the tips mitered path corners reach.
|
|
33
|
+
*/
|
|
34
|
+
interface StrokeShape {
|
|
35
|
+
type?: string;
|
|
36
|
+
strokeJoin?: StrokeJoin;
|
|
37
|
+
strokeMiterLimit?: number;
|
|
38
|
+
}
|
|
39
|
+
declare function strokeOverflow(strokes?: Stroke[], fallbackCap?: StrokeCap, network?: VectorNetwork | null, shape?: StrokeShape): number;
|
|
40
|
+
declare function effectOverflow(effects?: Effect[]): {
|
|
41
|
+
left: number;
|
|
42
|
+
right: number;
|
|
43
|
+
top: number;
|
|
44
|
+
bottom: number;
|
|
45
|
+
};
|
|
46
|
+
declare function computeAbsoluteBounds(nodes: Iterable<{
|
|
47
|
+
id: string;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
}>, getAbsolutePosition: (id: string) => Vector): Rect;
|
|
51
|
+
declare function computeVisualBounds(nodes: Iterable<{
|
|
52
|
+
id: string;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
rotation?: number;
|
|
56
|
+
strokes?: Stroke[];
|
|
57
|
+
strokeCap?: StrokeCap;
|
|
58
|
+
vectorNetwork?: VectorNetwork | null;
|
|
59
|
+
effects?: Effect[];
|
|
60
|
+
} & StrokeShape>, getAbsolutePosition: (id: string) => Vector): Rect;
|
|
61
|
+
interface VisualBoundsNode {
|
|
62
|
+
id: string;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
rotation?: number;
|
|
66
|
+
flipX?: boolean;
|
|
67
|
+
flipY?: boolean;
|
|
68
|
+
strokes?: Stroke[];
|
|
69
|
+
strokeCap?: StrokeCap;
|
|
70
|
+
vectorNetwork?: VectorNetwork | null;
|
|
71
|
+
effects?: Effect[];
|
|
72
|
+
fillGeometry?: Array<{
|
|
73
|
+
commandsBlob: Uint8Array;
|
|
74
|
+
}>;
|
|
75
|
+
strokeGeometry?: Array<{
|
|
76
|
+
commandsBlob: Uint8Array;
|
|
77
|
+
}>;
|
|
78
|
+
childIds?: string[];
|
|
79
|
+
visible?: boolean;
|
|
80
|
+
type?: string;
|
|
81
|
+
clipsContent?: boolean;
|
|
82
|
+
fontSize?: number;
|
|
83
|
+
textDecoration?: string;
|
|
84
|
+
textUnderlineOffset?: number | null;
|
|
85
|
+
textDecorationThickness?: number | null;
|
|
86
|
+
derivedTextHeight?: number | null;
|
|
87
|
+
}
|
|
88
|
+
declare function unionVisualBounds(a: VisualBounds | null, b: VisualBounds | null): VisualBounds | null;
|
|
89
|
+
declare function intersectVisualBounds(a: VisualBounds, b: VisualBounds): VisualBounds | null;
|
|
90
|
+
/**
|
|
91
|
+
* Coordinate pairs per path blob command: 0=close, 1=move, 2=line,
|
|
92
|
+
* 3=quad (glyph-derived blobs are quad-heavy), 4=cubic. Unknown → null so
|
|
93
|
+
* walkers stop instead of desyncing into coordinate bytes.
|
|
94
|
+
*/
|
|
95
|
+
declare function geometryCommandCoordCount(command: number): number | null;
|
|
96
|
+
declare function geometryBlobBounds(paths: Array<{
|
|
97
|
+
commandsBlob: Uint8Array;
|
|
98
|
+
}>): Rect | null;
|
|
99
|
+
declare function nodeVisualBounds(node: VisualBoundsNode, getAbsolutePosition: (id: string) => Vector): VisualBounds;
|
|
100
|
+
/** How far a text node's underline or strikethrough reaches below its box. */
|
|
101
|
+
declare function textDecorationOverflow(node: VisualBoundsNode): number;
|
|
102
|
+
declare function computeDescendantVisualBounds(nodeIds: string[], getNode: (id: string) => VisualBoundsNode | undefined, getAbsolutePosition: (id: string) => Vector): VisualBounds | null;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { StrokeShape, VisualBounds, VisualBoundsNode, computeAbsoluteBounds, computeBounds, computeDescendantVisualBounds, computeVisualBounds, degToRad, effectOverflow, geometryBlobBounds, geometryCommandCoordCount, intersectVisualBounds, nodeVisualBounds, polygonVertices, radToDeg, rotatePoint, rotatedBBox, rotatedCorners, strokeOverflow, textDecorationOverflow, unionVisualBounds };
|
|
105
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","names":[],"sources":["../src/geometry.ts"],"mappings":";;;iBAKgB,SAAS;iBAIT,SAAS;iBAIT,YAAY,YAAY,YAAY,YAAY,YAAY,cAAc;iBAS1E,eACd,YACA,YACA,YACA,YACA,uBACE,QAAQ,QAAQ,QAAQ;iBAYZ,YACd,WACA,WACA,WACA,WACA;EACG;EAAc;EAAe;EAAa;EAAgB;EAAiB;;UAyB/D;EACf;EACA;EACA;EACA;;iBAgCc,cAAc,OAAO,SAAS,QAAQ;iBAMtC,gBAAgB;EAC9B;EACA;EACA;EACA;EACA;IACE;;;;;UA0Ba;EACf;EACA,aAAa;EACb;;iBAGc,eACd,UAAU,UACV,cAAc,WACd,UAAU,sBACV,QAAQ;iBA+DM,eAAe,UAAU;;;;;;iBAyBzB,sBACd,OAAO;EAAW;EAAY;EAAe;IAC7C,sBAAsB,eAAe,SACpC;iBASa,oBACd,OAAO;EAEH;EACA;EACA;EACA;EACA,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB,UAAU;IACR,cAEN,sBAAsB,eAAe,SACpC;UAec;EACf;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB,UAAU;EACV,eAAe;IAAQ,cAAc;;EACrC,iBAAiB;IAAQ,cAAc;;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGc,kBACd,GAAG,qBACH,GAAG,sBACF;iBAWa,sBAAsB,GAAG,cAAc,GAAG,eAAe;;;;;;iBAazD,0BAA0B;iBAQ1B,mBAAmB,OAAO;EAAQ,cAAc;KAAgB;iBAoDhE,iBACd,MAAM,kBACN,sBAAsB,eAAe,SACpC;;iBAiCa,uBAAuB,MAAM;iBA6C7B,8BACd,mBACA,UAAU,eAAe,8BACzB,sBAAsB,eAAe,SACpC"}
|