@neta-art/cohub 9.0.1 → 11.0.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/README.md +108 -102
- package/dist/board/editor/align.d.ts +11 -0
- package/dist/board/editor/align.js +72 -0
- package/dist/board/editor/animation.d.ts +17 -0
- package/dist/board/editor/animation.js +187 -0
- package/dist/board/editor/camera.d.ts +32 -0
- package/dist/board/editor/camera.js +137 -0
- package/dist/board/editor/clipboard.d.ts +41 -0
- package/dist/board/editor/clipboard.js +129 -0
- package/dist/board/editor/connection-ports.d.ts +19 -0
- package/dist/board/editor/connection-ports.js +85 -0
- package/dist/board/editor/context.d.ts +111 -0
- package/dist/board/editor/context.js +30 -0
- package/dist/board/editor/copy.d.ts +17 -0
- package/dist/board/editor/copy.js +121 -0
- package/dist/board/editor/creation.d.ts +51 -0
- package/dist/board/editor/creation.js +225 -0
- package/dist/board/editor/deletion.d.ts +9 -0
- package/dist/board/editor/deletion.js +90 -0
- package/dist/board/editor/document-edits.d.ts +22 -0
- package/dist/board/editor/document-edits.js +193 -0
- package/dist/board/editor/document.d.ts +41 -0
- package/dist/board/editor/document.js +302 -0
- package/dist/board/editor/editor.d.ts +225 -0
- package/dist/board/editor/editor.js +439 -0
- package/dist/board/editor/index.d.ts +18 -0
- package/dist/board/editor/index.js +12 -0
- package/dist/board/editor/interaction.d.ts +115 -0
- package/dist/board/editor/interaction.js +584 -0
- package/dist/board/editor/query.d.ts +27 -0
- package/dist/board/editor/query.js +203 -0
- package/dist/board/editor/remote.d.ts +11 -0
- package/dist/board/editor/remote.js +55 -0
- package/dist/board/editor/selection-transform.d.ts +24 -0
- package/dist/board/editor/selection-transform.js +81 -0
- package/dist/board/editor/selection.d.ts +33 -0
- package/dist/board/editor/selection.js +197 -0
- package/dist/board/editor/snapping.d.ts +33 -0
- package/dist/board/editor/snapping.js +75 -0
- package/dist/board/editor/snapshots.d.ts +27 -0
- package/dist/board/editor/snapshots.js +132 -0
- package/dist/board/editor/spatial.d.ts +41 -0
- package/dist/board/editor/spatial.js +191 -0
- package/dist/board/editor/state.d.ts +12 -0
- package/dist/board/editor/state.js +49 -0
- package/dist/board/editor/tool.d.ts +10 -0
- package/dist/board/editor/tool.js +19 -0
- package/dist/board/editor/wheel.d.ts +5 -0
- package/dist/board/editor/wheel.js +17 -0
- package/dist/board/export/index.d.ts +28 -6
- package/dist/board/export/index.js +47 -13
- package/dist/board/export/node/index.d.ts +56 -0
- package/dist/board/{headless → export/node}/index.js +26 -21
- package/dist/board/export/node/scripts.d.ts +16 -0
- package/dist/board/export/node/scripts.js +258 -0
- package/dist/board/export/scene.d.ts +8 -5
- package/dist/board/export/scene.js +24 -9
- package/dist/board/{animation.d.ts → model/animation.d.ts} +8 -5
- package/dist/board/{animation.js → model/animation.js} +37 -10
- package/dist/board/{core → model}/arrow-geometry.d.ts +2 -2
- package/dist/board/{core → model}/arrow-geometry.js +2 -2
- package/dist/board/model/authoring.d.ts +20 -0
- package/dist/board/model/authoring.js +185 -0
- package/dist/board/{core → model}/draw-geometry.d.ts +2 -2
- package/dist/board/{core → model}/draw-geometry.js +1 -1
- package/dist/board/model/draw-input.d.ts +14 -0
- package/dist/board/model/draw-input.js +28 -0
- package/dist/board/{core → model}/export-assets.d.ts +1 -1
- package/dist/board/{core → model}/export-assets.js +1 -1
- package/dist/board/{core → model}/export-plan.d.ts +2 -2
- package/dist/board/{core → model}/export-plan.js +3 -2
- package/dist/board/{core → model}/file-preview.d.ts +1 -1
- package/dist/board/{core → model}/file-preview.js +2 -2
- package/dist/board/{core → model}/file-snapshot.d.ts +1 -1
- package/dist/board/{core → model}/file-snapshot.js +4 -3
- package/dist/board/{geometry.d.ts → model/geometry.d.ts} +3 -3
- package/dist/board/{geometry.js → model/geometry.js} +1 -1
- package/dist/board/{image-key.d.ts → model/image-key.d.ts} +2 -2
- package/dist/board/{image-key.js → model/image-key.js} +7 -3
- package/dist/board/model/index.d.ts +42 -0
- package/dist/board/model/index.js +39 -0
- package/dist/board/model/items/builtin.d.ts +5 -0
- package/dist/board/model/items/builtin.js +119 -0
- package/dist/board/model/items/create.d.ts +61 -0
- package/dist/board/model/items/create.js +272 -0
- package/dist/board/model/items/definition.d.ts +35 -0
- package/dist/board/model/items/definition.js +18 -0
- package/dist/board/model/items/id.d.ts +5 -0
- package/dist/board/model/items/id.js +11 -0
- package/dist/board/model/items/index.d.ts +6 -0
- package/dist/board/model/items/index.js +6 -0
- package/dist/board/model/items/registry.d.ts +35 -0
- package/dist/board/model/items/registry.js +84 -0
- package/dist/board/{media-playback.d.ts → model/media-playback.d.ts} +4 -3
- package/dist/board/{media-playback.js → model/media-playback.js} +15 -5
- package/dist/board/{media.d.ts → model/media.d.ts} +1 -1
- package/dist/board/{media.js → model/media.js} +8 -2
- package/dist/board/{core → model}/palette.d.ts +1 -1
- package/dist/board/{core → model}/palette.js +1 -1
- package/dist/board/{presets.d.ts → model/presets.d.ts} +3 -3
- package/dist/board/{presets.js → model/presets.js} +1 -1
- package/dist/board/{replay.d.ts → model/replay.d.ts} +5 -5
- package/dist/board/{replay.js → model/replay.js} +2 -2
- package/dist/board/model/sampling.d.ts +19 -0
- package/dist/board/model/sampling.js +96 -0
- package/dist/board/{core → model}/scene.d.ts +1 -1
- package/dist/board/{core → model}/scene.js +1 -1
- package/dist/board/model/script-example.d.ts +4 -0
- package/dist/board/model/script-example.js +21 -0
- package/dist/board/model/script-hit.d.ts +10 -0
- package/dist/board/model/script-hit.js +52 -0
- package/dist/board/model/script-index.d.ts +7 -0
- package/dist/board/model/script-index.js +15 -0
- package/dist/board/model/script-scene.d.ts +24 -0
- package/dist/board/model/script-scene.js +267 -0
- package/dist/board/model/script.d.ts +105 -0
- package/dist/board/model/script.js +1 -0
- package/dist/board/model/shape-types.d.ts +8 -0
- package/dist/board/model/shape-types.js +8 -0
- package/dist/board/{task.d.ts → model/task.d.ts} +4 -4
- package/dist/board/{task.js → model/task.js} +3 -3
- package/dist/board/{core → model}/text-metrics.d.ts +1 -1
- package/dist/board/{core → model}/text-metrics.js +1 -1
- package/dist/board/{core → model}/tool-styles.d.ts +1 -1
- package/dist/board/{core → model}/tool-styles.js +1 -1
- package/dist/board/{runtime/board-player.d.ts → player/index.d.ts} +2 -2
- package/dist/board/{runtime/board-player.js → player/index.js} +5 -4
- package/dist/board/render/board-background.d.ts +1 -1
- package/dist/board/render/clip.d.ts +1 -1
- package/dist/board/render/css-color.d.ts +6 -1
- package/dist/board/render/css-color.js +34 -20
- package/dist/board/render/diagnostics.d.ts +20 -0
- package/dist/board/render/diagnostics.js +117 -0
- package/dist/board/render/index.d.ts +9 -6
- package/dist/board/render/index.js +10 -7
- package/dist/board/render/media-interaction.d.ts +2 -2
- package/dist/board/render/media-interaction.js +1 -1
- package/dist/board/render/palette.d.ts +3 -2
- package/dist/board/render/palette.js +7 -3
- package/dist/board/render/renderers/arrow-card-renderer.js +4 -3
- package/dist/board/render/renderers/audio-card-renderer.js +2 -1
- package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -10
- package/dist/board/render/renderers/board-renderer-registry.js +17 -17
- package/dist/board/render/renderers/custom-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/{sketch-card-renderer.js → custom-card-renderer.js} +16 -15
- package/dist/board/render/renderers/draw-card-renderer.js +4 -3
- package/dist/board/render/renderers/effect-card-renderer.js +22 -5
- package/dist/board/render/renderers/far-plate.js +1 -1
- package/dist/board/render/renderers/file-card-renderer.d.ts +1 -1
- package/dist/board/render/renderers/file-card-renderer.js +2 -2
- package/dist/board/render/renderers/frame-card-renderer.js +30 -14
- package/dist/board/render/renderers/image-card-renderer.d.ts +1 -1
- package/dist/board/render/renderers/image-card-renderer.js +43 -4
- package/dist/board/render/renderers/shape-card-renderer.js +11 -28
- package/dist/board/render/renderers/task-card-renderer.js +1 -1
- package/dist/board/render/renderers/text-card-renderer.js +6 -4
- package/dist/board/render/renderers/unknown-card-renderer.js +1 -0
- package/dist/board/render/renderers/video-card-renderer.d.ts +1 -1
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sampling.d.ts +22 -0
- package/dist/board/render/sampling.js +21 -0
- package/dist/board/render/script-export.d.ts +11 -0
- package/dist/board/render/script-export.js +86 -0
- package/dist/board/render/script-host.d.ts +31 -0
- package/dist/board/render/script-host.js +421 -0
- package/dist/board/render/script-modules.d.ts +2 -0
- package/dist/board/render/script-modules.js +2 -0
- package/dist/board/render/script-runtime.d.ts +29 -0
- package/dist/board/render/script-runtime.js +213 -0
- package/dist/board/render/script-sandbox.d.ts +4 -0
- package/dist/board/render/script-sandbox.js +173 -0
- package/dist/board/render/stroke.d.ts +3 -2
- package/dist/board/render/stroke.js +23 -2
- package/dist/board/render/text-measurement.js +2 -2
- package/dist/board/replica/index.d.ts +70 -0
- package/dist/board/replica/index.js +276 -0
- package/dist/board/stage/assets.d.ts +41 -0
- package/dist/board/stage/assets.js +355 -0
- package/dist/board/stage/index.d.ts +8 -0
- package/dist/board/stage/index.js +8 -0
- package/dist/board/stage/lru.d.ts +32 -0
- package/dist/board/stage/lru.js +29 -0
- package/dist/board/stage/maintenance.d.ts +5 -0
- package/dist/board/stage/maintenance.js +11 -0
- package/dist/board/stage/pointer.d.ts +8 -0
- package/dist/board/stage/pointer.js +33 -0
- package/dist/board/stage/scene.d.ts +85 -0
- package/dist/board/stage/scene.js +515 -0
- package/dist/board/stage/script-pointer.d.ts +19 -0
- package/dist/board/stage/script-pointer.js +35 -0
- package/dist/board/stage/stage.d.ts +76 -0
- package/dist/board/stage/stage.js +774 -0
- package/dist/board/stage/texture-pool.d.ts +24 -0
- package/dist/board/stage/texture-pool.js +153 -0
- package/dist/board/stage/views.d.ts +38 -0
- package/dist/board/stage/views.js +93 -0
- package/dist/chunks/environment.d.ts +289 -23
- package/dist/chunks/host-bridge.d.ts +2 -2
- package/dist/chunks/http.d.ts +185 -71
- package/dist/chunks/http.js +368 -269
- package/dist/chunks/transport.js +3 -1
- package/dist/chunks/websocket.d.ts +9 -1
- package/dist/chunks/websocket.js +16 -2
- package/dist/host-bridge.js +2 -1
- package/dist/http.d.ts +2 -2
- package/dist/index.d.ts +182 -4
- package/dist/index.js +1393 -129
- package/dist/media.d.ts +1 -10
- package/dist/media.js +16 -27
- package/dist/protocol/dist/board-assets.d.ts +1 -0
- package/dist/protocol/dist/board-constants.js +2 -2
- package/dist/protocol/dist/board-model.d.ts +201 -11
- package/dist/protocol/dist/board-model.js +33 -14
- package/dist/protocol/dist/board-patch.js +3 -2
- package/dist/protocol/dist/board-schema.d.ts +4 -2
- package/dist/protocol/dist/board-schema.js +18 -4
- package/dist/protocol/dist/board-script-modules.d.ts +25 -0
- package/dist/protocol/dist/board-script-modules.js +127 -0
- package/dist/protocol/dist/board.d.ts +28 -2
- package/dist/protocol/dist/board.js +3 -1
- package/dist/protocol/dist/core/media.d.ts +5 -0
- package/dist/protocol/dist/core/media.js +39 -0
- package/dist/protocol/dist/display/index.d.ts +1 -0
- package/dist/protocol/dist/index.d.ts +7 -5
- package/dist/protocol/dist/realtime/types.d.ts +1 -0
- package/dist/protocol/dist/rtc/index.d.ts +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +21 -8
- package/dist/board/core/shape-definition.d.ts +0 -23
- package/dist/board/core/shape-definition.js +0 -45
- package/dist/board/core/shape-types.d.ts +0 -38
- package/dist/board/core/shape-types.js +0 -22
- package/dist/board/headless/index.d.ts +0 -55
- package/dist/board/headless/sketch.d.ts +0 -19
- package/dist/board/headless/sketch.js +0 -146
- package/dist/board/index.d.ts +0 -30
- package/dist/board/index.js +0 -29
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +0 -5
- package/dist/board/render/sketch-host.d.ts +0 -14
- package/dist/board/render/sketch-host.js +0 -216
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BOARD_STROKE_MAX_SIZE, BOARD_STROKE_MIN_SIZE, clampBoardStrokeSize } from "../../protocol/dist/board-constants.js";
|
|
2
|
+
import { isPublicBoardRemoteAddress, normalizeBoardRemoteUrl } from "../../protocol/dist/board-url.js";
|
|
3
|
+
import { BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_SHAPE_GEOMETRIES, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardArrowAnchorSchema, BoardArrowBindingSchema, BoardArrowEndSchema, BoardArrowItemSchema, BoardAudioItemSchema, BoardBackgroundSchema, BoardColorSchema, BoardCropSchema, BoardCustomItemSchema, BoardDrawItemSchema, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItemSchema, BoardExtensionItemSchema, BoardFileItemSchema, BoardFrameItemSchema, BoardIdSchema, BoardImageItemSchema, BoardKeySchema, BoardKeyframeSchema, BoardMarkerSchema, BoardMediaSnapshotSchema, BoardMediaSourceSchema, BoardPatchSchema, BoardScriptSchema, BoardSettingsSchema, BoardShapeItemSchema, BoardSizeSchema, BoardStyleSchema, BoardTaskArtifactSchema, BoardTaskItemSchema, BoardTaskSnapshotSchema, BoardTextItemSchema, BoardTrackSchema, BoardVec2Schema, BoardVideoItemSchema, boardItemSchema, emptyBoardDocument, hasAuthoredSize, isBoardColorString, isBoardEase, isBuiltinItem, isBuiltinItemType, isEmptyBoardDelta, isFileBackedItem, isMediaItem, isSafeBoardSourcePath, parseBoardItem, parseBoardMediaSource } from "../../protocol/dist/board-model.js";
|
|
4
|
+
import { IDENTITY_MATRIX, anchorPoint, applyMatrix, arrowBindings, autoAnchorSide, bendControl, clampBoardFontSize, createBoardLayout, createDocumentLayout, drawPointsBounds, drawSampleRadius, estimateTextWidth, framePoint, invertMatrix, isArrowBinding, layoutBoardText, multiplyMatrix, pointsRect, rotateAround, scaleVector, setBoardTextMeasurer, sideAnchor } from "../../protocol/dist/board-layout.js";
|
|
5
|
+
import { applyBoardDelta, applyBoardPatch, applyBoardPatchToDocument, boardPatchTouches, createDocumentState, diffBoardDocuments, diffMergePatch, isEmptyBoardPatch, listBoardProperties, mergePatch, parseBoardDocument, pruneBoardTrack, resolveBoardProperty, trackReferences } from "../../protocol/dist/board-patch.js";
|
|
6
|
+
import { isBoardPath, parseBoardManifest, serializeBoardManifest } from "../../protocol/dist/board.js";
|
|
7
|
+
import { BOARD_SCHEMA_TARGETS, boardJsonSchema, boardSchemaOverview } from "../../protocol/dist/board-schema.js";
|
|
8
|
+
import { boardScriptItems, hasBoardScripts } from "./script-index.js";
|
|
9
|
+
import { CORNER_RESIZE_HANDLES, CORNER_ROTATION_ZONE_WIDTH, EDGE_RESIZE_HANDLES, FIT_PADDING, HANDLE_DIRECTION, HANDLE_HIT_RADIUS, MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, MIN_ITEM_SIZE, RESIZE_HANDLES, ROTATION_HANDLE_OFFSET, VIEWPORT_MARGIN_RATIO, angleFromCenter, cameraForFocus, cameraForRect, cameraForState, clamp, clampZoom, degToRad, expandRect, fitToContent, frameContainsPoint, frameCornerRotationHandleAt, frameCorners, frameEdgeHandleAt, frameHandlePosition, frameRayIntersection, frameRect, handlePosition, itemBounds, normalizeRotation, normalizeViewport, normalizedPoint, panBy, pointToWorld, pointsBounds, radToDeg, rectCenter, rectContainsPoint, rectForCameraFocus, rectsIntersect, resizeFrame, resizeFrameToSize, rotateFrames, rotatePointAround, rotationHandleAnchor, rotationHandlePosition, scaleFrames, screenOffset, screenPoint, screenToWorld, selectionBounds, stableCullRect, unionRects, visibleWorldRect, worldOffset, worldPoint, worldRect, worldToScreen, zoomAround } from "./geometry.js";
|
|
10
|
+
import { boardScriptScope, composeBoardScriptItems, prepareBoardScriptOutput, scriptTemporaryPrefix, validateBoardScriptCommit, validateBoardScriptOutput } from "./script-scene.js";
|
|
11
|
+
import { boardScriptTarget } from "./script-hit.js";
|
|
12
|
+
import { BOARD_SCRIPT_DRAWING_EXAMPLE } from "./script-example.js";
|
|
13
|
+
import { applyBoardEvaluation, boardAnimationTime, boardDocumentAt, boardEase, compileBoardAnimations, evaluateBoardAnimations, parseHexColor, sampleBoardTrack } from "./animation.js";
|
|
14
|
+
import { buildBoardScene, orderBoardItems, placeItem, refreshBoardScene, sceneItemToItem, sceneItemsToRecord, toSceneItem } from "./scene.js";
|
|
15
|
+
import { createBoardAnimationSampler, resolveBoardAnimationCamera } from "./sampling.js";
|
|
16
|
+
import { boardPathTrack, boardSequence, boardSequencePatch } from "./authoring.js";
|
|
17
|
+
import { BOARD_PRESET_NAMES, boardNestedAnimation, boardNestedAnimationTrack, boardPresetTracks, isBoardPresetName, listBoardPresets } from "./presets.js";
|
|
18
|
+
import { ARROW_BINDING_GAP, arrowHitRadius, arrowPathBounds, distanceToArrow, pathMidpoint, pathPointAt, resolveAnchor, resolveArrow, resolveSceneArrow } from "./arrow-geometry.js";
|
|
19
|
+
import { buildStrokeOutline, buildStrokeRibbonGeometry, computeDrawBounds, createStrokeRibbonBuilder, distanceToStroke, isStrokeCorner, sampleRadius, simplifyDrawIndices, trimDrawPoints } from "./draw-geometry.js";
|
|
20
|
+
import { appendBoardDrawSamples, quantizeDrawCoordinate } from "./draw-input.js";
|
|
21
|
+
import { BOARD_EXPORT_MAX_TEXTURES, selectBoardExportAssets } from "./export-assets.js";
|
|
22
|
+
import { BOARD_EXPORT_DEFAULT_PADDING, BOARD_EXPORT_DEFAULT_SCALE, BOARD_EXPORT_ITEM_WARN_THRESHOLD, BOARD_EXPORT_MAX_EDGE, BOARD_EXPORT_MAX_PIXELS, exportItemBounds, normalizeBoardDocument, planBoardExport } from "./export-plan.js";
|
|
23
|
+
import { getMediaExtension, getMediaResourceTitle, inferBoardMediaKind } from "./media.js";
|
|
24
|
+
import { FILE_EXCERPT_MAX_BYTES, FILE_EXCERPT_MAX_CHARS, buildCodeExcerpt, buildFileExcerpt, buildFileSnapshot, fileBaseName, fileCategory, fileStem, readCoverFromFrontmatter, readFrontmatterScalars, readTitleFromFrontmatter, resolveCoverRef, resolveFileTitle, resolveSpacePath, shouldFetchFileExcerpt, splitFrontmatter } from "./file-snapshot.js";
|
|
25
|
+
import { availabilityFromError, fileCategoryAccent, fileMetaLine, filePreviewKind, filePreviewMemoKey, filePreviewScope, fileTypeLabel, formatFileSize, isFileSnapshotFresh, mergeFileSnapshot } from "./file-preview.js";
|
|
26
|
+
import { BOARD_COLORS, DEFAULT_BOARD_COLOR, boardColorCssVar, buildFallbackShapeColors, isBoardColorId, pickBoardColor, resolveBoardColor, resolveItemColor } from "./palette.js";
|
|
27
|
+
import { SHAPE_KINDS, isShapeKind } from "./shape-types.js";
|
|
28
|
+
import { TEXT_FONT_FAMILY, TEXT_FONT_SIZE, TEXT_LINE_HEIGHT, TEXT_MAX_FONT_SIZE, TEXT_MIN_FONT_SIZE, boardFontFamily } from "./text-metrics.js";
|
|
29
|
+
import { DEFAULT_BOARD_TOOL_STYLES, createBoardToolStyles } from "./tool-styles.js";
|
|
30
|
+
import { featuredTaskArtifact, rankedTaskArtifacts, taskArtifactPreviewUrl, taskArtifacts, taskRunToBoardTaskSnapshot } from "./task.js";
|
|
31
|
+
import { boardImageKeySource, imageAssetKey } from "./image-key.js";
|
|
32
|
+
import { FULL_CAPABILITIES, defineBoardItem } from "./items/definition.js";
|
|
33
|
+
import { builtinBoardItems } from "./items/builtin.js";
|
|
34
|
+
import { createBoardEntityId, createBoardItemId } from "./items/id.js";
|
|
35
|
+
import { createAppBoardItem, createArrowBoardItem, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, mediaFrameSize, titleForBoardItem } from "./items/create.js";
|
|
36
|
+
import { createBoardRegistry, defaultBoardRegistry } from "./items/registry.js";
|
|
37
|
+
import { playableBoardMedia, playableBoardMediaList, resetBoardPlaybackUrlCache, resolveBoardMediaUrl } from "./media-playback.js";
|
|
38
|
+
import { boardReplayActorKind, createBoardReplayPlayer } from "./replay.js";
|
|
39
|
+
export { ARROW_BINDING_GAP, BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_COLORS, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXPORT_DEFAULT_PADDING, BOARD_EXPORT_DEFAULT_SCALE, BOARD_EXPORT_ITEM_WARN_THRESHOLD, BOARD_EXPORT_MAX_EDGE, BOARD_EXPORT_MAX_PIXELS, BOARD_EXPORT_MAX_TEXTURES, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_PRESET_NAMES, BOARD_SCHEMA_TARGETS, BOARD_SCRIPT_DRAWING_EXAMPLE, BOARD_SHAPE_GEOMETRIES, BOARD_STROKE_MAX_SIZE, BOARD_STROKE_MIN_SIZE, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardArrowAnchorSchema, BoardArrowBindingSchema, BoardArrowEndSchema, BoardArrowItemSchema, BoardAudioItemSchema, BoardBackgroundSchema, BoardColorSchema, BoardCropSchema, BoardCustomItemSchema, BoardDrawItemSchema, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItemSchema, BoardExtensionItemSchema, BoardFileItemSchema, BoardFrameItemSchema, BoardIdSchema, BoardImageItemSchema, BoardKeySchema, BoardKeyframeSchema, BoardMarkerSchema, BoardMediaSnapshotSchema, BoardMediaSourceSchema, BoardPatchSchema, BoardScriptSchema, BoardSettingsSchema, BoardShapeItemSchema, BoardSizeSchema, BoardStyleSchema, BoardTaskArtifactSchema, BoardTaskItemSchema, BoardTaskSnapshotSchema, BoardTextItemSchema, BoardTrackSchema, BoardVec2Schema, BoardVideoItemSchema, CORNER_RESIZE_HANDLES, CORNER_ROTATION_ZONE_WIDTH, DEFAULT_BOARD_COLOR, DEFAULT_BOARD_TOOL_STYLES, EDGE_RESIZE_HANDLES, FILE_EXCERPT_MAX_BYTES, FILE_EXCERPT_MAX_CHARS, FIT_PADDING, FULL_CAPABILITIES, HANDLE_DIRECTION, HANDLE_HIT_RADIUS, IDENTITY_MATRIX, MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, MIN_ITEM_SIZE, RESIZE_HANDLES, ROTATION_HANDLE_OFFSET, SHAPE_KINDS, TEXT_FONT_FAMILY, TEXT_FONT_SIZE, TEXT_LINE_HEIGHT, TEXT_MAX_FONT_SIZE, TEXT_MIN_FONT_SIZE, VIEWPORT_MARGIN_RATIO, anchorPoint, angleFromCenter, appendBoardDrawSamples, applyBoardDelta, applyBoardEvaluation, applyBoardPatch, applyBoardPatchToDocument, applyMatrix, arrowBindings, arrowHitRadius, arrowPathBounds, autoAnchorSide, availabilityFromError, bendControl, boardAnimationTime, boardColorCssVar, boardDocumentAt, boardEase, boardFontFamily, boardImageKeySource, boardItemSchema, boardJsonSchema, boardNestedAnimation, boardNestedAnimationTrack, boardPatchTouches, boardPathTrack, boardPresetTracks, boardReplayActorKind, boardSchemaOverview, boardScriptItems, boardScriptScope, boardScriptTarget, boardSequence, boardSequencePatch, buildBoardScene, buildCodeExcerpt, buildFallbackShapeColors, buildFileExcerpt, buildFileSnapshot, buildStrokeOutline, buildStrokeRibbonGeometry, builtinBoardItems, cameraForFocus, cameraForRect, cameraForState, clamp, clampBoardFontSize, clampBoardStrokeSize, clampBoardFontSize as clampBoardTextFontSize, clampZoom, compileBoardAnimations, composeBoardScriptItems, computeDrawBounds, createAppBoardItem, createArrowBoardItem, createBoardAnimationSampler, createBoardEntityId, createBoardItemId, createBoardLayout, createBoardRegistry, createBoardReplayPlayer, createBoardToolStyles, createDocumentLayout, createDocumentState, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createStrokeRibbonBuilder, createTaskBoardItem, createTextBoardItem, defaultBoardRegistry, defineBoardItem, degToRad, diffBoardDocuments, diffMergePatch, distanceToArrow, distanceToStroke, drawPointsBounds, drawSampleRadius, emptyBoardDocument, estimateTextWidth, evaluateBoardAnimations, expandRect, exportItemBounds, featuredTaskArtifact, fileBaseName, fileCategory, fileCategoryAccent, fileMetaLine, filePreviewKind, filePreviewMemoKey, filePreviewScope, fileStem, fileTypeLabel, fitToContent, formatFileSize, frameContainsPoint, frameCornerRotationHandleAt, frameCorners, frameEdgeHandleAt, frameHandlePosition, framePoint, frameRayIntersection, frameRect, getMediaExtension, getMediaResourceTitle, handlePosition, hasAuthoredSize, hasBoardScripts, imageAssetKey, inferBoardMediaKind, invertMatrix, isArrowBinding, isBoardColorId, isBoardColorString, isBoardEase, isBoardPath, isBoardPresetName, isBuiltinItem, isBuiltinItemType, isEmptyBoardDelta, isEmptyBoardPatch, isFileBackedItem, isFileSnapshotFresh, isMediaItem, isPublicBoardRemoteAddress, isSafeBoardSourcePath, isShapeKind, isStrokeCorner, itemBounds, layoutBoardText, listBoardPresets, listBoardProperties, mediaFrameSize, mergeFileSnapshot, mergePatch, multiplyMatrix, normalizeBoardDocument, normalizeBoardRemoteUrl, normalizeRotation, normalizeViewport, normalizedPoint, orderBoardItems, panBy, parseBoardDocument, parseBoardItem, parseBoardManifest, parseBoardMediaSource, parseHexColor, pathMidpoint, pathPointAt, pickBoardColor, placeItem, planBoardExport, playableBoardMedia, playableBoardMediaList, pointToWorld, pointsBounds, pointsRect, prepareBoardScriptOutput, pruneBoardTrack, quantizeDrawCoordinate, radToDeg, rankedTaskArtifacts, readCoverFromFrontmatter, readFrontmatterScalars, readTitleFromFrontmatter, rectCenter, rectContainsPoint, rectForCameraFocus, rectsIntersect, refreshBoardScene, resetBoardPlaybackUrlCache, resizeFrame, resizeFrameToSize, resolveAnchor, resolveArrow, resolveBoardAnimationCamera, resolveBoardColor, resolveBoardMediaUrl, resolveBoardProperty, resolveCoverRef, resolveFileTitle, resolveItemColor, resolveSceneArrow, resolveSpacePath, rotateAround, rotateFrames, rotatePointAround, rotationHandleAnchor, rotationHandlePosition, sampleBoardTrack, sampleRadius, scaleFrames, scaleVector, sceneItemToItem, sceneItemsToRecord, screenOffset, screenPoint, screenToWorld, scriptTemporaryPrefix, selectBoardExportAssets, selectionBounds, serializeBoardManifest, setBoardTextMeasurer, shouldFetchFileExcerpt, sideAnchor, simplifyDrawIndices, splitFrontmatter, stableCullRect, taskArtifactPreviewUrl, taskArtifacts, taskRunToBoardTaskSnapshot, titleForBoardItem, toSceneItem, trackReferences, trimDrawPoints, unionRects, validateBoardScriptCommit, validateBoardScriptOutput, visibleWorldRect, worldOffset, worldPoint, worldRect, worldToScreen, zoomAround };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { degToRad, frameContainsPoint, itemBounds, rectCenter, rectContainsPoint, rotatePointAround, worldPoint } from "../geometry.js";
|
|
2
|
+
import { computeDrawBounds, distanceToStroke } from "../draw-geometry.js";
|
|
3
|
+
import { defineBoardItem } from "./definition.js";
|
|
4
|
+
//#region src/board/model/items/builtin.ts
|
|
5
|
+
function frameLocalPoint(item, point) {
|
|
6
|
+
const center = rectCenter(item.frame);
|
|
7
|
+
const rotated = item.frame.rotation ? rotatePointAround(point, center, -degToRad(item.frame.rotation)) : point;
|
|
8
|
+
return worldPoint(rotated.x - item.frame.x, rotated.y - item.frame.y);
|
|
9
|
+
}
|
|
10
|
+
const textItem = defineBoardItem({
|
|
11
|
+
type: "text",
|
|
12
|
+
capabilities: {
|
|
13
|
+
canEdit: true,
|
|
14
|
+
aspectLocked: true
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const imageItem = defineBoardItem({
|
|
18
|
+
type: "image",
|
|
19
|
+
capabilities: { aspectLocked: true }
|
|
20
|
+
});
|
|
21
|
+
const videoItem = defineBoardItem({
|
|
22
|
+
type: "video",
|
|
23
|
+
capabilities: {
|
|
24
|
+
canRotate: false,
|
|
25
|
+
aspectLocked: true
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const audioItem = defineBoardItem({
|
|
29
|
+
type: "audio",
|
|
30
|
+
capabilities: { canRotate: false }
|
|
31
|
+
});
|
|
32
|
+
const fileItem = defineBoardItem({
|
|
33
|
+
type: "file",
|
|
34
|
+
capabilities: { canRotate: false }
|
|
35
|
+
});
|
|
36
|
+
const taskItem = defineBoardItem({
|
|
37
|
+
type: "task",
|
|
38
|
+
capabilities: {
|
|
39
|
+
canRotate: false,
|
|
40
|
+
aspectLocked: true
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const effectItem = defineBoardItem({
|
|
44
|
+
type: "effect",
|
|
45
|
+
capabilities: {
|
|
46
|
+
canConnect: false,
|
|
47
|
+
canSnap: false
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const customItem = defineBoardItem({ type: "custom" });
|
|
51
|
+
const frameItem = defineBoardItem({
|
|
52
|
+
type: "frame",
|
|
53
|
+
capabilities: {
|
|
54
|
+
canEdit: true,
|
|
55
|
+
canRotate: false,
|
|
56
|
+
canConnect: false
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const arrowItem = defineBoardItem({
|
|
60
|
+
type: "arrow",
|
|
61
|
+
capabilities: {
|
|
62
|
+
canResize: false,
|
|
63
|
+
canRotate: false,
|
|
64
|
+
canEdit: true,
|
|
65
|
+
canConnect: false,
|
|
66
|
+
canSnap: false
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
function shapeContainsLocal(item, local) {
|
|
70
|
+
const w = item.frame.width;
|
|
71
|
+
const h = item.frame.height;
|
|
72
|
+
const nx = local.x / w * 2 - 1;
|
|
73
|
+
const ny = local.y / h * 2 - 1;
|
|
74
|
+
switch (item.props.geometry) {
|
|
75
|
+
case "ellipse": return nx * nx + ny * ny <= 1;
|
|
76
|
+
case "diamond": return Math.abs(nx) + Math.abs(ny) <= 1;
|
|
77
|
+
case "triangle": return ny >= -1 && ny <= 1 && Math.abs(nx) <= (ny + 1) / 2;
|
|
78
|
+
default: return local.x >= 0 && local.x <= w && local.y >= 0 && local.y <= h;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const builtinBoardItems = [
|
|
82
|
+
frameItem,
|
|
83
|
+
textItem,
|
|
84
|
+
defineBoardItem({
|
|
85
|
+
type: "shape",
|
|
86
|
+
capabilities: { canEdit: true },
|
|
87
|
+
hitTest: (item, point) => {
|
|
88
|
+
if (item.type !== "shape" || !frameContainsPoint(item.frame, point)) return false;
|
|
89
|
+
return shapeContainsLocal(item, frameLocalPoint(item, point));
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
defineBoardItem({
|
|
93
|
+
type: "draw",
|
|
94
|
+
capabilities: {
|
|
95
|
+
aspectLocked: true,
|
|
96
|
+
canConnect: false
|
|
97
|
+
},
|
|
98
|
+
hitTest: (item, point) => {
|
|
99
|
+
if (item.type !== "draw" || !rectContainsPoint(itemBounds(item.frame), point, 8)) return false;
|
|
100
|
+
const draw = item;
|
|
101
|
+
const width = draw.style.strokeWidth ?? 4;
|
|
102
|
+
const box = computeDrawBounds(draw.props.points, width);
|
|
103
|
+
const scale = item.frame.width / Math.max(1e-4, box.width);
|
|
104
|
+
const local = frameLocalPoint(item, point);
|
|
105
|
+
const inPoints = worldPoint(box.x + local.x / scale, box.y + local.y / scale);
|
|
106
|
+
return distanceToStroke(draw.props.points, inPoints) <= Math.max(6, width) / Math.min(1, scale);
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
arrowItem,
|
|
110
|
+
imageItem,
|
|
111
|
+
videoItem,
|
|
112
|
+
audioItem,
|
|
113
|
+
fileItem,
|
|
114
|
+
taskItem,
|
|
115
|
+
effectItem,
|
|
116
|
+
customItem
|
|
117
|
+
];
|
|
118
|
+
//#endregion
|
|
119
|
+
export { builtinBoardItems };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BoardItem, BoardMediaSnapshot, BoardTaskSnapshot } from "../../../protocol/dist/board-model.js";
|
|
2
|
+
import "../../../protocol/dist/index.js";
|
|
3
|
+
import { BoardFileSnapshotFacts } from "../file-snapshot.js";
|
|
4
|
+
import { ShapeKind } from "../shape-types.js";
|
|
5
|
+
//#region src/board/model/items/create.d.ts
|
|
6
|
+
type BoardItemEntry = {
|
|
7
|
+
id: string;
|
|
8
|
+
item: BoardItem;
|
|
9
|
+
};
|
|
10
|
+
declare function mediaFrameSize(naturalWidth?: number | null, naturalHeight?: number | null, maxEdge?: number, fallback?: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}): {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
type BoardMediaItemKind = "image" | "video" | "audio" | "file";
|
|
18
|
+
declare function createMediaBoardItem(path: string, x: number, y: number, snapshot?: BoardMediaSnapshot & BoardFileSnapshotFacts, id?: string, mediaKind?: BoardMediaItemKind): BoardItemEntry;
|
|
19
|
+
declare const createFileNodeForPath: typeof createMediaBoardItem;
|
|
20
|
+
declare function createTaskBoardItem(taskRunId: string, snapshot: BoardTaskSnapshot, x: number, y: number, metadata?: Record<string, unknown>, id?: string): BoardItemEntry;
|
|
21
|
+
declare function createTextBoardItem(text: string, x: number, y: number, color?: string, id?: string): BoardItemEntry;
|
|
22
|
+
declare function createShapeBoardItem(geometry: ShapeKind, x: number, y: number, color?: string, id?: string, box?: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}): BoardItemEntry;
|
|
28
|
+
declare function createFrameBoardItem(x: number, y: number, color?: string, label?: string, id?: string, box?: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}): BoardItemEntry;
|
|
34
|
+
type BoardAppMetadata = {
|
|
35
|
+
appId: string;
|
|
36
|
+
ref: string;
|
|
37
|
+
url: string;
|
|
38
|
+
name: string;
|
|
39
|
+
icon?: string;
|
|
40
|
+
};
|
|
41
|
+
declare function createAppBoardItem(app: BoardAppMetadata, x: number, y: number, id?: string): BoardItemEntry;
|
|
42
|
+
declare function createDrawBoardItem(worldPoints: Array<{
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
p: number;
|
|
46
|
+
}>, color: string, size?: number, id?: string): BoardItemEntry;
|
|
47
|
+
declare function createArrowBoardItem(start: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
}, end: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
} | {
|
|
54
|
+
item: string;
|
|
55
|
+
}, color: string, id?: string, size?: number, startEnd?: {
|
|
56
|
+
item: string;
|
|
57
|
+
anchor?: unknown;
|
|
58
|
+
}): BoardItemEntry;
|
|
59
|
+
declare function titleForBoardItem(value: BoardItem): string;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { BoardAppMetadata, BoardItemEntry, BoardMediaItemKind, createAppBoardItem, createArrowBoardItem, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, mediaFrameSize, titleForBoardItem };
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { parseBoardItem } from "../../../protocol/dist/board-model.js";
|
|
2
|
+
import { pointsRect } from "../../../protocol/dist/board-layout.js";
|
|
3
|
+
import { quantizeDrawCoordinate } from "../draw-input.js";
|
|
4
|
+
import { getMediaResourceTitle, inferBoardMediaKind } from "../media.js";
|
|
5
|
+
import { fileStem } from "../file-snapshot.js";
|
|
6
|
+
import { filePreviewKind } from "../file-preview.js";
|
|
7
|
+
import { DEFAULT_BOARD_TOOL_STYLES } from "../tool-styles.js";
|
|
8
|
+
import { featuredTaskArtifact } from "../task.js";
|
|
9
|
+
import { createBoardItemId } from "./id.js";
|
|
10
|
+
//#region src/board/model/items/create.ts
|
|
11
|
+
const DEFAULT_MEDIA_SIZE = {
|
|
12
|
+
width: 320,
|
|
13
|
+
height: 200
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_TASK_SIZE = {
|
|
16
|
+
width: 300,
|
|
17
|
+
height: 188
|
|
18
|
+
};
|
|
19
|
+
const DEFAULT_TASK_MEDIA_SIZE = {
|
|
20
|
+
width: 320,
|
|
21
|
+
height: 180
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_VIDEO_SIZE = {
|
|
24
|
+
width: 320,
|
|
25
|
+
height: 180
|
|
26
|
+
};
|
|
27
|
+
const DEFAULT_AUDIO_SIZE = {
|
|
28
|
+
width: 320,
|
|
29
|
+
height: 112
|
|
30
|
+
};
|
|
31
|
+
const DEFAULT_FILE_SIZE = {
|
|
32
|
+
width: 260,
|
|
33
|
+
height: 132
|
|
34
|
+
};
|
|
35
|
+
const DEFAULT_FILE_COVER_SIZE = {
|
|
36
|
+
width: 260,
|
|
37
|
+
height: 208
|
|
38
|
+
};
|
|
39
|
+
const DEFAULT_SHAPE_SIZE = {
|
|
40
|
+
width: 200,
|
|
41
|
+
height: 140
|
|
42
|
+
};
|
|
43
|
+
const DEFAULT_FRAME_SIZE = {
|
|
44
|
+
width: 480,
|
|
45
|
+
height: 320
|
|
46
|
+
};
|
|
47
|
+
function item(value) {
|
|
48
|
+
const parsed = parseBoardItem(value);
|
|
49
|
+
if (!parsed.ok) throw new Error(`Invalid Board item: ${parsed.diagnostics[0]?.path}: ${parsed.diagnostics[0]?.message}`);
|
|
50
|
+
return parsed.item;
|
|
51
|
+
}
|
|
52
|
+
function centered(x, y, size) {
|
|
53
|
+
return {
|
|
54
|
+
position: {
|
|
55
|
+
x: x - size.width / 2,
|
|
56
|
+
y: y - size.height / 2
|
|
57
|
+
},
|
|
58
|
+
size: { ...size }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function mediaFrameSize(naturalWidth, naturalHeight, maxEdge = 480, fallback = DEFAULT_MEDIA_SIZE) {
|
|
62
|
+
if (!naturalWidth || !naturalHeight || !Number.isFinite(naturalWidth) || !Number.isFinite(naturalHeight) || naturalWidth <= 0 || naturalHeight <= 0) return { ...fallback };
|
|
63
|
+
const scale = Math.min(1, maxEdge / Math.max(naturalWidth, naturalHeight));
|
|
64
|
+
return {
|
|
65
|
+
width: Math.max(24, naturalWidth * scale),
|
|
66
|
+
height: Math.max(24, naturalHeight * scale)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function cleanSnapshot(snapshot) {
|
|
70
|
+
return Object.fromEntries(Object.entries(snapshot).filter(([, value]) => value !== void 0));
|
|
71
|
+
}
|
|
72
|
+
function createMediaBoardItem(path, x, y, snapshot = {}, id = createBoardItemId(), mediaKind) {
|
|
73
|
+
const kind = mediaKind ?? inferBoardMediaKind(path, snapshot.mimeType);
|
|
74
|
+
const title = snapshot.title ?? (kind === "file" || kind === "text" ? fileStem(path) : getMediaResourceTitle(path));
|
|
75
|
+
if (kind === "image" || kind === "video") {
|
|
76
|
+
const size = mediaFrameSize(snapshot.naturalWidth, snapshot.naturalHeight, 480, kind === "video" ? DEFAULT_VIDEO_SIZE : DEFAULT_MEDIA_SIZE);
|
|
77
|
+
const mimeType = snapshot.mimeType ?? (kind === "video" ? "video/*" : void 0);
|
|
78
|
+
return {
|
|
79
|
+
id,
|
|
80
|
+
item: item({
|
|
81
|
+
type: kind,
|
|
82
|
+
...centered(x, y, size),
|
|
83
|
+
props: {
|
|
84
|
+
src: path,
|
|
85
|
+
snapshot: cleanSnapshot({
|
|
86
|
+
...snapshot,
|
|
87
|
+
title,
|
|
88
|
+
mimeType
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (kind === "audio") return {
|
|
95
|
+
id,
|
|
96
|
+
item: item({
|
|
97
|
+
type: "audio",
|
|
98
|
+
...centered(x, y, DEFAULT_AUDIO_SIZE),
|
|
99
|
+
props: {
|
|
100
|
+
src: path,
|
|
101
|
+
snapshot: cleanSnapshot({
|
|
102
|
+
...snapshot,
|
|
103
|
+
title,
|
|
104
|
+
mimeType: snapshot.mimeType ?? "audio/*"
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
id,
|
|
111
|
+
item: item({
|
|
112
|
+
type: "file",
|
|
113
|
+
...centered(x, y, filePreviewKind(snapshot) === "cover" ? DEFAULT_FILE_COVER_SIZE : DEFAULT_FILE_SIZE),
|
|
114
|
+
props: {
|
|
115
|
+
src: path,
|
|
116
|
+
snapshot: cleanSnapshot({
|
|
117
|
+
...snapshot,
|
|
118
|
+
title
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const createFileNodeForPath = createMediaBoardItem;
|
|
125
|
+
function createTaskBoardItem(taskRunId, snapshot, x, y, metadata, id = createBoardItemId()) {
|
|
126
|
+
const artifact = featuredTaskArtifact(snapshot.artifacts);
|
|
127
|
+
const visual = artifact?.type === "image" || artifact?.type === "video" ? artifact : null;
|
|
128
|
+
return {
|
|
129
|
+
id,
|
|
130
|
+
item: item({
|
|
131
|
+
type: "task",
|
|
132
|
+
...centered(x, y, visual ? mediaFrameSize(visual.naturalWidth, visual.naturalHeight, 480, DEFAULT_TASK_MEDIA_SIZE) : artifact?.type === "audio" ? DEFAULT_TASK_MEDIA_SIZE : DEFAULT_TASK_SIZE),
|
|
133
|
+
...metadata ? { metadata } : {},
|
|
134
|
+
props: {
|
|
135
|
+
taskRunId,
|
|
136
|
+
snapshot
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function createTextBoardItem(text, x, y, color = DEFAULT_BOARD_TOOL_STYLES.text.color, id = createBoardItemId()) {
|
|
142
|
+
return {
|
|
143
|
+
id,
|
|
144
|
+
item: item({
|
|
145
|
+
type: "text",
|
|
146
|
+
position: {
|
|
147
|
+
x,
|
|
148
|
+
y
|
|
149
|
+
},
|
|
150
|
+
...color === "neutral" ? {} : { style: { fill: color } },
|
|
151
|
+
props: { text }
|
|
152
|
+
})
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function createShapeBoardItem(geometry, x, y, color = DEFAULT_BOARD_TOOL_STYLES.shape.color, id = createBoardItemId(), box) {
|
|
156
|
+
return {
|
|
157
|
+
id,
|
|
158
|
+
item: item({
|
|
159
|
+
type: "shape",
|
|
160
|
+
...box ? {
|
|
161
|
+
position: {
|
|
162
|
+
x: box.x,
|
|
163
|
+
y: box.y
|
|
164
|
+
},
|
|
165
|
+
size: {
|
|
166
|
+
width: box.width,
|
|
167
|
+
height: box.height
|
|
168
|
+
}
|
|
169
|
+
} : centered(x, y, DEFAULT_SHAPE_SIZE),
|
|
170
|
+
style: { stroke: color },
|
|
171
|
+
props: { geometry }
|
|
172
|
+
})
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function createFrameBoardItem(x, y, color = DEFAULT_BOARD_TOOL_STYLES.frame.color, label = "Frame", id = createBoardItemId(), box) {
|
|
176
|
+
return {
|
|
177
|
+
id,
|
|
178
|
+
item: item({
|
|
179
|
+
type: "frame",
|
|
180
|
+
...box ? {
|
|
181
|
+
position: {
|
|
182
|
+
x: box.x,
|
|
183
|
+
y: box.y
|
|
184
|
+
},
|
|
185
|
+
size: {
|
|
186
|
+
width: box.width,
|
|
187
|
+
height: box.height
|
|
188
|
+
}
|
|
189
|
+
} : centered(x, y, DEFAULT_FRAME_SIZE),
|
|
190
|
+
...color === "neutral" ? {} : { style: { stroke: color } },
|
|
191
|
+
props: { label }
|
|
192
|
+
})
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function createAppBoardItem(app, x, y, id = createBoardItemId()) {
|
|
196
|
+
return {
|
|
197
|
+
id,
|
|
198
|
+
item: {
|
|
199
|
+
...createFrameBoardItem(x, y, "brand", app.name, id).item,
|
|
200
|
+
metadata: { cohubApp: app }
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function createDrawBoardItem(worldPoints, color, size = 4, id = createBoardItemId()) {
|
|
205
|
+
const origin = pointsRect(worldPoints);
|
|
206
|
+
const points = worldPoints.map((point) => ({
|
|
207
|
+
x: quantizeDrawCoordinate(point.x - origin.x),
|
|
208
|
+
y: quantizeDrawCoordinate(point.y - origin.y),
|
|
209
|
+
p: point.p
|
|
210
|
+
}));
|
|
211
|
+
return {
|
|
212
|
+
id,
|
|
213
|
+
item: item({
|
|
214
|
+
type: "draw",
|
|
215
|
+
position: {
|
|
216
|
+
x: origin.x,
|
|
217
|
+
y: origin.y
|
|
218
|
+
},
|
|
219
|
+
style: {
|
|
220
|
+
stroke: color,
|
|
221
|
+
strokeWidth: size
|
|
222
|
+
},
|
|
223
|
+
props: { points }
|
|
224
|
+
})
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function createArrowBoardItem(start, end, color, id = createBoardItemId(), size = DEFAULT_BOARD_TOOL_STYLES.arrow.size, startEnd) {
|
|
228
|
+
const local = (point) => ({
|
|
229
|
+
x: point.x - start.x,
|
|
230
|
+
y: point.y - start.y
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
id,
|
|
234
|
+
item: item({
|
|
235
|
+
type: "arrow",
|
|
236
|
+
position: {
|
|
237
|
+
x: start.x,
|
|
238
|
+
y: start.y
|
|
239
|
+
},
|
|
240
|
+
style: {
|
|
241
|
+
stroke: color,
|
|
242
|
+
strokeWidth: size
|
|
243
|
+
},
|
|
244
|
+
props: {
|
|
245
|
+
start: startEnd ?? {
|
|
246
|
+
x: 0,
|
|
247
|
+
y: 0
|
|
248
|
+
},
|
|
249
|
+
end: "item" in end ? end : local(end)
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function titleForBoardItem(value) {
|
|
255
|
+
switch (value.type) {
|
|
256
|
+
case "text": return value.props.text.split("\n")[0] || "Text";
|
|
257
|
+
case "shape": return value.props.text.split("\n")[0] || value.props.geometry;
|
|
258
|
+
case "draw": return "Drawing";
|
|
259
|
+
case "arrow": return value.props.label || "Arrow";
|
|
260
|
+
case "frame": return value.props.label || "Frame";
|
|
261
|
+
case "image":
|
|
262
|
+
case "video":
|
|
263
|
+
case "audio": return value.props.snapshot?.title ?? getMediaResourceTitle(value.props.src);
|
|
264
|
+
case "file": return value.props.snapshot?.title ?? fileStem(value.props.src);
|
|
265
|
+
case "task": return value.props.snapshot.title;
|
|
266
|
+
case "effect": return value.props.kind;
|
|
267
|
+
case "custom": return value.script.src.split("/").pop() ?? "Custom";
|
|
268
|
+
default: return value.type;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
export { createAppBoardItem, createArrowBoardItem, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, mediaFrameSize, titleForBoardItem };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BoardExtensionItem, BoardItemType } from "../../../protocol/dist/board-model.js";
|
|
2
|
+
import "../../../protocol/dist/index.js";
|
|
3
|
+
import { Rect, WorldPoint } from "../geometry.js";
|
|
4
|
+
import { BoardSceneItem } from "../scene.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/board/model/items/definition.d.ts
|
|
7
|
+
type BoardItemCapabilities = {
|
|
8
|
+
canMove: boolean;
|
|
9
|
+
canResize: boolean;
|
|
10
|
+
aspectLocked: boolean;
|
|
11
|
+
canRotate: boolean;
|
|
12
|
+
canEdit: boolean;
|
|
13
|
+
canConnect: boolean;
|
|
14
|
+
canSnap: boolean;
|
|
15
|
+
canLock: boolean;
|
|
16
|
+
};
|
|
17
|
+
type BoardItemResizeMode = "none" | "uniform" | "free";
|
|
18
|
+
declare const FULL_CAPABILITIES: BoardItemCapabilities;
|
|
19
|
+
type BoardItemDefinition<Props extends Record<string, unknown> = Record<string, unknown>> = {
|
|
20
|
+
type: BoardItemType;
|
|
21
|
+
capabilities?: Partial<BoardItemCapabilities>;
|
|
22
|
+
size?: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
props?: z.ZodType<Props>;
|
|
27
|
+
bounds?: (item: BoardSceneItem) => Rect;
|
|
28
|
+
hitTest?: (item: BoardSceneItem, point: WorldPoint) => boolean;
|
|
29
|
+
};
|
|
30
|
+
type BoardItemOf<Definition> = Definition extends BoardItemDefinition<infer Props> ? BoardExtensionItem & {
|
|
31
|
+
props: Props;
|
|
32
|
+
} : never;
|
|
33
|
+
declare function defineBoardItem<Props extends Record<string, unknown>>(definition: BoardItemDefinition<Props>): BoardItemDefinition<Props>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { BoardItemCapabilities, BoardItemDefinition, BoardItemOf, BoardItemResizeMode, FULL_CAPABILITIES, defineBoardItem };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BOARD_EXTENSION_TYPE_PATTERN, isBuiltinItemType } from "../../../protocol/dist/board-model.js";
|
|
2
|
+
//#region src/board/model/items/definition.ts
|
|
3
|
+
const FULL_CAPABILITIES = {
|
|
4
|
+
canMove: true,
|
|
5
|
+
canResize: true,
|
|
6
|
+
aspectLocked: false,
|
|
7
|
+
canRotate: true,
|
|
8
|
+
canEdit: false,
|
|
9
|
+
canConnect: true,
|
|
10
|
+
canSnap: true,
|
|
11
|
+
canLock: true
|
|
12
|
+
};
|
|
13
|
+
function defineBoardItem(definition) {
|
|
14
|
+
if (!isBuiltinItemType(definition.type) && !BOARD_EXTENSION_TYPE_PATTERN.test(definition.type)) throw new Error(`Board item type "${definition.type}" must be namespaced, like "acme.order".`);
|
|
15
|
+
return definition;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { FULL_CAPABILITIES, defineBoardItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/board/model/items/id.ts
|
|
2
|
+
function createBoardEntityId() {
|
|
3
|
+
const cryptoRef = globalThis.crypto;
|
|
4
|
+
if (cryptoRef && typeof cryptoRef.randomUUID === "function") return cryptoRef.randomUUID();
|
|
5
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
6
|
+
}
|
|
7
|
+
function createBoardItemId() {
|
|
8
|
+
return `item_${createBoardEntityId()}`;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createBoardEntityId, createBoardItemId };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BoardItemCapabilities, BoardItemDefinition, BoardItemOf, BoardItemResizeMode, FULL_CAPABILITIES, defineBoardItem } from "./definition.js";
|
|
2
|
+
import { builtinBoardItems } from "./builtin.js";
|
|
3
|
+
import { BoardAppMetadata, BoardItemEntry, BoardMediaItemKind, createAppBoardItem, createArrowBoardItem, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, mediaFrameSize, titleForBoardItem } from "./create.js";
|
|
4
|
+
import { createBoardEntityId, createBoardItemId } from "./id.js";
|
|
5
|
+
import { BoardItemInput, BoardRegistry, createBoardRegistry, defaultBoardRegistry } from "./registry.js";
|
|
6
|
+
export { BoardAppMetadata, BoardItemCapabilities, BoardItemDefinition, BoardItemEntry, BoardItemInput, BoardItemOf, BoardItemResizeMode, BoardMediaItemKind, BoardRegistry, FULL_CAPABILITIES, builtinBoardItems, createAppBoardItem, createArrowBoardItem, createBoardEntityId, createBoardItemId, createBoardRegistry, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, defaultBoardRegistry, defineBoardItem, mediaFrameSize, titleForBoardItem };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FULL_CAPABILITIES, defineBoardItem } from "./definition.js";
|
|
2
|
+
import { builtinBoardItems } from "./builtin.js";
|
|
3
|
+
import { createBoardEntityId, createBoardItemId } from "./id.js";
|
|
4
|
+
import { createAppBoardItem, createArrowBoardItem, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, mediaFrameSize, titleForBoardItem } from "./create.js";
|
|
5
|
+
import { createBoardRegistry, defaultBoardRegistry } from "./registry.js";
|
|
6
|
+
export { FULL_CAPABILITIES, builtinBoardItems, createAppBoardItem, createArrowBoardItem, createBoardEntityId, createBoardItemId, createBoardRegistry, createDrawBoardItem, createFileNodeForPath, createFrameBoardItem, createMediaBoardItem, createShapeBoardItem, createTaskBoardItem, createTextBoardItem, defaultBoardRegistry, defineBoardItem, mediaFrameSize, titleForBoardItem };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BoardItem } from "../../../protocol/dist/board-model.js";
|
|
2
|
+
import "../../../protocol/dist/index.js";
|
|
3
|
+
import { Rect, WorldPoint } from "../geometry.js";
|
|
4
|
+
import { BoardSceneItem } from "../scene.js";
|
|
5
|
+
import { BoardItemCapabilities, BoardItemDefinition, BoardItemResizeMode } from "./definition.js";
|
|
6
|
+
import { BoardItemEntry } from "./create.js";
|
|
7
|
+
//#region src/board/model/items/registry.d.ts
|
|
8
|
+
type BoardItemInput = {
|
|
9
|
+
props?: Record<string, unknown>;
|
|
10
|
+
at: WorldPoint;
|
|
11
|
+
size?: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
id?: string;
|
|
16
|
+
};
|
|
17
|
+
type BoardRegistry = {
|
|
18
|
+
readonly definitions: readonly BoardItemDefinition[];
|
|
19
|
+
get(type: string): BoardItemDefinition | undefined;
|
|
20
|
+
capabilities(item: Pick<BoardItem, "type">): BoardItemCapabilities;
|
|
21
|
+
resizeMode(item: Pick<BoardItem, "type">): BoardItemResizeMode;
|
|
22
|
+
bounds(item: BoardSceneItem): Rect;
|
|
23
|
+
hitTest(item: BoardSceneItem, point: WorldPoint): boolean;
|
|
24
|
+
validateProps(type: string, props: unknown): {
|
|
25
|
+
ok: true;
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
create(type: string, input: BoardItemInput): BoardItemEntry;
|
|
31
|
+
};
|
|
32
|
+
declare function createBoardRegistry(definitions?: Iterable<BoardItemDefinition>): BoardRegistry;
|
|
33
|
+
declare const defaultBoardRegistry: BoardRegistry;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { BoardItemInput, BoardRegistry, createBoardRegistry, defaultBoardRegistry };
|