@agent-native/creative-context 0.1.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 +108 -0
- package/agent-native.package.json +104 -0
- package/dist/actions/confirm-canonical-logo.d.ts +6 -0
- package/dist/actions/confirm-canonical-logo.d.ts.map +1 -0
- package/dist/actions/confirm-canonical-logo.js +19 -0
- package/dist/actions/confirm-canonical-logo.js.map +1 -0
- package/dist/actions/continue-context-import.d.ts +7 -0
- package/dist/actions/continue-context-import.d.ts.map +1 -0
- package/dist/actions/continue-context-import.js +10 -0
- package/dist/actions/continue-context-import.js.map +1 -0
- package/dist/actions/creative-context-a2a.d.ts +10 -0
- package/dist/actions/creative-context-a2a.d.ts.map +1 -0
- package/dist/actions/creative-context-a2a.js +66 -0
- package/dist/actions/creative-context-a2a.js.map +1 -0
- package/dist/actions/get-brand-profile.d.ts +33 -0
- package/dist/actions/get-brand-profile.d.ts.map +1 -0
- package/dist/actions/get-brand-profile.js +13 -0
- package/dist/actions/get-brand-profile.js.map +1 -0
- package/dist/actions/get-context-import-status.d.ts +22 -0
- package/dist/actions/get-context-import-status.d.ts.map +1 -0
- package/dist/actions/get-context-import-status.js +12 -0
- package/dist/actions/get-context-import-status.js.map +1 -0
- package/dist/actions/get-context-item.d.ts +2 -0
- package/dist/actions/get-context-item.d.ts.map +1 -0
- package/dist/actions/get-context-item.js +2 -0
- package/dist/actions/get-context-item.js.map +1 -0
- package/dist/actions/get-context-pack.d.ts +7 -0
- package/dist/actions/get-context-pack.d.ts.map +1 -0
- package/dist/actions/get-context-pack.js +12 -0
- package/dist/actions/get-context-pack.js.map +1 -0
- package/dist/actions/get-creative-context.d.ts +119 -0
- package/dist/actions/get-creative-context.d.ts.map +1 -0
- package/dist/actions/get-creative-context.js +112 -0
- package/dist/actions/get-creative-context.js.map +1 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +63 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/infer-brand-dna.d.ts +52 -0
- package/dist/actions/infer-brand-dna.d.ts.map +1 -0
- package/dist/actions/infer-brand-dna.js +13 -0
- package/dist/actions/infer-brand-dna.js.map +1 -0
- package/dist/actions/list-canonical-logo-candidates.d.ts +9 -0
- package/dist/actions/list-canonical-logo-candidates.d.ts.map +1 -0
- package/dist/actions/list-canonical-logo-candidates.js +82 -0
- package/dist/actions/list-canonical-logo-candidates.js.map +1 -0
- package/dist/actions/list-context-connections.d.ts +22 -0
- package/dist/actions/list-context-connections.d.ts.map +1 -0
- package/dist/actions/list-context-connections.js +43 -0
- package/dist/actions/list-context-connections.js.map +1 -0
- package/dist/actions/list-context-packs.d.ts +10 -0
- package/dist/actions/list-context-packs.d.ts.map +1 -0
- package/dist/actions/list-context-packs.js +16 -0
- package/dist/actions/list-context-packs.js.map +1 -0
- package/dist/actions/list-context-sources.d.ts +12 -0
- package/dist/actions/list-context-sources.d.ts.map +1 -0
- package/dist/actions/list-context-sources.js +20 -0
- package/dist/actions/list-context-sources.js.map +1 -0
- package/dist/actions/list-context-suggestions.d.ts +13 -0
- package/dist/actions/list-context-suggestions.d.ts.map +1 -0
- package/dist/actions/list-context-suggestions.js +28 -0
- package/dist/actions/list-context-suggestions.js.map +1 -0
- package/dist/actions/manage-brand-profile.d.ts +28 -0
- package/dist/actions/manage-brand-profile.d.ts.map +1 -0
- package/dist/actions/manage-brand-profile.js +47 -0
- package/dist/actions/manage-brand-profile.js.map +1 -0
- package/dist/actions/manage-context-pack.d.ts +33 -0
- package/dist/actions/manage-context-pack.d.ts.map +1 -0
- package/dist/actions/manage-context-pack.js +65 -0
- package/dist/actions/manage-context-pack.js.map +1 -0
- package/dist/actions/manage-context-source.d.ts +51 -0
- package/dist/actions/manage-context-source.d.ts.map +1 -0
- package/dist/actions/manage-context-source.js +137 -0
- package/dist/actions/manage-context-source.js.map +1 -0
- package/dist/actions/manage-layout-template.d.ts +13 -0
- package/dist/actions/manage-layout-template.d.ts.map +1 -0
- package/dist/actions/manage-layout-template.js +43 -0
- package/dist/actions/manage-layout-template.js.map +1 -0
- package/dist/actions/preview-context-import.d.ts +23 -0
- package/dist/actions/preview-context-import.d.ts.map +1 -0
- package/dist/actions/preview-context-import.js +57 -0
- package/dist/actions/preview-context-import.js.map +1 -0
- package/dist/actions/process-context-purge.d.ts +22 -0
- package/dist/actions/process-context-purge.d.ts.map +1 -0
- package/dist/actions/process-context-purge.js +19 -0
- package/dist/actions/process-context-purge.js.map +1 -0
- package/dist/actions/propose-brand-dna.d.ts +15 -0
- package/dist/actions/propose-brand-dna.d.ts.map +1 -0
- package/dist/actions/propose-brand-dna.js +19 -0
- package/dist/actions/propose-brand-dna.js.map +1 -0
- package/dist/actions/propose-canonical-logo.d.ts +9 -0
- package/dist/actions/propose-canonical-logo.d.ts.map +1 -0
- package/dist/actions/propose-canonical-logo.js +16 -0
- package/dist/actions/propose-canonical-logo.js.map +1 -0
- package/dist/actions/publish-brand-dna.d.ts +13 -0
- package/dist/actions/publish-brand-dna.d.ts.map +1 -0
- package/dist/actions/publish-brand-dna.js +23 -0
- package/dist/actions/publish-brand-dna.js.map +1 -0
- package/dist/actions/recommend-context-roots.d.ts +14 -0
- package/dist/actions/recommend-context-roots.d.ts.map +1 -0
- package/dist/actions/recommend-context-roots.js +22 -0
- package/dist/actions/recommend-context-roots.js.map +1 -0
- package/dist/actions/record-context-feedback.d.ts +10 -0
- package/dist/actions/record-context-feedback.d.ts.map +1 -0
- package/dist/actions/record-context-feedback.js +14 -0
- package/dist/actions/record-context-feedback.js.map +1 -0
- package/dist/actions/review-context-items.d.ts +35 -0
- package/dist/actions/review-context-items.d.ts.map +1 -0
- package/dist/actions/review-context-items.js +65 -0
- package/dist/actions/review-context-items.js.map +1 -0
- package/dist/actions/run-embedding-bakeoff.d.ts +15 -0
- package/dist/actions/run-embedding-bakeoff.d.ts.map +1 -0
- package/dist/actions/run-embedding-bakeoff.js +72 -0
- package/dist/actions/run-embedding-bakeoff.js.map +1 -0
- package/dist/actions/search-creative-context.d.ts +75 -0
- package/dist/actions/search-creative-context.d.ts.map +1 -0
- package/dist/actions/search-creative-context.js +41 -0
- package/dist/actions/search-creative-context.js.map +1 -0
- package/dist/actions/set-brand-dna.d.ts +15 -0
- package/dist/actions/set-brand-dna.d.ts.map +1 -0
- package/dist/actions/set-brand-dna.js +19 -0
- package/dist/actions/set-brand-dna.js.map +1 -0
- package/dist/actions/start-context-enrichment.d.ts +10 -0
- package/dist/actions/start-context-enrichment.d.ts.map +1 -0
- package/dist/actions/start-context-enrichment.js +46 -0
- package/dist/actions/start-context-enrichment.js.map +1 -0
- package/dist/actions/start-context-import.d.ts +9 -0
- package/dist/actions/start-context-import.d.ts.map +1 -0
- package/dist/actions/start-context-import.js +36 -0
- package/dist/actions/start-context-import.js.map +1 -0
- package/dist/client/CreativeContextChip.d.ts +13 -0
- package/dist/client/CreativeContextChip.d.ts.map +1 -0
- package/dist/client/CreativeContextChip.js +45 -0
- package/dist/client/CreativeContextChip.js.map +1 -0
- package/dist/client/CreativeContextPanel.d.ts +131 -0
- package/dist/client/CreativeContextPanel.d.ts.map +1 -0
- package/dist/client/CreativeContextPanel.js +778 -0
- package/dist/client/CreativeContextPanel.js.map +1 -0
- package/dist/client/CreativeContextSettingsLink.d.ts +4 -0
- package/dist/client/CreativeContextSettingsLink.d.ts.map +1 -0
- package/dist/client/CreativeContextSettingsLink.js +8 -0
- package/dist/client/CreativeContextSettingsLink.js.map +1 -0
- package/dist/client/actions.d.ts +256 -0
- package/dist/client/actions.d.ts.map +1 -0
- package/dist/client/actions.js +89 -0
- package/dist/client/actions.js.map +1 -0
- package/dist/client/agent-tab.d.ts +9 -0
- package/dist/client/agent-tab.d.ts.map +1 -0
- package/dist/client/agent-tab.js +32 -0
- package/dist/client/agent-tab.js.map +1 -0
- package/dist/client/application-state.d.ts +22 -0
- package/dist/client/application-state.d.ts.map +1 -0
- package/dist/client/application-state.js +88 -0
- package/dist/client/application-state.js.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/messages.d.ts +5 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +1059 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/connectors/context.d.ts +9 -0
- package/dist/connectors/context.d.ts.map +1 -0
- package/dist/connectors/context.js +59 -0
- package/dist/connectors/context.js.map +1 -0
- package/dist/connectors/document-parser.d.ts +2 -0
- package/dist/connectors/document-parser.d.ts.map +1 -0
- package/dist/connectors/document-parser.js +2 -0
- package/dist/connectors/document-parser.js.map +1 -0
- package/dist/connectors/figma-native.d.ts +18 -0
- package/dist/connectors/figma-native.d.ts.map +1 -0
- package/dist/connectors/figma-native.js +883 -0
- package/dist/connectors/figma-native.js.map +1 -0
- package/dist/connectors/figma.d.ts +10 -0
- package/dist/connectors/figma.d.ts.map +1 -0
- package/dist/connectors/figma.js +166 -0
- package/dist/connectors/figma.js.map +1 -0
- package/dist/connectors/google-slides-native.d.ts +58 -0
- package/dist/connectors/google-slides-native.d.ts.map +1 -0
- package/dist/connectors/google-slides-native.js +1118 -0
- package/dist/connectors/google-slides-native.js.map +1 -0
- package/dist/connectors/google-slides.d.ts +15 -0
- package/dist/connectors/google-slides.d.ts.map +1 -0
- package/dist/connectors/google-slides.js +896 -0
- package/dist/connectors/google-slides.js.map +1 -0
- package/dist/connectors/index.d.ts +20 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +44 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/manual.d.ts +9 -0
- package/dist/connectors/manual.d.ts.map +1 -0
- package/dist/connectors/manual.js +91 -0
- package/dist/connectors/manual.js.map +1 -0
- package/dist/connectors/normalize.d.ts +35 -0
- package/dist/connectors/normalize.d.ts.map +1 -0
- package/dist/connectors/normalize.js +216 -0
- package/dist/connectors/normalize.js.map +1 -0
- package/dist/connectors/notion.d.ts +10 -0
- package/dist/connectors/notion.d.ts.map +1 -0
- package/dist/connectors/notion.js +393 -0
- package/dist/connectors/notion.js.map +1 -0
- package/dist/connectors/private-artifacts.d.ts +39 -0
- package/dist/connectors/private-artifacts.d.ts.map +1 -0
- package/dist/connectors/private-artifacts.js +175 -0
- package/dist/connectors/private-artifacts.js.map +1 -0
- package/dist/connectors/provider-response.d.ts +20 -0
- package/dist/connectors/provider-response.d.ts.map +1 -0
- package/dist/connectors/provider-response.js +98 -0
- package/dist/connectors/provider-response.js.map +1 -0
- package/dist/connectors/recommendations.d.ts +25 -0
- package/dist/connectors/recommendations.d.ts.map +1 -0
- package/dist/connectors/recommendations.js +172 -0
- package/dist/connectors/recommendations.js.map +1 -0
- package/dist/connectors/registry.d.ts +10 -0
- package/dist/connectors/registry.d.ts.map +1 -0
- package/dist/connectors/registry.js +34 -0
- package/dist/connectors/registry.js.map +1 -0
- package/dist/connectors/rendered-page.d.ts +101 -0
- package/dist/connectors/rendered-page.d.ts.map +1 -0
- package/dist/connectors/rendered-page.js +504 -0
- package/dist/connectors/rendered-page.js.map +1 -0
- package/dist/connectors/smart-defaults.d.ts +9 -0
- package/dist/connectors/smart-defaults.d.ts.map +1 -0
- package/dist/connectors/smart-defaults.js +72 -0
- package/dist/connectors/smart-defaults.js.map +1 -0
- package/dist/connectors/types.d.ts +79 -0
- package/dist/connectors/types.d.ts.map +1 -0
- package/dist/connectors/types.js +2 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/connectors/upload.d.ts +9 -0
- package/dist/connectors/upload.d.ts.map +1 -0
- package/dist/connectors/upload.js +440 -0
- package/dist/connectors/upload.js.map +1 -0
- package/dist/connectors/website.d.ts +20 -0
- package/dist/connectors/website.d.ts.map +1 -0
- package/dist/connectors/website.js +616 -0
- package/dist/connectors/website.js.map +1 -0
- package/dist/embeddings/index.d.ts +3 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +3 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/providers.d.ts +7 -0
- package/dist/embeddings/providers.d.ts.map +1 -0
- package/dist/embeddings/providers.js +176 -0
- package/dist/embeddings/providers.js.map +1 -0
- package/dist/embeddings/types.d.ts +19 -0
- package/dist/embeddings/types.d.ts.map +1 -0
- package/dist/embeddings/types.js +2 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/eval/acceptance-fixtures.d.ts +3 -0
- package/dist/eval/acceptance-fixtures.d.ts.map +1 -0
- package/dist/eval/acceptance-fixtures.js +84 -0
- package/dist/eval/acceptance-fixtures.js.map +1 -0
- package/dist/eval/acceptance.d.ts +114 -0
- package/dist/eval/acceptance.d.ts.map +1 -0
- package/dist/eval/acceptance.js +260 -0
- package/dist/eval/acceptance.js.map +1 -0
- package/dist/eval/fixtures.d.ts +16 -0
- package/dist/eval/fixtures.d.ts.map +1 -0
- package/dist/eval/fixtures.js +119 -0
- package/dist/eval/fixtures.js.map +1 -0
- package/dist/eval/index.d.ts +63 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +174 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/background-worker.d.ts +31 -0
- package/dist/jobs/background-worker.d.ts.map +1 -0
- package/dist/jobs/background-worker.js +315 -0
- package/dist/jobs/background-worker.js.map +1 -0
- package/dist/jobs/import-runner.d.ts +3 -0
- package/dist/jobs/import-runner.d.ts.map +1 -0
- package/dist/jobs/import-runner.js +613 -0
- package/dist/jobs/import-runner.js.map +1 -0
- package/dist/jobs/index.d.ts +9 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +8 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/progress.d.ts +3 -0
- package/dist/jobs/progress.d.ts.map +1 -0
- package/dist/jobs/progress.js +30 -0
- package/dist/jobs/progress.js.map +1 -0
- package/dist/jobs/rebuild.d.ts +13 -0
- package/dist/jobs/rebuild.d.ts.map +1 -0
- package/dist/jobs/rebuild.js +178 -0
- package/dist/jobs/rebuild.js.map +1 -0
- package/dist/jobs/server-worker.d.ts +16 -0
- package/dist/jobs/server-worker.d.ts.map +1 -0
- package/dist/jobs/server-worker.js +252 -0
- package/dist/jobs/server-worker.js.map +1 -0
- package/dist/jobs/store-adapter.d.ts +3 -0
- package/dist/jobs/store-adapter.d.ts.map +1 -0
- package/dist/jobs/store-adapter.js +37 -0
- package/dist/jobs/store-adapter.js.map +1 -0
- package/dist/jobs/types.d.ts +138 -0
- package/dist/jobs/types.d.ts.map +1 -0
- package/dist/jobs/types.js +2 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/jobs/worker.d.ts +27 -0
- package/dist/jobs/worker.d.ts.map +1 -0
- package/dist/jobs/worker.js +90 -0
- package/dist/jobs/worker.js.map +1 -0
- package/dist/media-url.d.ts +7 -0
- package/dist/media-url.d.ts.map +1 -0
- package/dist/media-url.js +15 -0
- package/dist/media-url.js.map +1 -0
- package/dist/native-artifact-reassembly.d.ts +25 -0
- package/dist/native-artifact-reassembly.d.ts.map +1 -0
- package/dist/native-artifact-reassembly.js +262 -0
- package/dist/native-artifact-reassembly.js.map +1 -0
- package/dist/native-artifact.d.ts +88 -0
- package/dist/native-artifact.d.ts.map +1 -0
- package/dist/native-artifact.js +86 -0
- package/dist/native-artifact.js.map +1 -0
- package/dist/schema/index.d.ts +5519 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +374 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/migrations.d.ts +10 -0
- package/dist/schema/migrations.d.ts.map +1 -0
- package/dist/schema/migrations.js +253 -0
- package/dist/schema/migrations.js.map +1 -0
- package/dist/search/fusion.d.ts +15 -0
- package/dist/search/fusion.d.ts.map +1 -0
- package/dist/search/fusion.js +25 -0
- package/dist/search/fusion.js.map +1 -0
- package/dist/search/mode.d.ts +4 -0
- package/dist/search/mode.d.ts.map +1 -0
- package/dist/search/mode.js +13 -0
- package/dist/search/mode.js.map +1 -0
- package/dist/search/postgres-fts.d.ts +22 -0
- package/dist/search/postgres-fts.d.ts.map +1 -0
- package/dist/search/postgres-fts.js +83 -0
- package/dist/search/postgres-fts.js.map +1 -0
- package/dist/server/brand-context.d.ts +15 -0
- package/dist/server/brand-context.d.ts.map +1 -0
- package/dist/server/brand-context.js +149 -0
- package/dist/server/brand-context.js.map +1 -0
- package/dist/server/context.d.ts +77 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +63 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/enrichment.d.ts +23 -0
- package/dist/server/enrichment.d.ts.map +1 -0
- package/dist/server/enrichment.js +136 -0
- package/dist/server/enrichment.js.map +1 -0
- package/dist/server/generation-artifact-access.d.ts +21 -0
- package/dist/server/generation-artifact-access.d.ts.map +1 -0
- package/dist/server/generation-artifact-access.js +111 -0
- package/dist/server/generation-artifact-access.js.map +1 -0
- package/dist/server/generation-context.d.ts +204 -0
- package/dist/server/generation-context.d.ts.map +1 -0
- package/dist/server/generation-context.js +310 -0
- package/dist/server/generation-context.js.map +1 -0
- package/dist/server/index.d.ts +22 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +96 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/isolated-a2a.d.ts +172 -0
- package/dist/server/isolated-a2a.d.ts.map +1 -0
- package/dist/server/isolated-a2a.js +310 -0
- package/dist/server/isolated-a2a.js.map +1 -0
- package/dist/server/media.d.ts +15 -0
- package/dist/server/media.d.ts.map +1 -0
- package/dist/server/media.js +93 -0
- package/dist/server/media.js.map +1 -0
- package/dist/server/prompt-provider.d.ts +5 -0
- package/dist/server/prompt-provider.d.ts.map +1 -0
- package/dist/server/prompt-provider.js +59 -0
- package/dist/server/prompt-provider.js.map +1 -0
- package/dist/server/public-serialization.d.ts +160 -0
- package/dist/server/public-serialization.d.ts.map +1 -0
- package/dist/server/public-serialization.js +108 -0
- package/dist/server/public-serialization.js.map +1 -0
- package/dist/server/resource-paths.d.ts +3 -0
- package/dist/server/resource-paths.d.ts.map +1 -0
- package/dist/server/resource-paths.js +5 -0
- package/dist/server/resource-paths.js.map +1 -0
- package/dist/server/retrieval.d.ts +78 -0
- package/dist/server/retrieval.d.ts.map +1 -0
- package/dist/server/retrieval.js +443 -0
- package/dist/server/retrieval.js.map +1 -0
- package/dist/server/untrusted-reference.d.ts +8 -0
- package/dist/server/untrusted-reference.d.ts.map +1 -0
- package/dist/server/untrusted-reference.js +19 -0
- package/dist/server/untrusted-reference.js.map +1 -0
- package/dist/store/brand.d.ts +47 -0
- package/dist/store/brand.d.ts.map +1 -0
- package/dist/store/brand.js +360 -0
- package/dist/store/brand.js.map +1 -0
- package/dist/store/content.d.ts +120 -0
- package/dist/store/content.d.ts.map +1 -0
- package/dist/store/content.js +1437 -0
- package/dist/store/content.js.map +1 -0
- package/dist/store/generation.d.ts +28 -0
- package/dist/store/generation.d.ts.map +1 -0
- package/dist/store/generation.js +140 -0
- package/dist/store/generation.js.map +1 -0
- package/dist/store/helpers.d.ts +12 -0
- package/dist/store/helpers.d.ts.map +1 -0
- package/dist/store/helpers.js +41 -0
- package/dist/store/helpers.js.map +1 -0
- package/dist/store/index.d.ts +10 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +10 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/inference.d.ts +57 -0
- package/dist/store/inference.d.ts.map +1 -0
- package/dist/store/inference.js +279 -0
- package/dist/store/inference.js.map +1 -0
- package/dist/store/jobs.d.ts +80 -0
- package/dist/store/jobs.d.ts.map +1 -0
- package/dist/store/jobs.js +428 -0
- package/dist/store/jobs.js.map +1 -0
- package/dist/store/packs.d.ts +33 -0
- package/dist/store/packs.d.ts.map +1 -0
- package/dist/store/packs.js +321 -0
- package/dist/store/packs.js.map +1 -0
- package/dist/store/purge.d.ts +16 -0
- package/dist/store/purge.d.ts.map +1 -0
- package/dist/store/purge.js +256 -0
- package/dist/store/purge.js.map +1 -0
- package/dist/store/sources.d.ts +76 -0
- package/dist/store/sources.d.ts.map +1 -0
- package/dist/store/sources.js +538 -0
- package/dist/store/sources.js.map +1 -0
- package/dist/store/suggestions.d.ts +28 -0
- package/dist/store/suggestions.d.ts.map +1 -0
- package/dist/store/suggestions.js +250 -0
- package/dist/store/suggestions.js.map +1 -0
- package/dist/types.d.ts +493 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vector/index.d.ts +2 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/index.js +2 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/pgvector.d.ts +28 -0
- package/dist/vector/pgvector.d.ts.map +1 -0
- package/dist/vector/pgvector.js +117 -0
- package/dist/vector/pgvector.js.map +1 -0
- package/docs/evaluation.md +92 -0
- package/docs/llms-full.txt +168 -0
- package/docs/llms.txt +76 -0
- package/docs/skills/creative-context/SKILL.md +74 -0
- package/package.json +91 -0
- package/src/actions/agent-input-schemas.spec.ts +46 -0
- package/src/actions/confirm-canonical-logo.ts +20 -0
- package/src/actions/continue-context-import.ts +12 -0
- package/src/actions/creative-context-a2a.spec.ts +64 -0
- package/src/actions/creative-context-a2a.ts +88 -0
- package/src/actions/get-brand-profile.ts +16 -0
- package/src/actions/get-context-import-status.ts +13 -0
- package/src/actions/get-context-item.ts +1 -0
- package/src/actions/get-context-pack.ts +14 -0
- package/src/actions/get-creative-context.spec.ts +315 -0
- package/src/actions/get-creative-context.ts +148 -0
- package/src/actions/index.ts +65 -0
- package/src/actions/infer-brand-dna.ts +15 -0
- package/src/actions/list-canonical-logo-candidates.ts +121 -0
- package/src/actions/list-context-connections.spec.ts +23 -0
- package/src/actions/list-context-connections.ts +51 -0
- package/src/actions/list-context-packs.ts +17 -0
- package/src/actions/list-context-sources.ts +21 -0
- package/src/actions/list-context-suggestions.ts +30 -0
- package/src/actions/manage-brand-profile.ts +58 -0
- package/src/actions/manage-context-pack.ts +75 -0
- package/src/actions/manage-context-source.ts +154 -0
- package/src/actions/manage-layout-template.ts +51 -0
- package/src/actions/preview-context-import.spec.ts +64 -0
- package/src/actions/preview-context-import.ts +61 -0
- package/src/actions/process-context-purge.ts +25 -0
- package/src/actions/propose-brand-dna.ts +22 -0
- package/src/actions/propose-canonical-logo.ts +19 -0
- package/src/actions/publish-brand-dna.ts +25 -0
- package/src/actions/recommend-context-roots.ts +24 -0
- package/src/actions/record-context-feedback.ts +16 -0
- package/src/actions/review-context-items.ts +69 -0
- package/src/actions/run-embedding-bakeoff.ts +90 -0
- package/src/actions/search-creative-context.ts +47 -0
- package/src/actions/set-brand-dna.ts +22 -0
- package/src/actions/start-context-enrichment.ts +50 -0
- package/src/actions/start-context-import.ts +37 -0
- package/src/client/CreativeContextChip.tsx +162 -0
- package/src/client/CreativeContextPanel.tsx +2442 -0
- package/src/client/CreativeContextSettingsLink.tsx +30 -0
- package/src/client/actions.ts +438 -0
- package/src/client/agent-tab.tsx +58 -0
- package/src/client/application-state.spec.ts +41 -0
- package/src/client/application-state.ts +130 -0
- package/src/client/index.ts +62 -0
- package/src/client/messages.ts +1240 -0
- package/src/client/source-config.spec.ts +152 -0
- package/src/connectors/connectors.spec.ts +778 -0
- package/src/connectors/context.ts +83 -0
- package/src/connectors/document-parser.ts +5 -0
- package/src/connectors/figma-native.ts +1192 -0
- package/src/connectors/figma-native.visual.spec.ts +221 -0
- package/src/connectors/figma.spec.ts +812 -0
- package/src/connectors/figma.ts +257 -0
- package/src/connectors/fixtures/google-slides-native.json +353 -0
- package/src/connectors/google-slides-native.spec.ts +804 -0
- package/src/connectors/google-slides-native.ts +1656 -0
- package/src/connectors/google-slides-native.visual.spec.ts +119 -0
- package/src/connectors/google-slides.ts +1172 -0
- package/src/connectors/index.ts +103 -0
- package/src/connectors/manual.ts +132 -0
- package/src/connectors/normalize.ts +277 -0
- package/src/connectors/notion.ts +529 -0
- package/src/connectors/private-artifacts.spec.ts +95 -0
- package/src/connectors/private-artifacts.ts +248 -0
- package/src/connectors/provider-response.ts +144 -0
- package/src/connectors/recommendations.ts +237 -0
- package/src/connectors/registry.ts +48 -0
- package/src/connectors/rendered-page.ts +705 -0
- package/src/connectors/smart-defaults.spec.ts +135 -0
- package/src/connectors/smart-defaults.ts +87 -0
- package/src/connectors/types.ts +115 -0
- package/src/connectors/upload.spec.ts +175 -0
- package/src/connectors/upload.ts +548 -0
- package/src/connectors/website.spec.ts +509 -0
- package/src/connectors/website.ts +777 -0
- package/src/embeddings/index.ts +2 -0
- package/src/embeddings/providers.spec.ts +73 -0
- package/src/embeddings/providers.ts +228 -0
- package/src/embeddings/types.ts +24 -0
- package/src/eval/acceptance-fixtures.ts +97 -0
- package/src/eval/acceptance.spec.ts +92 -0
- package/src/eval/acceptance.ts +371 -0
- package/src/eval/connectors-golden.spec.ts +421 -0
- package/src/eval/eval.spec.ts +166 -0
- package/src/eval/fixtures/README.md +17 -0
- package/src/eval/fixtures/figma-brand-system-v1.json +140 -0
- package/src/eval/fixtures/figma-brand-system-v2.json +127 -0
- package/src/eval/fixtures/launch-hero.png +0 -0
- package/src/eval/fixtures/launch-system-v1.pptx +0 -0
- package/src/eval/fixtures/launch-system-v2.pptx +0 -0
- package/src/eval/fixtures/notion-brand-root.json +218 -0
- package/src/eval/fixtures/pricing-hero.png +0 -0
- package/src/eval/fixtures/rendered-brand-page.html +76 -0
- package/src/eval/fixtures.spec.ts +43 -0
- package/src/eval/fixtures.ts +136 -0
- package/src/eval/index.ts +291 -0
- package/src/eval/library-flow.acceptance.spec.tsx +141 -0
- package/src/index.ts +4 -0
- package/src/jobs/background-worker.ts +423 -0
- package/src/jobs/import-runner.spec.ts +582 -0
- package/src/jobs/import-runner.ts +792 -0
- package/src/jobs/index.ts +40 -0
- package/src/jobs/progress.ts +37 -0
- package/src/jobs/rebuild.ts +245 -0
- package/src/jobs/server-worker.spec.ts +159 -0
- package/src/jobs/server-worker.ts +344 -0
- package/src/jobs/store-adapter.ts +52 -0
- package/src/jobs/types.ts +147 -0
- package/src/jobs/worker.ts +152 -0
- package/src/manifest.spec.ts +26 -0
- package/src/media-url.ts +17 -0
- package/src/native-artifact-reassembly.spec.ts +386 -0
- package/src/native-artifact-reassembly.ts +406 -0
- package/src/native-artifact.ts +102 -0
- package/src/schema/index.ts +411 -0
- package/src/schema/migrations.spec.ts +41 -0
- package/src/schema/migrations.ts +258 -0
- package/src/search/fusion.spec.ts +21 -0
- package/src/search/fusion.ts +39 -0
- package/src/search/mode.spec.ts +28 -0
- package/src/search/mode.ts +21 -0
- package/src/search/postgres-fts.spec.ts +71 -0
- package/src/search/postgres-fts.ts +112 -0
- package/src/server/brand-context.spec.ts +43 -0
- package/src/server/brand-context.ts +160 -0
- package/src/server/context.ts +162 -0
- package/src/server/enrichment.ts +163 -0
- package/src/server/generation-artifact-access.ts +216 -0
- package/src/server/generation-context-a2a.spec.ts +131 -0
- package/src/server/generation-context-off.spec.ts +213 -0
- package/src/server/generation-context.spec.ts +124 -0
- package/src/server/generation-context.ts +493 -0
- package/src/server/index.ts +135 -0
- package/src/server/isolated-a2a.spec.ts +164 -0
- package/src/server/isolated-a2a.ts +413 -0
- package/src/server/media.spec.ts +92 -0
- package/src/server/media.ts +117 -0
- package/src/server/prompt-provider.spec.ts +78 -0
- package/src/server/prompt-provider.ts +73 -0
- package/src/server/public-serialization.spec.ts +149 -0
- package/src/server/public-serialization.ts +130 -0
- package/src/server/resource-paths.spec.ts +9 -0
- package/src/server/resource-paths.ts +5 -0
- package/src/server/retrieval-vector.spec.ts +180 -0
- package/src/server/retrieval.ts +587 -0
- package/src/server/untrusted-reference.spec.ts +22 -0
- package/src/server/untrusted-reference.ts +24 -0
- package/src/store/access.integration.spec.ts +1922 -0
- package/src/store/brand.ts +477 -0
- package/src/store/content.ts +1900 -0
- package/src/store/generation.ts +226 -0
- package/src/store/helpers.ts +53 -0
- package/src/store/index.ts +9 -0
- package/src/store/inference.spec.ts +84 -0
- package/src/store/inference.ts +339 -0
- package/src/store/invariants.spec.ts +119 -0
- package/src/store/jobs.ts +672 -0
- package/src/store/packs.ts +466 -0
- package/src/store/purge.ts +321 -0
- package/src/store/sources.spec.ts +102 -0
- package/src/store/sources.ts +708 -0
- package/src/store/suggestions.ts +333 -0
- package/src/types.ts +571 -0
- package/src/vector/index.ts +1 -0
- package/src/vector/pgvector.spec.ts +98 -0
- package/src/vector/pgvector.ts +164 -0
|
@@ -0,0 +1,883 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { collectFallbackNodeIds, collectImageFillRefs, extractFigmaTopLevelFrames, mapFigmaNodeToHtml, } from "@agent-native/core/ingestion";
|
|
3
|
+
import { creativeContextMediaUrl } from "../media-url.js";
|
|
4
|
+
import { parseNativeCreativeArtifact, } from "../native-artifact.js";
|
|
5
|
+
import { normalizeContextItem } from "./normalize.js";
|
|
6
|
+
import { rehostRemoteMedia } from "./private-artifacts.js";
|
|
7
|
+
import { asRecord, executeConnectorProviderRequest, stringValue, } from "./provider-response.js";
|
|
8
|
+
export const MAX_INLINE_NATIVE_CODE_BYTES = 128 * 1024;
|
|
9
|
+
const MAX_ARTBOARD_DIMENSION = 12_000;
|
|
10
|
+
const MAX_ARTBOARD_AREA = 24_000_000;
|
|
11
|
+
const MAX_DIRECT_CHILDREN = 200;
|
|
12
|
+
const MAX_HIERARCHY_DEPTH = 12;
|
|
13
|
+
const MAX_SEARCH_TEXT_CHARS = 40_000;
|
|
14
|
+
const MAX_MANIFEST_CHILDREN_PER_BUCKET = 64;
|
|
15
|
+
export async function fetchFigmaNativeContextItems(input) {
|
|
16
|
+
const file = await fetchFigmaFileInfo(input);
|
|
17
|
+
const compileContext = {
|
|
18
|
+
fileKey: input.fileKey,
|
|
19
|
+
fileName: file.name,
|
|
20
|
+
sourceUrl: input.sourceUrl,
|
|
21
|
+
sourceVersion: file.version,
|
|
22
|
+
sourceModifiedAt: file.lastModified ?? input.sourceModifiedAt,
|
|
23
|
+
connectionId: input.connectionId,
|
|
24
|
+
context: input.context,
|
|
25
|
+
assets: new FigmaAssetRegistry({
|
|
26
|
+
fileKey: input.fileKey,
|
|
27
|
+
sourceUrl: input.sourceUrl,
|
|
28
|
+
sourceVersion: file.version ?? file.lastModified ?? "current",
|
|
29
|
+
connectionId: input.connectionId,
|
|
30
|
+
context: input.context,
|
|
31
|
+
}),
|
|
32
|
+
artifacts: new Map(),
|
|
33
|
+
warnings: [...file.warnings],
|
|
34
|
+
};
|
|
35
|
+
const topLevel = extractFigmaTopLevelFrames(file.document);
|
|
36
|
+
const inventory = new Map();
|
|
37
|
+
for (const node of topLevel) {
|
|
38
|
+
const id = stringValue(node.id);
|
|
39
|
+
if (!id)
|
|
40
|
+
continue;
|
|
41
|
+
inventory.set(id, {
|
|
42
|
+
id,
|
|
43
|
+
name: stringValue(node.name) ?? `Node ${id}`,
|
|
44
|
+
type: stringValue(node.type) ?? "FRAME",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
for (const [id, value] of Object.entries(file.components)) {
|
|
48
|
+
const component = asRecord(value);
|
|
49
|
+
inventory.set(id, {
|
|
50
|
+
id,
|
|
51
|
+
name: stringValue(component?.name) ?? `Component ${id}`,
|
|
52
|
+
type: "COMPONENT",
|
|
53
|
+
optional: true,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
for (const entry of inventory.values()) {
|
|
57
|
+
if (compileContext.artifacts.has(externalId(input.fileKey, entry.id))) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
await compileNodeHierarchy(entry.id, compileContext, 0);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (!entry.optional)
|
|
65
|
+
throw error;
|
|
66
|
+
compileContext.warnings.push(`Figma component ${entry.name} could not be hydrated: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
|
+
inventory.delete(entry.id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const artifacts = [...compileContext.artifacts.values()];
|
|
71
|
+
const fileText = [
|
|
72
|
+
`${file.name} Figma inventory`,
|
|
73
|
+
...[...inventory.values()].map((entry) => `${entry.type}: ${entry.name}`),
|
|
74
|
+
].join("\n");
|
|
75
|
+
const parent = normalizeContextItem({
|
|
76
|
+
externalId: input.fileKey,
|
|
77
|
+
kind: "figma-file",
|
|
78
|
+
title: file.name,
|
|
79
|
+
canonicalUrl: input.sourceUrl,
|
|
80
|
+
mimeType: "application/vnd.figma.file",
|
|
81
|
+
content: fileText,
|
|
82
|
+
sourceModifiedAt: compileContext.sourceModifiedAt,
|
|
83
|
+
sourceVersion: compileContext.sourceVersion,
|
|
84
|
+
parseStatus: "parsed",
|
|
85
|
+
provenance: { provider: "figma", fileKey: input.fileKey },
|
|
86
|
+
metadata: {
|
|
87
|
+
provider: "figma",
|
|
88
|
+
version: file.version,
|
|
89
|
+
editorType: file.editorType,
|
|
90
|
+
role: file.role,
|
|
91
|
+
inventoryDepth: 2,
|
|
92
|
+
artifactCount: artifacts.length,
|
|
93
|
+
childExternalIds: artifacts
|
|
94
|
+
.filter((artifact) => inventory.has(artifact.nodeId))
|
|
95
|
+
.map((artifact) => artifact.externalId),
|
|
96
|
+
},
|
|
97
|
+
chunks: [{ ordinal: 0, kind: "text", text: fileText }],
|
|
98
|
+
edges: artifacts
|
|
99
|
+
.filter((artifact) => inventory.has(artifact.nodeId))
|
|
100
|
+
.map((artifact) => ({
|
|
101
|
+
relation: "contains-native-artifact",
|
|
102
|
+
toExternalId: artifact.externalId,
|
|
103
|
+
})),
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
items: [parent, ...artifacts.map((artifact) => artifact.item)],
|
|
107
|
+
warnings: compileContext.warnings,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async function fetchFigmaFileInfo(input) {
|
|
111
|
+
const requestFile = async (depth) => asRecord(await executeConnectorProviderRequest(input.context.providerApi, {
|
|
112
|
+
provider: "figma",
|
|
113
|
+
method: "GET",
|
|
114
|
+
path: `/files/${encodeURIComponent(input.fileKey)}`,
|
|
115
|
+
query: { depth },
|
|
116
|
+
connectionId: input.connectionId,
|
|
117
|
+
maxBytes: 4 * 1024 * 1024,
|
|
118
|
+
}));
|
|
119
|
+
let value;
|
|
120
|
+
const warnings = [];
|
|
121
|
+
try {
|
|
122
|
+
value = await requestFile(2);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (!isProviderSizeFailure(error))
|
|
126
|
+
throw error;
|
|
127
|
+
value = await requestFile(1);
|
|
128
|
+
const document = asRecord(value?.document);
|
|
129
|
+
const pages = Array.isArray(document?.children) ? document.children : [];
|
|
130
|
+
const hydratedPages = [];
|
|
131
|
+
for (const pageValue of pages) {
|
|
132
|
+
const page = asRecord(pageValue);
|
|
133
|
+
const pageId = stringValue(page?.id);
|
|
134
|
+
if (!pageId)
|
|
135
|
+
continue;
|
|
136
|
+
const payload = asRecord(await executeConnectorProviderRequest(input.context.providerApi, {
|
|
137
|
+
provider: "figma",
|
|
138
|
+
method: "GET",
|
|
139
|
+
path: `/files/${encodeURIComponent(input.fileKey)}/nodes`,
|
|
140
|
+
query: { ids: pageId, depth: 1 },
|
|
141
|
+
connectionId: input.connectionId,
|
|
142
|
+
maxBytes: 4 * 1024 * 1024,
|
|
143
|
+
}));
|
|
144
|
+
const hydrated = asRecord(asRecord(asRecord(payload?.nodes)?.[pageId])?.document);
|
|
145
|
+
if (hydrated)
|
|
146
|
+
hydratedPages.push(hydrated);
|
|
147
|
+
}
|
|
148
|
+
value = {
|
|
149
|
+
...value,
|
|
150
|
+
document: { ...document, children: hydratedPages },
|
|
151
|
+
components: {},
|
|
152
|
+
};
|
|
153
|
+
warnings.push("Figma file inventory exceeded the bounded depth-2 response, so pages were inventoried independently at depth 1.");
|
|
154
|
+
}
|
|
155
|
+
if (!value || !asRecord(value.document)) {
|
|
156
|
+
throw new Error(`Figma file ${input.fileKey} returned no document.`);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
name: stringValue(value.name) ?? input.sourceTitle,
|
|
160
|
+
version: stringValue(value.version),
|
|
161
|
+
lastModified: stringValue(value.lastModified) ?? input.sourceModifiedAt,
|
|
162
|
+
editorType: stringValue(value.editorType),
|
|
163
|
+
role: stringValue(value.role),
|
|
164
|
+
document: asRecord(value.document),
|
|
165
|
+
components: asRecord(value.components) ?? {},
|
|
166
|
+
warnings,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
async function compileNodeHierarchy(nodeId, input, depth) {
|
|
170
|
+
const id = externalId(input.fileKey, nodeId);
|
|
171
|
+
const existing = input.artifacts.get(id);
|
|
172
|
+
if (existing)
|
|
173
|
+
return existing;
|
|
174
|
+
const shallow = await fetchFigmaNode(nodeId, input, 2);
|
|
175
|
+
if (depth < MAX_HIERARCHY_DEPTH && shouldSplitBeforeFullFetch(shallow)) {
|
|
176
|
+
const split = await compileSplitNode(shallow, input, depth);
|
|
177
|
+
if (split)
|
|
178
|
+
return split;
|
|
179
|
+
}
|
|
180
|
+
let full;
|
|
181
|
+
try {
|
|
182
|
+
full = await fetchFigmaNode(nodeId, input);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
if (depth < MAX_HIERARCHY_DEPTH &&
|
|
186
|
+
isProviderSizeFailure(error) &&
|
|
187
|
+
canSplitAtChildren(shallow)) {
|
|
188
|
+
const split = await compileSplitNode(shallow, input, depth);
|
|
189
|
+
if (split)
|
|
190
|
+
return split;
|
|
191
|
+
}
|
|
192
|
+
if (isProviderSizeFailure(error)) {
|
|
193
|
+
input.warnings.push(`Figma node ${shallow.name ?? nodeId} was indivisible and exceeded the provider response bound; a localized rendered fallback was stored.`);
|
|
194
|
+
return compileRenderedFallback(shallow, input);
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
const estimated = compileWithPlaceholderAssets(full);
|
|
199
|
+
if (Buffer.byteLength(estimated.html, "utf8") > MAX_INLINE_NATIVE_CODE_BYTES) {
|
|
200
|
+
if (depth < MAX_HIERARCHY_DEPTH && canSplitAtChildren(full)) {
|
|
201
|
+
const split = await compileSplitNode(full, input, depth);
|
|
202
|
+
if (split)
|
|
203
|
+
return split;
|
|
204
|
+
}
|
|
205
|
+
input.warnings.push(`Figma node ${full.name ?? nodeId} produced more than 128 KiB of indivisible native code; a localized rendered fallback was stored.`);
|
|
206
|
+
return compileRenderedFallback(full, input);
|
|
207
|
+
}
|
|
208
|
+
return compileOrdinaryNode(full, input);
|
|
209
|
+
}
|
|
210
|
+
async function fetchFigmaNode(nodeId, input, depth) {
|
|
211
|
+
const payload = asRecord(await executeConnectorProviderRequest(input.context.providerApi, {
|
|
212
|
+
provider: "figma",
|
|
213
|
+
method: "GET",
|
|
214
|
+
path: `/files/${encodeURIComponent(input.fileKey)}/nodes`,
|
|
215
|
+
query: { ids: nodeId, ...(depth ? { depth } : {}) },
|
|
216
|
+
connectionId: input.connectionId,
|
|
217
|
+
maxBytes: 4 * 1024 * 1024,
|
|
218
|
+
}));
|
|
219
|
+
const entry = asRecord(asRecord(payload?.nodes)?.[nodeId]);
|
|
220
|
+
const document = asRecord(entry?.document);
|
|
221
|
+
if (!document) {
|
|
222
|
+
throw new Error(`Figma node ${nodeId} returned no document.`);
|
|
223
|
+
}
|
|
224
|
+
return document;
|
|
225
|
+
}
|
|
226
|
+
async function compileOrdinaryNode(node, input) {
|
|
227
|
+
const artifactId = externalId(input.fileKey, node.id);
|
|
228
|
+
const assets = await input.assets.forNode(node, artifactId);
|
|
229
|
+
const mapped = mapFigmaNodeToHtml(node, {
|
|
230
|
+
fallbackImageUrls: assets.fallbackImageUrls,
|
|
231
|
+
imageFillUrls: assets.imageFillUrls,
|
|
232
|
+
});
|
|
233
|
+
const html = wrapFigmaDocument(mapped.html || "<div></div>", node);
|
|
234
|
+
if (Buffer.byteLength(html, "utf8") > MAX_INLINE_NATIVE_CODE_BYTES) {
|
|
235
|
+
return compileRenderedFallback(node, input);
|
|
236
|
+
}
|
|
237
|
+
const fidelityReport = nativeFidelityReportFromEntries(mapped.fidelity.entries);
|
|
238
|
+
const nativeArtifact = parseNativeCreativeArtifact({
|
|
239
|
+
schemaVersion: 1,
|
|
240
|
+
app: "design",
|
|
241
|
+
format: "design-html",
|
|
242
|
+
rootExternalId: artifactId,
|
|
243
|
+
sourceBounds: normalizedBounds(node.absoluteBoundingBox),
|
|
244
|
+
fidelityReport,
|
|
245
|
+
...(assets.assetRefs.length ? { assetRefs: assets.assetRefs } : {}),
|
|
246
|
+
});
|
|
247
|
+
const item = nativeItem({
|
|
248
|
+
input,
|
|
249
|
+
node,
|
|
250
|
+
externalId: artifactId,
|
|
251
|
+
html,
|
|
252
|
+
nativeArtifact,
|
|
253
|
+
media: assets.media,
|
|
254
|
+
edges: figmaUsageEdges(node, input.fileKey),
|
|
255
|
+
});
|
|
256
|
+
const artifact = {
|
|
257
|
+
externalId: artifactId,
|
|
258
|
+
nodeId: node.id,
|
|
259
|
+
nodeName: node.name ?? node.id,
|
|
260
|
+
item,
|
|
261
|
+
nativeArtifact,
|
|
262
|
+
};
|
|
263
|
+
input.artifacts.set(artifactId, artifact);
|
|
264
|
+
return artifact;
|
|
265
|
+
}
|
|
266
|
+
async function compileRenderedFallback(node, input) {
|
|
267
|
+
const artifactId = externalId(input.fileKey, node.id);
|
|
268
|
+
const assets = await input.assets.forRenderedFallback(node, artifactId);
|
|
269
|
+
const mapped = mapFigmaNodeToHtml(node, {
|
|
270
|
+
fallbackImageUrls: assets.fallbackImageUrls,
|
|
271
|
+
forceImageFallbackNodeIds: new Set([node.id]),
|
|
272
|
+
});
|
|
273
|
+
const html = wrapFigmaDocument(mapped.html || "<div></div>", node);
|
|
274
|
+
const fidelityReport = nativeFidelityReportFromEntries(mapped.fidelity.entries);
|
|
275
|
+
const nativeArtifact = parseNativeCreativeArtifact({
|
|
276
|
+
schemaVersion: 1,
|
|
277
|
+
app: "design",
|
|
278
|
+
format: "design-html",
|
|
279
|
+
rootExternalId: artifactId,
|
|
280
|
+
sourceBounds: normalizedBounds(node.absoluteBoundingBox),
|
|
281
|
+
fidelityReport,
|
|
282
|
+
assetRefs: assets.assetRefs,
|
|
283
|
+
});
|
|
284
|
+
const item = nativeItem({
|
|
285
|
+
input,
|
|
286
|
+
node,
|
|
287
|
+
externalId: artifactId,
|
|
288
|
+
html,
|
|
289
|
+
nativeArtifact,
|
|
290
|
+
media: assets.media,
|
|
291
|
+
edges: figmaUsageEdges(node, input.fileKey),
|
|
292
|
+
});
|
|
293
|
+
const artifact = {
|
|
294
|
+
externalId: artifactId,
|
|
295
|
+
nodeId: node.id,
|
|
296
|
+
nodeName: node.name ?? node.id,
|
|
297
|
+
item,
|
|
298
|
+
nativeArtifact,
|
|
299
|
+
};
|
|
300
|
+
input.artifacts.set(artifactId, artifact);
|
|
301
|
+
return artifact;
|
|
302
|
+
}
|
|
303
|
+
async function compileSplitNode(node, input, depth) {
|
|
304
|
+
if (!canSplitAtChildren(node))
|
|
305
|
+
return null;
|
|
306
|
+
const children = (node.children ?? []).filter((child) => child.visible !== false);
|
|
307
|
+
const artifactId = externalId(input.fileKey, node.id);
|
|
308
|
+
const bounds = normalizedBounds(node.absoluteBoundingBox) ?? {
|
|
309
|
+
x: 0,
|
|
310
|
+
y: 0,
|
|
311
|
+
width: 1,
|
|
312
|
+
height: 1,
|
|
313
|
+
};
|
|
314
|
+
let manifestChildren = children.map((child, index) => ({
|
|
315
|
+
externalId: externalId(input.fileKey, child.id),
|
|
316
|
+
sourceNodeId: child.id,
|
|
317
|
+
bounds: relativeBounds(child.absoluteBoundingBox, bounds),
|
|
318
|
+
...(flattenTransform(child.relativeTransform)
|
|
319
|
+
? { transform: flattenTransform(child.relativeTransform) }
|
|
320
|
+
: {}),
|
|
321
|
+
zOrder: index,
|
|
322
|
+
}));
|
|
323
|
+
const placeholders = manifestChildren
|
|
324
|
+
.map((child) => `<div data-creative-context-child="${escapeAttribute(child.externalId)}" style="position:absolute;left:${round(child.bounds.x)}px;top:${round(child.bounds.y)}px;width:${round(child.bounds.width)}px;height:${round(child.bounds.height)}px;z-index:${child.zOrder}"></div>`)
|
|
325
|
+
.join("\n");
|
|
326
|
+
const minimumShell = wrapFigmaDocument(`<div>${placeholders}</div>`, node);
|
|
327
|
+
let compiledChildren = [];
|
|
328
|
+
for (const child of children) {
|
|
329
|
+
compiledChildren.push(await compileNodeHierarchy(child.id, input, depth + 1));
|
|
330
|
+
}
|
|
331
|
+
let boundedPlaceholders = placeholders;
|
|
332
|
+
if (Buffer.byteLength(minimumShell, "utf8") > MAX_INLINE_NATIVE_CODE_BYTES) {
|
|
333
|
+
const bucketed = compileManifestBuckets({
|
|
334
|
+
node,
|
|
335
|
+
input,
|
|
336
|
+
parentBounds: bounds,
|
|
337
|
+
manifestChildren,
|
|
338
|
+
compiledChildren,
|
|
339
|
+
});
|
|
340
|
+
manifestChildren = bucketed.manifestChildren;
|
|
341
|
+
compiledChildren = bucketed.compiledChildren;
|
|
342
|
+
boundedPlaceholders = manifestPlaceholders(manifestChildren);
|
|
343
|
+
}
|
|
344
|
+
const shellNode = { ...node, children: [] };
|
|
345
|
+
const shellAssets = await input.assets.forNode(shellNode, artifactId);
|
|
346
|
+
const shell = mapFigmaNodeToHtml(shellNode, {
|
|
347
|
+
fallbackImageUrls: shellAssets.fallbackImageUrls,
|
|
348
|
+
imageFillUrls: shellAssets.imageFillUrls,
|
|
349
|
+
});
|
|
350
|
+
const shellWithChildren = insertBeforeLastClosingDiv(shell.html || "<div></div>", boundedPlaceholders);
|
|
351
|
+
const html = wrapFigmaDocument(shellWithChildren, node);
|
|
352
|
+
if (Buffer.byteLength(html, "utf8") > MAX_INLINE_NATIVE_CODE_BYTES) {
|
|
353
|
+
input.warnings.push(`Figma node ${node.name ?? node.id} produced a hierarchical shell larger than 128 KiB; a localized rendered fallback was stored.`);
|
|
354
|
+
return compileRenderedFallback(node, input);
|
|
355
|
+
}
|
|
356
|
+
const fidelityReport = aggregateFidelity([
|
|
357
|
+
nativeFidelityReportFromEntries(shell.fidelity.entries),
|
|
358
|
+
...compiledChildren.map((child) => child.nativeArtifact.fidelityReport),
|
|
359
|
+
]);
|
|
360
|
+
const nativeArtifact = parseNativeCreativeArtifact({
|
|
361
|
+
schemaVersion: 1,
|
|
362
|
+
app: "design",
|
|
363
|
+
format: "design-html",
|
|
364
|
+
rootExternalId: artifactId,
|
|
365
|
+
sourceBounds: bounds,
|
|
366
|
+
childExternalIds: manifestChildren.map((child) => child.externalId),
|
|
367
|
+
manifest: { kind: "hierarchical-artboard", children: manifestChildren },
|
|
368
|
+
fidelityReport,
|
|
369
|
+
...(shellAssets.assetRefs.length
|
|
370
|
+
? { assetRefs: shellAssets.assetRefs }
|
|
371
|
+
: {}),
|
|
372
|
+
});
|
|
373
|
+
const item = nativeItem({
|
|
374
|
+
input,
|
|
375
|
+
node,
|
|
376
|
+
externalId: artifactId,
|
|
377
|
+
html,
|
|
378
|
+
nativeArtifact,
|
|
379
|
+
media: shellAssets.media,
|
|
380
|
+
edges: [
|
|
381
|
+
...figmaUsageEdges(node, input.fileKey),
|
|
382
|
+
...manifestChildren.map((child) => ({
|
|
383
|
+
relation: "contains-native-child",
|
|
384
|
+
toExternalId: child.externalId,
|
|
385
|
+
metadata: {
|
|
386
|
+
bounds: child.bounds,
|
|
387
|
+
transform: child.transform,
|
|
388
|
+
zOrder: child.zOrder,
|
|
389
|
+
},
|
|
390
|
+
})),
|
|
391
|
+
],
|
|
392
|
+
});
|
|
393
|
+
const artifact = {
|
|
394
|
+
externalId: artifactId,
|
|
395
|
+
nodeId: node.id,
|
|
396
|
+
nodeName: node.name ?? node.id,
|
|
397
|
+
item,
|
|
398
|
+
nativeArtifact,
|
|
399
|
+
};
|
|
400
|
+
input.artifacts.set(artifactId, artifact);
|
|
401
|
+
return artifact;
|
|
402
|
+
}
|
|
403
|
+
function compileManifestBuckets(input) {
|
|
404
|
+
const parentExternalId = externalId(input.input.fileKey, input.node.id);
|
|
405
|
+
const parentChildren = [];
|
|
406
|
+
const bucketArtifacts = [];
|
|
407
|
+
for (let offset = 0; offset < input.manifestChildren.length; offset += MAX_MANIFEST_CHILDREN_PER_BUCKET) {
|
|
408
|
+
const entries = input.manifestChildren.slice(offset, offset + MAX_MANIFEST_CHILDREN_PER_BUCKET);
|
|
409
|
+
const childArtifacts = input.compiledChildren.slice(offset, offset + MAX_MANIFEST_CHILDREN_PER_BUCKET);
|
|
410
|
+
const bucketIndex = Math.floor(offset / MAX_MANIFEST_CHILDREN_PER_BUCKET);
|
|
411
|
+
const bucketExternalId = `${parentExternalId}:manifest-bucket:${bucketIndex}`;
|
|
412
|
+
const bucketSourceNodeId = `${input.node.id}:manifest-bucket:${bucketIndex}`;
|
|
413
|
+
const bucketBounds = unionManifestBounds(entries);
|
|
414
|
+
const bucketChildren = entries.map((entry) => ({
|
|
415
|
+
...entry,
|
|
416
|
+
bounds: {
|
|
417
|
+
x: round(entry.bounds.x - bucketBounds.x),
|
|
418
|
+
y: round(entry.bounds.y - bucketBounds.y),
|
|
419
|
+
width: entry.bounds.width,
|
|
420
|
+
height: entry.bounds.height,
|
|
421
|
+
},
|
|
422
|
+
}));
|
|
423
|
+
const bucketHtml = wrapFigmaDocument(`<div style="position:relative;width:${round(bucketBounds.width)}px;height:${round(bucketBounds.height)}px">${manifestPlaceholders(bucketChildren)}</div>`, input.node);
|
|
424
|
+
if (Buffer.byteLength(bucketHtml, "utf8") > MAX_INLINE_NATIVE_CODE_BYTES) {
|
|
425
|
+
throw new Error(`Figma manifest bucket ${bucketExternalId} exceeded 128 KiB.`);
|
|
426
|
+
}
|
|
427
|
+
const nativeArtifact = parseNativeCreativeArtifact({
|
|
428
|
+
schemaVersion: 1,
|
|
429
|
+
app: "design",
|
|
430
|
+
format: "design-html",
|
|
431
|
+
rootExternalId: bucketExternalId,
|
|
432
|
+
sourceBounds: {
|
|
433
|
+
x: 0,
|
|
434
|
+
y: 0,
|
|
435
|
+
width: bucketBounds.width,
|
|
436
|
+
height: bucketBounds.height,
|
|
437
|
+
},
|
|
438
|
+
childExternalIds: bucketChildren.map((child) => child.externalId),
|
|
439
|
+
manifest: { kind: "hierarchical-artboard", children: bucketChildren },
|
|
440
|
+
fidelityReport: aggregateFidelity(childArtifacts.map((child) => child.nativeArtifact.fidelityReport)),
|
|
441
|
+
});
|
|
442
|
+
const bucketNode = {
|
|
443
|
+
id: bucketSourceNodeId,
|
|
444
|
+
name: `${input.node.name ?? input.node.id} segment ${bucketIndex + 1}`,
|
|
445
|
+
type: "SECTION",
|
|
446
|
+
absoluteBoundingBox: {
|
|
447
|
+
x: 0,
|
|
448
|
+
y: 0,
|
|
449
|
+
width: bucketBounds.width,
|
|
450
|
+
height: bucketBounds.height,
|
|
451
|
+
},
|
|
452
|
+
children: [],
|
|
453
|
+
};
|
|
454
|
+
const artifact = {
|
|
455
|
+
externalId: bucketExternalId,
|
|
456
|
+
nodeId: bucketSourceNodeId,
|
|
457
|
+
nodeName: bucketNode.name,
|
|
458
|
+
nativeArtifact,
|
|
459
|
+
item: nativeItem({
|
|
460
|
+
input: input.input,
|
|
461
|
+
node: bucketNode,
|
|
462
|
+
externalId: bucketExternalId,
|
|
463
|
+
html: bucketHtml,
|
|
464
|
+
nativeArtifact,
|
|
465
|
+
media: [],
|
|
466
|
+
edges: bucketChildren.map((child) => ({
|
|
467
|
+
relation: "contains-native-child",
|
|
468
|
+
toExternalId: child.externalId,
|
|
469
|
+
metadata: {
|
|
470
|
+
bounds: child.bounds,
|
|
471
|
+
transform: child.transform,
|
|
472
|
+
zOrder: child.zOrder,
|
|
473
|
+
},
|
|
474
|
+
})),
|
|
475
|
+
}),
|
|
476
|
+
};
|
|
477
|
+
input.input.artifacts.set(bucketExternalId, artifact);
|
|
478
|
+
bucketArtifacts.push(artifact);
|
|
479
|
+
parentChildren.push({
|
|
480
|
+
externalId: bucketExternalId,
|
|
481
|
+
sourceNodeId: bucketSourceNodeId.slice(0, 256),
|
|
482
|
+
bounds: bucketBounds,
|
|
483
|
+
zOrder: entries[0]?.zOrder ?? bucketIndex,
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
manifestChildren: parentChildren,
|
|
488
|
+
compiledChildren: bucketArtifacts,
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function manifestPlaceholders(children) {
|
|
492
|
+
return children
|
|
493
|
+
.map((child) => `<div data-creative-context-child="${escapeAttribute(child.externalId)}" style="position:absolute;left:${round(child.bounds.x)}px;top:${round(child.bounds.y)}px;width:${round(child.bounds.width)}px;height:${round(child.bounds.height)}px;z-index:${child.zOrder}"></div>`)
|
|
494
|
+
.join("\n");
|
|
495
|
+
}
|
|
496
|
+
function unionManifestBounds(children) {
|
|
497
|
+
const left = Math.min(...children.map((child) => child.bounds.x));
|
|
498
|
+
const top = Math.min(...children.map((child) => child.bounds.y));
|
|
499
|
+
const right = Math.max(...children.map((child) => child.bounds.x + child.bounds.width));
|
|
500
|
+
const bottom = Math.max(...children.map((child) => child.bounds.y + child.bounds.height));
|
|
501
|
+
return {
|
|
502
|
+
x: round(left),
|
|
503
|
+
y: round(top),
|
|
504
|
+
width: Math.max(0, round(right - left)),
|
|
505
|
+
height: Math.max(0, round(bottom - top)),
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function nativeItem(input) {
|
|
509
|
+
const text = extractSearchText(input.node);
|
|
510
|
+
const tokens = extractCodeTokens(input.html);
|
|
511
|
+
return normalizeContextItem({
|
|
512
|
+
externalId: input.externalId,
|
|
513
|
+
kind: input.nativeArtifact.manifest
|
|
514
|
+
? "figma-artboard-manifest"
|
|
515
|
+
: input.node.type === "COMPONENT"
|
|
516
|
+
? "figma-component"
|
|
517
|
+
: "figma-frame",
|
|
518
|
+
title: `${input.input.fileName} — ${input.node.name ?? input.node.id}`,
|
|
519
|
+
canonicalUrl: figmaNodeUrl(input.input.sourceUrl, input.node.id),
|
|
520
|
+
mimeType: "text/html",
|
|
521
|
+
content: input.html,
|
|
522
|
+
preserveContent: true,
|
|
523
|
+
summary: `${input.node.type} compiled to editable Design HTML/CSS${input.nativeArtifact.manifest ? ` in ${input.nativeArtifact.manifest.children.length} bounded child artifacts` : ""}.`,
|
|
524
|
+
sourceModifiedAt: input.input.sourceModifiedAt,
|
|
525
|
+
sourceVersion: input.input.sourceVersion,
|
|
526
|
+
parseStatus: "parsed",
|
|
527
|
+
provenance: {
|
|
528
|
+
provider: "figma",
|
|
529
|
+
fileKey: input.input.fileKey,
|
|
530
|
+
nodeId: input.node.id,
|
|
531
|
+
compiler: "@agent-native/core/ingestion:figma-node-to-html",
|
|
532
|
+
},
|
|
533
|
+
metadata: {
|
|
534
|
+
provider: "figma",
|
|
535
|
+
version: input.input.sourceVersion,
|
|
536
|
+
nodeType: input.node.type,
|
|
537
|
+
nativeArtifact: input.nativeArtifact,
|
|
538
|
+
},
|
|
539
|
+
chunks: [
|
|
540
|
+
...(text
|
|
541
|
+
? [
|
|
542
|
+
{
|
|
543
|
+
ordinal: 0,
|
|
544
|
+
kind: "text",
|
|
545
|
+
text,
|
|
546
|
+
metadata: { role: "source-text" },
|
|
547
|
+
},
|
|
548
|
+
]
|
|
549
|
+
: []),
|
|
550
|
+
{
|
|
551
|
+
ordinal: text ? 1 : 0,
|
|
552
|
+
kind: "code",
|
|
553
|
+
text: tokens,
|
|
554
|
+
metadata: { role: "code-tokens", format: "design-html" },
|
|
555
|
+
},
|
|
556
|
+
],
|
|
557
|
+
media: input.media,
|
|
558
|
+
edges: [
|
|
559
|
+
{ relation: "part-of-figma-file", toExternalId: input.input.fileKey },
|
|
560
|
+
...input.edges,
|
|
561
|
+
],
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
function compileWithPlaceholderAssets(node) {
|
|
565
|
+
return {
|
|
566
|
+
html: wrapFigmaDocument(mapFigmaNodeToHtml(node, {
|
|
567
|
+
fallbackImageUrls: Object.fromEntries(collectFallbackNodeIds(node).map((id) => [
|
|
568
|
+
id,
|
|
569
|
+
`/figma-fallback/${id}`,
|
|
570
|
+
])),
|
|
571
|
+
imageFillUrls: Object.fromEntries(collectImageFillRefs(node).map((ref) => [ref, `/figma-image/${ref}`])),
|
|
572
|
+
}).html, node),
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
class FigmaAssetRegistry {
|
|
576
|
+
input;
|
|
577
|
+
rehosted = new Map();
|
|
578
|
+
imageFillSourceUrls;
|
|
579
|
+
constructor(input) {
|
|
580
|
+
this.input = input;
|
|
581
|
+
}
|
|
582
|
+
async forNode(node, artifactExternalId) {
|
|
583
|
+
const fallbackIds = collectFallbackNodeIds(node);
|
|
584
|
+
const imageRefs = collectImageFillRefs(node);
|
|
585
|
+
return this.resolveAssets({
|
|
586
|
+
artifactExternalId,
|
|
587
|
+
fallbackIds,
|
|
588
|
+
imageRefs,
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
async forRenderedFallback(node, artifactExternalId) {
|
|
592
|
+
return this.resolveAssets({
|
|
593
|
+
artifactExternalId,
|
|
594
|
+
fallbackIds: [node.id],
|
|
595
|
+
imageRefs: [],
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
async resolveAssets(input) {
|
|
599
|
+
const fallbackSourceUrls = await this.renderUrls(input.fallbackIds, "png");
|
|
600
|
+
const imageFillSourceUrls = input.imageRefs.length
|
|
601
|
+
? await this.imageFillUrls()
|
|
602
|
+
: {};
|
|
603
|
+
const fallbackImageUrls = {};
|
|
604
|
+
const imageFillUrls = {};
|
|
605
|
+
const media = [];
|
|
606
|
+
const assetRefs = [];
|
|
607
|
+
for (const nodeId of input.fallbackIds) {
|
|
608
|
+
const url = fallbackSourceUrls[nodeId];
|
|
609
|
+
if (!url)
|
|
610
|
+
throw new Error(`Figma could not render fallback node ${nodeId}.`);
|
|
611
|
+
const entry = await this.rehost(`fallback:${nodeId}`, url, {
|
|
612
|
+
nodeId,
|
|
613
|
+
role: "rendered-fallback",
|
|
614
|
+
});
|
|
615
|
+
const withId = this.forArtifact(entry, input.artifactExternalId, `fallback:${nodeId}`);
|
|
616
|
+
const route = creativeContextMediaUrl({ mediaId: withId.id });
|
|
617
|
+
fallbackImageUrls[nodeId] = route;
|
|
618
|
+
media.push(withId);
|
|
619
|
+
assetRefs.push(route);
|
|
620
|
+
}
|
|
621
|
+
for (const imageRef of input.imageRefs) {
|
|
622
|
+
const url = imageFillSourceUrls[imageRef];
|
|
623
|
+
if (!url)
|
|
624
|
+
throw new Error(`Figma image fill ${imageRef} could not be resolved.`);
|
|
625
|
+
const entry = await this.rehost(`fill:${imageRef}`, url, {
|
|
626
|
+
imageRef,
|
|
627
|
+
role: "image-fill",
|
|
628
|
+
});
|
|
629
|
+
const withId = this.forArtifact(entry, input.artifactExternalId, `fill:${imageRef}`);
|
|
630
|
+
const route = creativeContextMediaUrl({ mediaId: withId.id });
|
|
631
|
+
imageFillUrls[imageRef] = route;
|
|
632
|
+
media.push(withId);
|
|
633
|
+
assetRefs.push(route);
|
|
634
|
+
}
|
|
635
|
+
return { fallbackImageUrls, imageFillUrls, media, assetRefs };
|
|
636
|
+
}
|
|
637
|
+
forArtifact(media, artifactExternalId, assetKey) {
|
|
638
|
+
return {
|
|
639
|
+
...media,
|
|
640
|
+
id: stableMediaId(this.input.fileKey, artifactExternalId, assetKey, media.contentHash ?? this.input.sourceVersion),
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
rehost(key, url, metadata) {
|
|
644
|
+
const existing = this.rehosted.get(key);
|
|
645
|
+
if (existing)
|
|
646
|
+
return existing;
|
|
647
|
+
const promise = rehostRemoteMedia({
|
|
648
|
+
url,
|
|
649
|
+
provenanceUrl: this.input.sourceUrl,
|
|
650
|
+
filename: `${this.input.fileKey}-${safeFilename(key)}`,
|
|
651
|
+
kind: "image",
|
|
652
|
+
context: this.input.context,
|
|
653
|
+
metadata: {
|
|
654
|
+
provider: "figma",
|
|
655
|
+
fileKey: this.input.fileKey,
|
|
656
|
+
...metadata,
|
|
657
|
+
},
|
|
658
|
+
});
|
|
659
|
+
this.rehosted.set(key, promise);
|
|
660
|
+
return promise;
|
|
661
|
+
}
|
|
662
|
+
async imageFillUrls() {
|
|
663
|
+
if (!this.imageFillSourceUrls) {
|
|
664
|
+
this.imageFillSourceUrls = executeConnectorProviderRequest(this.input.context.providerApi, {
|
|
665
|
+
provider: "figma",
|
|
666
|
+
method: "GET",
|
|
667
|
+
path: `/files/${encodeURIComponent(this.input.fileKey)}/images`,
|
|
668
|
+
connectionId: this.input.connectionId,
|
|
669
|
+
maxBytes: 4 * 1024 * 1024,
|
|
670
|
+
}).then((value) => {
|
|
671
|
+
const images = asRecord(asRecord(value)?.images) ?? {};
|
|
672
|
+
return Object.fromEntries(Object.entries(images).filter((entry) => typeof entry[1] === "string"));
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
return this.imageFillSourceUrls;
|
|
676
|
+
}
|
|
677
|
+
async renderUrls(ids, format) {
|
|
678
|
+
if (!ids.length)
|
|
679
|
+
return {};
|
|
680
|
+
const result = {};
|
|
681
|
+
for (let offset = 0; offset < ids.length; offset += 50) {
|
|
682
|
+
const batch = ids.slice(offset, offset + 50);
|
|
683
|
+
const payload = asRecord(await executeConnectorProviderRequest(this.input.context.providerApi, {
|
|
684
|
+
provider: "figma",
|
|
685
|
+
method: "GET",
|
|
686
|
+
path: `/images/${encodeURIComponent(this.input.fileKey)}`,
|
|
687
|
+
query: { ids: batch.join(","), format, scale: 2 },
|
|
688
|
+
connectionId: this.input.connectionId,
|
|
689
|
+
maxBytes: 1024 * 1024,
|
|
690
|
+
}));
|
|
691
|
+
for (const [id, url] of Object.entries(asRecord(payload?.images) ?? {})) {
|
|
692
|
+
if (typeof url === "string" && url)
|
|
693
|
+
result[id] = url;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function shouldSplitBeforeFullFetch(node) {
|
|
700
|
+
const bounds = node.absoluteBoundingBox;
|
|
701
|
+
return Boolean(canSplitAtChildren(node) &&
|
|
702
|
+
((bounds &&
|
|
703
|
+
(bounds.width > MAX_ARTBOARD_DIMENSION ||
|
|
704
|
+
bounds.height > MAX_ARTBOARD_DIMENSION ||
|
|
705
|
+
bounds.width * bounds.height > MAX_ARTBOARD_AREA)) ||
|
|
706
|
+
(node.children?.length ?? 0) > MAX_DIRECT_CHILDREN));
|
|
707
|
+
}
|
|
708
|
+
function canSplitAtChildren(node) {
|
|
709
|
+
if (node.type === "GROUP")
|
|
710
|
+
return false;
|
|
711
|
+
const children = (node.children ?? []).filter((child) => child.visible !== false);
|
|
712
|
+
if (children.length < 2)
|
|
713
|
+
return false;
|
|
714
|
+
if (node.isMask || children.some((child) => child.isMask))
|
|
715
|
+
return false;
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
function isProviderSizeFailure(error) {
|
|
719
|
+
return /4 MB|too large|response bound|exceeded.*limit|maximum response/i.test(error instanceof Error ? error.message : String(error));
|
|
720
|
+
}
|
|
721
|
+
export function nativeFidelityReportFromEntries(entries) {
|
|
722
|
+
const reasons = (level) => entries
|
|
723
|
+
.filter((entry) => entry.level === level)
|
|
724
|
+
.map((entry) => ({
|
|
725
|
+
nodeId: entry.nodeId,
|
|
726
|
+
nodeName: entry.nodeName,
|
|
727
|
+
nodeType: entry.nodeType,
|
|
728
|
+
reasons: entry.notes,
|
|
729
|
+
}))
|
|
730
|
+
.slice(0, 1_000);
|
|
731
|
+
const approximated = reasons("approximated");
|
|
732
|
+
const imageFallback = reasons("image-fallback");
|
|
733
|
+
return {
|
|
734
|
+
exact: { count: entries.filter((entry) => entry.level === "exact").length },
|
|
735
|
+
approximated: {
|
|
736
|
+
count: entries.filter((entry) => entry.level === "approximated").length,
|
|
737
|
+
reasons: approximated,
|
|
738
|
+
},
|
|
739
|
+
imageFallback: {
|
|
740
|
+
count: entries.filter((entry) => entry.level === "image-fallback").length,
|
|
741
|
+
reasons: imageFallback,
|
|
742
|
+
},
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function aggregateFidelity(reports) {
|
|
746
|
+
return {
|
|
747
|
+
exact: {
|
|
748
|
+
count: reports.reduce((sum, report) => sum + report.exact.count, 0),
|
|
749
|
+
},
|
|
750
|
+
approximated: {
|
|
751
|
+
count: reports.reduce((sum, report) => sum + report.approximated.count, 0),
|
|
752
|
+
reasons: reports
|
|
753
|
+
.flatMap((report) => report.approximated.reasons)
|
|
754
|
+
.slice(0, 1_000),
|
|
755
|
+
},
|
|
756
|
+
imageFallback: {
|
|
757
|
+
count: reports.reduce((sum, report) => sum + report.imageFallback.count, 0),
|
|
758
|
+
reasons: reports
|
|
759
|
+
.flatMap((report) => report.imageFallback.reasons)
|
|
760
|
+
.slice(0, 1_000),
|
|
761
|
+
},
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function extractSearchText(node) {
|
|
765
|
+
const values = [];
|
|
766
|
+
const visit = (current) => {
|
|
767
|
+
if (values.join("\n").length >= MAX_SEARCH_TEXT_CHARS)
|
|
768
|
+
return;
|
|
769
|
+
if (current.name)
|
|
770
|
+
values.push(current.name);
|
|
771
|
+
if (current.characters)
|
|
772
|
+
values.push(current.characters);
|
|
773
|
+
for (const child of current.children ?? [])
|
|
774
|
+
visit(child);
|
|
775
|
+
};
|
|
776
|
+
visit(node);
|
|
777
|
+
return values.join("\n").slice(0, MAX_SEARCH_TEXT_CHARS);
|
|
778
|
+
}
|
|
779
|
+
function extractCodeTokens(html) {
|
|
780
|
+
const tokens = new Set((html.match(/[A-Za-z][A-Za-z0-9_-]{2,}/g) ?? []).map((token) => token.toLowerCase()));
|
|
781
|
+
return [...tokens].slice(0, 4_000).join(" ");
|
|
782
|
+
}
|
|
783
|
+
function wrapFigmaDocument(fragment, node) {
|
|
784
|
+
return `<!doctype html>
|
|
785
|
+
<html>
|
|
786
|
+
<head>
|
|
787
|
+
<meta charset="utf-8" />
|
|
788
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
789
|
+
<style>*,*::before,*::after{box-sizing:border-box}html,body{margin:0;min-width:100%;min-height:100%}</style>
|
|
790
|
+
</head>
|
|
791
|
+
<body>
|
|
792
|
+
${fragment}
|
|
793
|
+
</body>
|
|
794
|
+
</html>`;
|
|
795
|
+
}
|
|
796
|
+
function figmaUsageEdges(node, fileKey) {
|
|
797
|
+
const edges = new Map();
|
|
798
|
+
const visit = (current) => {
|
|
799
|
+
if (current.componentId) {
|
|
800
|
+
edges.set(`component:${current.componentId}`, {
|
|
801
|
+
relation: "instance-of-component",
|
|
802
|
+
toExternalId: `${fileKey}:${current.componentId}`,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
const styles = current.styles;
|
|
806
|
+
for (const [styleType, styleId] of Object.entries(styles ?? {})) {
|
|
807
|
+
if (typeof styleId !== "string" || !styleId)
|
|
808
|
+
continue;
|
|
809
|
+
edges.set(`style:${styleId}`, {
|
|
810
|
+
relation: "uses-figma-token",
|
|
811
|
+
toExternalId: `${fileKey}:style:${styleId}`,
|
|
812
|
+
metadata: { styleType },
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
for (const child of current.children ?? [])
|
|
816
|
+
visit(child);
|
|
817
|
+
};
|
|
818
|
+
visit(node);
|
|
819
|
+
return [...edges.values()];
|
|
820
|
+
}
|
|
821
|
+
function normalizedBounds(bounds) {
|
|
822
|
+
return bounds
|
|
823
|
+
? {
|
|
824
|
+
x: round(bounds.x),
|
|
825
|
+
y: round(bounds.y),
|
|
826
|
+
width: Math.max(0, round(bounds.width)),
|
|
827
|
+
height: Math.max(0, round(bounds.height)),
|
|
828
|
+
}
|
|
829
|
+
: undefined;
|
|
830
|
+
}
|
|
831
|
+
function relativeBounds(child, parent) {
|
|
832
|
+
return child
|
|
833
|
+
? {
|
|
834
|
+
x: round(child.x - parent.x),
|
|
835
|
+
y: round(child.y - parent.y),
|
|
836
|
+
width: Math.max(0, round(child.width)),
|
|
837
|
+
height: Math.max(0, round(child.height)),
|
|
838
|
+
}
|
|
839
|
+
: { x: 0, y: 0, width: parent.width, height: parent.height };
|
|
840
|
+
}
|
|
841
|
+
function flattenTransform(transform) {
|
|
842
|
+
return transform
|
|
843
|
+
? [
|
|
844
|
+
transform[0][0],
|
|
845
|
+
transform[0][1],
|
|
846
|
+
transform[0][2],
|
|
847
|
+
transform[1][0],
|
|
848
|
+
transform[1][1],
|
|
849
|
+
transform[1][2],
|
|
850
|
+
]
|
|
851
|
+
: undefined;
|
|
852
|
+
}
|
|
853
|
+
function insertBeforeLastClosingDiv(html, children) {
|
|
854
|
+
const index = html.lastIndexOf("</div>");
|
|
855
|
+
return index < 0
|
|
856
|
+
? `${html}\n${children}`
|
|
857
|
+
: `${html.slice(0, index)}\n${children}\n${html.slice(index)}`;
|
|
858
|
+
}
|
|
859
|
+
function externalId(fileKey, nodeId) {
|
|
860
|
+
return `${fileKey}:${nodeId}`;
|
|
861
|
+
}
|
|
862
|
+
function stableMediaId(...values) {
|
|
863
|
+
return `ccm_${createHash("sha256").update(values.join("\u0000")).digest("hex").slice(0, 28)}`;
|
|
864
|
+
}
|
|
865
|
+
function safeFilename(value) {
|
|
866
|
+
return value.replace(/[^A-Za-z0-9._-]/g, "-").slice(0, 120);
|
|
867
|
+
}
|
|
868
|
+
function figmaNodeUrl(value, nodeId) {
|
|
869
|
+
const url = new URL(value);
|
|
870
|
+
url.searchParams.set("node-id", nodeId);
|
|
871
|
+
return url.href;
|
|
872
|
+
}
|
|
873
|
+
function escapeAttribute(value) {
|
|
874
|
+
return value
|
|
875
|
+
.replace(/&/g, "&")
|
|
876
|
+
.replace(/"/g, """)
|
|
877
|
+
.replace(/</g, "<")
|
|
878
|
+
.replace(/>/g, ">");
|
|
879
|
+
}
|
|
880
|
+
function round(value) {
|
|
881
|
+
return Math.round(value * 100) / 100;
|
|
882
|
+
}
|
|
883
|
+
//# sourceMappingURL=figma-native.js.map
|