@agent-native/core 0.92.7 → 0.92.9
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 +18 -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 +17 -3
- 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/ssr-handler.ts +7 -0
- 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.d.ts.map +1 -1
- package/dist/cli/recap.js +13 -3
- 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/observability/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +3 -3
- 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/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +7 -0
- package/dist/server/ssr-handler.js.map +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,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPenPathGeometry,
|
|
3
|
+
serializePenPath,
|
|
4
|
+
type PenNode,
|
|
5
|
+
type PenPath,
|
|
6
|
+
type PenPoint,
|
|
7
|
+
} from "@shared/pen-path";
|
|
8
|
+
|
|
9
|
+
import type { CreatePrimitiveSpec } from "@/components/design/design-canvas/creation";
|
|
10
|
+
import type { CanvasPrimitiveInsert } from "@/components/design/multi-screen/types";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* P4/single-screen placement: converts a `CreatePrimitiveSpec` emitted by
|
|
14
|
+
* DesignCanvas's single-screen click-to-place overlay (coordinates already in
|
|
15
|
+
* screen-content space, matching `appendCanvasPrimitiveToHtml`'s own
|
|
16
|
+
* coordinate system) into the `CanvasPrimitiveInsert` shape the overview path
|
|
17
|
+
* (`handleCreatePrimitive` / `appendCanvasPrimitiveToHtml`) already knows how
|
|
18
|
+
* to persist. This deliberately reuses the exact same insert shape as
|
|
19
|
+
* `draftPrimitiveToInsert` produces in MultiScreenCanvas.tsx so single-screen
|
|
20
|
+
* and overview creation commit through one shared persistence path instead of
|
|
21
|
+
* two.
|
|
22
|
+
*
|
|
23
|
+
* Pen specs carry the complete structured path collected by DesignCanvas's
|
|
24
|
+
* single-screen overlay. Keeping the nodes and handles intact makes focused
|
|
25
|
+
* screen authoring behave like overview/Figma pen authoring instead of
|
|
26
|
+
* fabricating a fixed-length line from the first point.
|
|
27
|
+
*/
|
|
28
|
+
export function createPrimitiveInsertFromSpec(
|
|
29
|
+
spec: CreatePrimitiveSpec,
|
|
30
|
+
nodeId: string,
|
|
31
|
+
): CanvasPrimitiveInsert | null {
|
|
32
|
+
if (spec.tool === "line" || spec.tool === "arrow") {
|
|
33
|
+
const points = spec.points;
|
|
34
|
+
if (!points || points.length < 2) return null;
|
|
35
|
+
const [start, end] = points;
|
|
36
|
+
if (!start || !end) return null;
|
|
37
|
+
const left = Math.min(start.x, end.x);
|
|
38
|
+
const top = Math.min(start.y, end.y);
|
|
39
|
+
const width = Math.max(1, Math.abs(end.x - start.x));
|
|
40
|
+
const height = Math.max(1, Math.abs(end.y - start.y));
|
|
41
|
+
return {
|
|
42
|
+
kind: spec.tool,
|
|
43
|
+
nodeId,
|
|
44
|
+
geometry: { x: left, y: top, width, height },
|
|
45
|
+
points,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (spec.tool === "pen") {
|
|
50
|
+
const penPath = spec.penPath;
|
|
51
|
+
if (!penPath || penPath.nodes.length < 2) return null;
|
|
52
|
+
const geometry = getPenPathGeometry(penPath);
|
|
53
|
+
return {
|
|
54
|
+
kind: "path",
|
|
55
|
+
nodeId,
|
|
56
|
+
geometry,
|
|
57
|
+
points: penPath.nodes.map((node) => node.point),
|
|
58
|
+
pathData: serializePenPath(penPath),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const rect = spec.rect;
|
|
63
|
+
if (!rect) return null;
|
|
64
|
+
return {
|
|
65
|
+
kind: spec.tool,
|
|
66
|
+
nodeId,
|
|
67
|
+
geometry: {
|
|
68
|
+
x: rect.x,
|
|
69
|
+
y: rect.y,
|
|
70
|
+
width: Math.max(1, rect.width),
|
|
71
|
+
height: Math.max(1, rect.height),
|
|
72
|
+
},
|
|
73
|
+
autoSize: spec.tool === "text" ? spec.fromClick : undefined,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reconstructs a structured `PenPath` (nodes + optional handles) from a `d`
|
|
79
|
+
* string produced by `serializePenPath` (shared/pen-path.ts). This is the
|
|
80
|
+
* deliberate INVERSE of that exact serializer — not a general SVG path
|
|
81
|
+
* parser — so it only needs to understand the small grammar
|
|
82
|
+
* `serializePenPath` actually emits: `M x y`, then per-segment `L x y` (both
|
|
83
|
+
* handles coincide with their anchors) or `C c1x c1y c2x c2y x y`
|
|
84
|
+
* (`c1`/`c2` are the FROM node's `handleOut` / TO node's `handleIn`,
|
|
85
|
+
* respectively — see `serializeSegment`), optionally followed by a trailing
|
|
86
|
+
* `Z` for a closed path (whose preceding segment is the wrap-around from the
|
|
87
|
+
* last node back to the first, not a new node).
|
|
88
|
+
*
|
|
89
|
+
* This exists because `CanvasPrimitiveInsert` (MultiScreenCanvas.tsx) only
|
|
90
|
+
* carries the already-flattened `pathData` string across the overview
|
|
91
|
+
* commit boundary, not the richer `DraftPrimitive.penPath` MultiScreenCanvas
|
|
92
|
+
* keeps internally — so committing a pen path drawn in OVERVIEW mode has no
|
|
93
|
+
* other source for the structured node/handle data `data-an-pen-nodes`
|
|
94
|
+
* needs. Single-screen pen placement (`createPrimitiveInsertFromSpec` above)
|
|
95
|
+
* builds its `PenPath` directly and never needs this reverse parse.
|
|
96
|
+
*
|
|
97
|
+
* Returns `null` for anything that doesn't match the expected grammar
|
|
98
|
+
* (empty/malformed `d`) rather than throwing, so a call site can always fall
|
|
99
|
+
* back to skipping `data-an-pen-nodes` for that element.
|
|
100
|
+
*/
|
|
101
|
+
export function parsePenPathFromSerializedD(d: string): PenPath | null {
|
|
102
|
+
const trimmed = d.trim();
|
|
103
|
+
if (!trimmed) return null;
|
|
104
|
+
const tokens = trimmed.match(/[MLCZ]|-?\d+(?:\.\d+)?/gi);
|
|
105
|
+
if (!tokens || tokens.length === 0) return null;
|
|
106
|
+
|
|
107
|
+
const readNumbers = (count: number): PenPoint[] => {
|
|
108
|
+
const points: PenPoint[] = [];
|
|
109
|
+
for (let i = 0; i < count; i += 2) {
|
|
110
|
+
const x = Number(tokens[cursor + i]);
|
|
111
|
+
const y = Number(tokens[cursor + i + 1]);
|
|
112
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
113
|
+
throw new Error("invalid pen path number");
|
|
114
|
+
}
|
|
115
|
+
points.push({ x, y });
|
|
116
|
+
}
|
|
117
|
+
return points;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
let cursor = 0;
|
|
121
|
+
const command = tokens[cursor];
|
|
122
|
+
if (command?.toUpperCase() !== "M") return null;
|
|
123
|
+
cursor += 1;
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const [start] = readNumbers(2);
|
|
127
|
+
if (!start) return null;
|
|
128
|
+
cursor += 2;
|
|
129
|
+
const nodes: PenNode[] = [{ point: start }];
|
|
130
|
+
let closed = false;
|
|
131
|
+
|
|
132
|
+
while (cursor < tokens.length) {
|
|
133
|
+
const token = tokens[cursor]?.toUpperCase();
|
|
134
|
+
if (token === "Z") {
|
|
135
|
+
cursor += 1;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (token === "L") {
|
|
139
|
+
cursor += 1;
|
|
140
|
+
const [to] = readNumbers(2);
|
|
141
|
+
if (!to) return null;
|
|
142
|
+
cursor += 2;
|
|
143
|
+
// Same wrap-around case as the "C" branch below: a closed path's
|
|
144
|
+
// final segment (immediately followed by Z) returns to the FIRST
|
|
145
|
+
// node rather than describing a new one.
|
|
146
|
+
const nextIsClose = tokens[cursor]?.toUpperCase() === "Z";
|
|
147
|
+
if (nextIsClose) {
|
|
148
|
+
closed = true;
|
|
149
|
+
} else {
|
|
150
|
+
nodes.push({ point: to });
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (token === "C") {
|
|
155
|
+
cursor += 1;
|
|
156
|
+
const coords = readNumbers(6);
|
|
157
|
+
cursor += 6;
|
|
158
|
+
const [c1, c2, to] = coords;
|
|
159
|
+
if (!c1 || !c2 || !to) return null;
|
|
160
|
+
const fromNode = nodes[nodes.length - 1];
|
|
161
|
+
if (!fromNode) return null;
|
|
162
|
+
if (!samePenPoint(c1, fromNode.point)) {
|
|
163
|
+
fromNode.handleOut = c1;
|
|
164
|
+
}
|
|
165
|
+
// A closed path's final "C"/"L" segment (immediately followed by Z)
|
|
166
|
+
// wraps from the last real node back to the FIRST node — it is not a
|
|
167
|
+
// new node. Apply its handles to the existing first node instead of
|
|
168
|
+
// pushing a duplicate.
|
|
169
|
+
const nextIsClose = tokens[cursor]?.toUpperCase() === "Z";
|
|
170
|
+
if (nextIsClose) {
|
|
171
|
+
closed = true;
|
|
172
|
+
const firstNode = nodes[0];
|
|
173
|
+
if (firstNode && !samePenPoint(c2, firstNode.point)) {
|
|
174
|
+
firstNode.handleIn = c2;
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
const node: PenNode = { point: to };
|
|
178
|
+
if (!samePenPoint(c2, to)) node.handleIn = c2;
|
|
179
|
+
nodes.push(node);
|
|
180
|
+
}
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
// Unknown token — grammar mismatch, bail rather than guess.
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return { nodes, closed };
|
|
188
|
+
} catch {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function samePenPoint(a: PenPoint, b: PenPoint): boolean {
|
|
194
|
+
return Math.abs(a.x - b.x) < 0.05 && Math.abs(a.y - b.y) < 0.05;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Reads the app's actual resolved theme (next-themes' `dark` class on
|
|
198
|
+
// <html>) rather than raw OS `prefers-color-scheme`. NOTE: this is about the
|
|
199
|
+
// EDITOR CHROME theme only — it must NOT gate board-content defaults. The
|
|
200
|
+
// board surface itself is ALWAYS dark (BOARD_SURFACE_BACKGROUND is a fixed
|
|
201
|
+
// hsl(0 0% 10%) regardless of editor theme), so board-drawn text keys its
|
|
202
|
+
// default color off `isBoardTarget` alone — see defaultCanvasTextColor.
|
|
203
|
+
// Gating it on this flag made T-tool board text render black-on-dark
|
|
204
|
+
// (invisible) whenever the editor UI was in light mode.
|
|
205
|
+
export function isDesignEditorDarkTheme(): boolean {
|
|
206
|
+
if (typeof document === "undefined") return false;
|
|
207
|
+
return document.documentElement.classList.contains("dark");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Default text color for a freshly drawn text primitive.
|
|
212
|
+
*
|
|
213
|
+
* - BOARD target: always white. The board surface is permanently dark
|
|
214
|
+
* (BOARD_SURFACE_BACKGROUND), independent of the editor chrome theme, so
|
|
215
|
+
* the "white Inter on dark board" default must not depend on
|
|
216
|
+
* isDesignEditorDarkTheme() — that gate left board text at `currentColor`
|
|
217
|
+
* (black in an unstyled document) for light-theme editor sessions.
|
|
218
|
+
* - SCREEN target: `currentColor`, so text dropped into an existing (often
|
|
219
|
+
* light) screen inherits its surrounding styles/theme exactly as before.
|
|
220
|
+
*/
|
|
221
|
+
export function defaultCanvasTextColor(isBoardTarget: boolean): string {
|
|
222
|
+
return isBoardTarget ? "#ffffff" : "currentColor";
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Default font stack for board-drawn text — Inter with the app's standard
|
|
226
|
+
* system-font fallback chain, matching the rest of the editor's UI type
|
|
227
|
+
* instead of the browser's serif default for an unstyled <div>. */
|
|
228
|
+
export const CANVAS_TEXT_DEFAULT_FONT_FAMILY =
|
|
229
|
+
'"Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
|