@agent-native/core 0.92.7 → 0.92.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/docs/content/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/ar-SA/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/ar-SA/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/ar-SA/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/de-DE/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/de-DE/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/de-DE/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/es-ES/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/es-ES/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/es-ES/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/fr-FR/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/fr-FR/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/fr-FR/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/hi-IN/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/hi-IN/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/hi-IN/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/ja-JP/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/ja-JP/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/ja-JP/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/ko-KR/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/ko-KR/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/ko-KR/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/pt-BR/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/pt-BR/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/pt-BR/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/zh-CN/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/zh-CN/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/zh-CN/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/locales/zh-TW/a2a-protocol.mdx +12 -0
- package/corpus/core/docs/content/locales/zh-TW/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/locales/zh-TW/pure-agent-apps.mdx +4 -0
- package/corpus/core/docs/content/pr-visual-recap.mdx +3 -3
- package/corpus/core/docs/content/pure-agent-apps.mdx +22 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/engine/builtin.ts +1 -1
- package/corpus/core/src/agent/model-config.ts +30 -30
- package/corpus/core/src/agent/production-agent.ts +129 -7
- package/corpus/core/src/cli/design-connect.ts +438 -83
- package/corpus/core/src/cli/recap.ts +2 -2
- package/corpus/core/src/client/AgentPanel.tsx +8 -1
- package/corpus/core/src/client/agent-chat-adapter.ts +12 -7
- package/corpus/core/src/client/composer/TiptapComposer.tsx +1 -1
- package/corpus/core/src/client/index.ts +4 -0
- package/corpus/core/src/client/org/TeamPage.tsx +41 -26
- package/corpus/core/src/client/use-action.ts +113 -1
- package/corpus/core/src/db/client.ts +12 -2
- package/corpus/core/src/db/create-get-db.ts +4 -1
- package/corpus/core/src/scripts/agent-engines/manage-agent-engine.ts +1 -1
- package/corpus/core/src/scripts/agent-engines/set-agent-engine.ts +1 -1
- package/corpus/core/src/server/transcribe-voice.ts +1 -1
- package/corpus/core/src/usage/store.ts +13 -4
- package/corpus/core/src/vite/client.ts +38 -1
- package/corpus/templates/analytics/AGENTS.md +3 -0
- package/corpus/templates/analytics/actions/get-data-program.ts +78 -0
- package/corpus/templates/analytics/actions/list-data-programs.ts +49 -0
- package/corpus/templates/analytics/app/global.css +11 -0
- package/corpus/templates/analytics/app/hooks/use-dashboard-chat-context.ts +163 -17
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/analytics/app/i18n-data.ts +20 -0
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/ChartCard.tsx +96 -3
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +3 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +61 -4
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +40 -2
- package/corpus/templates/analytics/changelog/2026-07-09-analytics-no-longer-forgets-successful-data-queries-when-a-l.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-dashboard-charts-keep-consistent-spacing-when-they-stack-ver.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-dashboard-charts-tables-and-extensions-can-be-selected-and-d.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-long-running-analytics-requests-now-recover-automatically-wh.md +6 -0
- package/corpus/templates/analytics/server/db/index.ts +6 -0
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +1 -7
- package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +102 -15
- package/corpus/templates/content/app/hooks/use-content-database.ts +52 -0
- package/corpus/templates/content/app/hooks/use-document-properties.ts +50 -6
- package/corpus/templates/content/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/content/app/i18n-data.ts +28 -0
- package/corpus/templates/content/changelog/2026-07-09-notion-conflict-warnings-no-longer-flash-during-normal-synce.md +6 -0
- package/corpus/templates/content/changelog/2026-07-09-property-menus-and-delete-confirmations-now-open-visibly-and.md +6 -0
- package/corpus/templates/content/server/lib/notion-sync.ts +130 -28
- package/corpus/templates/design/actions/add-breakpoint.ts +48 -68
- package/corpus/templates/design/actions/add-localhost-screens.ts +496 -61
- package/corpus/templates/design/actions/apply-component-prop-edit.ts +2 -18
- package/corpus/templates/design/actions/apply-design-token-edit.ts +51 -82
- package/corpus/templates/design/actions/apply-tweaks.ts +63 -41
- package/corpus/templates/design/actions/capture-design-state.ts +2 -2
- package/corpus/templates/design/actions/connect-localhost.ts +58 -12
- package/corpus/templates/design/actions/create-component.ts +2 -18
- package/corpus/templates/design/actions/create-design-branch.ts +38 -18
- package/corpus/templates/design/actions/create-fusion-app.ts +15 -11
- package/corpus/templates/design/actions/delete-file.ts +19 -34
- package/corpus/templates/design/actions/deploy-design-preview.ts +59 -27
- package/corpus/templates/design/actions/deploy-fusion-app.ts +22 -15
- package/corpus/templates/design/actions/export-pdf.ts +2 -1
- package/corpus/templates/design/actions/export-zip.ts +9 -3
- package/corpus/templates/design/actions/generate-design.ts +107 -70
- package/corpus/templates/design/actions/get-component-details.ts +2 -18
- package/corpus/templates/design/actions/get-design-branch-diff.ts +2 -3
- package/corpus/templates/design/actions/get-design-surface-index.ts +2 -18
- package/corpus/templates/design/actions/get-design.ts +2 -1
- package/corpus/templates/design/actions/grant-localhost-write-consent.ts +7 -1
- package/corpus/templates/design/actions/import-design-tokens.ts +114 -76
- package/corpus/templates/design/actions/index-components.ts +2 -18
- package/corpus/templates/design/actions/list-design-source-capabilities.ts +23 -28
- package/corpus/templates/design/actions/list-local-files.ts +9 -2
- package/corpus/templates/design/actions/migrate-board-objects-to-file.ts +82 -98
- package/corpus/templates/design/actions/open-component-source.ts +2 -18
- package/corpus/templates/design/actions/open-visual-edit.ts +19 -1
- package/corpus/templates/design/actions/present-design-variants.ts +70 -70
- package/corpus/templates/design/actions/preview-component-prop-edit.ts +4 -14
- package/corpus/templates/design/actions/read-local-file.ts +9 -2
- package/corpus/templates/design/actions/remove-breakpoint.ts +40 -61
- package/corpus/templates/design/actions/rename-screen.ts +425 -0
- package/corpus/templates/design/actions/request-localhost-write-consent.ts +12 -2
- package/corpus/templates/design/actions/revoke-localhost-write-consent.ts +9 -2
- package/corpus/templates/design/actions/sync-fusion-app.ts +56 -39
- package/corpus/templates/design/actions/update-design.ts +376 -61
- package/corpus/templates/design/actions/update-file.ts +455 -188
- package/corpus/templates/design/actions/write-local-file.ts +10 -2
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +685 -608
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +43 -15
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +576 -2015
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +62 -14
- package/corpus/templates/design/app/components/design/bridge/embedded-wheel.bridge.ts +263 -25
- package/corpus/templates/design/app/components/design/design-canvas/annotation-submit.ts +34 -0
- package/corpus/templates/design/app/components/design/design-canvas/coordinate-transforms.ts +40 -0
- package/corpus/templates/design/app/components/design/design-canvas/creation.ts +47 -0
- package/corpus/templates/design/app/components/design/design-canvas/element-payload.ts +27 -0
- package/corpus/templates/design/app/components/design/design-canvas/embedded-frame.ts +62 -0
- package/corpus/templates/design/app/components/design/design-canvas/external-preview.ts +137 -0
- package/corpus/templates/design/app/components/design/design-canvas/file-drop.ts +10 -0
- package/corpus/templates/design/app/components/design/design-canvas/hit-test.ts +23 -0
- package/corpus/templates/design/app/components/design/design-canvas/iframe-events.ts +23 -0
- package/corpus/templates/design/app/components/design/design-canvas/iframe-pan.ts +177 -0
- package/corpus/templates/design/app/components/design/design-canvas/motion-types.ts +7 -0
- package/corpus/templates/design/app/components/design/design-canvas/pending-text-edit.ts +62 -0
- package/corpus/templates/design/app/components/design/index.ts +2 -2
- package/corpus/templates/design/app/components/design/multi-screen/canvas-tools.ts +100 -0
- package/corpus/templates/design/app/components/design/multi-screen/coordinate-transforms.ts +81 -0
- package/corpus/templates/design/app/components/design/multi-screen/cross-screen-drop.ts +23 -13
- package/corpus/templates/design/app/components/design/multi-screen/culling.ts +238 -19
- package/corpus/templates/design/app/components/design/multi-screen/draft-primitives.ts +424 -0
- package/corpus/templates/design/app/components/design/multi-screen/frame-geometry.ts +341 -0
- package/corpus/templates/design/app/components/design/multi-screen/iframe-targeting.ts +52 -0
- package/corpus/templates/design/app/components/design/multi-screen/overview-layout.ts +62 -0
- package/corpus/templates/design/app/components/design/multi-screen/primitive-drop-target.ts +283 -0
- package/corpus/templates/design/app/components/design/multi-screen/screen-content-cache.ts +272 -0
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +5 -1
- package/corpus/templates/design/app/components/design/multi-screen/wheel-gesture-state.ts +12 -0
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +325 -84
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +15 -1
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +119 -47
- package/corpus/templates/design/app/i18n/zh-TW.ts +9 -0
- package/corpus/templates/design/app/i18n-data.ts +223 -0
- package/corpus/templates/design/app/lib/design-save-outbox.ts +379 -0
- package/corpus/templates/design/app/lib/png-clipboard.ts +113 -0
- package/corpus/templates/design/app/pages/design-editor/canvas-primitives.ts +229 -0
- package/corpus/templates/design/app/pages/design-editor/code-layer-state.ts +918 -0
- package/corpus/templates/design/app/pages/design-editor/collab-sync.ts +43 -0
- package/corpus/templates/design/app/pages/design-editor/cross-screen-text-color.ts +336 -0
- package/corpus/templates/design/app/pages/design-editor/data-operations.ts +270 -0
- package/corpus/templates/design/app/pages/design-editor/dom-guards.ts +24 -0
- package/corpus/templates/design/app/pages/design-editor/dom-utils.ts +11 -0
- package/corpus/templates/design/app/pages/design-editor/editor-session.ts +20 -0
- package/corpus/templates/design/app/pages/design-editor/editor-state.ts +408 -0
- package/corpus/templates/design/app/pages/design-editor/export-capture.ts +115 -0
- package/corpus/templates/design/app/pages/design-editor/geometry-persistence.ts +93 -0
- package/corpus/templates/design/app/pages/design-editor/history.ts +169 -0
- package/corpus/templates/design/app/pages/design-editor/layout-operations.ts +185 -0
- package/corpus/templates/design/app/pages/design-editor/motion-state.ts +309 -0
- package/corpus/templates/design/app/pages/design-editor/overview-camera.ts +438 -0
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +510 -0
- package/corpus/templates/design/app/pages/design-editor/portable-style.ts +115 -0
- package/corpus/templates/design/app/pages/design-editor/selection-state.ts +337 -0
- package/corpus/templates/design/app/pages/design-editor/style-utils.ts +5 -0
- package/corpus/templates/design/app/pages/design-editor/tool-state.ts +92 -0
- package/corpus/templates/design/app/pages/design-editor/tweak-save.ts +87 -0
- package/corpus/templates/design/app/pages/design-editor/types.ts +36 -0
- package/corpus/templates/design/app/routes/design.$id.tsx +11 -1
- package/corpus/templates/design/changelog/2026-07-09-design-edits-canvas-positions-tools-and-tab-context-now-pers.md +6 -0
- package/corpus/templates/design/changelog/2026-07-09-figma-style-shortcuts-drawing-annotations-and-cross-screen-d.md +6 -0
- package/corpus/templates/design/changelog/2026-07-09-hand-and-scale-tools-now-keep-their-active-toolbar-identity-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-09-large-multi-screen-designs-now-stay-responsive-during-long-c.md +6 -0
- package/corpus/templates/design/changelog/2026-07-09-layer-drags-now-land-exactly-where-the-insertion-indicator-s.md +6 -0
- package/corpus/templates/design/server/db/index.ts +2 -52
- package/corpus/templates/design/server/db/schema.ts +16 -0
- package/corpus/templates/design/server/lib/design-data-access.ts +70 -0
- package/corpus/templates/design/server/lib/design-data-mutation.ts +249 -0
- package/corpus/templates/design/server/lib/fusion-screens.ts +89 -76
- package/corpus/templates/design/server/lib/import-design-files.ts +76 -35
- package/corpus/templates/design/server/lib/verify-write-grant.ts +7 -2
- package/corpus/templates/design/server/plugins/db.ts +19 -0
- package/corpus/templates/design/server/source-workspace.ts +12 -13
- package/corpus/templates/design/shared/resolve-tweaks.ts +15 -0
- package/corpus/templates/design/shared/screen-rename.ts +42 -0
- package/corpus/templates/design/shared/source-mode.ts +84 -4
- package/dist/agent/engine/builder-engine.d.ts +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builtin.js +1 -1
- package/dist/agent/engine/builtin.js.map +1 -1
- package/dist/agent/model-config.d.ts +9 -9
- package/dist/agent/model-config.d.ts.map +1 -1
- package/dist/agent/model-config.js +30 -30
- package/dist/agent/model-config.js.map +1 -1
- package/dist/agent/production-agent.d.ts +60 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +106 -7
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/design-connect.d.ts +30 -1
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +359 -75
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/recap.js +2 -2
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +6 -1
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +10 -5
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/composer/TiptapComposer.js +1 -1
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +6 -5
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/use-action.d.ts +32 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +68 -1
- package/dist/client/use-action.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.d.ts +3 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +7 -2
- package/dist/db/client.js.map +1 -1
- package/dist/db/create-get-db.d.ts.map +1 -1
- package/dist/db/create-get-db.js +2 -2
- package/dist/db/create-get-db.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/scripts/agent-engines/manage-agent-engine.js +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/transcribe-voice.js +1 -1
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +13 -4
- package/dist/usage/store.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +36 -1
- package/dist/vite/client.js.map +1 -1
- package/docs/content/a2a-protocol.mdx +12 -0
- package/docs/content/locales/ar-SA/a2a-protocol.mdx +12 -0
- package/docs/content/locales/ar-SA/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/ar-SA/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/de-DE/a2a-protocol.mdx +12 -0
- package/docs/content/locales/de-DE/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/de-DE/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/es-ES/a2a-protocol.mdx +12 -0
- package/docs/content/locales/es-ES/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/es-ES/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/fr-FR/a2a-protocol.mdx +12 -0
- package/docs/content/locales/fr-FR/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/fr-FR/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/hi-IN/a2a-protocol.mdx +12 -0
- package/docs/content/locales/hi-IN/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/hi-IN/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/ja-JP/a2a-protocol.mdx +12 -0
- package/docs/content/locales/ja-JP/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/ja-JP/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/ko-KR/a2a-protocol.mdx +12 -0
- package/docs/content/locales/ko-KR/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/ko-KR/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/pt-BR/a2a-protocol.mdx +12 -0
- package/docs/content/locales/pt-BR/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/pt-BR/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/zh-CN/a2a-protocol.mdx +12 -0
- package/docs/content/locales/zh-CN/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/zh-CN/pure-agent-apps.mdx +4 -0
- package/docs/content/locales/zh-TW/a2a-protocol.mdx +12 -0
- package/docs/content/locales/zh-TW/pr-visual-recap.mdx +3 -3
- package/docs/content/locales/zh-TW/pure-agent-apps.mdx +4 -0
- package/docs/content/pr-visual-recap.mdx +3 -3
- package/docs/content/pure-agent-apps.mdx +22 -0
- package/package.json +2 -2
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { DEVICE_FRAME_VIEWPORTS, type DeviceFrameType } from "../types";
|
|
2
|
+
import { SURFACE_PADDING } from "./overview-layout";
|
|
3
|
+
import type { FrameGeometry, FrameGeometryById, Point } from "./types";
|
|
4
|
+
|
|
5
|
+
const SCREEN_WIDTH = 320;
|
|
6
|
+
const SCREEN_GAP = 56;
|
|
7
|
+
const FRAME_LABEL_HEIGHT = 28;
|
|
8
|
+
|
|
9
|
+
export interface BoundsRect {
|
|
10
|
+
left: number;
|
|
11
|
+
top: number;
|
|
12
|
+
right: number;
|
|
13
|
+
bottom: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ScreenViewportSize {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getBreakpointFrameGeometry(args: {
|
|
22
|
+
widthPx: number;
|
|
23
|
+
naturalAspect: number;
|
|
24
|
+
primaryScale: number;
|
|
25
|
+
}): {
|
|
26
|
+
frameWidth: number;
|
|
27
|
+
frameHeight: number;
|
|
28
|
+
naturalHeight: number;
|
|
29
|
+
scale: number;
|
|
30
|
+
} {
|
|
31
|
+
const scale =
|
|
32
|
+
Number.isFinite(args.primaryScale) && args.primaryScale > 0
|
|
33
|
+
? args.primaryScale
|
|
34
|
+
: 1;
|
|
35
|
+
const naturalHeight = Math.round(
|
|
36
|
+
args.widthPx * Math.max(0.01, args.naturalAspect),
|
|
37
|
+
);
|
|
38
|
+
const frameWidth = Math.round(args.widthPx * scale);
|
|
39
|
+
const frameHeight = Math.round(naturalHeight * scale);
|
|
40
|
+
return { frameWidth, frameHeight, naturalHeight, scale };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getInitialFrameGeometry(
|
|
44
|
+
index: number,
|
|
45
|
+
metadata?: ScreenViewportSize,
|
|
46
|
+
): FrameGeometry {
|
|
47
|
+
const column = index % 3;
|
|
48
|
+
const row = Math.floor(index / 3);
|
|
49
|
+
const height = getOverviewFrameHeight(SCREEN_WIDTH, metadata);
|
|
50
|
+
return {
|
|
51
|
+
x: column * (SCREEN_WIDTH + SCREEN_GAP),
|
|
52
|
+
y: row * (height + FRAME_LABEL_HEIGHT + SCREEN_GAP),
|
|
53
|
+
width: SCREEN_WIDTH,
|
|
54
|
+
height,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getOverviewFrameHeight(
|
|
59
|
+
width: number,
|
|
60
|
+
metadata?: ScreenViewportSize,
|
|
61
|
+
) {
|
|
62
|
+
const sourceWidth =
|
|
63
|
+
metadata?.width && metadata.width > 0 ? metadata.width : 1280;
|
|
64
|
+
const sourceHeight =
|
|
65
|
+
metadata?.height && metadata.height > 0 ? metadata.height : 2560;
|
|
66
|
+
return Math.max(80, Math.round((width * sourceHeight) / sourceWidth));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function sameFrameGeometry(a: FrameGeometry, b: FrameGeometry): boolean {
|
|
70
|
+
return (
|
|
71
|
+
a.x === b.x &&
|
|
72
|
+
a.y === b.y &&
|
|
73
|
+
a.width === b.width &&
|
|
74
|
+
a.height === b.height &&
|
|
75
|
+
(a.rotation ?? 0) === (b.rotation ?? 0) &&
|
|
76
|
+
(a.z ?? 0) === (b.z ?? 0)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function resolveFrameGeometrySync(args: {
|
|
81
|
+
screens: ReadonlyArray<{ id: string; metadata?: ScreenViewportSize }>;
|
|
82
|
+
currentGeometryById: FrameGeometryById;
|
|
83
|
+
persistedGeometryById:
|
|
84
|
+
| Record<string, Partial<FrameGeometry> | undefined>
|
|
85
|
+
| undefined;
|
|
86
|
+
}): {
|
|
87
|
+
next: FrameGeometryById;
|
|
88
|
+
changed: boolean;
|
|
89
|
+
shouldNotifyParent: boolean;
|
|
90
|
+
} {
|
|
91
|
+
const { screens, currentGeometryById, persistedGeometryById } = args;
|
|
92
|
+
const currentIds = new Set(screens.map((screen) => screen.id));
|
|
93
|
+
let shouldNotifyParent = Object.keys(currentGeometryById).some(
|
|
94
|
+
(id) => !currentIds.has(id),
|
|
95
|
+
);
|
|
96
|
+
const next: FrameGeometryById = {};
|
|
97
|
+
let changed = shouldNotifyParent;
|
|
98
|
+
|
|
99
|
+
screens.forEach((screen, index) => {
|
|
100
|
+
const existing = currentGeometryById[screen.id];
|
|
101
|
+
const persisted = persistedGeometryById?.[screen.id];
|
|
102
|
+
const resolved = {
|
|
103
|
+
...getInitialFrameGeometry(index, screen.metadata),
|
|
104
|
+
...persisted,
|
|
105
|
+
} as FrameGeometry;
|
|
106
|
+
next[screen.id] = persisted ? resolved : (existing ?? resolved);
|
|
107
|
+
if (!existing) changed = true;
|
|
108
|
+
if (persisted && !sameFrameGeometry(existing ?? resolved, resolved)) {
|
|
109
|
+
changed = true;
|
|
110
|
+
shouldNotifyParent = true;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return { next, changed, shouldNotifyParent };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function getPreviewDeviceFrameGeometry({
|
|
118
|
+
currentGeometry,
|
|
119
|
+
metadata,
|
|
120
|
+
previewDeviceFrame,
|
|
121
|
+
}: {
|
|
122
|
+
currentGeometry: FrameGeometry;
|
|
123
|
+
metadata?: ScreenViewportSize;
|
|
124
|
+
previewDeviceFrame: DeviceFrameType;
|
|
125
|
+
}): FrameGeometry {
|
|
126
|
+
if (previewDeviceFrame === "none") {
|
|
127
|
+
return {
|
|
128
|
+
...currentGeometry,
|
|
129
|
+
height: getOverviewFrameHeight(currentGeometry.width, metadata),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const viewport = DEVICE_FRAME_VIEWPORTS[previewDeviceFrame];
|
|
133
|
+
return {
|
|
134
|
+
...currentGeometry,
|
|
135
|
+
width: Math.max(1, Math.round(metadata?.width ?? viewport.width)),
|
|
136
|
+
height: Math.max(1, Math.round(metadata?.height ?? viewport.height)),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function getScreenPreviewViewport(
|
|
141
|
+
metadata: ScreenViewportSize,
|
|
142
|
+
geometry: ScreenViewportSize,
|
|
143
|
+
) {
|
|
144
|
+
const metadataWidth = Math.max(1, Math.round(metadata.width));
|
|
145
|
+
const metadataHeight = Math.max(1, Math.round(metadata.height));
|
|
146
|
+
const geometryWidth = Math.max(1, Math.round(geometry.width));
|
|
147
|
+
const geometryHeight = Math.max(1, Math.round(geometry.height));
|
|
148
|
+
const metadataAspect = metadataWidth / metadataHeight;
|
|
149
|
+
const geometryAspect = geometryWidth / geometryHeight;
|
|
150
|
+
const aspectMatches = Math.abs(metadataAspect - geometryAspect) < 0.005;
|
|
151
|
+
|
|
152
|
+
if (aspectMatches) {
|
|
153
|
+
return {
|
|
154
|
+
viewportWidth: metadataWidth,
|
|
155
|
+
viewportHeight: metadataHeight,
|
|
156
|
+
displayWidth: metadataWidth,
|
|
157
|
+
displayHeight: metadataHeight,
|
|
158
|
+
scale:
|
|
159
|
+
Math.abs(metadataWidth - geometryWidth) < 0.5 &&
|
|
160
|
+
Math.abs(metadataHeight - geometryHeight) < 0.5
|
|
161
|
+
? 1
|
|
162
|
+
: geometryWidth / metadataWidth,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
viewportWidth: geometryWidth,
|
|
168
|
+
viewportHeight: geometryHeight,
|
|
169
|
+
displayWidth: geometryWidth,
|
|
170
|
+
displayHeight: geometryHeight,
|
|
171
|
+
scale: 1,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function cloneFrameGeometryById(
|
|
176
|
+
geometryById: FrameGeometryById,
|
|
177
|
+
): FrameGeometryById {
|
|
178
|
+
return Object.fromEntries(
|
|
179
|
+
Object.entries(geometryById).map(([id, geometry]) => [id, { ...geometry }]),
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function frameGeometryWithOverrides(
|
|
184
|
+
base: FrameGeometryById,
|
|
185
|
+
overrides: FrameGeometryById,
|
|
186
|
+
): FrameGeometryById {
|
|
187
|
+
const next = cloneFrameGeometryById(base);
|
|
188
|
+
Object.entries(overrides).forEach(([id, geometry]) => {
|
|
189
|
+
next[id] = { ...geometry };
|
|
190
|
+
});
|
|
191
|
+
return next;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function getFrameCenter(frame: FrameGeometry): Point {
|
|
195
|
+
return {
|
|
196
|
+
x: frame.x + frame.width / 2,
|
|
197
|
+
y: frame.y + frame.height / 2,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function angleBetween(center: Point, point: Point): number {
|
|
202
|
+
return (Math.atan2(point.y - center.y, point.x - center.x) * 180) / Math.PI;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function getSelectableBounds(
|
|
206
|
+
geometry: FrameGeometry,
|
|
207
|
+
chromeScale = 1,
|
|
208
|
+
): BoundsRect {
|
|
209
|
+
return {
|
|
210
|
+
left: geometry.x,
|
|
211
|
+
top: geometry.y - FRAME_LABEL_HEIGHT * chromeScale,
|
|
212
|
+
right: geometry.x + geometry.width,
|
|
213
|
+
bottom: geometry.y + geometry.height,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function getLayerSelectableBounds(geometry: FrameGeometry): BoundsRect {
|
|
218
|
+
return {
|
|
219
|
+
left: geometry.x,
|
|
220
|
+
top: geometry.y,
|
|
221
|
+
right: geometry.x + geometry.width,
|
|
222
|
+
bottom: geometry.y + geometry.height,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function frameStyleLeftTop(
|
|
227
|
+
geometry: { x: number; y: number },
|
|
228
|
+
labelHeight = 0,
|
|
229
|
+
): { left: number; top: number } {
|
|
230
|
+
return {
|
|
231
|
+
left: SURFACE_PADDING + geometry.x,
|
|
232
|
+
top: SURFACE_PADDING + geometry.y - labelHeight,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function rectContainsPoint(bounds: BoundsRect, point: Point): boolean {
|
|
237
|
+
return (
|
|
238
|
+
point.x >= bounds.left &&
|
|
239
|
+
point.x <= bounds.right &&
|
|
240
|
+
point.y >= bounds.top &&
|
|
241
|
+
point.y <= bounds.bottom
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function rotatePointAroundCenter(
|
|
246
|
+
point: Point,
|
|
247
|
+
center: Point,
|
|
248
|
+
degrees: number,
|
|
249
|
+
): Point {
|
|
250
|
+
if (!degrees) return point;
|
|
251
|
+
const rad = (-degrees * Math.PI) / 180;
|
|
252
|
+
const dx = point.x - center.x;
|
|
253
|
+
const dy = point.y - center.y;
|
|
254
|
+
const cos = Math.cos(rad);
|
|
255
|
+
const sin = Math.sin(rad);
|
|
256
|
+
return {
|
|
257
|
+
x: center.x + dx * cos - dy * sin,
|
|
258
|
+
y: center.y + dx * sin + dy * cos,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function geometryContainsPoint(
|
|
263
|
+
geometry: FrameGeometry,
|
|
264
|
+
point: Point,
|
|
265
|
+
): boolean {
|
|
266
|
+
const local = rotatePointAroundCenter(
|
|
267
|
+
point,
|
|
268
|
+
getFrameCenter(geometry),
|
|
269
|
+
geometry.rotation ?? 0,
|
|
270
|
+
);
|
|
271
|
+
return rectContainsPoint(
|
|
272
|
+
{
|
|
273
|
+
left: geometry.x,
|
|
274
|
+
top: geometry.y,
|
|
275
|
+
right: geometry.x + geometry.width,
|
|
276
|
+
bottom: geometry.y + geometry.height,
|
|
277
|
+
},
|
|
278
|
+
local,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function geometryCorners(geometry: FrameGeometry): Point[] {
|
|
283
|
+
const center = getFrameCenter(geometry);
|
|
284
|
+
const rotation = geometry.rotation ?? 0;
|
|
285
|
+
return [
|
|
286
|
+
{ x: geometry.x, y: geometry.y },
|
|
287
|
+
{ x: geometry.x + geometry.width, y: geometry.y },
|
|
288
|
+
{ x: geometry.x + geometry.width, y: geometry.y + geometry.height },
|
|
289
|
+
{ x: geometry.x, y: geometry.y + geometry.height },
|
|
290
|
+
].map((point) => rotatePointAroundCenter(point, center, -rotation));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function geometryContainsGeometry(
|
|
294
|
+
outer: FrameGeometry,
|
|
295
|
+
inner: FrameGeometry,
|
|
296
|
+
): boolean {
|
|
297
|
+
return geometryCorners(inner).every((point) =>
|
|
298
|
+
geometryContainsPoint(outer, point),
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function findTopFrameEntryAtPoint<
|
|
303
|
+
T extends { id: string; geometry: FrameGeometry },
|
|
304
|
+
>(
|
|
305
|
+
entries: readonly T[],
|
|
306
|
+
point: Point,
|
|
307
|
+
options: { foregroundId?: string } = {},
|
|
308
|
+
): T | undefined {
|
|
309
|
+
return entries
|
|
310
|
+
.map((entry, index) => ({ entry, index }))
|
|
311
|
+
.filter(({ entry }) => {
|
|
312
|
+
const bounds = {
|
|
313
|
+
left: entry.geometry.x,
|
|
314
|
+
top: entry.geometry.y,
|
|
315
|
+
right: entry.geometry.x + entry.geometry.width,
|
|
316
|
+
bottom: entry.geometry.y + entry.geometry.height,
|
|
317
|
+
};
|
|
318
|
+
const local = rotatePointAroundCenter(
|
|
319
|
+
point,
|
|
320
|
+
getFrameCenter(entry.geometry),
|
|
321
|
+
entry.geometry.rotation ?? 0,
|
|
322
|
+
);
|
|
323
|
+
return rectContainsPoint(bounds, local);
|
|
324
|
+
})
|
|
325
|
+
.sort(
|
|
326
|
+
(a, b) =>
|
|
327
|
+
Number(b.entry.id === options.foregroundId) -
|
|
328
|
+
Number(a.entry.id === options.foregroundId) ||
|
|
329
|
+
(b.entry.geometry.z ?? 0) - (a.entry.geometry.z ?? 0) ||
|
|
330
|
+
b.index - a.index,
|
|
331
|
+
)[0]?.entry;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function getOutsideFrameDraftFallback<T>(
|
|
335
|
+
entries: readonly T[],
|
|
336
|
+
options: { hasBoardDrawHandler: boolean },
|
|
337
|
+
): T | undefined {
|
|
338
|
+
if (entries.length === 0) return undefined;
|
|
339
|
+
if (options.hasBoardDrawHandler) return undefined;
|
|
340
|
+
return entries[0];
|
|
341
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export function getPrimaryIframeId(screenId: string): string {
|
|
2
|
+
return screenId;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getBreakpointIframeId(
|
|
6
|
+
screenId: string,
|
|
7
|
+
widthPx: number,
|
|
8
|
+
): string {
|
|
9
|
+
return `${screenId}::bp-${widthPx}`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isBreakpointSelectionTarget(screen: {
|
|
13
|
+
breakpointWidths?: number[];
|
|
14
|
+
activeBreakpointWidth?: number;
|
|
15
|
+
}): boolean {
|
|
16
|
+
return (
|
|
17
|
+
screen.activeBreakpointWidth !== undefined &&
|
|
18
|
+
(screen.breakpointWidths ?? []).includes(screen.activeBreakpointWidth)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getActiveScreenIframeId(screen: {
|
|
23
|
+
id: string;
|
|
24
|
+
activeBreakpointWidth?: number;
|
|
25
|
+
breakpointWidths?: number[];
|
|
26
|
+
}): string {
|
|
27
|
+
const activeWidth = screen.activeBreakpointWidth;
|
|
28
|
+
if (
|
|
29
|
+
activeWidth !== undefined &&
|
|
30
|
+
screen.breakpointWidths?.includes(activeWidth)
|
|
31
|
+
) {
|
|
32
|
+
return getBreakpointIframeId(screen.id, activeWidth);
|
|
33
|
+
}
|
|
34
|
+
return getPrimaryIframeId(screen.id);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Resolve an ordinary screen iframe or the dedicated board surface iframe. */
|
|
38
|
+
export function findCanvasIframeForScreen(
|
|
39
|
+
root: HTMLElement | null,
|
|
40
|
+
iframeId: string,
|
|
41
|
+
boardFileId?: string,
|
|
42
|
+
): HTMLIFrameElement | null {
|
|
43
|
+
if (!root) return null;
|
|
44
|
+
if (boardFileId && iframeId === boardFileId) {
|
|
45
|
+
return root.querySelector<HTMLIFrameElement>(
|
|
46
|
+
"[data-board-surface-layer] iframe[data-design-preview-iframe]",
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return root.querySelector<HTMLIFrameElement>(
|
|
50
|
+
`[data-screen-iframe-id="${CSS.escape(iframeId)}"]`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
|
|
3
|
+
import type { FrameGeometry } from "./types";
|
|
4
|
+
|
|
5
|
+
export const OVERVIEW_FRAME_WIDTH = 320;
|
|
6
|
+
export const SURFACE_PADDING = 240;
|
|
7
|
+
|
|
8
|
+
export const LINEUP_RECENTER_SUPPRESS_MAX_AGE_MS = 10_000;
|
|
9
|
+
|
|
10
|
+
export interface LineupRecenterDuplicateArm {
|
|
11
|
+
atMs: number;
|
|
12
|
+
fromCount: number;
|
|
13
|
+
addedCount: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function shouldSuppressLineupRecenter(args: {
|
|
17
|
+
armed: LineupRecenterDuplicateArm | null;
|
|
18
|
+
nowMs: number;
|
|
19
|
+
screenCount: number;
|
|
20
|
+
deviceFrameChanged: boolean;
|
|
21
|
+
maxAgeMs?: number;
|
|
22
|
+
}): boolean {
|
|
23
|
+
if (!args.armed) return false;
|
|
24
|
+
if (args.deviceFrameChanged) return false;
|
|
25
|
+
const age = args.nowMs - args.armed.atMs;
|
|
26
|
+
if (age < 0 || age > (args.maxAgeMs ?? LINEUP_RECENTER_SUPPRESS_MAX_AGE_MS)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return (
|
|
30
|
+
args.screenCount > args.armed.fromCount && // i18n-ignore -- comparison, not visible copy
|
|
31
|
+
args.screenCount <= args.armed.fromCount + args.armed.addedCount
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isLineupShrinkOnlyChange(args: {
|
|
36
|
+
previousCount: number | null;
|
|
37
|
+
screenCount: number;
|
|
38
|
+
deviceFrameChanged: boolean;
|
|
39
|
+
}): boolean {
|
|
40
|
+
return (
|
|
41
|
+
!args.deviceFrameChanged &&
|
|
42
|
+
args.previousCount !== null &&
|
|
43
|
+
args.screenCount < args.previousCount
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function getBoardSurfaceLayerStyle(args: {
|
|
48
|
+
geometry: FrameGeometry;
|
|
49
|
+
interactive: boolean;
|
|
50
|
+
}): CSSProperties {
|
|
51
|
+
return {
|
|
52
|
+
position: "absolute",
|
|
53
|
+
left: SURFACE_PADDING + args.geometry.x,
|
|
54
|
+
top: SURFACE_PADDING + args.geometry.y,
|
|
55
|
+
width: args.geometry.width,
|
|
56
|
+
height: args.geometry.height,
|
|
57
|
+
overflow: "hidden",
|
|
58
|
+
pointerEvents: args.interactive ? "auto" : "none",
|
|
59
|
+
background: "transparent",
|
|
60
|
+
zIndex: 0,
|
|
61
|
+
};
|
|
62
|
+
}
|