@agent-native/core-corpus 0.214.0 → 0.217.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/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/analytics/.agents/skills/session-replay/SKILL.md +61 -1
- package/corpus/templates/analytics/AGENTS.md +1 -1
- package/corpus/templates/analytics/CHANGELOG.md +2 -0
- package/corpus/templates/analytics/actions/get-session-replay-summary.ts +9 -65
- package/corpus/templates/analytics/actions/list-event-catalog.ts +1 -1
- package/corpus/templates/analytics/actions/list-session-outputs.ts +40 -0
- package/corpus/templates/analytics/actions/list-session-recordings.ts +17 -4
- package/corpus/templates/analytics/actions/view-screen.ts +29 -3
- package/corpus/templates/analytics/app/i18n/en-US.ts +27 -0
- package/corpus/templates/analytics/app/pages/sessions/EventCatalogPage.tsx +18 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +3 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionOutputs.tsx +197 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionsTriagePage.tsx +114 -4
- package/corpus/templates/analytics/changelog/2026-10-15-sessions-can-find-people-who-made-a-slides-deck-but-didn-t-p.md +6 -0
- package/corpus/templates/analytics/changelog/2026-10-16-the-activation-funnel-counts-visitors-who-decline-analytics-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-10-21-session-replay-quotas-count-the-compressed-size-analytics-st.md +6 -0
- package/corpus/templates/analytics/server/db/schema.ts +67 -0
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +9 -0
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +28 -22
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +36 -1
- package/corpus/templates/analytics/server/lib/output-outcomes.ts +712 -0
- package/corpus/templates/analytics/server/lib/replay-origins.ts +33 -0
- package/corpus/templates/analytics/server/lib/session-event-index.ts +20 -0
- package/corpus/templates/analytics/server/lib/session-performance.ts +6 -40
- package/corpus/templates/analytics/server/lib/session-recording-associations.ts +30 -1
- package/corpus/templates/analytics/server/lib/session-replay-triage.ts +99 -0
- package/corpus/templates/analytics/server/lib/session-replay.ts +85 -40
- package/corpus/templates/analytics/server/lib/sessions-triage-lab.ts +8 -2
- package/corpus/templates/analytics/server/plugins/db.ts +46 -0
- package/corpus/templates/analytics/shared/output-use.ts +205 -0
- package/corpus/templates/analytics/shared/session-events.ts +6 -0
- package/corpus/templates/assets/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/brain/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/calendar/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/calendar/CHANGELOG.md +6 -0
- package/corpus/templates/calendar/actions/create-event.ts +2 -4
- package/corpus/templates/calendar/actions/update-event.ts +35 -6
- package/corpus/templates/calendar/changelog/2026-10-21-solo-events-avoid-notification-approval.md +6 -0
- package/corpus/templates/chat/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/clips/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/community/qr/package.json +1 -1
- package/corpus/templates/content/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/content/.agents/skills/content-product-development/references/verification.md +36 -0
- package/corpus/templates/content/.agents/skills/document-editing/SKILL.md +10 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +17 -3
- package/corpus/templates/content/.agents/skills/notion-integration/SKILL.md +4 -2
- package/corpus/templates/content/CHANGELOG.md +54 -0
- package/corpus/templates/content/acceptance/_writers.ts +604 -0
- package/corpus/templates/content/acceptance/generate-action-registry.ts +10 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/create-document.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/duplicate-page.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/edit-document-find-and-replace-without-a-revision.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/edit-document-find-and-replace.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/edit-document-initializecontent.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/import-content.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-import-content-source-existing-page.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-import-content-source-new-page.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-sync-local-folder-source-changed-file.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-sync-local-folder-source-new-file.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/restore-document-version.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/set-document-property-primary-blocks-field.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/set-image-alt-text.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/undo-content-import.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/update-document-browser-full-rewrite.json +75 -0
- package/corpus/templates/content/acceptance/known-loss.ts +69 -0
- package/corpus/templates/content/acceptance/round-trip-corpus.ts +1397 -0
- package/corpus/templates/content/actions/_blocks-field-identity.ts +35 -1
- package/corpus/templates/content/actions/_browser-document-save-attempt.ts +23 -1
- package/corpus/templates/content/actions/_builder-cms-blob-custody.ts +467 -0
- package/corpus/templates/content/actions/_builder-cms-execution-lease.ts +17 -0
- package/corpus/templates/content/actions/_builder-cms-intent-lookup.ts +5 -0
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +881 -21
- package/corpus/templates/content/actions/_builder-cms-write-adapter.ts +28 -2
- package/corpus/templates/content/actions/_builder-cms-write-client.ts +109 -11
- package/corpus/templates/content/actions/_builder-docs-client.ts +1 -0
- package/corpus/templates/content/actions/_builder-private-blob.test-fixture.ts +90 -0
- package/corpus/templates/content/actions/_builder-source-execution-guard.ts +48 -0
- package/corpus/templates/content/actions/_content-database-lifecycle.ts +11 -11
- package/corpus/templates/content/actions/_content-database-personal-view.ts +2 -0
- package/corpus/templates/content/actions/_content-favorites.ts +37 -0
- package/corpus/templates/content/actions/_content-save-outcomes.ts +5 -0
- package/corpus/templates/content/actions/_database-membership-lock.ts +39 -8
- package/corpus/templates/content/actions/_database-navigation.ts +19 -21
- package/corpus/templates/content/actions/_database-row-batch.ts +41 -18
- package/corpus/templates/content/actions/_database-row-mutation.ts +17 -28
- package/corpus/templates/content/actions/_database-source-utils.ts +308 -9
- package/corpus/templates/content/actions/_database-utils.ts +96 -7
- package/corpus/templates/content/actions/_database-view-setup.ts +37 -2
- package/corpus/templates/content/actions/_delete-content-space.ts +8 -1
- package/corpus/templates/content/actions/_document-edit-mutation.ts +33 -32
- package/corpus/templates/content/actions/_document-flush.ts +593 -171
- package/corpus/templates/content/actions/_document-save-locks.ts +54 -0
- package/corpus/templates/content/actions/_document-save-row.ts +133 -0
- package/corpus/templates/content/actions/_github-source-freshness.ts +30 -4
- package/corpus/templates/content/actions/_github-source.ts +18 -8
- package/corpus/templates/content/actions/_move-page-to-space.ts +189 -25
- package/corpus/templates/content/actions/_nfm-syntax.ts +2 -0
- package/corpus/templates/content/actions/_row-lock-order.ts +115 -0
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +23 -6
- package/corpus/templates/content/actions/cancel-prepared-builder-source-update.ts +110 -26
- package/corpus/templates/content/actions/change-content-database-source-role.ts +51 -7
- package/corpus/templates/content/actions/create-content-database.ts +11 -0
- package/corpus/templates/content/actions/create-document.ts +13 -1
- package/corpus/templates/content/actions/delete-content-database.ts +17 -14
- package/corpus/templates/content/actions/delete-document-property.ts +5 -0
- package/corpus/templates/content/actions/delete-document.ts +311 -100
- package/corpus/templates/content/actions/disconnect-content-database-source.ts +68 -2
- package/corpus/templates/content/actions/disconnect-local-folder-source.ts +33 -2
- package/corpus/templates/content/actions/edit-document.ts +18 -5
- package/corpus/templates/content/actions/execute-builder-source-execution.ts +900 -140
- package/corpus/templates/content/actions/export-document.ts +3 -0
- package/corpus/templates/content/actions/get-blocks-field-word-count.ts +22 -5
- package/corpus/templates/content/actions/get-document.ts +2 -0
- package/corpus/templates/content/actions/import-content-source.ts +170 -54
- package/corpus/templates/content/actions/move-document.ts +191 -73
- package/corpus/templates/content/actions/permanently-delete-document.ts +6 -0
- package/corpus/templates/content/actions/prepare-builder-source-execution.ts +155 -13
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +299 -73
- package/corpus/templates/content/actions/pull-document.ts +8 -2
- package/corpus/templates/content/actions/remove-database-items.ts +23 -4
- package/corpus/templates/content/actions/restore-content-database.ts +76 -55
- package/corpus/templates/content/actions/restore-document-version.ts +19 -35
- package/corpus/templates/content/actions/restore-document.ts +65 -53
- package/corpus/templates/content/actions/rollback-created-slash-document.ts +11 -16
- package/corpus/templates/content/actions/set-document-property.ts +15 -1
- package/corpus/templates/content/actions/set-live-body-switch.ts +45 -0
- package/corpus/templates/content/actions/share-local-file-document.ts +18 -14
- package/corpus/templates/content/actions/suggest-document-edit.ts +2 -3
- package/corpus/templates/content/actions/sync-local-folder-source.ts +35 -1
- package/corpus/templates/content/actions/undo-content-import.ts +16 -12
- package/corpus/templates/content/actions/update-content-database-view.ts +2 -0
- package/corpus/templates/content/actions/update-document.ts +158 -34
- package/corpus/templates/content/actions/validate-builder-source-execution.ts +135 -26
- package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +1 -6
- package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +49 -3
- package/corpus/templates/content/app/components/editor/ContentImportDialog.tsx +2 -0
- package/corpus/templates/content/app/components/editor/DocumentBlockFields.tsx +53 -11
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +608 -353
- package/corpus/templates/content/app/components/editor/StaticDocumentBody.tsx +765 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +233 -80
- package/corpus/templates/content/app/components/editor/blockFieldSaveController.ts +32 -3
- package/corpus/templates/content/app/components/editor/blockFieldSaveRegistry.ts +88 -23
- package/corpus/templates/content/app/components/editor/comment-anchors.ts +19 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +228 -71
- package/corpus/templates/content/app/components/editor/database/GitHubSourceStatusLine.tsx +27 -2
- package/corpus/templates/content/app/components/editor/database/ListItemLayout.tsx +32 -8
- package/corpus/templates/content/app/components/editor/database/ListItemRow.tsx +27 -2
- package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +1 -0
- package/corpus/templates/content/app/components/editor/document-flush-participant.ts +253 -0
- package/corpus/templates/content/app/components/editor/editor-transaction-meta.ts +28 -0
- package/corpus/templates/content/app/components/editor/extensions/AudioBlock.tsx +2 -1
- package/corpus/templates/content/app/components/editor/extensions/ImageBlock.tsx +27 -6
- package/corpus/templates/content/app/components/editor/extensions/LocalMdxComponentNode.tsx +0 -1
- package/corpus/templates/content/app/components/editor/extensions/NotionExtensions.tsx +4 -4
- package/corpus/templates/content/app/components/editor/extensions/SuggestionHighlight.ts +24 -2
- package/corpus/templates/content/app/components/editor/extensions/VideoBlock.tsx +25 -6
- package/corpus/templates/content/app/components/editor/pending-document-persistence.ts +59 -1
- package/corpus/templates/content/app/components/editor/stored-body-images.ts +27 -0
- package/corpus/templates/content/app/components/editor/suggestions/presentation-rebase.ts +17 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -4
- package/corpus/templates/content/app/components/trash/TrashBrowser.tsx +4 -1
- package/corpus/templates/content/app/global.css +21 -0
- package/corpus/templates/content/app/hooks/use-content-database.ts +40 -2
- package/corpus/templates/content/app/hooks/use-content-trash.ts +8 -0
- package/corpus/templates/content/app/hooks/use-documents.ts +14 -0
- package/corpus/templates/content/app/i18n-data.ts +1 -0
- package/corpus/templates/content/app/import-messages.ts +25 -0
- package/corpus/templates/content/app/trash-messages.ts +16 -0
- package/corpus/templates/content/changelog/2026-10-16-a-page-open-in-a-tab-that-shows-it-s-in-the-trash-reopens-wi.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-a-page-restored-from-trash-returns-to-its-place-in-its-colle.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-agent-written-markdown-keeps-nested-lists-indented-with-spac.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-opening-a-page-you-can-edit-no-longer-rebuilds-its-editor-on.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-pages-moved-or-imported-at-the-same-time-can-no-longer-end-u.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-re-importing-a-markdown-export-of-a-page-no-longer-reports-t.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-saving-a-page-or-restoring-one-of-its-versions-no-longer-fai.md +6 -0
- package/corpus/templates/content/changelog/2026-10-17-agents-reading-a-page-you-have-open-no-longer-wait-or-fail-w.md +6 -0
- package/corpus/templates/content/changelog/2026-10-17-builder-content-avoids-retrying-a-write-when-builder-accepte.md +6 -0
- package/corpus/templates/content/changelog/2026-10-18-link-a-new-collection-to-a-github-folder-from-its-sources.md +1 -1
- package/corpus/templates/content/changelog/2026-10-19-fresh-document-reads-require-confirmation-from-every-open-ed.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-builder-content-sync-keeps-read-and-write-status-accurate-wh.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-html-table-cells-preserve-a-trailing-backslash-when-opening-.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-preserve-empty-paragraph-colors-and-refuse-unsupported-inlin.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-the-advanced-filter-and-each-filter-group-inside-it-have-the.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-blocks-fields-keep-unconfirmed-saves-visible-and-agent-reads.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-list-rows-can-show-each-pages-first-lines.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-preserve-compact-table-row-groups-and-report-invalid-block-colors.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-suggested-edits-show-an-agent-s-whole-reason-open-a-group-to.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-suggestions-keep-refusing-unmatched-emphasis-in-stored-markd.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-a-collection-linked-to-a-big-github-folder-fills-faster-and-p.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-accept-remaining-and-reject-remaining-show-the-result-for-ev.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-accepting-a-group-of-suggested-edits-saves-faster-and-adds-o.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-agents-read-saved-page-text-after-failed-icon-change.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-changes-made-from-a-menu-or-popover-such-as-an-image-s-alt-t.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-text-an-agent-writes-inside-a-callout-column-or-synced-block.md +6 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.adapters.md +29 -0
- package/corpus/templates/content/e2e/auth-files.ts +28 -0
- package/corpus/templates/content/e2e/convergence-summary.ts +84 -29
- package/corpus/templates/content/e2e/gate-arm.ts +15 -0
- package/corpus/templates/content/e2e/global-setup.ts +43 -75
- package/corpus/templates/content/e2e/global-teardown.ts +34 -0
- package/corpus/templates/content/e2e/helpers.ts +598 -92
- package/corpus/templates/content/e2e/live-body-gate.ts +188 -0
- package/corpus/templates/content/e2e/playwright.config.ts +12 -3
- package/corpus/templates/content/e2e/server-identity.ts +47 -0
- package/corpus/templates/content/e2e/stored-form/collab-blocks.ts +123 -0
- package/corpus/templates/content/package.json +1 -1
- package/corpus/templates/content/parity/matrix.md +42 -42
- package/corpus/templates/content/parity/matrix.ts +3 -1
- package/corpus/templates/content/scripts/_stored-form-census-kinds.ts +30 -2
- package/corpus/templates/content/scripts/historical-icon-apply.ts +9 -1
- package/corpus/templates/content/scripts/trace-startup.mjs +460 -133
- package/corpus/templates/content/server/db/exec.ts +58 -0
- package/corpus/templates/content/server/db/schema.ts +21 -0
- package/corpus/templates/content/server/lib/content-trash-purge.ts +222 -144
- package/corpus/templates/content/server/lib/document-metadata-updated-at.ts +43 -1
- package/corpus/templates/content/server/lib/document-revision.ts +23 -0
- package/corpus/templates/content/server/lib/live-body-writer.ts +311 -0
- package/corpus/templates/content/server/lib/notion-sync.ts +63 -29
- package/corpus/templates/content/server/lib/notion.ts +5 -5
- package/corpus/templates/content/server/lib/suggested-edits.ts +357 -230
- package/corpus/templates/content/server/live-copy/binding.ts +31 -0
- package/corpus/templates/content/server/live-copy/bounded-task.d.ts +6 -0
- package/corpus/templates/content/server/live-copy/exec-db.ts +1 -0
- package/corpus/templates/content/server/live-copy/holds.ts +59 -0
- package/corpus/templates/content/server/live-copy/persist.ts +656 -0
- package/corpus/templates/content/server/live-copy/switch.ts +136 -0
- package/corpus/templates/content/server/live-copy/task-names.ts +4 -0
- package/corpus/templates/content/server/live-copy/tasks.ts +183 -0
- package/corpus/templates/content/server/live-copy/write-cause.ts +85 -0
- package/corpus/templates/content/server/live-copy/write.ts +85 -0
- package/corpus/templates/content/server/plugins/builder-private-payload-cleanup.ts +22 -0
- package/corpus/templates/content/server/plugins/collab.ts +3 -0
- package/corpus/templates/content/server/plugins/db.ts +33 -0
- package/corpus/templates/content/server/routes/api/documents/[id]/move.patch.ts +50 -168
- package/corpus/templates/content/shared/api.ts +32 -1
- package/corpus/templates/content/shared/blocks-fields-manifest.ts +106 -0
- package/corpus/templates/content/shared/database-item-layout.ts +54 -22
- package/corpus/templates/content/shared/database-query.ts +192 -30
- package/corpus/templates/content/shared/document-export.ts +12 -14
- package/corpus/templates/content/shared/document-flush-protocol.ts +88 -0
- package/corpus/templates/content/shared/document-intent-merge.ts +16 -9
- package/corpus/templates/content/shared/editor-save-state.ts +97 -0
- package/corpus/templates/content/shared/feature-flags.ts +10 -0
- package/corpus/templates/content/shared/import/markdown.ts +91 -7
- package/corpus/templates/content/shared/import/types.ts +2 -0
- package/corpus/templates/content/shared/inline-math.ts +6 -4
- package/corpus/templates/content/shared/nfm-fidelity.ts +247 -0
- package/corpus/templates/content/shared/nfm.ts +1933 -340
- package/corpus/templates/content/shared/og-description.ts +258 -36
- package/corpus/templates/content/shared/suggestion-diff.ts +13 -0
- package/corpus/templates/content/shared/suggestion-formatting.ts +143 -20
- package/corpus/templates/content/shared/suggestion-text.ts +39 -0
- package/corpus/templates/content/vitest.config.ts +10 -0
- package/corpus/templates/crm/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/design/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/design/.agents/skills/design-templates/SKILL.md +5 -1
- package/corpus/templates/design/.agents/skills/native-effects/SKILL.md +9 -2
- package/corpus/templates/design/.generated/bridge/shader-fill-preview.generated.ts +3 -249
- package/corpus/templates/design/.generated/bridge/shader-runtime.generated.ts +30 -92
- package/corpus/templates/design/AGENTS.md +1 -3
- package/corpus/templates/design/CHANGELOG.md +34 -0
- package/corpus/templates/design/CODE_NATIVE_DESIGN_STUDIO_IMPLEMENTATION_PLAN.md +1 -6
- package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +5 -7
- package/corpus/templates/design/actions/_native-local-export-server.ts +44 -31
- package/corpus/templates/design/actions/_native-render-contexts.ts +76 -21
- package/corpus/templates/design/actions/claim-native-local-export.ts +5 -0
- package/corpus/templates/design/actions/finish-native-local-export.ts +13 -2
- package/corpus/templates/design/actions/get-getting-started.ts +53 -0
- package/corpus/templates/design/actions/get-native-shader-approvals.ts +35 -0
- package/corpus/templates/design/actions/get-shader.ts +134 -219
- package/corpus/templates/design/actions/list-design-extensions.ts +3 -58
- package/corpus/templates/design/actions/request-native-local-export.ts +32 -6
- package/corpus/templates/design/actions/run-design-extension-action.ts +0 -29
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +141 -108
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +0 -218
- package/corpus/templates/design/app/components/design/DesignThumbnail.tsx +59 -3
- package/corpus/templates/design/app/components/design/EditPanel.tsx +35 -47
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +242 -62
- package/corpus/templates/design/app/components/design/NativePreviewErrorBoundary.tsx +53 -0
- package/corpus/templates/design/app/components/design/bridge/codegen.ts +18 -3
- package/corpus/templates/design/app/components/design/bridge/native-composition-clock.ts +5 -4
- package/corpus/templates/design/app/components/design/bridge/native-dom.ts +37 -0
- package/corpus/templates/design/app/components/design/bridge/native-intrinsic-image.ts +2 -1
- package/corpus/templates/design/app/components/design/bridge/native-mesh-grid.ts +90 -0
- package/corpus/templates/design/app/components/design/bridge/native-opaque-public-asset.ts +363 -0
- package/corpus/templates/design/app/components/design/bridge/native-opaque-worker-lease.ts +179 -0
- package/corpus/templates/design/app/components/design/bridge/native-preview-geometry.ts +132 -7
- package/corpus/templates/design/app/components/design/bridge/native-preview-policy.ts +4 -0
- package/corpus/templates/design/app/components/design/bridge/native-preview-viewport-transport.ts +378 -0
- package/corpus/templates/design/app/components/design/bridge/native-scene-body-transform.ts +62 -0
- package/corpus/templates/design/app/components/design/bridge/native-scene-presentation-element.ts +10 -0
- package/corpus/templates/design/app/components/design/bridge/native-shader-runtime.bridge.ts +778 -246
- package/corpus/templates/design/app/components/design/bridge/native-source-provider.ts +512 -320
- package/corpus/templates/design/app/components/design/bridge/native-stateful-resource.ts +2 -2
- package/corpus/templates/design/app/components/design/bridge/native-stateless-compute.ts +5 -2
- package/corpus/templates/design/app/components/design/bridge/native-svg-source.ts +11 -1
- package/corpus/templates/design/app/components/design/bridge/native-worker-broker.ts +6 -0
- package/corpus/templates/design/app/components/design/bridge/native-worker-entry.ts +761 -303
- package/corpus/templates/design/app/components/design/bridge/native-worker-fill.ts +16 -6
- package/corpus/templates/design/app/components/design/bridge/native-worker-gpu.ts +854 -91
- package/corpus/templates/design/app/components/design/bridge/native-worker-host.ts +15 -1
- package/corpus/templates/design/app/components/design/bridge/native-worker-input-assets.ts +200 -0
- package/corpus/templates/design/app/components/design/bridge/native-worker-protocol.ts +40 -1
- package/corpus/templates/design/app/components/design/bridge/native-worker-scene-host.ts +540 -161
- package/corpus/templates/design/app/components/design/bridge/native-worker-source-snapshot.ts +21 -0
- package/corpus/templates/design/app/components/design/bridge/shader-fill-preview.bridge.ts +5 -371
- package/corpus/templates/design/app/components/design/bridge/shader-runtime.bridge.ts +45 -150
- package/corpus/templates/design/app/components/design/design-canvas/interact-document.ts +5 -9
- package/corpus/templates/design/app/components/design/design-canvas/native-preview-surface.ts +150 -0
- package/corpus/templates/design/app/components/design/design-canvas/native-public-asset-preview.ts +409 -0
- package/corpus/templates/design/app/components/design/design-canvas/native-public-worker-preview.ts +1086 -0
- package/corpus/templates/design/app/components/design/design-canvas/private-replay-screenshot-preview.ts +2 -2
- package/corpus/templates/design/app/components/design/design-canvas/text-content-change-result.ts +46 -12
- package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +15 -26
- package/corpus/templates/design/app/components/design/edit-panel/fill-properties.tsx +74 -67
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +7 -19
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +39 -30
- package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +4 -0
- package/corpus/templates/design/app/components/design/inspector/NativeShaderColorControls.tsx +3 -7
- package/corpus/templates/design/app/components/design/inspector/NativeShaderPaintControls.tsx +12 -5
- package/corpus/templates/design/app/components/design/inspector/NativeShaderPanel.tsx +705 -190
- package/corpus/templates/design/app/components/design/inspector/fill-field-reading.ts +1 -2
- package/corpus/templates/design/app/components/design/inspector/index.ts +0 -6
- package/corpus/templates/design/app/components/design/inspector/native-catalog-display.ts +26 -5
- package/corpus/templates/design/app/components/design/inspector/native-shader-catalog-fixture.ts +42 -0
- package/corpus/templates/design/app/components/design/inspector/native-shader-catalog-preview.ts +51 -33
- package/corpus/templates/design/app/components/design/inspector/native-shader-paint.ts +1 -0
- package/corpus/templates/design/app/components/design/inspector/native-shader-property-draft.ts +89 -23
- package/corpus/templates/design/app/components/design/inspector/saved-glsl-shader.tsx +243 -0
- package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +54 -5
- package/corpus/templates/design/app/components/design/shader-source-coordination.ts +66 -0
- package/corpus/templates/design/app/components/design/use-native-shader-approvals.ts +36 -8
- package/corpus/templates/design/app/components/home/DesignHomeLibrary.tsx +15 -8
- package/corpus/templates/design/app/components/layout/GettingStarted.tsx +50 -0
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +3 -0
- package/corpus/templates/design/app/components/templates/DesignTemplateGrid.tsx +163 -0
- package/corpus/templates/design/app/components/templates/DesignTemplateLibrary.tsx +65 -78
- package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +66 -5
- package/corpus/templates/design/app/global.css +6 -0
- package/corpus/templates/design/app/i18n/en-US.ts +95 -2
- package/corpus/templates/design/app/lib/canvas-load-outcome.ts +147 -0
- package/corpus/templates/design/app/lib/canvas-outcome-tracking.ts +531 -0
- package/corpus/templates/design/app/lib/canvas-style-kind.ts +50 -0
- package/corpus/templates/design/app/pages/Index.tsx +10 -3
- package/corpus/templates/design/app/pages/Present.tsx +36 -1
- package/corpus/templates/design/app/pages/design-editor/commands/apply-file-content-update.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/apply-local-content-update.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/commit-visual-styles.ts +88 -32
- package/corpus/templates/design/app/pages/design-editor/commands/cross-screen-element-drop.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/layer-move-to-screen.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/paste-selection.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/paste-svg-layer.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/prepare-content-history-replay.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/redo.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/render-png-blob.ts +84 -41
- package/corpus/templates/design/app/pages/design-editor/commands/save-file-content.ts +38 -3
- package/corpus/templates/design/app/pages/design-editor/commands/shader-source-edit.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/undo.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/design-editor-view.tsx +0 -2
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-content-and-components.ts +4 -33
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-core.ts +9 -0
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-export-and-handoff.ts +2 -2
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-files-and-saving.ts +2 -0
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-history.ts +0 -11
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-layer-models.ts +2 -55
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-screen-rendering.tsx +0 -3
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-selection-and-styles.ts +0 -24
- package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +0 -16
- package/corpus/templates/design/app/pages/design-editor/use-native-local-export-requests.ts +70 -11
- package/corpus/templates/design/app/pages/design-editor/view/single-screen-canvas.tsx +0 -2
- package/corpus/templates/design/changelog/2026-10-20-folded-mesh-adds-an-animated-sculpted-fill-with-editable-col.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-read-only-design-views-render-native-shader-previews-in-nest.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-selected-screens-with-shader-effects-can-be-exported-togethe.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-shader-previews-reuse-validated-scene-data-while-panning-inc.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-shader-previews-stay-aligned-while-you-zoom.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-signed-out-sessions-no-longer-watch-for-private-png-export-r.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-a-getting-started-checklist-at-the-bottom-of-the-sidebar-tra.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-effect-thumbnails-show-richer-previews.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-native-effects-render-across-previews.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-native-shader-previews-use-less-gpu-memory-when-many-mesh-ef.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-opening-design-no-longer-shows-png-export-errors-when-no-exp.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-pulsing-border-controls-grouped.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-pulsing-border-follows-element-outlines.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-remove-obsolete-shader-fills.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-shader-previews-recover-from-temporary-gpu-and-image-failure.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-templates-now-open-a-read-only-preview-from-the-card-and-the.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-collapsed-shader-layers-no-longer-interrupt-other-shaders-on.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-shader-fills-and-effects-render-correctly-on-canvas-elements.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-shader-fills-keep-rendering-when-other-screen-content-cannot.md +6 -0
- package/corpus/templates/design/package.json +0 -1
- package/corpus/templates/design/playwright.config.ts +1 -1
- package/corpus/templates/design/scripts/design-export-validation/export-baseline.json +24 -0
- package/corpus/templates/design/scripts/runtime-budget-zoom.ts +9 -21
- package/corpus/templates/design/scripts/runtime-budget.ts +10 -24
- package/corpus/templates/design/server/lib/getting-started.ts +267 -0
- package/corpus/templates/design/server/plugins/agent-chat.ts +0 -2
- package/corpus/templates/design/server/plugins/getting-started.ts +5 -0
- package/corpus/templates/design/shared/design-template-presets/analytics-dashboard.ts +127 -0
- package/corpus/templates/design/shared/design-template-presets/design-studio.ts +98 -0
- package/corpus/templates/design/shared/design-template-presets/messaging-app.ts +101 -0
- package/corpus/templates/design/shared/design-template-presets/project-tasks.ts +120 -0
- package/corpus/templates/design/shared/design-template-presets.ts +8 -0
- package/corpus/templates/design/shared/effect-graph.ts +46 -1
- package/corpus/templates/design/shared/generation-output-receipt.ts +0 -1
- package/corpus/templates/design/shared/native-effect-animation-capability.ts +6 -0
- package/corpus/templates/design/shared/native-effect-folded-mesh-v1.ts +268 -0
- package/corpus/templates/design/shared/native-effect-folded-mesh-v2.ts +310 -0
- package/corpus/templates/design/shared/native-effect-folded-mesh.ts +489 -0
- package/corpus/templates/design/shared/native-effect-gallery-additions.ts +2 -2
- package/corpus/templates/design/shared/native-effect-paint.ts +8 -0
- package/corpus/templates/design/shared/native-effect-parameter-constraints.ts +8 -1
- package/corpus/templates/design/shared/native-effect-presets.ts +18 -1
- package/corpus/templates/design/shared/native-effect-property-presentation.ts +81 -0
- package/corpus/templates/design/shared/native-effect-pulsing-border-v3.ts +281 -0
- package/corpus/templates/design/shared/native-effect-pulsing-border-v4.ts +284 -0
- package/corpus/templates/design/shared/native-effect-pulsing-border.ts +300 -0
- package/corpus/templates/design/shared/native-effect-trust.ts +6 -0
- package/corpus/templates/design/shared/native-effect-wgsl.ts +12 -0
- package/corpus/templates/design/shared/native-effects.ts +528 -15
- package/corpus/templates/design/shared/native-input-resources.ts +36 -0
- package/corpus/templates/design/shared/native-local-export.ts +14 -0
- package/corpus/templates/design/shared/native-parameter-animation.ts +1 -0
- package/corpus/templates/design/shared/native-pointer-input.ts +9 -11
- package/corpus/templates/design/shared/shader-fills.ts +0 -513
- package/corpus/templates/design/vitest.setup.ts +7 -1
- package/corpus/templates/dispatch/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/dispatch/.agents/skills/turn-into-app/SKILL.md +20 -18
- package/corpus/templates/factory/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +36 -80
- package/corpus/templates/factory/.agents/skills/review-latest-feedback/references/channel-inventory.md +54 -16
- package/corpus/templates/factory/.agents/skills/review-latest-feedback/references/slack-reaction-replies.md +50 -73
- package/corpus/templates/factory/.agents/skills/turn-into-app/SKILL.md +20 -18
- package/corpus/templates/forms/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/forms/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/mail/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/plan/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/slides/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/slides/CHANGELOG.md +6 -0
- package/corpus/templates/slides/actions/delete-deck.ts +7 -0
- package/corpus/templates/slides/changelog/2026-10-21-connected-deck-deletion-requires-approval.md +6 -0
- package/corpus/templates/slides/scripts/edit-fidelity/client-action.ts +61 -0
- package/corpus/templates/slides/scripts/edit-fidelity/run.ts +10 -0
- package/corpus/templates/slides-2/.agents/skills/actions/SKILL.md +199 -0
- package/corpus/templates/slides-2/.agents/skills/actions/references/action-fields.md +145 -0
- package/corpus/templates/slides-2/.agents/skills/actions/references/examples.md +96 -0
- package/corpus/templates/slides-2/.agents/skills/actions/references/provider-apis.md +95 -0
- package/corpus/templates/slides-2/.agents/skills/adding-a-feature/SKILL.md +235 -0
- package/corpus/templates/slides-2/.agents/skills/agent-native-docs/SKILL.md +161 -0
- package/corpus/templates/slides-2/.agents/skills/agent-native-toolkit/SKILL.md +314 -0
- package/corpus/templates/slides-2/.agents/skills/analytics-data-for-decks/SKILL.md +44 -0
- package/corpus/templates/slides-2/.agents/skills/apply-slide-comments/SKILL.md +63 -0
- package/corpus/templates/slides-2/.agents/skills/client-side-routing/SKILL.md +87 -0
- package/corpus/templates/slides-2/.agents/skills/context-awareness/SKILL.md +282 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/SKILL.md +263 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/references/reference-inputs.md +72 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/references/slide-templates.md +93 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/references/source-material.md +16 -0
- package/corpus/templates/slides-2/.agents/skills/creative-context/SKILL.md +134 -0
- package/corpus/templates/slides-2/.agents/skills/customizing-agent-native/SKILL.md +219 -0
- package/corpus/templates/slides-2/.agents/skills/deck-management/SKILL.md +182 -0
- package/corpus/templates/slides-2/.agents/skills/delegate-to-agent/SKILL.md +62 -0
- package/corpus/templates/slides-2/.agents/skills/design-systems/SKILL.md +233 -0
- package/corpus/templates/slides-2/.agents/skills/external-agents/SKILL.md +549 -0
- package/corpus/templates/slides-2/.agents/skills/external-agents/references/mcp-apps-embedding.md +169 -0
- package/corpus/templates/slides-2/.agents/skills/frontend-design/SKILL.md +102 -0
- package/corpus/templates/slides-2/.agents/skills/frontend-design/references/visual-direction.md +102 -0
- package/corpus/templates/slides-2/.agents/skills/image-generation-via-a2a/SKILL.md +134 -0
- package/corpus/templates/slides-2/.agents/skills/performance/SKILL.md +79 -0
- package/corpus/templates/slides-2/.agents/skills/portability/SKILL.md +108 -0
- package/corpus/templates/slides-2/.agents/skills/real-time-sync/SKILL.md +146 -0
- package/corpus/templates/slides-2/.agents/skills/reliable-mutations/SKILL.md +72 -0
- package/corpus/templates/slides-2/.agents/skills/secrets/SKILL.md +82 -0
- package/corpus/templates/slides-2/.agents/skills/security/SKILL.md +80 -0
- package/corpus/templates/slides-2/.agents/skills/self-modifying-code/SKILL.md +123 -0
- package/corpus/templates/slides-2/.agents/skills/shadcn-ui/SKILL.md +71 -0
- package/corpus/templates/slides-2/.agents/skills/sharing/SKILL.md +286 -0
- package/corpus/templates/slides-2/.agents/skills/slide-design/SKILL.md +144 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/SKILL.md +284 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/animations.md +33 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/freeform-objects.md +22 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/restyling.md +69 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/transitions.md +26 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/video.md +45 -0
- package/corpus/templates/slides-2/.agents/skills/slide-images/SKILL.md +136 -0
- package/corpus/templates/slides-2/.agents/skills/storing-data/SKILL.md +234 -0
- package/corpus/templates/slides-2/.agents/skills/turn-into-skill/SKILL.md +112 -0
- package/corpus/templates/slides-2/.agents/skills/turn-into-skill/agents/openai.yaml +4 -0
- package/corpus/templates/slides-2/.agents/skills/workspace-conventions/SKILL.md +103 -0
- package/corpus/templates/slides-2/.builder/rules/deploy-app.mdc +22 -0
- package/corpus/templates/slides-2/.builder/rules/organize-ui.mdc +9 -0
- package/corpus/templates/slides-2/.dockerignore +61 -0
- package/corpus/templates/slides-2/.env.example +23 -0
- package/corpus/templates/slides-2/.ignore +3 -0
- package/corpus/templates/slides-2/.mcp.json +8 -0
- package/corpus/templates/slides-2/.oxfmtrc.json +8 -0
- package/corpus/templates/slides-2/AGENTS.md +66 -0
- package/corpus/templates/slides-2/CHANGELOG.md +76 -0
- package/corpus/templates/slides-2/DEVELOPING.md +157 -0
- package/corpus/templates/slides-2/README.md +58 -0
- package/corpus/templates/slides-2/THIRD_PARTY_NOTICES.md +33 -0
- package/corpus/templates/slides-2/_gitignore +38 -0
- package/corpus/templates/slides-2/actions/_agent-presence.ts +29 -0
- package/corpus/templates/slides-2/actions/_app-url.ts +37 -0
- package/corpus/templates/slides-2/actions/_deck-app-scope.ts +30 -0
- package/corpus/templates/slides-2/actions/_deck-tracking.ts +260 -0
- package/corpus/templates/slides-2/actions/_deck-write.ts +206 -0
- package/corpus/templates/slides-2/actions/_imported-slide-source.ts +162 -0
- package/corpus/templates/slides-2/actions/_inline-image-storage.ts +1013 -0
- package/corpus/templates/slides-2/actions/_linked-design-system.ts +83 -0
- package/corpus/templates/slides-2/actions/_presenter-notes.ts +83 -0
- package/corpus/templates/slides-2/actions/_render-artifacts.ts +111 -0
- package/corpus/templates/slides-2/actions/_slide-source.ts +344 -0
- package/corpus/templates/slides-2/actions/_tab-state.ts +51 -0
- package/corpus/templates/slides-2/actions/_test-brandfetch.ts +31 -0
- package/corpus/templates/slides-2/actions/_uploaded-files.ts +114 -0
- package/corpus/templates/slides-2/actions/add-deck.ts +123 -0
- package/corpus/templates/slides-2/actions/add-slide-comment.ts +267 -0
- package/corpus/templates/slides-2/actions/add-slide.ts +888 -0
- package/corpus/templates/slides-2/actions/analyze-brand-assets.ts +66 -0
- package/corpus/templates/slides-2/actions/apply-design-system.ts +111 -0
- package/corpus/templates/slides-2/actions/approve-deck-access-request.ts +287 -0
- package/corpus/templates/slides-2/actions/audit-contrast.ts +143 -0
- package/corpus/templates/slides-2/actions/check-image-gen.ts +17 -0
- package/corpus/templates/slides-2/actions/clone-context-slide.ts +340 -0
- package/corpus/templates/slides-2/actions/clone-creative-context-deck.ts +143 -0
- package/corpus/templates/slides-2/actions/control-deck-history.ts +186 -0
- package/corpus/templates/slides-2/actions/control-presenter.ts +117 -0
- package/corpus/templates/slides-2/actions/control-slide-editor.ts +267 -0
- package/corpus/templates/slides-2/actions/create-deck-from-template.ts +274 -0
- package/corpus/templates/slides-2/actions/create-deck.ts +1243 -0
- package/corpus/templates/slides-2/actions/create-design-system.ts +131 -0
- package/corpus/templates/slides-2/actions/create-share-link.ts +127 -0
- package/corpus/templates/slides-2/actions/db-health.ts +22 -0
- package/corpus/templates/slides-2/actions/delete-asset.ts +154 -0
- package/corpus/templates/slides-2/actions/delete-deck.ts +427 -0
- package/corpus/templates/slides-2/actions/delete-design-system.ts +167 -0
- package/corpus/templates/slides-2/actions/delete-slide-comment.ts +143 -0
- package/corpus/templates/slides-2/actions/delete-staged-dataset.ts +30 -0
- package/corpus/templates/slides-2/actions/duplicate-deck.ts +299 -0
- package/corpus/templates/slides-2/actions/export-google-slides.ts +41 -0
- package/corpus/templates/slides-2/actions/export-html.ts +770 -0
- package/corpus/templates/slides-2/actions/export-pptx.ts +2203 -0
- package/corpus/templates/slides-2/actions/extract-pdf.ts +49 -0
- package/corpus/templates/slides-2/actions/generate-image-api.ts +671 -0
- package/corpus/templates/slides-2/actions/generate-image.ts +492 -0
- package/corpus/templates/slides-2/actions/get-agent-access-deck.ts +52 -0
- package/corpus/templates/slides-2/actions/get-deck-access-status.ts +130 -0
- package/corpus/templates/slides-2/actions/get-deck-design-tokens.ts +62 -0
- package/corpus/templates/slides-2/actions/get-deck-reference-context.ts +232 -0
- package/corpus/templates/slides-2/actions/get-deck-template.ts +38 -0
- package/corpus/templates/slides-2/actions/get-deck-version.ts +85 -0
- package/corpus/templates/slides-2/actions/get-deck.ts +562 -0
- package/corpus/templates/slides-2/actions/get-design-system-decode-job-status.ts +57 -0
- package/corpus/templates/slides-2/actions/get-design-system-tier-limit.ts +12 -0
- package/corpus/templates/slides-2/actions/get-design-system.ts +453 -0
- package/corpus/templates/slides-2/actions/get-google-docs-status.ts +106 -0
- package/corpus/templates/slides-2/actions/get-google-picker-token.ts +84 -0
- package/corpus/templates/slides-2/actions/get-home-suggestions.ts +52 -0
- package/corpus/templates/slides-2/actions/get-layout-overflows.ts +192 -0
- package/corpus/templates/slides-2/actions/get-slide-render.ts +125 -0
- package/corpus/templates/slides-2/actions/get-slide-source.ts +115 -0
- package/corpus/templates/slides-2/actions/get-slide-theme-preview.ts +64 -0
- package/corpus/templates/slides-2/actions/get-slide-theme.ts +44 -0
- package/corpus/templates/slides-2/actions/get-slides-2-upload-storage-status.ts +17 -0
- package/corpus/templates/slides-2/actions/get-slides-notification-prefs.ts +37 -0
- package/corpus/templates/slides-2/actions/get-workspace-defaults.ts +51 -0
- package/corpus/templates/slides-2/actions/image-gen-status.ts +35 -0
- package/corpus/templates/slides-2/actions/import-code.ts +26 -0
- package/corpus/templates/slides-2/actions/import-design-project.ts +49 -0
- package/corpus/templates/slides-2/actions/import-document.ts +125 -0
- package/corpus/templates/slides-2/actions/import-docx.ts +57 -0
- package/corpus/templates/slides-2/actions/import-file.ts +1273 -0
- package/corpus/templates/slides-2/actions/import-from-url.ts +25 -0
- package/corpus/templates/slides-2/actions/import-google-doc.ts +208 -0
- package/corpus/templates/slides-2/actions/import-google-font.ts +110 -0
- package/corpus/templates/slides-2/actions/import-google-slides-reference.ts +667 -0
- package/corpus/templates/slides-2/actions/import-pptx.ts +564 -0
- package/corpus/templates/slides-2/actions/import-svgl-logo.ts +115 -0
- package/corpus/templates/slides-2/actions/index-design-system-with-builder.ts +181 -0
- package/corpus/templates/slides-2/actions/index-uploaded-design-system-files.ts +77 -0
- package/corpus/templates/slides-2/actions/list-assets.ts +286 -0
- package/corpus/templates/slides-2/actions/list-deck-templates.ts +83 -0
- package/corpus/templates/slides-2/actions/list-deck-versions.ts +185 -0
- package/corpus/templates/slides-2/actions/list-decks.ts +591 -0
- package/corpus/templates/slides-2/actions/list-design-systems.ts +180 -0
- package/corpus/templates/slides-2/actions/list-slide-comments.ts +128 -0
- package/corpus/templates/slides-2/actions/list-slide-themes.ts +17 -0
- package/corpus/templates/slides-2/actions/list-staged-datasets.ts +14 -0
- package/corpus/templates/slides-2/actions/logo-config.ts +13 -0
- package/corpus/templates/slides-2/actions/navigate.ts +158 -0
- package/corpus/templates/slides-2/actions/patch-deck.ts +2378 -0
- package/corpus/templates/slides-2/actions/provider-api-catalog.ts +25 -0
- package/corpus/templates/slides-2/actions/provider-api-docs.ts +83 -0
- package/corpus/templates/slides-2/actions/provider-api-request.ts +222 -0
- package/corpus/templates/slides-2/actions/query-staged-dataset.ts +83 -0
- package/corpus/templates/slides-2/actions/read-composer-source.ts +108 -0
- package/corpus/templates/slides-2/actions/request-deck-access.ts +803 -0
- package/corpus/templates/slides-2/actions/restore-deck-version.ts +203 -0
- package/corpus/templates/slides-2/actions/run.ts +2 -0
- package/corpus/templates/slides-2/actions/save-deck.ts +313 -0
- package/corpus/templates/slides-2/actions/search-google-fonts.ts +61 -0
- package/corpus/templates/slides-2/actions/search-images.ts +30 -0
- package/corpus/templates/slides-2/actions/search-logos.ts +23 -0
- package/corpus/templates/slides-2/actions/search-svgl-logos.ts +42 -0
- package/corpus/templates/slides-2/actions/set-default-design-system.ts +88 -0
- package/corpus/templates/slides-2/actions/set-workspace-defaults.ts +61 -0
- package/corpus/templates/slides-2/actions/start-design-system-upload.ts +80 -0
- package/corpus/templates/slides-2/actions/sync-design-system-with-builder.ts +84 -0
- package/corpus/templates/slides-2/actions/toggle-slide-comment-reaction.ts +150 -0
- package/corpus/templates/slides-2/actions/transform-slide-objects.ts +1528 -0
- package/corpus/templates/slides-2/actions/update-asset.ts +499 -0
- package/corpus/templates/slides-2/actions/update-deck-aspect-ratio.ts +95 -0
- package/corpus/templates/slides-2/actions/update-deck-design-tokens.ts +175 -0
- package/corpus/templates/slides-2/actions/update-design-system.ts +95 -0
- package/corpus/templates/slides-2/actions/update-slide-comment.ts +213 -0
- package/corpus/templates/slides-2/actions/update-slide-source.ts +353 -0
- package/corpus/templates/slides-2/actions/update-slide.ts +850 -0
- package/corpus/templates/slides-2/actions/update-slides-notification-prefs.ts +55 -0
- package/corpus/templates/slides-2/actions/view-screen.ts +1098 -0
- package/corpus/templates/slides-2/agent-native.app-skill.json +165 -0
- package/corpus/templates/slides-2/agent-native.config.ts +20 -0
- package/corpus/templates/slides-2/agent-native.json +18 -0
- package/corpus/templates/slides-2/app/components/ThemeToggle.tsx +47 -0
- package/corpus/templates/slides-2/app/components/comments/SlideCommentPins.tsx +781 -0
- package/corpus/templates/slides-2/app/components/comments/SlideCommentsPanel.tsx +1075 -0
- package/corpus/templates/slides-2/app/components/deck/DeckCard.tsx +304 -0
- package/corpus/templates/slides-2/app/components/deck/DeckFilterMenu.tsx +83 -0
- package/corpus/templates/slides-2/app/components/deck/ExcalidrawSlide.tsx +183 -0
- package/corpus/templates/slides-2/app/components/deck/MermaidRenderer.tsx +126 -0
- package/corpus/templates/slides-2/app/components/deck/SlideRenderer.tsx +1553 -0
- package/corpus/templates/slides-2/app/components/design-system/DesignSystemCard.tsx +235 -0
- package/corpus/templates/slides-2/app/components/design-system/DesignSystemSetup.tsx +2021 -0
- package/corpus/templates/slides-2/app/components/design-system/builder-design-system-upload.ts +200 -0
- package/corpus/templates/slides-2/app/components/design-system/builder-index-response.ts +104 -0
- package/corpus/templates/slides-2/app/components/editor/AddSlidePopover.tsx +461 -0
- package/corpus/templates/slides-2/app/components/editor/AiEditingMarker.tsx +24 -0
- package/corpus/templates/slides-2/app/components/editor/AlignmentGuides.tsx +82 -0
- package/corpus/templates/slides-2/app/components/editor/AnimationsPanel.tsx +698 -0
- package/corpus/templates/slides-2/app/components/editor/AppMenu.tsx +356 -0
- package/corpus/templates/slides-2/app/components/editor/AssetLibraryPanel.tsx +508 -0
- package/corpus/templates/slides-2/app/components/editor/BlockBubbleMenu.tsx +548 -0
- package/corpus/templates/slides-2/app/components/editor/DeckAccessDeniedPage.tsx +173 -0
- package/corpus/templates/slides-2/app/components/editor/DeckEditorSkeleton.tsx +35 -0
- package/corpus/templates/slides-2/app/components/editor/DeferredPopoverFallback.tsx +148 -0
- package/corpus/templates/slides-2/app/components/editor/EditorActionCluster.tsx +217 -0
- package/corpus/templates/slides-2/app/components/editor/EditorSidebar.tsx +1047 -0
- package/corpus/templates/slides-2/app/components/editor/EditorToolbar.tsx +1285 -0
- package/corpus/templates/slides-2/app/components/editor/ExportMenu.tsx +579 -0
- package/corpus/templates/slides-2/app/components/editor/GeneratingOverlay.tsx +21 -0
- package/corpus/templates/slides-2/app/components/editor/GeneratingSlidePreview.tsx +73 -0
- package/corpus/templates/slides-2/app/components/editor/GoogleDocImportHint.tsx +378 -0
- package/corpus/templates/slides-2/app/components/editor/GoogleDriveConnectionCta.tsx +154 -0
- package/corpus/templates/slides-2/app/components/editor/GoogleSlidesReferenceImport.tsx +299 -0
- package/corpus/templates/slides-2/app/components/editor/HistoryPanel.tsx +354 -0
- package/corpus/templates/slides-2/app/components/editor/HomeQuickStartDialog.tsx +202 -0
- package/corpus/templates/slides-2/app/components/editor/ImageCropOverlay.tsx +820 -0
- package/corpus/templates/slides-2/app/components/editor/ImageDropPromptPopover.tsx +280 -0
- package/corpus/templates/slides-2/app/components/editor/ImageGenPanel.tsx +244 -0
- package/corpus/templates/slides-2/app/components/editor/ImageOverlay.tsx +280 -0
- package/corpus/templates/slides-2/app/components/editor/ImageSearchPanel.tsx +183 -0
- package/corpus/templates/slides-2/app/components/editor/ImportDeckButton.tsx +247 -0
- package/corpus/templates/slides-2/app/components/editor/LogoSearchPanel.tsx +366 -0
- package/corpus/templates/slides-2/app/components/editor/MermaidToExcalidrawPanel.tsx +99 -0
- package/corpus/templates/slides-2/app/components/editor/MissingDeckAccessPane.tsx +219 -0
- package/corpus/templates/slides-2/app/components/editor/NewDeckReferenceStep.tsx +812 -0
- package/corpus/templates/slides-2/app/components/editor/PromptDialog.tsx +963 -0
- package/corpus/templates/slides-2/app/components/editor/QuestionFlow.tsx +119 -0
- package/corpus/templates/slides-2/app/components/editor/RequestDeckAccessDialog.tsx +101 -0
- package/corpus/templates/slides-2/app/components/editor/ShareDialog.tsx +126 -0
- package/corpus/templates/slides-2/app/components/editor/SlideContextToolbar.tsx +1471 -0
- package/corpus/templates/slides-2/app/components/editor/SlideEditor.tsx +11183 -0
- package/corpus/templates/slides-2/app/components/editor/SlideOverflowWarning.tsx +82 -0
- package/corpus/templates/slides-2/app/components/editor/SlideScrollStack.tsx +307 -0
- package/corpus/templates/slides-2/app/components/editor/SlideSlashCommandMenu.tsx +692 -0
- package/corpus/templates/slides-2/app/components/editor/SlideThumbnailContextMenu.tsx +52 -0
- package/corpus/templates/slides-2/app/components/editor/SlideTransitionControl.tsx +184 -0
- package/corpus/templates/slides-2/app/components/editor/SlidesComposerContext.tsx +789 -0
- package/corpus/templates/slides-2/app/components/editor/SlidesComposerContextProvider.tsx +74 -0
- package/corpus/templates/slides-2/app/components/editor/SlidesLayersPanel.tsx +377 -0
- package/corpus/templates/slides-2/app/components/editor/SpeakerNotesPanel.tsx +119 -0
- package/corpus/templates/slides-2/app/components/editor/TweaksPanel.tsx +77 -0
- package/corpus/templates/slides-2/app/components/editor/UploadStorageGate.tsx +37 -0
- package/corpus/templates/slides-2/app/components/editor/bullet-editing.ts +880 -0
- package/corpus/templates/slides-2/app/components/editor/canvas-interactions/index.ts +12 -0
- package/corpus/templates/slides-2/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +119 -0
- package/corpus/templates/slides-2/app/components/editor/commit-active-edit.ts +14 -0
- package/corpus/templates/slides-2/app/components/editor/editor-command-model.ts +35 -0
- package/corpus/templates/slides-2/app/components/editor/fit-text-object.ts +31 -0
- package/corpus/templates/slides-2/app/components/editor/in-place-text-session.browser-cases.json +983 -0
- package/corpus/templates/slides-2/app/components/editor/in-place-text-session.browser-host.ts +747 -0
- package/corpus/templates/slides-2/app/components/editor/in-place-text-session.ts +6891 -0
- package/corpus/templates/slides-2/app/components/editor/inline-edit-session.ts +26 -0
- package/corpus/templates/slides-2/app/components/editor/list-editing.ts +501 -0
- package/corpus/templates/slides-2/app/components/editor/rich-text-selection.ts +975 -0
- package/corpus/templates/slides-2/app/components/editor/rte-test-utils.ts +265 -0
- package/corpus/templates/slides-2/app/components/editor/selection-overlay-measurement.ts +191 -0
- package/corpus/templates/slides-2/app/components/editor/slide-escape-arbiter.ts +34 -0
- package/corpus/templates/slides-2/app/components/editor/slide-object-interactions.ts +6362 -0
- package/corpus/templates/slides-2/app/components/editor/slide-object-transform.browser-host.ts +19 -0
- package/corpus/templates/slides-2/app/components/editor/slide-pointer-target.ts +432 -0
- package/corpus/templates/slides-2/app/components/editor/slide-presence.ts +13 -0
- package/corpus/templates/slides-2/app/components/editor/slide-style.ts +243 -0
- package/corpus/templates/slides-2/app/components/editor/slide-text-targets.ts +540 -0
- package/corpus/templates/slides-2/app/components/editor/style-clipboard.ts +102 -0
- package/corpus/templates/slides-2/app/components/editor/use-prompt-import.ts +159 -0
- package/corpus/templates/slides-2/app/components/home/SlidesHomeLibrary.tsx +79 -0
- package/corpus/templates/slides-2/app/components/layout/AgentWorkIndicator.tsx +193 -0
- package/corpus/templates/slides-2/app/components/layout/Header.tsx +110 -0
- package/corpus/templates/slides-2/app/components/layout/Layout.tsx +492 -0
- package/corpus/templates/slides-2/app/components/layout/Sidebar.tsx +109 -0
- package/corpus/templates/slides-2/app/components/layout/layout-route-policy.ts +28 -0
- package/corpus/templates/slides-2/app/components/presentation/PresentationView.tsx +1116 -0
- package/corpus/templates/slides-2/app/components/presentation/PresenterView.tsx +526 -0
- package/corpus/templates/slides-2/app/components/presentation/SlideTransitionStage.tsx +297 -0
- package/corpus/templates/slides-2/app/components/presentation/present-channel.ts +31 -0
- package/corpus/templates/slides-2/app/components/presentation/slide-build-steps.ts +231 -0
- package/corpus/templates/slides-2/app/components/presentation/slide-navigation.ts +273 -0
- package/corpus/templates/slides-2/app/components/presentation/slide-transition-motion.ts +258 -0
- package/corpus/templates/slides-2/app/components/presentation/voice-navigation.ts +61 -0
- package/corpus/templates/slides-2/app/components/settings/notification-settings.tsx +93 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2AssetBrowser.tsx +726 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2CommandMenu.tsx +453 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2Comments.tsx +571 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2DesignTokens.tsx +345 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2Editor.tsx +4804 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2ExportMenu.tsx +671 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2FontBrowser.tsx +342 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2ImageCropControls.tsx +487 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2Inspector.tsx +950 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2SvglLogoSearchDialog.tsx +332 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/cross-slide-edit-history.ts +151 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/design-token-presets.ts +140 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/editor-action-errors.ts +47 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/editor-export-errors.ts +60 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/geometry.ts +275 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/image-crop-style.ts +82 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/inline-text-editor.tsx +631 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/keyboard-shortcuts.ts +104 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/object-insertion.ts +13 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/preview-patches.ts +54 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/sandbox-render-errors.ts +23 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/source-structure.ts +634 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/types.ts +85 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2BlackoutOverlay.tsx +13 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2ControlBar.tsx +285 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2HelpDialog.tsx +72 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2JumpInput.tsx +38 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2LaserPointer.tsx +67 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2Overview.tsx +161 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2Player.tsx +839 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2ProgressBar.tsx +23 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/keyboard.ts +36 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/presenter-channel.ts +131 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/use-presenter-action-bridge.ts +296 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/useSlides2TouchSwipe.ts +80 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/SandboxedSlide.tsx +724 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/SlideContentRenderer.tsx +137 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/Slides2Canvas.tsx +99 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/constants.ts +4 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/protocol.ts +1400 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/transition-frame.ts +439 -0
- package/corpus/templates/slides-2/app/components/templates/DeckTemplateLibrary.tsx +314 -0
- package/corpus/templates/slides-2/app/components/templates/DeckTemplatePreview.tsx +60 -0
- package/corpus/templates/slides-2/app/components/templates/DeckTemplateStage.tsx +45 -0
- package/corpus/templates/slides-2/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/avatar.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/button-group.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/button.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/card.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/command.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/context-menu.tsx +32 -0
- package/corpus/templates/slides-2/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/filter-trigger.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/input.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/label.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/progress.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/scroll-area.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/select.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/separator.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/slider.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/spinner.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/tabs.tsx +59 -0
- package/corpus/templates/slides-2/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/toggle-group.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/templates/slides-2/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/slides-2/app/components/visual-editor/CanvasCommentPins.tsx +46 -0
- package/corpus/templates/slides-2/app/components/visual-editor/DrawOverlay.tsx +27 -0
- package/corpus/templates/slides-2/app/components/visual-editor/MultiSelectChip.tsx +97 -0
- package/corpus/templates/slides-2/app/components/visual-editor/SaveStatusIndicator.tsx +273 -0
- package/corpus/templates/slides-2/app/components/visual-editor/index.ts +4 -0
- package/corpus/templates/slides-2/app/context/DeckContext.tsx +7486 -0
- package/corpus/templates/slides-2/app/design-system.ts +3 -0
- package/corpus/templates/slides-2/app/entry.client.tsx +10 -0
- package/corpus/templates/slides-2/app/entry.server.tsx +10 -0
- package/corpus/templates/slides-2/app/global.css +1626 -0
- package/corpus/templates/slides-2/app/hooks/use-agent-generating.ts +517 -0
- package/corpus/templates/slides-2/app/hooks/use-compact-editor-layout.ts +26 -0
- package/corpus/templates/slides-2/app/hooks/use-contrast-audit-bridge.ts +49 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-access-reload.ts +70 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-access.ts +50 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-design-system.ts +146 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-history-action-bridge.ts +266 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-presence.ts +89 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-role.ts +46 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-versions.ts +43 -0
- package/corpus/templates/slides-2/app/hooks/use-design-system-workflows.ts +11 -0
- package/corpus/templates/slides-2/app/hooks/use-design-systems.ts +31 -0
- package/corpus/templates/slides-2/app/hooks/use-generating-slide-preview.ts +115 -0
- package/corpus/templates/slides-2/app/hooks/use-navigation-state.ts +229 -0
- package/corpus/templates/slides-2/app/hooks/use-new-deck-generation-signal.ts +46 -0
- package/corpus/templates/slides-2/app/hooks/use-new-deck-generation.ts +710 -0
- package/corpus/templates/slides-2/app/hooks/use-sidebar-collapsed.ts +95 -0
- package/corpus/templates/slides-2/app/hooks/use-slide-comments.ts +202 -0
- package/corpus/templates/slides-2/app/hooks/use-slide-file-storage-status.ts +55 -0
- package/corpus/templates/slides-2/app/hooks/use-undo-selection.ts +66 -0
- package/corpus/templates/slides-2/app/hooks/use-workspace-defaults.ts +31 -0
- package/corpus/templates/slides-2/app/i18n/en-US.ts +1507 -0
- package/corpus/templates/slides-2/app/i18n/index.ts +19 -0
- package/corpus/templates/slides-2/app/lib/agent-visible-message.ts +21 -0
- package/corpus/templates/slides-2/app/lib/aspect-ratios.ts +7 -0
- package/corpus/templates/slides-2/app/lib/asset-error-copy.ts +59 -0
- package/corpus/templates/slides-2/app/lib/canvas-zoom.ts +47 -0
- package/corpus/templates/slides-2/app/lib/composer-context.ts +152 -0
- package/corpus/templates/slides-2/app/lib/composer-draft.ts +34 -0
- package/corpus/templates/slides-2/app/lib/contrast-audit.ts +390 -0
- package/corpus/templates/slides-2/app/lib/contrast-resolve.ts +240 -0
- package/corpus/templates/slides-2/app/lib/create-deck-generation.ts +938 -0
- package/corpus/templates/slides-2/app/lib/deck-access-lost.ts +4 -0
- package/corpus/templates/slides-2/app/lib/deck-backup.ts +186 -0
- package/corpus/templates/slides-2/app/lib/deck-editor-loading.ts +91 -0
- package/corpus/templates/slides-2/app/lib/deck-export-file-client.ts +77 -0
- package/corpus/templates/slides-2/app/lib/deck-filter.ts +52 -0
- package/corpus/templates/slides-2/app/lib/deck-list-loading.ts +16 -0
- package/corpus/templates/slides-2/app/lib/deck-preview-frame.ts +15 -0
- package/corpus/templates/slides-2/app/lib/deck-share-links.ts +9 -0
- package/corpus/templates/slides-2/app/lib/deck-sorting.ts +19 -0
- package/corpus/templates/slides-2/app/lib/deferred-editor-surfaces.ts +24 -0
- package/corpus/templates/slides-2/app/lib/design-system-selection.ts +11 -0
- package/corpus/templates/slides-2/app/lib/design-systems.ts +231 -0
- package/corpus/templates/slides-2/app/lib/dynamic-import.ts +50 -0
- package/corpus/templates/slides-2/app/lib/editor-agent-handoff.ts +92 -0
- package/corpus/templates/slides-2/app/lib/editor-shortcuts.ts +153 -0
- package/corpus/templates/slides-2/app/lib/export-google-slides-client.ts +168 -0
- package/corpus/templates/slides-2/app/lib/export-pdf-client.ts +684 -0
- package/corpus/templates/slides-2/app/lib/export-pptx-client.ts +2420 -0
- package/corpus/templates/slides-2/app/lib/generation-lifecycle.ts +24 -0
- package/corpus/templates/slides-2/app/lib/generation-state.ts +247 -0
- package/corpus/templates/slides-2/app/lib/google-docs-client.ts +110 -0
- package/corpus/templates/slides-2/app/lib/google-slides-export-availability-client.ts +53 -0
- package/corpus/templates/slides-2/app/lib/google-slides-reference-source.ts +18 -0
- package/corpus/templates/slides-2/app/lib/image-download.ts +85 -0
- package/corpus/templates/slides-2/app/lib/image-drop-to-agent.ts +210 -0
- package/corpus/templates/slides-2/app/lib/import-uploaded-deck.ts +132 -0
- package/corpus/templates/slides-2/app/lib/inline-edit-remote.ts +55 -0
- package/corpus/templates/slides-2/app/lib/localize-slides-changelog.ts +47 -0
- package/corpus/templates/slides-2/app/lib/mermaid-blocks.ts +18 -0
- package/corpus/templates/slides-2/app/lib/new-deck-reference-selection.ts +174 -0
- package/corpus/templates/slides-2/app/lib/normalize-slide-padding.ts +74 -0
- package/corpus/templates/slides-2/app/lib/pending-deck-changes.ts +33 -0
- package/corpus/templates/slides-2/app/lib/portaled-layer.ts +7 -0
- package/corpus/templates/slides-2/app/lib/pptx-google-slides.ts +204 -0
- package/corpus/templates/slides-2/app/lib/prompt-attachment-adapter.ts +37 -0
- package/corpus/templates/slides-2/app/lib/prompt-file-uploads.ts +557 -0
- package/corpus/templates/slides-2/app/lib/recent-references.ts +106 -0
- package/corpus/templates/slides-2/app/lib/reference-document-hydration.ts +406 -0
- package/corpus/templates/slides-2/app/lib/register-chat-renderers.tsx +645 -0
- package/corpus/templates/slides-2/app/lib/reveal-after-delete.ts +55 -0
- package/corpus/templates/slides-2/app/lib/sanitize-slide-html.ts +752 -0
- package/corpus/templates/slides-2/app/lib/slide-agent-context.ts +148 -0
- package/corpus/templates/slides-2/app/lib/slide-animation-elements.ts +900 -0
- package/corpus/templates/slides-2/app/lib/slide-clipboard.ts +534 -0
- package/corpus/templates/slides-2/app/lib/slide-comment-anchor.ts +286 -0
- package/corpus/templates/slides-2/app/lib/slide-content-merge.ts +295 -0
- package/corpus/templates/slides-2/app/lib/slide-image-replacement.ts +1919 -0
- package/corpus/templates/slides-2/app/lib/slide-live-remote.ts +215 -0
- package/corpus/templates/slides-2/app/lib/slide-scroll.ts +56 -0
- package/corpus/templates/slides-2/app/lib/slide-source-map.ts +1099 -0
- package/corpus/templates/slides-2/app/lib/slide-video.ts +390 -0
- package/corpus/templates/slides-2/app/lib/slides-relay-tracking.ts +114 -0
- package/corpus/templates/slides-2/app/lib/streaming-slide-html.ts +77 -0
- package/corpus/templates/slides-2/app/lib/tab-id.ts +3 -0
- package/corpus/templates/slides-2/app/lib/template-navigation.ts +15 -0
- package/corpus/templates/slides-2/app/lib/text-tool-shortcut.ts +75 -0
- package/corpus/templates/slides-2/app/lib/undo-reveal.ts +332 -0
- package/corpus/templates/slides-2/app/lib/upload-response.ts +107 -0
- package/corpus/templates/slides-2/app/lib/utils.ts +38 -0
- package/corpus/templates/slides-2/app/lib/validate-native-slide-html.ts +177 -0
- package/corpus/templates/slides-2/app/lib/video-upload.ts +354 -0
- package/corpus/templates/slides-2/app/pages/DeckEditor.tsx +6158 -0
- package/corpus/templates/slides-2/app/pages/DesignSystems.tsx +363 -0
- package/corpus/templates/slides-2/app/pages/Index.tsx +3254 -0
- package/corpus/templates/slides-2/app/pages/NotFound.tsx +33 -0
- package/corpus/templates/slides-2/app/pages/Presentation.tsx +120 -0
- package/corpus/templates/slides-2/app/pages/SharedPresentation.tsx +174 -0
- package/corpus/templates/slides-2/app/pages/SlideThemeDetail.tsx +227 -0
- package/corpus/templates/slides-2/app/pages/SlideThemes.tsx +155 -0
- package/corpus/templates/slides-2/app/pages/Slides2EditorPage.tsx +1618 -0
- package/corpus/templates/slides-2/app/pages/Slides2PresenterConsolePage.tsx +937 -0
- package/corpus/templates/slides-2/app/pages/Slides2PresenterPage.tsx +979 -0
- package/corpus/templates/slides-2/app/pages/Templates.tsx +32 -0
- package/corpus/templates/slides-2/app/root.tsx +391 -0
- package/corpus/templates/slides-2/app/routes/$.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/_index.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/access-request.approve.tsx +276 -0
- package/corpus/templates/slides-2/app/routes/agent.tsx +19 -0
- package/corpus/templates/slides-2/app/routes/chat.$threadId.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/chat.tsx +190 -0
- package/corpus/templates/slides-2/app/routes/deck.$id.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/deck.$id_.present.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/design-systems.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/extensions.$id.$slug.tsx +2 -0
- package/corpus/templates/slides-2/app/routes/extensions.$id.tsx +5 -0
- package/corpus/templates/slides-2/app/routes/extensions._index.tsx +5 -0
- package/corpus/templates/slides-2/app/routes/extensions.tsx +5 -0
- package/corpus/templates/slides-2/app/routes/home-layout.tsx +31 -0
- package/corpus/templates/slides-2/app/routes/home.tsx +22 -0
- package/corpus/templates/slides-2/app/routes/p.$id.tsx +195 -0
- package/corpus/templates/slides-2/app/routes/settings.$.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/settings.tsx +131 -0
- package/corpus/templates/slides-2/app/routes/share.$token.tsx +137 -0
- package/corpus/templates/slides-2/app/routes/slide.tsx +209 -0
- package/corpus/templates/slides-2/app/routes/team.tsx +11 -0
- package/corpus/templates/slides-2/app/routes/templates.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/themes.$id.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/themes.tsx +1 -0
- package/corpus/templates/slides-2/app/routes.ts +24 -0
- package/corpus/templates/slides-2/app/vite-env.d.ts +24 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-find-and-switch-decks-from-the-presenter-console.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-meet-slides-2-create-and-refine-editable-slide-decks-with-an.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-pptx-image-export.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-visual-editor.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-apply-an-accessible-design-system-to-an-existing-deck-before.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-choose-a-template-or-start-a-new-presentation-from-the-slide.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-generate-decks-from-a-prompt-then-edit-slide-elements-direct.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-generate-presentation-decks-from-a-prompt-and-edit-every-sli.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-new-presentation-drafts-save-before-generation-starts-so-you.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-the-assistant-can-undo-redo-and-save-pending-edits-in-the-vi.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-agents-can-insert-duplicate-and-delete-canvas-objects-in-sou.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-browse-slide-themes.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-clicking-a-slide-preview-in-overview-selects-that-slide.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-create-decks-from-a-prompt-and-edit-slides-directly-on-the-c.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-creating-and-editing-decks-now-starts-with-the-tools-most-re.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-deleting-decks-revokes-public-links.md +7 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-escape-cancels-an-in-progress-slide-drag-without-losing-earl.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-import-failures-now-show-clear-localized-descriptions-instea.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-presenter-controls-stay-responsive-when-moving-over-the-slid.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-presenter-notes-stay-private-from-viewers-and-commenters.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-preview-generated-slides-in-chat.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-remote-image-previews-accept-supported-raster-formats.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-search-the-svgl-catalog-and-add-svg-logos-to-a-deck-or-the-g.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-slide-generation-explains-when-react-effect-hooks-cannot-run.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-the-editor-highlights-hovered-objects-and-keeps-image-replac.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-the-slide-editor-uses-the-shared-agent-native-controls.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-deck-editing-controls-match-the-workspace.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-google-slides-imports-now-report-missing-image-data-instead-.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-imports-and-previews-handle-large-content-safely.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-public-deck-pages-can-export-source-backed-slides-to-pdf.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-saved-slide-images-stay-available.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-scope-global-media-picks-to-assets-the-current-deck-can-reso.md +6 -0
- package/corpus/templates/slides-2/components.json +20 -0
- package/corpus/templates/slides-2/drizzle.config.ts +3 -0
- package/corpus/templates/slides-2/learnings.defaults.md +5 -0
- package/corpus/templates/slides-2/netlify.toml +24 -0
- package/corpus/templates/slides-2/package.json +147 -0
- package/corpus/templates/slides-2/public/agent-native-icon-dark.svg +10 -0
- package/corpus/templates/slides-2/public/agent-native-icon-light.svg +10 -0
- package/corpus/templates/slides-2/public/agent-native-logo-dark.svg +21 -0
- package/corpus/templates/slides-2/public/agent-native-logo-light.svg +21 -0
- package/corpus/templates/slides-2/public/assets/builder-logo-white.svg +15 -0
- package/corpus/templates/slides-2/public/assets/generated/preview.html +61 -0
- package/corpus/templates/slides-2/public/assets/intuit-logo-white.svg +6 -0
- package/corpus/templates/slides-2/public/assets/walmart-logo-white.svg +6 -0
- package/corpus/templates/slides-2/public/chatgpt-plugin-icon.svg +7 -0
- package/corpus/templates/slides-2/public/favicon.svg +1 -0
- package/corpus/templates/slides-2/public/icon-180.svg +1 -0
- package/corpus/templates/slides-2/public/icon-192.svg +1 -0
- package/corpus/templates/slides-2/public/icon-512.svg +1 -0
- package/corpus/templates/slides-2/public/manifest.json +20 -0
- package/corpus/templates/slides-2/public/placeholder.svg +1 -0
- package/corpus/templates/slides-2/public/robots.txt +14 -0
- package/corpus/templates/slides-2/public/visual-edit-structure-proof.html +99 -0
- package/corpus/templates/slides-2/react-router.config.ts +7 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/README.md +499 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/authoring-fuzz.ts +9517 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/baseline.json +16427 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/dev-server-url.ts +10 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/lib/in-page.ts +1975 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/lib/metrics.ts +1401 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/retry-infra.ts +7 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/run-options.ts +21 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/run-outcomes.ts +127 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/run.ts +8451 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/README.md +116 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/compare-layout-lib.ts +241 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/compare-layout.ts +30 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/diff.ts +222 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/export.ts +765 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/fixtures/agent-dark-deck.json +48 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/generate-calibration.ts +765 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/google-export.ts +137 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/google-layout.ts +82 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/resolve-pkg.ts +29 -0
- package/corpus/templates/slides-2/scripts/migrate-production.ts +22 -0
- package/corpus/templates/slides-2/server/db/index.ts +73 -0
- package/corpus/templates/slides-2/server/db/schema.ts +189 -0
- package/corpus/templates/slides-2/server/handlers/assets-url.ts +13 -0
- package/corpus/templates/slides-2/server/handlers/assets.ts +3217 -0
- package/corpus/templates/slides-2/server/handlers/decks.ts +185 -0
- package/corpus/templates/slides-2/server/handlers/demo.ts +9 -0
- package/corpus/templates/slides-2/server/handlers/design-systems.ts +219 -0
- package/corpus/templates/slides-2/server/handlers/google-docs-auth.ts +165 -0
- package/corpus/templates/slides-2/server/handlers/image-gen.ts +153 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/gemini.ts +209 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/index.ts +61 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/openai.ts +288 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/types.ts +35 -0
- package/corpus/templates/slides-2/server/handlers/import/docx-parser.ts +31 -0
- package/corpus/templates/slides-2/server/handlers/import/html-converter.ts +1534 -0
- package/corpus/templates/slides-2/server/handlers/import/pdf-fidelity-parser.ts +1039 -0
- package/corpus/templates/slides-2/server/handlers/import/pdf-sidecar-reader.ts +81 -0
- package/corpus/templates/slides-2/server/handlers/import/pdf-style-digest.ts +187 -0
- package/corpus/templates/slides-2/server/handlers/import/pptx-assets.ts +155 -0
- package/corpus/templates/slides-2/server/handlers/import/pptx-parser.ts +57 -0
- package/corpus/templates/slides-2/server/handlers/request-auth-context.ts +108 -0
- package/corpus/templates/slides-2/server/handlers/share.ts +52 -0
- package/corpus/templates/slides-2/server/handlers/uploads-chunked.ts +1066 -0
- package/corpus/templates/slides-2/server/handlers/uploads.ts +457 -0
- package/corpus/templates/slides-2/server/lib/access-request-email.ts +66 -0
- package/corpus/templates/slides-2/server/lib/assets-image-delegation.ts +331 -0
- package/corpus/templates/slides-2/server/lib/bounded-multipart.ts +49 -0
- package/corpus/templates/slides-2/server/lib/builder-design-system-proxy.ts +122 -0
- package/corpus/templates/slides-2/server/lib/chat-attachments.ts +425 -0
- package/corpus/templates/slides-2/server/lib/chatgpt-directory-tools.ts +246 -0
- package/corpus/templates/slides-2/server/lib/chunked-upload-session.ts +195 -0
- package/corpus/templates/slides-2/server/lib/comment-notifications.ts +184 -0
- package/corpus/templates/slides-2/server/lib/deck-access-requests.ts +102 -0
- package/corpus/templates/slides-2/server/lib/deck-asset-scope.ts +150 -0
- package/corpus/templates/slides-2/server/lib/deck-export-tracking.ts +119 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-case-study.ts +154 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-company.ts +160 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-pitch.ts +151 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-quarterly.ts +264 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-shared.ts +35 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-update.ts +188 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-workshop.ts +196 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-keynote.ts +131 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-lesson.ts +209 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-manifesto.ts +149 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-portfolio.ts +144 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-research.ts +221 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-roadmap.ts +264 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-shared.ts +44 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/group-a.ts +16 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/group-b.ts +16 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/legacy.ts +567 -0
- package/corpus/templates/slides-2/server/lib/deck-templates.ts +60 -0
- package/corpus/templates/slides-2/server/lib/deck-versions.ts +233 -0
- package/corpus/templates/slides-2/server/lib/design-system-workflows.ts +22 -0
- package/corpus/templates/slides-2/server/lib/emails.ts +84 -0
- package/corpus/templates/slides-2/server/lib/env-config.ts +15 -0
- package/corpus/templates/slides-2/server/lib/fetch-remote-image.ts +245 -0
- package/corpus/templates/slides-2/server/lib/generation-completion.ts +278 -0
- package/corpus/templates/slides-2/server/lib/google-docs-access.ts +51 -0
- package/corpus/templates/slides-2/server/lib/google-docs-error.ts +54 -0
- package/corpus/templates/slides-2/server/lib/google-docs-oauth.ts +422 -0
- package/corpus/templates/slides-2/server/lib/google-fonts.ts +509 -0
- package/corpus/templates/slides-2/server/lib/google-oauth-preflight.ts +119 -0
- package/corpus/templates/slides-2/server/lib/google-slides-export-availability.ts +55 -0
- package/corpus/templates/slides-2/server/lib/image-proxy-response.ts +16 -0
- package/corpus/templates/slides-2/server/lib/image-proxy-url.ts +155 -0
- package/corpus/templates/slides-2/server/lib/import-asset-storage.ts +214 -0
- package/corpus/templates/slides-2/server/lib/imported-asset-batch.ts +218 -0
- package/corpus/templates/slides-2/server/lib/legacy-slide-source.ts +692 -0
- package/corpus/templates/slides-2/server/lib/media-search-providers.ts +216 -0
- package/corpus/templates/slides-2/server/lib/native-creative-context.ts +295 -0
- package/corpus/templates/slides-2/server/lib/pdf-parse-setup.ts +115 -0
- package/corpus/templates/slides-2/server/lib/provider-api.ts +57 -0
- package/corpus/templates/slides-2/server/lib/request-wait-until.ts +30 -0
- package/corpus/templates/slides-2/server/lib/shared-deck.ts +29 -0
- package/corpus/templates/slides-2/server/lib/slide-asset-references.ts +309 -0
- package/corpus/templates/slides-2/server/lib/slide-content-patch.ts +1004 -0
- package/corpus/templates/slides-2/server/lib/slide-hygiene.ts +731 -0
- package/corpus/templates/slides-2/server/lib/slide-image-insertion.ts +136 -0
- package/corpus/templates/slides-2/server/lib/slide-reveal-issues.ts +41 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/babel-walk.ts +117 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/batch-edit.ts +152 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/edit-ops.ts +1478 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/image-target.ts +128 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/text-diff.ts +23 -0
- package/corpus/templates/slides-2/server/lib/slide-source-limits.ts +9 -0
- package/corpus/templates/slides-2/server/lib/slide-source.ts +1786 -0
- package/corpus/templates/slides-2/server/lib/slide-theme-demo-sources.ts +2106 -0
- package/corpus/templates/slides-2/server/lib/slide-themes.ts +2174 -0
- package/corpus/templates/slides-2/server/lib/slide-worker-runtime.ts +1995 -0
- package/corpus/templates/slides-2/server/lib/slides-tracking.ts +73 -0
- package/corpus/templates/slides-2/server/lib/source-import.ts +213 -0
- package/corpus/templates/slides-2/server/lib/svgl.ts +364 -0
- package/corpus/templates/slides-2/server/lib/tenant-files.ts +179 -0
- package/corpus/templates/slides-2/server/lib/upload-storage-status.ts +9 -0
- package/corpus/templates/slides-2/server/lib/uploaded-asset-cleanup-outbox.ts +521 -0
- package/corpus/templates/slides-2/server/lib/uploaded-asset-object-lifecycle.ts +404 -0
- package/corpus/templates/slides-2/server/lib/uploaded-fonts.ts +696 -0
- package/corpus/templates/slides-2/server/lib/uploaded-reference-storage.ts +77 -0
- package/corpus/templates/slides-2/server/lib/validate-slide-animations.ts +341 -0
- package/corpus/templates/slides-2/server/middleware/auth.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/_dev-upload-stub.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/agent-chat.ts +402 -0
- package/corpus/templates/slides-2/server/plugins/auth.ts +31 -0
- package/corpus/templates/slides-2/server/plugins/collab.ts +30 -0
- package/corpus/templates/slides-2/server/plugins/config.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/core-routes.ts +30 -0
- package/corpus/templates/slides-2/server/plugins/creative-context.ts +187 -0
- package/corpus/templates/slides-2/server/plugins/db.ts +462 -0
- package/corpus/templates/slides-2/server/plugins/feature-flags.ts +5 -0
- package/corpus/templates/slides-2/server/plugins/labs.ts +8 -0
- package/corpus/templates/slides-2/server/plugins/orphaned-asset-cleanup.ts +17 -0
- package/corpus/templates/slides-2/server/plugins/otel.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/slides-2/server/register-secrets.ts +209 -0
- package/corpus/templates/slides-2/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/slides-2/server/routes/[...page].head.ts +1 -0
- package/corpus/templates/slides-2/server/routes/[base]/_agent-native/google-docs/auth-url.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/[base]/_agent-native/google-docs/callback.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/_agent-native/google-docs/auth-url.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/_agent-native/google-docs/callback.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/assets/upload-video.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/assets/upload.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/assets/video-uploads.delete.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/deck-agent-context.json.get.ts +105 -0
- package/corpus/templates/slides-2/server/routes/api/decks/events.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/demo.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/exports/[filename].get.ts +221 -0
- package/corpus/templates/slides-2/server/routes/api/exports/google-slides.post.ts +240 -0
- package/corpus/templates/slides-2/server/routes/api/exports/html.post.ts +67 -0
- package/corpus/templates/slides-2/server/routes/api/exports/pptx.post.ts +100 -0
- package/corpus/templates/slides-2/server/routes/api/gen-preview/[...].get.ts +24 -0
- package/corpus/templates/slides-2/server/routes/api/generated/[...].get.ts +24 -0
- package/corpus/templates/slides-2/server/routes/api/image-proxy.get.ts +518 -0
- package/corpus/templates/slides-2/server/routes/api/import-assets/[token].get.ts +70 -0
- package/corpus/templates/slides-2/server/routes/api/preview-images.get.ts +20 -0
- package/corpus/templates/slides-2/server/routes/api/share/[token].get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/[sessionId]/chunk.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/[sessionId]/status.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/[sessionId].delete.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/start.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads.delete.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads.post.ts +1 -0
- package/corpus/templates/slides-2/server/workspace-defaults.ts +196 -0
- package/corpus/templates/slides-2/shared/action-ui.ts +147 -0
- package/corpus/templates/slides-2/shared/agent-readable.ts +2 -0
- package/corpus/templates/slides-2/shared/api.ts +406 -0
- package/corpus/templates/slides-2/shared/app-state-tabs.ts +30 -0
- package/corpus/templates/slides-2/shared/app-storage.ts +9 -0
- package/corpus/templates/slides-2/shared/aspect-ratios.ts +49 -0
- package/corpus/templates/slides-2/shared/blank-slide.ts +179 -0
- package/corpus/templates/slides-2/shared/client-compatibility.ts +2 -0
- package/corpus/templates/slides-2/shared/contrast-audit.ts +255 -0
- package/corpus/templates/slides-2/shared/deck-access.ts +26 -0
- package/corpus/templates/slides-2/shared/deck-app-scope.ts +14 -0
- package/corpus/templates/slides-2/shared/deck-content.ts +37 -0
- package/corpus/templates/slides-2/shared/deck-history-control.ts +79 -0
- package/corpus/templates/slides-2/shared/deck-scope.ts +5 -0
- package/corpus/templates/slides-2/shared/deck-title.ts +199 -0
- package/corpus/templates/slides-2/shared/deck-write.ts +61 -0
- package/corpus/templates/slides-2/shared/design-flags.ts +7 -0
- package/corpus/templates/slides-2/shared/design-system-validation.ts +88 -0
- package/corpus/templates/slides-2/shared/editor-control.ts +120 -0
- package/corpus/templates/slides-2/shared/generation-timing.ts +19 -0
- package/corpus/templates/slides-2/shared/google-docs.ts +69 -0
- package/corpus/templates/slides-2/shared/labs.ts +10 -0
- package/corpus/templates/slides-2/shared/overview-navigation.ts +34 -0
- package/corpus/templates/slides-2/shared/ownership.ts +6 -0
- package/corpus/templates/slides-2/shared/pdf-sidecar.ts +130 -0
- package/corpus/templates/slides-2/shared/presenter-control.ts +111 -0
- package/corpus/templates/slides-2/shared/representative-slide.ts +89 -0
- package/corpus/templates/slides-2/shared/slide-background.ts +30 -0
- package/corpus/templates/slides-2/shared/slide-comment-anchor.ts +117 -0
- package/corpus/templates/slides-2/shared/slide-comment-reactions.ts +47 -0
- package/corpus/templates/slides-2/shared/slide-design-tokens.ts +92 -0
- package/corpus/templates/slides-2/shared/slide-fit.ts +78 -0
- package/corpus/templates/slides-2/shared/slide-ids.ts +133 -0
- package/corpus/templates/slides-2/shared/slide-number.ts +124 -0
- package/corpus/templates/slides-2/shared/slide-object-structure.ts +790 -0
- package/corpus/templates/slides-2/shared/slide-text-range-selection.ts +50 -0
- package/corpus/templates/slides-2/shared/slide-transitions.ts +70 -0
- package/corpus/templates/slides-2/shared/slides-2-transition.ts +194 -0
- package/corpus/templates/slides-2/shared/slides-user-prefs.ts +22 -0
- package/corpus/templates/slides-2/shared/source-import-errors.ts +12 -0
- package/corpus/templates/slides-2/shared/source-runtime-export.ts +76 -0
- package/corpus/templates/slides-2/shared/upload-types.ts +41 -0
- package/corpus/templates/slides-2/ssr-entry.ts +11 -0
- package/corpus/templates/slides-2/tsconfig.json +27 -0
- package/corpus/templates/slides-2/vite.config.ts +77 -0
- package/corpus/templates/slides-2/vitest.config.ts +28 -0
- package/corpus/templates/tasks/.agents/skills/actions/references/action-fields.md +1 -1
- package/package.json +1 -1
- package/corpus/templates/design/.agents/skills/shader-fills/SKILL.md +0 -182
- package/corpus/templates/design/actions/apply-shader-fill.ts +0 -450
- package/corpus/templates/design/actions/apply-shader.ts +0 -257
- package/corpus/templates/design/actions/preview-shader-fill.ts +0 -157
- package/corpus/templates/design/app/components/design/inspector/GlslShaderPanel.tsx +0 -1144
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +0 -450
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.stories.tsx +0 -71
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.tsx +0 -555
- package/corpus/templates/design/app/components/design/inspector/ShaderEffectRow.tsx +0 -105
- package/corpus/templates/design/app/components/design/inspector/ShaderFillsPanel.tsx +0 -433
- package/corpus/templates/design/app/components/design/inspector/color-picker-shader-pane.tsx +0 -648
- package/corpus/templates/design/shared/shader-fill.ts +0 -174
- package/corpus/templates/design/shared/shader-presets.ts +0 -1523
|
@@ -0,0 +1,2203 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { defineAction, fail } from "@agent-native/core/action";
|
|
5
|
+
import { ssrfSafeFetch } from "@agent-native/core/extensions/url-safety";
|
|
6
|
+
import { getRequestUserEmail } from "@agent-native/core/server/request-context";
|
|
7
|
+
import { resolveAccess } from "@agent-native/core/sharing";
|
|
8
|
+
import type PptxGenJS from "pptxgenjs";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
import "../server/db/index.js";
|
|
12
|
+
import {
|
|
13
|
+
trackDeckExported,
|
|
14
|
+
withExportFailureTracking,
|
|
15
|
+
} from "../server/lib/deck-export-tracking.js";
|
|
16
|
+
import { readLocalImportedAsset } from "../server/lib/import-asset-storage.js";
|
|
17
|
+
import { generationAttemptIdOf } from "../server/lib/slides-tracking.js";
|
|
18
|
+
import {
|
|
19
|
+
isHostedSlidesRuntime,
|
|
20
|
+
pruneHostedPptxExports,
|
|
21
|
+
pptxDeckBindingPath,
|
|
22
|
+
pptxExportRevisionKey,
|
|
23
|
+
safeGeneratedFilename,
|
|
24
|
+
tenantExportDir,
|
|
25
|
+
} from "../server/lib/tenant-files.js";
|
|
26
|
+
import {
|
|
27
|
+
type AspectRatio,
|
|
28
|
+
getAspectRatioDims,
|
|
29
|
+
ASPECT_RATIO_VALUES,
|
|
30
|
+
} from "../shared/aspect-ratios.js";
|
|
31
|
+
import { fillSlideNumberTokensInHtml } from "../shared/slide-number.js";
|
|
32
|
+
import { sourceRuntimeExportError } from "../shared/source-runtime-export.js";
|
|
33
|
+
import { getExportUrl } from "./_app-url.js";
|
|
34
|
+
import { assertSlides2DeckData } from "./_deck-app-scope.js";
|
|
35
|
+
import { canReadPresenterNotes } from "./_presenter-notes.js";
|
|
36
|
+
import { compileSlideSource } from "./_slide-source.js";
|
|
37
|
+
|
|
38
|
+
type TableCell = PptxGenJS.TableCell;
|
|
39
|
+
type TableRow = PptxGenJS.TableRow;
|
|
40
|
+
|
|
41
|
+
function getStyle(style: string, prop: string): string | null {
|
|
42
|
+
const re = new RegExp(`${prop}\\s*:\\s*([^;]+)`, "i");
|
|
43
|
+
const m = style.match(re);
|
|
44
|
+
return m ? m[1].trim() : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function colorToHex(color: string): { hex: string; transparency?: number } {
|
|
48
|
+
if (!color) return { hex: "FFFFFF" };
|
|
49
|
+
const parsed = parseCssColor(color);
|
|
50
|
+
if (parsed) return parsed;
|
|
51
|
+
console.warn(
|
|
52
|
+
`[export-pptx] unrecognized color "${color}", defaulting to white`,
|
|
53
|
+
);
|
|
54
|
+
return { hex: "FFFFFF" };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseCssColor(
|
|
58
|
+
color: string,
|
|
59
|
+
): { hex: string; transparency?: number } | undefined {
|
|
60
|
+
if (!color) return undefined;
|
|
61
|
+
|
|
62
|
+
color = color.replace(/['"]/g, "").trim();
|
|
63
|
+
|
|
64
|
+
if (/^#[0-9a-f]{8}$/i.test(color)) {
|
|
65
|
+
const alpha = parseInt(color.slice(7, 9), 16) / 255;
|
|
66
|
+
return {
|
|
67
|
+
hex: color.slice(1, 7).toUpperCase(),
|
|
68
|
+
transparency: Math.round((1 - alpha) * 100),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (/^#[0-9a-f]{6}$/i.test(color))
|
|
72
|
+
return { hex: color.slice(1).toUpperCase() };
|
|
73
|
+
if (/^#[0-9a-f]{3}$/i.test(color)) {
|
|
74
|
+
const r = color[1],
|
|
75
|
+
g = color[2],
|
|
76
|
+
b = color[3];
|
|
77
|
+
return { hex: `${r}${r}${g}${g}${b}${b}`.toUpperCase() };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const rgbMatch = color.match(
|
|
81
|
+
/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/,
|
|
82
|
+
);
|
|
83
|
+
if (rgbMatch) {
|
|
84
|
+
const hex = (n: string) => parseInt(n).toString(16).padStart(2, "0");
|
|
85
|
+
const result = {
|
|
86
|
+
hex: `${hex(rgbMatch[1])}${hex(rgbMatch[2])}${hex(rgbMatch[3])}`.toUpperCase(),
|
|
87
|
+
};
|
|
88
|
+
if (rgbMatch[4] === undefined) return result;
|
|
89
|
+
const alpha = parseFloat(rgbMatch[4]);
|
|
90
|
+
return { ...result, transparency: Math.round((1 - alpha) * 100) };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const named: Record<string, string> = {
|
|
94
|
+
white: "FFFFFF",
|
|
95
|
+
black: "000000",
|
|
96
|
+
transparent: "000000",
|
|
97
|
+
silver: "C0C0C0",
|
|
98
|
+
gray: "808080",
|
|
99
|
+
grey: "808080",
|
|
100
|
+
maroon: "800000",
|
|
101
|
+
red: "FF0000",
|
|
102
|
+
purple: "800080",
|
|
103
|
+
fuchsia: "FF00FF",
|
|
104
|
+
green: "008000",
|
|
105
|
+
lime: "00FF00",
|
|
106
|
+
olive: "808000",
|
|
107
|
+
yellow: "FFFF00",
|
|
108
|
+
navy: "000080",
|
|
109
|
+
blue: "0000FF",
|
|
110
|
+
teal: "008080",
|
|
111
|
+
aqua: "00FFFF",
|
|
112
|
+
};
|
|
113
|
+
const hex = named[color.toLowerCase()];
|
|
114
|
+
if (hex) return { hex };
|
|
115
|
+
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function cssFillToSolid(
|
|
120
|
+
value: string | null | undefined,
|
|
121
|
+
): { hex: string; transparency?: number } | undefined {
|
|
122
|
+
if (!value) return undefined;
|
|
123
|
+
if (!/gradient\(/i.test(value)) return colorToHex(value);
|
|
124
|
+
for (const stop of value.matchAll(/#[0-9a-f]{3,8}\b|rgba?\([^)]*\)/gi)) {
|
|
125
|
+
const parsed = colorToHex(stop[0]);
|
|
126
|
+
if ((parsed.transparency ?? 0) < 100) return parsed;
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const DEFAULT_DECK_FONT_FACE = "Poppins";
|
|
132
|
+
|
|
133
|
+
function cssFontFace(style: string): string | undefined {
|
|
134
|
+
return (
|
|
135
|
+
getStyle(style, "font-family")
|
|
136
|
+
?.replace(/["']/g, "")
|
|
137
|
+
.split(",")[0]
|
|
138
|
+
?.trim() || undefined
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function resolveShapeType(
|
|
143
|
+
shapeTypes: Record<string, string>,
|
|
144
|
+
shapeType: string | undefined,
|
|
145
|
+
): PptxGenJS.ShapeType {
|
|
146
|
+
if (!shapeType) return "rect" as PptxGenJS.ShapeType;
|
|
147
|
+
const known = shapeTypes[shapeType];
|
|
148
|
+
if (known) return known as PptxGenJS.ShapeType;
|
|
149
|
+
console.warn(
|
|
150
|
+
`[export-pptx] unrecognized shape geometry "${shapeType}", defaulting to a rectangle`,
|
|
151
|
+
);
|
|
152
|
+
return "rect" as PptxGenJS.ShapeType;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const CSS_BORDER_DASH_TYPES: Record<
|
|
156
|
+
string,
|
|
157
|
+
NonNullable<PptxGenJS.ShapeLineProps["dashType"]>
|
|
158
|
+
> = {
|
|
159
|
+
dashed: "dash",
|
|
160
|
+
dotted: "sysDot",
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const CSS_BORDER_STYLE_PATTERN =
|
|
164
|
+
/([\d.]+)px\s+(solid|dashed|dotted|double|groove|ridge|inset|outset)\s+(.+)/i;
|
|
165
|
+
|
|
166
|
+
interface ParsedCssBorder {
|
|
167
|
+
widthPx: number;
|
|
168
|
+
dashType?: NonNullable<PptxGenJS.ShapeLineProps["dashType"]>;
|
|
169
|
+
color: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const SINGLE_LINE_SPACING_RATIO = 1.2;
|
|
173
|
+
|
|
174
|
+
function cssLineHeightToSpacingMultiple(
|
|
175
|
+
lineHeight: number | undefined,
|
|
176
|
+
): number | undefined {
|
|
177
|
+
return lineHeight !== undefined &&
|
|
178
|
+
Number.isFinite(lineHeight) &&
|
|
179
|
+
lineHeight > 0
|
|
180
|
+
? lineHeight / SINGLE_LINE_SPACING_RATIO
|
|
181
|
+
: undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function parseCssBorder(
|
|
185
|
+
border: string | null | undefined,
|
|
186
|
+
): ParsedCssBorder | undefined {
|
|
187
|
+
const match = border?.match(CSS_BORDER_STYLE_PATTERN);
|
|
188
|
+
if (!match) return undefined;
|
|
189
|
+
return {
|
|
190
|
+
widthPx: Number.parseFloat(match[1]),
|
|
191
|
+
dashType: CSS_BORDER_DASH_TYPES[match[2].toLowerCase()],
|
|
192
|
+
color: match[3],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function pxToIn(
|
|
197
|
+
px: number,
|
|
198
|
+
dims: { width: number; pptxInches: { w: number } },
|
|
199
|
+
): number {
|
|
200
|
+
return (px / dims.width) * dims.pptxInches.w;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function pxToPt(
|
|
204
|
+
px: number,
|
|
205
|
+
dims: { width: number; pptxInches: { w: number } },
|
|
206
|
+
): number {
|
|
207
|
+
const pxPerInch = dims.width / dims.pptxInches.w;
|
|
208
|
+
return Math.round((px / pxPerInch) * 72);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const EMU_PER_INCH = 914400;
|
|
212
|
+
|
|
213
|
+
export function sourcePageInches(
|
|
214
|
+
html: string,
|
|
215
|
+
): { w: number; h: number } | undefined {
|
|
216
|
+
const widthEmu = Number(html.match(/data-slide-width-emu="(\d+)"/)?.[1]);
|
|
217
|
+
const heightEmu = Number(html.match(/data-slide-height-emu="(\d+)"/)?.[1]);
|
|
218
|
+
if (!widthEmu || !heightEmu) return undefined;
|
|
219
|
+
const w = widthEmu / EMU_PER_INCH;
|
|
220
|
+
const h = heightEmu / EMU_PER_INCH;
|
|
221
|
+
if (w < 1 || w > 56 || h < 1 || h > 56) {
|
|
222
|
+
console.warn(
|
|
223
|
+
`[export-pptx] ignoring out-of-range source page size ${widthEmu}x${heightEmu} EMU`,
|
|
224
|
+
);
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
return { w, h };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function withSourcePageInches(dims: SlideDims, html: string): SlideDims {
|
|
231
|
+
const pptxInches = sourcePageInches(html);
|
|
232
|
+
return pptxInches ? { ...dims, pptxInches } : dims;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
interface TextElement {
|
|
236
|
+
text: string;
|
|
237
|
+
fontSize?: number;
|
|
238
|
+
fontFace?: string;
|
|
239
|
+
color: string;
|
|
240
|
+
transparency?: number;
|
|
241
|
+
bold: boolean;
|
|
242
|
+
x: number;
|
|
243
|
+
y: number;
|
|
244
|
+
w: number;
|
|
245
|
+
h: number;
|
|
246
|
+
align?: "left" | "center" | "right";
|
|
247
|
+
letterSpacing?: number;
|
|
248
|
+
lineSpacingMultiple?: number;
|
|
249
|
+
runs?: TextRunElement[];
|
|
250
|
+
rotate?: number;
|
|
251
|
+
order?: number;
|
|
252
|
+
stack?: number;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
interface TextRunElement {
|
|
256
|
+
text: string;
|
|
257
|
+
options: {
|
|
258
|
+
fontSize?: number;
|
|
259
|
+
fontFace?: string;
|
|
260
|
+
color?: string;
|
|
261
|
+
transparency?: number;
|
|
262
|
+
bold?: boolean;
|
|
263
|
+
italic?: boolean;
|
|
264
|
+
underline?: { style: "sng" };
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
interface ImageElement {
|
|
269
|
+
src: string;
|
|
270
|
+
x: number;
|
|
271
|
+
y: number;
|
|
272
|
+
w: number;
|
|
273
|
+
h: number;
|
|
274
|
+
rotate?: number;
|
|
275
|
+
order?: number;
|
|
276
|
+
stack?: number;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface ShapeElement {
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
w: number;
|
|
283
|
+
h: number;
|
|
284
|
+
fill?: string;
|
|
285
|
+
fillTransparency?: number;
|
|
286
|
+
lineColor?: string;
|
|
287
|
+
lineTransparency?: number;
|
|
288
|
+
lineWidth?: number;
|
|
289
|
+
lineDashType?: NonNullable<PptxGenJS.ShapeLineProps["dashType"]>;
|
|
290
|
+
lineHeadType?: NonNullable<PptxGenJS.ShapeLineProps["beginArrowType"]>;
|
|
291
|
+
lineTailType?: NonNullable<PptxGenJS.ShapeLineProps["endArrowType"]>;
|
|
292
|
+
shapeType?: string;
|
|
293
|
+
rectRadius?: number;
|
|
294
|
+
points?: PptxGenJS.ShapeProps["points"];
|
|
295
|
+
rotate?: number;
|
|
296
|
+
order?: number;
|
|
297
|
+
stack?: number;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
interface TableElement {
|
|
301
|
+
rows: TableRow[];
|
|
302
|
+
x: number;
|
|
303
|
+
y: number;
|
|
304
|
+
w: number;
|
|
305
|
+
h: number;
|
|
306
|
+
colW?: number[];
|
|
307
|
+
rowH?: number[];
|
|
308
|
+
order?: number;
|
|
309
|
+
stack?: number;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
interface GridElement {
|
|
313
|
+
color: string;
|
|
314
|
+
transparency?: number;
|
|
315
|
+
stepX: number;
|
|
316
|
+
stepY: number;
|
|
317
|
+
offsetX: number;
|
|
318
|
+
offsetY: number;
|
|
319
|
+
lineWidth: number;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function assertServerPptxExportable(
|
|
323
|
+
html: string,
|
|
324
|
+
slideNumber: number,
|
|
325
|
+
): void {
|
|
326
|
+
const hasPersistedFreeformObject =
|
|
327
|
+
/\bdata-slide-object-id\s*=/i.test(html) ||
|
|
328
|
+
/\bclass\s*=\s*["'][^"']*\bfmd-freeform-object\b/i.test(html);
|
|
329
|
+
if (html.includes('data-imported-pptx="true"')) return;
|
|
330
|
+
if (!hasPersistedFreeformObject) return;
|
|
331
|
+
|
|
332
|
+
const error = new Error(
|
|
333
|
+
`Slide ${slideNumber} contains freeform positioned objects. Export this deck from the Slides 2 editor with Export > PowerPoint so browser-rendered geometry is preserved. The server export stopped instead of silently reflowing those objects.`,
|
|
334
|
+
);
|
|
335
|
+
error.name = "UnsupportedPositionedSlideExportError";
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
interface ParsedSlide {
|
|
340
|
+
texts: TextElement[];
|
|
341
|
+
images: ImageElement[];
|
|
342
|
+
shapes: ShapeElement[];
|
|
343
|
+
tables: TableElement[];
|
|
344
|
+
grid?: GridElement;
|
|
345
|
+
bgColor: string;
|
|
346
|
+
bgTransparency?: number;
|
|
347
|
+
bgGradient?: string;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function parseSlideHtml(
|
|
351
|
+
html: string,
|
|
352
|
+
aspectRatio?: AspectRatio,
|
|
353
|
+
slideNumber = 1,
|
|
354
|
+
): ParsedSlide {
|
|
355
|
+
assertServerPptxExportable(html, slideNumber);
|
|
356
|
+
const dims = withSourcePageInches(getAspectRatioDims(aspectRatio), html);
|
|
357
|
+
if (html.includes('data-imported-pdf="true"')) {
|
|
358
|
+
return parseImportedPdfSlideHtml(html, dims);
|
|
359
|
+
}
|
|
360
|
+
if (html.includes('data-imported-pptx="true"')) {
|
|
361
|
+
return parseImportedSlideHtml(html, dims);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const texts: TextElement[] = [];
|
|
365
|
+
const images: ImageElement[] = [];
|
|
366
|
+
const shapes: ShapeElement[] = [];
|
|
367
|
+
let bgColor = "000000";
|
|
368
|
+
let bgTransparency: number | undefined;
|
|
369
|
+
|
|
370
|
+
const slideW = dims.pptxInches.w;
|
|
371
|
+
const slideH = dims.pptxInches.h;
|
|
372
|
+
|
|
373
|
+
const slideStyleMatch = html.match(/class="fmd-slide"[^>]*style="([^"]*)"/);
|
|
374
|
+
const slideBackground = slideStyleMatch
|
|
375
|
+
? getStyle(slideStyleMatch[1], "background(?:-color)?")
|
|
376
|
+
: null;
|
|
377
|
+
const bgGradient =
|
|
378
|
+
slideBackground && /gradient\(/i.test(slideBackground)
|
|
379
|
+
? slideBackground
|
|
380
|
+
: undefined;
|
|
381
|
+
const parsedBg = cssFillToSolid(slideBackground);
|
|
382
|
+
if (parsedBg) {
|
|
383
|
+
bgColor = parsedBg.hex;
|
|
384
|
+
bgTransparency = parsedBg.transparency;
|
|
385
|
+
}
|
|
386
|
+
const slideFontFace = slideStyleMatch
|
|
387
|
+
? cssFontFace(slideStyleMatch[1])
|
|
388
|
+
: undefined;
|
|
389
|
+
|
|
390
|
+
const paddingStr = slideStyleMatch
|
|
391
|
+
? getStyle(slideStyleMatch[1], "padding")
|
|
392
|
+
: null;
|
|
393
|
+
let padTop = 80,
|
|
394
|
+
padLeft = 110;
|
|
395
|
+
if (paddingStr) {
|
|
396
|
+
const parts = paddingStr.split(/\s+/).map((s) => parseInt(s));
|
|
397
|
+
if (parts.length >= 2) {
|
|
398
|
+
padTop = parts[0] || 80;
|
|
399
|
+
padLeft = parts[1] || 110;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const xMargin = pxToIn(padLeft, dims);
|
|
404
|
+
const contentW = slideW - 2 * xMargin;
|
|
405
|
+
let yPos = pxToIn(padTop, dims);
|
|
406
|
+
|
|
407
|
+
const isCentered =
|
|
408
|
+
slideStyleMatch && slideStyleMatch[1].includes("justify-content: center");
|
|
409
|
+
|
|
410
|
+
let match;
|
|
411
|
+
interface ParsedEl {
|
|
412
|
+
tag: string;
|
|
413
|
+
style: string;
|
|
414
|
+
innerHtml: string;
|
|
415
|
+
index: number;
|
|
416
|
+
}
|
|
417
|
+
const elements: ParsedEl[] = [];
|
|
418
|
+
|
|
419
|
+
const innerContent = html.replace(
|
|
420
|
+
/^<div[^>]*class="fmd-slide"[^>]*>([\s\S]*)<\/div>\s*$/i,
|
|
421
|
+
"$1",
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
const topLevelRegex = /<(h1|h2|h3|p|div)\b([^>]*)>([\s\S]*?)<\/\1>/gi;
|
|
425
|
+
while ((match = topLevelRegex.exec(innerContent)) !== null) {
|
|
426
|
+
const tag = match[1].toLowerCase();
|
|
427
|
+
const attrs = match[2];
|
|
428
|
+
const inner = match[3];
|
|
429
|
+
|
|
430
|
+
const styleMatch = attrs.match(/style="([^"]*)"/);
|
|
431
|
+
const style = styleMatch ? styleMatch[1] : "";
|
|
432
|
+
|
|
433
|
+
elements.push({
|
|
434
|
+
tag,
|
|
435
|
+
style,
|
|
436
|
+
innerHtml: inner,
|
|
437
|
+
index: match.index,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (isCentered && elements.length > 0) {
|
|
442
|
+
let totalHeight = 0;
|
|
443
|
+
for (const el of elements) {
|
|
444
|
+
const fs = getStyle(el.style, "font-size");
|
|
445
|
+
const fontSize = fs ? parseInt(fs) : 22;
|
|
446
|
+
const mb = getStyle(el.style, "margin");
|
|
447
|
+
let marginBottom = 0;
|
|
448
|
+
if (mb) {
|
|
449
|
+
const parts = mb.split(/\s+/).map((s) => parseInt(s));
|
|
450
|
+
if (parts.length === 4) marginBottom = parts[2] || 0;
|
|
451
|
+
else if (parts.length === 2) marginBottom = parts[0] || 0;
|
|
452
|
+
else marginBottom = parts[0] || 0;
|
|
453
|
+
}
|
|
454
|
+
totalHeight += fontSize * 1.3 + marginBottom;
|
|
455
|
+
}
|
|
456
|
+
yPos = (slideH - pxToIn(totalHeight, dims)) / 2;
|
|
457
|
+
if (yPos < pxToIn(padTop, dims)) yPos = pxToIn(padTop, dims);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
for (const el of elements) {
|
|
461
|
+
const style = el.style;
|
|
462
|
+
const fs = getStyle(style, "font-size");
|
|
463
|
+
const fontSize = fs ? parseInt(fs) : 22;
|
|
464
|
+
const fontWeight = getStyle(style, "font-weight");
|
|
465
|
+
const bold =
|
|
466
|
+
fontWeight !== null &&
|
|
467
|
+
(parseInt(fontWeight) >= 700 || fontWeight === "bold");
|
|
468
|
+
const color = getStyle(style, "(?<!background-)color") || "#FFFFFF"; // guard:allow-raw-color — PowerPoint export requires a concrete fallback slide color.
|
|
469
|
+
const letterSpacing = getStyle(style, "letter-spacing");
|
|
470
|
+
const lineHeight = getStyle(style, "line-height");
|
|
471
|
+
|
|
472
|
+
const text = el.innerHtml
|
|
473
|
+
.replace(/<br\s*\/?>/gi, "\n")
|
|
474
|
+
.replace(/<[^>]+>/g, "")
|
|
475
|
+
.replace(/“/g, "“")
|
|
476
|
+
.replace(/”/g, "”")
|
|
477
|
+
.replace(/&/g, "&")
|
|
478
|
+
.replace(/</g, "<")
|
|
479
|
+
.replace(/>/g, ">")
|
|
480
|
+
.replace(/●/g, "●")
|
|
481
|
+
.replace(/&[a-z]+;/gi, " ")
|
|
482
|
+
.replace(/&#x[0-9a-f]+;/gi, "")
|
|
483
|
+
.trim();
|
|
484
|
+
|
|
485
|
+
if (!text && !el.innerHtml.includes("<img")) continue;
|
|
486
|
+
|
|
487
|
+
const imgRegex =
|
|
488
|
+
/<img[^>]*src="([^"]*)"[^>]*(?:style="([^"]*)")?[^>]*\/?>/gi;
|
|
489
|
+
let imgMatch;
|
|
490
|
+
while ((imgMatch = imgRegex.exec(el.innerHtml)) !== null) {
|
|
491
|
+
const imgSrc = imgMatch[1];
|
|
492
|
+
const imgStyle = imgMatch[2] || "";
|
|
493
|
+
const imgW = getStyle(imgStyle, "width");
|
|
494
|
+
const imgH = getStyle(imgStyle, "height");
|
|
495
|
+
images.push({
|
|
496
|
+
src: imgSrc,
|
|
497
|
+
x: xMargin,
|
|
498
|
+
y: yPos,
|
|
499
|
+
w: imgW ? pxToIn(parseInt(imgW), dims) : contentW,
|
|
500
|
+
h: imgH ? pxToIn(parseInt(imgH), dims) : pxToIn(300, dims),
|
|
501
|
+
});
|
|
502
|
+
yPos += imgH
|
|
503
|
+
? pxToIn(parseInt(imgH), dims) + 0.2
|
|
504
|
+
: pxToIn(300, dims) + 0.2;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (text) {
|
|
508
|
+
const lineCount = Math.max(1, text.split("\n").length);
|
|
509
|
+
const lineH = lineHeight ? parseFloat(lineHeight) : 1.3;
|
|
510
|
+
const elHeight = pxToIn(fontSize * lineH * lineCount, dims);
|
|
511
|
+
|
|
512
|
+
const marginStr = getStyle(style, "margin");
|
|
513
|
+
let marginBottom = 0;
|
|
514
|
+
if (marginStr) {
|
|
515
|
+
const parts = marginStr.split(/\s+/).map((s) => parseInt(s));
|
|
516
|
+
if (parts.length === 4) marginBottom = parts[2] || 0;
|
|
517
|
+
else if (parts.length >= 2) marginBottom = 0;
|
|
518
|
+
else marginBottom = parts[0] || 0;
|
|
519
|
+
}
|
|
520
|
+
const mbStr = getStyle(style, "margin-bottom");
|
|
521
|
+
if (mbStr) marginBottom = parseInt(mbStr) || 0;
|
|
522
|
+
|
|
523
|
+
const parsedColor = colorToHex(color);
|
|
524
|
+
texts.push({
|
|
525
|
+
text,
|
|
526
|
+
fontSize: pxToPt(fontSize, dims),
|
|
527
|
+
fontFace: cssFontFace(style) ?? slideFontFace ?? DEFAULT_DECK_FONT_FACE,
|
|
528
|
+
color: parsedColor.hex,
|
|
529
|
+
transparency: parsedColor.transparency,
|
|
530
|
+
bold,
|
|
531
|
+
x: xMargin,
|
|
532
|
+
y: yPos,
|
|
533
|
+
w: contentW,
|
|
534
|
+
h: elHeight + 0.2,
|
|
535
|
+
letterSpacing: letterSpacing ? parseFloat(letterSpacing) : undefined,
|
|
536
|
+
lineSpacingMultiple: lineH,
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
yPos += elHeight + pxToIn(marginBottom, dims) + 0.1;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return {
|
|
544
|
+
texts,
|
|
545
|
+
images,
|
|
546
|
+
shapes,
|
|
547
|
+
tables: [],
|
|
548
|
+
bgColor,
|
|
549
|
+
bgTransparency,
|
|
550
|
+
...(bgGradient ? { bgGradient } : {}),
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
interface SlideDims {
|
|
555
|
+
width: number;
|
|
556
|
+
height: number;
|
|
557
|
+
pptxInches: { w: number; h: number };
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function slideWrapperStyle(html: string): string | undefined {
|
|
561
|
+
return html.match(
|
|
562
|
+
/class=(["'])[^"']*\bfmd-slide\b[^"']*\1[^>]*\bstyle=(["'])([\s\S]*?)\2/i,
|
|
563
|
+
)?.[3];
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function parseImportedPdfSlideHtml(html: string, dims: SlideDims): ParsedSlide {
|
|
567
|
+
const outerStyle = slideWrapperStyle(html);
|
|
568
|
+
const parsedBg = colorToHex(
|
|
569
|
+
outerStyle
|
|
570
|
+
? (getStyle(outerStyle, "background(?:-color)?") ?? "#000000") // guard:allow-raw-color - imported PDF fallback
|
|
571
|
+
: "#000000", // guard:allow-raw-color - imported PDF fallback
|
|
572
|
+
);
|
|
573
|
+
const bgColor = parsedBg.hex;
|
|
574
|
+
const bgTransparency = parsedBg.transparency;
|
|
575
|
+
const src = html.match(/<img\b[^>]*\bsrc=["']([^"']+)["'][^>]*>/i)?.[1];
|
|
576
|
+
const outerAttrs = html.match(/<div\b([^>]*)>/i)?.[1] ?? "";
|
|
577
|
+
const sourceWidth = Number.parseFloat(
|
|
578
|
+
getAttribute(outerAttrs, "data-source-width") ?? "",
|
|
579
|
+
);
|
|
580
|
+
const sourceHeight = Number.parseFloat(
|
|
581
|
+
getAttribute(outerAttrs, "data-source-height") ?? "",
|
|
582
|
+
);
|
|
583
|
+
let x = 0;
|
|
584
|
+
let y = 0;
|
|
585
|
+
let w = dims.pptxInches.w;
|
|
586
|
+
let h = dims.pptxInches.h;
|
|
587
|
+
if (
|
|
588
|
+
Number.isFinite(sourceWidth) &&
|
|
589
|
+
Number.isFinite(sourceHeight) &&
|
|
590
|
+
sourceWidth > 0 &&
|
|
591
|
+
sourceHeight > 0
|
|
592
|
+
) {
|
|
593
|
+
const sourceAspect = sourceWidth / sourceHeight;
|
|
594
|
+
const deckAspect = dims.pptxInches.w / dims.pptxInches.h;
|
|
595
|
+
if (sourceAspect > deckAspect) {
|
|
596
|
+
h = w / sourceAspect;
|
|
597
|
+
y = (dims.pptxInches.h - h) / 2;
|
|
598
|
+
} else {
|
|
599
|
+
w = h * sourceAspect;
|
|
600
|
+
x = (dims.pptxInches.w - w) / 2;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return {
|
|
604
|
+
texts: [],
|
|
605
|
+
images: src
|
|
606
|
+
? [
|
|
607
|
+
{
|
|
608
|
+
src: decodeHtmlText(src),
|
|
609
|
+
x,
|
|
610
|
+
y,
|
|
611
|
+
w,
|
|
612
|
+
h,
|
|
613
|
+
order: 0,
|
|
614
|
+
},
|
|
615
|
+
]
|
|
616
|
+
: [],
|
|
617
|
+
shapes: [],
|
|
618
|
+
tables: [],
|
|
619
|
+
bgColor,
|
|
620
|
+
bgTransparency,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
const IMPORTED_PPTX_BACKGROUND_FALLBACK = "#ffffff"; // guard:allow-raw-color - mirrors the importer's PPTX default
|
|
625
|
+
const IMPORTED_PPTX_FOREGROUND_FALLBACK = "111827"; // guard:allow-raw-color - mirrors the importer's PPTX default
|
|
626
|
+
|
|
627
|
+
function parseImportedSlideHtml(html: string, dims: SlideDims): ParsedSlide {
|
|
628
|
+
const texts: TextElement[] = [];
|
|
629
|
+
const images: ImageElement[] = [];
|
|
630
|
+
const shapes: ShapeElement[] = [];
|
|
631
|
+
const tables: TableElement[] = [];
|
|
632
|
+
const outerStyle = slideWrapperStyle(html);
|
|
633
|
+
const background = outerStyle
|
|
634
|
+
? getStyle(outerStyle, "background(?:-color)?")
|
|
635
|
+
: undefined;
|
|
636
|
+
const parsedBg =
|
|
637
|
+
cssFillToSolid(background) ?? colorToHex(IMPORTED_PPTX_BACKGROUND_FALLBACK);
|
|
638
|
+
const bgColor = parsedBg.hex;
|
|
639
|
+
const bgTransparency = parsedBg.transparency;
|
|
640
|
+
const bgGradient =
|
|
641
|
+
background && /gradient\(/i.test(background) ? background : undefined;
|
|
642
|
+
const slideFontFace = outerStyle ? cssFontFace(outerStyle) : undefined;
|
|
643
|
+
const grid = outerStyle ? parseImportedGrid(outerStyle) : undefined;
|
|
644
|
+
const elementRegex =
|
|
645
|
+
/<div\b([^>]*\bdata-pptx-element-kind=["'](text|image|shape|table)["'][^>]*)>([\s\S]*?)<\/div>/gi;
|
|
646
|
+
let match: RegExpExecArray | null;
|
|
647
|
+
while ((match = elementRegex.exec(html)) !== null) {
|
|
648
|
+
const attrs = match[1];
|
|
649
|
+
const kind = match[2].toLowerCase();
|
|
650
|
+
const innerHtml = match[3];
|
|
651
|
+
const style = getAttribute(attrs, "style") ?? "";
|
|
652
|
+
const geometry = importedGeometry(style, dims);
|
|
653
|
+
if (!geometry) continue;
|
|
654
|
+
const rotate = importedRotation(style);
|
|
655
|
+
const stack = cssStackLevel(style);
|
|
656
|
+
|
|
657
|
+
if (kind === "image") {
|
|
658
|
+
const imageAttrs = innerHtml.match(/<img\b([^>]*)>/i)?.[1] ?? "";
|
|
659
|
+
const src = getAttribute(imageAttrs, "src");
|
|
660
|
+
if (src) {
|
|
661
|
+
images.push({
|
|
662
|
+
src,
|
|
663
|
+
...geometry,
|
|
664
|
+
...(rotate != null ? { rotate } : {}),
|
|
665
|
+
order: match.index,
|
|
666
|
+
stack,
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (kind === "shape") {
|
|
673
|
+
const parsedFill = cssFillToSolid(
|
|
674
|
+
getStyle(style, "background(?:-color)?"),
|
|
675
|
+
);
|
|
676
|
+
const border = parseCssBorder(getStyle(style, "border"));
|
|
677
|
+
const parsedLine = border ? colorToHex(border.color) : undefined;
|
|
678
|
+
const outline = importedFreeformStroke(innerHtml, dims);
|
|
679
|
+
const line = importedLineStroke(style, innerHtml, dims);
|
|
680
|
+
shapes.push({
|
|
681
|
+
...geometry,
|
|
682
|
+
...(parsedFill
|
|
683
|
+
? { fill: parsedFill.hex, fillTransparency: parsedFill.transparency }
|
|
684
|
+
: {}),
|
|
685
|
+
...(border && parsedLine
|
|
686
|
+
? {
|
|
687
|
+
lineColor: parsedLine.hex,
|
|
688
|
+
lineTransparency: parsedLine.transparency,
|
|
689
|
+
lineWidth: Math.max(0.5, pxToPt(border.widthPx, dims)),
|
|
690
|
+
...(border.dashType ? { lineDashType: border.dashType } : {}),
|
|
691
|
+
}
|
|
692
|
+
: outline
|
|
693
|
+
? {
|
|
694
|
+
lineColor: outline.color.hex,
|
|
695
|
+
lineTransparency: outline.color.transparency,
|
|
696
|
+
lineWidth: outline.width,
|
|
697
|
+
}
|
|
698
|
+
: {}),
|
|
699
|
+
...importedShapeGeometry(attrs, style, outline?.path, geometry, dims),
|
|
700
|
+
...line,
|
|
701
|
+
...(rotate != null ? { rotate } : {}),
|
|
702
|
+
order: match.index,
|
|
703
|
+
stack,
|
|
704
|
+
});
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (kind === "table") {
|
|
709
|
+
const rows = importedTableRows(innerHtml, dims);
|
|
710
|
+
if (rows.length > 0) {
|
|
711
|
+
tables.push({
|
|
712
|
+
...geometry,
|
|
713
|
+
rows,
|
|
714
|
+
...importedTableTracks(innerHtml, rows, geometry),
|
|
715
|
+
order: match.index,
|
|
716
|
+
stack,
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
const runs = importedTextRuns(innerHtml, dims);
|
|
723
|
+
const firstRun = runs.find((run) => run.text.trim()) ?? runs[0];
|
|
724
|
+
const firstParagraph = innerHtml.match(
|
|
725
|
+
/<p\b[^>]*style=["']([^"']*)["']/i,
|
|
726
|
+
)?.[1];
|
|
727
|
+
const lineHeight = firstParagraph
|
|
728
|
+
? getStyle(firstParagraph, "line-height")
|
|
729
|
+
: null;
|
|
730
|
+
const alignValue = getStyle(style, "text-align");
|
|
731
|
+
const boxFontFace = firstRun?.options.fontFace ?? slideFontFace;
|
|
732
|
+
texts.push({
|
|
733
|
+
text: runs.map((run) => run.text).join(""),
|
|
734
|
+
...(firstRun?.options.fontSize != null
|
|
735
|
+
? { fontSize: firstRun.options.fontSize }
|
|
736
|
+
: {}),
|
|
737
|
+
...(boxFontFace ? { fontFace: boxFontFace } : {}),
|
|
738
|
+
color: firstRun?.options.color ?? IMPORTED_PPTX_FOREGROUND_FALLBACK,
|
|
739
|
+
transparency: firstRun?.options.transparency,
|
|
740
|
+
bold: runs.length > 0 && runs.every((run) => run.options.bold === true),
|
|
741
|
+
align:
|
|
742
|
+
alignValue === "center" || alignValue === "right" ? alignValue : "left",
|
|
743
|
+
lineSpacingMultiple: cssLineHeightToSpacingMultiple(
|
|
744
|
+
lineHeight ? Number(lineHeight) : undefined,
|
|
745
|
+
),
|
|
746
|
+
x: geometry.x,
|
|
747
|
+
y: geometry.y,
|
|
748
|
+
w: geometry.w,
|
|
749
|
+
h: geometry.h,
|
|
750
|
+
runs,
|
|
751
|
+
...(rotate != null ? { rotate } : {}),
|
|
752
|
+
order: match.index,
|
|
753
|
+
stack,
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return {
|
|
758
|
+
texts,
|
|
759
|
+
images,
|
|
760
|
+
shapes,
|
|
761
|
+
tables,
|
|
762
|
+
grid,
|
|
763
|
+
bgColor,
|
|
764
|
+
bgTransparency,
|
|
765
|
+
...(bgGradient ? { bgGradient } : {}),
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function parseImportedGrid(style: string): GridElement | undefined {
|
|
770
|
+
const backgroundImage = getStyle(style, "background-image");
|
|
771
|
+
const size = getStyle(style, "background-size")
|
|
772
|
+
?.split(/\s+/)
|
|
773
|
+
.map((value) => Number.parseFloat(value));
|
|
774
|
+
const position = getStyle(style, "background-position")
|
|
775
|
+
?.split(/\s+/)
|
|
776
|
+
.map((value) => Number.parseFloat(value));
|
|
777
|
+
const color = backgroundImage?.match(/#[0-9a-f]{6}|rgb\([^)]*\)/i)?.[0];
|
|
778
|
+
const lineWidth = backgroundImage?.match(/\s0\s+([\d.]+)px/i)?.[1];
|
|
779
|
+
if (
|
|
780
|
+
!color ||
|
|
781
|
+
!size ||
|
|
782
|
+
size.length < 2 ||
|
|
783
|
+
!Number.isFinite(size[0]) ||
|
|
784
|
+
!Number.isFinite(size[1]) ||
|
|
785
|
+
size[0] <= 0 ||
|
|
786
|
+
size[1] <= 0 ||
|
|
787
|
+
!position ||
|
|
788
|
+
position.length < 2 ||
|
|
789
|
+
!Number.isFinite(position[0]) ||
|
|
790
|
+
!Number.isFinite(position[1]) ||
|
|
791
|
+
!lineWidth
|
|
792
|
+
) {
|
|
793
|
+
return undefined;
|
|
794
|
+
}
|
|
795
|
+
const parsedColor = colorToHex(color);
|
|
796
|
+
return {
|
|
797
|
+
color: parsedColor.hex,
|
|
798
|
+
transparency: parsedColor.transparency,
|
|
799
|
+
stepX: size[0],
|
|
800
|
+
stepY: size[1],
|
|
801
|
+
offsetX: position[0],
|
|
802
|
+
offsetY: position[1],
|
|
803
|
+
lineWidth: Number.parseFloat(lineWidth),
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function importedGeometry(
|
|
808
|
+
style: string,
|
|
809
|
+
dims: SlideDims,
|
|
810
|
+
): { x: number; y: number; w: number; h: number } | null {
|
|
811
|
+
const left = cssPx(style, "left");
|
|
812
|
+
const top = cssPx(style, "top");
|
|
813
|
+
const width = cssPx(style, "width");
|
|
814
|
+
const height = cssPx(style, "height");
|
|
815
|
+
if (left == null || top == null || width == null || height == null)
|
|
816
|
+
return null;
|
|
817
|
+
return {
|
|
818
|
+
x: pxToIn(left, dims),
|
|
819
|
+
y: pxToInY(top, dims),
|
|
820
|
+
w: pxToIn(width, dims),
|
|
821
|
+
h: pxToInY(height, dims),
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function pxToInY(px: number, dims: SlideDims): number {
|
|
826
|
+
return (px / dims.height) * dims.pptxInches.h;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function importedRotation(style: string): number | undefined {
|
|
830
|
+
const degrees = Number.parseFloat(
|
|
831
|
+
getStyle(style, "transform")?.match(
|
|
832
|
+
/rotate\(\s*(-?[\d.]+)deg\s*\)/i,
|
|
833
|
+
)?.[1] ?? "",
|
|
834
|
+
);
|
|
835
|
+
return Number.isFinite(degrees) && degrees !== 0 ? degrees : undefined;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function importedShapeGeometry(
|
|
839
|
+
attrs: string,
|
|
840
|
+
style: string,
|
|
841
|
+
strokeOutline: string | undefined,
|
|
842
|
+
size: { w: number; h: number },
|
|
843
|
+
dims: SlideDims,
|
|
844
|
+
): Pick<ShapeElement, "shapeType" | "rectRadius" | "points"> {
|
|
845
|
+
const preset = getAttribute(attrs, "data-pptx-shape-type");
|
|
846
|
+
if (preset) return { shapeType: preset };
|
|
847
|
+
|
|
848
|
+
const clipPath = getStyle(style, "clip-path");
|
|
849
|
+
const outline =
|
|
850
|
+
clipPath?.match(/path\(\s*(["']?)([^"')]*)\1\s*\)/i)?.[2] ?? strokeOutline;
|
|
851
|
+
if (outline) {
|
|
852
|
+
const points = svgPathPoints(outline, dims);
|
|
853
|
+
if (points) return { shapeType: "custGeom", points };
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
const polygon = clipPath?.match(/polygon\(([^)]*)\)/i)?.[1];
|
|
857
|
+
if (polygon) {
|
|
858
|
+
const points = clipPathPolygonPoints(polygon, size, dims);
|
|
859
|
+
if (points) return { shapeType: "custGeom", points };
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
const radius = getStyle(style, "border-radius")?.split(/\s+/)[0];
|
|
863
|
+
if (!radius) return {};
|
|
864
|
+
const shortSide = Math.min(size.w, size.h);
|
|
865
|
+
const value = Number.parseFloat(radius);
|
|
866
|
+
if (!Number.isFinite(value) || value <= 0) return {};
|
|
867
|
+
if (radius.endsWith("%")) {
|
|
868
|
+
return value >= 50
|
|
869
|
+
? { shapeType: "ellipse" }
|
|
870
|
+
: { shapeType: "roundRect", rectRadius: (value / 100) * shortSide };
|
|
871
|
+
}
|
|
872
|
+
return {
|
|
873
|
+
shapeType: "roundRect",
|
|
874
|
+
rectRadius: Math.min(pxToIn(value, dims), shortSide / 2),
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function importedFreeformStroke(
|
|
879
|
+
innerHtml: string,
|
|
880
|
+
dims: SlideDims,
|
|
881
|
+
):
|
|
882
|
+
| { path: string; color: ReturnType<typeof colorToHex>; width: number }
|
|
883
|
+
| undefined {
|
|
884
|
+
const pathAttrs = innerHtml.match(/<svg\b[^>]*>\s*<path\b([^>]*)>/i)?.[1];
|
|
885
|
+
if (!pathAttrs) return undefined;
|
|
886
|
+
const path = getAttribute(pathAttrs, "d");
|
|
887
|
+
const stroke = getAttribute(pathAttrs, "stroke");
|
|
888
|
+
if (!path || !stroke) return undefined;
|
|
889
|
+
const widthPx = Number.parseFloat(
|
|
890
|
+
getAttribute(pathAttrs, "stroke-width") ?? "1",
|
|
891
|
+
);
|
|
892
|
+
return {
|
|
893
|
+
path: decodeHtmlText(path),
|
|
894
|
+
color: colorToHex(stroke),
|
|
895
|
+
width: Math.max(0.5, pxToPt(Number.isFinite(widthPx) ? widthPx : 1, dims)),
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
const SINGLE_EDGE_BORDER_AXES = {
|
|
900
|
+
"border-top": "x",
|
|
901
|
+
"border-left": "y",
|
|
902
|
+
} as const;
|
|
903
|
+
|
|
904
|
+
function importedLineStroke(
|
|
905
|
+
style: string,
|
|
906
|
+
innerHtml: string,
|
|
907
|
+
dims: SlideDims,
|
|
908
|
+
):
|
|
909
|
+
| (Pick<
|
|
910
|
+
ShapeElement,
|
|
911
|
+
| "shapeType"
|
|
912
|
+
| "lineColor"
|
|
913
|
+
| "lineTransparency"
|
|
914
|
+
| "lineWidth"
|
|
915
|
+
| "lineDashType"
|
|
916
|
+
| "lineHeadType"
|
|
917
|
+
| "lineTailType"
|
|
918
|
+
> &
|
|
919
|
+
Partial<Pick<ShapeElement, "w" | "h">>)
|
|
920
|
+
| undefined {
|
|
921
|
+
for (const [property, axis] of Object.entries(SINGLE_EDGE_BORDER_AXES)) {
|
|
922
|
+
const border = parseCssBorder(getStyle(style, property));
|
|
923
|
+
if (!border) continue;
|
|
924
|
+
const color = colorToHex(border.color);
|
|
925
|
+
return {
|
|
926
|
+
shapeType: "line",
|
|
927
|
+
...(axis === "x" ? { h: 0 } : { w: 0 }),
|
|
928
|
+
lineColor: color.hex,
|
|
929
|
+
lineTransparency: color.transparency,
|
|
930
|
+
lineWidth: Math.max(0.5, pxToPt(border.widthPx, dims)),
|
|
931
|
+
...(border.dashType ? { lineDashType: border.dashType } : {}),
|
|
932
|
+
...importedLineEndTypes(innerHtml, axis),
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
return undefined;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function importedLineEndTypes(
|
|
939
|
+
innerHtml: string,
|
|
940
|
+
axis: "x" | "y",
|
|
941
|
+
): Pick<ShapeElement, "lineHeadType" | "lineTailType"> {
|
|
942
|
+
const svg = innerHtml.match(/<svg\b([^>]*)>([\s\S]*?)<\/svg>/i);
|
|
943
|
+
const viewBox = getAttribute(svg?.[1] ?? "", "viewBox")
|
|
944
|
+
?.trim()
|
|
945
|
+
.split(/[\s,]+/)
|
|
946
|
+
.map(Number);
|
|
947
|
+
if (!svg || viewBox?.length !== 4 || !viewBox.every(Number.isFinite)) {
|
|
948
|
+
return {};
|
|
949
|
+
}
|
|
950
|
+
const middle = (axis === "x" ? viewBox[2] : viewBox[3]) / 2;
|
|
951
|
+
const ends: Pick<ShapeElement, "lineHeadType" | "lineTailType"> = {};
|
|
952
|
+
for (const circle of svg[2].matchAll(/<circle\b([^>]*)>/gi)) {
|
|
953
|
+
const alongAttribute = getAttribute(circle[1], axis === "x" ? "cx" : "cy");
|
|
954
|
+
if (alongAttribute == null) continue;
|
|
955
|
+
const along = Number(alongAttribute);
|
|
956
|
+
if (!Number.isFinite(along)) continue;
|
|
957
|
+
if (along < middle) ends.lineHeadType = "oval";
|
|
958
|
+
else ends.lineTailType = "oval";
|
|
959
|
+
}
|
|
960
|
+
return ends;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
type CustomGeometryPoint = NonNullable<ShapeElement["points"]>[number];
|
|
964
|
+
|
|
965
|
+
const SVG_PATH_ARITY: Record<string, number> = {
|
|
966
|
+
M: 2,
|
|
967
|
+
L: 2,
|
|
968
|
+
Q: 4,
|
|
969
|
+
C: 6,
|
|
970
|
+
A: 7,
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
const SVG_PATH_NUMBER = /[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi;
|
|
974
|
+
|
|
975
|
+
function svgPathPoints(
|
|
976
|
+
path: string,
|
|
977
|
+
dims: SlideDims,
|
|
978
|
+
): NonNullable<ShapeElement["points"]> | undefined {
|
|
979
|
+
const points: CustomGeometryPoint[] = [];
|
|
980
|
+
const toX = (px: number) => pxToIn(px, dims);
|
|
981
|
+
const toY = (px: number) => pxToInY(px, dims);
|
|
982
|
+
let cursorX = 0;
|
|
983
|
+
let cursorY = 0;
|
|
984
|
+
let subpathX = 0;
|
|
985
|
+
let subpathY = 0;
|
|
986
|
+
let seenCommand = false;
|
|
987
|
+
|
|
988
|
+
for (const match of path.matchAll(/([A-Za-z])([^A-Za-z]*)/g)) {
|
|
989
|
+
const command = match[1].toUpperCase();
|
|
990
|
+
const relative = match[1] !== command;
|
|
991
|
+
seenCommand = true;
|
|
992
|
+
const args = (match[2].match(SVG_PATH_NUMBER) ?? []).map(Number);
|
|
993
|
+
if (command === "Z") {
|
|
994
|
+
if (args.length > 0) return undefined;
|
|
995
|
+
points.push({ close: true });
|
|
996
|
+
cursorX = subpathX;
|
|
997
|
+
cursorY = subpathY;
|
|
998
|
+
continue;
|
|
999
|
+
}
|
|
1000
|
+
const arity = SVG_PATH_ARITY[command];
|
|
1001
|
+
if (
|
|
1002
|
+
!arity ||
|
|
1003
|
+
args.length === 0 ||
|
|
1004
|
+
args.length % arity !== 0 ||
|
|
1005
|
+
args.some((value) => !Number.isFinite(value))
|
|
1006
|
+
) {
|
|
1007
|
+
console.warn(
|
|
1008
|
+
`[export-pptx] unreadable SVG path command "${match[0].trim().slice(0, 40)}" in a shape outline; exported as a rectangle`,
|
|
1009
|
+
);
|
|
1010
|
+
return undefined;
|
|
1011
|
+
}
|
|
1012
|
+
for (let i = 0; i < args.length; i += arity) {
|
|
1013
|
+
const chunk = args.slice(i, i + arity);
|
|
1014
|
+
const originX = relative ? cursorX : 0;
|
|
1015
|
+
const originY = relative ? cursorY : 0;
|
|
1016
|
+
const atX = (index: number) => originX + chunk[index];
|
|
1017
|
+
const atY = (index: number) => originY + chunk[index];
|
|
1018
|
+
const endX = atX(arity - 2);
|
|
1019
|
+
const endY = atY(arity - 1);
|
|
1020
|
+
if (command === "M") {
|
|
1021
|
+
points.push(
|
|
1022
|
+
i === 0
|
|
1023
|
+
? { x: toX(endX), y: toY(endY), moveTo: true }
|
|
1024
|
+
: { x: toX(endX), y: toY(endY) },
|
|
1025
|
+
);
|
|
1026
|
+
if (i === 0) {
|
|
1027
|
+
subpathX = endX;
|
|
1028
|
+
subpathY = endY;
|
|
1029
|
+
}
|
|
1030
|
+
} else if (command === "L") {
|
|
1031
|
+
points.push({ x: toX(endX), y: toY(endY) });
|
|
1032
|
+
} else if (command === "C") {
|
|
1033
|
+
points.push({
|
|
1034
|
+
x: toX(endX),
|
|
1035
|
+
y: toY(endY),
|
|
1036
|
+
curve: {
|
|
1037
|
+
type: "cubic",
|
|
1038
|
+
x1: toX(atX(0)),
|
|
1039
|
+
y1: toY(atY(1)),
|
|
1040
|
+
x2: toX(atX(2)),
|
|
1041
|
+
y2: toY(atY(3)),
|
|
1042
|
+
},
|
|
1043
|
+
});
|
|
1044
|
+
} else if (command === "Q") {
|
|
1045
|
+
points.push({
|
|
1046
|
+
x: toX(endX),
|
|
1047
|
+
y: toY(endY),
|
|
1048
|
+
curve: { type: "quadratic", x1: toX(atX(0)), y1: toY(atY(1)) },
|
|
1049
|
+
});
|
|
1050
|
+
} else {
|
|
1051
|
+
const arc = svgArcToPptxCurve(
|
|
1052
|
+
cursorX,
|
|
1053
|
+
cursorY,
|
|
1054
|
+
[...chunk.slice(0, 5), endX, endY],
|
|
1055
|
+
dims,
|
|
1056
|
+
);
|
|
1057
|
+
if (!arc) return undefined;
|
|
1058
|
+
points.push(arc);
|
|
1059
|
+
}
|
|
1060
|
+
cursorX = endX;
|
|
1061
|
+
cursorY = endY;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
if (!seenCommand) return undefined;
|
|
1066
|
+
return points.length > 0 ? points : undefined;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function svgArcToPptxCurve(
|
|
1070
|
+
startX: number,
|
|
1071
|
+
startY: number,
|
|
1072
|
+
[radiusX, radiusY, rotation, largeArc, sweep, endX, endY]: number[],
|
|
1073
|
+
dims: SlideDims,
|
|
1074
|
+
): CustomGeometryPoint | undefined {
|
|
1075
|
+
if (rotation !== 0) {
|
|
1076
|
+
console.warn(
|
|
1077
|
+
`[export-pptx] rotated elliptical arc (${rotation}deg) in a shape outline; exported as a rectangle`,
|
|
1078
|
+
);
|
|
1079
|
+
return undefined;
|
|
1080
|
+
}
|
|
1081
|
+
const point = { x: pxToIn(endX, dims), y: pxToInY(endY, dims) };
|
|
1082
|
+
let rx = Math.abs(radiusX);
|
|
1083
|
+
let ry = Math.abs(radiusY);
|
|
1084
|
+
if (!(rx > 0) || !(ry > 0)) return point;
|
|
1085
|
+
|
|
1086
|
+
const midX = (startX - endX) / 2;
|
|
1087
|
+
const midY = (startY - endY) / 2;
|
|
1088
|
+
const scale = (midX * midX) / (rx * rx) + (midY * midY) / (ry * ry);
|
|
1089
|
+
if (scale > 1) {
|
|
1090
|
+
rx *= Math.sqrt(scale);
|
|
1091
|
+
ry *= Math.sqrt(scale);
|
|
1092
|
+
}
|
|
1093
|
+
const denominator = rx * rx * midY * midY + ry * ry * midX * midX;
|
|
1094
|
+
const numerator = rx * rx * ry * ry - denominator;
|
|
1095
|
+
const factor =
|
|
1096
|
+
(largeArc !== sweep ? 1 : -1) *
|
|
1097
|
+
Math.sqrt(Math.max(0, numerator / denominator));
|
|
1098
|
+
const centerX = (factor * (rx * midY)) / ry + (startX + endX) / 2;
|
|
1099
|
+
const centerY = (-factor * (ry * midX)) / rx + (startY + endY) / 2;
|
|
1100
|
+
const startAngle = Math.atan2(
|
|
1101
|
+
(startY - centerY) / ry,
|
|
1102
|
+
(startX - centerX) / rx,
|
|
1103
|
+
);
|
|
1104
|
+
const endAngle = Math.atan2((endY - centerY) / ry, (endX - centerX) / rx);
|
|
1105
|
+
let swingAngle = endAngle - startAngle;
|
|
1106
|
+
if (sweep && swingAngle < 0) swingAngle += 2 * Math.PI;
|
|
1107
|
+
if (!sweep && swingAngle > 0) swingAngle -= 2 * Math.PI;
|
|
1108
|
+
|
|
1109
|
+
const toDegrees = (radians: number) => (radians * 180) / Math.PI;
|
|
1110
|
+
return {
|
|
1111
|
+
...point,
|
|
1112
|
+
curve: {
|
|
1113
|
+
type: "arc",
|
|
1114
|
+
wR: pxToIn(rx, dims),
|
|
1115
|
+
hR: pxToInY(ry, dims),
|
|
1116
|
+
stAng: (toDegrees(startAngle) + 360) % 360,
|
|
1117
|
+
swAng: toDegrees(swingAngle),
|
|
1118
|
+
},
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
function clipPathPolygonPoints(
|
|
1123
|
+
polygon: string,
|
|
1124
|
+
size: { w: number; h: number },
|
|
1125
|
+
dims: SlideDims,
|
|
1126
|
+
): NonNullable<ShapeElement["points"]> | undefined {
|
|
1127
|
+
const points: Array<{ x: number; y: number }> = [];
|
|
1128
|
+
for (const pair of polygon.split(",")) {
|
|
1129
|
+
const [rawX, rawY] = pair.trim().split(/\s+/);
|
|
1130
|
+
const x = clipPathCoord(rawX, size.w, dims, pxToIn);
|
|
1131
|
+
const y = clipPathCoord(rawY, size.h, dims, pxToInY);
|
|
1132
|
+
if (x == null || y == null) return undefined;
|
|
1133
|
+
points.push({ x, y });
|
|
1134
|
+
}
|
|
1135
|
+
return points.length >= 3 ? [...points, { close: true }] : undefined;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
function clipPathCoord(
|
|
1139
|
+
raw: string | undefined,
|
|
1140
|
+
side: number,
|
|
1141
|
+
dims: SlideDims,
|
|
1142
|
+
toInches: (px: number, dims: SlideDims) => number,
|
|
1143
|
+
): number | undefined {
|
|
1144
|
+
if (!raw) return undefined;
|
|
1145
|
+
const value = Number.parseFloat(raw);
|
|
1146
|
+
if (!Number.isFinite(value)) return undefined;
|
|
1147
|
+
return raw.endsWith("%") ? (value / 100) * side : toInches(value, dims);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
function importedTextRuns(html: string, dims: SlideDims): TextRunElement[] {
|
|
1151
|
+
const paragraphs = [...html.matchAll(/<p\b[^>]*>([\s\S]*?)<\/p>/gi)].map(
|
|
1152
|
+
(match) => match[1],
|
|
1153
|
+
);
|
|
1154
|
+
const blocks = paragraphs.length > 0 ? paragraphs : [html];
|
|
1155
|
+
const runs: TextRunElement[] = [];
|
|
1156
|
+
blocks.forEach((block, paragraphIndex) => {
|
|
1157
|
+
if (paragraphIndex > 0) runs.push({ text: "\n", options: {} });
|
|
1158
|
+
const spans = [...block.matchAll(/<span\b([^>]*)>([\s\S]*?)<\/span>/gi)];
|
|
1159
|
+
if (spans.length === 0) {
|
|
1160
|
+
const text = decodeHtmlText(stripTags(block));
|
|
1161
|
+
if (text) runs.push({ text, options: {} });
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
for (const span of spans) {
|
|
1165
|
+
const attrs = span[1];
|
|
1166
|
+
const style = getAttribute(attrs, "style") ?? "";
|
|
1167
|
+
const text = decodeHtmlText(stripTags(span[2]));
|
|
1168
|
+
if (!text) continue;
|
|
1169
|
+
runs.push({ text, options: importedRunOptions(style, dims) });
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
return runs;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
export function tableOptions(table: TableElement): PptxGenJS.TableProps {
|
|
1176
|
+
return {
|
|
1177
|
+
x: table.x,
|
|
1178
|
+
y: table.y,
|
|
1179
|
+
w: table.w,
|
|
1180
|
+
h: table.h,
|
|
1181
|
+
...(table.colW ? { colW: table.colW } : {}),
|
|
1182
|
+
...(table.rowH ? { rowH: table.rowH } : {}),
|
|
1183
|
+
autoPage: false,
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
function firstParagraphStyle(html: string): string | undefined {
|
|
1188
|
+
return html.match(/<p\b[^>]*style=["']([^"']*)["']/i)?.[1];
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
function importedTableTracks(
|
|
1192
|
+
html: string,
|
|
1193
|
+
rows: TableRow[],
|
|
1194
|
+
box: { w: number; h: number },
|
|
1195
|
+
): { colW?: number[]; rowH?: number[] } {
|
|
1196
|
+
const percentages = (pattern: RegExp) => {
|
|
1197
|
+
const values = [...html.matchAll(pattern)].map((match) =>
|
|
1198
|
+
Number.parseFloat(match[1]),
|
|
1199
|
+
);
|
|
1200
|
+
return values.every((value) => Number.isFinite(value) && value > 0)
|
|
1201
|
+
? values
|
|
1202
|
+
: [];
|
|
1203
|
+
};
|
|
1204
|
+
const columnCount = (rows[0] ?? []).reduce(
|
|
1205
|
+
(total, cell) => total + (Number(cell.options?.colspan) || 1),
|
|
1206
|
+
0,
|
|
1207
|
+
);
|
|
1208
|
+
const colW = percentages(
|
|
1209
|
+
/<col\b[^>]*\bstyle=["'][^"']*\bwidth\s*:\s*([\d.]+)%/gi,
|
|
1210
|
+
);
|
|
1211
|
+
const rowH = percentages(
|
|
1212
|
+
/<tr\b[^>]*\bstyle=["'][^"']*\bheight\s*:\s*([\d.]+)%/gi,
|
|
1213
|
+
);
|
|
1214
|
+
return {
|
|
1215
|
+
...(colW.length === columnCount
|
|
1216
|
+
? { colW: colW.map((percent) => (percent / 100) * box.w) }
|
|
1217
|
+
: {}),
|
|
1218
|
+
...(rowH.length === rows.length
|
|
1219
|
+
? { rowH: rowH.map((percent) => (percent / 100) * box.h) }
|
|
1220
|
+
: {}),
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function importedCellMargin(
|
|
1225
|
+
style: string,
|
|
1226
|
+
dims: SlideDims,
|
|
1227
|
+
): [number, number, number, number] | undefined {
|
|
1228
|
+
const parts = getStyle(style, "padding")
|
|
1229
|
+
?.trim()
|
|
1230
|
+
.split(/\s+/)
|
|
1231
|
+
.map((value) => Number.parseFloat(value));
|
|
1232
|
+
if (!parts?.length || parts.length > 4) return undefined;
|
|
1233
|
+
if (parts.some((value) => !Number.isFinite(value) || value < 0))
|
|
1234
|
+
return undefined;
|
|
1235
|
+
const [top, right = top, bottom = top, left = right] = parts;
|
|
1236
|
+
const margin: [number, number, number, number] = [
|
|
1237
|
+
pxToInY(top, dims),
|
|
1238
|
+
pxToIn(right, dims),
|
|
1239
|
+
pxToInY(bottom, dims),
|
|
1240
|
+
pxToIn(left, dims),
|
|
1241
|
+
];
|
|
1242
|
+
return margin.some((inches) => inches >= 1) ? undefined : margin;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
function importedTableRows(html: string, dims: SlideDims): TableRow[] {
|
|
1246
|
+
return [...html.matchAll(/<tr\b[^>]*>([\s\S]*?)<\/tr>/gi)].map(
|
|
1247
|
+
(rowMatch): TableRow =>
|
|
1248
|
+
[...rowMatch[1].matchAll(/<t[dh]\b([^>]*)>([\s\S]*?)<\/t[dh]>/gi)].map(
|
|
1249
|
+
(cellMatch): TableCell => {
|
|
1250
|
+
const attrs = cellMatch[1];
|
|
1251
|
+
const cellHtml = cellMatch[2];
|
|
1252
|
+
const style = getAttribute(attrs, "style") ?? "";
|
|
1253
|
+
const runs = importedTextRuns(cellHtml, dims);
|
|
1254
|
+
const parsedFill = cssFillToSolid(
|
|
1255
|
+
getStyle(style, "background(?:-color)?"),
|
|
1256
|
+
);
|
|
1257
|
+
const border = parseCssBorder(getStyle(style, "border"));
|
|
1258
|
+
const parsedBorder = border ? colorToHex(border.color) : undefined;
|
|
1259
|
+
const colSpan = Number.parseInt(
|
|
1260
|
+
getAttribute(attrs, "colspan") ?? "",
|
|
1261
|
+
10,
|
|
1262
|
+
);
|
|
1263
|
+
const rowSpan = Number.parseInt(
|
|
1264
|
+
getAttribute(attrs, "rowspan") ?? "",
|
|
1265
|
+
10,
|
|
1266
|
+
);
|
|
1267
|
+
const align =
|
|
1268
|
+
getStyle(style, "text-align") ??
|
|
1269
|
+
getStyle(firstParagraphStyle(cellHtml) ?? "", "text-align");
|
|
1270
|
+
const verticalAlign = getStyle(style, "vertical-align");
|
|
1271
|
+
const margin = importedCellMargin(style, dims);
|
|
1272
|
+
const options: NonNullable<TableCell["options"]> = {
|
|
1273
|
+
...(margin ? { margin } : {}),
|
|
1274
|
+
...(align === "center" || align === "right" || align === "justify"
|
|
1275
|
+
? { align }
|
|
1276
|
+
: {}),
|
|
1277
|
+
...(verticalAlign === "top" ||
|
|
1278
|
+
verticalAlign === "middle" ||
|
|
1279
|
+
verticalAlign === "bottom"
|
|
1280
|
+
? { valign: verticalAlign }
|
|
1281
|
+
: {}),
|
|
1282
|
+
...(parsedFill
|
|
1283
|
+
? {
|
|
1284
|
+
fill: {
|
|
1285
|
+
color: parsedFill.hex,
|
|
1286
|
+
...(parsedFill.transparency != null
|
|
1287
|
+
? { transparency: parsedFill.transparency }
|
|
1288
|
+
: {}),
|
|
1289
|
+
},
|
|
1290
|
+
}
|
|
1291
|
+
: {}),
|
|
1292
|
+
...(parsedBorder && border
|
|
1293
|
+
? {
|
|
1294
|
+
border: {
|
|
1295
|
+
type: border.dashType
|
|
1296
|
+
? ("dash" as const)
|
|
1297
|
+
: ("solid" as const),
|
|
1298
|
+
color: parsedBorder.hex,
|
|
1299
|
+
pt: Math.max(0.5, pxToPt(border.widthPx, dims)),
|
|
1300
|
+
},
|
|
1301
|
+
}
|
|
1302
|
+
: {}),
|
|
1303
|
+
...(Number.isFinite(colSpan) && colSpan > 1
|
|
1304
|
+
? { colspan: colSpan }
|
|
1305
|
+
: {}),
|
|
1306
|
+
...(Number.isFinite(rowSpan) && rowSpan > 1
|
|
1307
|
+
? { rowspan: rowSpan }
|
|
1308
|
+
: {}),
|
|
1309
|
+
};
|
|
1310
|
+
const text: TableCell["text"] =
|
|
1311
|
+
runs.length > 0
|
|
1312
|
+
? runs.map((run) => ({ text: run.text, options: run.options }))
|
|
1313
|
+
: "";
|
|
1314
|
+
return { text, options };
|
|
1315
|
+
},
|
|
1316
|
+
),
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
function importedRunOptions(
|
|
1321
|
+
style: string,
|
|
1322
|
+
dims: SlideDims,
|
|
1323
|
+
): TextRunElement["options"] {
|
|
1324
|
+
const fontSizePx = cssPx(style, "font-size");
|
|
1325
|
+
const fontFamily = cssFontFace(style);
|
|
1326
|
+
const fontWeight = getStyle(style, "font-weight");
|
|
1327
|
+
const colorValue = getStyle(style, "color");
|
|
1328
|
+
const parsedColor = colorValue
|
|
1329
|
+
? colorToHex(colorValue) // guard:allow-raw-color - PPTX text fallback
|
|
1330
|
+
: undefined;
|
|
1331
|
+
return {
|
|
1332
|
+
...(fontSizePx != null ? { fontSize: pxToPt(fontSizePx, dims) } : {}),
|
|
1333
|
+
...(fontFamily ? { fontFace: fontFamily } : {}),
|
|
1334
|
+
...(parsedColor
|
|
1335
|
+
? { color: parsedColor.hex, transparency: parsedColor.transparency }
|
|
1336
|
+
: {}),
|
|
1337
|
+
...(fontWeight
|
|
1338
|
+
? {
|
|
1339
|
+
bold: Number.parseInt(fontWeight, 10) >= 700 || fontWeight === "bold",
|
|
1340
|
+
}
|
|
1341
|
+
: {}),
|
|
1342
|
+
...(getStyle(style, "font-style") === "italic" ? { italic: true } : {}),
|
|
1343
|
+
...(getStyle(style, "text-decoration")?.includes("underline")
|
|
1344
|
+
? { underline: { style: "sng" as const } }
|
|
1345
|
+
: {}),
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
function cssStackLevel(style: string): number {
|
|
1350
|
+
const value = getStyle(style, "z-index");
|
|
1351
|
+
const parsed = value ? Number.parseInt(value, 10) : Number.NaN;
|
|
1352
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
export function orderImportedObjects(parsed: {
|
|
1356
|
+
images: ImageElement[];
|
|
1357
|
+
shapes: ShapeElement[];
|
|
1358
|
+
tables: TableElement[];
|
|
1359
|
+
texts: TextElement[];
|
|
1360
|
+
}) {
|
|
1361
|
+
return [
|
|
1362
|
+
...parsed.texts.map((value) => ({ kind: "text" as const, value })),
|
|
1363
|
+
...parsed.images.map((value) => ({ kind: "image" as const, value })),
|
|
1364
|
+
...parsed.shapes.map((value) => ({ kind: "shape" as const, value })),
|
|
1365
|
+
...parsed.tables.map((value) => ({ kind: "table" as const, value })),
|
|
1366
|
+
].sort(
|
|
1367
|
+
(a, b) =>
|
|
1368
|
+
(a.value.stack ?? 0) - (b.value.stack ?? 0) ||
|
|
1369
|
+
(a.value.order ?? 0) - (b.value.order ?? 0),
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
function cssPx(style: string, property: string): number | null {
|
|
1374
|
+
const value = getStyle(style, property);
|
|
1375
|
+
if (!value) return null;
|
|
1376
|
+
const parsed = Number.parseFloat(value);
|
|
1377
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
function getAttribute(attrs: string, name: string): string | null {
|
|
1381
|
+
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1382
|
+
const match = attrs.match(
|
|
1383
|
+
new RegExp(`\\b${escapedName}\\s*=\\s*(["'])(.*?)\\1`, "i"),
|
|
1384
|
+
);
|
|
1385
|
+
return match?.[2] ?? null;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
function stripTags(value: string): string {
|
|
1389
|
+
return value.replace(/<br\s*\/?\s*>/gi, "\n").replace(/<[^>]+>/g, "");
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
function decodeHtmlText(value: string): string {
|
|
1393
|
+
return value
|
|
1394
|
+
.replace(/ /gi, " ")
|
|
1395
|
+
.replace(/&/gi, "&")
|
|
1396
|
+
.replace(/</gi, "<")
|
|
1397
|
+
.replace(/>/gi, ">")
|
|
1398
|
+
.replace(/"/gi, '"')
|
|
1399
|
+
.replace(/'|'/gi, "'")
|
|
1400
|
+
.replace(/●/gi, "●");
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function splitTopLevel(value: string): string[] {
|
|
1404
|
+
const parts: string[] = [];
|
|
1405
|
+
let depth = 0;
|
|
1406
|
+
let start = 0;
|
|
1407
|
+
for (let i = 0; i < value.length; i++) {
|
|
1408
|
+
const char = value[i];
|
|
1409
|
+
if (char === "(") depth++;
|
|
1410
|
+
else if (char === ")") depth--;
|
|
1411
|
+
else if (char === "," && depth === 0) {
|
|
1412
|
+
parts.push(value.slice(start, i));
|
|
1413
|
+
start = i + 1;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
parts.push(value.slice(start));
|
|
1417
|
+
return parts.map((part) => part.trim()).filter(Boolean);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
function drawingMlColor(parsed: {
|
|
1421
|
+
hex: string;
|
|
1422
|
+
transparency?: number;
|
|
1423
|
+
}): string {
|
|
1424
|
+
return parsed.transparency
|
|
1425
|
+
? `<a:srgbClr val="${parsed.hex}"><a:alpha val="${Math.round((100 - parsed.transparency) * 1000)}"/></a:srgbClr>`
|
|
1426
|
+
: `<a:srgbClr val="${parsed.hex}"/>`;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
export function cssGradientToDrawingMl(css: string): string | undefined {
|
|
1430
|
+
const match = css.trim().match(/^(linear|radial)-gradient\(([\s\S]*)\)$/i);
|
|
1431
|
+
if (!match) return undefined;
|
|
1432
|
+
const kind = match[1].toLowerCase();
|
|
1433
|
+
const args = splitTopLevel(match[2]);
|
|
1434
|
+
|
|
1435
|
+
const config =
|
|
1436
|
+
args.length > 0 && !parseCssColor(splitGradientStop(args[0]).color)
|
|
1437
|
+
? args[0]
|
|
1438
|
+
: undefined;
|
|
1439
|
+
const stopArgs = config === undefined ? args : args.slice(1);
|
|
1440
|
+
if (stopArgs.length < 2) return undefined;
|
|
1441
|
+
|
|
1442
|
+
let geometry: string;
|
|
1443
|
+
if (kind === "linear") {
|
|
1444
|
+
const cssAngle = linearGradientAngle(config);
|
|
1445
|
+
if (cssAngle === undefined) return undefined;
|
|
1446
|
+
const ang = Math.round(((((cssAngle - 90) % 360) + 360) % 360) * 60000);
|
|
1447
|
+
geometry = `<a:lin ang="${ang}" scaled="0"/>`;
|
|
1448
|
+
} else {
|
|
1449
|
+
const center = radialGradientCenter(config);
|
|
1450
|
+
if (!center) return undefined;
|
|
1451
|
+
const pct = (value: number) => Math.round(value * 1000);
|
|
1452
|
+
geometry = `<a:path path="circle"><a:fillToRect l="${pct(center.x)}" t="${pct(center.y)}" r="${pct(100 - center.x)}" b="${pct(100 - center.y)}"/></a:path>`;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
const stops: string[] = [];
|
|
1456
|
+
for (const [index, stopArg] of stopArgs.entries()) {
|
|
1457
|
+
const { color, position } = splitGradientStop(stopArg);
|
|
1458
|
+
const parsed = parseCssColor(color);
|
|
1459
|
+
if (!parsed) return undefined;
|
|
1460
|
+
const resolved = position ?? (index / (stopArgs.length - 1)) * 100;
|
|
1461
|
+
const clamped = Math.min(100, Math.max(0, resolved));
|
|
1462
|
+
stops.push(
|
|
1463
|
+
`<a:gs pos="${Math.round(clamped * 1000)}">${drawingMlColor(parsed)}</a:gs>`,
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
return `<a:gradFill rotWithShape="1"><a:gsLst>${stops.join("")}</a:gsLst>${geometry}</a:gradFill>`;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
function splitGradientStop(arg: string): { color: string; position?: number } {
|
|
1470
|
+
const match = arg.match(/\s([\d.]+)%$/);
|
|
1471
|
+
return match
|
|
1472
|
+
? { color: arg.slice(0, match.index).trim(), position: Number(match[1]) }
|
|
1473
|
+
: { color: arg };
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
const LINEAR_GRADIENT_SIDE_ANGLES: Record<string, number> = {
|
|
1477
|
+
top: 0,
|
|
1478
|
+
"top right": 45,
|
|
1479
|
+
"right top": 45,
|
|
1480
|
+
right: 90,
|
|
1481
|
+
"bottom right": 135,
|
|
1482
|
+
"right bottom": 135,
|
|
1483
|
+
bottom: 180,
|
|
1484
|
+
"bottom left": 225,
|
|
1485
|
+
"left bottom": 225,
|
|
1486
|
+
left: 270,
|
|
1487
|
+
"top left": 315,
|
|
1488
|
+
"left top": 315,
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
function linearGradientAngle(config: string | undefined): number | undefined {
|
|
1492
|
+
if (config === undefined) return 180;
|
|
1493
|
+
const degrees = config.match(/^(-?[\d.]+)deg$/i)?.[1];
|
|
1494
|
+
if (degrees !== undefined) return Number(degrees);
|
|
1495
|
+
const side = config.match(/^to\s+([a-z]+(?:\s+[a-z]+)?)$/i)?.[1];
|
|
1496
|
+
return side === undefined
|
|
1497
|
+
? undefined
|
|
1498
|
+
: LINEAR_GRADIENT_SIDE_ANGLES[side.toLowerCase().replace(/\s+/g, " ")];
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
const RADIAL_POSITION_PERCENTS: Record<string, number> = {
|
|
1502
|
+
left: 0,
|
|
1503
|
+
top: 0,
|
|
1504
|
+
center: 50,
|
|
1505
|
+
right: 100,
|
|
1506
|
+
bottom: 100,
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
function radialGradientCenter(
|
|
1510
|
+
config: string | undefined,
|
|
1511
|
+
): { x: number; y: number } | undefined {
|
|
1512
|
+
if (config === undefined) return { x: 50, y: 50 };
|
|
1513
|
+
const at = config.match(/\bat\s+(.+)$/i)?.[1].trim();
|
|
1514
|
+
if (at === undefined) return { x: 50, y: 50 };
|
|
1515
|
+
const axes = at.split(/\s+/).map((axis) => {
|
|
1516
|
+
const percent = axis.match(/^([\d.]+)%$/)?.[1];
|
|
1517
|
+
return percent !== undefined
|
|
1518
|
+
? Number(percent)
|
|
1519
|
+
: RADIAL_POSITION_PERCENTS[axis.toLowerCase()];
|
|
1520
|
+
});
|
|
1521
|
+
const [x, y = 50] = axes;
|
|
1522
|
+
if (axes.length > 2 || x === undefined || y === undefined) return undefined;
|
|
1523
|
+
return { x, y };
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
const THEME_COLOR_SLOTS = [
|
|
1527
|
+
"dk1",
|
|
1528
|
+
"lt1",
|
|
1529
|
+
"dk2",
|
|
1530
|
+
"lt2",
|
|
1531
|
+
"accent1",
|
|
1532
|
+
"accent2",
|
|
1533
|
+
"accent3",
|
|
1534
|
+
"accent4",
|
|
1535
|
+
"accent5",
|
|
1536
|
+
"accent6",
|
|
1537
|
+
"hlink",
|
|
1538
|
+
"folHlink",
|
|
1539
|
+
] as const;
|
|
1540
|
+
|
|
1541
|
+
export function themeClrSchemeXml(
|
|
1542
|
+
colorsByName: Record<string, string>,
|
|
1543
|
+
): string | undefined {
|
|
1544
|
+
const slots: string[] = [];
|
|
1545
|
+
for (const slot of THEME_COLOR_SLOTS) {
|
|
1546
|
+
const color = colorsByName[slot];
|
|
1547
|
+
if (!color) return undefined;
|
|
1548
|
+
slots.push(`<a:${slot}>${drawingMlColor(colorToHex(color))}</a:${slot}>`);
|
|
1549
|
+
}
|
|
1550
|
+
return `<a:clrScheme name="Deck">${slots.join("")}</a:clrScheme>`;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
function replaceOnce(
|
|
1554
|
+
xml: string,
|
|
1555
|
+
pattern: RegExp,
|
|
1556
|
+
replacement: string,
|
|
1557
|
+
what: string,
|
|
1558
|
+
): string {
|
|
1559
|
+
if (!pattern.test(xml)) {
|
|
1560
|
+
fail(
|
|
1561
|
+
`[export-pptx] could not rewrite ${what}: pptxgenjs no longer emits the node this patches. Nothing was written rather than shipping a deck that silently lost it.`,
|
|
1562
|
+
{ errorCode: "pptx_export_rewrite_failed", statusCode: 500 },
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
return xml.replace(pattern, () => replacement);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
export async function applyDeckIdentity(
|
|
1569
|
+
buffer: Buffer,
|
|
1570
|
+
args: {
|
|
1571
|
+
themeColors?: Record<string, string>;
|
|
1572
|
+
slideGradients: Map<number, string>;
|
|
1573
|
+
},
|
|
1574
|
+
): Promise<Buffer> {
|
|
1575
|
+
const clrScheme = args.themeColors
|
|
1576
|
+
? themeClrSchemeXml(args.themeColors)
|
|
1577
|
+
: undefined;
|
|
1578
|
+
if (!clrScheme && args.slideGradients.size === 0) return buffer;
|
|
1579
|
+
|
|
1580
|
+
const JSZip = (await import("jszip")).default;
|
|
1581
|
+
const zip = await JSZip.loadAsync(buffer);
|
|
1582
|
+
const rewrite = async (
|
|
1583
|
+
partPath: string,
|
|
1584
|
+
pattern: RegExp,
|
|
1585
|
+
replacement: string,
|
|
1586
|
+
what: string,
|
|
1587
|
+
) => {
|
|
1588
|
+
const xml = await zip.file(partPath)?.async("string");
|
|
1589
|
+
if (xml === undefined) {
|
|
1590
|
+
fail(`[export-pptx] generated package is missing ${partPath}`, {
|
|
1591
|
+
errorCode: "pptx_export_package_incomplete",
|
|
1592
|
+
statusCode: 500,
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
zip.file(partPath, replaceOnce(xml, pattern, replacement, what));
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
if (clrScheme) {
|
|
1599
|
+
await rewrite(
|
|
1600
|
+
"ppt/theme/theme1.xml",
|
|
1601
|
+
/<a:clrScheme name="[^"]*">[\s\S]*?<\/a:clrScheme>/,
|
|
1602
|
+
clrScheme,
|
|
1603
|
+
"the theme color scheme",
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
for (const [slideIndex, gradFill] of args.slideGradients) {
|
|
1607
|
+
await rewrite(
|
|
1608
|
+
`ppt/slides/slide${slideIndex + 1}.xml`,
|
|
1609
|
+
/<p:bg>[\s\S]*?<\/p:bg>/,
|
|
1610
|
+
`<p:bg><p:bgPr>${gradFill}<a:effectLst/></p:bgPr></p:bg>`,
|
|
1611
|
+
`slide ${slideIndex + 1}'s gradient background`,
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
return zip.generateAsync({ type: "nodebuffer", compression: "DEFLATE" });
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
const MAX_REMOTE_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
1618
|
+
const MAX_REMOTE_IMAGE_TOTAL_BYTES = 50 * 1024 * 1024;
|
|
1619
|
+
|
|
1620
|
+
export interface RemoteImageByteBudget {
|
|
1621
|
+
maxImageBytes: number;
|
|
1622
|
+
maxTotalBytes: number;
|
|
1623
|
+
totalBytes: number;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
export function createRemoteImageByteBudget(
|
|
1627
|
+
limits: { maxImageBytes?: number; maxTotalBytes?: number } = {},
|
|
1628
|
+
): RemoteImageByteBudget {
|
|
1629
|
+
return {
|
|
1630
|
+
maxImageBytes: limits.maxImageBytes ?? MAX_REMOTE_IMAGE_BYTES,
|
|
1631
|
+
maxTotalBytes: limits.maxTotalBytes ?? MAX_REMOTE_IMAGE_TOTAL_BYTES,
|
|
1632
|
+
totalBytes: 0,
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
async function cancelImageResponse(response: Response): Promise<void> {
|
|
1637
|
+
try {
|
|
1638
|
+
await response.body?.cancel();
|
|
1639
|
+
} catch {
|
|
1640
|
+
// coercion-ok: cancellation is cleanup; the caller still reports the failed export.
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
async function readRemoteImageBody(
|
|
1645
|
+
response: Response,
|
|
1646
|
+
budget: RemoteImageByteBudget,
|
|
1647
|
+
): Promise<Buffer | null> {
|
|
1648
|
+
const declaredSize = Number(response.headers.get("content-length"));
|
|
1649
|
+
if (
|
|
1650
|
+
Number.isFinite(declaredSize) &&
|
|
1651
|
+
(declaredSize > budget.maxImageBytes ||
|
|
1652
|
+
budget.totalBytes + declaredSize > budget.maxTotalBytes)
|
|
1653
|
+
) {
|
|
1654
|
+
await cancelImageResponse(response);
|
|
1655
|
+
return null;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
const reader = response.body?.getReader();
|
|
1659
|
+
if (!reader) return null;
|
|
1660
|
+
const chunks: Uint8Array[] = [];
|
|
1661
|
+
let imageBytes = 0;
|
|
1662
|
+
try {
|
|
1663
|
+
while (true) {
|
|
1664
|
+
const { done, value } = await reader.read();
|
|
1665
|
+
if (done) break;
|
|
1666
|
+
const nextImageBytes = imageBytes + value.byteLength;
|
|
1667
|
+
if (
|
|
1668
|
+
nextImageBytes > budget.maxImageBytes ||
|
|
1669
|
+
budget.totalBytes + nextImageBytes > budget.maxTotalBytes
|
|
1670
|
+
) {
|
|
1671
|
+
await reader.cancel();
|
|
1672
|
+
return null;
|
|
1673
|
+
}
|
|
1674
|
+
imageBytes = nextImageBytes;
|
|
1675
|
+
chunks.push(value);
|
|
1676
|
+
}
|
|
1677
|
+
budget.totalBytes += imageBytes;
|
|
1678
|
+
return Buffer.concat(chunks, imageBytes);
|
|
1679
|
+
} catch {
|
|
1680
|
+
await cancelImageResponse(response);
|
|
1681
|
+
return null;
|
|
1682
|
+
} finally {
|
|
1683
|
+
reader.releaseLock();
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
export async function fetchImageAsBase64(
|
|
1688
|
+
url: string,
|
|
1689
|
+
ownerEmail?: string,
|
|
1690
|
+
budget = createRemoteImageByteBudget(),
|
|
1691
|
+
): Promise<string | null> {
|
|
1692
|
+
try {
|
|
1693
|
+
const parsedUrl = new URL(url, "http://slides.local");
|
|
1694
|
+
if (parsedUrl.pathname.startsWith("/api/import-assets/") && ownerEmail) {
|
|
1695
|
+
const token = parsedUrl.pathname.slice("/api/import-assets/".length);
|
|
1696
|
+
const localAsset = await readLocalImportedAsset({
|
|
1697
|
+
token,
|
|
1698
|
+
email: ownerEmail,
|
|
1699
|
+
});
|
|
1700
|
+
if (localAsset) {
|
|
1701
|
+
return `data:${localAsset.mimeType};base64,${Buffer.from(localAsset.data).toString("base64")}`;
|
|
1702
|
+
}
|
|
1703
|
+
return null;
|
|
1704
|
+
}
|
|
1705
|
+
const response = await ssrfSafeFetch(
|
|
1706
|
+
url,
|
|
1707
|
+
{ signal: AbortSignal.timeout(10_000) },
|
|
1708
|
+
{ maxRedirects: 3 },
|
|
1709
|
+
);
|
|
1710
|
+
if (!response.ok) {
|
|
1711
|
+
await cancelImageResponse(response);
|
|
1712
|
+
return null;
|
|
1713
|
+
}
|
|
1714
|
+
const contentType = response.headers.get("content-type") || "";
|
|
1715
|
+
if (!contentType.toLowerCase().startsWith("image/")) {
|
|
1716
|
+
await cancelImageResponse(response);
|
|
1717
|
+
return null;
|
|
1718
|
+
}
|
|
1719
|
+
const buffer = await readRemoteImageBody(response, budget);
|
|
1720
|
+
if (!buffer) return null;
|
|
1721
|
+
const base64 = buffer.toString("base64");
|
|
1722
|
+
return `data:${contentType};base64,${base64}`;
|
|
1723
|
+
} catch {
|
|
1724
|
+
// coercion-ok: the caller treats null as an image export failure before creating the file.
|
|
1725
|
+
return null;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
const trackPptxExportFailures = withExportFailureTracking<{
|
|
1730
|
+
deckId: string;
|
|
1731
|
+
includeNotes: boolean;
|
|
1732
|
+
}>("pptx");
|
|
1733
|
+
|
|
1734
|
+
type SlidesPptxDownloadContext = {
|
|
1735
|
+
slidesPptxDownload?: true;
|
|
1736
|
+
slidesPptxDownloadFilename?: string;
|
|
1737
|
+
slidesPptxDownloadPersist?: true;
|
|
1738
|
+
slidesPptxDownloadExpectedRevision?: string;
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
function slidesPptxDownloadContext(
|
|
1742
|
+
ctx: unknown,
|
|
1743
|
+
): SlidesPptxDownloadContext | undefined {
|
|
1744
|
+
const context = ctx as SlidesPptxDownloadContext | undefined;
|
|
1745
|
+
return context?.slidesPptxDownload === true ? context : undefined;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
function isSafePptxFilename(filename: unknown): filename is string {
|
|
1749
|
+
return (
|
|
1750
|
+
typeof filename === "string" &&
|
|
1751
|
+
!filename.includes("..") &&
|
|
1752
|
+
path.basename(filename) === filename &&
|
|
1753
|
+
path.extname(filename).toLowerCase() === ".pptx" &&
|
|
1754
|
+
/^[a-zA-Z0-9_.-]+$/.test(filename)
|
|
1755
|
+
);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
export default defineAction({
|
|
1759
|
+
description:
|
|
1760
|
+
"Export legacy/imported HTML slides and source-backed slides as a PowerPoint (.pptx) file, preserving imported PPTX geometry, text styles, shapes, and images. For source slides without a static preview, the action attempts bounded server-side static rendering; source that requires Worker rendering returns source_runtime_export_required before a file is created. Freeform editor objects must use the Slides 2 editor's Export > PowerPoint flow so browser-rendered geometry is preserved. Returns a download URL for a successful export.",
|
|
1761
|
+
schema: z.object({
|
|
1762
|
+
deckId: z.string().describe("Deck ID to export"),
|
|
1763
|
+
includeNotes: z
|
|
1764
|
+
.preprocess(
|
|
1765
|
+
(v) => (v === "true" ? true : v === "false" ? false : v),
|
|
1766
|
+
z.boolean().optional().default(true),
|
|
1767
|
+
)
|
|
1768
|
+
.describe("Include speaker notes"),
|
|
1769
|
+
}),
|
|
1770
|
+
mcpAnnotations: {
|
|
1771
|
+
readOnlyHint: false,
|
|
1772
|
+
destructiveHint: false,
|
|
1773
|
+
openWorldHint: false,
|
|
1774
|
+
},
|
|
1775
|
+
run: trackPptxExportFailures(async (args, ctx, facts) => {
|
|
1776
|
+
const { deckId, includeNotes } = args;
|
|
1777
|
+
const downloadContext = slidesPptxDownloadContext(ctx);
|
|
1778
|
+
const userEmail = getRequestUserEmail();
|
|
1779
|
+
if (!userEmail)
|
|
1780
|
+
fail("no authenticated user", {
|
|
1781
|
+
errorCode: "not_authenticated",
|
|
1782
|
+
statusCode: 401,
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1785
|
+
const access = await resolveAccess("deck", deckId);
|
|
1786
|
+
if (!access)
|
|
1787
|
+
fail(`Deck not found: ${deckId}`, {
|
|
1788
|
+
errorCode: "deck_not_found",
|
|
1789
|
+
statusCode: 404,
|
|
1790
|
+
});
|
|
1791
|
+
|
|
1792
|
+
facts.deckId = deckId;
|
|
1793
|
+
const row = access.resource;
|
|
1794
|
+
const exportNotes = includeNotes && canReadPresenterNotes(access.role);
|
|
1795
|
+
assertSlides2DeckData(row.data);
|
|
1796
|
+
const exportRevision = pptxExportRevisionKey(
|
|
1797
|
+
deckId,
|
|
1798
|
+
row.updatedAt,
|
|
1799
|
+
row.title,
|
|
1800
|
+
row.data,
|
|
1801
|
+
exportNotes,
|
|
1802
|
+
);
|
|
1803
|
+
if (
|
|
1804
|
+
downloadContext?.slidesPptxDownloadExpectedRevision &&
|
|
1805
|
+
downloadContext.slidesPptxDownloadExpectedRevision !== exportRevision
|
|
1806
|
+
) {
|
|
1807
|
+
fail("Deck changed after this export link was created. Export again.", {
|
|
1808
|
+
errorCode: "export_revision_stale",
|
|
1809
|
+
statusCode: 409,
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
const deckData = JSON.parse(row.data);
|
|
1813
|
+
const slides = deckData.slides || [];
|
|
1814
|
+
facts.slideCount = slides.length;
|
|
1815
|
+
facts.generationAttemptId = generationAttemptIdOf(
|
|
1816
|
+
deckData.generationContext,
|
|
1817
|
+
);
|
|
1818
|
+
if (slides.length === 0) {
|
|
1819
|
+
fail("Cannot export empty deck", {
|
|
1820
|
+
errorCode: "empty_deck",
|
|
1821
|
+
statusCode: 400,
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
const pptxSlides: unknown[] = [];
|
|
1825
|
+
for (const slide of slides) {
|
|
1826
|
+
if (!slide || typeof slide !== "object" || Array.isArray(slide)) {
|
|
1827
|
+
pptxSlides.push(slide);
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
const slideRecord = slide as Record<string, unknown>;
|
|
1831
|
+
const sourceTsx = slideRecord.sourceTsx;
|
|
1832
|
+
const content = slideRecord.content;
|
|
1833
|
+
if (
|
|
1834
|
+
slideRecord.sourceRuntimeRequired !== true &&
|
|
1835
|
+
typeof sourceTsx === "string" &&
|
|
1836
|
+
sourceTsx.trim() &&
|
|
1837
|
+
!(typeof content === "string" && content.trim())
|
|
1838
|
+
) {
|
|
1839
|
+
const rendered = await compileSlideSource(sourceTsx, {
|
|
1840
|
+
ownerEmail: row.ownerEmail,
|
|
1841
|
+
orgId: row.orgId,
|
|
1842
|
+
});
|
|
1843
|
+
pptxSlides.push(
|
|
1844
|
+
rendered.content.trim()
|
|
1845
|
+
? { ...slideRecord, content: rendered.content }
|
|
1846
|
+
: slide,
|
|
1847
|
+
);
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
pptxSlides.push(slide);
|
|
1851
|
+
}
|
|
1852
|
+
const sourceRuntimeError = sourceRuntimeExportError(pptxSlides, "pptx");
|
|
1853
|
+
if (sourceRuntimeError) {
|
|
1854
|
+
fail(sourceRuntimeError.message, {
|
|
1855
|
+
errorCode: sourceRuntimeError.errorCode,
|
|
1856
|
+
statusCode: sourceRuntimeError.statusCode,
|
|
1857
|
+
details: {
|
|
1858
|
+
format: sourceRuntimeError.format,
|
|
1859
|
+
slideIds: sourceRuntimeError.slideIds,
|
|
1860
|
+
slideCount: sourceRuntimeError.slideCount,
|
|
1861
|
+
},
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
const rawAspectRatio = deckData.aspectRatio;
|
|
1865
|
+
const aspectRatio: AspectRatio | undefined = ASPECT_RATIO_VALUES.includes(
|
|
1866
|
+
rawAspectRatio,
|
|
1867
|
+
)
|
|
1868
|
+
? rawAspectRatio
|
|
1869
|
+
: undefined;
|
|
1870
|
+
const slideContents: string[] = pptxSlides.map(
|
|
1871
|
+
(slide: unknown, index: number) =>
|
|
1872
|
+
slide &&
|
|
1873
|
+
typeof slide === "object" &&
|
|
1874
|
+
typeof (slide as { content?: unknown }).content === "string"
|
|
1875
|
+
? fillSlideNumberTokensInHtml(
|
|
1876
|
+
(slide as { content: string }).content,
|
|
1877
|
+
{
|
|
1878
|
+
number: index + 1,
|
|
1879
|
+
count: slides.length,
|
|
1880
|
+
},
|
|
1881
|
+
)
|
|
1882
|
+
: "",
|
|
1883
|
+
);
|
|
1884
|
+
const sourcePage = slideContents
|
|
1885
|
+
.map(sourcePageInches)
|
|
1886
|
+
.find((page) => page !== undefined);
|
|
1887
|
+
const dims: SlideDims = {
|
|
1888
|
+
...getAspectRatioDims(aspectRatio),
|
|
1889
|
+
...(sourcePage ? { pptxInches: sourcePage } : {}),
|
|
1890
|
+
};
|
|
1891
|
+
|
|
1892
|
+
const PptxGenJS = (await import("pptxgenjs")).default;
|
|
1893
|
+
const pptx = new PptxGenJS();
|
|
1894
|
+
const remoteImageBudget = createRemoteImageByteBudget();
|
|
1895
|
+
|
|
1896
|
+
if (
|
|
1897
|
+
Math.abs(dims.pptxInches.w - 13.33) < 0.01 &&
|
|
1898
|
+
Math.abs(dims.pptxInches.h - 7.5) < 0.01
|
|
1899
|
+
) {
|
|
1900
|
+
pptx.layout = "LAYOUT_WIDE";
|
|
1901
|
+
} else {
|
|
1902
|
+
pptx.defineLayout({
|
|
1903
|
+
name: "AGENT_NATIVE",
|
|
1904
|
+
width: dims.pptxInches.w,
|
|
1905
|
+
height: dims.pptxInches.h,
|
|
1906
|
+
});
|
|
1907
|
+
pptx.layout = "AGENT_NATIVE";
|
|
1908
|
+
}
|
|
1909
|
+
pptx.author = "Agent-Native Slides 2";
|
|
1910
|
+
pptx.title = row.title;
|
|
1911
|
+
const [headFontFace, bodyFontFace] = deckThemeFonts(deckData);
|
|
1912
|
+
if (headFontFace) pptx.theme = { headFontFace, bodyFontFace };
|
|
1913
|
+
|
|
1914
|
+
const slideGradients = new Map<number, string>();
|
|
1915
|
+
let backgroundGradientsFlattened = 0;
|
|
1916
|
+
|
|
1917
|
+
for (const [slideIndex, slide] of slides.entries()) {
|
|
1918
|
+
const pptxSlide = pptx.addSlide();
|
|
1919
|
+
const slideContent = slideContents[slideIndex];
|
|
1920
|
+
const {
|
|
1921
|
+
texts,
|
|
1922
|
+
images,
|
|
1923
|
+
shapes,
|
|
1924
|
+
tables,
|
|
1925
|
+
grid,
|
|
1926
|
+
bgColor,
|
|
1927
|
+
bgTransparency,
|
|
1928
|
+
bgGradient,
|
|
1929
|
+
} = parseSlideHtml(slideContent, aspectRatio, slideIndex + 1);
|
|
1930
|
+
|
|
1931
|
+
pptxSlide.background = {
|
|
1932
|
+
color: bgColor,
|
|
1933
|
+
...(bgTransparency != null ? { transparency: bgTransparency } : {}),
|
|
1934
|
+
};
|
|
1935
|
+
if (bgGradient) {
|
|
1936
|
+
const gradFill = cssGradientToDrawingMl(bgGradient);
|
|
1937
|
+
if (gradFill) {
|
|
1938
|
+
slideGradients.set(slideIndex, gradFill);
|
|
1939
|
+
} else {
|
|
1940
|
+
backgroundGradientsFlattened++;
|
|
1941
|
+
console.warn(
|
|
1942
|
+
`[export-pptx] slide ${slideIndex + 1} background "${bgGradient}" has no DrawingML equivalent; exported as flat #${bgColor}`,
|
|
1943
|
+
);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
if (grid) {
|
|
1948
|
+
const gridWidth = pxToIn(grid.stepX, dims);
|
|
1949
|
+
const gridHeight = pxToInY(grid.stepY, dims);
|
|
1950
|
+
const gridX = pxToIn(grid.offsetX, dims);
|
|
1951
|
+
const gridY = pxToInY(grid.offsetY, dims);
|
|
1952
|
+
const lineWidth = Math.max(0.5, grid.lineWidth * 0.75);
|
|
1953
|
+
const gridLine = {
|
|
1954
|
+
color: grid.color,
|
|
1955
|
+
width: lineWidth,
|
|
1956
|
+
...(grid.transparency != null
|
|
1957
|
+
? { transparency: grid.transparency }
|
|
1958
|
+
: {}),
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
for (let x = gridX; x < dims.pptxInches.w; x += gridWidth) {
|
|
1962
|
+
pptxSlide.addShape(pptx.ShapeType.line, {
|
|
1963
|
+
x,
|
|
1964
|
+
y: 0,
|
|
1965
|
+
w: 0,
|
|
1966
|
+
h: dims.pptxInches.h,
|
|
1967
|
+
line: gridLine,
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
for (let y = gridY; y < dims.pptxInches.h; y += gridHeight) {
|
|
1971
|
+
pptxSlide.addShape(pptx.ShapeType.line, {
|
|
1972
|
+
x: 0,
|
|
1973
|
+
y,
|
|
1974
|
+
w: dims.pptxInches.w,
|
|
1975
|
+
h: 0,
|
|
1976
|
+
line: gridLine,
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
const orderedTexts = [...texts].sort(
|
|
1982
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0),
|
|
1983
|
+
);
|
|
1984
|
+
const orderedImages = [...images].sort(
|
|
1985
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0),
|
|
1986
|
+
);
|
|
1987
|
+
const orderedShapes = [...shapes].sort(
|
|
1988
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0),
|
|
1989
|
+
);
|
|
1990
|
+
const orderedTables = [...tables].sort(
|
|
1991
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0),
|
|
1992
|
+
);
|
|
1993
|
+
|
|
1994
|
+
const orderedObjects = orderImportedObjects({
|
|
1995
|
+
images: orderedImages,
|
|
1996
|
+
shapes: orderedShapes,
|
|
1997
|
+
tables: orderedTables,
|
|
1998
|
+
texts: orderedTexts,
|
|
1999
|
+
});
|
|
2000
|
+
|
|
2001
|
+
for (const object of orderedObjects) {
|
|
2002
|
+
if (object.kind === "text") {
|
|
2003
|
+
const t = object.value;
|
|
2004
|
+
const options = {
|
|
2005
|
+
x: t.x,
|
|
2006
|
+
y: t.y,
|
|
2007
|
+
w: t.w,
|
|
2008
|
+
h: t.h,
|
|
2009
|
+
color: t.color,
|
|
2010
|
+
bold: t.bold,
|
|
2011
|
+
align: t.align || "left",
|
|
2012
|
+
valign: "top" as const,
|
|
2013
|
+
wrap: true,
|
|
2014
|
+
...(t.fontSize != null ? { fontSize: t.fontSize } : {}),
|
|
2015
|
+
...(t.fontFace != null ? { fontFace: t.fontFace } : {}),
|
|
2016
|
+
...(t.transparency != null ? { transparency: t.transparency } : {}),
|
|
2017
|
+
...(t.letterSpacing != null
|
|
2018
|
+
? { charSpacing: t.letterSpacing }
|
|
2019
|
+
: {}),
|
|
2020
|
+
...(t.lineSpacingMultiple != null
|
|
2021
|
+
? { lineSpacingMultiple: t.lineSpacingMultiple }
|
|
2022
|
+
: {}),
|
|
2023
|
+
...(t.rotate != null ? { rotate: t.rotate } : {}),
|
|
2024
|
+
};
|
|
2025
|
+
if (t.runs?.length) {
|
|
2026
|
+
pptxSlide.addText(t.runs, options);
|
|
2027
|
+
} else {
|
|
2028
|
+
pptxSlide.addText(t.text, options);
|
|
2029
|
+
}
|
|
2030
|
+
} else if (object.kind === "image") {
|
|
2031
|
+
const img = object.value;
|
|
2032
|
+
const dataUri = await fetchImageAsBase64(
|
|
2033
|
+
img.src,
|
|
2034
|
+
userEmail,
|
|
2035
|
+
remoteImageBudget,
|
|
2036
|
+
);
|
|
2037
|
+
if (!dataUri) {
|
|
2038
|
+
fail(
|
|
2039
|
+
`Cannot export PowerPoint: an image on slide ${slideIndex + 1} could not be loaded. No file was created.`,
|
|
2040
|
+
{
|
|
2041
|
+
errorCode: "pptx_image_unavailable",
|
|
2042
|
+
statusCode: 422,
|
|
2043
|
+
details: { slideNumber: slideIndex + 1 },
|
|
2044
|
+
},
|
|
2045
|
+
);
|
|
2046
|
+
}
|
|
2047
|
+
pptxSlide.addImage({
|
|
2048
|
+
data: dataUri,
|
|
2049
|
+
x: img.x,
|
|
2050
|
+
y: img.y,
|
|
2051
|
+
w: img.w,
|
|
2052
|
+
h: img.h,
|
|
2053
|
+
...(img.rotate != null ? { rotate: img.rotate } : {}),
|
|
2054
|
+
});
|
|
2055
|
+
} else if (object.kind === "table") {
|
|
2056
|
+
pptxSlide.addTable(object.value.rows, tableOptions(object.value));
|
|
2057
|
+
} else {
|
|
2058
|
+
const shape = object.value;
|
|
2059
|
+
pptxSlide.addShape(
|
|
2060
|
+
resolveShapeType(pptx.ShapeType, shape.shapeType),
|
|
2061
|
+
{
|
|
2062
|
+
x: shape.x,
|
|
2063
|
+
y: shape.y,
|
|
2064
|
+
w: shape.w,
|
|
2065
|
+
h: shape.h,
|
|
2066
|
+
...(shape.rectRadius != null
|
|
2067
|
+
? { rectRadius: shape.rectRadius }
|
|
2068
|
+
: {}),
|
|
2069
|
+
...(shape.rotate != null ? { rotate: shape.rotate } : {}),
|
|
2070
|
+
...(shape.points ? { points: shape.points } : {}),
|
|
2071
|
+
...(shape.fill
|
|
2072
|
+
? {
|
|
2073
|
+
fill: {
|
|
2074
|
+
color: shape.fill,
|
|
2075
|
+
...(shape.fillTransparency != null
|
|
2076
|
+
? { transparency: shape.fillTransparency }
|
|
2077
|
+
: {}),
|
|
2078
|
+
},
|
|
2079
|
+
}
|
|
2080
|
+
: {}),
|
|
2081
|
+
...(shape.lineColor
|
|
2082
|
+
? {
|
|
2083
|
+
line: {
|
|
2084
|
+
color: shape.lineColor,
|
|
2085
|
+
width: shape.lineWidth ?? 1,
|
|
2086
|
+
...(shape.lineDashType
|
|
2087
|
+
? { dashType: shape.lineDashType }
|
|
2088
|
+
: {}),
|
|
2089
|
+
...(shape.lineHeadType
|
|
2090
|
+
? { beginArrowType: shape.lineHeadType }
|
|
2091
|
+
: {}),
|
|
2092
|
+
...(shape.lineTailType
|
|
2093
|
+
? { endArrowType: shape.lineTailType }
|
|
2094
|
+
: {}),
|
|
2095
|
+
...(shape.lineTransparency != null
|
|
2096
|
+
? { transparency: shape.lineTransparency }
|
|
2097
|
+
: {}),
|
|
2098
|
+
},
|
|
2099
|
+
}
|
|
2100
|
+
: {}),
|
|
2101
|
+
},
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
if (
|
|
2107
|
+
exportNotes &&
|
|
2108
|
+
slide &&
|
|
2109
|
+
typeof slide.notes === "string" &&
|
|
2110
|
+
slide.notes
|
|
2111
|
+
) {
|
|
2112
|
+
pptxSlide.addNotes(slide.notes);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
const buffer = await applyDeckIdentity(
|
|
2117
|
+
(await pptx.write({ outputType: "nodebuffer" })) as Buffer,
|
|
2118
|
+
{ themeColors: deckThemeColors(deckData), slideGradients },
|
|
2119
|
+
);
|
|
2120
|
+
const filename = isSafePptxFilename(
|
|
2121
|
+
downloadContext?.slidesPptxDownloadFilename,
|
|
2122
|
+
)
|
|
2123
|
+
? downloadContext.slidesPptxDownloadFilename
|
|
2124
|
+
: safeGeneratedFilename(row.title, ".pptx", deckId);
|
|
2125
|
+
const persistExport =
|
|
2126
|
+
!downloadContext || downloadContext.slidesPptxDownloadPersist === true;
|
|
2127
|
+
|
|
2128
|
+
const exportDir = tenantExportDir(userEmail);
|
|
2129
|
+
if (persistExport) {
|
|
2130
|
+
fs.mkdirSync(exportDir, { recursive: true });
|
|
2131
|
+
fs.writeFileSync(path.join(exportDir, filename), buffer);
|
|
2132
|
+
fs.writeFileSync(
|
|
2133
|
+
pptxDeckBindingPath(exportDir, filename),
|
|
2134
|
+
exportRevision,
|
|
2135
|
+
);
|
|
2136
|
+
}
|
|
2137
|
+
if (isHostedSlidesRuntime()) {
|
|
2138
|
+
try {
|
|
2139
|
+
pruneHostedPptxExports(
|
|
2140
|
+
exportDir,
|
|
2141
|
+
Date.now(),
|
|
2142
|
+
persistExport ? filename : undefined,
|
|
2143
|
+
);
|
|
2144
|
+
} catch (error) {
|
|
2145
|
+
console.warn(
|
|
2146
|
+
"[export-pptx] Could not prune hosted PPTX exports",
|
|
2147
|
+
error,
|
|
2148
|
+
);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
trackDeckExported(
|
|
2153
|
+
{
|
|
2154
|
+
...facts,
|
|
2155
|
+
deckId,
|
|
2156
|
+
exportFormat: "pptx",
|
|
2157
|
+
renderLocation: "server",
|
|
2158
|
+
status: "completed",
|
|
2159
|
+
},
|
|
2160
|
+
ctx,
|
|
2161
|
+
);
|
|
2162
|
+
|
|
2163
|
+
return {
|
|
2164
|
+
downloadUrl: getExportUrl(filename, {
|
|
2165
|
+
deckId,
|
|
2166
|
+
includeNotes: exportNotes,
|
|
2167
|
+
exportRevision,
|
|
2168
|
+
}),
|
|
2169
|
+
...(downloadContext ? { buffer } : {}),
|
|
2170
|
+
filename,
|
|
2171
|
+
slideCount: slides.length,
|
|
2172
|
+
...(backgroundGradientsFlattened > 0
|
|
2173
|
+
? { backgroundGradientsFlattened }
|
|
2174
|
+
: {}),
|
|
2175
|
+
};
|
|
2176
|
+
}),
|
|
2177
|
+
});
|
|
2178
|
+
|
|
2179
|
+
function deckThemeColors(
|
|
2180
|
+
deckData: unknown,
|
|
2181
|
+
): Record<string, string> | undefined {
|
|
2182
|
+
const colorsByName = (
|
|
2183
|
+
deckData as { theme?: { colorsByName?: unknown } } | null
|
|
2184
|
+
)?.theme?.colorsByName;
|
|
2185
|
+
if (!colorsByName || typeof colorsByName !== "object") return undefined;
|
|
2186
|
+
const entries = Object.entries(colorsByName).filter(
|
|
2187
|
+
(entry): entry is [string, string] => typeof entry[1] === "string",
|
|
2188
|
+
);
|
|
2189
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
function deckThemeFonts(
|
|
2193
|
+
deckData: unknown,
|
|
2194
|
+
): [string | undefined, string | undefined] {
|
|
2195
|
+
const fonts = (deckData as { theme?: { fonts?: unknown } } | null)?.theme
|
|
2196
|
+
?.fonts;
|
|
2197
|
+
if (!Array.isArray(fonts)) return [undefined, undefined];
|
|
2198
|
+
const face = (index: number) =>
|
|
2199
|
+
typeof fonts[index] === "string" && fonts[index]
|
|
2200
|
+
? (fonts[index] as string)
|
|
2201
|
+
: undefined;
|
|
2202
|
+
return [face(0), face(1) ?? face(0)];
|
|
2203
|
+
}
|