@dexhq/canvas 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +5 -3
- package/app/canvas/activity-parts.tsx +50 -6
- package/app/canvas/activity.tsx +10 -18
- package/app/canvas/agent-changes.ts +18 -8
- package/app/canvas/anchoring.ts +15 -7
- package/app/canvas/canvas-context.tsx +6 -2
- package/app/canvas/canvas-input.ts +186 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +7 -44
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +250 -27
- package/app/canvas/canvas-ui.ts +13 -3
- package/app/canvas/canvas.css +147 -29
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +270 -111
- package/app/canvas/element-link.ts +135 -0
- package/app/canvas/element-picker.ts +223 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/export-dialog.tsx +265 -0
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +83 -16
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-context-menu.tsx +61 -7
- package/app/canvas/frame-node.tsx +19 -20
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +68 -22
- package/app/canvas/linked-element.tsx +196 -0
- package/app/canvas/live-page.ts +156 -19
- package/app/canvas/mentions.tsx +209 -0
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/picked-box.tsx +21 -0
- package/app/canvas/removed-views-panel.tsx +4 -4
- package/app/canvas/request-node.tsx +151 -0
- package/app/canvas/review-panel.tsx +8 -3
- package/app/canvas/section-node.tsx +6 -133
- package/app/canvas/spec-margin.tsx +4 -1
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/teammates-layer.tsx +205 -0
- package/app/canvas/text-layer.tsx +103 -17
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +7 -6
- package/app/canvas/tool-icons.tsx +24 -56
- package/app/canvas/typing.ts +12 -0
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +40 -42
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/use-canvas-editor.ts +4 -2
- package/app/canvas/xray.ts +3 -12
- package/app/export/player-model.ts +159 -0
- package/app/export/player.tsx +198 -0
- package/app/export.html +31 -0
- package/app/export.tsx +9 -0
- package/app/frame/announce-refreshes.ts +21 -0
- package/app/frame/start-frame.tsx +50 -0
- package/app/frame/view-loads.ts +161 -0
- package/app/frame/views.ts +13 -49
- package/app/frame.tsx +2 -33
- package/app/i18n/locales/en/messages.po +233 -14
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +232 -13
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/dex-glyphs.tsx +219 -0
- package/app/icons/glyphs.tsx +80 -80
- package/app/kit/use-flow.ts +2 -1
- package/app/live/canvas-teammates.ts +90 -0
- package/app/live/studio-api.ts +30 -20
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +45 -14
- package/app/pages/commands-settings.tsx +17 -3
- package/app/pages/render.tsx +39 -11
- package/app/shell/bell.tsx +15 -5
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/presence.tsx +123 -26
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/thread-list.tsx +25 -8
- package/app/shell/working-on.tsx +35 -3
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +39 -11
- package/app/ui/reference.tsx +21 -8
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/bin/sudio.mjs +1 -1
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +5 -5
- package/dist/cli/commands/create.mjs +4 -4
- package/dist/cli/commands/export.d.mts +40 -0
- package/dist/cli/commands/export.mjs +66 -0
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +2 -2
- package/dist/cli/commands/upgrade.mjs +1 -1
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +13 -7
- package/dist/cli/main.d.mts +42 -5
- package/dist/cli/main.mjs +1 -0
- package/dist/config/load.mjs +14 -2
- package/dist/config/project-files.d.mts +11 -0
- package/dist/config/project-files.mjs +23 -2
- package/dist/config/renamed.d.mts +7 -2
- package/dist/config/renamed.mjs +13 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/commands.d.mts +11 -9
- package/dist/content/commands.mjs +22 -16
- package/dist/content/comments-log.mjs +2 -1
- package/dist/content/content.d.mts +13 -143
- package/dist/content/content.mjs +55 -76
- package/dist/content/element-words.d.mts +42 -0
- package/dist/content/element-words.mjs +112 -0
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/hosted-person.d.mts +31 -0
- package/dist/content/hosted-person.mjs +68 -0
- package/dist/content/merge-rules.d.mts +5 -0
- package/dist/content/merge-rules.mjs +17 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/screenshot.mjs +9 -0
- package/dist/content/text-edit.d.mts +24 -14
- package/dist/content/text-edit.mjs +92 -81
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +285 -0
- package/dist/content/thread-module.d.mts +2 -4
- package/dist/content/thread-module.mjs +4 -5
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/agents.d.mts +10 -0
- package/dist/server/agents.mjs +21 -6
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/canvas-presence.d.mts +22 -0
- package/dist/server/canvas-presence.mjs +160 -0
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/command-settings.mjs +1 -1
- package/dist/server/comments/actions.d.mts +145 -0
- package/dist/server/comments/actions.mjs +146 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +67 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +59 -23
- package/dist/server/export/build.d.mts +15 -0
- package/dist/server/export/build.mjs +220 -0
- package/dist/server/export/page.d.mts +25 -0
- package/dist/server/export/page.mjs +40 -0
- package/dist/server/export/plugin.d.mts +31 -0
- package/dist/server/export/plugin.mjs +69 -0
- package/dist/server/export/run.d.mts +9 -0
- package/dist/server/export/run.mjs +61 -0
- package/dist/server/export/save.d.mts +7 -0
- package/dist/server/export/save.mjs +29 -0
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/hosted.d.mts +8 -0
- package/dist/server/hosted.mjs +78 -0
- package/dist/server/live-mirror.mjs +66 -10
- package/dist/server/live.mjs +28 -1
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +9 -8
- package/dist/server/me.d.mts +3 -1
- package/dist/server/me.mjs +8 -2
- package/dist/server/notices.d.mts +1 -1
- package/dist/server/notices.mjs +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +1 -1
- package/dist/server/people.d.mts +8 -3
- package/dist/server/people.mjs +6 -2
- package/dist/server/pictures.d.mts +1 -1
- package/dist/server/pictures.mjs +2 -2
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/prebundle.d.mts +32 -0
- package/dist/server/prebundle.mjs +115 -0
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/problems.d.mts +8 -0
- package/dist/server/problems.mjs +13 -0
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +76 -78
- package/dist/server/source-stamp.d.mts +4 -3
- package/dist/server/source-stamp.mjs +60 -31
- package/dist/server/state.d.mts +19 -10
- package/dist/server/state.mjs +27 -18
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.d.mts +8 -0
- package/dist/server/thread-source.mjs +25 -6
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/export.d.mts +5 -0
- package/dist/server/tools/export.mjs +35 -0
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/place-frame.mjs +16 -16
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +2 -2
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.d.mts +9 -4
- package/dist/server/vite.mjs +65 -63
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/welcome.mjs +2 -1
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.d.mts +4 -0
- package/dist/setup/apply.mjs +5 -4
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +72 -22
- package/dist/setup/design-system-checks.mjs +3 -17
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect/workspace.d.mts +10 -10
- package/dist/setup/detect/workspace.mjs +10 -12
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.d.mts +4 -1
- package/dist/setup/doctor.mjs +8 -6
- package/dist/setup/migrate/dex-folder.d.mts +61 -0
- package/dist/setup/migrate/dex-folder.mjs +544 -0
- package/dist/setup/migrate/files-folder.mjs +1 -1
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/migrations.mjs +4 -0
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/migrate/setup-files.d.mts +5 -0
- package/dist/setup/migrate/setup-files.mjs +115 -0
- package/dist/setup/migrate/studio-state.d.mts +2 -2
- package/dist/setup/migrate/studio-state.mjs +4 -4
- package/dist/setup/placement.d.mts +1 -1
- package/dist/setup/placement.mjs +5 -4
- package/dist/setup/plan.d.mts +5 -5
- package/dist/setup/plan.mjs +8 -12
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +10 -10
- package/dist/setup/prompts.d.mts +2 -1
- package/dist/setup/prompts.mjs +4 -3
- package/dist/setup/questions.mjs +3 -2
- package/dist/setup/starters.d.mts +3 -1
- package/dist/setup/starters.mjs +9 -3
- package/dist/setup/write.d.mts +15 -3
- package/dist/setup/write.mjs +23 -3
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +22 -7
- package/dist/shared/canvas-core.mjs +39 -11
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +55 -0
- package/dist/shared/comments/routes.mjs +39 -0
- package/dist/shared/export-core.d.mts +62 -0
- package/dist/shared/export-core.mjs +101 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/live-core.d.mts +2 -0
- package/dist/shared/live-core.mjs +6 -1
- package/dist/shared/live-presence.d.mts +57 -2
- package/dist/shared/live-presence.mjs +90 -4
- package/dist/shared/page-messages.d.mts +14 -1
- package/dist/shared/page-messages.mjs +30 -3
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/people-core.d.mts +28 -0
- package/dist/shared/people-core.mjs +27 -1
- package/dist/shared/presence-core.d.mts +13 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/references-core.d.mts +4 -0
- package/dist/shared/references-core.mjs +12 -4
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +21 -0
- package/dist/shared/studio-files.mjs +16 -2
- package/dist/shared/studio-routes.d.mts +29 -63
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +29 -6
- package/dist/shared/threads-core.mjs +68 -13
- package/extension/dist/feedback.js +104 -284
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +104 -284
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +4 -4
- package/src/cli/commands/export.ts +78 -0
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/commands/upgrade.ts +1 -1
- package/src/cli/help.ts +13 -7
- package/src/cli/main.ts +1 -0
- package/src/config/load.ts +26 -2
- package/src/config/project-files.ts +36 -6
- package/src/config/renamed.ts +19 -4
- package/src/content/capture.ts +6 -12
- package/src/content/commands.ts +30 -18
- package/src/content/comments-log.ts +4 -1
- package/src/content/content.ts +71 -257
- package/src/content/element-words.ts +175 -0
- package/src/content/flow-specs.ts +2 -1
- package/src/content/hosted-person.ts +107 -0
- package/src/content/merge-rules.ts +29 -0
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/screenshot.ts +14 -0
- package/src/content/text-edit.ts +172 -105
- package/src/content/text-replace.ts +420 -0
- package/src/content/thread-module.ts +2 -4
- package/src/content/trash.ts +1 -1
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/agents.ts +48 -17
- package/src/server/canvas-presence.ts +237 -0
- package/src/server/channel.ts +95 -53
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/command-settings.ts +1 -1
- package/src/server/comments/actions.ts +333 -0
- package/src/server/comments/routes.ts +131 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +94 -33
- package/src/server/export/build.ts +310 -0
- package/src/server/export/page.ts +85 -0
- package/src/server/export/plugin.ts +138 -0
- package/src/server/export/run.ts +79 -0
- package/src/server/export/save.ts +38 -0
- package/src/server/file-lock.ts +205 -54
- package/src/server/hosted.ts +113 -0
- package/src/server/live-mirror.ts +93 -8
- package/src/server/live.ts +46 -1
- package/src/server/machine-update.ts +3 -3
- package/src/server/mcp.ts +15 -14
- package/src/server/me.ts +12 -6
- package/src/server/notices.ts +2 -2
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +13 -3
- package/src/server/pictures.ts +2 -2
- package/src/server/port.ts +94 -20
- package/src/server/prebundle.ts +230 -0
- package/src/server/presence.ts +12 -4
- package/src/server/problems.ts +11 -0
- package/src/server/requests.ts +115 -110
- package/src/server/roster.ts +1 -1
- package/src/server/saved.ts +1 -1
- package/src/server/source-stamp.ts +118 -37
- package/src/server/state.ts +53 -31
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/thread-source.ts +35 -3
- package/src/server/tools/export.ts +56 -0
- package/src/server/tools/place-frame.ts +23 -15
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/thread-list.ts +1 -1
- package/src/server/tools/watch.ts +7 -7
- package/src/server/updates.ts +2 -2
- package/src/server/vite.ts +106 -110
- package/src/server/web-app.ts +11 -9
- package/src/server/welcome.ts +3 -1
- package/src/setup/apply.ts +8 -5
- package/src/setup/create.ts +101 -27
- package/src/setup/design-system-checks.ts +8 -21
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect/workspace.ts +20 -21
- package/src/setup/detect.ts +0 -4
- package/src/setup/doctor.ts +13 -6
- package/src/setup/migrate/dex-folder.ts +842 -0
- package/src/setup/migrate/files-folder.ts +1 -1
- package/src/setup/migrate/guides.ts +3 -1
- package/src/setup/migrate/migrations.ts +8 -2
- package/src/setup/migrate/setup-files.ts +198 -0
- package/src/setup/migrate/studio-state.ts +12 -10
- package/src/setup/own-app.ts +1 -1
- package/src/setup/placement.ts +7 -6
- package/src/setup/plan.ts +13 -18
- package/src/setup/project.ts +11 -10
- package/src/setup/prompts.ts +5 -4
- package/src/setup/questions.ts +6 -3
- package/src/setup/starters.ts +11 -4
- package/src/setup/write.ts +34 -3
- package/src/shared/canvas-core.ts +48 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +81 -0
- package/src/shared/export-core.ts +198 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/live-core.ts +8 -0
- package/src/shared/live-presence.ts +171 -2
- package/src/shared/page-messages.ts +38 -2
- package/src/shared/page-review.ts +11 -16
- package/src/shared/people-core.ts +44 -0
- package/src/shared/presence-core.ts +18 -2
- package/src/shared/references-core.ts +22 -3
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +29 -1
- package/src/shared/studio-routes.ts +32 -65
- package/src/shared/threads-core.ts +134 -12
- package/templates/methods/explore.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +2 -1
- package/templates/rules/canvas-frames.md +6 -3
- package/templates/rules/commands.md +1 -0
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/studio.md +17 -11
- package/templates/skills/comprehend/SKILL.md +56 -0
- package/templates/skills/distill/SKILL.md +172 -0
- package/templates/skills/export-prototype/SKILL.md +35 -0
- package/templates/skills/riff/SKILL.md +21 -0
- package/templates/skills/riff-deep/SKILL.md +40 -0
- package/templates/skills/riff-max/SKILL.md +46 -0
- package/templates/skills/riff-state/SKILL.md +45 -0
- package/templates/skills/riff-up/SKILL.md +38 -0
- package/templates/skills/riff-wide/SKILL.md +40 -0
- package/templates/starters/standalone/README.md +1 -1
- package/templates/starters/turborepo/README.md +2 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
- package/templates/starters/vite/README.md +1 -1
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { viewHref } from "./prototypes-core.mjs";
|
|
2
1
|
import { isRecord, isText } from "./checks.mjs";
|
|
3
2
|
import { gridProblems } from "./frame-grids.mjs";
|
|
3
|
+
import { viewHref } from "./prototypes-core.mjs";
|
|
4
4
|
import { isSketch, sketchFrameProblems } from "./sketch-core.mjs";
|
|
5
5
|
//#region src/shared/canvas-core.ts
|
|
6
6
|
/** The page each viewport shows, in CSS pixels. */
|
|
@@ -502,6 +502,34 @@ const insertOver = (row, frame, below, beside) => {
|
|
|
502
502
|
* on its step, level with the frame it names. Returns the frame's id.
|
|
503
503
|
*/
|
|
504
504
|
const insertInCell = (row, frame, cell) => cell.under !== void 0 && insertUnder(row, frame, cell.under) || cell.over !== void 0 && insertOver(row, frame, cell.over, cell.beside) || insertAt(row, frame, Math.max(1, Math.round(cell.step)), cell.beside);
|
|
505
|
+
/**
|
|
506
|
+
* The cell a request for a new view fills: a step in its row, or in a new
|
|
507
|
+
* row, right above the row `above` names (a step in a row has no row to go
|
|
508
|
+
* above), else at the end of the section.
|
|
509
|
+
*/
|
|
510
|
+
const requestCell = ({ above, row, section, step }) => {
|
|
511
|
+
if (row) return {
|
|
512
|
+
section,
|
|
513
|
+
row,
|
|
514
|
+
step
|
|
515
|
+
};
|
|
516
|
+
return above ? {
|
|
517
|
+
section,
|
|
518
|
+
above,
|
|
519
|
+
step
|
|
520
|
+
} : {
|
|
521
|
+
section,
|
|
522
|
+
step
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Put a new row among a section's rows: right above the row `above` names,
|
|
527
|
+
* as the + on the line between two rows asks, else below the others.
|
|
528
|
+
*/
|
|
529
|
+
const addRowAbove = (rows, row, above) => {
|
|
530
|
+
const at = rows.findIndex((each) => each.id === above);
|
|
531
|
+
rows.splice(at < 0 ? rows.length : at, 0, row);
|
|
532
|
+
};
|
|
505
533
|
/** A new, empty row for a section with `rows`, its id from `name`. A row
|
|
506
534
|
* has no name of its own: only its frames are named. */
|
|
507
535
|
const emptyRow = (rows, name) => ({
|
|
@@ -561,14 +589,14 @@ const sizeOf = (frame) => {
|
|
|
561
589
|
};
|
|
562
590
|
/**
|
|
563
591
|
* Put a frame for a view in a cell: on its step in its row, or in a new row
|
|
564
|
-
*
|
|
565
|
-
* size
|
|
592
|
+
* when the cell names none (addRowAbove). It takes `viewport`'s size, else
|
|
593
|
+
* `size`, else the size of the frame before it, else `fallback` (the team's
|
|
566
594
|
* default device), else desktop's. A frame for the view already on that step
|
|
567
595
|
* (in that row, or any row of the section for a new row) is kept as it is.
|
|
568
596
|
* Returns a new canvas, the frame's key and whether it was added; or the
|
|
569
597
|
* problem when the section or row is not there.
|
|
570
598
|
*/
|
|
571
|
-
function placeViewInCell(canvas, cell, { view, viewport, fallback }) {
|
|
599
|
+
function placeViewInCell(canvas, cell, { view, viewport, size, fallback }) {
|
|
572
600
|
const section = canvas.sections.find((entry) => entry.id === cell.section);
|
|
573
601
|
if (!section) return { problem: `No section "${cell.section}" on the canvas.` };
|
|
574
602
|
const rows = cell.row ? section.rows.filter((entry) => entry.id === cell.row) : section.rows;
|
|
@@ -590,7 +618,7 @@ function placeViewInCell(canvas, cell, { view, viewport, fallback }) {
|
|
|
590
618
|
const placed = placeFrameInCell(canvas, cell, {
|
|
591
619
|
id: view,
|
|
592
620
|
view,
|
|
593
|
-
...viewport ? { viewport } : sizedView(sizeForCell(canvas, cell) ?? fallback ?? VIEWPORTS.desktop)
|
|
621
|
+
...viewport ? { viewport } : sizedView(size ?? sizeForCell(canvas, cell) ?? fallback ?? VIEWPORTS.desktop)
|
|
594
622
|
});
|
|
595
623
|
return "problem" in placed ? placed : {
|
|
596
624
|
...placed,
|
|
@@ -598,10 +626,10 @@ function placeViewInCell(canvas, cell, { view, viewport, fallback }) {
|
|
|
598
626
|
};
|
|
599
627
|
}
|
|
600
628
|
/**
|
|
601
|
-
* Put a frame in a cell: on its step in its row, or in a new row
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
629
|
+
* Put a frame in a cell: on its step in its row, or in a new row when the
|
|
630
|
+
* cell names none (addRowAbove). A frame already on that step, and those
|
|
631
|
+
* after it, move one step along. Returns a new canvas and the frame's key,
|
|
632
|
+
* or the problem when the section or row is not there.
|
|
605
633
|
*/
|
|
606
634
|
function placeFrameInCell(canvas, cell, frame) {
|
|
607
635
|
const next = structuredClone(canvas);
|
|
@@ -611,7 +639,7 @@ function placeFrameInCell(canvas, cell, frame) {
|
|
|
611
639
|
if (cell.row && !row) return { problem: `No row "${cell.row}" in section "${cell.section}". Leave the row out for a new one.` };
|
|
612
640
|
if (!row) {
|
|
613
641
|
row = emptyRow(into.rows);
|
|
614
|
-
into.rows.
|
|
642
|
+
addRowAbove(into.rows, row, cell.above);
|
|
615
643
|
}
|
|
616
644
|
const id = insertInCell(row, frame, cell);
|
|
617
645
|
return {
|
|
@@ -856,4 +884,4 @@ function rowTitleProblems(canvas) {
|
|
|
856
884
|
return sections.flatMap((section) => (section?.rows ?? []).filter((row) => isRecord(row) && "title" in row).map((row) => `section "${section?.id}" › row "${row?.id}": a row has no "title"; name its frame instead (npx dex upgrade moves it there)`));
|
|
857
885
|
}
|
|
858
886
|
//#endregion
|
|
859
|
-
export { NOTE_SIZE, OWN_FRAME_TITLE, SLIDE_GRID, SLIDE_LAYOUTS, SLIDE_SIZE, SPEC_SIZE, VIEWPORTS, appendOwnFrame, appendRow, appendSection, canvasFrames, canvasProblems, emptyRow, foldRowTitles, foldedTitle, frameKey, frameKind, frameTitle, humanise, idFor, insertAt, insertInCell, insertRowBelow, insertUnder, isFrameUid, isNoteFrame, isNotePath, isSlideFrame, isSlideLayout, isSlidePath, isSnapshotImage, isSpecPath, kinded, legacyFrameUid, madeInNewerDex, newFrameUid, normaliseRow, parseFrameKey, pinSteps, placeFrameInCell, placeViewInCell, placedAt, rowTitleProblems, sameCell, sectionPosition, shapeProblems, sizeForCell, sizedView, specName, specSizeOf, stepsOf, uniqueId, unknownReason, viewFramePage, viewOf };
|
|
887
|
+
export { NOTE_SIZE, OWN_FRAME_TITLE, SLIDE_GRID, SLIDE_LAYOUTS, SLIDE_SIZE, SPEC_SIZE, VIEWPORTS, addRowAbove, appendOwnFrame, appendRow, appendSection, canvasFrames, canvasProblems, emptyRow, foldRowTitles, foldedTitle, frameKey, frameKind, frameTitle, humanise, idFor, insertAt, insertInCell, insertRowBelow, insertUnder, isFrameUid, isNoteFrame, isNotePath, isSlideFrame, isSlideLayout, isSlidePath, isSnapshotImage, isSpecPath, kinded, legacyFrameUid, madeInNewerDex, newFrameUid, normaliseRow, parseFrameKey, pinSteps, placeFrameInCell, placeViewInCell, placedAt, requestCell, rowTitleProblems, sameCell, sectionPosition, shapeProblems, sizeForCell, sizedView, specName, specSizeOf, stepsOf, uniqueId, unknownReason, viewFramePage, viewOf };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { CanvasPoint, SlideLayout, Viewport } from "./canvas-core.mjs";
|
|
2
|
+
import { Sketch } from "./sketch-core.mjs";
|
|
3
|
+
import { FrameGrid, FrameGuide } from "./frame-grids.mjs";
|
|
4
|
+
//#region src/shared/canvas-file.d.ts
|
|
5
|
+
interface FrameBase {
|
|
6
|
+
/**
|
|
7
|
+
* On a column's first frame: the id of a frame stacked further down a
|
|
8
|
+
* column to its left, in its row, for this column to start level with
|
|
9
|
+
* rather than at the row's top.
|
|
10
|
+
*/
|
|
11
|
+
beside?: string;
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* The step this frame shows, counted from 1: its column on the canvas. Leave
|
|
15
|
+
* out to follow the previous frame in the row.
|
|
16
|
+
*/
|
|
17
|
+
step?: number;
|
|
18
|
+
title?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Which frame this is, for good: kept when it moves or is renamed, new on
|
|
21
|
+
* a copy. Picks follow it. Given to the saver's frames that have none when
|
|
22
|
+
* they save.
|
|
23
|
+
*/
|
|
24
|
+
uid?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Stacked directly below the frame before it in its row, in that frame's
|
|
27
|
+
* column, rather than in a column of its own.
|
|
28
|
+
*/
|
|
29
|
+
under?: true;
|
|
30
|
+
}
|
|
31
|
+
/** A live, interactive render of one of the prototype's views. */
|
|
32
|
+
export interface ViewFrame extends FrameBase {
|
|
33
|
+
doc?: undefined;
|
|
34
|
+
/** The frame's own grids, shown in place of the canvas's (Figma's, pasted). */
|
|
35
|
+
grids?: FrameGrid[];
|
|
36
|
+
/** Guide lines on the frame. */
|
|
37
|
+
guides?: FrameGuide[];
|
|
38
|
+
params?: Record<string, string>;
|
|
39
|
+
/** A fixed size in pixels, for a snapshot of one element; else the viewport's. */
|
|
40
|
+
size?: {
|
|
41
|
+
height: number;
|
|
42
|
+
width: number;
|
|
43
|
+
};
|
|
44
|
+
sketch?: undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Where a snapshot was captured from, and when; and the image it is, when
|
|
47
|
+
* it is one, in the prototype's folder: "images/….png".
|
|
48
|
+
*/
|
|
49
|
+
snapshot?: {
|
|
50
|
+
captured: string;
|
|
51
|
+
image?: string;
|
|
52
|
+
url: string;
|
|
53
|
+
};
|
|
54
|
+
spec?: undefined;
|
|
55
|
+
view: string;
|
|
56
|
+
viewport?: Viewport;
|
|
57
|
+
}
|
|
58
|
+
/** A markdown document from the prototype's docs folder. */
|
|
59
|
+
export interface DocFrame extends FrameBase {
|
|
60
|
+
doc: string;
|
|
61
|
+
/** A size of its own in pixels, set by resizing it; else 640 by 900. */
|
|
62
|
+
size?: {
|
|
63
|
+
height: number;
|
|
64
|
+
width: number;
|
|
65
|
+
};
|
|
66
|
+
sketch?: undefined;
|
|
67
|
+
spec?: undefined;
|
|
68
|
+
view?: undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A spec, edited in place on the canvas: a markdown file in its placer's
|
|
72
|
+
* folder. In a section, it is that section's spec; outside any section, it is part
|
|
73
|
+
* of the file spec.
|
|
74
|
+
*/
|
|
75
|
+
export interface SpecFrame extends FrameBase {
|
|
76
|
+
doc?: undefined;
|
|
77
|
+
/**
|
|
78
|
+
* A slide's layout: its first frame beside its words (the default), or
|
|
79
|
+
* centred above them. Only a slide (people/<person>/slides/) has one.
|
|
80
|
+
*/
|
|
81
|
+
layout?: SlideLayout;
|
|
82
|
+
/**
|
|
83
|
+
* A width of its own in pixels, set by resizing it; else 520. With a
|
|
84
|
+
* height, it is never taller than that, and scrolls; without one, it is
|
|
85
|
+
* as tall as its words (never less than 240). A slide's is fixed, both
|
|
86
|
+
* ways: 1920 by 1080 until resized.
|
|
87
|
+
*/
|
|
88
|
+
size?: {
|
|
89
|
+
height?: number;
|
|
90
|
+
width: number;
|
|
91
|
+
};
|
|
92
|
+
sketch?: undefined;
|
|
93
|
+
/** Its file, from the file's folder: "people/ana/specs/checkout.md". */
|
|
94
|
+
spec: string;
|
|
95
|
+
view?: undefined;
|
|
96
|
+
}
|
|
97
|
+
export interface SketchFrame extends FrameBase {
|
|
98
|
+
doc?: undefined;
|
|
99
|
+
sketch: Sketch;
|
|
100
|
+
spec?: undefined;
|
|
101
|
+
/** Required, as an older Dex names a frame by its title or view. */
|
|
102
|
+
title: string;
|
|
103
|
+
view?: undefined;
|
|
104
|
+
}
|
|
105
|
+
declare const readFromDisk: unique symbol;
|
|
106
|
+
/**
|
|
107
|
+
* A frame this Dex cannot show: a kind from a newer Dex, or a mistake.
|
|
108
|
+
* Only reading a canvas makes one, so Dex never writes a frame that shows
|
|
109
|
+
* nothing.
|
|
110
|
+
*/
|
|
111
|
+
export interface UnknownFrame extends FrameBase {
|
|
112
|
+
doc?: undefined;
|
|
113
|
+
sketch?: undefined;
|
|
114
|
+
spec?: undefined;
|
|
115
|
+
view?: undefined;
|
|
116
|
+
readonly [readFromDisk]: true;
|
|
117
|
+
}
|
|
118
|
+
export type Frame = ViewFrame | DocFrame | SpecFrame | SketchFrame | UnknownFrame;
|
|
119
|
+
/**
|
|
120
|
+
* One pass through the section's steps: the main path, an error state, an
|
|
121
|
+
* alternative. Its frames are the steps, left to right.
|
|
122
|
+
*/
|
|
123
|
+
export interface Row {
|
|
124
|
+
/**
|
|
125
|
+
* In a person's copy of someone else's section: the id of their row this one
|
|
126
|
+
* is shown under (people-core.ts).
|
|
127
|
+
*/
|
|
128
|
+
after?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Whose it is, when not its section's: someone's version of a row in
|
|
131
|
+
* another person's section. Set when the canvas is read, never written.
|
|
132
|
+
*/
|
|
133
|
+
author?: string;
|
|
134
|
+
/** The id of the section in its author's file that keeps it. */
|
|
135
|
+
copy?: string;
|
|
136
|
+
frames: Frame[];
|
|
137
|
+
id: string;
|
|
138
|
+
title?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A section. Rows below the first are iterations of it. With `at`, a frame of
|
|
142
|
+
* its own instead: one frame, drawn at that point, with no section around it.
|
|
143
|
+
*/
|
|
144
|
+
export interface Section {
|
|
145
|
+
/** Where a frame of its own's top left corner is, in canvas pixels. */
|
|
146
|
+
at?: CanvasPoint;
|
|
147
|
+
/**
|
|
148
|
+
* Whose it is: the person whose people/<person>/canvas.json it is in. Set
|
|
149
|
+
* when the canvas is read, never written; only they change it.
|
|
150
|
+
*/
|
|
151
|
+
author?: string;
|
|
152
|
+
/** The id of the section it is a copy of, shown right below it. */
|
|
153
|
+
copyOf?: string;
|
|
154
|
+
/** When it was added, as an ISO date. */
|
|
155
|
+
created?: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
/** Whose section it was copied from, when it is a copy. */
|
|
158
|
+
from?: string;
|
|
159
|
+
id: string;
|
|
160
|
+
/**
|
|
161
|
+
* Where the section's area starts, its top left corner in canvas pixels,
|
|
162
|
+
* once someone has drawn it or dragged it there. None stacks it with the
|
|
163
|
+
* others, top to bottom.
|
|
164
|
+
*/
|
|
165
|
+
position?: CanvasPoint;
|
|
166
|
+
rows: Row[];
|
|
167
|
+
/**
|
|
168
|
+
* The least size of a section's area, in canvas pixels, once someone has
|
|
169
|
+
* sized it or frames have left it: its frames still grow it, but it never
|
|
170
|
+
* shrinks below this.
|
|
171
|
+
*/
|
|
172
|
+
size?: {
|
|
173
|
+
height: number;
|
|
174
|
+
width: number;
|
|
175
|
+
};
|
|
176
|
+
title: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* canvas.json: sections stacked top to bottom, and frames of their own where
|
|
180
|
+
* they were drawn. In each section, steps run left to right and iterations
|
|
181
|
+
* (states, errors, alternatives) top to bottom.
|
|
182
|
+
*/
|
|
183
|
+
export interface Canvas {
|
|
184
|
+
/**
|
|
185
|
+
* Set in a person's file once their frames have uids: from then on, a
|
|
186
|
+
* frame of theirs with none is new.
|
|
187
|
+
*/
|
|
188
|
+
frameUids?: true;
|
|
189
|
+
/**
|
|
190
|
+
* Whose sections come first, as the canvas was read: each
|
|
191
|
+
* person by when they joined. Never saved.
|
|
192
|
+
*/
|
|
193
|
+
people?: readonly string[];
|
|
194
|
+
sections: Section[];
|
|
195
|
+
/**
|
|
196
|
+
* Whose canvas.json has given its frames uids, as the canvas was read: a
|
|
197
|
+
* frame of theirs with none is new. Never saved.
|
|
198
|
+
*/
|
|
199
|
+
uidsGiven?: readonly string[];
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Sketch } from "../sketch-core.mjs";
|
|
2
|
+
import { ThreadAudience, ThreadStatus, ThreadTarget, ThreadWithPrototype } from "../threads-core.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/shared/comments/routes.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A comment to start: what it is on, its first message (left out with a
|
|
7
|
+
* wireframe), who it is for, and a wireframe for an agent to build.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NEW_COMMENT: z.ZodObject<{
|
|
10
|
+
target: z.ZodCustom<ThreadTarget, ThreadTarget>;
|
|
11
|
+
body: z.ZodOptional<z.ZodString>;
|
|
12
|
+
for: z.ZodOptional<z.ZodCustom<ThreadAudience, ThreadAudience>>;
|
|
13
|
+
sketch: z.ZodOptional<z.ZodCustom<Sketch, Sketch>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
/**
|
|
16
|
+
* A person's change to a comment, by its id: a reply, a status, who it is
|
|
17
|
+
* for, a reaction, an edit or removal of their own message (`on`, by its
|
|
18
|
+
* `at`), a review's comment hidden from the published site, or where a
|
|
19
|
+
* request for a new view waits and its size (`target`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const COMMENT_CHANGE: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
body: z.ZodOptional<z.ZodString>;
|
|
24
|
+
edit: z.ZodOptional<z.ZodString>;
|
|
25
|
+
for: z.ZodOptional<z.ZodCustom<ThreadAudience, ThreadAudience>>;
|
|
26
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
on: z.ZodOptional<z.ZodString>;
|
|
28
|
+
react: z.ZodOptional<z.ZodString>;
|
|
29
|
+
remove: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
status: z.ZodOptional<z.ZodCustom<ThreadStatus, ThreadStatus>>;
|
|
31
|
+
target: z.ZodOptional<z.ZodCustom<ThreadTarget, ThreadTarget>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
/**
|
|
34
|
+
* Each comment request, by name, and its answer to each method it takes.
|
|
35
|
+
* The query a request needs is in its comment.
|
|
36
|
+
*/
|
|
37
|
+
export interface CommentAnswers {
|
|
38
|
+
/** ?slug= for one prototype's, or none for every one's. */
|
|
39
|
+
threads: {
|
|
40
|
+
GET: ThreadWithPrototype[];
|
|
41
|
+
POST: ThreadWithPrototype;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The bodies they take, by request and method, as the schemas above check them. */
|
|
45
|
+
export interface CommentBodies {
|
|
46
|
+
/** A comment to start, or a change to one, by its id. */
|
|
47
|
+
threads: {
|
|
48
|
+
POST: z.input<typeof NEW_COMMENT> | z.input<typeof COMMENT_CHANGE>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** The comment requests and the methods each takes. */
|
|
52
|
+
export declare const COMMENT_ROUTES: {
|
|
53
|
+
readonly threads: readonly ["GET", "POST"];
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isRecord } from "../checks.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/shared/comments/routes.ts
|
|
4
|
+
/** An object, of a type whose fields the thread rules check. */
|
|
5
|
+
const record = (what) => z.custom(isRecord, `Expected ${what}`);
|
|
6
|
+
/** Text, of a type whose words the thread rules check. */
|
|
7
|
+
const word = () => z.custom((value) => typeof value === "string", "Expected text");
|
|
8
|
+
/**
|
|
9
|
+
* A comment to start: what it is on, its first message (left out with a
|
|
10
|
+
* wireframe), who it is for, and a wireframe for an agent to build.
|
|
11
|
+
*/
|
|
12
|
+
const NEW_COMMENT = z.object({
|
|
13
|
+
target: record("what the comment is on, with its kind"),
|
|
14
|
+
body: z.string().optional(),
|
|
15
|
+
for: word().optional(),
|
|
16
|
+
sketch: record("a wireframe").optional()
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* A person's change to a comment, by its id: a reply, a status, who it is
|
|
20
|
+
* for, a reaction, an edit or removal of their own message (`on`, by its
|
|
21
|
+
* `at`), a review's comment hidden from the published site, or where a
|
|
22
|
+
* request for a new view waits and its size (`target`).
|
|
23
|
+
*/
|
|
24
|
+
const COMMENT_CHANGE = z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
body: z.string().optional(),
|
|
27
|
+
edit: z.string().optional(),
|
|
28
|
+
for: word().optional(),
|
|
29
|
+
hidden: z.boolean().optional(),
|
|
30
|
+
on: z.string().optional(),
|
|
31
|
+
react: z.string().optional(),
|
|
32
|
+
remove: z.boolean().optional(),
|
|
33
|
+
status: word().optional(),
|
|
34
|
+
target: record("the request's cell, as a view's").optional()
|
|
35
|
+
});
|
|
36
|
+
/** The comment requests and the methods each takes. */
|
|
37
|
+
const COMMENT_ROUTES = { threads: ["GET", "POST"] };
|
|
38
|
+
//#endregion
|
|
39
|
+
export { COMMENT_CHANGE, COMMENT_ROUTES, NEW_COMMENT };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Canvas, ViewFrame } from "./canvas-file.mjs";
|
|
2
|
+
//#region src/shared/export-core.d.ts
|
|
3
|
+
/** What an export makes. */
|
|
4
|
+
export declare const EXPORT_KINDS: readonly ["clickable", "pages", "content", "source"];
|
|
5
|
+
export type ExportKind = (typeof EXPORT_KINDS)[number];
|
|
6
|
+
/**
|
|
7
|
+
* Kinds an agent prepares first: the content pack's copy moves into
|
|
8
|
+
* content.json, the source pack's views are made to stand alone.
|
|
9
|
+
*/
|
|
10
|
+
export declare const AGENT_PREPARED: ReadonlySet<ExportKind>;
|
|
11
|
+
/** The skill an agent follows to prepare an export (templates/skills/). */
|
|
12
|
+
export declare const EXPORT_COMMAND = "export-prototype";
|
|
13
|
+
/** What to export: frames by key, or whole sections; none is every section. */
|
|
14
|
+
export interface ExportChoice {
|
|
15
|
+
/** People can switch between the exported flows. */
|
|
16
|
+
flows?: boolean;
|
|
17
|
+
frames?: readonly string[];
|
|
18
|
+
kind: ExportKind;
|
|
19
|
+
sections?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/** A view frame as the exported page has it: no uids, grids or snapshots. */
|
|
22
|
+
export type ExportedFrame = Pick<ViewFrame, "id" | "params" | "size" | "step" | "title" | "under" | "view" | "viewport">;
|
|
23
|
+
export interface ExportedRow {
|
|
24
|
+
frames: ExportedFrame[];
|
|
25
|
+
id: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ExportedSection {
|
|
29
|
+
id: string;
|
|
30
|
+
rows: ExportedRow[];
|
|
31
|
+
title?: string;
|
|
32
|
+
}
|
|
33
|
+
/** What the exported page reads, as `window.dexExport`. */
|
|
34
|
+
export interface ExportData {
|
|
35
|
+
flows: boolean;
|
|
36
|
+
sections: ExportedSection[];
|
|
37
|
+
slug: string;
|
|
38
|
+
title: string;
|
|
39
|
+
}
|
|
40
|
+
/** The global the exported page's data is set on. */
|
|
41
|
+
export declare const EXPORT_GLOBAL = "dexExport";
|
|
42
|
+
/** The global a content pack's content.js sets. */
|
|
43
|
+
export declare const CONTENT_GLOBAL = "dexContent";
|
|
44
|
+
/** The frames chosen, as the exported page plays them, and the views they show. */
|
|
45
|
+
export interface ExportSelection {
|
|
46
|
+
sections: ExportedSection[];
|
|
47
|
+
views: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The view frames a choice takes from a canvas, section by section, row by
|
|
51
|
+
* row, in the canvas's order; every other kind of frame (docs, notes,
|
|
52
|
+
* sketches, snapshot images) stays behind. Throws naming a frame or section
|
|
53
|
+
* the canvas does not have, or when nothing is left to export.
|
|
54
|
+
*/
|
|
55
|
+
export declare function exportSelection(canvas: Pick<Canvas, "sections">, choice: Pick<ExportChoice, "frames" | "sections">): ExportSelection;
|
|
56
|
+
/** The address of a frame on the exported page: its view, with its params. */
|
|
57
|
+
export declare const exportedPath: (slug: string, frame: ExportedFrame) => string;
|
|
58
|
+
/** What an export's zip is called, from its file's title. */
|
|
59
|
+
export declare const exportFileName: (title: string) => string;
|
|
60
|
+
/** What is wrong with an export asked for over the wire; none when it is fine. */
|
|
61
|
+
export declare function exportChoiceProblems(body: unknown): string[];
|
|
62
|
+
//#endregion
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { isOneOf } from "./checks.mjs";
|
|
2
|
+
import { slugify } from "./prototypes-core.mjs";
|
|
3
|
+
import { canvasFrames, viewOf } from "./canvas-core.mjs";
|
|
4
|
+
//#region src/shared/export-core.ts
|
|
5
|
+
/** What an export makes. */
|
|
6
|
+
const EXPORT_KINDS = [
|
|
7
|
+
"clickable",
|
|
8
|
+
"pages",
|
|
9
|
+
"content",
|
|
10
|
+
"source"
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Kinds an agent prepares first: the content pack's copy moves into
|
|
14
|
+
* content.json, the source pack's views are made to stand alone.
|
|
15
|
+
*/
|
|
16
|
+
const AGENT_PREPARED = /* @__PURE__ */ new Set(["content", "source"]);
|
|
17
|
+
/** The skill an agent follows to prepare an export (templates/skills/). */
|
|
18
|
+
const EXPORT_COMMAND = "export-prototype";
|
|
19
|
+
/** The global the exported page's data is set on. */
|
|
20
|
+
const EXPORT_GLOBAL = "dexExport";
|
|
21
|
+
/** The global a content pack's content.js sets. */
|
|
22
|
+
const CONTENT_GLOBAL = "dexContent";
|
|
23
|
+
const exportedFrame = (frame) => ({
|
|
24
|
+
id: frame.id,
|
|
25
|
+
view: frame.view,
|
|
26
|
+
...frame.params ? { params: frame.params } : {},
|
|
27
|
+
...frame.size ? { size: frame.size } : {},
|
|
28
|
+
...frame.step === void 0 ? {} : { step: frame.step },
|
|
29
|
+
...frame.title ? { title: frame.title } : {},
|
|
30
|
+
...frame.under ? { under: frame.under } : {},
|
|
31
|
+
...frame.viewport ? { viewport: frame.viewport } : {}
|
|
32
|
+
});
|
|
33
|
+
/** The rows and sections a list of frames, in the canvas's order, fills. */
|
|
34
|
+
const sectionsOf = (canvas, taken) => canvas.sections.flatMap((section) => {
|
|
35
|
+
const rows = section.rows.flatMap((row) => {
|
|
36
|
+
const frames = taken.filter(({ address }) => address.section === section.id && address.row === row.id).map(({ frame }) => exportedFrame(frame));
|
|
37
|
+
return frames.length > 0 ? [{
|
|
38
|
+
id: row.id,
|
|
39
|
+
frames,
|
|
40
|
+
...row.title ? { title: row.title } : {}
|
|
41
|
+
}] : [];
|
|
42
|
+
});
|
|
43
|
+
return rows.length > 0 ? [{
|
|
44
|
+
id: section.id,
|
|
45
|
+
rows,
|
|
46
|
+
...section.title ? { title: section.title } : {}
|
|
47
|
+
}] : [];
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* The view frames a choice takes from a canvas, section by section, row by
|
|
51
|
+
* row, in the canvas's order; every other kind of frame (docs, notes,
|
|
52
|
+
* sketches, snapshot images) stays behind. Throws naming a frame or section
|
|
53
|
+
* the canvas does not have, or when nothing is left to export.
|
|
54
|
+
*/
|
|
55
|
+
function exportSelection(canvas, choice) {
|
|
56
|
+
const frames = new Set(choice.frames ?? []);
|
|
57
|
+
const sections = new Set(choice.sections ?? []);
|
|
58
|
+
const everything = frames.size === 0 && sections.size === 0;
|
|
59
|
+
const all = canvasFrames(canvas);
|
|
60
|
+
const known = /* @__PURE__ */ new Set([...canvas.sections.map((section) => section.id), ...all.map(({ key }) => key)]);
|
|
61
|
+
const unknown = [...frames, ...sections].filter((key) => !known.has(key));
|
|
62
|
+
if (unknown.length > 0) throw new Error(`This file has no frame or section ${unknown.join(", ")}.`);
|
|
63
|
+
const taken = all.flatMap(({ address, frame, key }) => {
|
|
64
|
+
const view = viewOf(frame);
|
|
65
|
+
return (everything || sections.has(address.section) || frames.has(key)) && view && !view.snapshot?.image ? [{
|
|
66
|
+
address,
|
|
67
|
+
frame: view,
|
|
68
|
+
key
|
|
69
|
+
}] : [];
|
|
70
|
+
});
|
|
71
|
+
if (taken.length === 0) throw new Error("None of these frames shows a view, so there is nothing to export.");
|
|
72
|
+
return {
|
|
73
|
+
sections: sectionsOf(canvas, taken),
|
|
74
|
+
views: [...new Set(taken.map(({ frame }) => frame.view))].sort()
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** The address of a frame on the exported page: its view, with its params. */
|
|
78
|
+
const exportedPath = (slug, frame) => {
|
|
79
|
+
const search = new URLSearchParams(frame.params).toString();
|
|
80
|
+
return `/files/${slug}/views/${frame.view}${search ? `?${search}` : ""}`;
|
|
81
|
+
};
|
|
82
|
+
/** What an export's zip is called, from its file's title. */
|
|
83
|
+
const exportFileName = (title) => `${slugify(title) || "prototype"}.zip`;
|
|
84
|
+
/** Left out, or a list of keys of `parts` parts each, none of them empty. */
|
|
85
|
+
const isKeyList = (value, parts) => value === void 0 || Array.isArray(value) && value.every((key) => {
|
|
86
|
+
const split = typeof key === "string" ? key.split("/") : [];
|
|
87
|
+
return split.length === parts && split.every((part) => part.length > 0);
|
|
88
|
+
});
|
|
89
|
+
/** What is wrong with an export asked for over the wire; none when it is fine. */
|
|
90
|
+
function exportChoiceProblems(body) {
|
|
91
|
+
if (!body || typeof body !== "object") return ["Send what to export: { kind, frames?, sections?, flows? }."];
|
|
92
|
+
const { kind, frames, sections, flows } = body;
|
|
93
|
+
const problems = [];
|
|
94
|
+
if (!isOneOf(EXPORT_KINDS, kind)) problems.push(`kind is one of ${EXPORT_KINDS.join(", ")}.`);
|
|
95
|
+
if (!isKeyList(frames, 3)) problems.push("frames is a list of frame keys, section/row/frame.");
|
|
96
|
+
if (!isKeyList(sections, 1)) problems.push("sections is a list of section ids.");
|
|
97
|
+
if (flows !== void 0 && typeof flows !== "boolean") problems.push("flows is true or false.");
|
|
98
|
+
return problems;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { AGENT_PREPARED, CONTENT_GLOBAL, EXPORT_COMMAND, EXPORT_GLOBAL, EXPORT_KINDS, exportChoiceProblems, exportFileName, exportSelection, exportedPath };
|
|
@@ -76,4 +76,12 @@ export interface SendOptions {
|
|
|
76
76
|
}
|
|
77
77
|
/** Send feedback to the relay, if it is ready; never throws. */
|
|
78
78
|
export declare const sendFeedback: (feedback: Feedback, { fetch, url }?: SendOptions) => Promise<Sent>;
|
|
79
|
+
/**
|
|
80
|
+
* Post a form to a relay and read its answer: the tracker's id, or why not.
|
|
81
|
+
* A form, so a simple request with no preflight; sign-ups travel this way
|
|
82
|
+
* too (signup.ts). Never throws.
|
|
83
|
+
*/
|
|
84
|
+
export declare const postToRelay: (url: string, form: FormData, fetch: NonNullable<SendOptions["fetch"]>) => Promise<Exclude<Sent, {
|
|
85
|
+
reason: "invalid";
|
|
86
|
+
}>>;
|
|
79
87
|
//#endregion
|
package/dist/shared/feedback.mjs
CHANGED
|
@@ -154,10 +154,18 @@ const sendFeedback = async (feedback, { fetch = globalThis.fetch, url = FEEDBACK
|
|
|
154
154
|
reason: "invalid",
|
|
155
155
|
problems
|
|
156
156
|
};
|
|
157
|
+
return await postToRelay(url, toForm(feedback), fetch);
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Post a form to a relay and read its answer: the tracker's id, or why not.
|
|
161
|
+
* A form, so a simple request with no preflight; sign-ups travel this way
|
|
162
|
+
* too (signup.ts). Never throws.
|
|
163
|
+
*/
|
|
164
|
+
const postToRelay = async (url, form, fetch) => {
|
|
157
165
|
try {
|
|
158
166
|
const response = await fetch(url, {
|
|
159
167
|
method: "POST",
|
|
160
|
-
body:
|
|
168
|
+
body: form
|
|
161
169
|
});
|
|
162
170
|
if (response.ok) {
|
|
163
171
|
const { id } = await response.json();
|
|
@@ -189,4 +197,4 @@ const sendFeedback = async (feedback, { fetch = globalThis.fetch, url = FEEDBACK
|
|
|
189
197
|
}
|
|
190
198
|
};
|
|
191
199
|
//#endregion
|
|
192
|
-
export { FEEDBACK_ACCEPT, FEEDBACK_KINDS, FEEDBACK_LIMITS, FEEDBACK_SOURCES, FEEDBACK_URL, checkFeedback, feedbackFileType, feedbackTypeOfName, isFeedbackFile, receiveFeedback, sendFeedback };
|
|
200
|
+
export { FEEDBACK_ACCEPT, FEEDBACK_KINDS, FEEDBACK_LIMITS, FEEDBACK_SOURCES, FEEDBACK_URL, checkFeedback, feedbackFileType, feedbackTypeOfName, isFeedbackFile, postToRelay, receiveFeedback, sendFeedback };
|
|
@@ -46,6 +46,8 @@ export declare function writeProblem(doc: Doc, path: string, next: string | null
|
|
|
46
46
|
export declare function writeFilesProblem(doc: Doc, files: Record<string, string>): string | undefined;
|
|
47
47
|
/** The paths a deep change to the files map touched. */
|
|
48
48
|
export declare function changedPaths(events: YEvent<AbstractType<unknown>>[], files: Map<Text>): Set<string>;
|
|
49
|
+
/** How many characters differ between two texts: an edit distance. */
|
|
50
|
+
export declare function editDistance(from: string, to: string): number;
|
|
49
51
|
/**
|
|
50
52
|
* A three-way merge of text: the changes from `base` to `local`, applied on
|
|
51
53
|
* top of `remote`. When the same lines changed on both sides, the local
|
|
@@ -132,6 +132,11 @@ function changedPaths(events, files) {
|
|
|
132
132
|
else if (typeof event.path[0] === "string") paths.add(event.path[0]);
|
|
133
133
|
return paths;
|
|
134
134
|
}
|
|
135
|
+
/** How many characters differ between two texts: an edit distance. */
|
|
136
|
+
function editDistance(from, to) {
|
|
137
|
+
if (from === to) return 0;
|
|
138
|
+
return dmp.diff_levenshtein(dmp.diff_main(from, to));
|
|
139
|
+
}
|
|
135
140
|
/**
|
|
136
141
|
* A three-way merge of text: the changes from `base` to `local`, applied on
|
|
137
142
|
* top of `remote`. When the same lines changed on both sides, the local
|
|
@@ -154,4 +159,4 @@ function mergeText(base, local, remote) {
|
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
//#endregion
|
|
157
|
-
export { FILES_KEY, LARGE_CANVAS_BYTES, LIVE_EXTENSIONS, LIVE_FILES, LIVE_FOLDERS, MAX_FILES, MAX_FILE_BYTES, changedPaths, filesOf, isLivePath, mergeText, readFiles, setText, writeFile, writeFilesProblem, writeProblem };
|
|
162
|
+
export { FILES_KEY, LARGE_CANVAS_BYTES, LIVE_EXTENSIONS, LIVE_FILES, LIVE_FOLDERS, MAX_FILES, MAX_FILE_BYTES, changedPaths, editDistance, filesOf, isLivePath, mergeText, readFiles, setText, writeFile, writeFilesProblem, writeProblem };
|