@sarjallab09/figma-intelligence 1.1.0 → 1.2.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/README.md +67 -36
- package/dist/bin/cli.js +2 -0
- package/dist/design-bridge/bridge.js +2 -0
- package/dist/figma-bridge-plugin/bridge-relay.js +2 -0
- package/dist/figma-bridge-plugin/code.js +1 -0
- package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package-lock.json +0 -3
- package/dist/figma-bridge-plugin/ui.html +4970 -0
- package/dist/figma-intelligence-layer/dist/index.js +2 -0
- package/dist/scripts/clean-existing-chunks.js +2 -0
- package/dist/scripts/connect-ai-tool.js +2 -0
- package/dist/scripts/convert-hub-pdfs.js +2 -0
- package/dist/scripts/figma-mcp-status.js +2 -0
- package/dist/scripts/register-codex-mcp.js +2 -0
- package/dist/scripts/test-copilot-chat.js +2 -0
- package/package.json +11 -8
- package/bin/cli.js +0 -859
- package/design-bridge/bridge.js +0 -196
- package/design-bridge/lib/assets.js +0 -367
- package/design-bridge/lib/prompt.js +0 -85
- package/design-bridge/lib/server.js +0 -66
- package/design-bridge/lib/stitch.js +0 -37
- package/design-bridge/lib/tokens.js +0 -82
- package/design-bridge/package-lock.json +0 -579
- package/figma-bridge-plugin/README.md +0 -97
- package/figma-bridge-plugin/anthropic-chat-runner.js +0 -192
- package/figma-bridge-plugin/bridge-relay.js +0 -2505
- package/figma-bridge-plugin/chat-runner.js +0 -485
- package/figma-bridge-plugin/code.js +0 -1534
- package/figma-bridge-plugin/codex-runner.js +0 -505
- package/figma-bridge-plugin/component-schemas.js +0 -110
- package/figma-bridge-plugin/content-context.js +0 -869
- package/figma-bridge-plugin/create-button.js +0 -216
- package/figma-bridge-plugin/gemini-cli-runner.js +0 -291
- package/figma-bridge-plugin/gemini-runner.js +0 -187
- package/figma-bridge-plugin/html-to-figma.js +0 -927
- package/figma-bridge-plugin/knowledge-hub/.gitkeep +0 -0
- package/figma-bridge-plugin/knowledge-hub/uspec-references/anatomy-spec.md +0 -159
- package/figma-bridge-plugin/knowledge-hub/uspec-references/api-spec.md +0 -162
- package/figma-bridge-plugin/knowledge-hub/uspec-references/color-spec.md +0 -148
- package/figma-bridge-plugin/knowledge-hub/uspec-references/full-spec-template.md +0 -314
- package/figma-bridge-plugin/knowledge-hub/uspec-references/property-spec.md +0 -175
- package/figma-bridge-plugin/knowledge-hub/uspec-references/screen-reader-spec.md +0 -180
- package/figma-bridge-plugin/knowledge-hub/uspec-references/structure-spec.md +0 -165
- package/figma-bridge-plugin/perplexity-runner.js +0 -188
- package/figma-bridge-plugin/references/SKILL.md +0 -178
- package/figma-bridge-plugin/references/anatomy-spec.md +0 -159
- package/figma-bridge-plugin/references/api-spec.md +0 -162
- package/figma-bridge-plugin/references/color-spec.md +0 -148
- package/figma-bridge-plugin/references/full-spec-template.md +0 -314
- package/figma-bridge-plugin/references/property-spec.md +0 -175
- package/figma-bridge-plugin/references/screen-reader-spec.md +0 -180
- package/figma-bridge-plugin/references/structure-spec.md +0 -165
- package/figma-bridge-plugin/shared-prompt-config.js +0 -645
- package/figma-bridge-plugin/spec-helpers/build-table.js +0 -269
- package/figma-bridge-plugin/spec-helpers/classify-elements.js +0 -189
- package/figma-bridge-plugin/spec-helpers/index.js +0 -35
- package/figma-bridge-plugin/spec-helpers/parse-figma-link.js +0 -49
- package/figma-bridge-plugin/spec-helpers/position-markers.js +0 -158
- package/figma-bridge-plugin/stitch-auth.js +0 -322
- package/figma-bridge-plugin/stitch-runner.js +0 -1427
- package/figma-bridge-plugin/token-resolver.js +0 -107
- package/figma-bridge-plugin/ui.html +0 -4542
- package/figma-intelligence-layer/.env.example +0 -39
- package/figma-intelligence-layer/docs/local-image-generation.md +0 -60
- package/figma-intelligence-layer/examples/comfyui-workflow-template.example.json +0 -101
- package/figma-intelligence-layer/jest.config.js +0 -14
- package/figma-intelligence-layer/mcp-config.json +0 -19
- package/figma-intelligence-layer/package-lock.json +0 -5892
- package/figma-intelligence-layer/scripts/setup-comfyui-local.sh +0 -67
- package/figma-intelligence-layer/scripts/start-comfyui.sh +0 -33
- package/figma-intelligence-layer/src/index.ts +0 -2233
- package/figma-intelligence-layer/src/shared/auto-layout-validator.ts +0 -404
- package/figma-intelligence-layer/src/shared/cache.ts +0 -187
- package/figma-intelligence-layer/src/shared/color-operations.ts +0 -533
- package/figma-intelligence-layer/src/shared/color-utils.ts +0 -138
- package/figma-intelligence-layer/src/shared/component-script-builder.ts +0 -413
- package/figma-intelligence-layer/src/shared/component-templates.ts +0 -2767
- package/figma-intelligence-layer/src/shared/concept-taxonomy.ts +0 -694
- package/figma-intelligence-layer/src/shared/decision-log.ts +0 -128
- package/figma-intelligence-layer/src/shared/design-system-context.ts +0 -568
- package/figma-intelligence-layer/src/shared/design-system-intelligence.ts +0 -131
- package/figma-intelligence-layer/src/shared/design-system-matcher.ts +0 -184
- package/figma-intelligence-layer/src/shared/design-system-normalizers.ts +0 -196
- package/figma-intelligence-layer/src/shared/design-system-tokens.ts +0 -295
- package/figma-intelligence-layer/src/shared/dtcg-validator.ts +0 -530
- package/figma-intelligence-layer/src/shared/enrichment-pipeline.ts +0 -671
- package/figma-intelligence-layer/src/shared/figma-bridge.ts +0 -1418
- package/figma-intelligence-layer/src/shared/font-config.ts +0 -126
- package/figma-intelligence-layer/src/shared/icon-catalog.ts +0 -360
- package/figma-intelligence-layer/src/shared/icon-fetch.ts +0 -80
- package/figma-intelligence-layer/src/shared/prototype-script-builder.ts +0 -162
- package/figma-intelligence-layer/src/shared/response-compression.ts +0 -440
- package/figma-intelligence-layer/src/shared/semantic-token-catalog.ts +0 -324
- package/figma-intelligence-layer/src/shared/token-binder.ts +0 -505
- package/figma-intelligence-layer/src/shared/token-math.ts +0 -427
- package/figma-intelligence-layer/src/shared/token-naming.ts +0 -468
- package/figma-intelligence-layer/src/shared/token-utils.ts +0 -420
- package/figma-intelligence-layer/src/shared/types.ts +0 -346
- package/figma-intelligence-layer/src/shared/typography-presets.ts +0 -94
- package/figma-intelligence-layer/src/shared/unsplash.ts +0 -165
- package/figma-intelligence-layer/src/shared/vision-client.ts +0 -607
- package/figma-intelligence-layer/src/shared/vision-provider-anthropic.ts +0 -334
- package/figma-intelligence-layer/src/shared/vision-provider-openai.ts +0 -446
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-handler.ts +0 -782
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-renderer.ts +0 -496
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotation-kit.ts +0 -230
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/colorblind-sim.ts +0 -66
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/index.ts +0 -810
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-analyzer.ts +0 -1191
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-figma-page.ts +0 -1346
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-handler.ts +0 -148
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-figma-page.ts +0 -499
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-report.ts +0 -910
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-checker.ts +0 -989
- package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-criteria.ts +0 -1160
- package/figma-intelligence-layer/src/tools/phase1-vision/design-from-ref/index.ts +0 -424
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/component-recognizer.ts +0 -38
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/ds-matcher.ts +0 -111
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/font-matcher.ts +0 -114
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/icon-resolver.ts +0 -103
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/index.ts +0 -1060
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/layout-segmenter.ts +0 -18
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/token-inferencer.ts +0 -39
- package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/vision-pipeline.ts +0 -58
- package/figma-intelligence-layer/src/tools/phase1-vision/sketch-to-design/index.ts +0 -298
- package/figma-intelligence-layer/src/tools/phase1-vision/visual-audit/index.ts +0 -197
- package/figma-intelligence-layer/src/tools/phase2-accuracy/component-audit/index.ts +0 -494
- package/figma-intelligence-layer/src/tools/phase2-accuracy/intent-translator/index.ts +0 -356
- package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/container-patterns.ts +0 -123
- package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/index.ts +0 -663
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/built-in-rules.yaml +0 -56
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/index.ts +0 -614
- package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/rule-engine.ts +0 -113
- package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/color-theory.ts +0 -178
- package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/index.ts +0 -470
- package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/index.ts +0 -429
- package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/token-override-maps.ts +0 -226
- package/figma-intelligence-layer/src/tools/phase3-generation/ai-image-insert/index.ts +0 -535
- package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts +0 -660
- package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/pattern-fingerprints.ts +0 -209
- package/figma-intelligence-layer/src/tools/phase3-generation/composition-builder/index.ts +0 -540
- package/figma-intelligence-layer/src/tools/phase3-generation/figma-animated-build.ts +0 -391
- package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/index.ts +0 -2019
- package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts +0 -131
- package/figma-intelligence-layer/src/tools/phase3-generation/prototype-map/index.ts +0 -381
- package/figma-intelligence-layer/src/tools/phase3-generation/prototype-wire/index.ts +0 -565
- package/figma-intelligence-layer/src/tools/phase3-generation/swarm-build/index.ts +0 -764
- package/figma-intelligence-layer/src/tools/phase3-generation/system-drift/index.ts +0 -535
- package/figma-intelligence-layer/src/tools/phase3-generation/unsplash-search/index.ts +0 -84
- package/figma-intelligence-layer/src/tools/phase3-generation/url-to-frame/index.ts +0 -401
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/css-animations.ts +0 -68
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/framer-motion.ts +0 -78
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/swift-animations.ts +0 -93
- package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/index.ts +0 -596
- package/figma-intelligence-layer/src/tools/phase4-sync/ci-check/index.ts +0 -462
- package/figma-intelligence-layer/src/tools/phase4-sync/export-tokens/index.ts +0 -1470
- package/figma-intelligence-layer/src/tools/phase4-sync/generate-component-code/index.ts +0 -829
- package/figma-intelligence-layer/src/tools/phase4-sync/handoff-spec/index.ts +0 -702
- package/figma-intelligence-layer/src/tools/phase4-sync/icon-library-sync/index.ts +0 -483
- package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/index.ts +0 -501
- package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/storybook-parser.ts +0 -106
- package/figma-intelligence-layer/src/tools/phase4-sync/watch-docs/index.ts +0 -676
- package/figma-intelligence-layer/src/tools/phase4-sync/webhook-listener/index.ts +0 -560
- package/figma-intelligence-layer/src/tools/phase5-governance/apg-doc/index.ts +0 -1043
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/component-detection.ts +0 -620
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/anatomy.ts +0 -331
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/color-tokens.ts +0 -77
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/properties.ts +0 -54
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/snapshot.ts +0 -287
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/spacing.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/states.ts +0 -43
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/typography.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/index.ts +0 -221
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/_default.ts +0 -166
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/accordion.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/alert.ts +0 -234
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar-group.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar.ts +0 -249
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/badge.ts +0 -231
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/banner.ts +0 -293
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/breadcrumb.ts +0 -240
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/button.ts +0 -243
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/calendar.ts +0 -307
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/card.ts +0 -143
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/checkbox.ts +0 -227
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/chip.ts +0 -233
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/combobox.ts +0 -282
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/datepicker.ts +0 -276
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/divider.ts +0 -223
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/drawer.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/dropdown-menu.ts +0 -289
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/empty-state.ts +0 -261
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/file-uploader.ts +0 -290
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/form.ts +0 -265
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/grid.ts +0 -238
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/icon.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/index.ts +0 -128
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-edit.ts +0 -286
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-message.ts +0 -255
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/input.ts +0 -330
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/link.ts +0 -247
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/list.ts +0 -250
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/menu.ts +0 -247
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/modal.ts +0 -144
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navbar.ts +0 -264
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navigation.ts +0 -251
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/number-input.ts +0 -261
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/pagination.ts +0 -248
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/popover.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/progress.ts +0 -251
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/radio.ts +0 -142
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/range-slider.ts +0 -282
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/rating.ts +0 -250
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/search.ts +0 -258
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/segmented-control.ts +0 -265
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/select.ts +0 -319
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/skeleton.ts +0 -256
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/slider.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/spinner.ts +0 -239
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/status-dot.ts +0 -252
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/stepper.ts +0 -270
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/table.ts +0 -244
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tabs.ts +0 -143
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tag.ts +0 -243
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/textarea.ts +0 -259
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/time-picker.ts +0 -293
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toast.ts +0 -144
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toggle.ts +0 -289
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toolbar.ts +0 -267
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tooltip.ts +0 -232
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/treeview.ts +0 -257
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/typography.ts +0 -319
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/legacy-compat.ts +0 -121
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/anatomy-diagram.ts +0 -430
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/figma-page.ts +0 -312
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/json.ts +0 -129
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/markdown.ts +0 -78
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/visual-doc.ts +0 -2333
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/accessibility.ts +0 -100
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/anatomy.ts +0 -32
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/color-tokens.ts +0 -59
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/content-guidance.ts +0 -18
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/design-tokens.ts +0 -53
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/interaction-rules.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/overview.ts +0 -91
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/properties-api.ts +0 -71
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/qa-criteria.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/related-components.ts +0 -110
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/responsive.ts +0 -19
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/size-specs.ts +0 -67
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/spacing-structure.ts +0 -58
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/state-specs.ts +0 -79
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/states.ts +0 -50
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/type-hierarchy.ts +0 -33
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/typography.ts +0 -55
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/usage-guidelines.ts +0 -73
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/variants.ts +0 -81
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/types.ts +0 -409
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/index.ts +0 -198
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/renderer.ts +0 -701
- package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/types.ts +0 -88
- package/figma-intelligence-layer/src/tools/phase5-governance/decision-log/index.ts +0 -135
- package/figma-intelligence-layer/src/tools/phase5-governance/design-decision-log/index.ts +0 -491
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-primitives/index.ts +0 -416
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-scaffolder/index.ts +0 -722
- package/figma-intelligence-layer/src/tools/phase5-governance/ds-variables/index.ts +0 -449
- package/figma-intelligence-layer/src/tools/phase5-governance/health-report/index.ts +0 -393
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/index.ts +0 -406
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts +0 -292
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/json.ts +0 -24
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/markdown.ts +0 -172
- package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/naming-guide.ts +0 -409
- package/figma-intelligence-layer/src/tools/phase5-governance/token-analytics/index.ts +0 -594
- package/figma-intelligence-layer/src/tools/phase5-governance/token-docs/index.ts +0 -710
- package/figma-intelligence-layer/src/tools/phase5-governance/token-migrate/index.ts +0 -458
- package/figma-intelligence-layer/src/tools/phase5-governance/token-naming/index.ts +0 -134
- package/figma-intelligence-layer/tests/apg-doc.test.ts +0 -101
- package/figma-intelligence-layer/tests/design-system-context.test.ts +0 -152
- package/figma-intelligence-layer/tests/design-system-matcher.test.ts +0 -144
- package/figma-intelligence-layer/tests/figma-bridge.test.ts +0 -83
- package/figma-intelligence-layer/tests/generate-image-and-insert.test.ts +0 -56
- package/figma-intelligence-layer/tests/screen-cloner-regression.test.ts +0 -69
- package/figma-intelligence-layer/tests/smoke.test.ts +0 -174
- package/figma-intelligence-layer/tests/spec-generator.test.ts +0 -127
- package/figma-intelligence-layer/tests/token-migrate.test.ts +0 -21
- package/figma-intelligence-layer/tests/token-naming.test.ts +0 -30
- package/figma-intelligence-layer/tsconfig.json +0 -19
- package/scripts/clean-existing-chunks.js +0 -179
- package/scripts/connect-ai-tool.js +0 -490
- package/scripts/convert-hub-pdfs.js +0 -425
- package/scripts/figma-mcp-status.js +0 -349
- package/scripts/register-codex-mcp.js +0 -96
- /package/{design-bridge → dist/design-bridge}/.env.example +0 -0
- /package/{design-bridge → dist/design-bridge}/package.json +0 -0
- /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/manifest.json +0 -0
- /package/{figma-bridge-plugin → dist/figma-bridge-plugin}/package.json +0 -0
- /package/{figma-intelligence-layer → dist/figma-intelligence-layer}/package.json +0 -0
|
@@ -1,596 +0,0 @@
|
|
|
1
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
-
// Animation Specifier
|
|
3
|
-
// Extracts prototype animation data from Figma connections and generates
|
|
4
|
-
// production-ready animation code for framer-motion, CSS, Swift, and Android.
|
|
5
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
-
|
|
7
|
-
import { getBridge } from "../../../shared/figma-bridge.js";
|
|
8
|
-
import { decisionLog } from "../../../shared/decision-log.js";
|
|
9
|
-
|
|
10
|
-
// ─── Public types ─────────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
export interface AnimationSpecifierArgs {
|
|
13
|
-
fileKey?: string;
|
|
14
|
-
frameNodeId?: string;
|
|
15
|
-
outputFormat: "json" | "framer-motion" | "css" | "swift" | "android" | "all";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface AnimationSpec {
|
|
19
|
-
name: string;
|
|
20
|
-
fromId: string;
|
|
21
|
-
toId: string;
|
|
22
|
-
duration: number;
|
|
23
|
-
easing: string;
|
|
24
|
-
easingValues: number[];
|
|
25
|
-
direction: string;
|
|
26
|
-
type: string;
|
|
27
|
-
isSpring: boolean;
|
|
28
|
-
springStiffness?: number;
|
|
29
|
-
springDamping?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface AnimationSpecifierResult {
|
|
33
|
-
animations: AnimationSpec[];
|
|
34
|
-
code: {
|
|
35
|
-
json?: string;
|
|
36
|
-
framerMotion?: string;
|
|
37
|
-
css?: string;
|
|
38
|
-
swift?: string;
|
|
39
|
-
android?: string;
|
|
40
|
-
};
|
|
41
|
-
totalConnections: number;
|
|
42
|
-
animatedConnections: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ─── Easing maps ──────────────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
const EASING_CSS_MAP: Record<string, string> = {
|
|
48
|
-
EASE_IN: "cubic-bezier(0.4, 0, 1, 1)",
|
|
49
|
-
EASE_OUT: "cubic-bezier(0, 0, 0.2, 1)",
|
|
50
|
-
EASE_IN_OUT: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
51
|
-
LINEAR: "cubic-bezier(0, 0, 1, 1)",
|
|
52
|
-
SPRING: "cubic-bezier(0.4, 0, 0.2, 1)", // approximation for CSS
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const EASING_SWIFT_MAP: Record<string, string> = {
|
|
56
|
-
EASE_IN: ".easeIn",
|
|
57
|
-
EASE_OUT: ".easeOut",
|
|
58
|
-
EASE_IN_OUT: ".easeInOut",
|
|
59
|
-
LINEAR: ".linear",
|
|
60
|
-
SPRING: ".spring(response: 0.4, dampingFraction: 0.7)",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const EASING_CUBIC_MAP: Record<string, number[]> = {
|
|
64
|
-
EASE_IN: [0.4, 0, 1, 1],
|
|
65
|
-
EASE_OUT: [0, 0, 0.2, 1],
|
|
66
|
-
EASE_IN_OUT: [0.4, 0, 0.2, 1],
|
|
67
|
-
LINEAR: [0, 0, 1, 1],
|
|
68
|
-
SPRING: [0.4, 0, 0.2, 1],
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// ─── Connection parser ────────────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
interface RawConnection {
|
|
74
|
-
fromId: string;
|
|
75
|
-
fromName: string;
|
|
76
|
-
toId: string;
|
|
77
|
-
toName: string;
|
|
78
|
-
trigger: Record<string, unknown>;
|
|
79
|
-
action: Record<string, unknown>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function sanitizeName(name: string): string {
|
|
83
|
-
return name
|
|
84
|
-
.replace(/[^a-zA-Z0-9_\s]/g, "")
|
|
85
|
-
.trim()
|
|
86
|
-
.replace(/\s+(.)/g, (_, c: string) => c.toUpperCase())
|
|
87
|
-
.replace(/^\w/, (c) => c.toLowerCase());
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function detectEasing(action: Record<string, unknown>): string {
|
|
91
|
-
const transition = action["transition"] as Record<string, unknown> | undefined;
|
|
92
|
-
if (!transition) return "EASE_IN_OUT";
|
|
93
|
-
|
|
94
|
-
const easing = transition["easing"] as Record<string, unknown> | string | undefined;
|
|
95
|
-
if (!easing) return "EASE_IN_OUT";
|
|
96
|
-
|
|
97
|
-
if (typeof easing === "string") return easing;
|
|
98
|
-
|
|
99
|
-
const type = (easing["type"] as string | undefined)?.toUpperCase();
|
|
100
|
-
if (!type) return "EASE_IN_OUT";
|
|
101
|
-
|
|
102
|
-
if (type.includes("SPRING") || type === "SPRING_PRESET") return "SPRING";
|
|
103
|
-
if (type.includes("EASE_IN_AND_OUT") || type.includes("EASE_IN_OUT")) return "EASE_IN_OUT";
|
|
104
|
-
if (type.includes("EASE_IN")) return "EASE_IN";
|
|
105
|
-
if (type.includes("EASE_OUT")) return "EASE_OUT";
|
|
106
|
-
if (type.includes("LINEAR")) return "LINEAR";
|
|
107
|
-
return "EASE_IN_OUT";
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function detectTransitionType(action: Record<string, unknown>): { type: string; direction: string } {
|
|
111
|
-
const transition = action["transition"] as Record<string, unknown> | undefined;
|
|
112
|
-
if (!transition) return { type: "DISSOLVE", direction: "none" };
|
|
113
|
-
|
|
114
|
-
const rawType = (transition["type"] as string | undefined)?.toUpperCase() ?? "DISSOLVE";
|
|
115
|
-
const direction = (transition["direction"] as string | undefined)?.toUpperCase() ?? "none";
|
|
116
|
-
|
|
117
|
-
return { type: rawType, direction };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function parseConnections(connections: RawConnection[]): AnimationSpec[] {
|
|
121
|
-
const specs: AnimationSpec[] = [];
|
|
122
|
-
|
|
123
|
-
for (const conn of connections) {
|
|
124
|
-
const transition = (conn.action["transition"] as Record<string, unknown> | undefined);
|
|
125
|
-
if (!transition) continue;
|
|
126
|
-
|
|
127
|
-
const durationRaw = transition["duration"] as number | undefined;
|
|
128
|
-
const duration = typeof durationRaw === "number" ? durationRaw : 0.3;
|
|
129
|
-
|
|
130
|
-
const easingKey = detectEasing(conn.action);
|
|
131
|
-
const { type, direction } = detectTransitionType(conn.action);
|
|
132
|
-
const isSpring = easingKey === "SPRING";
|
|
133
|
-
|
|
134
|
-
const spec: AnimationSpec = {
|
|
135
|
-
name: sanitizeName(`${conn.fromName}To${conn.toName}`),
|
|
136
|
-
fromId: conn.fromId,
|
|
137
|
-
toId: conn.toId,
|
|
138
|
-
duration,
|
|
139
|
-
easing: easingKey,
|
|
140
|
-
easingValues: EASING_CUBIC_MAP[easingKey] ?? [0.4, 0, 0.2, 1],
|
|
141
|
-
direction,
|
|
142
|
-
type,
|
|
143
|
-
isSpring,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
if (isSpring) {
|
|
147
|
-
spec.springStiffness = 300;
|
|
148
|
-
spec.springDamping = 30;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
specs.push(spec);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return specs;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// ─── Code generators ──────────────────────────────────────────────────────────
|
|
158
|
-
|
|
159
|
-
function getSlideAxis(type: string, direction: string): { axis: "x" | "y"; sign: number } {
|
|
160
|
-
const dir = direction.toUpperCase();
|
|
161
|
-
|
|
162
|
-
if (type === "PUSH" || type === "SLIDE_IN" || type === "SLIDE_OUT" ||
|
|
163
|
-
type === "MOVE_IN" || type === "MOVE_OUT") {
|
|
164
|
-
if (dir === "LEFT") return { axis: "x", sign: -1 };
|
|
165
|
-
if (dir === "RIGHT") return { axis: "x", sign: 1 };
|
|
166
|
-
if (dir === "UP") return { axis: "y", sign: -1 };
|
|
167
|
-
if (dir === "DOWN") return { axis: "y", sign: 1 };
|
|
168
|
-
}
|
|
169
|
-
return { axis: "x", sign: 1 };
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function getClosedVariant(spec: AnimationSpec): Record<string, unknown> {
|
|
173
|
-
const type = spec.type.toUpperCase();
|
|
174
|
-
const dir = spec.direction.toUpperCase();
|
|
175
|
-
|
|
176
|
-
if (type === "DISSOLVE") {
|
|
177
|
-
return { opacity: 0 };
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (type === "SMART_ANIMATE") {
|
|
181
|
-
return { opacity: 0, scale: 0.95 };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
type === "PUSH" || type === "SLIDE_IN" || type === "SLIDE_OUT" ||
|
|
186
|
-
type === "MOVE_IN" || type === "MOVE_OUT"
|
|
187
|
-
) {
|
|
188
|
-
const { axis, sign } = getSlideAxis(type, dir);
|
|
189
|
-
const closed: Record<string, unknown> = { opacity: 0 };
|
|
190
|
-
closed[axis] = sign * 100;
|
|
191
|
-
return closed;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return { opacity: 0 };
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function generateFramerMotion(specs: AnimationSpec[]): string {
|
|
198
|
-
const lines: string[] = [
|
|
199
|
-
'// Generated by figma-intelligence-layer animation-specifier',
|
|
200
|
-
'import { Variants } from "framer-motion";',
|
|
201
|
-
"",
|
|
202
|
-
];
|
|
203
|
-
|
|
204
|
-
for (const spec of specs) {
|
|
205
|
-
const varName = `${spec.name}Variants`;
|
|
206
|
-
const closedVariant = getClosedVariant(spec);
|
|
207
|
-
const openVariant: Record<string, unknown> = { opacity: 1 };
|
|
208
|
-
|
|
209
|
-
// Mirror positional closed values to zero in open
|
|
210
|
-
for (const key of Object.keys(closedVariant)) {
|
|
211
|
-
if (key !== "opacity" && key !== "scale") openVariant[key] = 0;
|
|
212
|
-
if (key === "scale") openVariant[key] = 1;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
let transition: Record<string, unknown>;
|
|
216
|
-
if (spec.isSpring) {
|
|
217
|
-
transition = {
|
|
218
|
-
type: "spring",
|
|
219
|
-
stiffness: spec.springStiffness ?? 300,
|
|
220
|
-
damping: spec.springDamping ?? 30,
|
|
221
|
-
};
|
|
222
|
-
} else {
|
|
223
|
-
transition = {
|
|
224
|
-
duration: spec.duration,
|
|
225
|
-
ease: spec.easingValues,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
lines.push(`export const ${varName}: Variants = {`);
|
|
230
|
-
lines.push(` closed: ${JSON.stringify(closedVariant)},`);
|
|
231
|
-
lines.push(` open: {`);
|
|
232
|
-
lines.push(` ...${JSON.stringify(openVariant)},`);
|
|
233
|
-
lines.push(` transition: ${JSON.stringify(transition)},`);
|
|
234
|
-
lines.push(` },`);
|
|
235
|
-
lines.push(`};`);
|
|
236
|
-
lines.push("");
|
|
237
|
-
|
|
238
|
-
// Add a helper component usage comment
|
|
239
|
-
lines.push(`// Usage: <motion.div variants={${varName}} initial="closed" animate="open" />`);
|
|
240
|
-
lines.push("");
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return lines.join("\n");
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function generateCSS(specs: AnimationSpec[]): string {
|
|
247
|
-
const lines: string[] = [
|
|
248
|
-
"/* Generated by figma-intelligence-layer animation-specifier */",
|
|
249
|
-
"",
|
|
250
|
-
];
|
|
251
|
-
|
|
252
|
-
for (const spec of specs) {
|
|
253
|
-
const type = spec.type.toUpperCase();
|
|
254
|
-
const dir = spec.direction.toUpperCase();
|
|
255
|
-
const name = spec.name;
|
|
256
|
-
const durationMs = Math.round(spec.duration * 1000);
|
|
257
|
-
const easingCss = EASING_CSS_MAP[spec.easing] ?? "ease-in-out";
|
|
258
|
-
|
|
259
|
-
if (type === "DISSOLVE") {
|
|
260
|
-
lines.push(`@keyframes ${name}FadeIn {`);
|
|
261
|
-
lines.push(` from { opacity: 0; }`);
|
|
262
|
-
lines.push(` to { opacity: 1; }`);
|
|
263
|
-
lines.push(`}`);
|
|
264
|
-
lines.push("");
|
|
265
|
-
lines.push(`.${name} {`);
|
|
266
|
-
lines.push(` animation: ${name}FadeIn ${durationMs}ms ${easingCss} forwards;`);
|
|
267
|
-
lines.push(`}`);
|
|
268
|
-
} else if (type === "SMART_ANIMATE") {
|
|
269
|
-
lines.push(`@keyframes ${name}Morph {`);
|
|
270
|
-
lines.push(` from { opacity: 0; transform: scale(0.95); }`);
|
|
271
|
-
lines.push(` to { opacity: 1; transform: scale(1); }`);
|
|
272
|
-
lines.push(`}`);
|
|
273
|
-
lines.push("");
|
|
274
|
-
lines.push(`.${name} {`);
|
|
275
|
-
lines.push(` animation: ${name}Morph ${durationMs}ms ${easingCss} forwards;`);
|
|
276
|
-
lines.push(`}`);
|
|
277
|
-
} else if (
|
|
278
|
-
type === "PUSH" || type === "SLIDE_IN" || type === "SLIDE_OUT" ||
|
|
279
|
-
type === "MOVE_IN" || type === "MOVE_OUT"
|
|
280
|
-
) {
|
|
281
|
-
const { axis, sign } = getSlideAxis(type, dir);
|
|
282
|
-
const translateFn = axis === "x" ? "translateX" : "translateY";
|
|
283
|
-
const fromVal = `${sign * 100}%`;
|
|
284
|
-
|
|
285
|
-
lines.push(`@keyframes ${name}SlideIn {`);
|
|
286
|
-
lines.push(` from { opacity: 0; transform: ${translateFn}(${fromVal}); }`);
|
|
287
|
-
lines.push(` to { opacity: 1; transform: ${translateFn}(0); }`);
|
|
288
|
-
lines.push(`}`);
|
|
289
|
-
lines.push("");
|
|
290
|
-
lines.push(`.${name} {`);
|
|
291
|
-
lines.push(` animation: ${name}SlideIn ${durationMs}ms ${easingCss} forwards;`);
|
|
292
|
-
lines.push(`}`);
|
|
293
|
-
} else {
|
|
294
|
-
lines.push(`@keyframes ${name} {`);
|
|
295
|
-
lines.push(` from { opacity: 0; }`);
|
|
296
|
-
lines.push(` to { opacity: 1; }`);
|
|
297
|
-
lines.push(`}`);
|
|
298
|
-
lines.push("");
|
|
299
|
-
lines.push(`.${name} {`);
|
|
300
|
-
lines.push(` animation: ${name} ${durationMs}ms ${easingCss} forwards;`);
|
|
301
|
-
lines.push(`}`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
lines.push("");
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return lines.join("\n");
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function generateSwift(specs: AnimationSpec[]): string {
|
|
311
|
-
const lines: string[] = [
|
|
312
|
-
"// Generated by figma-intelligence-layer animation-specifier",
|
|
313
|
-
"import SwiftUI",
|
|
314
|
-
"import UIKit",
|
|
315
|
-
"",
|
|
316
|
-
"// MARK: - SwiftUI Animations",
|
|
317
|
-
"",
|
|
318
|
-
];
|
|
319
|
-
|
|
320
|
-
for (const spec of specs) {
|
|
321
|
-
const type = spec.type.toUpperCase();
|
|
322
|
-
const dir = spec.direction.toUpperCase();
|
|
323
|
-
const swiftEasing = EASING_SWIFT_MAP[spec.easing] ?? ".easeInOut";
|
|
324
|
-
const durationStr = spec.duration.toFixed(3);
|
|
325
|
-
const name = spec.name;
|
|
326
|
-
|
|
327
|
-
lines.push(`// Transition: ${spec.fromId} → ${spec.toId}`);
|
|
328
|
-
|
|
329
|
-
if (spec.isSpring) {
|
|
330
|
-
lines.push(`func ${name}Animation(isVisible: Binding<Bool>) -> some View {`);
|
|
331
|
-
lines.push(` content`);
|
|
332
|
-
lines.push(` .opacity(isVisible.wrappedValue ? 1 : 0)`);
|
|
333
|
-
lines.push(` .animation(.spring(response: ${durationStr}, dampingFraction: 0.7), value: isVisible.wrappedValue)`);
|
|
334
|
-
lines.push(`}`);
|
|
335
|
-
} else if (type === "DISSOLVE") {
|
|
336
|
-
lines.push(`func ${name}Animation(isVisible: Binding<Bool>) -> some View {`);
|
|
337
|
-
lines.push(` content`);
|
|
338
|
-
lines.push(` .opacity(isVisible.wrappedValue ? 1 : 0)`);
|
|
339
|
-
lines.push(` .animation(.easeInOut(duration: ${durationStr}), value: isVisible.wrappedValue)`);
|
|
340
|
-
lines.push(`}`);
|
|
341
|
-
} else if (type === "SMART_ANIMATE") {
|
|
342
|
-
lines.push(`func ${name}Animation(isVisible: Binding<Bool>) -> some View {`);
|
|
343
|
-
lines.push(` content`);
|
|
344
|
-
lines.push(` .opacity(isVisible.wrappedValue ? 1 : 0)`);
|
|
345
|
-
lines.push(` .scaleEffect(isVisible.wrappedValue ? 1 : 0.95)`);
|
|
346
|
-
lines.push(` .animation(${swiftEasing}(duration: ${durationStr}), value: isVisible.wrappedValue)`);
|
|
347
|
-
lines.push(`}`);
|
|
348
|
-
} else if (
|
|
349
|
-
type === "PUSH" || type === "SLIDE_IN" || type === "SLIDE_OUT" ||
|
|
350
|
-
type === "MOVE_IN" || type === "MOVE_OUT"
|
|
351
|
-
) {
|
|
352
|
-
const isHorizontal = dir === "LEFT" || dir === "RIGHT";
|
|
353
|
-
const offsetEdge = dir === "LEFT" ? "-UIScreen.main.bounds.width"
|
|
354
|
-
: dir === "RIGHT" ? "UIScreen.main.bounds.width"
|
|
355
|
-
: dir === "UP" ? "-UIScreen.main.bounds.height"
|
|
356
|
-
: "UIScreen.main.bounds.height";
|
|
357
|
-
|
|
358
|
-
lines.push(`func ${name}Animation(isVisible: Binding<Bool>) -> some View {`);
|
|
359
|
-
if (isHorizontal) {
|
|
360
|
-
lines.push(` content`);
|
|
361
|
-
lines.push(` .offset(x: isVisible.wrappedValue ? 0 : ${offsetEdge})`);
|
|
362
|
-
lines.push(` .opacity(isVisible.wrappedValue ? 1 : 0)`);
|
|
363
|
-
lines.push(` .animation(${swiftEasing}(duration: ${durationStr}), value: isVisible.wrappedValue)`);
|
|
364
|
-
} else {
|
|
365
|
-
lines.push(` content`);
|
|
366
|
-
lines.push(` .offset(y: isVisible.wrappedValue ? 0 : ${offsetEdge})`);
|
|
367
|
-
lines.push(` .opacity(isVisible.wrappedValue ? 1 : 0)`);
|
|
368
|
-
lines.push(` .animation(${swiftEasing}(duration: ${durationStr}), value: isVisible.wrappedValue)`);
|
|
369
|
-
}
|
|
370
|
-
lines.push(`}`);
|
|
371
|
-
} else {
|
|
372
|
-
lines.push(`func ${name}Animation(isVisible: Binding<Bool>) -> some View {`);
|
|
373
|
-
lines.push(` content`);
|
|
374
|
-
lines.push(` .opacity(isVisible.wrappedValue ? 1 : 0)`);
|
|
375
|
-
lines.push(` .animation(${swiftEasing}(duration: ${durationStr}), value: isVisible.wrappedValue)`);
|
|
376
|
-
lines.push(`}`);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
lines.push("");
|
|
380
|
-
|
|
381
|
-
// UIKit version
|
|
382
|
-
lines.push(`// UIKit equivalent for ${name}`);
|
|
383
|
-
lines.push(`func ${name}UIKitAnimate(view: UIView, isShowing: Bool) {`);
|
|
384
|
-
if (spec.isSpring) {
|
|
385
|
-
lines.push(` let animator = UIViewPropertyAnimator(duration: ${durationStr}, dampingRatio: 0.7) {`);
|
|
386
|
-
lines.push(` view.alpha = isShowing ? 1 : 0`);
|
|
387
|
-
lines.push(` view.transform = isShowing ? .identity : CGAffineTransform(scaleX: 0.95, y: 0.95)`);
|
|
388
|
-
lines.push(` }`);
|
|
389
|
-
} else {
|
|
390
|
-
lines.push(` let animator = UIViewPropertyAnimator(duration: ${durationStr}, curve: ${swiftEasing.replace(".", ".")}) {`);
|
|
391
|
-
lines.push(` view.alpha = isShowing ? 1 : 0`);
|
|
392
|
-
lines.push(` }`);
|
|
393
|
-
}
|
|
394
|
-
lines.push(` animator.startAnimation()`);
|
|
395
|
-
lines.push(`}`);
|
|
396
|
-
lines.push("");
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return lines.join("\n");
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function generateAndroid(specs: AnimationSpec[]): string {
|
|
403
|
-
const lines: string[] = [
|
|
404
|
-
"// Generated by figma-intelligence-layer animation-specifier",
|
|
405
|
-
"// Kotlin — place these in your animation utilities file",
|
|
406
|
-
"",
|
|
407
|
-
"import android.animation.AnimatorSet",
|
|
408
|
-
"import android.animation.ObjectAnimator",
|
|
409
|
-
"import android.view.View",
|
|
410
|
-
"import android.view.animation.AccelerateDecelerateInterpolator",
|
|
411
|
-
"import android.view.animation.AccelerateInterpolator",
|
|
412
|
-
"import android.view.animation.DecelerateInterpolator",
|
|
413
|
-
"import android.view.animation.LinearInterpolator",
|
|
414
|
-
"import androidx.interpolator.view.animation.FastOutSlowInInterpolator",
|
|
415
|
-
"",
|
|
416
|
-
"object FigmaAnimations {",
|
|
417
|
-
"",
|
|
418
|
-
];
|
|
419
|
-
|
|
420
|
-
for (const spec of specs) {
|
|
421
|
-
const type = spec.type.toUpperCase();
|
|
422
|
-
const dir = spec.direction.toUpperCase();
|
|
423
|
-
const durationMs = Math.round(spec.duration * 1000);
|
|
424
|
-
const name = spec.name;
|
|
425
|
-
|
|
426
|
-
const interpolatorMap: Record<string, string> = {
|
|
427
|
-
EASE_IN: "AccelerateInterpolator()",
|
|
428
|
-
EASE_OUT: "DecelerateInterpolator()",
|
|
429
|
-
EASE_IN_OUT: "FastOutSlowInInterpolator()",
|
|
430
|
-
LINEAR: "LinearInterpolator()",
|
|
431
|
-
SPRING: "FastOutSlowInInterpolator()",
|
|
432
|
-
};
|
|
433
|
-
const interpolator = interpolatorMap[spec.easing] ?? "FastOutSlowInInterpolator()";
|
|
434
|
-
|
|
435
|
-
lines.push(` // ${spec.fromId} → ${spec.toId}`);
|
|
436
|
-
lines.push(` fun ${name}(view: View, isEntering: Boolean) {`);
|
|
437
|
-
|
|
438
|
-
if (type === "DISSOLVE") {
|
|
439
|
-
lines.push(` val alpha = ObjectAnimator.ofFloat(`);
|
|
440
|
-
lines.push(` view, "alpha", if (isEntering) 0f else 1f, if (isEntering) 1f else 0f`);
|
|
441
|
-
lines.push(` )`);
|
|
442
|
-
lines.push(` alpha.duration = ${durationMs}L`);
|
|
443
|
-
lines.push(` alpha.interpolator = ${interpolator}`);
|
|
444
|
-
lines.push(` alpha.start()`);
|
|
445
|
-
} else if (type === "SMART_ANIMATE") {
|
|
446
|
-
lines.push(` val alpha = ObjectAnimator.ofFloat(`);
|
|
447
|
-
lines.push(` view, "alpha", if (isEntering) 0f else 1f, if (isEntering) 1f else 0f`);
|
|
448
|
-
lines.push(` )`);
|
|
449
|
-
lines.push(` val scaleX = ObjectAnimator.ofFloat(`);
|
|
450
|
-
lines.push(` view, "scaleX", if (isEntering) 0.95f else 1f, if (isEntering) 1f else 0.95f`);
|
|
451
|
-
lines.push(` )`);
|
|
452
|
-
lines.push(` val scaleY = ObjectAnimator.ofFloat(`);
|
|
453
|
-
lines.push(` view, "scaleY", if (isEntering) 0.95f else 1f, if (isEntering) 1f else 0.95f`);
|
|
454
|
-
lines.push(` )`);
|
|
455
|
-
lines.push(` val set = AnimatorSet()`);
|
|
456
|
-
lines.push(` set.playTogether(alpha, scaleX, scaleY)`);
|
|
457
|
-
lines.push(` set.duration = ${durationMs}L`);
|
|
458
|
-
lines.push(` set.interpolator = ${interpolator}`);
|
|
459
|
-
lines.push(` set.start()`);
|
|
460
|
-
} else if (
|
|
461
|
-
type === "PUSH" || type === "SLIDE_IN" || type === "SLIDE_OUT" ||
|
|
462
|
-
type === "MOVE_IN" || type === "MOVE_OUT"
|
|
463
|
-
) {
|
|
464
|
-
const { axis, sign } = getSlideAxis(type, dir);
|
|
465
|
-
const property = axis === "x" ? "translationX" : "translationY";
|
|
466
|
-
const fromExpr = `if (isEntering) ${sign * 500}f else 0f`;
|
|
467
|
-
const toExpr = `if (isEntering) 0f else ${sign * 500}f`;
|
|
468
|
-
|
|
469
|
-
lines.push(` val translate = ObjectAnimator.ofFloat(`);
|
|
470
|
-
lines.push(` view, "${property}", ${fromExpr}, ${toExpr}`);
|
|
471
|
-
lines.push(` )`);
|
|
472
|
-
lines.push(` val alpha = ObjectAnimator.ofFloat(`);
|
|
473
|
-
lines.push(` view, "alpha", if (isEntering) 0f else 1f, if (isEntering) 1f else 0f`);
|
|
474
|
-
lines.push(` )`);
|
|
475
|
-
lines.push(` val set = AnimatorSet()`);
|
|
476
|
-
lines.push(` set.playTogether(translate, alpha)`);
|
|
477
|
-
lines.push(` set.duration = ${durationMs}L`);
|
|
478
|
-
lines.push(` set.interpolator = ${interpolator}`);
|
|
479
|
-
lines.push(` set.start()`);
|
|
480
|
-
} else {
|
|
481
|
-
lines.push(` val alpha = ObjectAnimator.ofFloat(`);
|
|
482
|
-
lines.push(` view, "alpha", if (isEntering) 0f else 1f, if (isEntering) 1f else 0f`);
|
|
483
|
-
lines.push(` )`);
|
|
484
|
-
lines.push(` alpha.duration = ${durationMs}L`);
|
|
485
|
-
lines.push(` alpha.interpolator = ${interpolator}`);
|
|
486
|
-
lines.push(` alpha.start()`);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
lines.push(` }`);
|
|
490
|
-
lines.push("");
|
|
491
|
-
|
|
492
|
-
// XML resource comment
|
|
493
|
-
lines.push(` /*`);
|
|
494
|
-
lines.push(` * res/animator/${name.toLowerCase()}.xml`);
|
|
495
|
-
lines.push(` * <set xmlns:android="http://schemas.android.com/apk/res/android">`);
|
|
496
|
-
|
|
497
|
-
if (type === "DISSOLVE") {
|
|
498
|
-
lines.push(` * <objectAnimator android:propertyName="alpha"`);
|
|
499
|
-
lines.push(` * android:valueFrom="0" android:valueTo="1"`);
|
|
500
|
-
lines.push(` * android:duration="${durationMs}" />`);
|
|
501
|
-
} else if (
|
|
502
|
-
type === "PUSH" || type === "SLIDE_IN" || type === "SLIDE_OUT" ||
|
|
503
|
-
type === "MOVE_IN" || type === "MOVE_OUT"
|
|
504
|
-
) {
|
|
505
|
-
const { axis, sign } = getSlideAxis(type, dir);
|
|
506
|
-
const property = axis === "x" ? "translationX" : "translationY";
|
|
507
|
-
lines.push(` * <objectAnimator android:propertyName="${property}"`);
|
|
508
|
-
lines.push(` * android:valueFrom="${sign * 500}" android:valueTo="0"`);
|
|
509
|
-
lines.push(` * android:duration="${durationMs}" />`);
|
|
510
|
-
lines.push(` * <objectAnimator android:propertyName="alpha"`);
|
|
511
|
-
lines.push(` * android:valueFrom="0" android:valueTo="1"`);
|
|
512
|
-
lines.push(` * android:duration="${durationMs}" />`);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
lines.push(` * </set>`);
|
|
516
|
-
lines.push(` */`);
|
|
517
|
-
lines.push("");
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
lines.push("}");
|
|
521
|
-
return lines.join("\n");
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// ─── Main handler ─────────────────────────────────────────────────────────────
|
|
525
|
-
|
|
526
|
-
export async function animationSpecifierHandler(
|
|
527
|
-
args: AnimationSpecifierArgs
|
|
528
|
-
): Promise<AnimationSpecifierResult> {
|
|
529
|
-
const { frameNodeId, outputFormat } = args;
|
|
530
|
-
|
|
531
|
-
const bridge = await getBridge();
|
|
532
|
-
|
|
533
|
-
// 1. Retrieve all prototype connections
|
|
534
|
-
let rawConnections = await bridge.getPrototypeConnections();
|
|
535
|
-
|
|
536
|
-
// 2. Filter to the requested frame if specified
|
|
537
|
-
if (frameNodeId) {
|
|
538
|
-
rawConnections = rawConnections.filter(
|
|
539
|
-
(c) => c.fromId === frameNodeId || c.toId === frameNodeId
|
|
540
|
-
);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const totalConnections = rawConnections.length;
|
|
544
|
-
|
|
545
|
-
// 3. Filter to connections that carry animation data
|
|
546
|
-
const animatedRaw = rawConnections.filter((c) => {
|
|
547
|
-
const transition = (c.action["transition"] as Record<string, unknown> | undefined);
|
|
548
|
-
return transition !== undefined && transition !== null;
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
const animatedConnections = animatedRaw.length;
|
|
552
|
-
|
|
553
|
-
// 4. Parse into AnimationSpec objects
|
|
554
|
-
const animations = parseConnections(animatedRaw);
|
|
555
|
-
|
|
556
|
-
// 5. Generate code in the requested format(s)
|
|
557
|
-
const code: AnimationSpecifierResult["code"] = {};
|
|
558
|
-
const needsAll = outputFormat === "all";
|
|
559
|
-
|
|
560
|
-
if (outputFormat === "json" || needsAll) {
|
|
561
|
-
code.json = JSON.stringify(animations, null, 2);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (outputFormat === "framer-motion" || needsAll) {
|
|
565
|
-
code.framerMotion = generateFramerMotion(animations);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (outputFormat === "css" || needsAll) {
|
|
569
|
-
code.css = generateCSS(animations);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
if (outputFormat === "swift" || needsAll) {
|
|
573
|
-
code.swift = generateSwift(animations);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
if (outputFormat === "android" || needsAll) {
|
|
577
|
-
code.android = generateAndroid(animations);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// 6. Log the action
|
|
581
|
-
await decisionLog.log({
|
|
582
|
-
tool: "animation-specifier",
|
|
583
|
-
nodeIds: frameNodeId ? [frameNodeId] : animations.map((a) => a.fromId).slice(0, 20),
|
|
584
|
-
rationale: `Extracted ${animatedConnections} animated prototype connections from ${totalConnections} total. Generated ${outputFormat} animation code for ${animations.length} transitions.`,
|
|
585
|
-
reversible: false,
|
|
586
|
-
metadata: {
|
|
587
|
-
frameNodeId,
|
|
588
|
-
outputFormat,
|
|
589
|
-
totalConnections,
|
|
590
|
-
animatedConnections,
|
|
591
|
-
animationCount: animations.length,
|
|
592
|
-
},
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
return { animations, code, totalConnections, animatedConnections };
|
|
596
|
-
}
|