@agent-native/core 0.131.4 → 0.131.6
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 +3 -3
- package/corpus/core/CHANGELOG.md +69 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +13 -6
- package/corpus/core/docs/content/cloneable-saas.mdx +5 -5
- package/corpus/core/docs/content/creating-templates.mdx +9 -0
- package/corpus/core/docs/content/deployment.mdx +14 -10
- package/corpus/core/docs/content/docs-components.mdx +491 -0
- package/corpus/core/docs/content/doctor.mdx +8 -1
- package/corpus/core/docs/content/drop-in-agent.mdx +1 -1
- package/corpus/core/docs/content/extensions.mdx +18 -18
- package/corpus/core/docs/content/faq.mdx +4 -4
- package/corpus/core/docs/content/key-concepts.mdx +30 -21
- package/corpus/core/docs/content/template-brain-developers.mdx +4 -1
- package/corpus/core/docs/content/template-mail-developers.mdx +4 -1
- package/corpus/core/docs/content/what-is-agent-native.mdx +6 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/client.ts +449 -66
- package/corpus/core/src/a2a/correlation.ts +31 -0
- package/corpus/core/src/a2a/types.ts +4 -0
- package/corpus/core/src/action.ts +3 -0
- package/corpus/core/src/agent/engine/registry.ts +45 -5
- package/corpus/core/src/agent/production-agent.ts +151 -18
- package/corpus/core/src/agent/run-loop-with-resume.ts +190 -3
- package/corpus/core/src/agent/run-manager.ts +117 -41
- package/corpus/core/src/agent/thread-debug-history.ts +86 -0
- package/corpus/core/src/agent/types.ts +3 -1
- package/corpus/core/src/cli/create.ts +11 -1
- package/corpus/core/src/cli/templates-meta.ts +2 -2
- package/corpus/core/src/client/agent-chat-adapter.ts +91 -13
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/corpus/core/src/client/sse-event-processor.ts +17 -3
- package/corpus/core/src/db/client.ts +57 -17
- package/corpus/core/src/integrations/adapters/slack.ts +8 -3
- package/corpus/core/src/localization/default-messages.ts +44 -0
- package/corpus/core/src/observability/traces.ts +78 -5
- package/corpus/core/src/scripts/call-agent.ts +290 -9
- package/corpus/core/src/scripts/describe-workspace-apps.ts +2 -2
- package/corpus/core/src/secrets/crypto.ts +126 -34
- package/corpus/core/src/secrets/storage.ts +61 -25
- package/corpus/core/src/server/agent-capabilities.ts +1 -1
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +111 -7
- package/corpus/core/src/server/agent-chat/context-tools.ts +2 -0
- package/corpus/core/src/server/agent-chat/plugin-options.ts +34 -1
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +91 -59
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +14 -7
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/corpus/core/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -7
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +5 -4
- package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +6 -4
- package/corpus/templates/analytics/AGENTS.md +6 -4
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +4 -3
- package/corpus/templates/analytics/changelog/2026-07-30-scheduled-dashboard-emails-complete-every-panel-without-pool.md +6 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +28 -1
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +18 -11
- package/corpus/templates/analytics/server/lib/analytics-connector-catalog.ts +4 -4
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +9 -5
- package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +6 -2
- package/corpus/templates/analytics/server/lib/dashboard-panel-source-resolver.ts +11 -4
- package/corpus/templates/analytics/server/lib/dashboard-report-render.ts +49 -31
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +16 -8
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +9 -3
- package/corpus/templates/analytics/server/lib/production-serverless-runtime.ts +11 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/analytics/server/plugins/analytics-alert-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/dashboard-report-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/uptime-monitor-jobs.ts +1 -12
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +54 -6
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +20 -9
- package/corpus/templates/brain/.agents/skills/ingestion-and-connectors/SKILL.md +33 -1
- package/corpus/templates/brain/AGENTS.md +3 -1
- package/corpus/templates/brain/README.md +4 -1
- package/corpus/templates/brain/actions/_schemas.ts +30 -8
- package/corpus/templates/brain/actions/ask-brain.ts +124 -14
- package/corpus/templates/brain/actions/create-source.ts +18 -2
- package/corpus/templates/brain/actions/enqueue-captures-distillation.ts +8 -123
- package/corpus/templates/brain/actions/enqueue-distillation.ts +6 -127
- package/corpus/templates/brain/actions/import-capture.ts +17 -5
- package/corpus/templates/brain/actions/import-transcript.ts +17 -5
- package/corpus/templates/brain/actions/update-source.ts +25 -5
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/brain/changelog/2026-07-30-blessed-resources-can-feed-cited-company-answers.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-30-the-left-sidebar-no-longer-shows-a-blank-organization-placeh.md +6 -0
- package/corpus/templates/brain/server/lib/brain.ts +49 -19
- package/corpus/templates/brain/server/lib/distillation-queue.ts +147 -0
- package/corpus/templates/brain/server/lib/source-policy.ts +264 -0
- package/corpus/templates/brain/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +116 -19
- package/corpus/templates/clips/app/components/meetings/google-oauth-identity-notice.tsx +51 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +3 -1
- package/corpus/templates/clips/changelog/2026-07-30-google-calendar-warning.md +6 -0
- package/corpus/templates/content/.agents/skills/content-product-development/SKILL.md +47 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +72 -8
- package/corpus/templates/content/changelog/2026-07-30-the-slash-command-hint-now-stays-on-only-the-active-empty-li.md +6 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +506 -11
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +148 -17
- package/corpus/templates/design/app/components/design/canvas-interactions/design-canvas-interactions.ts +357 -0
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +7 -466
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +15 -311
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +19 -997
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +8 -1216
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +31 -38
- package/corpus/templates/design/package.json +0 -1
- package/corpus/templates/dispatch/AGENTS.md +8 -0
- package/corpus/templates/dispatch/DEVELOPING.md +29 -0
- package/corpus/templates/dispatch/actions/view-screen.ts +34 -2
- package/corpus/templates/dispatch/app/i18n-data.ts +457 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-delegated-dispatch-work-continues-reliably-in-the-background.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-find-failed-runs-across-apps.md +6 -0
- package/corpus/templates/dispatch/netlify.toml +3 -0
- package/corpus/templates/slides/.agents/skills/analytics-data-for-decks/SKILL.md +8 -12
- package/corpus/templates/slides/AGENTS.md +4 -4
- package/corpus/templates/slides/actions/duplicate-deck.ts +19 -4
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -10
- package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +12 -1
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +30 -13
- package/corpus/templates/slides/app/components/editor/DeckEditorSkeleton.tsx +35 -0
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +63 -56
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +21 -76
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +1110 -292
- package/corpus/templates/slides/app/components/editor/SlideOverflowWarning.tsx +53 -0
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +235 -18
- package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +4 -1
- package/corpus/templates/slides/app/components/editor/canvas-interactions/index.ts +11 -0
- package/corpus/templates/slides/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +129 -0
- package/corpus/templates/slides/app/components/editor/selection-overlay-measurement.ts +70 -0
- package/corpus/templates/slides/app/components/editor/slide-object-interactions.ts +519 -65
- package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +36 -426
- package/corpus/templates/slides/app/components/visual-editor/DrawOverlay.tsx +19 -458
- package/corpus/templates/slides/app/context/DeckContext.tsx +179 -72
- package/corpus/templates/slides/app/global.css +105 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +8 -0
- package/corpus/templates/slides/app/lib/deck-editor-loading.ts +26 -0
- package/corpus/templates/slides/app/lib/mermaid-blocks.ts +27 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +71 -38
- package/corpus/templates/slides/app/pages/Index.tsx +98 -41
- package/corpus/templates/slides/changelog/2026-07-30-deck-loading-no-longer-flashes-an-unavailable-message.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-duplicating-a-deck-from-the-deck-list-now-opens-the-copy-imm.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-layout-overflow-warning-is-readable-and-dismissible.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-shared-canvas-annotations.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-objects-can-be-moved-as-a-group-copied-and-pasted-with.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-text-editing-and-object-controls-now-match-google-slides.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-style-panel-now-scrolls-with-speaker-notes-open-shows-the-sl.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-top-toolbar-controls-now-use-consistent-sizing-with-undo-and.md +6 -0
- package/corpus/templates/slides/netlify.toml +3 -1
- package/corpus/templates/slides/package.json +0 -1
- package/corpus/templates/slides/server/lib/chat-attachments.ts +18 -0
- package/corpus/templates/slides/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/slides/vite.config.ts +0 -1
- package/corpus/toolkit/CHANGELOG.md +13 -0
- package/corpus/toolkit/README.md +19 -0
- package/corpus/toolkit/agent-native.eject.json +38 -0
- package/corpus/toolkit/package.json +29 -1
- package/corpus/toolkit/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
- package/corpus/toolkit/src/canvas-annotations/DrawOverlay.tsx +1233 -0
- package/corpus/toolkit/src/canvas-annotations/index.ts +15 -0
- package/corpus/toolkit/src/canvas-annotations/types.ts +14 -0
- package/corpus/toolkit/src/canvas-interactions/canvas-interactions.ts +933 -0
- package/corpus/toolkit/src/canvas-interactions/index.ts +67 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input-utils.ts +311 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input.tsx +491 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +26 -171
- package/corpus/toolkit/src/index.ts +1 -0
- package/dist/a2a/client.d.ts +23 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +309 -44
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/correlation.d.ts +1 -0
- package/dist/a2a/correlation.d.ts.map +1 -1
- package/dist/a2a/correlation.js +27 -0
- package/dist/a2a/correlation.js.map +1 -1
- package/dist/a2a/types.d.ts +4 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/action.d.ts +3 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +34 -7
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/production-agent.d.ts +40 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +113 -15
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts +21 -0
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +163 -4
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts +16 -9
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +93 -42
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-debug-history.d.ts +10 -0
- package/dist/agent/thread-debug-history.d.ts.map +1 -0
- package/dist/agent/thread-debug-history.js +68 -0
- package/dist/agent/thread-debug-history.js.map +1 -0
- package/dist/agent/types.d.ts +3 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +6 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/templates-meta.js +2 -2
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +76 -13
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +1 -1
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +12 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +48 -17
- package/dist/db/client.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/integrations/adapters/slack.js +7 -3
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/localization/default-messages.d.ts +43 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +43 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/traces.d.ts +3 -1
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +73 -4
- package/dist/observability/traces.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
- package/dist/provider-api/actions/provider-api.d.ts +13 -13
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +233 -10
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/describe-workspace-apps.js +2 -2
- package/dist/scripts/describe-workspace-apps.js.map +1 -1
- package/dist/secrets/crypto.d.ts +31 -21
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +108 -33
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/secrets/storage.d.ts +3 -5
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +40 -25
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/agent-capabilities.js +1 -1
- package/dist/server/agent-capabilities.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +17 -3
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +92 -3
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +2 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +23 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
- package/dist/server/agent-chat/plugin-options.js +4 -1
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat/prompt-resources.js +1 -1
- package/dist/server/agent-chat/prompt-resources.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +2 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +79 -56
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +14 -7
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +14 -7
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/dist/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -7
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +13 -6
- package/docs/content/cloneable-saas.mdx +5 -5
- package/docs/content/creating-templates.mdx +9 -0
- package/docs/content/deployment.mdx +14 -10
- package/docs/content/docs-components.mdx +491 -0
- package/docs/content/doctor.mdx +8 -1
- package/docs/content/drop-in-agent.mdx +1 -1
- package/docs/content/extensions.mdx +18 -18
- package/docs/content/faq.mdx +4 -4
- package/docs/content/key-concepts.mdx +30 -21
- package/docs/content/template-brain-developers.mdx +4 -1
- package/docs/content/template-mail-developers.mdx +4 -1
- package/docs/content/what-is-agent-native.mdx +6 -6
- package/package.json +2 -2
- package/src/a2a/client.ts +449 -66
- package/src/a2a/correlation.ts +31 -0
- package/src/a2a/types.ts +4 -0
- package/src/action.ts +3 -0
- package/src/agent/engine/registry.ts +45 -5
- package/src/agent/production-agent.ts +151 -18
- package/src/agent/run-loop-with-resume.ts +190 -3
- package/src/agent/run-manager.ts +117 -41
- package/src/agent/thread-debug-history.ts +86 -0
- package/src/agent/types.ts +3 -1
- package/src/cli/create.ts +11 -1
- package/src/cli/templates-meta.ts +2 -2
- package/src/client/agent-chat-adapter.ts +91 -13
- package/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/src/client/sse-event-processor.ts +17 -3
- package/src/db/client.ts +57 -17
- package/src/integrations/adapters/slack.ts +8 -3
- package/src/localization/default-messages.ts +44 -0
- package/src/observability/traces.ts +78 -5
- package/src/scripts/call-agent.ts +290 -9
- package/src/scripts/describe-workspace-apps.ts +2 -2
- package/src/secrets/crypto.ts +126 -34
- package/src/secrets/storage.ts +61 -25
- package/src/server/agent-capabilities.ts +1 -1
- package/src/server/agent-chat/action-filters-a2a.ts +111 -7
- package/src/server/agent-chat/context-tools.ts +2 -0
- package/src/server/agent-chat/plugin-options.ts +34 -1
- package/src/server/agent-chat/prompt-resources.ts +1 -1
- package/src/server/agent-chat-plugin.ts +91 -59
- package/src/templates/default/.agents/skills/secrets/SKILL.md +14 -7
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -7
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -7
- package/src/vite/client.ts +1 -0
|
@@ -1,311 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* as a real scrub rather than jitter during a plain click. Mirrors
|
|
17
|
-
* ScrubInput's DRAG_THRESHOLD_PX. */
|
|
18
|
-
export const SCRUB_DRAG_THRESHOLD_PX = 3;
|
|
19
|
-
|
|
20
|
-
export interface ScrubDragState {
|
|
21
|
-
startX: number;
|
|
22
|
-
prevX: number;
|
|
23
|
-
hasDragged: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Begins tracking a new scrub gesture at the given starting pointer X. */
|
|
27
|
-
export function startScrubDrag(startX: number): ScrubDragState {
|
|
28
|
-
return { startX, prevX: startX, hasDragged: false };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface ScrubDragTick {
|
|
32
|
-
/** The updated drag state after this pointermove sample. */
|
|
33
|
-
state: ScrubDragState;
|
|
34
|
-
/** The incremental delta (px) to apply this tick, or null when the move
|
|
35
|
-
* should be ignored (no movement, or still under the jitter threshold). */
|
|
36
|
-
deltaX: number | null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Processes one pointermove sample against the in-progress drag state.
|
|
41
|
-
* Mirrors ScrubInput's handlePointerMove threshold/hasDragged logic exactly:
|
|
42
|
-
* a move is ignored until cumulative movement clears SCRUB_DRAG_THRESHOLD_PX,
|
|
43
|
-
* after which every subsequent move (including this one) yields an
|
|
44
|
-
* incremental delta and marks the gesture as a real drag.
|
|
45
|
-
*/
|
|
46
|
-
export function updateScrubDrag(
|
|
47
|
-
state: ScrubDragState,
|
|
48
|
-
clientX: number,
|
|
49
|
-
): ScrubDragTick {
|
|
50
|
-
const incr = clientX - state.prevX;
|
|
51
|
-
if (incr === 0) {
|
|
52
|
-
return { state, deltaX: null };
|
|
53
|
-
}
|
|
54
|
-
const cumulativeDelta = Math.abs(clientX - state.startX);
|
|
55
|
-
if (!state.hasDragged && cumulativeDelta < SCRUB_DRAG_THRESHOLD_PX) {
|
|
56
|
-
return { state: { ...state, prevX: clientX }, deltaX: null };
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
state: { ...state, prevX: clientX, hasDragged: true },
|
|
60
|
-
deltaX: incr,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface ParsedScrubExpression {
|
|
65
|
-
value: number;
|
|
66
|
-
normalized: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
type MathOperator = "+" | "-" | "*" | "/";
|
|
70
|
-
|
|
71
|
-
type Token =
|
|
72
|
-
| { type: "number"; value: number }
|
|
73
|
-
| { type: "operator"; value: MathOperator };
|
|
74
|
-
|
|
75
|
-
const NUMBER_CHAR_PATTERN = /[0-9.]/;
|
|
76
|
-
// Comma is only treated as a digit character while scanning a number token
|
|
77
|
-
// (see tokenizeExpression) so a locale-style decimal comma ("12,5") parses as
|
|
78
|
-
// 12.5, without swallowing the "," that a caller might use to separate
|
|
79
|
-
// distinct expressions elsewhere.
|
|
80
|
-
const NUMBER_OR_COMMA_CHAR_PATTERN = /[0-9.,]/;
|
|
81
|
-
|
|
82
|
-
export function parseScrubExpression(
|
|
83
|
-
input: string,
|
|
84
|
-
currentValue: number,
|
|
85
|
-
options: ScrubExpressionOptions = {},
|
|
86
|
-
): ParsedScrubExpression | null {
|
|
87
|
-
const raw = input.trim();
|
|
88
|
-
if (!raw) return null;
|
|
89
|
-
|
|
90
|
-
const expression = toNumericExpression(raw, currentValue, options.unit);
|
|
91
|
-
const value = evaluateNumericExpression(expression);
|
|
92
|
-
if (value === null) return null;
|
|
93
|
-
|
|
94
|
-
const normalizedValue = normalizeScrubNumber(value, options);
|
|
95
|
-
return {
|
|
96
|
-
value: normalizedValue,
|
|
97
|
-
normalized: formatScrubValue(normalizedValue, options),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function normalizeScrubNumber(
|
|
102
|
-
value: number,
|
|
103
|
-
options: ScrubExpressionOptions = {},
|
|
104
|
-
): number {
|
|
105
|
-
if (!Number.isFinite(value)) return 0;
|
|
106
|
-
|
|
107
|
-
let next = value;
|
|
108
|
-
if (Number.isFinite(options.min)) next = Math.max(options.min!, next);
|
|
109
|
-
if (Number.isFinite(options.max)) next = Math.min(options.max!, next);
|
|
110
|
-
if (Number.isFinite(options.precision)) {
|
|
111
|
-
const scale = 10 ** Math.max(0, options.precision!);
|
|
112
|
-
next = Math.round(next * scale) / scale;
|
|
113
|
-
}
|
|
114
|
-
return Object.is(next, -0) ? 0 : next;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Whether a field's unit should snap to whole numbers while the user is
|
|
119
|
-
* actively pointer-dragging (scrubbing) it. Px-type fields (padding, gap,
|
|
120
|
-
* position, size, radius, etc.) read as integers in Figma-style editors even
|
|
121
|
-
* though the underlying `precision` option (which also governs *typed* input
|
|
122
|
-
* and keyboard nudges) allows one decimal place so a typed "12.5" still
|
|
123
|
-
* commits legally. Scoped to "px" specifically — unitless fields like
|
|
124
|
-
* line-height (precision-based, fractional by design) and other units (deg,
|
|
125
|
-
* %) are untouched.
|
|
126
|
-
*/
|
|
127
|
-
export function scrubSnapsToInteger(unit: string | undefined): boolean {
|
|
128
|
-
return unit === "px";
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Rounds a live scrub-drag value to a whole number when the field's unit
|
|
133
|
-
* calls for integer-only scrubbing (see `scrubSnapsToInteger`), applied
|
|
134
|
-
* *before* `normalizeScrubNumber`'s own min/max/precision clamp so a
|
|
135
|
-
* following precision clamp (if any) can't reintroduce a fraction. Only the
|
|
136
|
-
* pointer-drag scrub gesture should call this — typed input and keyboard
|
|
137
|
-
* nudges keep their existing `precision`-based rounding untouched.
|
|
138
|
-
*/
|
|
139
|
-
export function roundScrubDragValue(
|
|
140
|
-
value: number,
|
|
141
|
-
unit: string | undefined,
|
|
142
|
-
): number {
|
|
143
|
-
return scrubSnapsToInteger(unit) ? Math.round(value) : value;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function formatScrubValue(
|
|
147
|
-
value: number,
|
|
148
|
-
options: Pick<ScrubExpressionOptions, "precision" | "unit"> = {},
|
|
149
|
-
): string {
|
|
150
|
-
const normalized = normalizeScrubNumber(value, options);
|
|
151
|
-
let numeric: string;
|
|
152
|
-
if (Number.isFinite(options.precision) && options.precision! >= 0) {
|
|
153
|
-
const fixed = normalized.toFixed(options.precision!);
|
|
154
|
-
if (options.unit) {
|
|
155
|
-
// For fields with units (px, %, °, etc.) collapse all trailing zeros
|
|
156
|
-
// including the decimal point: "12.30px" → "12.3px", "10.00px" → "10px".
|
|
157
|
-
// Leave integer strings alone; otherwise precision 0 turns "100" into "1".
|
|
158
|
-
numeric = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
|
|
159
|
-
} else {
|
|
160
|
-
// For unitless fields (e.g. line-height), preserve at least one decimal
|
|
161
|
-
// digit so values like "2.0" stay "2.0" rather than collapsing to "2".
|
|
162
|
-
// Only strip redundant trailing zeros beyond the first decimal digit.
|
|
163
|
-
numeric = fixed.includes(".") ? fixed.replace(/(?<=\.\d)0+$/, "") : fixed;
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
numeric = String(normalized);
|
|
167
|
-
}
|
|
168
|
-
return `${numeric}${options.unit ?? ""}`;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function getScrubStepFromEvent(
|
|
172
|
-
event: Pick<KeyboardEvent | PointerEvent, "altKey" | "shiftKey">,
|
|
173
|
-
step: number,
|
|
174
|
-
): number {
|
|
175
|
-
// Alt (fine-step) and Shift (coarse) are mutually exclusive — alt takes
|
|
176
|
-
// priority, matching Figma's modifier convention. Applying both independently
|
|
177
|
-
// would make Shift+Alt a no-op (×10 × 0.1 = ×1).
|
|
178
|
-
let multiplier = 1;
|
|
179
|
-
if (event.altKey) multiplier = 0.1;
|
|
180
|
-
else if (event.shiftKey) multiplier = 10;
|
|
181
|
-
return step * multiplier;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function toNumericExpression(
|
|
185
|
-
raw: string,
|
|
186
|
-
currentValue: number,
|
|
187
|
-
unit?: string,
|
|
188
|
-
): string {
|
|
189
|
-
let expression = raw.trim();
|
|
190
|
-
|
|
191
|
-
if (unit) {
|
|
192
|
-
expression = expression.replace(new RegExp(escapeRegExp(unit), "gi"), "");
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (expression.startsWith("=")) return expression.slice(1).trim();
|
|
196
|
-
if (/^[+\-*/]/.test(expression)) return `${currentValue}${expression}`;
|
|
197
|
-
return expression;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function evaluateNumericExpression(expression: string): number | null {
|
|
201
|
-
const tokens = tokenizeExpression(expression);
|
|
202
|
-
if (!tokens.length) return null;
|
|
203
|
-
|
|
204
|
-
const values: number[] = [];
|
|
205
|
-
const operators: MathOperator[] = [];
|
|
206
|
-
|
|
207
|
-
for (const token of tokens) {
|
|
208
|
-
if (token.type === "number") {
|
|
209
|
-
values.push(token.value);
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
while (
|
|
214
|
-
operators.length &&
|
|
215
|
-
precedence(operators[operators.length - 1]) >= precedence(token.value)
|
|
216
|
-
) {
|
|
217
|
-
if (!applyTopOperator(values, operators)) return null;
|
|
218
|
-
}
|
|
219
|
-
operators.push(token.value);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
while (operators.length) {
|
|
223
|
-
if (!applyTopOperator(values, operators)) return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (values.length !== 1 || !Number.isFinite(values[0])) return null;
|
|
227
|
-
return values[0];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function tokenizeExpression(expression: string): Token[] {
|
|
231
|
-
const tokens: Token[] = [];
|
|
232
|
-
let index = 0;
|
|
233
|
-
let previousWasOperator = true;
|
|
234
|
-
|
|
235
|
-
while (index < expression.length) {
|
|
236
|
-
const char = expression[index];
|
|
237
|
-
if (/\s/.test(char)) {
|
|
238
|
-
index += 1;
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const signedNumber =
|
|
243
|
-
(char === "+" || char === "-") &&
|
|
244
|
-
previousWasOperator &&
|
|
245
|
-
NUMBER_CHAR_PATTERN.test(expression[index + 1] ?? "");
|
|
246
|
-
|
|
247
|
-
if (NUMBER_CHAR_PATTERN.test(char) || signedNumber) {
|
|
248
|
-
const start = index;
|
|
249
|
-
index += 1;
|
|
250
|
-
// Allow a single comma decimal separator within this number token
|
|
251
|
-
// ("12,5" → 12.5), matching common European locale input. A second
|
|
252
|
-
// comma/period is left for the caller's Number() parse to reject.
|
|
253
|
-
while (NUMBER_OR_COMMA_CHAR_PATTERN.test(expression[index] ?? ""))
|
|
254
|
-
index += 1;
|
|
255
|
-
const value = Number(expression.slice(start, index).replace(",", "."));
|
|
256
|
-
if (!Number.isFinite(value)) return [];
|
|
257
|
-
tokens.push({ type: "number", value });
|
|
258
|
-
previousWasOperator = false;
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (isOperator(char)) {
|
|
263
|
-
tokens.push({ type: "operator", value: char });
|
|
264
|
-
previousWasOperator = true;
|
|
265
|
-
index += 1;
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return [];
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return tokens;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function applyTopOperator(
|
|
276
|
-
values: number[],
|
|
277
|
-
operators: MathOperator[],
|
|
278
|
-
): boolean {
|
|
279
|
-
const operator = operators.pop();
|
|
280
|
-
const right = values.pop();
|
|
281
|
-
const left = values.pop();
|
|
282
|
-
if (!operator || right === undefined || left === undefined) return false;
|
|
283
|
-
|
|
284
|
-
switch (operator) {
|
|
285
|
-
case "+":
|
|
286
|
-
values.push(left + right);
|
|
287
|
-
return true;
|
|
288
|
-
case "-":
|
|
289
|
-
values.push(left - right);
|
|
290
|
-
return true;
|
|
291
|
-
case "*":
|
|
292
|
-
values.push(left * right);
|
|
293
|
-
return true;
|
|
294
|
-
case "/":
|
|
295
|
-
if (right === 0) return false;
|
|
296
|
-
values.push(left / right);
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function precedence(operator: MathOperator): number {
|
|
302
|
-
return operator === "*" || operator === "/" ? 2 : 1;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function isOperator(char: string): char is MathOperator {
|
|
306
|
-
return char === "+" || char === "-" || char === "*" || char === "/";
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function escapeRegExp(value: string): string {
|
|
310
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
311
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
formatScrubValue,
|
|
3
|
+
getScrubStepFromEvent,
|
|
4
|
+
normalizeScrubNumber,
|
|
5
|
+
parseScrubExpression,
|
|
6
|
+
roundScrubDragValue,
|
|
7
|
+
scrubSnapsToInteger,
|
|
8
|
+
SCRUB_DRAG_THRESHOLD_PX,
|
|
9
|
+
startScrubDrag,
|
|
10
|
+
updateScrubDrag,
|
|
11
|
+
type ParsedScrubExpression,
|
|
12
|
+
type ScrubDragState,
|
|
13
|
+
type ScrubDragTick,
|
|
14
|
+
type ScrubExpressionOptions,
|
|
15
|
+
} from "@agent-native/toolkit/design-tweaks";
|