handoff-app-next 2.0.0-canary.1
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/Changelog.md +2069 -0
- package/License.md +19 -0
- package/README.md +461 -0
- package/components.json +21 -0
- package/config/config.template.js +95 -0
- package/config/config.template.ts +54 -0
- package/config/docs/design.md +14 -0
- package/config/docs/foundations/border-radius.md +6 -0
- package/config/docs/foundations/colors.md +7 -0
- package/config/docs/foundations/effects.md +8 -0
- package/config/docs/foundations/elevation.md +6 -0
- package/config/docs/foundations/focus.md +6 -0
- package/config/docs/foundations/fonts.md +7 -0
- package/config/docs/foundations/grid.md +21 -0
- package/config/docs/foundations/icon.md +6 -0
- package/config/docs/foundations/icons.md +6 -0
- package/config/docs/foundations/logo.md +7 -0
- package/config/docs/foundations/logos.md +7 -0
- package/config/docs/foundations/motion.md +6 -0
- package/config/docs/foundations/spacing.md +7 -0
- package/config/docs/foundations/typography.md +8 -0
- package/config/docs/foundations.md +44 -0
- package/config/docs/guidelines.md +11 -0
- package/config/docs/index.md +9 -0
- package/config/docs/playground.md +14 -0
- package/config/docs/system/figma-sync.md +14 -0
- package/config/docs/system/tokens/foundations/colors.md +24 -0
- package/config/docs/system/tokens/foundations/effects.md +21 -0
- package/config/docs/system/tokens/foundations/spacing.md +22 -0
- package/config/docs/system/tokens/foundations/typography.md +24 -0
- package/config/docs/system.md +13 -0
- package/config/templates/component/template.hbs +6 -0
- package/config/templates/component/template.js +0 -0
- package/config/templates/component/template.json +45 -0
- package/config/templates/component/template.scss +2 -0
- package/config/templates/page.md +11 -0
- package/config/templates/page.mdx +49 -0
- package/config/templates/template.html +7 -0
- package/dist/app/components/Component/Cards.d.ts +25 -0
- package/dist/app/components/Component/Cards.jsx +27 -0
- package/dist/app/lib/adapter-kit/types.d.ts +581 -0
- package/dist/app/lib/adapter-kit/types.js +36 -0
- package/dist/app/lib/hubspot-field-map.d.ts +170 -0
- package/dist/app/lib/hubspot-field-map.js +538 -0
- package/dist/app/lib/hubspot-module/build-module.d.ts +136 -0
- package/dist/app/lib/hubspot-module/build-module.js +122 -0
- package/dist/app/lib/hubspot-module/context.d.ts +111 -0
- package/dist/app/lib/hubspot-module/context.js +228 -0
- package/dist/app/lib/hubspot-module/fields/boolean.d.ts +8 -0
- package/dist/app/lib/hubspot-module/fields/boolean.js +22 -0
- package/dist/app/lib/hubspot-module/fields/button.d.ts +19 -0
- package/dist/app/lib/hubspot-module/fields/button.js +66 -0
- package/dist/app/lib/hubspot-module/fields/fields.d.ts +20 -0
- package/dist/app/lib/hubspot-module/fields/fields.js +93 -0
- package/dist/app/lib/hubspot-module/fields/generic.d.ts +33 -0
- package/dist/app/lib/hubspot-module/fields/generic.js +150 -0
- package/dist/app/lib/hubspot-module/fields/hubdb.d.ts +14 -0
- package/dist/app/lib/hubspot-module/fields/hubdb.js +155 -0
- package/dist/app/lib/hubspot-module/fields/image.d.ts +27 -0
- package/dist/app/lib/hubspot-module/fields/image.js +59 -0
- package/dist/app/lib/hubspot-module/fields/menu.d.ts +8 -0
- package/dist/app/lib/hubspot-module/fields/menu.js +12 -0
- package/dist/app/lib/hubspot-module/fields/object.d.ts +11 -0
- package/dist/app/lib/hubspot-module/fields/object.js +31 -0
- package/dist/app/lib/hubspot-module/fields/select.d.ts +17 -0
- package/dist/app/lib/hubspot-module/fields/select.js +37 -0
- package/dist/app/lib/hubspot-module/fields/text.d.ts +15 -0
- package/dist/app/lib/hubspot-module/fields/text.js +63 -0
- package/dist/app/lib/hubspot-module/fields/url.d.ts +35 -0
- package/dist/app/lib/hubspot-module/fields/url.js +57 -0
- package/dist/app/lib/hubspot-module/fields/utils.d.ts +20 -0
- package/dist/app/lib/hubspot-module/fields/utils.js +33 -0
- package/dist/app/lib/hubspot-module/fields/video.d.ts +21 -0
- package/dist/app/lib/hubspot-module/fields/video.js +70 -0
- package/dist/app/lib/hubspot-module/index.d.ts +20 -0
- package/dist/app/lib/hubspot-module/index.js +17 -0
- package/dist/app/lib/hubspot-module/transpile.d.ts +27 -0
- package/dist/app/lib/hubspot-module/transpile.js +658 -0
- package/dist/app/lib/hubspot-module/types.d.ts +204 -0
- package/dist/app/lib/hubspot-module/types.js +47 -0
- package/dist/app/lib/hubspot-module-build.d.ts +33 -0
- package/dist/app/lib/hubspot-module-build.js +41 -0
- package/dist/app-builder/build.d.ts +21 -0
- package/dist/app-builder/build.js +649 -0
- package/dist/app-builder/client-config.d.ts +17 -0
- package/dist/app-builder/client-config.js +106 -0
- package/dist/app-builder/config-diff/index.d.ts +4 -0
- package/dist/app-builder/config-diff/index.js +3 -0
- package/dist/app-builder/config-diff/registry.d.ts +9 -0
- package/dist/app-builder/config-diff/registry.js +15 -0
- package/dist/app-builder/config-diff/snapshot.d.ts +13 -0
- package/dist/app-builder/config-diff/snapshot.js +38 -0
- package/dist/app-builder/config-diff/strategies/pattern.d.ts +2 -0
- package/dist/app-builder/config-diff/strategies/pattern.js +66 -0
- package/dist/app-builder/config-diff/types.d.ts +33 -0
- package/dist/app-builder/config-diff/types.js +1 -0
- package/dist/app-builder/index.d.ts +6 -0
- package/dist/app-builder/index.js +4 -0
- package/dist/app-builder/path-contract.d.ts +23 -0
- package/dist/app-builder/path-contract.js +60 -0
- package/dist/app-builder/paths.d.ts +24 -0
- package/dist/app-builder/paths.js +82 -0
- package/dist/app-builder/watchers/component.d.ts +15 -0
- package/dist/app-builder/watchers/component.js +58 -0
- package/dist/app-builder/watchers/utils.d.ts +14 -0
- package/dist/app-builder/watchers/utils.js +31 -0
- package/dist/app-builder/watchers.d.ts +44 -0
- package/dist/app-builder/watchers.js +299 -0
- package/dist/app-builder/websocket.d.ts +12 -0
- package/dist/app-builder/websocket.js +56 -0
- package/dist/cache/build-cache.d.ts +169 -0
- package/dist/cache/build-cache.js +421 -0
- package/dist/cache/file-state.d.ts +58 -0
- package/dist/cache/file-state.js +122 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.js +6 -0
- package/dist/cache/push-state.d.ts +69 -0
- package/dist/cache/push-state.js +156 -0
- package/dist/cli/create.d.ts +5 -0
- package/dist/cli/create.js +301 -0
- package/dist/cli/eject.d.ts +17 -0
- package/dist/cli/eject.js +82 -0
- package/dist/cli/fetch-design-md.d.ts +14 -0
- package/dist/cli/fetch-design-md.js +62 -0
- package/dist/cli/figma-audit.d.ts +7 -0
- package/dist/cli/figma-audit.js +55 -0
- package/dist/cli/init-claude-core.d.ts +26 -0
- package/dist/cli/init-claude-core.js +81 -0
- package/dist/cli/make.d.ts +12 -0
- package/dist/cli/make.js +178 -0
- package/dist/cli/scaffold.d.ts +5 -0
- package/dist/cli/scaffold.js +504 -0
- package/dist/cli/sync/apply-declaration-pull.d.ts +14 -0
- package/dist/cli/sync/apply-declaration-pull.js +184 -0
- package/dist/cli/sync/apply-pull.d.ts +24 -0
- package/dist/cli/sync/apply-pull.js +174 -0
- package/dist/cli/sync/cli-auth-store.d.ts +12 -0
- package/dist/cli/sync/cli-auth-store.js +44 -0
- package/dist/cli/sync/collect-build-artifacts.d.ts +17 -0
- package/dist/cli/sync/collect-build-artifacts.js +143 -0
- package/dist/cli/sync/collect-referenced-images.d.ts +36 -0
- package/dist/cli/sync/collect-referenced-images.js +165 -0
- package/dist/cli/sync/declaration-patch.d.ts +9 -0
- package/dist/cli/sync/declaration-patch.js +196 -0
- package/dist/cli/sync/hash.d.ts +2 -0
- package/dist/cli/sync/hash.js +11 -0
- package/dist/cli/sync/open-browser.d.ts +5 -0
- package/dist/cli/sync/open-browser.js +37 -0
- package/dist/cli/sync/push-provenance.d.ts +25 -0
- package/dist/cli/sync/push-provenance.js +82 -0
- package/dist/cli/sync/push-registry-content.d.ts +132 -0
- package/dist/cli/sync/push-registry-content.js +854 -0
- package/dist/cli/sync/push-shared-assets.d.ts +26 -0
- package/dist/cli/sync/push-shared-assets.js +33 -0
- package/dist/cli/sync/resolve-declaration-payload.d.ts +8 -0
- package/dist/cli/sync/resolve-declaration-payload.js +208 -0
- package/dist/cli/sync/resolve-declaration.d.ts +5 -0
- package/dist/cli/sync/resolve-declaration.js +12 -0
- package/dist/cli/sync/run-cli-login.d.ts +9 -0
- package/dist/cli/sync/run-cli-login.js +81 -0
- package/dist/cli/sync/run-history-purge.d.ts +19 -0
- package/dist/cli/sync/run-history-purge.js +112 -0
- package/dist/cli/sync/run-pull.d.ts +9 -0
- package/dist/cli/sync/run-pull.js +92 -0
- package/dist/cli/sync/run-push.d.ts +47 -0
- package/dist/cli/sync/run-push.js +585 -0
- package/dist/cli/sync/run-sync-status.d.ts +2 -0
- package/dist/cli/sync/run-sync-status.js +30 -0
- package/dist/cli/sync/sync-remote-env.d.ts +14 -0
- package/dist/cli/sync/sync-remote-env.js +52 -0
- package/dist/cli/sync/sync-state.d.ts +15 -0
- package/dist/cli/sync/sync-state.js +26 -0
- package/dist/cli/tokens/ensure-default-brand.d.ts +18 -0
- package/dist/cli/tokens/ensure-default-brand.js +95 -0
- package/dist/cli/tokens/migrate-legacy.d.ts +23 -0
- package/dist/cli/tokens/migrate-legacy.js +213 -0
- package/dist/cli/tokens/parse-css-brands.d.ts +25 -0
- package/dist/cli/tokens/parse-css-brands.js +148 -0
- package/dist/cli/tokens/transform.d.ts +12 -0
- package/dist/cli/tokens/transform.js +126 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +56 -0
- package/dist/commands/audit/figma-components.d.ts +8 -0
- package/dist/commands/audit/figma-components.js +27 -0
- package/dist/commands/build/app.d.ts +8 -0
- package/dist/commands/build/app.js +22 -0
- package/dist/commands/build/components.d.ts +7 -0
- package/dist/commands/build/components.js +17 -0
- package/dist/commands/build/hubspot.d.ts +56 -0
- package/dist/commands/build/hubspot.js +177 -0
- package/dist/commands/dev/index.d.ts +6 -0
- package/dist/commands/dev/index.js +14 -0
- package/dist/commands/eject/config.d.ts +6 -0
- package/dist/commands/eject/config.js +14 -0
- package/dist/commands/eject/pages.d.ts +6 -0
- package/dist/commands/eject/pages.js +14 -0
- package/dist/commands/eject/theme.d.ts +6 -0
- package/dist/commands/eject/theme.js +14 -0
- package/dist/commands/fetch/index.d.ts +6 -0
- package/dist/commands/fetch/index.js +14 -0
- package/dist/commands/history-purge.d.ts +19 -0
- package/dist/commands/history-purge.js +52 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +66 -0
- package/dist/commands/init/index.d.ts +5 -0
- package/dist/commands/init/index.js +12 -0
- package/dist/commands/init/vercel.d.ts +6 -0
- package/dist/commands/init/vercel.js +99 -0
- package/dist/commands/init-claude.d.ts +9 -0
- package/dist/commands/init-claude.js +47 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.js +28 -0
- package/dist/commands/logout.d.ts +6 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/make/component.d.ts +7 -0
- package/dist/commands/make/component.js +23 -0
- package/dist/commands/make/page.d.ts +8 -0
- package/dist/commands/make/page.js +33 -0
- package/dist/commands/make/template.d.ts +8 -0
- package/dist/commands/make/template.js +33 -0
- package/dist/commands/mcp-init.d.ts +12 -0
- package/dist/commands/mcp-init.js +94 -0
- package/dist/commands/mcp-token.d.ts +7 -0
- package/dist/commands/mcp-token.js +23 -0
- package/dist/commands/prepare-runtime.d.ts +7 -0
- package/dist/commands/prepare-runtime.js +28 -0
- package/dist/commands/pull.d.ts +7 -0
- package/dist/commands/pull.js +18 -0
- package/dist/commands/push-all.d.ts +23 -0
- package/dist/commands/push-all.js +146 -0
- package/dist/commands/push-assets.d.ts +8 -0
- package/dist/commands/push-assets.js +40 -0
- package/dist/commands/push-tokens.d.ts +8 -0
- package/dist/commands/push-tokens.js +40 -0
- package/dist/commands/push.d.ts +14 -0
- package/dist/commands/push.js +75 -0
- package/dist/commands/scaffold/index.d.ts +6 -0
- package/dist/commands/scaffold/index.js +15 -0
- package/dist/commands/start/index.d.ts +6 -0
- package/dist/commands/start/index.js +14 -0
- package/dist/commands/sync-status.d.ts +6 -0
- package/dist/commands/sync-status.js +14 -0
- package/dist/commands/tokens-build.d.ts +7 -0
- package/dist/commands/tokens-build.js +104 -0
- package/dist/commands/types.d.ts +5 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/utils.d.ts +18 -0
- package/dist/commands/utils.js +19 -0
- package/dist/commands/validate/components.d.ts +7 -0
- package/dist/commands/validate/components.js +19 -0
- package/dist/commands/validate.d.ts +11 -0
- package/dist/commands/validate.js +163 -0
- package/dist/commands/vercel-build.d.ts +7 -0
- package/dist/commands/vercel-build.js +81 -0
- package/dist/config/declaration-module-load.d.ts +6 -0
- package/dist/config/declaration-module-load.js +68 -0
- package/dist/config/defaults.d.ts +16 -0
- package/dist/config/defaults.js +60 -0
- package/dist/config/helpers.d.ts +7 -0
- package/dist/config/helpers.js +29 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.js +11 -0
- package/dist/config/loader.d.ts +20 -0
- package/dist/config/loader.js +107 -0
- package/dist/config/normalizers/declaration.d.ts +11 -0
- package/dist/config/normalizers/declaration.js +122 -0
- package/dist/config/normalizers/pattern.d.ts +8 -0
- package/dist/config/normalizers/pattern.js +31 -0
- package/dist/config/runtime.d.ts +42 -0
- package/dist/config/runtime.js +337 -0
- package/dist/config/validator.d.ts +9 -0
- package/dist/config/validator.js +22 -0
- package/dist/declarations/codegen.d.ts +57 -0
- package/dist/declarations/codegen.js +279 -0
- package/dist/declarations/helpers.d.ts +6 -0
- package/dist/declarations/helpers.js +20 -0
- package/dist/declarations/index.d.ts +2 -0
- package/dist/declarations/index.js +1 -0
- package/dist/declarations/types.d.ts +193 -0
- package/dist/declarations/types.js +1 -0
- package/dist/figma/component-linking.d.ts +164 -0
- package/dist/figma/component-linking.js +1080 -0
- package/dist/figma/image-fills.d.ts +32 -0
- package/dist/figma/image-fills.js +211 -0
- package/dist/generated/build-meta.d.ts +4 -0
- package/dist/generated/build-meta.js +6 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +301 -0
- package/dist/pipeline/archive.d.ts +19 -0
- package/dist/pipeline/archive.js +62 -0
- package/dist/pipeline/components.d.ts +5 -0
- package/dist/pipeline/components.js +7 -0
- package/dist/pipeline/documentation.d.ts +3 -0
- package/dist/pipeline/documentation.js +64 -0
- package/dist/pipeline/figma.d.ts +11 -0
- package/dist/pipeline/figma.js +142 -0
- package/dist/pipeline/hubspot/config.d.ts +179 -0
- package/dist/pipeline/hubspot/config.js +171 -0
- package/dist/pipeline/hubspot/emit.d.ts +101 -0
- package/dist/pipeline/hubspot/emit.js +283 -0
- package/dist/pipeline/index.d.ts +14 -0
- package/dist/pipeline/index.js +34 -0
- package/dist/pipeline/patterns.d.ts +8 -0
- package/dist/pipeline/patterns.js +8 -0
- package/dist/pipeline/styles.d.ts +10 -0
- package/dist/pipeline/styles.js +127 -0
- package/dist/pipeline/validation.d.ts +6 -0
- package/dist/pipeline/validation.js +23 -0
- package/dist/transformers/docgen/index.d.ts +24 -0
- package/dist/transformers/docgen/index.js +244 -0
- package/dist/transformers/plugins/csf-render.d.ts +5 -0
- package/dist/transformers/plugins/csf-render.js +406 -0
- package/dist/transformers/plugins/handlebars-previews.d.ts +12 -0
- package/dist/transformers/plugins/handlebars-previews.js +128 -0
- package/dist/transformers/plugins/index.d.ts +11 -0
- package/dist/transformers/plugins/index.js +10 -0
- package/dist/transformers/plugins/slot-probe-candidates.d.ts +159 -0
- package/dist/transformers/plugins/slot-probe-candidates.js +279 -0
- package/dist/transformers/plugins/slot-probe.d.ts +66 -0
- package/dist/transformers/plugins/slot-probe.js +298 -0
- package/dist/transformers/plugins/ssr-render.d.ts +33 -0
- package/dist/transformers/plugins/ssr-render.js +531 -0
- package/dist/transformers/plugins.d.ts +14 -0
- package/dist/transformers/plugins.js +15 -0
- package/dist/transformers/preview/component/api.d.ts +22 -0
- package/dist/transformers/preview/component/api.js +146 -0
- package/dist/transformers/preview/component/artifacts.d.ts +3 -0
- package/dist/transformers/preview/component/artifacts.js +103 -0
- package/dist/transformers/preview/component/build-shared-bundles.d.ts +83 -0
- package/dist/transformers/preview/component/build-shared-bundles.js +400 -0
- package/dist/transformers/preview/component/builder.d.ts +29 -0
- package/dist/transformers/preview/component/builder.js +638 -0
- package/dist/transformers/preview/component/css.d.ts +68 -0
- package/dist/transformers/preview/component/css.js +219 -0
- package/dist/transformers/preview/component/field-annotations.d.ts +129 -0
- package/dist/transformers/preview/component/field-annotations.js +325 -0
- package/dist/transformers/preview/component/html.d.ts +21 -0
- package/dist/transformers/preview/component/html.js +80 -0
- package/dist/transformers/preview/component/javascript.d.ts +24 -0
- package/dist/transformers/preview/component/javascript.js +162 -0
- package/dist/transformers/preview/component/normalizer.d.ts +35 -0
- package/dist/transformers/preview/component/normalizer.js +56 -0
- package/dist/transformers/preview/component/playwright-shared.d.ts +70 -0
- package/dist/transformers/preview/component/playwright-shared.js +164 -0
- package/dist/transformers/preview/component/preview-assets.d.ts +55 -0
- package/dist/transformers/preview/component/preview-assets.js +144 -0
- package/dist/transformers/preview/component/preview-merge.d.ts +53 -0
- package/dist/transformers/preview/component/preview-merge.js +50 -0
- package/dist/transformers/preview/component/preview-select.d.ts +86 -0
- package/dist/transformers/preview/component/preview-select.js +150 -0
- package/dist/transformers/preview/component/preview-server.d.ts +41 -0
- package/dist/transformers/preview/component/preview-server.js +112 -0
- package/dist/transformers/preview/component/preview-validation.d.ts +64 -0
- package/dist/transformers/preview/component/preview-validation.js +194 -0
- package/dist/transformers/preview/component/previews.d.ts +9 -0
- package/dist/transformers/preview/component/previews.js +6 -0
- package/dist/transformers/preview/component/screenshot.d.ts +90 -0
- package/dist/transformers/preview/component/screenshot.js +282 -0
- package/dist/transformers/preview/component/serialized-elements.d.ts +86 -0
- package/dist/transformers/preview/component/serialized-elements.js +118 -0
- package/dist/transformers/preview/component/summary.d.ts +6 -0
- package/dist/transformers/preview/component/summary.js +41 -0
- package/dist/transformers/preview/component.d.ts +13 -0
- package/dist/transformers/preview/component.js +26 -0
- package/dist/transformers/preview/height-reporter.d.ts +27 -0
- package/dist/transformers/preview/height-reporter.js +32 -0
- package/dist/transformers/preview/pattern/api.d.ts +11 -0
- package/dist/transformers/preview/pattern/api.js +58 -0
- package/dist/transformers/preview/pattern/builder.d.ts +17 -0
- package/dist/transformers/preview/pattern/builder.js +149 -0
- package/dist/transformers/preview/pattern/html.d.ts +25 -0
- package/dist/transformers/preview/pattern/html.js +95 -0
- package/dist/transformers/preview/slots.d.ts +109 -0
- package/dist/transformers/preview/slots.js +13 -0
- package/dist/transformers/preview/types.d.ts +292 -0
- package/dist/transformers/preview/types.js +7 -0
- package/dist/transformers/types.d.ts +60 -0
- package/dist/transformers/types.js +1 -0
- package/dist/transformers/utils/build.d.ts +27 -0
- package/dist/transformers/utils/build.js +77 -0
- package/dist/transformers/utils/csf.d.ts +16 -0
- package/dist/transformers/utils/csf.js +29 -0
- package/dist/transformers/utils/handlebars.d.ts +32 -0
- package/dist/transformers/utils/handlebars.js +73 -0
- package/dist/transformers/utils/html.d.ts +18 -0
- package/dist/transformers/utils/html.js +40 -0
- package/dist/transformers/utils/index.d.ts +13 -0
- package/dist/transformers/utils/index.js +20 -0
- package/dist/transformers/utils/module.d.ts +13 -0
- package/dist/transformers/utils/module.js +41 -0
- package/dist/transformers/utils/schema-loader.d.ts +19 -0
- package/dist/transformers/utils/schema-loader.js +61 -0
- package/dist/transformers/utils/schema.d.ts +33 -0
- package/dist/transformers/utils/schema.js +517 -0
- package/dist/transformers/utils/string.d.ts +36 -0
- package/dist/transformers/utils/string.js +52 -0
- package/dist/transformers/utils/svg-sprite.d.ts +16 -0
- package/dist/transformers/utils/svg-sprite.js +114 -0
- package/dist/transformers/utils/usage.d.ts +23 -0
- package/dist/transformers/utils/usage.js +282 -0
- package/dist/transformers/utils/vite-logger.d.ts +2 -0
- package/dist/transformers/utils/vite-logger.js +30 -0
- package/dist/transformers/validation/runner.d.ts +67 -0
- package/dist/transformers/validation/runner.js +277 -0
- package/dist/transformers/vite-config.d.ts +3 -0
- package/dist/transformers/vite-config.js +18 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/config.d.ts +472 -0
- package/dist/types/config.js +1 -0
- package/dist/types/font.d.ts +3 -0
- package/dist/types/font.js +1 -0
- package/dist/types/handoff-sync.d.ts +132 -0
- package/dist/types/handoff-sync.js +5 -0
- package/dist/types/history-purge.d.ts +112 -0
- package/dist/types/history-purge.js +18 -0
- package/dist/types/icon.d.ts +8 -0
- package/dist/types/icon.js +1 -0
- package/dist/types/preview.d.ts +138 -0
- package/dist/types/preview.js +1 -0
- package/dist/types/validation.d.ts +200 -0
- package/dist/types/validation.js +11 -0
- package/dist/utils/asset-upload-limits.d.ts +87 -0
- package/dist/utils/asset-upload-limits.js +129 -0
- package/dist/utils/design-md.d.ts +55 -0
- package/dist/utils/design-md.js +107 -0
- package/dist/utils/duration.d.ts +2 -0
- package/dist/utils/duration.js +2 -0
- package/dist/utils/filter.d.ts +31 -0
- package/dist/utils/filter.js +109 -0
- package/dist/utils/fs.d.ts +8 -0
- package/dist/utils/fs.js +31 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/line-diff.d.ts +25 -0
- package/dist/utils/line-diff.js +74 -0
- package/dist/utils/logger.d.ts +50 -0
- package/dist/utils/logger.js +158 -0
- package/dist/utils/path.d.ts +21 -0
- package/dist/utils/path.js +50 -0
- package/dist/utils/port.d.ts +15 -0
- package/dist/utils/port.js +38 -0
- package/dist/utils/rich-text.d.ts +228 -0
- package/dist/utils/rich-text.js +1087 -0
- package/dist/validators/axe.d.ts +47 -0
- package/dist/validators/axe.js +222 -0
- package/dist/validators/contrast.d.ts +33 -0
- package/dist/validators/contrast.js +235 -0
- package/dist/validators/index.d.ts +30 -0
- package/dist/validators/index.js +26 -0
- package/dist/validators/schema.d.ts +34 -0
- package/dist/validators/schema.js +138 -0
- package/docs/DEPENDENCIES.md +26 -0
- package/docs/DEPLOYMENT.md +110 -0
- package/docs/LOCAL-RIG.md +305 -0
- package/docs/README.md +15 -0
- package/docs/REGISTRY-SETUP.md +353 -0
- package/docs/STANDALONE-INSTALL.md +70 -0
- package/docs/WORKSPACE-PACKAGE-JSON.md +125 -0
- package/docs/api.md +657 -0
- package/docs/api_spec.yaml +450 -0
- package/docs/cli.md +86 -0
- package/docs/schemas/component.schema.json +167 -0
- package/docs/schemas/examples/button.json +83 -0
- package/drizzle.config.ts +10 -0
- package/package.json +271 -0
- package/postcss.config.mjs +8 -0
- package/scripts/assert-standalone-install.mjs +60 -0
- package/src/app/app/[...slug]/DocCatchAllClient.tsx +103 -0
- package/src/app/app/[...slug]/page.tsx +101 -0
- package/src/app/app/account/AccountClient.tsx +116 -0
- package/src/app/app/account/IntegrationsSection.tsx +273 -0
- package/src/app/app/account/SanityCard.tsx +473 -0
- package/src/app/app/account/ai-cost/page.tsx +141 -0
- package/src/app/app/account/appearance/AppearanceClient.tsx +433 -0
- package/src/app/app/account/appearance/page.tsx +52 -0
- package/src/app/app/account/integrations/page.tsx +37 -0
- package/src/app/app/account/layout.tsx +82 -0
- package/src/app/app/account/page.tsx +41 -0
- package/src/app/app/account/users/UsersClient.tsx +244 -0
- package/src/app/app/account/users/page.tsx +36 -0
- package/src/app/app/actions/ai-generate.ts +25 -0
- package/src/app/app/actions/components.ts +126 -0
- package/src/app/app/actions/patterns.ts +289 -0
- package/src/app/app/admin/ai-cost/AiCostClient.tsx +236 -0
- package/src/app/app/admin/ai-cost/page.tsx +56 -0
- package/src/app/app/admin/builds/BuildsClient.tsx +527 -0
- package/src/app/app/admin/builds/page.tsx +41 -0
- package/src/app/app/admin/integrations/page.tsx +32 -0
- package/src/app/app/admin/pages/PagesClient.tsx +282 -0
- package/src/app/app/admin/pages/edit/PageEditorClient.tsx +157 -0
- package/src/app/app/admin/pages/edit/page.tsx +48 -0
- package/src/app/app/admin/pages/page.tsx +31 -0
- package/src/app/app/admin/protection/ProtectionClient.tsx +235 -0
- package/src/app/app/admin/protection/page.tsx +33 -0
- package/src/app/app/admin/reference/ReferenceClient.tsx +150 -0
- package/src/app/app/admin/reference/page.tsx +38 -0
- package/src/app/app/admin/users/page.tsx +11 -0
- package/src/app/app/api/account/route.ts +36 -0
- package/src/app/app/api/admin/builds/status/route.ts +34 -0
- package/src/app/app/api/admin/cleanup-versions/route.ts +64 -0
- package/src/app/app/api/admin/contract-limit-audit/route.ts +126 -0
- package/src/app/app/api/admin/contract-render-audit/route.ts +116 -0
- package/src/app/app/api/admin/field-bridge-audit/route.ts +152 -0
- package/src/app/app/api/admin/migrate/route.ts +47 -0
- package/src/app/app/api/admin/playground-turns/route.ts +85 -0
- package/src/app/app/api/admin/purge-history/route.ts +119 -0
- package/src/app/app/api/auth/[...nextauth]/route.ts +30 -0
- package/src/app/app/api/component/[...path]/route.ts +141 -0
- package/src/app/app/api/component-artifact/[...path]/route.ts +18 -0
- package/src/app/app/api/components/route.ts +78 -0
- package/src/app/app/api/figma-plugin/auth/device/route.ts +40 -0
- package/src/app/app/api/figma-plugin/auth/revoke/route.ts +15 -0
- package/src/app/app/api/figma-plugin/auth/token/route.ts +50 -0
- package/src/app/app/api/figma-plugin/foundations/commit/route.ts +111 -0
- package/src/app/app/api/figma-plugin/foundations/preview/route.ts +69 -0
- package/src/app/app/api/figma-plugin/foundations/route.ts +49 -0
- package/src/app/app/api/handoff/admin/appearance/route.ts +80 -0
- package/src/app/app/api/handoff/admin/backfill-artifact-blobs/route.ts +48 -0
- package/src/app/app/api/handoff/admin/build-tasks/kill/route.ts +43 -0
- package/src/app/app/api/handoff/admin/build-tasks/route.ts +21 -0
- package/src/app/app/api/handoff/admin/invite/route.ts +18 -0
- package/src/app/app/api/handoff/admin/normalize-previews/route.ts +107 -0
- package/src/app/app/api/handoff/admin/reference-materials/route.ts +69 -0
- package/src/app/app/api/handoff/admin/remove/route.ts +18 -0
- package/src/app/app/api/handoff/admin/resend-invite/route.ts +18 -0
- package/src/app/app/api/handoff/admin/role/route.ts +18 -0
- package/src/app/app/api/handoff/admin/users/route.ts +16 -0
- package/src/app/app/api/handoff/ai/analyze-layout-guide/route.ts +172 -0
- package/src/app/app/api/handoff/ai/analyze-layout-guide/wireframe-style/wireframe-example-1.png +0 -0
- package/src/app/app/api/handoff/ai/analyze-layout-guide/wireframe-style/wireframe-example-2.png +0 -0
- package/src/app/app/api/handoff/ai/chat/route.ts +217 -0
- package/src/app/app/api/handoff/ai/component-screenshot/route.ts +43 -0
- package/src/app/app/api/handoff/ai/debug-foundation-raster/route.ts +162 -0
- package/src/app/app/api/handoff/ai/design-artifact/[id]/clone/route.ts +68 -0
- package/src/app/app/api/handoff/ai/design-artifact/[id]/public/route.ts +37 -0
- package/src/app/app/api/handoff/ai/design-artifact/[id]/route.ts +99 -0
- package/src/app/app/api/handoff/ai/design-artifact/[id]/status/route.ts +44 -0
- package/src/app/app/api/handoff/ai/design-artifact/route.ts +405 -0
- package/src/app/app/api/handoff/ai/design-artifact-extract/route.ts +37 -0
- package/src/app/app/api/handoff/ai/design-generation-job/[id]/route.ts +67 -0
- package/src/app/app/api/handoff/ai/design-generation-jobs/route.ts +23 -0
- package/src/app/app/api/handoff/ai/design-jobs/run/route.ts +102 -0
- package/src/app/app/api/handoff/ai/extract-url/route.ts +34 -0
- package/src/app/app/api/handoff/ai/foundation-preview/route.ts +44 -0
- package/src/app/app/api/handoff/ai/generate-component/route.ts +137 -0
- package/src/app/app/api/handoff/ai/generate-design/route.ts +210 -0
- package/src/app/app/api/handoff/ai/generate-image/route.ts +72 -0
- package/src/app/app/api/handoff/ai/generate-pattern/route.ts +86 -0
- package/src/app/app/api/handoff/ai/playground-chat/refine/route.ts +52 -0
- package/src/app/app/api/handoff/ai/playground-chat/route.ts +102 -0
- package/src/app/app/api/handoff/ai/status/route.ts +14 -0
- package/src/app/app/api/handoff/artifact-asset/route.ts +88 -0
- package/src/app/app/api/handoff/assets/[id]/raw/route.ts +49 -0
- package/src/app/app/api/handoff/assets/[id]/route.ts +76 -0
- package/src/app/app/api/handoff/assets/collections/route.ts +54 -0
- package/src/app/app/api/handoff/assets/confirm/route.ts +80 -0
- package/src/app/app/api/handoff/assets/icon-sets/route.ts +47 -0
- package/src/app/app/api/handoff/assets/presign/route.ts +41 -0
- package/src/app/app/api/handoff/assets/route.ts +89 -0
- package/src/app/app/api/handoff/assets/upload/route.ts +152 -0
- package/src/app/app/api/handoff/assets/usages/[id]/route.ts +21 -0
- package/src/app/app/api/handoff/assets/usages/route.ts +69 -0
- package/src/app/app/api/handoff/auth/request-reset/route.ts +9 -0
- package/src/app/app/api/handoff/auth/reset-password/route.ts +17 -0
- package/src/app/app/api/handoff/capture/health/route.ts +86 -0
- package/src/app/app/api/handoff/capture/jobs/route.ts +75 -0
- package/src/app/app/api/handoff/capture/run/route.ts +112 -0
- package/src/app/app/api/handoff/changelog/pushes/route.ts +49 -0
- package/src/app/app/api/handoff/changelog/route.ts +28 -0
- package/src/app/app/api/handoff/changes/why/route.ts +41 -0
- package/src/app/app/api/handoff/cms/connections/route.ts +182 -0
- package/src/app/app/api/handoff/cms/sanity/callback/route.ts +18 -0
- package/src/app/app/api/handoff/cms/sanity/categories/route.ts +146 -0
- package/src/app/app/api/handoff/cms/sanity/connect/route.ts +15 -0
- package/src/app/app/api/handoff/cms/sanity/publish/route.ts +161 -0
- package/src/app/app/api/handoff/cms/sanity/token/route.ts +87 -0
- package/src/app/app/api/handoff/components/[id]/screenshot.png/route.ts +101 -0
- package/src/app/app/api/handoff/components/[id]/thumbnail.svg/route.ts +158 -0
- package/src/app/app/api/handoff/components/build/route.ts +26 -0
- package/src/app/app/api/handoff/components/history/contract/route.ts +33 -0
- package/src/app/app/api/handoff/components/history/route.ts +35 -0
- package/src/app/app/api/handoff/components/history/version/route.ts +36 -0
- package/src/app/app/api/handoff/components/route.ts +56 -0
- package/src/app/app/api/handoff/components/validation/route.ts +36 -0
- package/src/app/app/api/handoff/design/workspace/brand-imagery-image/route.ts +75 -0
- package/src/app/app/api/handoff/design/workspace/route.ts +163 -0
- package/src/app/app/api/handoff/figma/component-properties/route.ts +34 -0
- package/src/app/app/api/handoff/figma/components/route.ts +21 -0
- package/src/app/app/api/handoff/figma/components/sync/route.ts +50 -0
- package/src/app/app/api/handoff/figma/fetch/route.ts +126 -0
- package/src/app/app/api/handoff/guest/assets/route.ts +52 -0
- package/src/app/app/api/handoff/guest/enter/route.ts +169 -0
- package/src/app/app/api/handoff/guest/submission/route.ts +209 -0
- package/src/app/app/api/handoff/guest/submission/submit/route.ts +63 -0
- package/src/app/app/api/handoff/image-slots/route.ts +24 -0
- package/src/app/app/api/handoff/navigation/prune/route.ts +106 -0
- package/src/app/app/api/handoff/pages/route.ts +90 -0
- package/src/app/app/api/handoff/patterns/[id]/clone/route.ts +69 -0
- package/src/app/app/api/handoff/patterns/[id]/manifest/route.ts +102 -0
- package/src/app/app/api/handoff/patterns/[id]/notes/route.ts +101 -0
- package/src/app/app/api/handoff/patterns/[id]/route.ts +41 -0
- package/src/app/app/api/handoff/patterns/[id]/thumbnail.svg/route.ts +70 -0
- package/src/app/app/api/handoff/patterns/route.ts +77 -0
- package/src/app/app/api/handoff/reference-materials/route.ts +40 -0
- package/src/app/app/api/handoff/review/[id]/route.ts +172 -0
- package/src/app/app/api/handoff/review/[id]/voice/route.ts +58 -0
- package/src/app/app/api/handoff/review/route.ts +31 -0
- package/src/app/app/api/handoff/share/[token]/route.ts +82 -0
- package/src/app/app/api/handoff/share/links/route.ts +48 -0
- package/src/app/app/api/handoff/share/route.ts +172 -0
- package/src/app/app/api/handoff/site-protection/route.ts +85 -0
- package/src/app/app/api/handoff/site-protection/unlock/route.ts +62 -0
- package/src/app/app/api/handoff/templates/[id]/submissions/route.ts +41 -0
- package/src/app/app/api/mcp/route.ts +39 -0
- package/src/app/app/api/oauth/authorization-server-metadata/route.ts +30 -0
- package/src/app/app/api/oauth/authorize/route.ts +158 -0
- package/src/app/app/api/oauth/device/approve/route.ts +32 -0
- package/src/app/app/api/oauth/device/route.ts +34 -0
- package/src/app/app/api/oauth/protected-resource-metadata/route.ts +26 -0
- package/src/app/app/api/oauth/register/route.ts +43 -0
- package/src/app/app/api/oauth/token/route.ts +94 -0
- package/src/app/app/api/openapi/route.ts +38 -0
- package/src/app/app/api/patterns/route.ts +8 -0
- package/src/app/app/api/registry/assets/ingest/route.ts +204 -0
- package/src/app/app/api/registry/assets/ingest-figma-fills/route.ts +81 -0
- package/src/app/app/api/registry/components/[id]/previews/[previewId]/route.ts +56 -0
- package/src/app/app/api/registry/components/[id]/previews/route.ts +66 -0
- package/src/app/app/api/registry/config/route.ts +50 -0
- package/src/app/app/api/registry/dtcg/download/route.ts +78 -0
- package/src/app/app/api/registry/dtcg/route.ts +133 -0
- package/src/app/app/api/registry/fonts/route.ts +67 -0
- package/src/app/app/api/registry/icons/download/route.ts +52 -0
- package/src/app/app/api/registry/icons/route.ts +47 -0
- package/src/app/app/api/registry/image-slots/route.ts +68 -0
- package/src/app/app/api/registry/logo.svg/route.ts +45 -0
- package/src/app/app/api/registry/logos/route.ts +47 -0
- package/src/app/app/api/registry/navigation/route.ts +52 -0
- package/src/app/app/api/registry/pages/route.ts +67 -0
- package/src/app/app/api/registry/theme/route.ts +51 -0
- package/src/app/app/api/registry/theme.css/route.ts +34 -0
- package/src/app/app/api/registry/tokens/route.ts +59 -0
- package/src/app/app/api/sync/changes/route.ts +24 -0
- package/src/app/app/api/sync/shared-assets/route.ts +79 -0
- package/src/app/app/api/sync/status/route.ts +12 -0
- package/src/app/app/api/sync/upload/route.ts +109 -0
- package/src/app/app/assets/AssetsClient.tsx +670 -0
- package/src/app/app/assets/[id]/AssetDetailClient.tsx +319 -0
- package/src/app/app/assets/[id]/page.tsx +8 -0
- package/src/app/app/assets/fonts/page.tsx +5 -0
- package/src/app/app/assets/logos/page.tsx +5 -0
- package/src/app/app/assets/page.tsx +5 -0
- package/src/app/app/cli/device/CliDeviceClient.tsx +104 -0
- package/src/app/app/cli/device/page.tsx +45 -0
- package/src/app/app/design/DesignClient.tsx +1682 -0
- package/src/app/app/design/SessionHistoryPanel.tsx +116 -0
- package/src/app/app/design/assets/[id]/page.tsx +11 -0
- package/src/app/app/design/assets/icons/page.tsx +8 -0
- package/src/app/app/design/assets/page.tsx +8 -0
- package/src/app/app/design/library/[id]/SavedDesignDetailClient.tsx +892 -0
- package/src/app/app/design/library/[id]/page.tsx +40 -0
- package/src/app/app/design/library/[id]/share/SharePublicClient.tsx +107 -0
- package/src/app/app/design/library/[id]/share/page.tsx +22 -0
- package/src/app/app/design/library/page.tsx +12 -0
- package/src/app/app/design/page.tsx +158 -0
- package/src/app/app/design/settings/SettingsClient.tsx +648 -0
- package/src/app/app/design/settings/page.tsx +41 -0
- package/src/app/app/design/settings/settings-constants.ts +96 -0
- package/src/app/app/design/v1/DesignClient.tsx +1316 -0
- package/src/app/app/design/v1/page.tsx +103 -0
- package/src/app/app/design/workbench-session.ts +54 -0
- package/src/app/app/design/workbench-types.ts +72 -0
- package/src/app/app/dev/local-setup/LocalSetupClient.tsx +119 -0
- package/src/app/app/dev/local-setup/McpSetupSection.tsx +174 -0
- package/src/app/app/dev/local-setup/page.tsx +5 -0
- package/src/app/app/developer/api/route.ts +13 -0
- package/src/app/app/developer/cli/page.tsx +192 -0
- package/src/app/app/developer/layout.tsx +57 -0
- package/src/app/app/developer/local-setup/page.tsx +37 -0
- package/src/app/app/developer/mcp/page.tsx +74 -0
- package/src/app/app/developer/page.tsx +111 -0
- package/src/app/app/developer/push-pull/page.tsx +130 -0
- package/src/app/app/fonts/[filename]/route.ts +41 -0
- package/src/app/app/foundations/[...slug]/page.tsx +83 -0
- package/src/app/app/foundations/assets/[id]/page.tsx +35 -0
- package/src/app/app/foundations/assets/page.tsx +31 -0
- package/src/app/app/foundations/border-radius/page.tsx +179 -0
- package/src/app/app/foundations/colors/page.tsx +166 -0
- package/src/app/app/foundations/effects/page.tsx +124 -0
- package/src/app/app/foundations/elevation/page.tsx +209 -0
- package/src/app/app/foundations/error.tsx +22 -0
- package/src/app/app/foundations/grid/page.tsx +315 -0
- package/src/app/app/foundations/icons/IconsPageClient.tsx +100 -0
- package/src/app/app/foundations/icons/[name]/SingleIconClient.tsx +231 -0
- package/src/app/app/foundations/icons/[name]/page.tsx +44 -0
- package/src/app/app/foundations/icons/page.tsx +58 -0
- package/src/app/app/foundations/logo/page.tsx +213 -0
- package/src/app/app/foundations/motion/page.tsx +228 -0
- package/src/app/app/foundations/page.tsx +65 -0
- package/src/app/app/foundations/spacing/page.tsx +171 -0
- package/src/app/app/foundations/typography/page.tsx +115 -0
- package/src/app/app/layout.tsx +131 -0
- package/src/app/app/library/LibraryClient.tsx +567 -0
- package/src/app/app/library/page.tsx +46 -0
- package/src/app/app/login/LoginClient.tsx +75 -0
- package/src/app/app/login/page.tsx +33 -0
- package/src/app/app/page.tsx +178 -0
- package/src/app/app/patterns/PatternBrowserClient.tsx +263 -0
- package/src/app/app/patterns/page.tsx +14 -0
- package/src/app/app/playground/PlaygroundClient.tsx +84 -0
- package/src/app/app/playground/[id]/page.tsx +215 -0
- package/src/app/app/playground/page.tsx +79 -0
- package/src/app/app/providers.tsx +72 -0
- package/src/app/app/reset-password/ResetPasswordClient.tsx +89 -0
- package/src/app/app/reset-password/page.tsx +24 -0
- package/src/app/app/review/ReviewClient.tsx +31 -0
- package/src/app/app/review/page.tsx +56 -0
- package/src/app/app/s/[token]/page.tsx +317 -0
- package/src/app/app/setup/SetupClient.tsx +87 -0
- package/src/app/app/setup/actions.ts +53 -0
- package/src/app/app/setup/page.tsx +28 -0
- package/src/app/app/system/FigmaFetchControls.tsx +163 -0
- package/src/app/app/system/FigmaSyncPanel.tsx +357 -0
- package/src/app/app/system/NewComponentForm.tsx +272 -0
- package/src/app/app/system/SystemPageClient.tsx +137 -0
- package/src/app/app/system/changelog/ChangelogClient.tsx +608 -0
- package/src/app/app/system/changelog/page.tsx +28 -0
- package/src/app/app/system/component/[component]/ComponentAssetsPanel.tsx +108 -0
- package/src/app/app/system/component/[component]/ComponentDetailClient.tsx +420 -0
- package/src/app/app/system/component/[component]/ComponentImageSlotsPanel.tsx +163 -0
- package/src/app/app/system/component/[component]/ComponentVersionHistory.tsx +430 -0
- package/src/app/app/system/component/[component]/VersionCompare.tsx +267 -0
- package/src/app/app/system/component/[component]/page.tsx +68 -0
- package/src/app/app/system/component/page.tsx +5 -0
- package/src/app/app/system/figma-sync/FigmaSyncPageClient.tsx +35 -0
- package/src/app/app/system/figma-sync/page.tsx +21 -0
- package/src/app/app/system/health/ComponentHealthTable.tsx +217 -0
- package/src/app/app/system/health/HealthDashboardClient.tsx +141 -0
- package/src/app/app/system/health/RuleBreakdownTable.tsx +123 -0
- package/src/app/app/system/health/ScoreBadge.tsx +58 -0
- package/src/app/app/system/health/TrendChart.tsx +76 -0
- package/src/app/app/system/health/ValidatorBreakdownBars.tsx +35 -0
- package/src/app/app/system/health/health-types.ts +7 -0
- package/src/app/app/system/health/page.tsx +100 -0
- package/src/app/app/system/page.tsx +21 -0
- package/src/app/app/system/pattern/[pattern]/PatternDetailClient.tsx +216 -0
- package/src/app/app/system/pattern/[pattern]/page.tsx +53 -0
- package/src/app/app/system/pattern/page.tsx +5 -0
- package/src/app/app/unlock/UnlockClient.tsx +100 -0
- package/src/app/app/unlock/page.tsx +40 -0
- package/src/app/components/Auth/AuthControls.tsx +146 -0
- package/src/app/components/Brief/BuildList.tsx +78 -0
- package/src/app/components/Brief/BuildPanel.tsx +460 -0
- package/src/app/components/Brief/export-blocks.ts +47 -0
- package/src/app/components/Chat/ChatActionCard.tsx +97 -0
- package/src/app/components/Chat/ChatChangelogFeed.tsx +252 -0
- package/src/app/components/Chat/ChatComponentGrid.tsx +144 -0
- package/src/app/components/Chat/ChatContext.tsx +192 -0
- package/src/app/components/Chat/ChatDrawer.tsx +162 -0
- package/src/app/components/Chat/ChatFab.tsx +41 -0
- package/src/app/components/Chat/ChatInput.tsx +150 -0
- package/src/app/components/Chat/ChatMessage.tsx +125 -0
- package/src/app/components/Chat/ChatValidationPanel.tsx +161 -0
- package/src/app/components/CloudFeatureGate.tsx +27 -0
- package/src/app/components/Component/BestPracticesCard.tsx +36 -0
- package/src/app/components/Component/Cards.tsx +76 -0
- package/src/app/components/Component/ComponentLists.tsx +279 -0
- package/src/app/components/Component/ComponentWorkbenchDialog.tsx +230 -0
- package/src/app/components/Component/InlineComponentEditor.tsx +163 -0
- package/src/app/components/Component/PageSliceResolver.tsx +81 -0
- package/src/app/components/Component/Preview.tsx +1091 -0
- package/src/app/components/Component/slices/BestPracticesSlice.tsx +14 -0
- package/src/app/components/Component/slices/CardsSlice.tsx +17 -0
- package/src/app/components/Component/slices/ComponentDisplaySlice.tsx +101 -0
- package/src/app/components/Component/slices/PropertiesSlice.tsx +24 -0
- package/src/app/components/Component/slices/TextSlice.tsx +23 -0
- package/src/app/components/Component/slices/ValidationResultsSlice.tsx +31 -0
- package/src/app/components/Component/slices/index.ts +14 -0
- package/src/app/components/Component/usePreviews.ts +97 -0
- package/src/app/components/ComponentDesignTokens.tsx +271 -0
- package/src/app/components/ComponentGuidelines.tsx +21 -0
- package/src/app/components/ComponentNotFound.tsx +35 -0
- package/src/app/components/ComponentSearch.tsx +96 -0
- package/src/app/components/CopyCode.tsx +59 -0
- package/src/app/components/CopyToClipboard.tsx +63 -0
- package/src/app/components/Design/DevHandoffPanel.tsx +481 -0
- package/src/app/components/DownloadTokens.tsx +78 -0
- package/src/app/components/Footer.tsx +46 -0
- package/src/app/components/Foundations/BrandColorSwatches.tsx +151 -0
- package/src/app/components/Foundations/ColorContrast.tsx +179 -0
- package/src/app/components/Foundations/ColorGrid.tsx +199 -0
- package/src/app/components/Foundations/ColorInfo.tsx +64 -0
- package/src/app/components/Foundations/ColorSpaces.tsx +119 -0
- package/src/app/components/Foundations/ColorTailwind.tsx +58 -0
- package/src/app/components/Foundations/ColorsDisplay.tsx +136 -0
- package/src/app/components/Foundations/DisplayLogo.tsx +16 -0
- package/src/app/components/Foundations/IconCatalogGrid.tsx +145 -0
- package/src/app/components/Foundations/ProvenanceBadge.tsx +40 -0
- package/src/app/components/Foundations/RulesSheet.tsx +204 -0
- package/src/app/components/Foundations/TokenOutputTabs.tsx +88 -0
- package/src/app/components/Foundations/TypographyExample.tsx +275 -0
- package/src/app/components/Guest/GuestAuthoring.tsx +589 -0
- package/src/app/components/Guest/GuestEditor.tsx +157 -0
- package/src/app/components/Hero.tsx +42 -0
- package/src/app/components/InlineEdit/InlineEditField.tsx +162 -0
- package/src/app/components/InlineEdit/InlineEditHeader.tsx +98 -0
- package/src/app/components/Layout/BuildBadge.tsx +90 -0
- package/src/app/components/Layout/Header.tsx +54 -0
- package/src/app/components/Layout/Main.tsx +84 -0
- package/src/app/components/Markdown/CodeHighlight.tsx +328 -0
- package/src/app/components/Markdown/MarkdownComponents.tsx +270 -0
- package/src/app/components/Markdown/MarkdownEditor.tsx +153 -0
- package/src/app/components/Markdown/WysiwygEditor.tsx +364 -0
- package/src/app/components/Markdown/wysiwyg.css +89 -0
- package/src/app/components/ModeSwitcher.tsx +29 -0
- package/src/app/components/NavLink.tsx +26 -0
- package/src/app/components/Navigation/AnchorNav.tsx +94 -0
- package/src/app/components/Navigation/AnchorNavLink.tsx +41 -0
- package/src/app/components/Navigation/AnchorNavNew.tsx +27 -0
- package/src/app/components/Navigation/MainNav.tsx +84 -0
- package/src/app/components/Navigation/MobileNav.tsx +123 -0
- package/src/app/components/Navigation/PrevNextNav.tsx +53 -0
- package/src/app/components/Navigation/SideNav.tsx +336 -0
- package/src/app/components/Navigation/anchor-slugify.ts +6 -0
- package/src/app/components/Playground/AiChatPanel.tsx +1483 -0
- package/src/app/components/Playground/ComponentCard.tsx +65 -0
- package/src/app/components/Playground/ComponentLibrary.tsx +228 -0
- package/src/app/components/Playground/CoverImagePicker.tsx +281 -0
- package/src/app/components/Playground/EditContext.tsx +247 -0
- package/src/app/components/Playground/EditSheet.tsx +82 -0
- package/src/app/components/Playground/FieldGuardrailsContext.ts +31 -0
- package/src/app/components/Playground/FieldLinkContext.ts +138 -0
- package/src/app/components/Playground/FieldMediaContext.ts +50 -0
- package/src/app/components/Playground/FindingsList.tsx +149 -0
- package/src/app/components/Playground/MediaBrowser.tsx +397 -0
- package/src/app/components/Playground/PageChecks.tsx +71 -0
- package/src/app/components/Playground/PageTitle.tsx +93 -0
- package/src/app/components/Playground/PlaygroundBuilder.tsx +1271 -0
- package/src/app/components/Playground/PlaygroundContext.tsx +990 -0
- package/src/app/components/Playground/PlaygroundWorkbench.tsx +260 -0
- package/src/app/components/Playground/Preview.tsx +1465 -0
- package/src/app/components/Playground/PublishToSanityDialog.tsx +468 -0
- package/src/app/components/Playground/SavePatternDialog.tsx +231 -0
- package/src/app/components/Playground/ShareTemplate.tsx +503 -0
- package/src/app/components/Playground/SortableItem.tsx +94 -0
- package/src/app/components/Playground/Wizard/ApiKeySettings.tsx +139 -0
- package/src/app/components/Playground/Wizard/PageImporter.tsx +384 -0
- package/src/app/components/Playground/Wizard/WizardDialog.tsx +329 -0
- package/src/app/components/Playground/Wizard/llm-client.ts +87 -0
- package/src/app/components/Playground/Wizard/prompt-builder.ts +134 -0
- package/src/app/components/Playground/Wizard/response-parser.ts +80 -0
- package/src/app/components/Playground/fields/ButtonField.tsx +24 -0
- package/src/app/components/Playground/fields/Field.tsx +344 -0
- package/src/app/components/Playground/fields/FieldLabel.tsx +9 -0
- package/src/app/components/Playground/fields/FunctionField.tsx +19 -0
- package/src/app/components/Playground/fields/ImageField.tsx +239 -0
- package/src/app/components/Playground/fields/LinkField.tsx +24 -0
- package/src/app/components/Playground/fields/RawJsonField.tsx +60 -0
- package/src/app/components/Playground/fields/RichTextField.tsx +220 -0
- package/src/app/components/Playground/fields/SelectField.tsx +55 -0
- package/src/app/components/Playground/fields/SlotField.tsx +40 -0
- package/src/app/components/Playground/fields/TextField.tsx +125 -0
- package/src/app/components/Playground/fields/VideoFileField.tsx +67 -0
- package/src/app/components/Playground/fields/content-only.ts +121 -0
- package/src/app/components/Playground/fields/field-type.ts +84 -0
- package/src/app/components/Playground/fields/reseed.ts +140 -0
- package/src/app/components/Playground/inline-edit-script.ts +596 -0
- package/src/app/components/Playground/link-guard-script.ts +50 -0
- package/src/app/components/Playground/types.ts +76 -0
- package/src/app/components/Playground/usePublishToSanity.ts +153 -0
- package/src/app/components/Review/ReviewQueueClient.tsx +288 -0
- package/src/app/components/SideNav/Custom.tsx +40 -0
- package/src/app/components/SideNavNew.tsx +280 -0
- package/src/app/components/Typography/Headers.tsx +50 -0
- package/src/app/components/Validation/ValidationFrameworkResults.tsx +208 -0
- package/src/app/components/Validation/ValidationResults.tsx +60 -0
- package/src/app/components/cards/CardsWithIcons.tsx +38 -0
- package/src/app/components/context/AuthUiContext.tsx +13 -0
- package/src/app/components/context/ConfigContext.tsx +43 -0
- package/src/app/components/context/HandoffCapabilitiesContext.tsx +40 -0
- package/src/app/components/context/HotReloadProvider.tsx +38 -0
- package/src/app/components/context/PreviewContext.tsx +135 -0
- package/src/app/components/library/AssetCard.tsx +166 -0
- package/src/app/components/library/KindPicker.tsx +66 -0
- package/src/app/components/library/LaneTabs.tsx +54 -0
- package/src/app/components/library/LifecycleBadge.tsx +28 -0
- package/src/app/components/library/LifecyclePicker.tsx +53 -0
- package/src/app/components/library/MetaControl.tsx +294 -0
- package/src/app/components/library/OwnerAttribution.tsx +106 -0
- package/src/app/components/library/PageNotes.tsx +191 -0
- package/src/app/components/library/PageOrigin.tsx +124 -0
- package/src/app/components/library/VisibilityBadge.tsx +25 -0
- package/src/app/components/library/VisibilityPicker.tsx +56 -0
- package/src/app/components/library/index.ts +7 -0
- package/src/app/components/ui/accordion.tsx +49 -0
- package/src/app/components/ui/alert.tsx +39 -0
- package/src/app/components/ui/attachment.tsx +204 -0
- package/src/app/components/ui/badge.tsx +32 -0
- package/src/app/components/ui/breadcrumb.tsx +68 -0
- package/src/app/components/ui/bubble.tsx +125 -0
- package/src/app/components/ui/button.tsx +45 -0
- package/src/app/components/ui/card.tsx +76 -0
- package/src/app/components/ui/collapsible.tsx +9 -0
- package/src/app/components/ui/dialog.tsx +80 -0
- package/src/app/components/ui/drawer.tsx +103 -0
- package/src/app/components/ui/dropdown-menu.tsx +176 -0
- package/src/app/components/ui/input.tsx +22 -0
- package/src/app/components/ui/json-tree-view.tsx +250 -0
- package/src/app/components/ui/label.tsx +24 -0
- package/src/app/components/ui/marker.tsx +69 -0
- package/src/app/components/ui/message-scroller.tsx +130 -0
- package/src/app/components/ui/message.tsx +92 -0
- package/src/app/components/ui/mobile-nav.tsx +95 -0
- package/src/app/components/ui/navigation-menu.tsx +116 -0
- package/src/app/components/ui/popover.tsx +31 -0
- package/src/app/components/ui/radio-group.tsx +36 -0
- package/src/app/components/ui/select.tsx +132 -0
- package/src/app/components/ui/separator.tsx +29 -0
- package/src/app/components/ui/sheet.tsx +140 -0
- package/src/app/components/ui/sidebar.tsx +609 -0
- package/src/app/components/ui/skeleton.tsx +15 -0
- package/src/app/components/ui/switch.tsx +29 -0
- package/src/app/components/ui/table.tsx +60 -0
- package/src/app/components/ui/tabs.tsx +53 -0
- package/src/app/components/ui/textarea.tsx +19 -0
- package/src/app/components/ui/toggle-group.tsx +51 -0
- package/src/app/components/ui/toggle.tsx +39 -0
- package/src/app/components/ui/tooltip.tsx +30 -0
- package/src/app/components/util/colors.ts +93 -0
- package/src/app/components/util/dtcg.ts +50 -0
- package/src/app/components/util/index.ts +963 -0
- package/src/app/components/util/theme-provider.tsx +11 -0
- package/src/app/components/util/token.ts +70 -0
- package/src/app/components.json +21 -0
- package/src/app/css/index.css +275 -0
- package/src/app/css/theme.css +14 -0
- package/src/app/css.d.ts +1 -0
- package/src/app/hooks/use-mobile.tsx +17 -0
- package/src/app/instrumentation.ts +39 -0
- package/src/app/lib/adapter-kit/errors.ts +141 -0
- package/src/app/lib/adapter-kit/types.ts +637 -0
- package/src/app/lib/admin-build-tasks-types.ts +41 -0
- package/src/app/lib/api-path.ts +12 -0
- package/src/app/lib/asset-search.ts +167 -0
- package/src/app/lib/asset-types.ts +88 -0
- package/src/app/lib/asset-upload-source.ts +314 -0
- package/src/app/lib/auth.ts +244 -0
- package/src/app/lib/authoring-guardrails.ts +591 -0
- package/src/app/lib/authoring-shapes.ts +261 -0
- package/src/app/lib/authz/guest.ts +131 -0
- package/src/app/lib/authz/notes.ts +102 -0
- package/src/app/lib/authz/policy.ts +228 -0
- package/src/app/lib/authz/review.ts +180 -0
- package/src/app/lib/authz/vocab.ts +175 -0
- package/src/app/lib/brief-components.ts +212 -0
- package/src/app/lib/build-audits.ts +239 -0
- package/src/app/lib/capture-chromium-plan.ts +123 -0
- package/src/app/lib/capture-determinism.ts +397 -0
- package/src/app/lib/capture-kinds.ts +207 -0
- package/src/app/lib/change-digest.ts +108 -0
- package/src/app/lib/chat-turn-guards.ts +149 -0
- package/src/app/lib/cli-sync-jwt.ts +110 -0
- package/src/app/lib/client/poll-generation-job.ts +85 -0
- package/src/app/lib/client-name.ts +29 -0
- package/src/app/lib/cms-migration-prompt.ts +99 -0
- package/src/app/lib/component-capture.ts +156 -0
- package/src/app/lib/component-id.ts +14 -0
- package/src/app/lib/component-thumbnail.ts +200 -0
- package/src/app/lib/composition-summary.ts +84 -0
- package/src/app/lib/content-length-plan.ts +512 -0
- package/src/app/lib/contract-limit-audit.ts +228 -0
- package/src/app/lib/contract-render-audit.ts +208 -0
- package/src/app/lib/data/component-row.ts +121 -0
- package/src/app/lib/data/components-digest.ts +116 -0
- package/src/app/lib/data/dynamic-provider.ts +765 -0
- package/src/app/lib/data/has-payload.ts +18 -0
- package/src/app/lib/data/hybrid-provider.ts +6 -0
- package/src/app/lib/data/index.ts +45 -0
- package/src/app/lib/data/menu-merge.ts +417 -0
- package/src/app/lib/data/page-metadata.ts +85 -0
- package/src/app/lib/data/pattern-merge.ts +78 -0
- package/src/app/lib/data/static-provider.ts +237 -0
- package/src/app/lib/data/types.ts +125 -0
- package/src/app/lib/db/auto-migrate.ts +205 -0
- package/src/app/lib/db/bootstrap-admin.ts +45 -0
- package/src/app/lib/db/capture-job-queries.ts +333 -0
- package/src/app/lib/db/changelog-queries.ts +623 -0
- package/src/app/lib/db/cms-connection-config.ts +21 -0
- package/src/app/lib/db/cms-connection-queries.ts +218 -0
- package/src/app/lib/db/component-artifact-queries.ts +115 -0
- package/src/app/lib/db/component-facets.ts +535 -0
- package/src/app/lib/db/component-preview-queries.ts +224 -0
- package/src/app/lib/db/component-version-queries.ts +682 -0
- package/src/app/lib/db/dialect.ts +15 -0
- package/src/app/lib/db/event-log-store.ts +47 -0
- package/src/app/lib/db/grant-queries.ts +827 -0
- package/src/app/lib/db/history-purge-plan.ts +446 -0
- package/src/app/lib/db/history-purge.ts +233 -0
- package/src/app/lib/db/index.ts +92 -0
- package/src/app/lib/db/migrations/0000_init.sql +226 -0
- package/src/app/lib/db/migrations/0001_design_workspace.sql +12 -0
- package/src/app/lib/db/migrations/0002_boring_ricochet.sql +50 -0
- package/src/app/lib/db/migrations/0003_demonic_flatman.sql +41 -0
- package/src/app/lib/db/migrations/0004_validation_runs.sql +18 -0
- package/src/app/lib/db/migrations/0005_component_versions.sql +21 -0
- package/src/app/lib/db/migrations/0006_token_and_page_changes.sql +40 -0
- package/src/app/lib/db/migrations/0007_design_spec.sql +9 -0
- package/src/app/lib/db/migrations/0008_design_generation_jobs.sql +22 -0
- package/src/app/lib/db/migrations/0009_assets.sql +80 -0
- package/src/app/lib/db/migrations/0010_registry_dtcg.sql +13 -0
- package/src/app/lib/db/migrations/0011_dtcg_brands.sql +5 -0
- package/src/app/lib/db/migrations/0012_icon_logo_registry.sql +13 -0
- package/src/app/lib/db/migrations/0013_registry_fonts.sql +13 -0
- package/src/app/lib/db/migrations/0014_asset_blobs.sql +9 -0
- package/src/app/lib/db/migrations/0015_appearance.sql +7 -0
- package/src/app/lib/db/migrations/0016_image_slots.sql +16 -0
- package/src/app/lib/db/migrations/0017_component_preview.sql +20 -0
- package/src/app/lib/db/migrations/0018_token_change_details.sql +26 -0
- package/src/app/lib/db/migrations/0019_change_why.sql +18 -0
- package/src/app/lib/db/migrations/0020_pattern_change.sql +17 -0
- package/src/app/lib/db/migrations/0021_mcp_oauth_connector.sql +37 -0
- package/src/app/lib/db/migrations/0022_dtcg_source.sql +21 -0
- package/src/app/lib/db/migrations/0023_perf_indexes.sql +30 -0
- package/src/app/lib/db/migrations/0024_phase_b_visibility.sql +40 -0
- package/src/app/lib/db/migrations/0027_guest_authoring.sql +49 -0
- package/src/app/lib/db/migrations/0028_invite_to_build.sql +99 -0
- package/src/app/lib/db/migrations/0029_pages_templates_reflow.sql +121 -0
- package/src/app/lib/db/migrations/0030_retire_briefs.sql +71 -0
- package/src/app/lib/db/migrations/0031_drop_brief_columns.sql +32 -0
- package/src/app/lib/db/migrations/0033_site_protection.sql +45 -0
- package/src/app/lib/db/migrations/0034_brand_imagery.sql +8 -0
- package/src/app/lib/db/migrations/0035_history_provenance.sql +42 -0
- package/src/app/lib/db/migrations/0036_cms_connections.sql +68 -0
- package/src/app/lib/db/migrations/0037_component_preview_purpose.sql +17 -0
- package/src/app/lib/db/migrations/0038_capture_job.sql +87 -0
- package/src/app/lib/db/migrations/meta/0000_snapshot.json +1424 -0
- package/src/app/lib/db/migrations/meta/0002_snapshot.json +1644 -0
- package/src/app/lib/db/migrations/meta/0003_snapshot.json +1820 -0
- package/src/app/lib/db/migrations/meta/_journal.json +258 -0
- package/src/app/lib/db/note-queries.ts +184 -0
- package/src/app/lib/db/pattern-write.ts +1094 -0
- package/src/app/lib/db/property-delta.ts +117 -0
- package/src/app/lib/db/push-grouping.ts +256 -0
- package/src/app/lib/db/queries.ts +2426 -0
- package/src/app/lib/db/registry-queries.ts +607 -0
- package/src/app/lib/db/schema-active.ts +2 -0
- package/src/app/lib/db/schema-pg.ts +1201 -0
- package/src/app/lib/db/schema.ts +2 -0
- package/src/app/lib/db/seed.ts +117 -0
- package/src/app/lib/db/sync-queries.ts +542 -0
- package/src/app/lib/db/token-flatten.ts +95 -0
- package/src/app/lib/db/validation-queries.ts +82 -0
- package/src/app/lib/db/version-baseline.ts +42 -0
- package/src/app/lib/design-workspace-client.ts +194 -0
- package/src/app/lib/design-workspace-format.ts +294 -0
- package/src/app/lib/docx-copy.ts +279 -0
- package/src/app/lib/dtcg-axes.ts +138 -0
- package/src/app/lib/dtcg-normalizer.ts +370 -0
- package/src/app/lib/edit-operations.ts +275 -0
- package/src/app/lib/email.ts +199 -0
- package/src/app/lib/error-summary.ts +79 -0
- package/src/app/lib/evals/cases.ts +678 -0
- package/src/app/lib/evals/copy-coverage.ts +147 -0
- package/src/app/lib/evals/copy-decks.ts +296 -0
- package/src/app/lib/field-lens.ts +308 -0
- package/src/app/lib/field-marks.ts +206 -0
- package/src/app/lib/figma-plugin-contract.ts +104 -0
- package/src/app/lib/figma-sync-types.ts +56 -0
- package/src/app/lib/generated/build-meta.ts +8 -0
- package/src/app/lib/guest-editable.ts +371 -0
- package/src/app/lib/handoff-capabilities.ts +91 -0
- package/src/app/lib/health-types.ts +324 -0
- package/src/app/lib/hubspot-field-map.ts +770 -0
- package/src/app/lib/hubspot-module/build-module.ts +238 -0
- package/src/app/lib/hubspot-module/context.ts +259 -0
- package/src/app/lib/hubspot-module/fields/boolean.ts +24 -0
- package/src/app/lib/hubspot-module/fields/button.ts +70 -0
- package/src/app/lib/hubspot-module/fields/fields.ts +104 -0
- package/src/app/lib/hubspot-module/fields/generic.ts +183 -0
- package/src/app/lib/hubspot-module/fields/hubdb.ts +168 -0
- package/src/app/lib/hubspot-module/fields/image.ts +65 -0
- package/src/app/lib/hubspot-module/fields/menu.ts +14 -0
- package/src/app/lib/hubspot-module/fields/object.ts +42 -0
- package/src/app/lib/hubspot-module/fields/select.ts +43 -0
- package/src/app/lib/hubspot-module/fields/text.ts +68 -0
- package/src/app/lib/hubspot-module/fields/url.ts +57 -0
- package/src/app/lib/hubspot-module/fields/utils.ts +36 -0
- package/src/app/lib/hubspot-module/fields/video.ts +75 -0
- package/src/app/lib/hubspot-module/index.ts +30 -0
- package/src/app/lib/hubspot-module/transpile.ts +727 -0
- package/src/app/lib/hubspot-module/types.ts +238 -0
- package/src/app/lib/hubspot-module-build.ts +50 -0
- package/src/app/lib/image-bytes.ts +133 -0
- package/src/app/lib/image-dimensions.ts +214 -0
- package/src/app/lib/image-field-write.ts +51 -0
- package/src/app/lib/image-generation-request.ts +142 -0
- package/src/app/lib/image-target.ts +175 -0
- package/src/app/lib/json-shape.ts +121 -0
- package/src/app/lib/library-image-seed.ts +236 -0
- package/src/app/lib/login-required-messages.ts +17 -0
- package/src/app/lib/mcp/apps/component-gallery.bundle.ts +2 -0
- package/src/app/lib/mcp/apps/component-gallery.client.ts +208 -0
- package/src/app/lib/mcp/apps/component-preview.bundle.ts +2 -0
- package/src/app/lib/mcp/apps/component-preview.client.ts +140 -0
- package/src/app/lib/mcp/apps/token-palette.bundle.ts +2 -0
- package/src/app/lib/mcp/apps/token-palette.client.ts +199 -0
- package/src/app/lib/mcp/contract-report.ts +200 -0
- package/src/app/lib/mcp/create-server.ts +2622 -0
- package/src/app/lib/mcp/history-shapes.ts +72 -0
- package/src/app/lib/mcp/project-profile.ts +82 -0
- package/src/app/lib/mcp/scaffold-helpers.ts +93 -0
- package/src/app/lib/mcp/stack-guides/bootstrap-handlebars.md +62 -0
- package/src/app/lib/mcp/stack-guides/react-scss.md +7 -0
- package/src/app/lib/mcp/stack-guides/react-tailwind.md +9 -0
- package/src/app/lib/mcp/stack-guides/tailwind-handlebars.md +142 -0
- package/src/app/lib/mcp/stack-guides.ts +68 -0
- package/src/app/lib/mcp/tool-catalog.ts +132 -0
- package/src/app/lib/mcp-auth.ts +85 -0
- package/src/app/lib/merge-block-values.ts +868 -0
- package/src/app/lib/normalize-preview-values.ts +244 -0
- package/src/app/lib/notify.ts +213 -0
- package/src/app/lib/oauth-scopes.ts +33 -0
- package/src/app/lib/page-exemplars.ts +112 -0
- package/src/app/lib/page-manifest.ts +162 -0
- package/src/app/lib/page-provenance.ts +231 -0
- package/src/app/lib/page-slug.ts +68 -0
- package/src/app/lib/page-title.ts +44 -0
- package/src/app/lib/page-urls.ts +41 -0
- package/src/app/lib/passwords.ts +33 -0
- package/src/app/lib/pattern-payload.ts +122 -0
- package/src/app/lib/pattern-thumbnail.ts +234 -0
- package/src/app/lib/placeholder-audit.ts +196 -0
- package/src/app/lib/placeholder-copy.ts +370 -0
- package/src/app/lib/playground-prompt-link.ts +46 -0
- package/src/app/lib/preview-groups.ts +107 -0
- package/src/app/lib/preview-purpose-labels.ts +37 -0
- package/src/app/lib/preview-purpose.ts +37 -0
- package/src/app/lib/preview-render-target.ts +27 -0
- package/src/app/lib/preview-url.ts +15 -0
- package/src/app/lib/publish-to-sanity-state.ts +605 -0
- package/src/app/lib/rate-limit.ts +75 -0
- package/src/app/lib/remote-handoff-client.ts +33 -0
- package/src/app/lib/sanity-assets.ts +211 -0
- package/src/app/lib/sanity-categories.ts +178 -0
- package/src/app/lib/sanity-config.ts +266 -0
- package/src/app/lib/sanity-integration-state.ts +235 -0
- package/src/app/lib/sanity-mapping.ts +3284 -0
- package/src/app/lib/sanity-portable-text.ts +640 -0
- package/src/app/lib/sanity-publish.ts +337 -0
- package/src/app/lib/sanity-references.ts +295 -0
- package/src/app/lib/server/admin-users.ts +162 -0
- package/src/app/lib/server/ai-client.ts +633 -0
- package/src/app/lib/server/ai-proxy.ts +70 -0
- package/src/app/lib/server/api-gate.ts +148 -0
- package/src/app/lib/server/appearance.ts +169 -0
- package/src/app/lib/server/asset-generation-worker.ts +133 -0
- package/src/app/lib/server/asset-ingest-store.ts +55 -0
- package/src/app/lib/server/asset-ingest.ts +347 -0
- package/src/app/lib/server/auth-reset.ts +107 -0
- package/src/app/lib/server/capture-browser.ts +130 -0
- package/src/app/lib/server/capture-harness.ts +319 -0
- package/src/app/lib/server/capture-worker.ts +178 -0
- package/src/app/lib/server/change-why.ts +195 -0
- package/src/app/lib/server/cli-device-oauth.ts +159 -0
- package/src/app/lib/server/cms-providers.ts +53 -0
- package/src/app/lib/server/component-build-preload.cjs +3 -0
- package/src/app/lib/server/component-build-worker.ts +196 -0
- package/src/app/lib/server/component-builder.ts +96 -0
- package/src/app/lib/server/component-capture-reads.ts +172 -0
- package/src/app/lib/server/component-generation-context.ts +165 -0
- package/src/app/lib/server/component-generation-images.ts +40 -0
- package/src/app/lib/server/component-generation-llm.ts +232 -0
- package/src/app/lib/server/component-generation-run.ts +289 -0
- package/src/app/lib/server/component-generation-schedule.ts +12 -0
- package/src/app/lib/server/component-preview-screenshot.ts +111 -0
- package/src/app/lib/server/component-scaffold.ts +88 -0
- package/src/app/lib/server/component-visual-compare.ts +90 -0
- package/src/app/lib/server/design-artifact-persist.ts +49 -0
- package/src/app/lib/server/design-asset-extractor.ts +414 -0
- package/src/app/lib/server/design-asset-schedule.ts +36 -0
- package/src/app/lib/server/design-asset-worker-spawn.ts +64 -0
- package/src/app/lib/server/design-asset-worker.ts +24 -0
- package/src/app/lib/server/design-generation-worker.ts +281 -0
- package/src/app/lib/server/design-prompt-builder.ts +322 -0
- package/src/app/lib/server/design-spec-generator.ts +739 -0
- package/src/app/lib/server/design-spec-types.ts +219 -0
- package/src/app/lib/server/design-system-context.ts +141 -0
- package/src/app/lib/server/design-token-summary.ts +133 -0
- package/src/app/lib/server/design-workspace.ts +230 -0
- package/src/app/lib/server/dev-handoff.ts +334 -0
- package/src/app/lib/server/doc-pages.ts +442 -0
- package/src/app/lib/server/event-log.ts +138 -0
- package/src/app/lib/server/fetch-asset-bytes.ts +161 -0
- package/src/app/lib/server/figma-audit-api.ts +188 -0
- package/src/app/lib/server/figma-auth.ts +113 -0
- package/src/app/lib/server/figma-fetch-runner.ts +241 -0
- package/src/app/lib/server/figma-fetch-worker.ts +130 -0
- package/src/app/lib/server/figma-fetch.ts +90 -0
- package/src/app/lib/server/figma-fills-ingest.ts +201 -0
- package/src/app/lib/server/figma-plugin-properties-sync.ts +438 -0
- package/src/app/lib/server/figma-sync-service.ts +1076 -0
- package/src/app/lib/server/find-assets.ts +53 -0
- package/src/app/lib/server/foundation-image.tsx +671 -0
- package/src/app/lib/server/generation-queue-health.ts +108 -0
- package/src/app/lib/server/guest-context.ts +62 -0
- package/src/app/lib/server/guest-session.ts +153 -0
- package/src/app/lib/server/handoff-app-paths.ts +77 -0
- package/src/app/lib/server/handoff-component-patch.ts +123 -0
- package/src/app/lib/server/handoff-config-load.ts +29 -0
- package/src/app/lib/server/handoff-config-project.ts +104 -0
- package/src/app/lib/server/mcp-oauth-connector.ts +269 -0
- package/src/app/lib/server/node-tsx-worker-launcher.cjs +32 -0
- package/src/app/lib/server/oauth-state.ts +83 -0
- package/src/app/lib/server/passphrase.ts +121 -0
- package/src/app/lib/server/pattern-api-map.ts +123 -0
- package/src/app/lib/server/playground-chat.ts +1890 -0
- package/src/app/lib/server/public-api-paths.ts +34 -0
- package/src/app/lib/server/reference-material-generator.ts +341 -0
- package/src/app/lib/server/reference-material-ids.ts +8 -0
- package/src/app/lib/server/reference-material-persist.ts +25 -0
- package/src/app/lib/server/reference-material-schedule.ts +13 -0
- package/src/app/lib/server/registry-cache.ts +110 -0
- package/src/app/lib/server/request-public-url.ts +19 -0
- package/src/app/lib/server/runtime-config.ts +43 -0
- package/src/app/lib/server/s3-assets.ts +188 -0
- package/src/app/lib/server/sanity-connection.ts +176 -0
- package/src/app/lib/server/sanity-oauth.ts +34 -0
- package/src/app/lib/server/scaffold-args.ts +392 -0
- package/src/app/lib/server/secret-box.ts +85 -0
- package/src/app/lib/server/serverless-chromium.ts +93 -0
- package/src/app/lib/server/share-link-token.ts +106 -0
- package/src/app/lib/server/site-protection.ts +145 -0
- package/src/app/lib/server/spawn-tsx-worker.ts +47 -0
- package/src/app/lib/server/store-image-asset.ts +220 -0
- package/src/app/lib/server/token-freshness.ts +23 -0
- package/src/app/lib/server/unlock-cookie.ts +70 -0
- package/src/app/lib/server/upload-asset-to-library.ts +128 -0
- package/src/app/lib/server/url-extract.ts +117 -0
- package/src/app/lib/server/voice-audit.ts +209 -0
- package/src/app/lib/set-at-args-path.ts +36 -0
- package/src/app/lib/site-gate.ts +374 -0
- package/src/app/lib/slot-capabilities.ts +487 -0
- package/src/app/lib/source-copy.ts +295 -0
- package/src/app/lib/storage/artifact-images.ts +225 -0
- package/src/app/lib/storage/capture-artifacts.ts +109 -0
- package/src/app/lib/swap-image-src.ts +121 -0
- package/src/app/lib/sync-auth.ts +124 -0
- package/src/app/lib/tool-payload.ts +101 -0
- package/src/app/lib/turn-log.ts +78 -0
- package/src/app/lib/url-safety.ts +46 -0
- package/src/app/lib/utils.ts +35 -0
- package/src/app/lib/workbench-level.ts +56 -0
- package/src/app/middleware-hook.mjs +2 -0
- package/src/app/next-env.d.ts +6 -0
- package/src/app/next.config.mjs +355 -0
- package/src/app/postcss.config.mjs +8 -0
- package/src/app/proxy.ts +133 -0
- package/src/app/public/assets/css/preview.css +27 -0
- package/src/app/public/assets/design/blocks/callout-cta.jpg +0 -0
- package/src/app/public/assets/design/blocks/carousel.png +0 -0
- package/src/app/public/assets/design/blocks/container.png +0 -0
- package/src/app/public/assets/design/blocks/customer-stories.jpg +0 -0
- package/src/app/public/assets/design/blocks/faq.jpg +0 -0
- package/src/app/public/assets/design/blocks/features-comparison.jpg +0 -0
- package/src/app/public/assets/design/blocks/table.jpg +0 -0
- package/src/app/public/assets/images/blocks.svg +150 -0
- package/src/app/public/assets/images/check-circle.svg +10 -0
- package/src/app/public/assets/images/colors.svg +186 -0
- package/src/app/public/assets/images/components.png +0 -0
- package/src/app/public/assets/images/components.svg +183 -0
- package/src/app/public/assets/images/illustration-sample-2.svg +102 -0
- package/src/app/public/assets/images/illustration-sample-3.svg +124 -0
- package/src/app/public/assets/images/illustration-sample-bw-1.svg +84 -0
- package/src/app/public/assets/images/illustration-sample-bw-2.svg +88 -0
- package/src/app/public/assets/images/illustration-sample-bw-3.svg +125 -0
- package/src/app/public/assets/images/illustration-sample.svg +110 -0
- package/src/app/public/assets/images/typography.svg +279 -0
- package/src/app/public/assets/images/usage-correct.png +0 -0
- package/src/app/public/assets/images/usage-wrong.png +0 -0
- package/src/app/public/assets/images/x-circle.svg +10 -0
- package/src/app/public/assets/js/preview.js +90 -0
- package/src/app/public/assets/svg/activity.svg +1 -0
- package/src/app/public/assets/svg/add.svg +1 -0
- package/src/app/public/assets/svg/airplay.svg +1 -0
- package/src/app/public/assets/svg/alert-circle.svg +1 -0
- package/src/app/public/assets/svg/alert-octagon.svg +1 -0
- package/src/app/public/assets/svg/alert-triangle.svg +1 -0
- package/src/app/public/assets/svg/align-center.svg +1 -0
- package/src/app/public/assets/svg/align-justify.svg +1 -0
- package/src/app/public/assets/svg/align-left.svg +1 -0
- package/src/app/public/assets/svg/arrow-down-circle.svg +1 -0
- package/src/app/public/assets/svg/arrow-left-circle.svg +1 -0
- package/src/app/public/assets/svg/arrow-right-circle.svg +1 -0
- package/src/app/public/assets/svg/arrow-right.svg +4 -0
- package/src/app/public/assets/svg/arrow-up-circle.svg +1 -0
- package/src/app/public/assets/svg/bell-off.svg +1 -0
- package/src/app/public/assets/svg/bell.svg +1 -0
- package/src/app/public/assets/svg/camera.svg +1 -0
- package/src/app/public/assets/svg/cast.svg +1 -0
- package/src/app/public/assets/svg/check.svg +1 -0
- package/src/app/public/assets/svg/clock.svg +1 -0
- package/src/app/public/assets/svg/code.svg +1 -0
- package/src/app/public/assets/svg/component-accordion.svg +56 -0
- package/src/app/public/assets/svg/component-alert.svg +34 -0
- package/src/app/public/assets/svg/component-button.svg +63 -0
- package/src/app/public/assets/svg/component-checkbox.svg +41 -0
- package/src/app/public/assets/svg/component-input.svg +30 -0
- package/src/app/public/assets/svg/component-modal.svg +63 -0
- package/src/app/public/assets/svg/component-pagination.svg +82 -0
- package/src/app/public/assets/svg/component-radio.svg +15 -0
- package/src/app/public/assets/svg/component-select.svg +48 -0
- package/src/app/public/assets/svg/component-switch.svg +6 -0
- package/src/app/public/assets/svg/component-table.svg +45 -0
- package/src/app/public/assets/svg/component-tabs.svg +34 -0
- package/src/app/public/assets/svg/component-tooltip.svg +60 -0
- package/src/app/public/assets/svg/component.svg +48 -0
- package/src/app/public/assets/svg/copy.svg +1 -0
- package/src/app/public/assets/svg/delivery.svg +1 -0
- package/src/app/public/assets/svg/download.svg +1 -0
- package/src/app/public/assets/svg/file-jpg.svg +20 -0
- package/src/app/public/assets/svg/file-svg.svg +31 -0
- package/src/app/public/assets/svg/file-zip.svg +24 -0
- package/src/app/public/assets/svg/hero-brand-assets.svg +44 -0
- package/src/app/public/assets/svg/hero-colors.svg +10 -0
- package/src/app/public/assets/svg/hero-components.svg +68 -0
- package/src/app/public/assets/svg/hero-design.svg +20 -0
- package/src/app/public/assets/svg/hero-effects.svg +1 -0
- package/src/app/public/assets/svg/illustration-sample.svg +82 -0
- package/src/app/public/assets/svg/image.svg +8 -0
- package/src/app/public/assets/svg/link.svg +1 -0
- package/src/app/public/assets/svg/logo.svg +8 -0
- package/src/app/public/assets/svg/moon.svg +1 -0
- package/src/app/public/assets/svg/motiv-logo-dark-example.svg +11 -0
- package/src/app/public/assets/svg/motiv-logo-example.svg +11 -0
- package/src/app/public/assets/svg/plus-circle.svg +1 -0
- package/src/app/public/assets/svg/react.svg +10 -0
- package/src/app/public/assets/svg/search-laptop.svg +20 -0
- package/src/app/public/assets/svg/search.svg +1 -0
- package/src/app/public/assets/svg/send.svg +10 -0
- package/src/app/public/assets/svg/share.svg +1 -0
- package/src/app/public/assets/svg/small-accordion.svg +9 -0
- package/src/app/public/assets/svg/small-button.svg +9 -0
- package/src/app/public/assets/svg/small-pagination.svg +14 -0
- package/src/app/public/assets/svg/small-radio.svg +15 -0
- package/src/app/public/assets/svg/small-select.svg +9 -0
- package/src/app/public/assets/svg/small-table.svg +16 -0
- package/src/app/public/assets/svg/small-toggle.svg +9 -0
- package/src/app/public/assets/svg/sun.svg +1 -0
- package/src/app/public/assets/svg/token-alignment.svg +5 -0
- package/src/app/public/assets/svg/token-border-radius.svg +3 -0
- package/src/app/public/assets/svg/token-border-width.svg +10 -0
- package/src/app/public/assets/svg/token-spacing-horizontal.svg +8 -0
- package/src/app/public/assets/svg/token-spacing-vertical.svg +8 -0
- package/src/app/public/assets/svg/token-type-small.svg +5 -0
- package/src/app/public/assets/svg/x.svg +1 -0
- package/src/app/public/assets/svg/zap.svg +1 -0
- package/src/app/public/favicon.ico +0 -0
- package/src/app/public/fonts/readme.md +4 -0
- package/src/app/public/handoff-logo.svg +38 -0
- package/src/app/public/logo.svg +13 -0
- package/src/app/public/openapi.yaml +1818 -0
- package/src/app/public/robots.txt +0 -0
- package/src/app/tsconfig.json +53 -0
- package/src/app/types/middleware-hook.d.ts +10 -0
- package/src/app/types/next-auth-augmentation.d.ts +20 -0
- package/src/app-builder/README.md +43 -0
- package/src/app-builder/build.ts +741 -0
- package/src/app-builder/client-config.ts +124 -0
- package/src/app-builder/config-diff/index.ts +4 -0
- package/src/app-builder/config-diff/registry.ts +23 -0
- package/src/app-builder/config-diff/snapshot.ts +51 -0
- package/src/app-builder/config-diff/strategies/pattern.ts +80 -0
- package/src/app-builder/config-diff/types.ts +36 -0
- package/src/app-builder/index.ts +7 -0
- package/src/app-builder/path-contract.ts +81 -0
- package/src/app-builder/paths.ts +90 -0
- package/src/app-builder/watchers/component.ts +72 -0
- package/src/app-builder/watchers/utils.ts +44 -0
- package/src/app-builder/watchers.ts +345 -0
- package/src/app-builder/websocket.ts +72 -0
- package/src/cache/README.md +49 -0
- package/src/cache/build-cache.ts +567 -0
- package/src/cache/file-state.ts +170 -0
- package/src/cache/index.ts +46 -0
- package/src/cache/push-state.ts +201 -0
- package/src/cli/README.md +12 -0
- package/src/cli/create.ts +366 -0
- package/src/cli/eject.ts +93 -0
- package/src/cli/fetch-design-md.ts +60 -0
- package/src/cli/figma-audit.ts +76 -0
- package/src/cli/init-claude-core.ts +111 -0
- package/src/cli/make.ts +203 -0
- package/src/cli/scaffold.ts +651 -0
- package/src/cli/sync/apply-declaration-pull.ts +257 -0
- package/src/cli/sync/apply-pull.ts +223 -0
- package/src/cli/sync/cli-auth-store.ts +51 -0
- package/src/cli/sync/collect-build-artifacts.ts +159 -0
- package/src/cli/sync/collect-referenced-images.ts +204 -0
- package/src/cli/sync/declaration-patch.ts +192 -0
- package/src/cli/sync/hash.ts +12 -0
- package/src/cli/sync/open-browser.ts +37 -0
- package/src/cli/sync/push-provenance.ts +109 -0
- package/src/cli/sync/push-registry-content.ts +1025 -0
- package/src/cli/sync/push-shared-assets.ts +62 -0
- package/src/cli/sync/resolve-declaration-payload.ts +231 -0
- package/src/cli/sync/resolve-declaration.ts +18 -0
- package/src/cli/sync/run-cli-login.ts +110 -0
- package/src/cli/sync/run-history-purge.ts +142 -0
- package/src/cli/sync/run-pull.ts +112 -0
- package/src/cli/sync/run-push.ts +702 -0
- package/src/cli/sync/run-sync-status.ts +37 -0
- package/src/cli/sync/sync-remote-env.ts +64 -0
- package/src/cli/sync/sync-state.ts +42 -0
- package/src/cli/tokens/ensure-default-brand.ts +115 -0
- package/src/cli/tokens/migrate-legacy.ts +261 -0
- package/src/cli/tokens/parse-css-brands.ts +208 -0
- package/src/cli/tokens/transform.ts +134 -0
- package/src/cli.ts +62 -0
- package/src/commands/README.md +25 -0
- package/src/commands/audit/figma-components.ts +37 -0
- package/src/commands/build/app.ts +32 -0
- package/src/commands/build/components.ts +25 -0
- package/src/commands/build/hubspot.ts +267 -0
- package/src/commands/dev/index.ts +20 -0
- package/src/commands/eject/config.ts +20 -0
- package/src/commands/eject/pages.ts +20 -0
- package/src/commands/eject/theme.ts +20 -0
- package/src/commands/fetch/index.ts +20 -0
- package/src/commands/history-purge.ts +67 -0
- package/src/commands/index.ts +67 -0
- package/src/commands/init/index.ts +17 -0
- package/src/commands/init/vercel.ts +112 -0
- package/src/commands/init-claude.ts +61 -0
- package/src/commands/login.ts +39 -0
- package/src/commands/logout.ts +22 -0
- package/src/commands/make/component.ts +34 -0
- package/src/commands/make/page.ts +47 -0
- package/src/commands/make/template.ts +47 -0
- package/src/commands/mcp-init.ts +111 -0
- package/src/commands/mcp-token.ts +32 -0
- package/src/commands/prepare-runtime.ts +39 -0
- package/src/commands/pull.ts +28 -0
- package/src/commands/push-all.ts +202 -0
- package/src/commands/push-assets.ts +52 -0
- package/src/commands/push-tokens.ts +52 -0
- package/src/commands/push.ts +91 -0
- package/src/commands/scaffold/index.ts +22 -0
- package/src/commands/start/index.ts +20 -0
- package/src/commands/sync-status.ts +21 -0
- package/src/commands/tokens-build.ts +118 -0
- package/src/commands/types.ts +6 -0
- package/src/commands/utils.ts +21 -0
- package/src/commands/validate/components.ts +27 -0
- package/src/commands/validate.ts +189 -0
- package/src/commands/vercel-build.ts +96 -0
- package/src/config/README.md +32 -0
- package/src/config/declaration-module-load.ts +74 -0
- package/src/config/defaults.ts +78 -0
- package/src/config/helpers.ts +43 -0
- package/src/config/index.ts +16 -0
- package/src/config/loader.ts +131 -0
- package/src/config/normalizers/declaration.ts +180 -0
- package/src/config/normalizers/pattern.ts +56 -0
- package/src/config/runtime.ts +426 -0
- package/src/config/validator.ts +24 -0
- package/src/declarations/codegen.ts +367 -0
- package/src/declarations/helpers.ts +36 -0
- package/src/declarations/index.ts +20 -0
- package/src/declarations/types.ts +214 -0
- package/src/figma/component-linking.ts +1415 -0
- package/src/figma/image-fills.ts +247 -0
- package/src/generated/build-meta.ts +8 -0
- package/src/index.d.ts +13 -0
- package/src/index.ts +369 -0
- package/src/pipeline/README.md +21 -0
- package/src/pipeline/archive.ts +75 -0
- package/src/pipeline/components.ts +9 -0
- package/src/pipeline/documentation.ts +77 -0
- package/src/pipeline/figma.ts +173 -0
- package/src/pipeline/hubspot/config.ts +288 -0
- package/src/pipeline/hubspot/emit.ts +385 -0
- package/src/pipeline/index.ts +38 -0
- package/src/pipeline/patterns.ts +12 -0
- package/src/pipeline/styles.ts +154 -0
- package/src/pipeline/validation.ts +25 -0
- package/src/stacks/bootstrap-handlebars.md +117 -0
- package/src/stacks/react-scss.md +126 -0
- package/src/stacks/react-tailwind.md +123 -0
- package/src/stacks/tailwind-handlebars.md +142 -0
- package/src/transformers/README.md +19 -0
- package/src/transformers/docgen/index.ts +305 -0
- package/src/transformers/plugins/csf-render.ts +485 -0
- package/src/transformers/plugins/handlebars-previews.ts +194 -0
- package/src/transformers/plugins/index.ts +14 -0
- package/src/transformers/plugins/slot-probe-candidates.ts +386 -0
- package/src/transformers/plugins/slot-probe.ts +366 -0
- package/src/transformers/plugins/ssr-render.ts +622 -0
- package/src/transformers/plugins.ts +17 -0
- package/src/transformers/preview/component/api.ts +175 -0
- package/src/transformers/preview/component/artifacts.ts +112 -0
- package/src/transformers/preview/component/build-shared-bundles.ts +453 -0
- package/src/transformers/preview/component/builder.ts +754 -0
- package/src/transformers/preview/component/css.ts +253 -0
- package/src/transformers/preview/component/field-annotations.ts +400 -0
- package/src/transformers/preview/component/html.ts +96 -0
- package/src/transformers/preview/component/javascript.ts +182 -0
- package/src/transformers/preview/component/normalizer.ts +83 -0
- package/src/transformers/preview/component/playwright-shared.ts +183 -0
- package/src/transformers/preview/component/preview-assets.ts +158 -0
- package/src/transformers/preview/component/preview-merge.ts +95 -0
- package/src/transformers/preview/component/preview-select.ts +184 -0
- package/src/transformers/preview/component/preview-server.ts +128 -0
- package/src/transformers/preview/component/preview-validation.ts +255 -0
- package/src/transformers/preview/component/previews.ts +12 -0
- package/src/transformers/preview/component/screenshot.ts +306 -0
- package/src/transformers/preview/component/serialized-elements.ts +124 -0
- package/src/transformers/preview/component/summary.ts +54 -0
- package/src/transformers/preview/component.ts +31 -0
- package/src/transformers/preview/height-reporter.ts +37 -0
- package/src/transformers/preview/pattern/api.ts +83 -0
- package/src/transformers/preview/pattern/builder.ts +192 -0
- package/src/transformers/preview/pattern/html.ts +115 -0
- package/src/transformers/preview/slots.ts +105 -0
- package/src/transformers/preview/types.ts +302 -0
- package/src/transformers/types.ts +68 -0
- package/src/transformers/utils/build.ts +85 -0
- package/src/transformers/utils/csf.ts +48 -0
- package/src/transformers/utils/handlebars.ts +92 -0
- package/src/transformers/utils/html.ts +44 -0
- package/src/transformers/utils/index.ts +27 -0
- package/src/transformers/utils/module.ts +54 -0
- package/src/transformers/utils/schema-loader.ts +68 -0
- package/src/transformers/utils/schema.ts +569 -0
- package/src/transformers/utils/string.ts +55 -0
- package/src/transformers/utils/svg-sprite.ts +139 -0
- package/src/transformers/utils/usage.ts +317 -0
- package/src/transformers/utils/vite-logger.ts +33 -0
- package/src/transformers/validation/runner.ts +351 -0
- package/src/transformers/vite-config.ts +21 -0
- package/src/types/README.md +12 -0
- package/src/types/config.ts +482 -0
- package/src/types/font.ts +3 -0
- package/src/types/handoff-sync.ts +145 -0
- package/src/types/history-purge.ts +141 -0
- package/src/types/icon.ts +8 -0
- package/src/types/preview.ts +136 -0
- package/src/types/validation.ts +213 -0
- package/src/utils/README.md +14 -0
- package/src/utils/asset-upload-limits.ts +157 -0
- package/src/utils/design-md.ts +152 -0
- package/src/utils/duration.ts +3 -0
- package/src/utils/filter.ts +134 -0
- package/src/utils/fs.ts +35 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/line-diff.ts +80 -0
- package/src/utils/logger.ts +176 -0
- package/src/utils/path.ts +61 -0
- package/src/utils/port.ts +46 -0
- package/src/utils/rich-text.ts +1202 -0
- package/src/validators/axe.ts +288 -0
- package/src/validators/contrast.ts +270 -0
- package/src/validators/index.ts +42 -0
- package/src/validators/schema.ts +191 -0
- package/tailwind.config.ts +96 -0
- package/templates/default/README.md.tpl +15 -0
- package/templates/default/components/button/Button.jsx.tpl +64 -0
- package/templates/default/components/button/Button.tsx.tpl +92 -0
- package/templates/default/components/button/button.react.handoff.js.tpl +31 -0
- package/templates/default/components/button/button.react.handoff.ts.tpl +31 -0
- package/templates/default/env.tpl +2 -0
- package/templates/default/gitignore.tpl +7 -0
- package/templates/default/handoff.config.js.tpl +216 -0
- package/templates/default/handoff.config.ts.tpl +196 -0
- package/templates/default/handoff.config.with-examples.js.tpl +215 -0
- package/templates/default/handoff.config.with-examples.ts.tpl +208 -0
- package/templates/default/package.json.tpl +19 -0
- package/templates/default/tsconfig.json.tpl +24 -0
- package/templates/workflows/hubspot-deploy.yml +134 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,1271 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
|
4
|
+
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
5
|
+
import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
6
|
+
import { Button } from '../ui/button';
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuItem,
|
|
11
|
+
DropdownMenuTrigger,
|
|
12
|
+
} from '../ui/dropdown-menu';
|
|
13
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from '../ui/tooltip';
|
|
14
|
+
import {
|
|
15
|
+
ChevronDown,
|
|
16
|
+
FileCodeIcon,
|
|
17
|
+
Layers,
|
|
18
|
+
Monitor,
|
|
19
|
+
PanelLeft,
|
|
20
|
+
Plus,
|
|
21
|
+
SaveIcon,
|
|
22
|
+
ShieldCheck,
|
|
23
|
+
UserPlus,
|
|
24
|
+
Smartphone,
|
|
25
|
+
ChevronLeft,
|
|
26
|
+
} from 'lucide-react';
|
|
27
|
+
import { cn } from '../../lib/utils';
|
|
28
|
+
import { usePlayground } from './PlaygroundContext';
|
|
29
|
+
import AiChatPanel from './AiChatPanel';
|
|
30
|
+
import { EditContextProvider, useEditContext } from './EditContext';
|
|
31
|
+
import SortableItem from './SortableItem';
|
|
32
|
+
import Preview, { constructComponentPreview, renderPreview } from './Preview';
|
|
33
|
+
import ComponentLibrary from './ComponentLibrary';
|
|
34
|
+
import { handoffApiUrl } from '@/lib/api-path';
|
|
35
|
+
import { htmlToPortableText, toWireArgs } from '@handoff/utils/rich-text';
|
|
36
|
+
import ShareTemplate from './ShareTemplate';
|
|
37
|
+
import PublishToSanityDialog from './PublishToSanityDialog';
|
|
38
|
+
import MetaControl from '../library/MetaControl';
|
|
39
|
+
import PageTitle from './PageTitle';
|
|
40
|
+
import PageOrigin from '../library/PageOrigin';
|
|
41
|
+
import { fieldIdToArgsPath, isRichtextFieldId, richtextEditableFieldPaths, textEditableFieldPaths } from '@/lib/field-marks';
|
|
42
|
+
import { setAtArgsPath } from '@/lib/set-at-args-path';
|
|
43
|
+
import {
|
|
44
|
+
FieldLinkProvider,
|
|
45
|
+
REVEAL_FIELD_MESSAGE,
|
|
46
|
+
fieldLinkKey,
|
|
47
|
+
orderPropertiesByDocument,
|
|
48
|
+
useFieldLink,
|
|
49
|
+
} from './FieldLinkContext';
|
|
50
|
+
import { componentFieldRules, declaredRuleForPath, resolveFieldGuardrail } from '@/lib/authoring-guardrails';
|
|
51
|
+
import MediaBrowser from './MediaBrowser';
|
|
52
|
+
import { renderFormFields } from './fields/Field';
|
|
53
|
+
import type { PlaygroundPageExport, SelectedPlaygroundComponent } from './types';
|
|
54
|
+
|
|
55
|
+
const VIEWPORTS = {
|
|
56
|
+
desktop: { width: '100%', icon: Monitor, label: 'Desktop' },
|
|
57
|
+
mobile: { width: '375px', icon: Smartphone, label: 'Mobile' },
|
|
58
|
+
} as const;
|
|
59
|
+
|
|
60
|
+
type ViewportKey = keyof typeof VIEWPORTS;
|
|
61
|
+
|
|
62
|
+
function buildHandoffPageExport(selectedComponents: SelectedPlaygroundComponent[]): PlaygroundPageExport {
|
|
63
|
+
return {
|
|
64
|
+
title: 'Playground Page',
|
|
65
|
+
description: '',
|
|
66
|
+
group: 'Playground',
|
|
67
|
+
components: selectedComponents.map((c) => c.id),
|
|
68
|
+
previews: {
|
|
69
|
+
default: {
|
|
70
|
+
title: 'Default',
|
|
71
|
+
values: selectedComponents.map((c) => c.data ?? {}),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The block editor, shown in place of the block list rather than beside it.
|
|
79
|
+
*
|
|
80
|
+
* Editing one block is a mode, not a second thing to look at: the list and the editor were competing
|
|
81
|
+
* for attention in two rails while the canvas — the thing you are actually judging — got squeezed
|
|
82
|
+
* between them. Swapping within one rail gives the preview the width back and makes "which block am I
|
|
83
|
+
* editing" unambiguous.
|
|
84
|
+
*
|
|
85
|
+
* Both exits return to the list. Cancel simply discards: `EditContext` keeps edits local until
|
|
86
|
+
* `handleSave` commits them, so leaving without saving needs no undo.
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* The one header for the left panel, in both of its states — the blocks list ("Blocks") and a block's
|
|
90
|
+
* editor ("< Hero CTA"). One component with one fixed height (`min-h-12`: the back button's 24px plus
|
|
91
|
+
* `py-3`) so switching states never moves the border line under it.
|
|
92
|
+
*
|
|
93
|
+
* @param onBack When set, the title is the block's name behind a back chevron, and the pair fades in
|
|
94
|
+
* sliding from the left. Without it, the list label fades in sliding from the right — mirrored, so
|
|
95
|
+
* each state appears to arrive from where the other one went.
|
|
96
|
+
*/
|
|
97
|
+
function PanelHeader({ title, onBack }: { title: string; onBack?: () => void }) {
|
|
98
|
+
return (
|
|
99
|
+
// pb-px balances the 1px bottom border: without it the 47px content box centers the 24px
|
|
100
|
+
// title at a half-pixel, which re-rasterizes as a visible subpixel settle after the slide-in.
|
|
101
|
+
<div className="flex h-12 shrink-0 items-center border-b px-4 pb-px">
|
|
102
|
+
{onBack ? (
|
|
103
|
+
<div className="flex min-w-0 items-center gap-2 animate-in fade-in slide-in-from-left-4 duration-300">
|
|
104
|
+
<Button
|
|
105
|
+
variant="ghost"
|
|
106
|
+
size="sm"
|
|
107
|
+
className="h-6 w-6 shrink-0 p-0"
|
|
108
|
+
onClick={onBack}
|
|
109
|
+
aria-label="Back to blocks"
|
|
110
|
+
title="Back to blocks"
|
|
111
|
+
>
|
|
112
|
+
<ChevronLeft className="h-4 w-4" />
|
|
113
|
+
</Button>
|
|
114
|
+
{/* leading-6 keeps the text box at an even height inside the 48px row — a fractional
|
|
115
|
+
resting position re-rasterizes with a visible subpixel settle when the slide-in's
|
|
116
|
+
compositing layer is dropped. transform-gpu keeps the layer for the same reason. */}
|
|
117
|
+
<h3 className="truncate text-[13px] font-semibold leading-6 text-black transform-gpu">{title}</h3>
|
|
118
|
+
</div>
|
|
119
|
+
) : (
|
|
120
|
+
<span className="text-[13px] font-semibold leading-6 text-black animate-in fade-in slide-in-from-right-4 duration-300 transform-gpu">{title}</span>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function BlockEditorPanel({ onDone }: { onDone: () => void }) {
|
|
127
|
+
const { component, properties, data, handleSave } = useEditContext();
|
|
128
|
+
const { documentOrder } = useFieldLink();
|
|
129
|
+
/**
|
|
130
|
+
* Fields in the order the page reads, not the order the schema happens to list (roadmap F.2).
|
|
131
|
+
*
|
|
132
|
+
* The canvas reports its marks in document order for free — a `TreeWalker` yields them that way — so this is
|
|
133
|
+
* applying a fact rather than guessing at one. With no report (a React block, or a canvas still loading) the
|
|
134
|
+
* schema order stands.
|
|
135
|
+
*/
|
|
136
|
+
const ordered = useMemo(() => orderPropertiesByDocument(properties, documentOrder), [properties, documentOrder]);
|
|
137
|
+
if (!component) return null;
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
{/* No Cancel/Apply pair any more: the canvas live-updates while typing (see EditContext's
|
|
142
|
+
patch postMessage), so back is the one exit and it commits. */}
|
|
143
|
+
<PanelHeader
|
|
144
|
+
title={component.title}
|
|
145
|
+
onBack={() => {
|
|
146
|
+
handleSave();
|
|
147
|
+
onDone();
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
<div className="flex-1 overflow-y-auto px-4 py-3">
|
|
151
|
+
{component.description && (
|
|
152
|
+
<p className="mb-3 text-xs text-muted-foreground">{component.description}</p>
|
|
153
|
+
)}
|
|
154
|
+
{renderFormFields(ordered, data)}
|
|
155
|
+
</div>
|
|
156
|
+
</>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The one shell for every level of a page (roadmap E.8).
|
|
162
|
+
*
|
|
163
|
+
* A page, a brief, and a build made from that brief are all the same object shape rendered with different write
|
|
164
|
+
* capability, so they get the same toolbar and the same canvas — only the left panel changes. Before this,
|
|
165
|
+
* a brief had its own route and its own 30/70 layout, which is exactly why it read as a third product instead
|
|
166
|
+
* of a deeper view of the page ("It makes it unclear what's happening" — the maintainer, 2026-08-06).
|
|
167
|
+
*
|
|
168
|
+
* @param leftPanel Replaces the blocks list / block editor entirely. Set at brief and build level, where there
|
|
169
|
+
* is no structure to edit and the panel is about the invitation or the submission instead.
|
|
170
|
+
* @param canvasControls When false the preview gets **no** injected affordances at all — not even the edit
|
|
171
|
+
* pencil `structuralEditing: false` keeps for guests. A frozen brief or someone else's build must not offer
|
|
172
|
+
* a control the write path would refuse.
|
|
173
|
+
*/
|
|
174
|
+
export default function PlaygroundBuilder({
|
|
175
|
+
leftPanel,
|
|
176
|
+
canvasControls = true,
|
|
177
|
+
buildCount = 0,
|
|
178
|
+
onShowBuilds,
|
|
179
|
+
checkCount = 0,
|
|
180
|
+
onShowChecks,
|
|
181
|
+
}: {
|
|
182
|
+
leftPanel?: React.ReactNode;
|
|
183
|
+
canvasControls?: boolean;
|
|
184
|
+
/** How many pages have been made from this one. Only used to label the control. */
|
|
185
|
+
buildCount?: number;
|
|
186
|
+
/** How many findings the server computed for this page. Zero still opens — "nothing wrong" is an answer. */
|
|
187
|
+
checkCount?: number;
|
|
188
|
+
/** Set at page level to offer that list without leaving the page. */
|
|
189
|
+
onShowBuilds?: () => void;
|
|
190
|
+
/** Set at page level to show what the checks made of this page without leaving it. */
|
|
191
|
+
onShowChecks?: () => void;
|
|
192
|
+
} = {}) {
|
|
193
|
+
const {
|
|
194
|
+
selectedComponents,
|
|
195
|
+
loading,
|
|
196
|
+
error,
|
|
197
|
+
onDragEnd,
|
|
198
|
+
removeComponent,
|
|
199
|
+
activeComponentId,
|
|
200
|
+
setActiveComponentId,
|
|
201
|
+
editingPatternId,
|
|
202
|
+
setEditingPatternId,
|
|
203
|
+
isDynamicApp,
|
|
204
|
+
updateComponent,
|
|
205
|
+
saveState,
|
|
206
|
+
pageTitle,
|
|
207
|
+
structuralEditing,
|
|
208
|
+
aiAssistantEnabled,
|
|
209
|
+
contentOnly,
|
|
210
|
+
guardrails,
|
|
211
|
+
selectedBlockId,
|
|
212
|
+
setSelectedBlockId,
|
|
213
|
+
consumeCanvasReveal,
|
|
214
|
+
} = usePlayground();
|
|
215
|
+
|
|
216
|
+
const [html, setHtml] = useState('');
|
|
217
|
+
const [loadingHtml, setLoadingHtml] = useState(false);
|
|
218
|
+
const [wizardOpen, setWizardOpen] = useState(false);
|
|
219
|
+
const [templateNotice, setTemplateNotice] = useState<string | null>(null);
|
|
220
|
+
/** The Sanity publish dialog. A dialog rather than a wizard route: it never leaves the canvas. */
|
|
221
|
+
const [publishOpen, setPublishOpen] = useState(false);
|
|
222
|
+
|
|
223
|
+
const [viewport, setViewport] = useState<ViewportKey>('desktop');
|
|
224
|
+
/** Canvas zoom: 1 or 0.7 — a visual scale-down of the frame only, the document still lays out at full width. */
|
|
225
|
+
const [canvasScale, setCanvasScale] = useState(1);
|
|
226
|
+
const [leftPanelOpen, setLeftPanelOpen] = useState(true);
|
|
227
|
+
const basePath = process.env.HANDOFF_APP_BASE_PATH ?? '';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The `maxLength` in force for the overlay's counter, **per block**.
|
|
231
|
+
*
|
|
232
|
+
* Resolved through `resolveFieldGuardrail` so the number in the canvas is the number the rail shows and the
|
|
233
|
+
* server enforces — three places agreeing because they share one resolver, not because they were kept in step.
|
|
234
|
+
* Keyed without a row index: one rule covers every row of a repeater.
|
|
235
|
+
*
|
|
236
|
+
* **Component declarations are included, not just the brief's fields.** Reading only `guardrails.fields` meant
|
|
237
|
+
* the canvas counter appeared exclusively for brief-configured paths — so on a registry whose limits all come
|
|
238
|
+
* from component contracts (the Handlebars registry: every one of them) the overlay showed no counter at all, while the rail showed
|
|
239
|
+
* one and the server enforced it. That is the same class of gap as E.9's original `maxLength`-only read.
|
|
240
|
+
*
|
|
241
|
+
* **Per block rather than a union**, because two components can declare different limits for the same field
|
|
242
|
+
* name — `title` is 60 on one and 80 on another — and a flat map would quietly show one block another's number.
|
|
243
|
+
* The frame already knows its `blockId`, so it can look up its own.
|
|
244
|
+
*/
|
|
245
|
+
const inlineFieldLimits = useMemo(() => {
|
|
246
|
+
const out: Record<string, Record<string, number>> = {};
|
|
247
|
+
for (const component of selectedComponents) {
|
|
248
|
+
const blockId = component.uniqueId;
|
|
249
|
+
if (!blockId) continue;
|
|
250
|
+
const declared = componentFieldRules((component as { properties?: unknown }).properties);
|
|
251
|
+
const forBlock: Record<string, number> = {};
|
|
252
|
+
// Every path either side knows about: the component's own declarations plus the brief's overrides.
|
|
253
|
+
for (const path of new Set([...Object.keys(declared), ...Object.keys(guardrails.fields ?? {})])) {
|
|
254
|
+
const max = resolveFieldGuardrail(guardrails, path, declaredRuleForPath(declared, path)).maxLength;
|
|
255
|
+
if (max) forBlock[path] = max;
|
|
256
|
+
}
|
|
257
|
+
if (Object.keys(forBlock).length) out[blockId] = forBlock;
|
|
258
|
+
}
|
|
259
|
+
return out;
|
|
260
|
+
}, [guardrails, selectedComponents]);
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Which field paths a text overlay may edit, unioned across the blocks on the canvas.
|
|
264
|
+
*
|
|
265
|
+
* Derived from each component's own contract, because the frame cannot know a declared type — and getting this
|
|
266
|
+
* wrong is not cosmetic: a field wrapping a repeater reads back as its rows concatenated, and committing that
|
|
267
|
+
* writes a string over an array. Union rather than per-block because the frame keys on the field path, and two
|
|
268
|
+
* blocks sharing a path share a type in practice.
|
|
269
|
+
*/
|
|
270
|
+
const inlineEditableFields = useMemo(() => {
|
|
271
|
+
const out = new Set<string>();
|
|
272
|
+
for (const c of selectedComponents) {
|
|
273
|
+
for (const path of textEditableFieldPaths((c as { properties?: unknown }).properties)) out.add(path);
|
|
274
|
+
}
|
|
275
|
+
return [...out];
|
|
276
|
+
}, [selectedComponents]);
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The rail ↔ canvas link (roadmap F.2). Kept here because this is the one component that holds both ends: the
|
|
280
|
+
* canvas iframe to post to, and the rail that renders the fields.
|
|
281
|
+
*/
|
|
282
|
+
const [hoveredField, setHoveredField] = useState<string | null>(null);
|
|
283
|
+
/** Document order of marks, per block, as the frame reports it. */
|
|
284
|
+
const [fieldOrderByBlock, setFieldOrderByBlock] = useState<Record<string, string[]>>({});
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Hovering a field in the rail highlights it in the canvas.
|
|
288
|
+
*
|
|
289
|
+
* Posted straight to the frame rather than routed through state, so the canvas responds on the same tick the
|
|
290
|
+
* pointer moves — and the frame is the only thing that can find the mark anyway.
|
|
291
|
+
*/
|
|
292
|
+
const handleFieldHover = useCallback((path: string | null) => {
|
|
293
|
+
setHoveredField(path);
|
|
294
|
+
canvasIframeRef.current?.contentWindow?.postMessage(
|
|
295
|
+
{ type: 'playground-highlight-field', fieldId: path },
|
|
296
|
+
'*'
|
|
297
|
+
);
|
|
298
|
+
}, []);
|
|
299
|
+
|
|
300
|
+
const fieldLink = useMemo(
|
|
301
|
+
() => ({
|
|
302
|
+
hovered: hoveredField,
|
|
303
|
+
onHover: handleFieldHover,
|
|
304
|
+
documentOrder: activeComponentId ? (fieldOrderByBlock[activeComponentId] ?? null) : null,
|
|
305
|
+
}),
|
|
306
|
+
[hoveredField, handleFieldHover, activeComponentId, fieldOrderByBlock]
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Richtext paths, unioned across the canvas — roadmap F.2b.
|
|
311
|
+
*
|
|
312
|
+
* Separate from `inlineEditableFields` because the frame needs to know *which overlay* to open, not merely that a
|
|
313
|
+
* field is editable. Same union-rather-than-per-block reasoning: the frame keys on the field path.
|
|
314
|
+
*/
|
|
315
|
+
const inlineRichtextFields = useMemo(() => {
|
|
316
|
+
const out = new Set<string>();
|
|
317
|
+
for (const c of selectedComponents) {
|
|
318
|
+
for (const path of richtextEditableFieldPaths((c as { properties?: unknown }).properties)) out.add(path);
|
|
319
|
+
}
|
|
320
|
+
return [...out];
|
|
321
|
+
}, [selectedComponents]);
|
|
322
|
+
|
|
323
|
+
// The canvas preview iframe — shared with the right-panel editor so field
|
|
324
|
+
// edits live-update the real page via postMessage (no full canvas rebuild).
|
|
325
|
+
const canvasIframeRef = useRef<HTMLIFrameElement>(null);
|
|
326
|
+
|
|
327
|
+
const sensors = useSensors(
|
|
328
|
+
useSensor(PointerSensor),
|
|
329
|
+
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
const activeComponent = selectedComponents.find((c) => c.uniqueId === activeComponentId) ?? null;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Set when the editor was opened FROM the canvas (a field click, the block's own edit button): the
|
|
336
|
+
* user is already looking at that block, and scrolling it to the top of the canvas was what made
|
|
337
|
+
* everything above it "disappear" the moment they entered edit mode. The scroll below is for the
|
|
338
|
+
* OTHER direction — picking a block in the rail — and only that.
|
|
339
|
+
*/
|
|
340
|
+
const activatedFromCanvasRef = useRef(false);
|
|
341
|
+
|
|
342
|
+
// Bring the selected block into view in the canvas. Paired with the listener injected by
|
|
343
|
+
// `getBlockControlsScript`; posting to a canvas that has not finished loading is a no-op, and the
|
|
344
|
+
// next selection will land, so no retry is needed.
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
if (!activeComponentId) return;
|
|
347
|
+
if (activatedFromCanvasRef.current) {
|
|
348
|
+
activatedFromCanvasRef.current = false;
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
canvasIframeRef.current?.contentWindow?.postMessage(
|
|
352
|
+
{ type: 'playground-scroll-to-block', blockId: activeComponentId },
|
|
353
|
+
'*'
|
|
354
|
+
);
|
|
355
|
+
}, [activeComponentId]);
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Where the canvas is scrolled to, as last reported by the frame.
|
|
359
|
+
*
|
|
360
|
+
* A ref, not state: this updates on every scrolled frame and re-rendering for it would be absurd — and it is
|
|
361
|
+
* read only at the moment a rebuild is assembled. The frame is opaque-origin, so asking it is the only way to
|
|
362
|
+
* know. See `getBlockControlsScript` for why a rebuild needs it at all.
|
|
363
|
+
*/
|
|
364
|
+
const canvasScrollRef = useRef(0);
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* The canvas as of the last srcdoc build (or accepted patch), for telling content edits from structural ones.
|
|
368
|
+
*
|
|
369
|
+
* A structural change — a block added, removed, reordered, or swapped for another component — needs the full
|
|
370
|
+
* rebuild below. A pure content change (a chat changeset's `update`, a rail commit) re-rendered one block's
|
|
371
|
+
* HTML on an otherwise identical list, and rebuilding the whole document for that threw away every block's
|
|
372
|
+
* DOM and any open overlay. Those are patched into the live frame instead: React blocks through the
|
|
373
|
+
* `update-props` listener each block already registers, Handlebars blocks through `getBlockPatchScript`.
|
|
374
|
+
*/
|
|
375
|
+
const patchBaseRef = useRef<SelectedPlaygroundComponent[] | null>(null);
|
|
376
|
+
/** The injected scripts are built from these; if either moves, the document itself is stale. */
|
|
377
|
+
const patchFlagsRef = useRef<string>('');
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Selection (chat targeting) wiring. The frame owns the painting, this side owns the state:
|
|
381
|
+
* a block click toggles, the backdrop and a vanished block clear, and every repaint of the frame is
|
|
382
|
+
* re-told the current selection (a srcdoc rebuild starts from a blank document).
|
|
383
|
+
*/
|
|
384
|
+
const selectedBlockIdRef = useRef<string | null>(null);
|
|
385
|
+
selectedBlockIdRef.current = selectedBlockId;
|
|
386
|
+
const postSelection = useCallback((blockId: string | null) => {
|
|
387
|
+
canvasIframeRef.current?.contentWindow?.postMessage({ type: 'playground-select-block', blockId }, '*');
|
|
388
|
+
}, []);
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Hover linking between the rail and the canvas, both directions. Transient by nature — no re-sync
|
|
392
|
+
* after rebuilds, no persistence; whichever side the pointer is actually on drives the other.
|
|
393
|
+
*/
|
|
394
|
+
const [hoveredBlockId, setHoveredBlockId] = useState<string | null>(null);
|
|
395
|
+
const hoverBlockFromRail = useCallback((blockId: string | null) => {
|
|
396
|
+
setHoveredBlockId(blockId);
|
|
397
|
+
canvasIframeRef.current?.contentWindow?.postMessage({ type: 'playground-hover-block', blockId }, '*');
|
|
398
|
+
}, []);
|
|
399
|
+
useEffect(() => {
|
|
400
|
+
postSelection(selectedBlockId);
|
|
401
|
+
}, [selectedBlockId, postSelection]);
|
|
402
|
+
// A selected block that an op or a removal took off the page must not keep scoping the chat.
|
|
403
|
+
useEffect(() => {
|
|
404
|
+
if (selectedBlockId && !selectedComponents.some((c) => c.uniqueId === selectedBlockId)) {
|
|
405
|
+
setSelectedBlockId(null);
|
|
406
|
+
}
|
|
407
|
+
}, [selectedComponents, selectedBlockId, setSelectedBlockId]);
|
|
408
|
+
|
|
409
|
+
useEffect(() => {
|
|
410
|
+
const prev = patchBaseRef.current;
|
|
411
|
+
patchBaseRef.current = selectedComponents;
|
|
412
|
+
// Taken on every run, whatever this run decides: the flag belongs to the write that fired this effect.
|
|
413
|
+
const reveal = consumeCanvasReveal();
|
|
414
|
+
const flags = `${canvasControls}:${structuralEditing}`;
|
|
415
|
+
const flagsChanged = patchFlagsRef.current !== flags;
|
|
416
|
+
patchFlagsRef.current = flags;
|
|
417
|
+
const sameStructure =
|
|
418
|
+
prev !== null &&
|
|
419
|
+
!flagsChanged &&
|
|
420
|
+
prev.length === selectedComponents.length &&
|
|
421
|
+
prev.every((p, i) => p.uniqueId === selectedComponents[i].uniqueId && p.id === selectedComponents[i].id);
|
|
422
|
+
if (sameStructure) {
|
|
423
|
+
const frame = canvasIframeRef.current?.contentWindow;
|
|
424
|
+
// Identity says what changed: applyBlockOps and updateComponent replace only the objects they touched.
|
|
425
|
+
// An empty diff means some other dependency fired this effect — let the rebuild answer it.
|
|
426
|
+
const changed = selectedComponents.filter((c, i) => prev![i] !== c);
|
|
427
|
+
if (frame && changed.length > 0 && changed.every((c) => c.format === 'react' || c.rendered)) {
|
|
428
|
+
for (const c of changed) {
|
|
429
|
+
if (c.format === 'react')
|
|
430
|
+
frame.postMessage(
|
|
431
|
+
{ type: 'update-props', props: toWireArgs(c.data, c.properties), blockId: c.uniqueId },
|
|
432
|
+
'*'
|
|
433
|
+
);
|
|
434
|
+
else frame.postMessage({ type: 'playground-replace-block-html', blockId: c.uniqueId, html: c.rendered }, '*');
|
|
435
|
+
}
|
|
436
|
+
// The `html` state is now behind the live frame — deliberately. It is only read as srcdoc, and the
|
|
437
|
+
// next structural change rebuilds it from the same components this patch came from.
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// A pure INSERTION that asked to be revealed (a chat changeset): every previous block still present, in
|
|
443
|
+
// order, plus new ones between them. The frame takes the new blocks into its live document and the
|
|
444
|
+
// canvas plays the reveal — zoom out to the page's final height, existing blocks slide apart, new blocks
|
|
445
|
+
// fade into the gaps (see `playground-insert-blocks` in getBlockPatchScript and <Preview>). Handlebars
|
|
446
|
+
// only: a React block's loader is a <script>, which an innerHTML insert will not run, so a changeset
|
|
447
|
+
// that inserts one takes the rebuild below. Kept blocks a same-changeset `update` touched are patched
|
|
448
|
+
// first, so the reveal plays over their new content.
|
|
449
|
+
if (reveal && prev !== null && !flagsChanged && prev.length > 0 && selectedComponents.length > prev.length) {
|
|
450
|
+
const frame = canvasIframeRef.current?.contentWindow;
|
|
451
|
+
const prevById = new Map(prev.map((p) => [p.uniqueId, p]));
|
|
452
|
+
const kept = selectedComponents.filter((c) => prevById.has(c.uniqueId));
|
|
453
|
+
const added = selectedComponents.filter((c) => !prevById.has(c.uniqueId));
|
|
454
|
+
const sameOrder =
|
|
455
|
+
kept.length === prev.length && kept.every((c, i) => c.uniqueId === prev[i].uniqueId && c.id === prev[i].id);
|
|
456
|
+
const keptPatchable = kept.every((c) => prevById.get(c.uniqueId) === c || c.format === 'react' || !!c.rendered);
|
|
457
|
+
const addedPatchable = added.length > 0 && added.every((c) => c.format !== 'react' && !!c.rendered);
|
|
458
|
+
if (frame && sameOrder && keptPatchable && addedPatchable) {
|
|
459
|
+
for (const c of kept) {
|
|
460
|
+
if (prevById.get(c.uniqueId) === c) continue;
|
|
461
|
+
if (c.format === 'react')
|
|
462
|
+
frame.postMessage(
|
|
463
|
+
{ type: 'update-props', props: toWireArgs(c.data, c.properties), blockId: c.uniqueId },
|
|
464
|
+
'*'
|
|
465
|
+
);
|
|
466
|
+
else frame.postMessage({ type: 'playground-replace-block-html', blockId: c.uniqueId, html: c.rendered }, '*');
|
|
467
|
+
}
|
|
468
|
+
frame.postMessage(
|
|
469
|
+
{
|
|
470
|
+
type: 'playground-insert-blocks',
|
|
471
|
+
order: selectedComponents.map((c) => c.uniqueId),
|
|
472
|
+
blocks: added.map((c) => ({ blockId: c.uniqueId, title: c.title, html: c.rendered })),
|
|
473
|
+
},
|
|
474
|
+
'*'
|
|
475
|
+
);
|
|
476
|
+
// As with content patches, `html` is now behind the live frame; the next structural change rebuilds.
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// A pure REMOVAL that asked to be revealed: every remaining block was there before, in order, and the
|
|
482
|
+
// rest are gone. The same choreography as the insert, backwards — zoom out, the leaving blocks fade,
|
|
483
|
+
// the survivors slide up to close the gaps, zoom back in (see `playground-remove-blocks`). Any surviving
|
|
484
|
+
// block a same-changeset `update` touched is patched first, as above.
|
|
485
|
+
if (reveal && prev !== null && !flagsChanged && selectedComponents.length > 0 && selectedComponents.length < prev.length) {
|
|
486
|
+
const frame = canvasIframeRef.current?.contentWindow;
|
|
487
|
+
const nowById = new Map(selectedComponents.map((c) => [c.uniqueId, c]));
|
|
488
|
+
const survivors = prev.filter((p) => nowById.has(p.uniqueId));
|
|
489
|
+
const removed = prev.filter((p) => !nowById.has(p.uniqueId));
|
|
490
|
+
const sameOrder =
|
|
491
|
+
survivors.length === selectedComponents.length &&
|
|
492
|
+
survivors.every((p, i) => p.uniqueId === selectedComponents[i].uniqueId && p.id === selectedComponents[i].id);
|
|
493
|
+
const prevById = new Map(prev.map((p) => [p.uniqueId, p]));
|
|
494
|
+
const keptPatchable = selectedComponents.every(
|
|
495
|
+
(c) => prevById.get(c.uniqueId) === c || c.format === 'react' || !!c.rendered
|
|
496
|
+
);
|
|
497
|
+
if (frame && removed.length > 0 && sameOrder && keptPatchable) {
|
|
498
|
+
for (const c of selectedComponents) {
|
|
499
|
+
if (prevById.get(c.uniqueId) === c) continue;
|
|
500
|
+
if (c.format === 'react')
|
|
501
|
+
frame.postMessage(
|
|
502
|
+
{ type: 'update-props', props: toWireArgs(c.data, c.properties), blockId: c.uniqueId },
|
|
503
|
+
'*'
|
|
504
|
+
);
|
|
505
|
+
else frame.postMessage({ type: 'playground-replace-block-html', blockId: c.uniqueId, html: c.rendered }, '*');
|
|
506
|
+
}
|
|
507
|
+
frame.postMessage({ type: 'playground-remove-blocks', ids: removed.map((c) => c.uniqueId) }, '*');
|
|
508
|
+
// `html` is now behind the live frame; the next structural change rebuilds.
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// A pure PERMUTATION — same blocks, same content, new order (a sidebar drag) — animates in place
|
|
514
|
+
// instead of rebuilding: the frame FLIPs its wrappers to the new order (see getBlockPatchScript).
|
|
515
|
+
// Content is compared by the parts a drag cannot change (`data`, `rendered` — onDragEnd re-wraps the
|
|
516
|
+
// objects for `order`, so object identity alone cannot be the test).
|
|
517
|
+
if (prev !== null && !flagsChanged && prev.length === selectedComponents.length && prev.length > 0) {
|
|
518
|
+
const prevById = new Map(prev.map((p) => [p.uniqueId, p]));
|
|
519
|
+
const isPermutation =
|
|
520
|
+
selectedComponents.some((c, i) => prev[i].uniqueId !== c.uniqueId) &&
|
|
521
|
+
selectedComponents.every((c) => {
|
|
522
|
+
const p = prevById.get(c.uniqueId);
|
|
523
|
+
return !!p && p.id === c.id && p.data === c.data && p.rendered === c.rendered;
|
|
524
|
+
});
|
|
525
|
+
const frame = canvasIframeRef.current?.contentWindow;
|
|
526
|
+
if (isPermutation && frame) {
|
|
527
|
+
frame.postMessage(
|
|
528
|
+
{ type: 'playground-reorder-blocks', order: selectedComponents.map((c) => c.uniqueId) },
|
|
529
|
+
'*'
|
|
530
|
+
);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const render = async () => {
|
|
536
|
+
setLoadingHtml(true);
|
|
537
|
+
const result = await constructComponentPreview(selectedComponents, basePath, {
|
|
538
|
+
// The canvas scrolls in <Preview scrollHost> — the frame reports its height and block positions.
|
|
539
|
+
hostScroll: true,
|
|
540
|
+
restoreScrollY: canvasScrollRef.current,
|
|
541
|
+
injectBlockControls: canvasControls,
|
|
542
|
+
// Edit yes, remove no, when the structure is fixed (roadmap E.5).
|
|
543
|
+
allowDelete: structuralEditing && canvasControls,
|
|
544
|
+
/**
|
|
545
|
+
* Inline editing rides on the same flag as the block controls: both mean "this canvas is editable".
|
|
546
|
+
* A React block carries no `{{#field}}` marks, so the script finds nothing and returns — no branch
|
|
547
|
+
* needed, and no half-working affordance on a surface that cannot support it.
|
|
548
|
+
*/
|
|
549
|
+
inlineEdit: canvasControls,
|
|
550
|
+
/**
|
|
551
|
+
* Navigation is injected whether or not this canvas is editable.
|
|
552
|
+
*
|
|
553
|
+
* A review canvas is exactly where "click the finding, see the problem" matters most, and it is the one
|
|
554
|
+
* canvas that had no listener at all — the messages below were posted into a frame that ignored them.
|
|
555
|
+
*/
|
|
556
|
+
fieldNavigation: !canvasControls,
|
|
557
|
+
// A link in a preview is scenery, not a destination. Clicking one used to navigate the frame away.
|
|
558
|
+
interceptLinks: true,
|
|
559
|
+
// Click a block to TARGET it (chat scoping) — selection, not the editor.
|
|
560
|
+
blockSelection: true,
|
|
561
|
+
fieldLimits: inlineFieldLimits,
|
|
562
|
+
editableFields: inlineEditableFields,
|
|
563
|
+
richtextFields: inlineRichtextFields,
|
|
564
|
+
});
|
|
565
|
+
setHtml(result);
|
|
566
|
+
setLoadingHtml(false);
|
|
567
|
+
};
|
|
568
|
+
render();
|
|
569
|
+
// Both inline lists are memoized, so including them costs nothing and closes a real staleness gap: a
|
|
570
|
+
// guardrail edited while the canvas is open would otherwise leave the overlay counting against the old limit.
|
|
571
|
+
}, [
|
|
572
|
+
selectedComponents,
|
|
573
|
+
basePath,
|
|
574
|
+
structuralEditing,
|
|
575
|
+
canvasControls,
|
|
576
|
+
inlineFieldLimits,
|
|
577
|
+
inlineEditableFields,
|
|
578
|
+
inlineRichtextFields,
|
|
579
|
+
consumeCanvasReveal,
|
|
580
|
+
]);
|
|
581
|
+
|
|
582
|
+
useEffect(() => {
|
|
583
|
+
const handler = (event: MessageEvent) => {
|
|
584
|
+
if (event.data?.type === 'playground-scroll') {
|
|
585
|
+
if (typeof event.data.y === 'number') canvasScrollRef.current = event.data.y;
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// The canvas telling us which block the pointer is over, for the rail's mirrored hover.
|
|
590
|
+
if (event.data?.type === 'playground-block-hover') {
|
|
591
|
+
setHoveredBlockId(typeof event.data.blockId === 'string' ? event.data.blockId : null);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// A block clicked in the canvas: toggle targeting. Selection only — the editor stays closed; the
|
|
596
|
+
// rail row highlights instead (see SortableItem's isSelected).
|
|
597
|
+
if (event.data?.type === 'playground-block-click') {
|
|
598
|
+
const id = typeof event.data.blockId === 'string' ? event.data.blockId : null;
|
|
599
|
+
if (id) setSelectedBlockId((prev) => (prev === id ? null : id));
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// A height report doubles as "the frame has a live document": a srcdoc rebuild starts blank, so
|
|
604
|
+
// the selection paint must be re-sent. Idempotent, so the repeats on ordinary resizes cost nothing.
|
|
605
|
+
if (event.data?.type === 'playground-canvas-height') {
|
|
606
|
+
if (selectedBlockIdRef.current && event.source === canvasIframeRef.current?.contentWindow) {
|
|
607
|
+
postSelection(selectedBlockIdRef.current);
|
|
608
|
+
}
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* The canvas telling the rail what the pointer is over, and which order its fields render in — the two
|
|
614
|
+
* messages the frame has been emitting since F.2 with nothing listening (roadmap F.2).
|
|
615
|
+
*/
|
|
616
|
+
/**
|
|
617
|
+
* A findings list asking for a field to be shown (roadmap E.11). This is the only place that can satisfy it:
|
|
618
|
+
* a finding names a block by *index*, and only the builder holds the ordered blocks to turn that into a
|
|
619
|
+
* `uniqueId` — plus the canvas ref to point at.
|
|
620
|
+
*/
|
|
621
|
+
if (event.data?.type === REVEAL_FIELD_MESSAGE) {
|
|
622
|
+
const { blockIndex, path } = event.data as { blockIndex?: unknown; path?: unknown };
|
|
623
|
+
if (typeof blockIndex !== 'number') return;
|
|
624
|
+
const block = selectedComponents[blockIndex];
|
|
625
|
+
if (!block?.uniqueId) return;
|
|
626
|
+
|
|
627
|
+
// Open the block's editor in the rail. The field the finding is about is inside it.
|
|
628
|
+
setActiveComponentId(block.uniqueId);
|
|
629
|
+
|
|
630
|
+
const key = typeof path === 'string' && path ? fieldLinkKey(path) : null;
|
|
631
|
+
setHoveredField(key);
|
|
632
|
+
const frame = canvasIframeRef.current?.contentWindow;
|
|
633
|
+
/**
|
|
634
|
+
* Scroll first, then highlight. A page-level finding carries no path, so it still brings the block into
|
|
635
|
+
* view — being shown the right block is most of the answer even when no single field is at fault.
|
|
636
|
+
*/
|
|
637
|
+
/**
|
|
638
|
+
* `flash` outlines the whole section on arrival; `reveal` centres the field inside it.
|
|
639
|
+
*
|
|
640
|
+
* Both only from here. Selecting a block in the rail posts the same scroll message, and a section that
|
|
641
|
+
* flashes every time you click down a list is noise — this path is the one where you asked "show me the
|
|
642
|
+
* thing this finding is about" and are looking for it.
|
|
643
|
+
*/
|
|
644
|
+
frame?.postMessage({ type: 'playground-scroll-to-block', blockId: block.uniqueId, flash: true }, '*');
|
|
645
|
+
frame?.postMessage({ type: 'playground-highlight-field', fieldId: key, reveal: true }, '*');
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (event.data?.type === 'playground-field-hover') {
|
|
650
|
+
const id = event.data.fieldId;
|
|
651
|
+
setHoveredField(typeof id === 'string' ? fieldLinkKey(id) : null);
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
if (event.data?.type === 'playground-fields') {
|
|
655
|
+
const { fields } = event.data as { fields?: { id?: unknown; blockId?: unknown }[] };
|
|
656
|
+
if (!Array.isArray(fields)) return;
|
|
657
|
+
const next: Record<string, string[]> = {};
|
|
658
|
+
for (const f of fields) {
|
|
659
|
+
if (typeof f?.id !== 'string' || typeof f?.blockId !== 'string') continue;
|
|
660
|
+
(next[f.blockId] ??= []).push(f.id);
|
|
661
|
+
}
|
|
662
|
+
// Replaced wholesale, not merged: the frame reports every mark in the document each time it loads, so a
|
|
663
|
+
// stale block's order would otherwise outlive the block itself.
|
|
664
|
+
setFieldOrderByBlock(next);
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
/** A field focused for inline editing selects it in the rail too, so the two views agree on "current". */
|
|
668
|
+
if (event.data?.type === 'playground-field-focus') {
|
|
669
|
+
const { blockId, fieldId } = event.data as { blockId?: unknown; fieldId?: unknown };
|
|
670
|
+
// Canvas-originated: don't scroll the canvas to a block the user just clicked inside.
|
|
671
|
+
if (typeof blockId === 'string') {
|
|
672
|
+
activatedFromCanvasRef.current = true;
|
|
673
|
+
setActiveComponentId(blockId);
|
|
674
|
+
}
|
|
675
|
+
if (typeof fieldId === 'string') setHoveredField(fieldLinkKey(fieldId));
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (event.data?.type === 'playground-block-action') {
|
|
680
|
+
const { action, blockId } = event.data;
|
|
681
|
+
if (action === 'edit') {
|
|
682
|
+
// Same canvas origin as a field click — see activatedFromCanvasRef.
|
|
683
|
+
activatedFromCanvasRef.current = true;
|
|
684
|
+
setActiveComponentId(blockId);
|
|
685
|
+
} else if (action === 'delete' && structuralEditing) {
|
|
686
|
+
// Gated here as well as in the injected script: the iframe's messages are input, not instructions.
|
|
687
|
+
removeComponent(blockId);
|
|
688
|
+
}
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* An inline edit committed in the canvas (roadmap F.2).
|
|
694
|
+
*
|
|
695
|
+
* Applied through the same `updateComponent` the rail writes with, so an inline edit is indistinguishable
|
|
696
|
+
* downstream — autosave, guardrails and the audit all see an ordinary value change. The frame reports a
|
|
697
|
+
* *mark id*; `fieldIdToArgsPath` turns it into the path the data actually uses, which is the join that has
|
|
698
|
+
* to be right or an edit writes somewhere nothing renders.
|
|
699
|
+
*
|
|
700
|
+
* **`rendered` is refreshed too, and that is not optional**: `constructComponentPreview` draws a Handlebars
|
|
701
|
+
* block from `component.rendered`, a cached HTML string, and never re-renders it from `data`. Committing
|
|
702
|
+
* `data` alone updated the record and saved it, then rebuilt the canvas from the stale string — so the text
|
|
703
|
+
* snapped back the instant it was committed and inline editing looked like it did not persist. This mirrors
|
|
704
|
+
* what `EditContext.handleSave` does for the rail, for the same reason.
|
|
705
|
+
*
|
|
706
|
+
* Re-gated here: a message from the frame is input, not an instruction. Nothing is applied on a surface
|
|
707
|
+
* that is not offering inline editing in the first place.
|
|
708
|
+
*/
|
|
709
|
+
if (event.data?.type === 'playground-field-commit' && canvasControls) {
|
|
710
|
+
const { blockId, fieldId, value } = event.data as { blockId?: string; fieldId?: string; value?: unknown };
|
|
711
|
+
if (!blockId || !fieldId || typeof value !== 'string') return;
|
|
712
|
+
const block = selectedComponents.find((c) => c.uniqueId === blockId);
|
|
713
|
+
if (!block) return;
|
|
714
|
+
|
|
715
|
+
const path = fieldIdToArgsPath(fieldId);
|
|
716
|
+
if (!path.length) return;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* **The parent converts, because the frame cannot.** `inline-edit-script` is a stringified script in a
|
|
720
|
+
* sandboxed iframe with no module loader, so it cannot import the converter; its contract stays
|
|
721
|
+
* "commit `innerHTML`, post HTML". Storing that HTML straight would leave the canvas writing markup
|
|
722
|
+
* into an arg the rail writes Portable Text into — two shapes for one field, and a history facet that
|
|
723
|
+
* moves depending on which editor last touched it. So the boundary is here, one line before the write.
|
|
724
|
+
*
|
|
725
|
+
* Only for a field the component declares richtext: a text overlay posts plain copy, and parsing that
|
|
726
|
+
* would wrap a headline in a block it never had.
|
|
727
|
+
*/
|
|
728
|
+
const stored = isRichtextFieldId(block.properties, fieldId) ? htmlToPortableText(value) : value;
|
|
729
|
+
|
|
730
|
+
const nextData = setAtArgsPath(block.data, path, stored);
|
|
731
|
+
void (async () => {
|
|
732
|
+
const updated = { ...block, data: nextData };
|
|
733
|
+
updated.rendered = await renderPreview(updated, nextData, basePath);
|
|
734
|
+
updateComponent(updated);
|
|
735
|
+
})();
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
window.addEventListener('message', handler);
|
|
739
|
+
return () => window.removeEventListener('message', handler);
|
|
740
|
+
}, [
|
|
741
|
+
setActiveComponentId,
|
|
742
|
+
removeComponent,
|
|
743
|
+
structuralEditing,
|
|
744
|
+
canvasControls,
|
|
745
|
+
selectedComponents,
|
|
746
|
+
updateComponent,
|
|
747
|
+
basePath,
|
|
748
|
+
setSelectedBlockId,
|
|
749
|
+
postSelection,
|
|
750
|
+
]);
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Loading and failure keep the left panel, when there is one.
|
|
754
|
+
*
|
|
755
|
+
* These used to replace the entire shell, which was harmless while the panel only ever held a block list. At
|
|
756
|
+
* brief and build level (roadmap E.8) that panel is the **only way back to the page** — so a canvas that
|
|
757
|
+
* failed to load would strand you on a "Try Again" button with no navigation at all.
|
|
758
|
+
*/
|
|
759
|
+
/**
|
|
760
|
+
* The page's content, as a manifest to read or a prompt to paste (reflow R.6).
|
|
761
|
+
*
|
|
762
|
+
* Fetched rather than assembled here: the route is the one place that decides what "the content of this
|
|
763
|
+
* page" is, and a second assembly in the browser would be a second answer. The prompt goes to the clipboard
|
|
764
|
+
* because its destination is an agent conversation; the manifest downloads because its destination is a
|
|
765
|
+
* document somebody marks up.
|
|
766
|
+
*/
|
|
767
|
+
const exportContent = useCallback(
|
|
768
|
+
async (format: 'markdown' | 'prompt') => {
|
|
769
|
+
if (!editingPatternId) return;
|
|
770
|
+
try {
|
|
771
|
+
const res = await fetch(
|
|
772
|
+
handoffApiUrl(`/api/handoff/patterns/${encodeURIComponent(editingPatternId)}/manifest?format=${format}`),
|
|
773
|
+
{ credentials: 'include' }
|
|
774
|
+
);
|
|
775
|
+
if (!res.ok) throw new Error('Could not build the export.');
|
|
776
|
+
const text = await res.text();
|
|
777
|
+
|
|
778
|
+
if (format === 'prompt') {
|
|
779
|
+
await navigator.clipboard.writeText(text);
|
|
780
|
+
setTemplateNotice('Prompt copied — paste it into an agent that has your CMS connected.');
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
const url = URL.createObjectURL(new Blob([text], { type: 'text/markdown' }));
|
|
785
|
+
const a = document.createElement('a');
|
|
786
|
+
a.href = url;
|
|
787
|
+
a.download = `${editingPatternId}-content.md`;
|
|
788
|
+
a.click();
|
|
789
|
+
URL.revokeObjectURL(url);
|
|
790
|
+
} catch (e) {
|
|
791
|
+
setTemplateNotice(e instanceof Error ? e.message : 'Could not build the export.');
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
[editingPatternId]
|
|
795
|
+
);
|
|
796
|
+
|
|
797
|
+
if (loading || error) {
|
|
798
|
+
const filler = error ? (
|
|
799
|
+
<div className="text-center">
|
|
800
|
+
<p className="mb-4 text-sm text-destructive">{error}</p>
|
|
801
|
+
<Button onClick={() => window.location.reload()} size="sm">
|
|
802
|
+
Try Again
|
|
803
|
+
</Button>
|
|
804
|
+
</div>
|
|
805
|
+
) : (
|
|
806
|
+
<div className="text-center">
|
|
807
|
+
<div className="mx-auto h-8 w-8 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-primary"></div>
|
|
808
|
+
<p className="mt-3 text-sm text-muted-foreground">Loading components…</p>
|
|
809
|
+
</div>
|
|
810
|
+
);
|
|
811
|
+
|
|
812
|
+
if (!leftPanel) {
|
|
813
|
+
return <div className="flex h-full items-center justify-center">{filler}</div>;
|
|
814
|
+
}
|
|
815
|
+
return (
|
|
816
|
+
<div className="flex h-full min-h-0">
|
|
817
|
+
{/**
|
|
818
|
+
* Wider than the page-level rail — brief and build level (the maintainer, QA).
|
|
819
|
+
*
|
|
820
|
+
* Those levels have no right-hand panel at all, so the extra 60px comes out of empty space rather than out
|
|
821
|
+
* of the canvas, and it is the panel people actually *work* in: findings, a note, a decision.
|
|
822
|
+
*/}
|
|
823
|
+
{leftPanelOpen && (
|
|
824
|
+
<div className="flex w-[360px] shrink-0 flex-col border-r bg-background">{leftPanel}</div>
|
|
825
|
+
)}
|
|
826
|
+
<div className="flex flex-1 items-center justify-center">{filler}</div>
|
|
827
|
+
</div>
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
const handleDownload = async () => {
|
|
832
|
+
const downloadHtml = await constructComponentPreview(selectedComponents, basePath, { injectBlockControls: false });
|
|
833
|
+
const blob = new Blob([downloadHtml], { type: 'text/html' });
|
|
834
|
+
const url = URL.createObjectURL(blob);
|
|
835
|
+
const a = document.createElement('a');
|
|
836
|
+
a.href = url;
|
|
837
|
+
a.download = 'page.html';
|
|
838
|
+
a.click();
|
|
839
|
+
URL.revokeObjectURL(url);
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
const handleDownloadPage = () => {
|
|
843
|
+
const pageExport = buildHandoffPageExport(selectedComponents);
|
|
844
|
+
const blob = new Blob([JSON.stringify(pageExport, null, 2)], { type: 'application/json' });
|
|
845
|
+
const url = URL.createObjectURL(blob);
|
|
846
|
+
const a = document.createElement('a');
|
|
847
|
+
a.href = url;
|
|
848
|
+
a.download = 'playground-page.json';
|
|
849
|
+
a.click();
|
|
850
|
+
URL.revokeObjectURL(url);
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Share this page as a template (reflow R.2).
|
|
855
|
+
*
|
|
856
|
+
* Replaces the three-step invite wizard, which existed because sharing used to produce a *brief* — an object
|
|
857
|
+
* with a name, a version and a life of its own. Sharing now points a link at the template itself, so the
|
|
858
|
+
* screen asks only what the link needs.
|
|
859
|
+
*/
|
|
860
|
+
if (wizardOpen && editingPatternId) {
|
|
861
|
+
return (
|
|
862
|
+
<ShareTemplate
|
|
863
|
+
templateId={editingPatternId}
|
|
864
|
+
pageTitle={pageTitle}
|
|
865
|
+
onCancel={() => setWizardOpen(false)}
|
|
866
|
+
/>
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
return (
|
|
871
|
+
<div className="flex h-full flex-col">
|
|
872
|
+
{/* ── Top Toolbar ── */}
|
|
873
|
+
<div className="relative flex h-12 shrink-0 items-center border-b bg-background px-2">
|
|
874
|
+
{/* Left group */}
|
|
875
|
+
<div className="flex items-center gap-1">
|
|
876
|
+
<Tooltip>
|
|
877
|
+
<TooltipTrigger asChild>
|
|
878
|
+
<Button variant="ghost" size="sm" className="h-8 w-8 p-0" onClick={() => setLeftPanelOpen(!leftPanelOpen)}>
|
|
879
|
+
<PanelLeft className={cn('h-4 w-4 transition-colors', leftPanelOpen && 'text-primary')} />
|
|
880
|
+
</Button>
|
|
881
|
+
</TooltipTrigger>
|
|
882
|
+
<TooltipContent side="bottom">{leftPanelOpen ? 'Hide blocks' : 'Show blocks'}</TooltipContent>
|
|
883
|
+
</Tooltip>
|
|
884
|
+
|
|
885
|
+
<div className="mx-1 h-4 w-px bg-border" />
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
{isDynamicApp && (
|
|
889
|
+
<>
|
|
890
|
+
{/* No "open a page" control: pages are opened from /library, which is their home, and each
|
|
891
|
+
one has a real URL (roadmap E.2c). One place to browse, not two. */}
|
|
892
|
+
{/**
|
|
893
|
+
* No "save page" here any more: in dynamic mode the page autosaves and creates itself on the
|
|
894
|
+
* first block (roadmap E.2/E.3). What remains is the action that actually needs a decision —
|
|
895
|
+
* turning this page into a template others can build from.
|
|
896
|
+
*/}
|
|
897
|
+
{/* Visibility + lifecycle, where the page is. Replaces the old read-only "Share" link control:
|
|
898
|
+
handing a page to someone is "Invite to build", and who may see it is this. */}
|
|
899
|
+
{editingPatternId && <MetaControl resourceType="pattern" resourceId={editingPatternId} basePath={basePath} />}
|
|
900
|
+
{/**
|
|
901
|
+
* Where this page came from, for a page that came from somewhere (the maintainer, 2026-08-13).
|
|
902
|
+
*
|
|
903
|
+
* The R.4 provenance panel is only reachable by opening a page *through its template*; opened
|
|
904
|
+
* from the library — the ordinary way — a guest's page looked like any other. Renders nothing
|
|
905
|
+
* when there is no provenance, which is most pages.
|
|
906
|
+
*/}
|
|
907
|
+
{editingPatternId && <PageOrigin pageId={editingPatternId} basePath={basePath} />}
|
|
908
|
+
|
|
909
|
+
{/* The work coming back, reachable from the page rather than only through a brief (E.8). */}
|
|
910
|
+
{onShowBuilds && buildCount > 0 && (
|
|
911
|
+
<Tooltip>
|
|
912
|
+
<TooltipTrigger asChild>
|
|
913
|
+
<Button variant="ghost" size="sm" className="h-8 gap-1 px-2" onClick={onShowBuilds}>
|
|
914
|
+
<Layers className="h-4 w-4" />
|
|
915
|
+
{/* "Build" is gone as a product word — there are pages and templates (the maintainer, 2026-08-13). */}
|
|
916
|
+
<span className="text-xs">Pages</span>
|
|
917
|
+
<span className="rounded-full bg-muted px-1.5 text-xs tabular-nums">{buildCount}</span>
|
|
918
|
+
</Button>
|
|
919
|
+
</TooltipTrigger>
|
|
920
|
+
<TooltipContent side="bottom">Pages people made from this template</TooltipContent>
|
|
921
|
+
</Tooltip>
|
|
922
|
+
)}
|
|
923
|
+
|
|
924
|
+
{/**
|
|
925
|
+
* What the checks found, on the page itself (the maintainer, 2026-08-13).
|
|
926
|
+
*
|
|
927
|
+
* Shown whenever there is a saved page, **including when the count is zero** — "we checked and
|
|
928
|
+
* found nothing" is the answer to "did this run at all?", and hiding the control at zero is
|
|
929
|
+
* exactly what made the checks look like they had been removed.
|
|
930
|
+
*/}
|
|
931
|
+
{onShowChecks && editingPatternId && (
|
|
932
|
+
<Tooltip>
|
|
933
|
+
<TooltipTrigger asChild>
|
|
934
|
+
<Button variant="ghost" size="sm" className="h-8 gap-1 px-2" onClick={onShowChecks}>
|
|
935
|
+
<ShieldCheck className="h-4 w-4" />
|
|
936
|
+
<span className="text-xs">Checks</span>
|
|
937
|
+
{checkCount > 0 ? (
|
|
938
|
+
<span className="rounded-full bg-muted px-1.5 text-xs tabular-nums">{checkCount}</span>
|
|
939
|
+
) : null}
|
|
940
|
+
</Button>
|
|
941
|
+
</TooltipTrigger>
|
|
942
|
+
<TooltipContent side="bottom">Accessibility, SEO and content checks on this page</TooltipContent>
|
|
943
|
+
</Tooltip>
|
|
944
|
+
)}
|
|
945
|
+
|
|
946
|
+
{selectedComponents.length > 0 && editingPatternId && (
|
|
947
|
+
<div className="flex items-center">
|
|
948
|
+
<Tooltip>
|
|
949
|
+
<TooltipTrigger asChild>
|
|
950
|
+
<Button
|
|
951
|
+
variant="ghost"
|
|
952
|
+
size="sm"
|
|
953
|
+
className="h-8 gap-1 px-2"
|
|
954
|
+
onClick={() => setWizardOpen(true)}
|
|
955
|
+
>
|
|
956
|
+
<UserPlus className="h-4 w-4" />
|
|
957
|
+
{/* The act is sharing a template, not issuing an invitation — "invite" implied a named
|
|
958
|
+
person and an object with a life of its own, and it is neither (reflow R.2). */}
|
|
959
|
+
<span className="text-xs">Share</span>
|
|
960
|
+
</Button>
|
|
961
|
+
</TooltipTrigger>
|
|
962
|
+
<TooltipContent side="bottom">
|
|
963
|
+
Give people a link to build their own page from this one. Yours stays yours.
|
|
964
|
+
</TooltipContent>
|
|
965
|
+
</Tooltip>
|
|
966
|
+
|
|
967
|
+
</div>
|
|
968
|
+
)}
|
|
969
|
+
</>
|
|
970
|
+
)}
|
|
971
|
+
|
|
972
|
+
{selectedComponents.length > 0 && (
|
|
973
|
+
<>
|
|
974
|
+
|
|
975
|
+
<DropdownMenu>
|
|
976
|
+
<Tooltip>
|
|
977
|
+
<TooltipTrigger asChild>
|
|
978
|
+
<DropdownMenuTrigger asChild>
|
|
979
|
+
<Button variant="ghost" size="sm" className="h-8 gap-1 px-2">
|
|
980
|
+
<FileCodeIcon className="h-4 w-4" />
|
|
981
|
+
<ChevronDown className="h-3 w-3" />
|
|
982
|
+
</Button>
|
|
983
|
+
</DropdownMenuTrigger>
|
|
984
|
+
</TooltipTrigger>
|
|
985
|
+
<TooltipContent side="bottom">Export</TooltipContent>
|
|
986
|
+
</Tooltip>
|
|
987
|
+
<DropdownMenuContent align="start">
|
|
988
|
+
<DropdownMenuItem onClick={handleDownload}>Download as HTML</DropdownMenuItem>
|
|
989
|
+
<DropdownMenuItem onClick={handleDownloadPage}>Download as Handoff page</DropdownMenuItem>
|
|
990
|
+
{/**
|
|
991
|
+
* The content of this page, as words (reflow R.6).
|
|
992
|
+
*
|
|
993
|
+
* Two exports off one artifact: a **manifest** for whoever has to read every string on the
|
|
994
|
+
* page without clicking through a canvas, and a **prompt** for an agent holding a CMS's MCP.
|
|
995
|
+
* Both need a saved page — there is no id to export before the first save.
|
|
996
|
+
*/}
|
|
997
|
+
{editingPatternId ? (
|
|
998
|
+
<>
|
|
999
|
+
<DropdownMenuItem onClick={() => void exportContent('markdown')}>
|
|
1000
|
+
Download content manifest
|
|
1001
|
+
</DropdownMenuItem>
|
|
1002
|
+
<DropdownMenuItem onClick={() => void exportContent('prompt')}>
|
|
1003
|
+
Copy “move to CMS” prompt
|
|
1004
|
+
</DropdownMenuItem>
|
|
1005
|
+
{/**
|
|
1006
|
+
* The third destination, and the only one that writes rather than hands over a file.
|
|
1007
|
+
*
|
|
1008
|
+
* It sits with the two content exports because it answers the same question they do —
|
|
1009
|
+
* "where does this page go next?" — and the manifest and the prompt are the two answers
|
|
1010
|
+
* for a CMS nobody has connected yet. Same gate as those: no saved page, no id to
|
|
1011
|
+
* publish, and nothing here to offer.
|
|
1012
|
+
*/}
|
|
1013
|
+
<DropdownMenuItem onClick={() => setPublishOpen(true)}>
|
|
1014
|
+
Publish to Sanity…
|
|
1015
|
+
</DropdownMenuItem>
|
|
1016
|
+
</>
|
|
1017
|
+
) : null}
|
|
1018
|
+
</DropdownMenuContent>
|
|
1019
|
+
</DropdownMenu>
|
|
1020
|
+
</>
|
|
1021
|
+
)}
|
|
1022
|
+
|
|
1023
|
+
</div>
|
|
1024
|
+
|
|
1025
|
+
{/* Center group — the document's name: what the thing IS, front and center. */}
|
|
1026
|
+
<div className="absolute left-1/2 flex -translate-x-1/2 items-center">{isDynamicApp && <PageTitle />}</div>
|
|
1027
|
+
|
|
1028
|
+
{/* Right group */}
|
|
1029
|
+
<div className="ml-auto flex items-center gap-1">
|
|
1030
|
+
{/* Autosave state for a page that has a record. Silent for a brand-new canvas, which has
|
|
1031
|
+
nothing to autosave to yet. Sits left of the viewport controls. */}
|
|
1032
|
+
{saveState !== 'off' ? (
|
|
1033
|
+
<span
|
|
1034
|
+
aria-live="polite"
|
|
1035
|
+
className={`mr-2 text-xs ${saveState === 'failed' ? 'text-amber-700 dark:text-amber-400' : 'text-muted-foreground'}`}
|
|
1036
|
+
>
|
|
1037
|
+
{saveState === 'saving' ? 'Saving…' : saveState === 'saved' ? 'Saved' : saveState === 'failed' ? 'Not saved' : 'Unsaved changes'}
|
|
1038
|
+
</span>
|
|
1039
|
+
) : null}
|
|
1040
|
+
|
|
1041
|
+
{/* Viewport + scale controls, far right */}
|
|
1042
|
+
<div className="flex items-center rounded-lg border bg-muted/50 p-0.5">
|
|
1043
|
+
{(Object.entries(VIEWPORTS) as [ViewportKey, (typeof VIEWPORTS)[ViewportKey]][]).map(([key, { icon: Icon, label }]) => (
|
|
1044
|
+
<Tooltip key={key}>
|
|
1045
|
+
<TooltipTrigger asChild>
|
|
1046
|
+
<button
|
|
1047
|
+
onClick={() => setViewport(key)}
|
|
1048
|
+
className={cn(
|
|
1049
|
+
'rounded-md px-3 py-1.5 transition-colors',
|
|
1050
|
+
viewport === key
|
|
1051
|
+
? 'bg-background text-foreground shadow-sm'
|
|
1052
|
+
: 'text-muted-foreground hover:text-foreground'
|
|
1053
|
+
)}
|
|
1054
|
+
>
|
|
1055
|
+
<Icon className="h-4 w-4" />
|
|
1056
|
+
</button>
|
|
1057
|
+
</TooltipTrigger>
|
|
1058
|
+
<TooltipContent side="bottom">{label}</TooltipContent>
|
|
1059
|
+
</Tooltip>
|
|
1060
|
+
))}
|
|
1061
|
+
<div className="mx-0.5 h-4 w-px bg-border" />
|
|
1062
|
+
<Tooltip>
|
|
1063
|
+
<TooltipTrigger asChild>
|
|
1064
|
+
<button
|
|
1065
|
+
onClick={() => setCanvasScale((s) => (s === 1 ? 0.7 : 1))}
|
|
1066
|
+
className={cn(
|
|
1067
|
+
'rounded-md px-2 py-1.5 text-xs font-medium tabular-nums transition-colors',
|
|
1068
|
+
canvasScale !== 1
|
|
1069
|
+
? 'bg-background text-foreground shadow-sm'
|
|
1070
|
+
: 'text-muted-foreground hover:text-foreground'
|
|
1071
|
+
)}
|
|
1072
|
+
>
|
|
1073
|
+
{Math.round(canvasScale * 100)}%
|
|
1074
|
+
</button>
|
|
1075
|
+
</TooltipTrigger>
|
|
1076
|
+
<TooltipContent side="bottom">{canvasScale === 1 ? 'Scale canvas to 70%' : 'Back to 100%'}</TooltipContent>
|
|
1077
|
+
</Tooltip>
|
|
1078
|
+
</div>
|
|
1079
|
+
</div>
|
|
1080
|
+
|
|
1081
|
+
</div>
|
|
1082
|
+
|
|
1083
|
+
{templateNotice ? (
|
|
1084
|
+
<div className="flex items-center gap-3 border-b bg-muted/40 px-4 py-2 text-sm">
|
|
1085
|
+
<span>{templateNotice}</span>
|
|
1086
|
+
<Button size="sm" variant="ghost" onClick={() => setTemplateNotice(null)}>
|
|
1087
|
+
Dismiss
|
|
1088
|
+
</Button>
|
|
1089
|
+
</div>
|
|
1090
|
+
) : null}
|
|
1091
|
+
|
|
1092
|
+
{/* Mounted only while open, so closing it forgets the form and the last publish's result. */}
|
|
1093
|
+
{publishOpen && editingPatternId ? (
|
|
1094
|
+
<PublishToSanityDialog
|
|
1095
|
+
pageId={editingPatternId}
|
|
1096
|
+
open={publishOpen}
|
|
1097
|
+
onOpenChange={setPublishOpen}
|
|
1098
|
+
integrationsHref={`${basePath}/account/integrations`}
|
|
1099
|
+
/>
|
|
1100
|
+
) : null}
|
|
1101
|
+
|
|
1102
|
+
{/* ── Main content area ── */}
|
|
1103
|
+
<div className="flex flex-1 overflow-hidden">
|
|
1104
|
+
{/* ── Left Panel — Blocks, or the editor for one block ── */}
|
|
1105
|
+
{leftPanelOpen && (
|
|
1106
|
+
<div className="flex w-[300px] shrink-0 flex-col border-r bg-background">
|
|
1107
|
+
{leftPanel ? (
|
|
1108
|
+
leftPanel
|
|
1109
|
+
) : activeComponent ? (
|
|
1110
|
+
<FieldLinkProvider value={fieldLink}>
|
|
1111
|
+
<EditContextProvider
|
|
1112
|
+
key={activeComponent.uniqueId}
|
|
1113
|
+
component={activeComponent}
|
|
1114
|
+
onCommit={updateComponent}
|
|
1115
|
+
targetIframeRef={canvasIframeRef}
|
|
1116
|
+
contentOnly={contentOnly}
|
|
1117
|
+
>
|
|
1118
|
+
<BlockEditorPanel onDone={() => setActiveComponentId(null)} />
|
|
1119
|
+
<MediaBrowser />
|
|
1120
|
+
</EditContextProvider>
|
|
1121
|
+
</FieldLinkProvider>
|
|
1122
|
+
) : (
|
|
1123
|
+
<>
|
|
1124
|
+
<PanelHeader title="Blocks" />
|
|
1125
|
+
|
|
1126
|
+
<div className="flex-1 overflow-y-auto p-2">
|
|
1127
|
+
{selectedComponents.length === 0 && !structuralEditing ? (
|
|
1128
|
+
<p className="px-4 py-10 text-center text-sm text-muted-foreground">
|
|
1129
|
+
This page has no blocks yet.
|
|
1130
|
+
</p>
|
|
1131
|
+
) : selectedComponents.length === 0 ? (
|
|
1132
|
+
<div className="flex flex-1 items-center justify-center px-4">
|
|
1133
|
+
<ComponentLibrary
|
|
1134
|
+
trigger={
|
|
1135
|
+
<button className="flex w-full flex-col items-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/20 px-4 py-10 text-center transition-colors hover:border-primary/30 hover:bg-muted/30">
|
|
1136
|
+
<div className="rounded-full bg-muted p-3">
|
|
1137
|
+
<Plus className="h-6 w-6 text-muted-foreground/50" />
|
|
1138
|
+
</div>
|
|
1139
|
+
<div>
|
|
1140
|
+
<p className="text-sm font-medium text-muted-foreground">Add your first block</p>
|
|
1141
|
+
<p className="mt-1 text-xs text-muted-foreground/70">Browse the component library</p>
|
|
1142
|
+
</div>
|
|
1143
|
+
</button>
|
|
1144
|
+
}
|
|
1145
|
+
/>
|
|
1146
|
+
</div>
|
|
1147
|
+
) : (
|
|
1148
|
+
/**
|
|
1149
|
+
* Same rail either way, minus the drag context and the remove control when the structure is
|
|
1150
|
+
* fixed. Wrapping in DndContext but ignoring drops would still show grab cursors and drag
|
|
1151
|
+
* shadows for something that cannot happen.
|
|
1152
|
+
*/
|
|
1153
|
+
(structuralEditing ? (
|
|
1154
|
+
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={onDragEnd}>
|
|
1155
|
+
<SortableContext items={selectedComponents.map((c) => c.uniqueId)} strategy={verticalListSortingStrategy}>
|
|
1156
|
+
<div className="space-y-0.5">
|
|
1157
|
+
{selectedComponents.map((component) => (
|
|
1158
|
+
<SortableItem
|
|
1159
|
+
key={component.uniqueId}
|
|
1160
|
+
component={component}
|
|
1161
|
+
isActive={component.uniqueId === activeComponentId}
|
|
1162
|
+
isSelected={component.uniqueId === selectedBlockId}
|
|
1163
|
+
isHovered={component.uniqueId === hoveredBlockId}
|
|
1164
|
+
// Row click SELECTS (highlights here and on the canvas, scopes the chat) —
|
|
1165
|
+
// the same toggle a canvas click does. The pencil is what opens the editor.
|
|
1166
|
+
onClick={() => setSelectedBlockId((prev) =>
|
|
1167
|
+
prev === component.uniqueId ? null : component.uniqueId
|
|
1168
|
+
)}
|
|
1169
|
+
onEdit={(id) => setActiveComponentId(id)}
|
|
1170
|
+
onRemove={removeComponent}
|
|
1171
|
+
onHover={hoverBlockFromRail}
|
|
1172
|
+
/>
|
|
1173
|
+
))}
|
|
1174
|
+
</div>
|
|
1175
|
+
</SortableContext>
|
|
1176
|
+
</DndContext>
|
|
1177
|
+
) : (
|
|
1178
|
+
<div className="space-y-0.5">
|
|
1179
|
+
{selectedComponents.map((component) => (
|
|
1180
|
+
<button
|
|
1181
|
+
key={component.uniqueId}
|
|
1182
|
+
type="button"
|
|
1183
|
+
onClick={() => setActiveComponentId(
|
|
1184
|
+
component.uniqueId === activeComponentId ? null : component.uniqueId
|
|
1185
|
+
)}
|
|
1186
|
+
className={cn(
|
|
1187
|
+
'flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm',
|
|
1188
|
+
component.uniqueId === selectedBlockId
|
|
1189
|
+
? 'bg-blue-600 text-white'
|
|
1190
|
+
: component.uniqueId === activeComponentId
|
|
1191
|
+
? 'bg-muted font-medium'
|
|
1192
|
+
: cn('hover:bg-muted/50', component.uniqueId === hoveredBlockId && 'bg-muted/50')
|
|
1193
|
+
)}
|
|
1194
|
+
onMouseEnter={() => hoverBlockFromRail(component.uniqueId)}
|
|
1195
|
+
onMouseLeave={() => hoverBlockFromRail(null)}
|
|
1196
|
+
>
|
|
1197
|
+
<span className="truncate">{component.title}</span>
|
|
1198
|
+
</button>
|
|
1199
|
+
))}
|
|
1200
|
+
</div>
|
|
1201
|
+
))
|
|
1202
|
+
)}
|
|
1203
|
+
</div>
|
|
1204
|
+
|
|
1205
|
+
{structuralEditing ? (
|
|
1206
|
+
<div className="border-t p-3">
|
|
1207
|
+
<ComponentLibrary
|
|
1208
|
+
trigger={
|
|
1209
|
+
<Button variant="outline" size="sm" className="w-full gap-2 border-dashed">
|
|
1210
|
+
<Plus className="h-4 w-4" />
|
|
1211
|
+
Add Block
|
|
1212
|
+
</Button>
|
|
1213
|
+
}
|
|
1214
|
+
/>
|
|
1215
|
+
</div>
|
|
1216
|
+
) : null}
|
|
1217
|
+
</>
|
|
1218
|
+
)}
|
|
1219
|
+
</div>
|
|
1220
|
+
)}
|
|
1221
|
+
|
|
1222
|
+
{/* ── Center — Preview Canvas ── */}
|
|
1223
|
+
<div className="flex flex-1 flex-col overflow-hidden bg-background">
|
|
1224
|
+
{/* The canvas keeps its size at every viewport; device emulation narrows the frame inside
|
|
1225
|
+
<Preview> instead, so the scroll area under the reader never jumps. */}
|
|
1226
|
+
<div className="flex flex-1 overflow-auto">
|
|
1227
|
+
<div className="h-full w-full">
|
|
1228
|
+
{/* Spinner only before the FIRST document exists. Swapping the mounted <Preview> for a
|
|
1229
|
+
spinner on every rebuild threw away its measured height and scroll state, so each
|
|
1230
|
+
reorder remounted a full-height card that then snapped back down — the old canvas
|
|
1231
|
+
stays up until the new document replaces it atomically. */}
|
|
1232
|
+
{loadingHtml && !html ? (
|
|
1233
|
+
<div className="flex h-full items-center justify-center">
|
|
1234
|
+
<div className="h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-primary"></div>
|
|
1235
|
+
</div>
|
|
1236
|
+
) : selectedComponents.length === 0 ? (
|
|
1237
|
+
/**
|
|
1238
|
+
* A muted placeholder rather than the blank white document an empty preview renders as — which
|
|
1239
|
+
* read as a broken canvas in dark mode. Keyed on the blocks, not on `html`:
|
|
1240
|
+
* `constructComponentPreview([])` returns a complete-but-empty document, so `html` is always
|
|
1241
|
+
* truthy. The iframe's *contents* keep their own theme once there is something to show; this is
|
|
1242
|
+
* only what fills the space when there is not.
|
|
1243
|
+
*/
|
|
1244
|
+
<div className="flex h-full items-center justify-center bg-muted/30 p-8">
|
|
1245
|
+
<p className="max-w-sm text-center text-sm text-muted-foreground">
|
|
1246
|
+
{structuralEditing
|
|
1247
|
+
? 'Add a block to see it here.'
|
|
1248
|
+
: 'Nothing to preview yet — this page has no blocks.'}
|
|
1249
|
+
</p>
|
|
1250
|
+
</div>
|
|
1251
|
+
) : (
|
|
1252
|
+
<Preview
|
|
1253
|
+
html={html}
|
|
1254
|
+
className="h-full"
|
|
1255
|
+
iframeRef={canvasIframeRef}
|
|
1256
|
+
scrollHost
|
|
1257
|
+
frameWidth={VIEWPORTS[viewport].width}
|
|
1258
|
+
frameScale={canvasScale}
|
|
1259
|
+
onBackdropClick={() => setSelectedBlockId(null)}
|
|
1260
|
+
/>
|
|
1261
|
+
)}
|
|
1262
|
+
</div>
|
|
1263
|
+
</div>
|
|
1264
|
+
</div>
|
|
1265
|
+
|
|
1266
|
+
{aiAssistantEnabled && <AiChatPanel />}
|
|
1267
|
+
</div>
|
|
1268
|
+
|
|
1269
|
+
</div>
|
|
1270
|
+
);
|
|
1271
|
+
}
|