@pixerate/editor-react 0.91.1 → 0.93.1
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/dist/animation-editor/AnimationEditor.d.cts +11 -1
- package/dist/animation-editor/AnimationEditor.d.ts +11 -1
- package/dist/animation-editor/index.cjs +494 -366
- package/dist/animation-editor/index.js +48 -4
- package/dist/canvas/AgentPresenceLayer.d.cts +3 -0
- package/dist/canvas/AgentPresenceLayer.d.ts +3 -0
- package/dist/canvas/index.cjs +1033 -893
- package/dist/canvas/index.d.cts +2 -0
- package/dist/canvas/index.d.ts +2 -0
- package/dist/canvas/index.js +125 -74
- package/dist/canvas/useCanvasPlaybackSurface.d.cts +28 -0
- package/dist/canvas/useCanvasPlaybackSurface.d.ts +28 -0
- package/dist/chart/ChartEditor.d.cts +12 -1
- package/dist/chart/ChartEditor.d.ts +12 -1
- package/dist/chart/index.cjs +187 -29
- package/dist/chart/index.js +74 -10
- package/dist/{chunk-SMMO7CZB.js → chunk-6YRSQW2V.js} +84 -2
- package/dist/chunk-7I73DW4V.js +43 -0
- package/dist/{chunk-GML6BYCN.js → chunk-GECXTPSH.js} +53 -3
- package/dist/chunk-IPVWWVSF.js +96 -0
- package/dist/hooks/useAgentToolProvider.d.cts +6 -2
- package/dist/hooks/useAgentToolProvider.d.ts +6 -2
- package/dist/image-editor/ImageEditor.d.cts +10 -0
- package/dist/image-editor/ImageEditor.d.ts +10 -0
- package/dist/image-editor/index.cjs +1028 -864
- package/dist/image-editor/index.js +2 -1
- package/dist/index.cjs +2070 -1812
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +21 -3
- package/dist/paint-editor/PaintEditor.d.cts +12 -1
- package/dist/paint-editor/PaintEditor.d.ts +12 -1
- package/dist/paint-editor/index.cjs +319 -164
- package/dist/paint-editor/index.js +84 -11
- package/dist/parameters/ParametersPanel.d.cts +11 -1
- package/dist/parameters/ParametersPanel.d.ts +11 -1
- package/dist/parameters/index.cjs +190 -41
- package/dist/parameters/index.js +23 -4
- package/dist/playback/AgentPlaybackContext.d.cts +9 -0
- package/dist/playback/AgentPlaybackContext.d.ts +9 -0
- package/dist/playback/PresenceLayer.d.cts +28 -0
- package/dist/playback/PresenceLayer.d.ts +28 -0
- package/dist/playback/index.d.cts +4 -0
- package/dist/playback/index.d.ts +4 -0
- package/dist/playback/useElementPlaybackSurface.d.cts +19 -0
- package/dist/playback/useElementPlaybackSurface.d.ts +19 -0
- package/dist/playback/usePlaybackSurface.d.cts +11 -0
- package/dist/playback/usePlaybackSurface.d.ts +11 -0
- package/dist/spreadsheet/SpreadsheetEditor.d.cts +10 -0
- package/dist/spreadsheet/SpreadsheetEditor.d.ts +10 -0
- package/dist/spreadsheet/index.cjs +443 -313
- package/dist/spreadsheet/index.js +2 -1
- package/dist/vector/VectorCanvas.d.cts +11 -1
- package/dist/vector/VectorCanvas.d.ts +11 -1
- package/dist/vector/index.cjs +946 -826
- package/dist/vector/index.js +42 -3
- package/dist/video-editor/VideoEditor.d.cts +6 -1
- package/dist/video-editor/VideoEditor.d.ts +6 -1
- package/dist/video-editor/VideoTimeline.d.cts +11 -1
- package/dist/video-editor/VideoTimeline.d.ts +11 -1
- package/dist/video-editor/index.cjs +463 -332
- package/dist/video-editor/index.js +53 -5
- package/package.json +3 -3
package/dist/canvas/index.cjs
CHANGED
|
@@ -30,23 +30,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/canvas/index.ts
|
|
31
31
|
var canvas_exports = {};
|
|
32
32
|
__export(canvas_exports, {
|
|
33
|
-
ANIMATABLE_PROPERTIES: () =>
|
|
34
|
-
ANIMATION_DATA_KEY: () =>
|
|
35
|
-
ANIMATION_EASING_LABELS: () =>
|
|
36
|
-
ANIMATION_EASING_PRESETS: () =>
|
|
37
|
-
ANIMATION_TIME_EPSILON: () =>
|
|
38
|
-
AUTO_LAYOUT_DATA_KEY: () =>
|
|
33
|
+
ANIMATABLE_PROPERTIES: () => import_canvas34.ANIMATABLE_PROPERTIES,
|
|
34
|
+
ANIMATION_DATA_KEY: () => import_canvas34.ANIMATION_DATA_KEY,
|
|
35
|
+
ANIMATION_EASING_LABELS: () => import_canvas34.ANIMATION_EASING_LABELS,
|
|
36
|
+
ANIMATION_EASING_PRESETS: () => import_canvas34.ANIMATION_EASING_PRESETS,
|
|
37
|
+
ANIMATION_TIME_EPSILON: () => import_canvas34.ANIMATION_TIME_EPSILON,
|
|
38
|
+
AUTO_LAYOUT_DATA_KEY: () => import_canvas32.AUTO_LAYOUT_DATA_KEY,
|
|
39
39
|
AgentPresenceLayer: () => AgentPresenceLayer,
|
|
40
|
-
AnimationEditError: () =>
|
|
41
|
-
AnimationPlayer: () =>
|
|
40
|
+
AnimationEditError: () => import_canvas34.AnimationEditError,
|
|
41
|
+
AnimationPlayer: () => import_canvas34.AnimationPlayer,
|
|
42
42
|
AnimationTimeline: () => AnimationTimeline,
|
|
43
|
-
CANVAS_COMPONENT_DRAG_TYPE: () =>
|
|
44
|
-
CANVAS_GRADIENT_PRESETS: () =>
|
|
45
|
-
CANVAS_TOKEN_PROPERTIES: () =>
|
|
46
|
-
CHILD_LAYOUT_DATA_KEY: () =>
|
|
47
|
-
CONNECTION_LINE_TYPES: () =>
|
|
48
|
-
CSS_ANIMATION_PROPERTIES: () =>
|
|
49
|
-
CUBIC_BEZIER_PRESETS: () =>
|
|
43
|
+
CANVAS_COMPONENT_DRAG_TYPE: () => import_canvas35.CANVAS_COMPONENT_DRAG_TYPE,
|
|
44
|
+
CANVAS_GRADIENT_PRESETS: () => import_canvas35.CANVAS_GRADIENT_PRESETS,
|
|
45
|
+
CANVAS_TOKEN_PROPERTIES: () => import_canvas33.CANVAS_TOKEN_PROPERTIES,
|
|
46
|
+
CHILD_LAYOUT_DATA_KEY: () => import_canvas32.CHILD_LAYOUT_DATA_KEY,
|
|
47
|
+
CONNECTION_LINE_TYPES: () => import_canvas28.CONNECTION_LINE_TYPES,
|
|
48
|
+
CSS_ANIMATION_PROPERTIES: () => import_canvas34.CSS_ANIMATION_PROPERTIES,
|
|
49
|
+
CUBIC_BEZIER_PRESETS: () => import_canvas34.CUBIC_BEZIER_PRESETS,
|
|
50
50
|
CanvasComponentsPanel: () => CanvasComponentsPanel,
|
|
51
51
|
CanvasDrawLayer: () => CanvasDrawLayer,
|
|
52
52
|
CanvasEffectsPanel: () => CanvasEffectsPanel,
|
|
@@ -54,312 +54,313 @@ __export(canvas_exports, {
|
|
|
54
54
|
CanvasGuidesLayer: () => CanvasGuidesLayer,
|
|
55
55
|
CanvasInstanceInspector: () => CanvasInstanceInspector,
|
|
56
56
|
CanvasNodeEffectLayer: () => CanvasNodeEffectLayer,
|
|
57
|
-
CanvasScenesStore: () =>
|
|
58
|
-
DEFAULT_ARRANGE_SHORTCUTS: () =>
|
|
57
|
+
CanvasScenesStore: () => import_canvas28.CanvasScenesStore,
|
|
58
|
+
DEFAULT_ARRANGE_SHORTCUTS: () => import_canvas28.DEFAULT_ARRANGE_SHORTCUTS,
|
|
59
59
|
DiagramPresenceLayer: () => DiagramPresenceLayer,
|
|
60
|
-
MAX_KEYFRAME_REFS: () =>
|
|
61
|
-
ManualClock: () =>
|
|
60
|
+
MAX_KEYFRAME_REFS: () => import_canvas34.MAX_KEYFRAME_REFS,
|
|
61
|
+
ManualClock: () => import_canvas31.ManualClock,
|
|
62
62
|
MermaidDiagramGroup: () => MermaidDiagramGroup,
|
|
63
63
|
MermaidDiagramNode: () => MermaidDiagramNode,
|
|
64
64
|
MermaidFamilyScene: () => MermaidFamilyScene,
|
|
65
65
|
MermaidThumbnail: () => MermaidThumbnail,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
PresenceLayer: () => PresenceLayer,
|
|
67
|
+
RESIZE_HANDLES: () => import_canvas27.RESIZE_HANDLES,
|
|
68
|
+
SHAPE_DATA_KEY: () => import_canvas29.SHAPE_DATA_KEY,
|
|
69
|
+
SHAPE_KINDS: () => import_canvas29.SHAPE_KINDS,
|
|
70
|
+
SHAPE_NODE_TYPE: () => import_canvas29.SHAPE_NODE_TYPE,
|
|
71
|
+
SHAPE_OPERATIONS: () => import_canvas29.SHAPE_OPERATIONS,
|
|
71
72
|
ShapeNode: () => ShapeNode,
|
|
72
73
|
ShapeNodeZoomContext: () => ShapeNodeZoomContext,
|
|
73
74
|
ShapeNodeZoomProvider: () => ShapeNodeZoomProvider,
|
|
74
|
-
TOKEN_BINDINGS_DATA_KEY: () =>
|
|
75
|
-
TOKEN_MODES_DATA_KEY: () =>
|
|
75
|
+
TOKEN_BINDINGS_DATA_KEY: () => import_canvas33.TOKEN_BINDINGS_DATA_KEY,
|
|
76
|
+
TOKEN_MODES_DATA_KEY: () => import_canvas33.TOKEN_MODES_DATA_KEY,
|
|
76
77
|
TokenBindingPicker: () => TokenBindingPicker,
|
|
77
78
|
TokenModeSwitcher: () => TokenModeSwitcher,
|
|
78
|
-
addCanvasVariant: () =>
|
|
79
|
-
addKeyframesAtTime: () =>
|
|
80
|
-
alignNodes: () =>
|
|
81
|
-
angleToSvgLinearCoords: () =>
|
|
82
|
-
animateNode: () =>
|
|
83
|
-
applyAnimation: () =>
|
|
84
|
-
applyAnimationOverrides: () =>
|
|
85
|
-
applyConstraints: () =>
|
|
86
|
-
applyNodeUpdates: () =>
|
|
87
|
-
applyShapeCombination: () =>
|
|
88
|
-
applyShapeReplacement: () =>
|
|
89
|
-
bezierPathArea: () =>
|
|
90
|
-
bezierPathBounds: () =>
|
|
91
|
-
bezierPathLength: () =>
|
|
92
|
-
bezierPathPointAtLength: () =>
|
|
93
|
-
bezierPathSignedArea: () =>
|
|
94
|
-
bezierPathToSvg: () =>
|
|
95
|
-
bindCanvasComponentProperty: () =>
|
|
96
|
-
bindCanvasToken: () =>
|
|
97
|
-
blendLayout: () =>
|
|
98
|
-
boundsOf: () =>
|
|
99
|
-
brushstrokeScaleBucket: () =>
|
|
100
|
-
brushstrokeSeed: () =>
|
|
101
|
-
calculateDagreReflowDisplacement: () =>
|
|
102
|
-
calculateDirectionalDisplacement: () =>
|
|
103
|
-
canCombineShapeNodes: () =>
|
|
104
|
-
canOffsetShapeNodes: () =>
|
|
105
|
-
canOutlineShapeNodeStrokes: () =>
|
|
106
|
-
canvasHeight: () =>
|
|
107
|
-
centerNodes: () =>
|
|
108
|
-
centre: () =>
|
|
109
|
-
clampAnimationValue: () =>
|
|
110
|
-
clampLayoutSize: () =>
|
|
111
|
-
combineCanvasComponentsAsVariants: () =>
|
|
112
|
-
combineShapeNodes: () =>
|
|
113
|
-
computeNodesBoundingBox: () =>
|
|
114
|
-
computeSnapGuides: () =>
|
|
115
|
-
connectedOnly: () =>
|
|
116
|
-
copyKeyframes: () =>
|
|
117
|
-
countPathSegments: () =>
|
|
118
|
-
createAnimationPlayer: () =>
|
|
119
|
-
createBezierTrajectory: () =>
|
|
120
|
-
createCanvasAnimationController: () =>
|
|
121
|
-
createCanvasAutoLayoutController: () =>
|
|
122
|
-
createCanvasComponent: () =>
|
|
123
|
-
createCanvasComponentsController: () =>
|
|
124
|
-
createCanvasDrawController: () =>
|
|
125
|
-
createCanvasInstance: () =>
|
|
126
|
-
createCanvasScenesStore: () =>
|
|
127
|
-
createDefaultStrokeStyle: () =>
|
|
128
|
-
createFanOutTrajectory: () =>
|
|
129
|
-
createGuideIndex: () =>
|
|
130
|
-
createNodeGuideIndex: () =>
|
|
131
|
-
cubicBezierAt: () =>
|
|
132
|
-
cubicPointAt: () =>
|
|
133
|
-
cubicsToPathData: () =>
|
|
134
|
-
dashContours: () =>
|
|
135
|
-
defaultEasing: () =>
|
|
136
|
-
deleteKeyframes: () =>
|
|
137
|
-
detachCanvasInstance: () =>
|
|
138
|
-
detachTokenBindings: () =>
|
|
139
|
-
distanceToBezierPath: () =>
|
|
140
|
-
distributeNodes: () =>
|
|
141
|
-
dividePaths: () =>
|
|
142
|
-
dividePolygons: () =>
|
|
143
|
-
easingFromInfluence: () =>
|
|
144
|
-
easingLabel: () =>
|
|
145
|
-
easingToCss: () =>
|
|
146
|
-
ensureLayout: () =>
|
|
147
|
-
estimateCanvasHeight: () =>
|
|
148
|
-
estimateNodeSize: () =>
|
|
149
|
-
evaluateAnimation: () =>
|
|
150
|
-
evaluateEasing: () =>
|
|
151
|
-
evaluateTrack: () =>
|
|
152
|
-
excludePaths: () =>
|
|
153
|
-
exportCssAnimation: () =>
|
|
154
|
-
findConnectorSnap: () =>
|
|
155
|
-
findStrokesAtPoint: () =>
|
|
156
|
-
fitCubicRun: () =>
|
|
157
|
-
fitCubics: () =>
|
|
158
|
-
fitFreehandPath: () =>
|
|
159
|
-
fitPathData: () =>
|
|
160
|
-
fitViewportToNodes: () =>
|
|
161
|
-
fitViewportToRect: () =>
|
|
162
|
-
flattenSvgPath: () =>
|
|
163
|
-
flowSide: () =>
|
|
164
|
-
formatAnimationTime: () =>
|
|
165
|
-
formatOklab: () =>
|
|
166
|
-
freehandBrushstroke: () =>
|
|
167
|
-
getAbsolutePosition: () =>
|
|
168
|
-
getAnimatableProperty: () =>
|
|
169
|
-
getAnimatedProperties: () =>
|
|
170
|
-
getAnimatedValue: () =>
|
|
171
|
-
getAnimationDuration: () =>
|
|
172
|
-
getAnimationTrack: () =>
|
|
173
|
-
getAutoLayout: () =>
|
|
174
|
-
getAutoLayoutGrid: () =>
|
|
175
|
-
getAutoLayoutInsertTarget: () =>
|
|
176
|
-
getBindableTokenProperties: () =>
|
|
177
|
-
getBrushedShapeSvg: () =>
|
|
178
|
-
getCanvasComponentDragId: () =>
|
|
179
|
-
getCanvasTokenProperty: () =>
|
|
180
|
-
getCenteredNodePosition: () =>
|
|
181
|
-
getChildLayout: () =>
|
|
182
|
-
getComponentSourceId: () =>
|
|
183
|
-
getCssPropertyAnimations: () =>
|
|
184
|
-
getEffectiveTokenModes: () =>
|
|
185
|
-
getFlowChildren: () =>
|
|
186
|
-
getInstanceData: () =>
|
|
187
|
-
getInstanceStatus: () =>
|
|
188
|
-
getKeyframeTimes: () =>
|
|
189
|
-
getLayoutParent: () =>
|
|
190
|
-
getLayoutSizing: () =>
|
|
191
|
-
getLayoutedNodes: () =>
|
|
192
|
-
getNextVariantValues: () =>
|
|
193
|
-
getNodeAnimation: () =>
|
|
194
|
-
getNodeOverrides: () =>
|
|
195
|
-
getNodeRect: () =>
|
|
196
|
-
getNodeShape: () =>
|
|
197
|
-
getNodeSize: () =>
|
|
198
|
-
getNodeTokenBindings: () =>
|
|
199
|
-
getNodeTokenModes: () =>
|
|
200
|
-
getResizingNodeRect: () =>
|
|
201
|
-
getShapeRenderData: () =>
|
|
202
|
-
getShapeSvg: () =>
|
|
203
|
-
getTimelineRows: () =>
|
|
204
|
-
getTimelineTicks: () =>
|
|
205
|
-
getTokenPropertyScope: () =>
|
|
206
|
-
getTokensForProperty: () =>
|
|
207
|
-
gradientToSvgDef: () =>
|
|
208
|
-
handlePoint: () =>
|
|
209
|
-
hasVisibleStroke: () =>
|
|
210
|
-
inferResizeHandle: () =>
|
|
211
|
-
inspectCanvasInstance: () =>
|
|
212
|
-
inspectNodeTokens: () =>
|
|
213
|
-
interpolateAnimationValue: () =>
|
|
214
|
-
intersectPaths: () =>
|
|
215
|
-
intersectPolygons: () =>
|
|
216
|
-
invertNodeUpdates: () =>
|
|
217
|
-
isAnimationEasing: () =>
|
|
218
|
-
isAnimationKeyframe: () =>
|
|
219
|
-
isAutoLayoutFrame: () =>
|
|
220
|
-
isBrushedShape: () =>
|
|
221
|
-
isCanvasComponent: () =>
|
|
222
|
-
isCanvasComponentSet: () =>
|
|
223
|
-
isCanvasGradient: () =>
|
|
224
|
-
isCanvasInstance: () =>
|
|
225
|
-
isCssExportExact: () =>
|
|
226
|
-
isEventFromTextInput: () =>
|
|
227
|
-
isKeyframeSelected: () =>
|
|
228
|
-
isLocked: () =>
|
|
229
|
-
isMeasureModifierHeld: () =>
|
|
230
|
-
isNodeAnimated: () =>
|
|
231
|
-
isShapeDescription: () =>
|
|
232
|
-
isShapeNode: () =>
|
|
233
|
-
isStraightCubic: () =>
|
|
234
|
-
isValidCanvasNode: () =>
|
|
235
|
-
isValidUrl: () =>
|
|
236
|
-
layoutAll: () =>
|
|
237
|
-
layoutBounds: () =>
|
|
238
|
-
layoutFrame: () =>
|
|
239
|
-
layoutUp: () =>
|
|
240
|
-
layoutUpMany: () =>
|
|
241
|
-
linearPositionTrajectory: () =>
|
|
242
|
-
linearTrajectory: () =>
|
|
243
|
-
listCanvasBrushes: () =>
|
|
244
|
-
listCanvasComponents: () =>
|
|
245
|
-
loadCanvasBrushstrokeRenderer: () =>
|
|
246
|
-
lockNodes: () =>
|
|
247
|
-
makeSizingCoherent: () =>
|
|
248
|
-
matchArrangeShortcut: () =>
|
|
249
|
-
matchSize: () =>
|
|
250
|
-
measureBetween: () =>
|
|
251
|
-
measureLabel: () =>
|
|
252
|
-
measureSelection: () =>
|
|
253
|
-
measureToLine: () =>
|
|
254
|
-
mergeNodeUpdates: () =>
|
|
79
|
+
addCanvasVariant: () => import_canvas35.addCanvasVariant,
|
|
80
|
+
addKeyframesAtTime: () => import_canvas34.addKeyframesAtTime,
|
|
81
|
+
alignNodes: () => import_canvas28.alignNodes,
|
|
82
|
+
angleToSvgLinearCoords: () => import_canvas35.angleToSvgLinearCoords,
|
|
83
|
+
animateNode: () => import_canvas34.animateNode,
|
|
84
|
+
applyAnimation: () => import_canvas34.applyAnimation,
|
|
85
|
+
applyAnimationOverrides: () => import_canvas34.applyAnimationOverrides,
|
|
86
|
+
applyConstraints: () => import_canvas32.applyConstraints,
|
|
87
|
+
applyNodeUpdates: () => import_canvas28.applyNodeUpdates,
|
|
88
|
+
applyShapeCombination: () => import_canvas29.applyShapeCombination,
|
|
89
|
+
applyShapeReplacement: () => import_canvas30.applyShapeReplacement,
|
|
90
|
+
bezierPathArea: () => import_canvas30.bezierPathArea,
|
|
91
|
+
bezierPathBounds: () => import_canvas30.bezierPathBounds,
|
|
92
|
+
bezierPathLength: () => import_canvas30.bezierPathLength,
|
|
93
|
+
bezierPathPointAtLength: () => import_canvas30.bezierPathPointAtLength,
|
|
94
|
+
bezierPathSignedArea: () => import_canvas30.bezierPathSignedArea,
|
|
95
|
+
bezierPathToSvg: () => import_canvas30.bezierPathToSvg,
|
|
96
|
+
bindCanvasComponentProperty: () => import_canvas35.bindCanvasComponentProperty,
|
|
97
|
+
bindCanvasToken: () => import_canvas33.bindCanvasToken,
|
|
98
|
+
blendLayout: () => import_canvas31.blendLayout,
|
|
99
|
+
boundsOf: () => import_canvas31.boundsOf,
|
|
100
|
+
brushstrokeScaleBucket: () => import_canvas35.brushstrokeScaleBucket,
|
|
101
|
+
brushstrokeSeed: () => import_canvas35.brushstrokeSeed,
|
|
102
|
+
calculateDagreReflowDisplacement: () => import_canvas31.calculateDagreReflowDisplacement,
|
|
103
|
+
calculateDirectionalDisplacement: () => import_canvas31.calculateDirectionalDisplacement,
|
|
104
|
+
canCombineShapeNodes: () => import_canvas29.canCombineShapeNodes,
|
|
105
|
+
canOffsetShapeNodes: () => import_canvas30.canOffsetShapeNodes,
|
|
106
|
+
canOutlineShapeNodeStrokes: () => import_canvas30.canOutlineShapeNodeStrokes,
|
|
107
|
+
canvasHeight: () => import_canvas31.canvasHeight,
|
|
108
|
+
centerNodes: () => import_canvas31.centerNodes,
|
|
109
|
+
centre: () => import_canvas31.centre,
|
|
110
|
+
clampAnimationValue: () => import_canvas34.clampAnimationValue,
|
|
111
|
+
clampLayoutSize: () => import_canvas32.clampLayoutSize,
|
|
112
|
+
combineCanvasComponentsAsVariants: () => import_canvas35.combineCanvasComponentsAsVariants,
|
|
113
|
+
combineShapeNodes: () => import_canvas29.combineShapeNodes,
|
|
114
|
+
computeNodesBoundingBox: () => import_canvas31.computeNodesBoundingBox,
|
|
115
|
+
computeSnapGuides: () => import_canvas28.computeSnapGuides,
|
|
116
|
+
connectedOnly: () => import_canvas31.connectedOnly,
|
|
117
|
+
copyKeyframes: () => import_canvas34.copyKeyframes,
|
|
118
|
+
countPathSegments: () => import_canvas30.countPathSegments,
|
|
119
|
+
createAnimationPlayer: () => import_canvas34.createAnimationPlayer,
|
|
120
|
+
createBezierTrajectory: () => import_canvas31.createBezierTrajectory,
|
|
121
|
+
createCanvasAnimationController: () => import_canvas34.createCanvasAnimationController,
|
|
122
|
+
createCanvasAutoLayoutController: () => import_canvas32.createCanvasAutoLayoutController,
|
|
123
|
+
createCanvasComponent: () => import_canvas35.createCanvasComponent,
|
|
124
|
+
createCanvasComponentsController: () => import_canvas35.createCanvasComponentsController,
|
|
125
|
+
createCanvasDrawController: () => import_canvas35.createCanvasDrawController,
|
|
126
|
+
createCanvasInstance: () => import_canvas35.createCanvasInstance,
|
|
127
|
+
createCanvasScenesStore: () => import_canvas28.createCanvasScenesStore,
|
|
128
|
+
createDefaultStrokeStyle: () => import_canvas35.createDefaultStrokeStyle,
|
|
129
|
+
createFanOutTrajectory: () => import_canvas31.createFanOutTrajectory,
|
|
130
|
+
createGuideIndex: () => import_canvas28.createGuideIndex,
|
|
131
|
+
createNodeGuideIndex: () => import_canvas28.createNodeGuideIndex,
|
|
132
|
+
cubicBezierAt: () => import_canvas34.cubicBezierAt,
|
|
133
|
+
cubicPointAt: () => import_canvas27.cubicPointAt,
|
|
134
|
+
cubicsToPathData: () => import_canvas27.cubicsToPathData,
|
|
135
|
+
dashContours: () => import_canvas30.dashContours,
|
|
136
|
+
defaultEasing: () => import_canvas31.defaultEasing,
|
|
137
|
+
deleteKeyframes: () => import_canvas34.deleteKeyframes,
|
|
138
|
+
detachCanvasInstance: () => import_canvas35.detachCanvasInstance,
|
|
139
|
+
detachTokenBindings: () => import_canvas33.detachTokenBindings,
|
|
140
|
+
distanceToBezierPath: () => import_canvas30.distanceToBezierPath,
|
|
141
|
+
distributeNodes: () => import_canvas28.distributeNodes,
|
|
142
|
+
dividePaths: () => import_canvas30.dividePaths,
|
|
143
|
+
dividePolygons: () => import_canvas29.dividePolygons,
|
|
144
|
+
easingFromInfluence: () => import_canvas34.easingFromInfluence,
|
|
145
|
+
easingLabel: () => import_canvas34.easingLabel,
|
|
146
|
+
easingToCss: () => import_canvas34.easingToCss,
|
|
147
|
+
ensureLayout: () => import_canvas31.ensureLayout,
|
|
148
|
+
estimateCanvasHeight: () => import_canvas31.estimateCanvasHeight,
|
|
149
|
+
estimateNodeSize: () => import_canvas31.estimateNodeSize,
|
|
150
|
+
evaluateAnimation: () => import_canvas34.evaluateAnimation,
|
|
151
|
+
evaluateEasing: () => import_canvas34.evaluateEasing,
|
|
152
|
+
evaluateTrack: () => import_canvas34.evaluateTrack,
|
|
153
|
+
excludePaths: () => import_canvas30.excludePaths,
|
|
154
|
+
exportCssAnimation: () => import_canvas34.exportCssAnimation,
|
|
155
|
+
findConnectorSnap: () => import_canvas28.findConnectorSnap,
|
|
156
|
+
findStrokesAtPoint: () => import_canvas35.findStrokesAtPoint,
|
|
157
|
+
fitCubicRun: () => import_canvas27.fitCubicRun,
|
|
158
|
+
fitCubics: () => import_canvas27.fitCubics,
|
|
159
|
+
fitFreehandPath: () => import_canvas27.fitFreehandPath,
|
|
160
|
+
fitPathData: () => import_canvas27.fitPathData,
|
|
161
|
+
fitViewportToNodes: () => import_canvas28.fitViewportToNodes,
|
|
162
|
+
fitViewportToRect: () => import_canvas28.fitViewportToRect,
|
|
163
|
+
flattenSvgPath: () => import_canvas29.flattenSvgPath,
|
|
164
|
+
flowSide: () => import_canvas31.flowSide,
|
|
165
|
+
formatAnimationTime: () => import_canvas34.formatAnimationTime,
|
|
166
|
+
formatOklab: () => import_canvas34.formatOklab,
|
|
167
|
+
freehandBrushstroke: () => import_canvas35.freehandBrushstroke,
|
|
168
|
+
getAbsolutePosition: () => import_canvas28.getAbsolutePosition,
|
|
169
|
+
getAnimatableProperty: () => import_canvas34.getAnimatableProperty,
|
|
170
|
+
getAnimatedProperties: () => import_canvas34.getAnimatedProperties,
|
|
171
|
+
getAnimatedValue: () => import_canvas34.getAnimatedValue,
|
|
172
|
+
getAnimationDuration: () => import_canvas34.getAnimationDuration,
|
|
173
|
+
getAnimationTrack: () => import_canvas34.getAnimationTrack,
|
|
174
|
+
getAutoLayout: () => import_canvas32.getAutoLayout,
|
|
175
|
+
getAutoLayoutGrid: () => import_canvas32.getAutoLayoutGrid,
|
|
176
|
+
getAutoLayoutInsertTarget: () => import_canvas32.getAutoLayoutInsertTarget,
|
|
177
|
+
getBindableTokenProperties: () => import_canvas33.getBindableTokenProperties,
|
|
178
|
+
getBrushedShapeSvg: () => import_canvas35.getBrushedShapeSvg,
|
|
179
|
+
getCanvasComponentDragId: () => import_canvas35.getCanvasComponentDragId,
|
|
180
|
+
getCanvasTokenProperty: () => import_canvas33.getCanvasTokenProperty,
|
|
181
|
+
getCenteredNodePosition: () => import_canvas31.getCenteredNodePosition,
|
|
182
|
+
getChildLayout: () => import_canvas32.getChildLayout,
|
|
183
|
+
getComponentSourceId: () => import_canvas35.getComponentSourceId,
|
|
184
|
+
getCssPropertyAnimations: () => import_canvas34.getCssPropertyAnimations,
|
|
185
|
+
getEffectiveTokenModes: () => import_canvas33.getEffectiveTokenModes,
|
|
186
|
+
getFlowChildren: () => import_canvas32.getFlowChildren,
|
|
187
|
+
getInstanceData: () => import_canvas35.getInstanceData,
|
|
188
|
+
getInstanceStatus: () => import_canvas35.getInstanceStatus,
|
|
189
|
+
getKeyframeTimes: () => import_canvas34.getKeyframeTimes,
|
|
190
|
+
getLayoutParent: () => import_canvas32.getLayoutParent,
|
|
191
|
+
getLayoutSizing: () => import_canvas32.getLayoutSizing,
|
|
192
|
+
getLayoutedNodes: () => import_canvas31.getLayoutedNodes,
|
|
193
|
+
getNextVariantValues: () => import_canvas35.getNextVariantValues,
|
|
194
|
+
getNodeAnimation: () => import_canvas34.getNodeAnimation,
|
|
195
|
+
getNodeOverrides: () => import_canvas35.getNodeOverrides,
|
|
196
|
+
getNodeRect: () => import_canvas28.getNodeRect,
|
|
197
|
+
getNodeShape: () => import_canvas29.getNodeShape,
|
|
198
|
+
getNodeSize: () => import_canvas28.getNodeSize,
|
|
199
|
+
getNodeTokenBindings: () => import_canvas33.getNodeTokenBindings,
|
|
200
|
+
getNodeTokenModes: () => import_canvas33.getNodeTokenModes,
|
|
201
|
+
getResizingNodeRect: () => import_canvas27.getResizingNodeRect,
|
|
202
|
+
getShapeRenderData: () => import_canvas29.getShapeRenderData,
|
|
203
|
+
getShapeSvg: () => import_canvas29.getShapeSvg,
|
|
204
|
+
getTimelineRows: () => import_canvas34.getTimelineRows,
|
|
205
|
+
getTimelineTicks: () => import_canvas34.getTimelineTicks,
|
|
206
|
+
getTokenPropertyScope: () => import_canvas33.getTokenPropertyScope,
|
|
207
|
+
getTokensForProperty: () => import_canvas33.getTokensForProperty,
|
|
208
|
+
gradientToSvgDef: () => import_canvas35.gradientToSvgDef,
|
|
209
|
+
handlePoint: () => import_canvas28.handlePoint,
|
|
210
|
+
hasVisibleStroke: () => import_canvas30.hasVisibleStroke,
|
|
211
|
+
inferResizeHandle: () => import_canvas27.inferResizeHandle,
|
|
212
|
+
inspectCanvasInstance: () => import_canvas35.inspectCanvasInstance,
|
|
213
|
+
inspectNodeTokens: () => import_canvas33.inspectNodeTokens,
|
|
214
|
+
interpolateAnimationValue: () => import_canvas34.interpolateAnimationValue,
|
|
215
|
+
intersectPaths: () => import_canvas30.intersectPaths,
|
|
216
|
+
intersectPolygons: () => import_canvas29.intersectPolygons,
|
|
217
|
+
invertNodeUpdates: () => import_canvas28.invertNodeUpdates,
|
|
218
|
+
isAnimationEasing: () => import_canvas34.isAnimationEasing,
|
|
219
|
+
isAnimationKeyframe: () => import_canvas34.isAnimationKeyframe,
|
|
220
|
+
isAutoLayoutFrame: () => import_canvas32.isAutoLayoutFrame,
|
|
221
|
+
isBrushedShape: () => import_canvas35.isBrushedShape,
|
|
222
|
+
isCanvasComponent: () => import_canvas35.isCanvasComponent,
|
|
223
|
+
isCanvasComponentSet: () => import_canvas35.isCanvasComponentSet,
|
|
224
|
+
isCanvasGradient: () => import_canvas35.isCanvasGradient,
|
|
225
|
+
isCanvasInstance: () => import_canvas35.isCanvasInstance,
|
|
226
|
+
isCssExportExact: () => import_canvas34.isCssExportExact,
|
|
227
|
+
isEventFromTextInput: () => import_canvas31.isEventFromTextInput,
|
|
228
|
+
isKeyframeSelected: () => import_canvas34.isKeyframeSelected,
|
|
229
|
+
isLocked: () => import_canvas28.isLocked,
|
|
230
|
+
isMeasureModifierHeld: () => import_canvas27.isMeasureModifierHeld,
|
|
231
|
+
isNodeAnimated: () => import_canvas34.isNodeAnimated,
|
|
232
|
+
isShapeDescription: () => import_canvas29.isShapeDescription,
|
|
233
|
+
isShapeNode: () => import_canvas29.isShapeNode,
|
|
234
|
+
isStraightCubic: () => import_canvas27.isStraightCubic,
|
|
235
|
+
isValidCanvasNode: () => import_canvas31.isValidCanvasNode,
|
|
236
|
+
isValidUrl: () => import_canvas31.isValidUrl,
|
|
237
|
+
layoutAll: () => import_canvas32.layoutAll,
|
|
238
|
+
layoutBounds: () => import_canvas31.layoutBounds,
|
|
239
|
+
layoutFrame: () => import_canvas32.layoutFrame,
|
|
240
|
+
layoutUp: () => import_canvas32.layoutUp,
|
|
241
|
+
layoutUpMany: () => import_canvas32.layoutUpMany,
|
|
242
|
+
linearPositionTrajectory: () => import_canvas31.linearPositionTrajectory,
|
|
243
|
+
linearTrajectory: () => import_canvas31.linearTrajectory,
|
|
244
|
+
listCanvasBrushes: () => import_canvas35.listCanvasBrushes,
|
|
245
|
+
listCanvasComponents: () => import_canvas35.listCanvasComponents,
|
|
246
|
+
loadCanvasBrushstrokeRenderer: () => import_canvas35.loadCanvasBrushstrokeRenderer,
|
|
247
|
+
lockNodes: () => import_canvas28.lockNodes,
|
|
248
|
+
makeSizingCoherent: () => import_canvas32.makeSizingCoherent,
|
|
249
|
+
matchArrangeShortcut: () => import_canvas28.matchArrangeShortcut,
|
|
250
|
+
matchSize: () => import_canvas28.matchSize,
|
|
251
|
+
measureBetween: () => import_canvas27.measureBetween,
|
|
252
|
+
measureLabel: () => import_canvas27.measureLabel,
|
|
253
|
+
measureSelection: () => import_canvas27.measureSelection,
|
|
254
|
+
measureToLine: () => import_canvas27.measureToLine,
|
|
255
|
+
mergeNodeUpdates: () => import_canvas32.mergeNodeUpdates,
|
|
255
256
|
mermaidNodeStyle: () => mermaidNodeStyle,
|
|
256
|
-
mixColorsOklab: () =>
|
|
257
|
-
moveKeyframes: () =>
|
|
258
|
-
moveLayoutChild: () =>
|
|
259
|
-
multiPolygonArea: () =>
|
|
260
|
-
multiPolygonBounds: () =>
|
|
261
|
-
nearestHandlePositions: () =>
|
|
262
|
-
normalizeBezierPath: () =>
|
|
263
|
-
normalizeKeyframes: () =>
|
|
264
|
-
offsetPath: () =>
|
|
265
|
-
offsetShapeNodes: () =>
|
|
266
|
-
oklabToRgb: () =>
|
|
267
|
-
oppositePosition: () =>
|
|
268
|
-
outlineShapeNodeStrokes: () =>
|
|
269
|
-
outlineStroke: () =>
|
|
270
|
-
overlaps: () =>
|
|
271
|
-
parseCanvasClipboardData: () =>
|
|
272
|
-
parseCanvasScenes: () =>
|
|
273
|
-
parseCssEasing: () =>
|
|
274
|
-
parseCssGradient: () =>
|
|
275
|
-
parseKeyframeClipboard: () =>
|
|
276
|
-
parseOklab: () =>
|
|
277
|
-
parseSvgPath: () =>
|
|
278
|
-
pasteKeyframes: () =>
|
|
279
|
-
pathBoolean: () =>
|
|
280
|
-
pathDataToPolyline: () =>
|
|
281
|
-
placeBeside: () =>
|
|
282
|
-
playWebAnimations: () =>
|
|
283
|
-
pointInBezierPath: () =>
|
|
284
|
-
pointInMultiPolygon: () =>
|
|
285
|
-
pointInRings: () =>
|
|
286
|
-
pointerPenSample: () =>
|
|
287
|
-
polygonArea: () =>
|
|
288
|
-
polygonBoolean: () =>
|
|
289
|
-
polygonToSvgPath: () =>
|
|
290
|
-
positionToSide: () =>
|
|
291
|
-
profileAlongPolyline: () =>
|
|
292
|
-
pruneCanvasTokenModes: () =>
|
|
293
|
-
pushCanvasInstanceOverrides: () =>
|
|
294
|
-
readAnimatableValue: () =>
|
|
295
|
-
readNodeStyleProperty: () =>
|
|
296
|
-
readStyleSize: () =>
|
|
297
|
-
realClock: () =>
|
|
298
|
-
recordAnimationChanges: () =>
|
|
299
|
-
relayoutUpdates: () =>
|
|
300
|
-
remapPastedNodes: () =>
|
|
301
|
-
removeCanvasVariant: () =>
|
|
302
|
-
removeTrack: () =>
|
|
303
|
-
renameCanvasVariantProperty: () =>
|
|
304
|
-
renameCanvasVariantValue: () =>
|
|
305
|
-
renderCanvasBrushSwatch: () =>
|
|
306
|
-
renderShapeBrushstroke: () =>
|
|
307
|
-
reorderNodes: () =>
|
|
308
|
-
repositionNodesTo: () =>
|
|
309
|
-
resetCanvasInstanceOverrides: () =>
|
|
310
|
-
resizeHandleAxes: () =>
|
|
311
|
-
resolveCanvasGradient: () =>
|
|
312
|
-
resolveCanvasTokens: () =>
|
|
313
|
-
resolveEasing: () =>
|
|
314
|
-
resolvePadding: () =>
|
|
315
|
-
restoreCanvasMainComponent: () =>
|
|
316
|
-
revertShapeCombination: () =>
|
|
317
|
-
rgbToOklab: () =>
|
|
318
|
-
ringSignedArea: () =>
|
|
319
|
-
runMultiNodeTransition: () =>
|
|
320
|
-
sampleAnimationFrames: () =>
|
|
321
|
-
scaleKeyframes: () =>
|
|
322
|
-
serializeCanvasNodes: () =>
|
|
323
|
-
setCanvasComponentProperty: () =>
|
|
324
|
-
setCanvasInstanceProperties: () =>
|
|
325
|
-
setCanvasTokenMode: () =>
|
|
326
|
-
setCanvasVariantProperties: () =>
|
|
327
|
-
setKeyframe: () =>
|
|
328
|
-
setKeyframeEasing: () =>
|
|
329
|
-
setMotionPath: () =>
|
|
330
|
-
setTrackEnabled: () =>
|
|
331
|
-
shapeNodeToBezierPath: () =>
|
|
332
|
-
shapeNodeToPolygon: () =>
|
|
333
|
-
shapeToBezierPath: () =>
|
|
334
|
-
shapeToPolygon: () =>
|
|
335
|
-
sideToPosition: () =>
|
|
336
|
-
simplifyRing: () =>
|
|
337
|
-
snapKeyframeDelta: () =>
|
|
338
|
-
snapNodeDrag: () =>
|
|
339
|
-
snapNodeResize: () =>
|
|
340
|
-
snapResize: () =>
|
|
341
|
-
snapTimeToFrame: () =>
|
|
342
|
-
snapToGrid: () =>
|
|
343
|
-
springAt: () =>
|
|
344
|
-
streamlinePoints: () =>
|
|
345
|
-
strokeOutlineRings: () =>
|
|
346
|
-
strokePointsToPathData: () =>
|
|
347
|
-
strokeToShapeNode: () =>
|
|
348
|
-
subtractPaths: () =>
|
|
349
|
-
subtractPolygons: () =>
|
|
350
|
-
swapCanvasInstance: () =>
|
|
351
|
-
syncAllCanvasInstances: () =>
|
|
352
|
-
syncCanvasComponents: () =>
|
|
353
|
-
syncCanvasInstance: () =>
|
|
354
|
-
timeToX: () =>
|
|
355
|
-
toBezierPath: () =>
|
|
356
|
-
toWebAnimations: () =>
|
|
357
|
-
toggleLockNodes: () =>
|
|
358
|
-
transformBezierPath: () =>
|
|
359
|
-
unionPolygons: () =>
|
|
360
|
-
unitePaths: () =>
|
|
361
|
-
unlockNodes: () =>
|
|
362
|
-
updateKeyframe: () =>
|
|
257
|
+
mixColorsOklab: () => import_canvas34.mixColorsOklab,
|
|
258
|
+
moveKeyframes: () => import_canvas34.moveKeyframes,
|
|
259
|
+
moveLayoutChild: () => import_canvas32.moveLayoutChild,
|
|
260
|
+
multiPolygonArea: () => import_canvas29.multiPolygonArea,
|
|
261
|
+
multiPolygonBounds: () => import_canvas29.multiPolygonBounds,
|
|
262
|
+
nearestHandlePositions: () => import_canvas28.nearestHandlePositions,
|
|
263
|
+
normalizeBezierPath: () => import_canvas30.normalizeBezierPath,
|
|
264
|
+
normalizeKeyframes: () => import_canvas34.normalizeKeyframes,
|
|
265
|
+
offsetPath: () => import_canvas30.offsetPath,
|
|
266
|
+
offsetShapeNodes: () => import_canvas30.offsetShapeNodes,
|
|
267
|
+
oklabToRgb: () => import_canvas34.oklabToRgb,
|
|
268
|
+
oppositePosition: () => import_canvas28.oppositePosition,
|
|
269
|
+
outlineShapeNodeStrokes: () => import_canvas30.outlineShapeNodeStrokes,
|
|
270
|
+
outlineStroke: () => import_canvas30.outlineStroke,
|
|
271
|
+
overlaps: () => import_canvas31.overlaps,
|
|
272
|
+
parseCanvasClipboardData: () => import_canvas31.parseCanvasClipboardData,
|
|
273
|
+
parseCanvasScenes: () => import_canvas28.parseCanvasScenes,
|
|
274
|
+
parseCssEasing: () => import_canvas34.parseCssEasing,
|
|
275
|
+
parseCssGradient: () => import_canvas35.parseCssGradient,
|
|
276
|
+
parseKeyframeClipboard: () => import_canvas34.parseKeyframeClipboard,
|
|
277
|
+
parseOklab: () => import_canvas34.parseOklab,
|
|
278
|
+
parseSvgPath: () => import_canvas29.parseSvgPath,
|
|
279
|
+
pasteKeyframes: () => import_canvas34.pasteKeyframes,
|
|
280
|
+
pathBoolean: () => import_canvas30.pathBoolean,
|
|
281
|
+
pathDataToPolyline: () => import_canvas35.pathDataToPolyline,
|
|
282
|
+
placeBeside: () => import_canvas31.placeBeside,
|
|
283
|
+
playWebAnimations: () => import_canvas34.playWebAnimations,
|
|
284
|
+
pointInBezierPath: () => import_canvas30.pointInBezierPath,
|
|
285
|
+
pointInMultiPolygon: () => import_canvas29.pointInMultiPolygon,
|
|
286
|
+
pointInRings: () => import_canvas29.pointInRings,
|
|
287
|
+
pointerPenSample: () => import_canvas35.pointerPenSample,
|
|
288
|
+
polygonArea: () => import_canvas29.polygonArea,
|
|
289
|
+
polygonBoolean: () => import_canvas29.polygonBoolean,
|
|
290
|
+
polygonToSvgPath: () => import_canvas29.polygonToSvgPath,
|
|
291
|
+
positionToSide: () => import_canvas28.positionToSide,
|
|
292
|
+
profileAlongPolyline: () => import_canvas35.profileAlongPolyline,
|
|
293
|
+
pruneCanvasTokenModes: () => import_canvas33.pruneCanvasTokenModes,
|
|
294
|
+
pushCanvasInstanceOverrides: () => import_canvas35.pushCanvasInstanceOverrides,
|
|
295
|
+
readAnimatableValue: () => import_canvas34.readAnimatableValue,
|
|
296
|
+
readNodeStyleProperty: () => import_canvas33.readNodeStyleProperty,
|
|
297
|
+
readStyleSize: () => import_canvas28.readStyleSize,
|
|
298
|
+
realClock: () => import_canvas31.realClock,
|
|
299
|
+
recordAnimationChanges: () => import_canvas34.recordAnimationChanges,
|
|
300
|
+
relayoutUpdates: () => import_canvas32.relayoutUpdates,
|
|
301
|
+
remapPastedNodes: () => import_canvas31.remapPastedNodes,
|
|
302
|
+
removeCanvasVariant: () => import_canvas35.removeCanvasVariant,
|
|
303
|
+
removeTrack: () => import_canvas34.removeTrack,
|
|
304
|
+
renameCanvasVariantProperty: () => import_canvas35.renameCanvasVariantProperty,
|
|
305
|
+
renameCanvasVariantValue: () => import_canvas35.renameCanvasVariantValue,
|
|
306
|
+
renderCanvasBrushSwatch: () => import_canvas35.renderCanvasBrushSwatch,
|
|
307
|
+
renderShapeBrushstroke: () => import_canvas35.renderShapeBrushstroke,
|
|
308
|
+
reorderNodes: () => import_canvas28.reorderNodes,
|
|
309
|
+
repositionNodesTo: () => import_canvas31.repositionNodesTo,
|
|
310
|
+
resetCanvasInstanceOverrides: () => import_canvas35.resetCanvasInstanceOverrides,
|
|
311
|
+
resizeHandleAxes: () => import_canvas27.resizeHandleAxes,
|
|
312
|
+
resolveCanvasGradient: () => import_canvas35.resolveCanvasGradient,
|
|
313
|
+
resolveCanvasTokens: () => import_canvas33.resolveCanvasTokens,
|
|
314
|
+
resolveEasing: () => import_canvas34.resolveEasing,
|
|
315
|
+
resolvePadding: () => import_canvas32.resolvePadding,
|
|
316
|
+
restoreCanvasMainComponent: () => import_canvas35.restoreCanvasMainComponent,
|
|
317
|
+
revertShapeCombination: () => import_canvas29.revertShapeCombination,
|
|
318
|
+
rgbToOklab: () => import_canvas34.rgbToOklab,
|
|
319
|
+
ringSignedArea: () => import_canvas29.ringSignedArea,
|
|
320
|
+
runMultiNodeTransition: () => import_canvas31.runMultiNodeTransition,
|
|
321
|
+
sampleAnimationFrames: () => import_canvas34.sampleAnimationFrames,
|
|
322
|
+
scaleKeyframes: () => import_canvas34.scaleKeyframes,
|
|
323
|
+
serializeCanvasNodes: () => import_canvas31.serializeCanvasNodes,
|
|
324
|
+
setCanvasComponentProperty: () => import_canvas35.setCanvasComponentProperty,
|
|
325
|
+
setCanvasInstanceProperties: () => import_canvas35.setCanvasInstanceProperties,
|
|
326
|
+
setCanvasTokenMode: () => import_canvas33.setCanvasTokenMode,
|
|
327
|
+
setCanvasVariantProperties: () => import_canvas35.setCanvasVariantProperties,
|
|
328
|
+
setKeyframe: () => import_canvas34.setKeyframe,
|
|
329
|
+
setKeyframeEasing: () => import_canvas34.setKeyframeEasing,
|
|
330
|
+
setMotionPath: () => import_canvas34.setMotionPath,
|
|
331
|
+
setTrackEnabled: () => import_canvas34.setTrackEnabled,
|
|
332
|
+
shapeNodeToBezierPath: () => import_canvas30.shapeNodeToBezierPath,
|
|
333
|
+
shapeNodeToPolygon: () => import_canvas29.shapeNodeToPolygon,
|
|
334
|
+
shapeToBezierPath: () => import_canvas30.shapeToBezierPath,
|
|
335
|
+
shapeToPolygon: () => import_canvas29.shapeToPolygon,
|
|
336
|
+
sideToPosition: () => import_canvas28.sideToPosition,
|
|
337
|
+
simplifyRing: () => import_canvas29.simplifyRing,
|
|
338
|
+
snapKeyframeDelta: () => import_canvas34.snapKeyframeDelta,
|
|
339
|
+
snapNodeDrag: () => import_canvas28.snapNodeDrag,
|
|
340
|
+
snapNodeResize: () => import_canvas27.snapNodeResize,
|
|
341
|
+
snapResize: () => import_canvas27.snapResize,
|
|
342
|
+
snapTimeToFrame: () => import_canvas34.snapTimeToFrame,
|
|
343
|
+
snapToGrid: () => import_canvas27.snapToGrid,
|
|
344
|
+
springAt: () => import_canvas34.springAt,
|
|
345
|
+
streamlinePoints: () => import_canvas35.streamlinePoints,
|
|
346
|
+
strokeOutlineRings: () => import_canvas30.strokeOutlineRings,
|
|
347
|
+
strokePointsToPathData: () => import_canvas35.strokePointsToPathData,
|
|
348
|
+
strokeToShapeNode: () => import_canvas35.strokeToShapeNode,
|
|
349
|
+
subtractPaths: () => import_canvas30.subtractPaths,
|
|
350
|
+
subtractPolygons: () => import_canvas29.subtractPolygons,
|
|
351
|
+
swapCanvasInstance: () => import_canvas35.swapCanvasInstance,
|
|
352
|
+
syncAllCanvasInstances: () => import_canvas35.syncAllCanvasInstances,
|
|
353
|
+
syncCanvasComponents: () => import_canvas35.syncCanvasComponents,
|
|
354
|
+
syncCanvasInstance: () => import_canvas35.syncCanvasInstance,
|
|
355
|
+
timeToX: () => import_canvas34.timeToX,
|
|
356
|
+
toBezierPath: () => import_canvas30.toBezierPath,
|
|
357
|
+
toWebAnimations: () => import_canvas34.toWebAnimations,
|
|
358
|
+
toggleLockNodes: () => import_canvas28.toggleLockNodes,
|
|
359
|
+
transformBezierPath: () => import_canvas30.transformBezierPath,
|
|
360
|
+
unionPolygons: () => import_canvas29.unionPolygons,
|
|
361
|
+
unitePaths: () => import_canvas30.unitePaths,
|
|
362
|
+
unlockNodes: () => import_canvas28.unlockNodes,
|
|
363
|
+
updateKeyframe: () => import_canvas34.updateKeyframe,
|
|
363
364
|
useCanvasAnimation: () => useCanvasAnimation,
|
|
364
365
|
useCanvasArrange: () => useCanvasArrange,
|
|
365
366
|
useCanvasArrangeShortcuts: () => useCanvasArrangeShortcuts,
|
|
@@ -377,6 +378,7 @@ __export(canvas_exports, {
|
|
|
377
378
|
useCanvasGraph: () => useCanvasGraph,
|
|
378
379
|
useCanvasLayout: () => useCanvasLayout,
|
|
379
380
|
useCanvasMeasure: () => useCanvasMeasure,
|
|
381
|
+
useCanvasPlaybackSurface: () => useCanvasPlaybackSurface,
|
|
380
382
|
useCanvasScenes: () => useCanvasScenes,
|
|
381
383
|
useCanvasShortcuts: () => useCanvasShortcuts,
|
|
382
384
|
useCanvasTokens: () => useCanvasTokens,
|
|
@@ -387,15 +389,15 @@ __export(canvas_exports, {
|
|
|
387
389
|
usePresenceState: () => usePresenceState,
|
|
388
390
|
useShapeBrushstroke: () => useShapeBrushstroke,
|
|
389
391
|
useStreamingCanvas: () => useStreamingCanvas,
|
|
390
|
-
validateCanvasBrush: () =>
|
|
391
|
-
validateCanvasBrushPaint: () =>
|
|
392
|
-
withNodeAnimation: () =>
|
|
393
|
-
withStyleSize: () =>
|
|
394
|
-
wouldCreateComponentCycle: () =>
|
|
395
|
-
wrapAnimationTime: () =>
|
|
396
|
-
writeNodeStyleProperty: () =>
|
|
397
|
-
xToTime: () =>
|
|
398
|
-
xorPolygons: () =>
|
|
392
|
+
validateCanvasBrush: () => import_canvas35.validateCanvasBrush,
|
|
393
|
+
validateCanvasBrushPaint: () => import_canvas35.validateCanvasBrushPaint,
|
|
394
|
+
withNodeAnimation: () => import_canvas34.withNodeAnimation,
|
|
395
|
+
withStyleSize: () => import_canvas28.withStyleSize,
|
|
396
|
+
wouldCreateComponentCycle: () => import_canvas35.wouldCreateComponentCycle,
|
|
397
|
+
wrapAnimationTime: () => import_canvas34.wrapAnimationTime,
|
|
398
|
+
writeNodeStyleProperty: () => import_canvas33.writeNodeStyleProperty,
|
|
399
|
+
xToTime: () => import_canvas34.xToTime,
|
|
400
|
+
xorPolygons: () => import_canvas29.xorPolygons
|
|
399
401
|
});
|
|
400
402
|
module.exports = __toCommonJS(canvas_exports);
|
|
401
403
|
|
|
@@ -463,13 +465,149 @@ function AgentPresenceLayer({ presences, className = "" }) {
|
|
|
463
465
|
);
|
|
464
466
|
}
|
|
465
467
|
|
|
466
|
-
// src/
|
|
467
|
-
var import_react = require("react");
|
|
468
|
+
// src/playback/PresenceLayer.tsx
|
|
469
|
+
var import_react = __toESM(require("react"), 1);
|
|
470
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
471
|
+
function PresenceLayer({ presence, viewport, className = "" }) {
|
|
472
|
+
const { actors } = (0, import_react.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
473
|
+
if (!actors.length) return null;
|
|
474
|
+
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
476
|
+
"div",
|
|
477
|
+
{
|
|
478
|
+
className: `pixerate-presence ${className}`.trim(),
|
|
479
|
+
"aria-hidden": "true",
|
|
480
|
+
"data-testid": "presence-layer",
|
|
481
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
|
|
482
|
+
children: actors.map((a) => {
|
|
483
|
+
const at = map(a);
|
|
484
|
+
const ring = a.focus && (() => {
|
|
485
|
+
const tl = map(a.focus);
|
|
486
|
+
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
487
|
+
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
488
|
+
})();
|
|
489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.default.Fragment, { children: [
|
|
490
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
491
|
+
"div",
|
|
492
|
+
{
|
|
493
|
+
"data-actor-focus": a.id,
|
|
494
|
+
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
|
|
498
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
500
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
501
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
|
|
502
|
+
] })
|
|
503
|
+
] })
|
|
504
|
+
] }, a.id);
|
|
505
|
+
})
|
|
506
|
+
}
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// src/canvas/useCanvasPlaybackSurface.ts
|
|
511
|
+
var import_react4 = require("react");
|
|
468
512
|
var import_canvas = require("@pixerate/editor/canvas");
|
|
513
|
+
|
|
514
|
+
// src/playback/usePlaybackSurface.ts
|
|
515
|
+
var import_react3 = require("react");
|
|
516
|
+
var import_tools = require("@pixerate/editor/tools");
|
|
517
|
+
|
|
518
|
+
// src/playback/AgentPlaybackContext.tsx
|
|
519
|
+
var import_react2 = require("react");
|
|
520
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
521
|
+
var AgentPlaybackContext = (0, import_react2.createContext)(null);
|
|
522
|
+
function useAgentPlayback() {
|
|
523
|
+
return (0, import_react2.useContext)(AgentPlaybackContext);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// src/playback/usePlaybackSurface.ts
|
|
527
|
+
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
528
|
+
const ambient = useAgentPlayback();
|
|
529
|
+
const target = playback === void 0 ? ambient : playback;
|
|
530
|
+
const [ownPresence] = (0, import_react3.useState)(() => new import_tools.PresenceStore());
|
|
531
|
+
const presence = sharedPresence ?? ownPresence;
|
|
532
|
+
const latest = (0, import_react3.useRef)(options);
|
|
533
|
+
latest.current = options;
|
|
534
|
+
(0, import_react3.useEffect)(() => {
|
|
535
|
+
if (!target || !id) return;
|
|
536
|
+
const o = () => latest.current;
|
|
537
|
+
const surface = {
|
|
538
|
+
presence,
|
|
539
|
+
locate: (ref) => o().locate?.(ref) ?? null,
|
|
540
|
+
bounds: () => o().bounds?.() ?? null,
|
|
541
|
+
visible: () => o().visible?.() ?? true,
|
|
542
|
+
toViewport: (p) => o().toViewport?.(p) ?? p,
|
|
543
|
+
fromViewport: (p) => o().fromViewport?.(p) ?? p,
|
|
544
|
+
beginGesture: (key) => o().beginGesture?.(key),
|
|
545
|
+
endGesture: () => o().endGesture?.(),
|
|
546
|
+
reveal: () => o().reveal?.(),
|
|
547
|
+
open: (ref) => o().open?.(ref),
|
|
548
|
+
get defaultKind() {
|
|
549
|
+
return o().defaultKind;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
const detach = target.attach(id, surface);
|
|
553
|
+
return () => {
|
|
554
|
+
detach();
|
|
555
|
+
for (const a of presence.getState().actors) presence.remove(a.id);
|
|
556
|
+
};
|
|
557
|
+
}, [target, id, presence]);
|
|
558
|
+
return presence;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/canvas/useCanvasPlaybackSurface.ts
|
|
562
|
+
function useCanvasPlaybackSurface(playback, id, options) {
|
|
563
|
+
const latest = (0, import_react4.useRef)(options);
|
|
564
|
+
latest.current = options;
|
|
565
|
+
const locate = (0, import_react4.useMemo)(
|
|
566
|
+
() => (0, import_canvas.createCanvasPlaybackLocator)({
|
|
567
|
+
getNodes: () => latest.current.getNodes(),
|
|
568
|
+
getEdges: () => latest.current.getEdges?.() ?? [],
|
|
569
|
+
get rectOptions() {
|
|
570
|
+
return latest.current.rectOptions;
|
|
571
|
+
}
|
|
572
|
+
}),
|
|
573
|
+
[]
|
|
574
|
+
);
|
|
575
|
+
const box = () => latest.current.container.current?.getBoundingClientRect() ?? null;
|
|
576
|
+
return usePlaybackSurface(playback, id, {
|
|
577
|
+
defaultKind: "node",
|
|
578
|
+
locate,
|
|
579
|
+
bounds: () => {
|
|
580
|
+
const r = box();
|
|
581
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
582
|
+
return r && r.width > 0 ? { x: -x / zoom, y: -y / zoom, width: r.width / zoom, height: r.height / zoom } : null;
|
|
583
|
+
},
|
|
584
|
+
visible: () => {
|
|
585
|
+
if (latest.current.visible) return latest.current.visible();
|
|
586
|
+
const r = box();
|
|
587
|
+
const hidden = typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
588
|
+
return !!r && r.width > 0 && r.height > 0 && !hidden;
|
|
589
|
+
},
|
|
590
|
+
toViewport: (p) => {
|
|
591
|
+
const r = box();
|
|
592
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
593
|
+
return { x: (r?.left ?? 0) + p.x * zoom + x, y: (r?.top ?? 0) + p.y * zoom + y };
|
|
594
|
+
},
|
|
595
|
+
fromViewport: (p) => {
|
|
596
|
+
const r = box();
|
|
597
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
598
|
+
return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
|
|
599
|
+
},
|
|
600
|
+
reveal: () => latest.current.reveal?.()
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// src/canvas/useStreamingCanvas.ts
|
|
605
|
+
var import_react5 = require("react");
|
|
606
|
+
var import_canvas2 = require("@pixerate/editor/canvas");
|
|
469
607
|
function useStreamingCanvas(options) {
|
|
470
|
-
const managerRef = (0,
|
|
471
|
-
(0,
|
|
472
|
-
const manager = new
|
|
608
|
+
const managerRef = (0, import_react5.useRef)(null);
|
|
609
|
+
(0, import_react5.useEffect)(() => {
|
|
610
|
+
const manager = new import_canvas2.StreamingLayoutManager({
|
|
473
611
|
throttleMs: options.throttleMs,
|
|
474
612
|
glideDurationMs: options.glideDurationMs,
|
|
475
613
|
connectedOnly: options.connectedOnly,
|
|
@@ -489,13 +627,13 @@ function useStreamingCanvas(options) {
|
|
|
489
627
|
options.clock,
|
|
490
628
|
options.onPositionsChange
|
|
491
629
|
]);
|
|
492
|
-
const pushStreamUpdate = (0,
|
|
630
|
+
const pushStreamUpdate = (0, import_react5.useCallback)(
|
|
493
631
|
(nodes, edges, currentPositions) => {
|
|
494
632
|
managerRef.current?.pushStreamUpdate(nodes, edges, currentPositions);
|
|
495
633
|
},
|
|
496
634
|
[]
|
|
497
635
|
);
|
|
498
|
-
const flush = (0,
|
|
636
|
+
const flush = (0, import_react5.useCallback)(
|
|
499
637
|
(nodes, edges, currentPositions) => {
|
|
500
638
|
managerRef.current?.flush(nodes, edges, currentPositions);
|
|
501
639
|
},
|
|
@@ -508,13 +646,13 @@ function useStreamingCanvas(options) {
|
|
|
508
646
|
}
|
|
509
647
|
|
|
510
648
|
// src/canvas/useCanvasGraph.ts
|
|
511
|
-
var
|
|
649
|
+
var import_react6 = require("react");
|
|
512
650
|
function useCanvasGraph(options = {}) {
|
|
513
|
-
const [nodes, setNodesState] = (0,
|
|
514
|
-
const [edges, setEdgesState] = (0,
|
|
515
|
-
const baselineNodesRef = (0,
|
|
516
|
-
const baselineEdgesRef = (0,
|
|
517
|
-
const setNodes = (0,
|
|
651
|
+
const [nodes, setNodesState] = (0, import_react6.useState)(options.initialNodes ?? []);
|
|
652
|
+
const [edges, setEdgesState] = (0, import_react6.useState)(options.initialEdges ?? []);
|
|
653
|
+
const baselineNodesRef = (0, import_react6.useRef)(options.initialNodes ?? []);
|
|
654
|
+
const baselineEdgesRef = (0, import_react6.useRef)(options.initialEdges ?? []);
|
|
655
|
+
const setNodes = (0, import_react6.useCallback)(
|
|
518
656
|
(updater) => {
|
|
519
657
|
setNodesState((prev) => {
|
|
520
658
|
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
@@ -524,7 +662,7 @@ function useCanvasGraph(options = {}) {
|
|
|
524
662
|
},
|
|
525
663
|
[options.onNodesChange]
|
|
526
664
|
);
|
|
527
|
-
const setEdges = (0,
|
|
665
|
+
const setEdges = (0, import_react6.useCallback)(
|
|
528
666
|
(updater) => {
|
|
529
667
|
setEdgesState((prev) => {
|
|
530
668
|
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
@@ -534,13 +672,13 @@ function useCanvasGraph(options = {}) {
|
|
|
534
672
|
},
|
|
535
673
|
[options.onEdgesChange]
|
|
536
674
|
);
|
|
537
|
-
const addNode = (0,
|
|
675
|
+
const addNode = (0, import_react6.useCallback)(
|
|
538
676
|
(node) => {
|
|
539
677
|
setNodes((prev) => [...prev, node]);
|
|
540
678
|
},
|
|
541
679
|
[setNodes]
|
|
542
680
|
);
|
|
543
|
-
const removeNodes = (0,
|
|
681
|
+
const removeNodes = (0, import_react6.useCallback)(
|
|
544
682
|
(ids) => {
|
|
545
683
|
const idSet = new Set(ids);
|
|
546
684
|
setNodes((prev) => prev.filter((n) => !idSet.has(n.id)));
|
|
@@ -548,7 +686,7 @@ function useCanvasGraph(options = {}) {
|
|
|
548
686
|
},
|
|
549
687
|
[setNodes, setEdges]
|
|
550
688
|
);
|
|
551
|
-
const updateNodeData = (0,
|
|
689
|
+
const updateNodeData = (0, import_react6.useCallback)(
|
|
552
690
|
(id, patch) => {
|
|
553
691
|
setNodes(
|
|
554
692
|
(prev) => prev.map((node) => {
|
|
@@ -562,7 +700,7 @@ function useCanvasGraph(options = {}) {
|
|
|
562
700
|
},
|
|
563
701
|
[setNodes]
|
|
564
702
|
);
|
|
565
|
-
const updateNodePosition = (0,
|
|
703
|
+
const updateNodePosition = (0, import_react6.useCallback)(
|
|
566
704
|
(id, position) => {
|
|
567
705
|
setNodes(
|
|
568
706
|
(prev) => prev.map((node) => {
|
|
@@ -576,24 +714,24 @@ function useCanvasGraph(options = {}) {
|
|
|
576
714
|
},
|
|
577
715
|
[setNodes]
|
|
578
716
|
);
|
|
579
|
-
const addEdge = (0,
|
|
717
|
+
const addEdge = (0, import_react6.useCallback)(
|
|
580
718
|
(edge) => {
|
|
581
719
|
setEdges((prev) => [...prev, edge]);
|
|
582
720
|
},
|
|
583
721
|
[setEdges]
|
|
584
722
|
);
|
|
585
|
-
const removeEdges = (0,
|
|
723
|
+
const removeEdges = (0, import_react6.useCallback)(
|
|
586
724
|
(ids) => {
|
|
587
725
|
const idSet = new Set(ids);
|
|
588
726
|
setEdges((prev) => prev.filter((e) => !idSet.has(e.id)));
|
|
589
727
|
},
|
|
590
728
|
[setEdges]
|
|
591
729
|
);
|
|
592
|
-
const resetBaseline = (0,
|
|
730
|
+
const resetBaseline = (0, import_react6.useCallback)(() => {
|
|
593
731
|
baselineNodesRef.current = nodes;
|
|
594
732
|
baselineEdgesRef.current = edges;
|
|
595
733
|
}, [nodes, edges]);
|
|
596
|
-
const getDifferences = (0,
|
|
734
|
+
const getDifferences = (0, import_react6.useCallback)(() => {
|
|
597
735
|
const currentNodesMap = new Map(nodes.map((n) => [n.id, n]));
|
|
598
736
|
const currentEdgesMap = new Map(edges.map((e) => [e.id, e]));
|
|
599
737
|
const baselineNodesMap = new Map(baselineNodesRef.current.map((n) => [n.id, n]));
|
|
@@ -643,22 +781,22 @@ function useCanvasGraph(options = {}) {
|
|
|
643
781
|
}
|
|
644
782
|
|
|
645
783
|
// src/canvas/useCanvasLayout.ts
|
|
646
|
-
var
|
|
647
|
-
var
|
|
784
|
+
var import_react7 = require("react");
|
|
785
|
+
var import_canvas3 = require("@pixerate/editor/canvas");
|
|
648
786
|
function useCanvasLayout(options) {
|
|
649
787
|
const { nodes, edges, setNodes, getNodesBounds, screenToFlowPosition } = options;
|
|
650
|
-
const applyLayout = (0,
|
|
788
|
+
const applyLayout = (0, import_react7.useCallback)(
|
|
651
789
|
(layoutOptions = {}) => {
|
|
652
|
-
const layouted = (0,
|
|
790
|
+
const layouted = (0, import_canvas3.getLayoutedNodes)(nodes, edges, getNodesBounds, layoutOptions);
|
|
653
791
|
setNodes(layouted);
|
|
654
792
|
return layouted;
|
|
655
793
|
},
|
|
656
794
|
[nodes, edges, getNodesBounds, setNodes]
|
|
657
795
|
);
|
|
658
|
-
const applyIncrementalLayout = (0,
|
|
796
|
+
const applyIncrementalLayout = (0, import_react7.useCallback)(
|
|
659
797
|
(incrementalOptions = {}) => {
|
|
660
798
|
const storedPositions = incrementalOptions.storedPositions ?? Object.fromEntries(nodes.map((n) => [n.id, n.position]));
|
|
661
|
-
const blended = (0,
|
|
799
|
+
const blended = (0, import_canvas3.ensureLayout)(nodes, edges, {
|
|
662
800
|
...incrementalOptions,
|
|
663
801
|
storedPositions
|
|
664
802
|
});
|
|
@@ -667,7 +805,7 @@ function useCanvasLayout(options) {
|
|
|
667
805
|
},
|
|
668
806
|
[nodes, edges, setNodes]
|
|
669
807
|
);
|
|
670
|
-
const center = (0,
|
|
808
|
+
const center = (0, import_react7.useCallback)(
|
|
671
809
|
(screenDimensions) => {
|
|
672
810
|
if (!screenToFlowPosition || !getNodesBounds) {
|
|
673
811
|
console.warn(
|
|
@@ -675,12 +813,12 @@ function useCanvasLayout(options) {
|
|
|
675
813
|
);
|
|
676
814
|
return;
|
|
677
815
|
}
|
|
678
|
-
const centered = (0,
|
|
816
|
+
const centered = (0, import_canvas3.centerNodes)(nodes, screenToFlowPosition, getNodesBounds, screenDimensions);
|
|
679
817
|
setNodes(centered);
|
|
680
818
|
},
|
|
681
819
|
[nodes, screenToFlowPosition, getNodesBounds, setNodes]
|
|
682
820
|
);
|
|
683
|
-
const getPlacementPosition = (0,
|
|
821
|
+
const getPlacementPosition = (0, import_react7.useCallback)(
|
|
684
822
|
(size, side = "right", nearNodeId, placementOptions = {}) => {
|
|
685
823
|
const rects = {};
|
|
686
824
|
for (const node of nodes) {
|
|
@@ -693,7 +831,7 @@ function useCanvasLayout(options) {
|
|
|
693
831
|
height
|
|
694
832
|
};
|
|
695
833
|
}
|
|
696
|
-
return (0,
|
|
834
|
+
return (0, import_canvas3.placeBeside)(rects, size, side, nearNodeId, placementOptions);
|
|
697
835
|
},
|
|
698
836
|
[nodes]
|
|
699
837
|
);
|
|
@@ -702,22 +840,22 @@ function useCanvasLayout(options) {
|
|
|
702
840
|
applyIncrementalLayout,
|
|
703
841
|
center,
|
|
704
842
|
getPlacementPosition,
|
|
705
|
-
getCenteredNodePosition:
|
|
843
|
+
getCenteredNodePosition: import_canvas3.getCenteredNodePosition
|
|
706
844
|
};
|
|
707
845
|
}
|
|
708
846
|
|
|
709
847
|
// src/canvas/useCanvasClipboard.ts
|
|
710
|
-
var
|
|
711
|
-
var
|
|
848
|
+
var import_react8 = require("react");
|
|
849
|
+
var import_canvas4 = require("@pixerate/editor/canvas");
|
|
712
850
|
function useCanvasClipboard(options = {}) {
|
|
713
|
-
const copySelectedNodes = (0,
|
|
851
|
+
const copySelectedNodes = (0, import_react8.useCallback)(
|
|
714
852
|
(selectedNodes, connectedEdges, event) => {
|
|
715
853
|
const native = event && "nativeEvent" in event ? event.nativeEvent : event;
|
|
716
|
-
if (native && (0,
|
|
854
|
+
if (native && (0, import_canvas4.isEventFromTextInput)(native)) {
|
|
717
855
|
return false;
|
|
718
856
|
}
|
|
719
857
|
if (selectedNodes.length === 0) return false;
|
|
720
|
-
const serialized = (0,
|
|
858
|
+
const serialized = (0, import_canvas4.serializeCanvasNodes)(selectedNodes, connectedEdges);
|
|
721
859
|
const clipboardData = event?.clipboardData || native?.clipboardData;
|
|
722
860
|
if (clipboardData) {
|
|
723
861
|
clipboardData.setData("application/json", serialized);
|
|
@@ -731,10 +869,10 @@ function useCanvasClipboard(options = {}) {
|
|
|
731
869
|
},
|
|
732
870
|
[]
|
|
733
871
|
);
|
|
734
|
-
const handlePasteEvent = (0,
|
|
872
|
+
const handlePasteEvent = (0, import_react8.useCallback)(
|
|
735
873
|
async (event) => {
|
|
736
874
|
const native = "nativeEvent" in event ? event.nativeEvent : event;
|
|
737
|
-
if ((0,
|
|
875
|
+
if ((0, import_canvas4.isEventFromTextInput)(native)) {
|
|
738
876
|
return false;
|
|
739
877
|
}
|
|
740
878
|
const clipboardData = native?.clipboardData || event?.clipboardData;
|
|
@@ -745,24 +883,24 @@ function useCanvasClipboard(options = {}) {
|
|
|
745
883
|
};
|
|
746
884
|
const jsonText = clipboardData.getData("application/json");
|
|
747
885
|
if (jsonText) {
|
|
748
|
-
const parsed = (0,
|
|
886
|
+
const parsed = (0, import_canvas4.parseCanvasClipboardData)(jsonText);
|
|
749
887
|
if (parsed && parsed.nodes.length > 0) {
|
|
750
888
|
prevent();
|
|
751
|
-
const remapped = (0,
|
|
889
|
+
const remapped = (0, import_canvas4.remapPastedNodes)(parsed.nodes, parsed.edges);
|
|
752
890
|
await options.onPasteNodes?.(remapped.nodes, remapped.edges);
|
|
753
891
|
return true;
|
|
754
892
|
}
|
|
755
893
|
}
|
|
756
894
|
const text = clipboardData.getData("text/plain")?.trim();
|
|
757
895
|
if (text) {
|
|
758
|
-
const parsed = (0,
|
|
896
|
+
const parsed = (0, import_canvas4.parseCanvasClipboardData)(text);
|
|
759
897
|
if (parsed && parsed.nodes.length > 0) {
|
|
760
898
|
prevent();
|
|
761
|
-
const remapped = (0,
|
|
899
|
+
const remapped = (0, import_canvas4.remapPastedNodes)(parsed.nodes, parsed.edges);
|
|
762
900
|
await options.onPasteNodes?.(remapped.nodes, remapped.edges);
|
|
763
901
|
return true;
|
|
764
902
|
}
|
|
765
|
-
if ((0,
|
|
903
|
+
if ((0, import_canvas4.isValidUrl)(text)) {
|
|
766
904
|
prevent();
|
|
767
905
|
options.onPasteUrl?.(text);
|
|
768
906
|
return true;
|
|
@@ -784,8 +922,8 @@ function useCanvasClipboard(options = {}) {
|
|
|
784
922
|
}
|
|
785
923
|
|
|
786
924
|
// src/canvas/useCanvasShortcuts.ts
|
|
787
|
-
var
|
|
788
|
-
var
|
|
925
|
+
var import_react9 = require("react");
|
|
926
|
+
var import_canvas5 = require("@pixerate/editor/canvas");
|
|
789
927
|
function useCanvasShortcuts(options = {}) {
|
|
790
928
|
const {
|
|
791
929
|
targetElement,
|
|
@@ -803,13 +941,13 @@ function useCanvasShortcuts(options = {}) {
|
|
|
803
941
|
onFitView,
|
|
804
942
|
getSelectedNodes
|
|
805
943
|
} = options;
|
|
806
|
-
(0,
|
|
944
|
+
(0, import_react9.useEffect)(() => {
|
|
807
945
|
if (!enabled) return;
|
|
808
946
|
const target = targetElement ?? (typeof window !== "undefined" ? window : null);
|
|
809
947
|
if (!target) return;
|
|
810
948
|
function handleKeyDown(event) {
|
|
811
949
|
const keyboardEvent = event;
|
|
812
|
-
if ((0,
|
|
950
|
+
if ((0, import_canvas5.isEventFromTextInput)(keyboardEvent)) {
|
|
813
951
|
return;
|
|
814
952
|
}
|
|
815
953
|
const isMac = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
@@ -888,7 +1026,7 @@ function useCanvasShortcuts(options = {}) {
|
|
|
888
1026
|
}
|
|
889
1027
|
|
|
890
1028
|
// src/canvas/useCanvasDocking.ts
|
|
891
|
-
var
|
|
1029
|
+
var import_react10 = require("react");
|
|
892
1030
|
function useCanvasDocking(options = {}) {
|
|
893
1031
|
const {
|
|
894
1032
|
strategy = "center-point",
|
|
@@ -898,22 +1036,22 @@ function useCanvasDocking(options = {}) {
|
|
|
898
1036
|
onDockLeave,
|
|
899
1037
|
onDockDrop
|
|
900
1038
|
} = options;
|
|
901
|
-
const activeDockTargetRef = (0,
|
|
902
|
-
const isDockable = (0,
|
|
1039
|
+
const activeDockTargetRef = (0, import_react10.useRef)(null);
|
|
1040
|
+
const isDockable = (0, import_react10.useCallback)(
|
|
903
1041
|
(node) => {
|
|
904
1042
|
if (!dockableTypes || dockableTypes.length === 0) return true;
|
|
905
1043
|
return !!node.type && dockableTypes.includes(node.type);
|
|
906
1044
|
},
|
|
907
1045
|
[dockableTypes]
|
|
908
1046
|
);
|
|
909
|
-
const isTarget = (0,
|
|
1047
|
+
const isTarget = (0, import_react10.useCallback)(
|
|
910
1048
|
(node) => {
|
|
911
1049
|
if (!targetTypes || targetTypes.length === 0) return true;
|
|
912
1050
|
return !!node.type && targetTypes.includes(node.type);
|
|
913
1051
|
},
|
|
914
1052
|
[targetTypes]
|
|
915
1053
|
);
|
|
916
|
-
const findDockTarget = (0,
|
|
1054
|
+
const findDockTarget = (0, import_react10.useCallback)(
|
|
917
1055
|
(draggedNode, candidates, cursorPos) => {
|
|
918
1056
|
if (!isDockable(draggedNode)) return null;
|
|
919
1057
|
const draggedWidth = draggedNode.measured?.width ?? draggedNode.width ?? 200;
|
|
@@ -972,7 +1110,7 @@ function useCanvasDocking(options = {}) {
|
|
|
972
1110
|
},
|
|
973
1111
|
[isDockable, isTarget, strategy]
|
|
974
1112
|
);
|
|
975
|
-
const updateDragOver = (0,
|
|
1113
|
+
const updateDragOver = (0, import_react10.useCallback)(
|
|
976
1114
|
(draggedNode, candidates, cursorPos) => {
|
|
977
1115
|
const target = findDockTarget(draggedNode, candidates, cursorPos);
|
|
978
1116
|
if (target?.id !== activeDockTargetRef.current?.id) {
|
|
@@ -987,7 +1125,7 @@ function useCanvasDocking(options = {}) {
|
|
|
987
1125
|
},
|
|
988
1126
|
[findDockTarget, onDockHover, onDockLeave]
|
|
989
1127
|
);
|
|
990
|
-
const finalizeDock = (0,
|
|
1128
|
+
const finalizeDock = (0, import_react10.useCallback)(
|
|
991
1129
|
(draggedNode) => {
|
|
992
1130
|
if (activeDockTargetRef.current) {
|
|
993
1131
|
onDockDrop?.(activeDockTargetRef.current, draggedNode);
|
|
@@ -1005,22 +1143,22 @@ function useCanvasDocking(options = {}) {
|
|
|
1005
1143
|
}
|
|
1006
1144
|
|
|
1007
1145
|
// src/canvas/useCanvasExplosion.ts
|
|
1008
|
-
var
|
|
1009
|
-
var
|
|
1146
|
+
var import_react11 = require("react");
|
|
1147
|
+
var import_canvas6 = require("@pixerate/editor/canvas");
|
|
1010
1148
|
function mergeById(base, updated) {
|
|
1011
1149
|
if (updated.length === 0) return [...base];
|
|
1012
1150
|
const byId = new Map(updated.map((n) => [n.id, n]));
|
|
1013
1151
|
return base.map((n) => byId.get(n.id) ?? n);
|
|
1014
1152
|
}
|
|
1015
1153
|
function useCanvasExplosion(target) {
|
|
1016
|
-
const snapshotsRef = (0,
|
|
1017
|
-
const explodeNode = (0,
|
|
1154
|
+
const snapshotsRef = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
|
|
1155
|
+
const explodeNode = (0, import_react11.useCallback)(
|
|
1018
1156
|
(parentNodeId, options) => {
|
|
1019
1157
|
const { nodes, edges, setNodes, setEdges } = target;
|
|
1020
1158
|
const parent = nodes.find((n) => n.id === parentNodeId);
|
|
1021
1159
|
if (!parent || options.childNodes.length === 0) return;
|
|
1022
1160
|
const originPos = { ...parent.position };
|
|
1023
|
-
const displacedMap = options.displacementStrategy === "directional" ? (0,
|
|
1161
|
+
const displacedMap = options.displacementStrategy === "directional" ? (0, import_canvas6.calculateDirectionalDisplacement)({
|
|
1024
1162
|
existingNodes: nodes,
|
|
1025
1163
|
originNode: parent,
|
|
1026
1164
|
childNodes: options.childNodes,
|
|
@@ -1046,7 +1184,7 @@ function useCanvasExplosion(target) {
|
|
|
1046
1184
|
if (options.childEdges && options.childEdges.length > 0) {
|
|
1047
1185
|
setEdges((prev) => [...prev, ...options.childEdges]);
|
|
1048
1186
|
}
|
|
1049
|
-
const trajectory = options.trajectory ?? (0,
|
|
1187
|
+
const trajectory = options.trajectory ?? (0, import_canvas6.createFanOutTrajectory)();
|
|
1050
1188
|
const transitions = [];
|
|
1051
1189
|
options.childNodes.forEach((child, index) => {
|
|
1052
1190
|
const liveChild = mergedNodes.find((n) => n.id === child.id);
|
|
@@ -1070,13 +1208,13 @@ function useCanvasExplosion(target) {
|
|
|
1070
1208
|
node,
|
|
1071
1209
|
from: { ...node.position },
|
|
1072
1210
|
to: targetPos,
|
|
1073
|
-
trajectory:
|
|
1211
|
+
trajectory: import_canvas6.linearPositionTrajectory,
|
|
1074
1212
|
duration: options.duration ?? 400,
|
|
1075
1213
|
easing: options.easing
|
|
1076
1214
|
});
|
|
1077
1215
|
}
|
|
1078
1216
|
});
|
|
1079
|
-
(0,
|
|
1217
|
+
(0, import_canvas6.runMultiNodeTransition)(transitions, {
|
|
1080
1218
|
styleFormat: "object",
|
|
1081
1219
|
onUpdate: (updated) => setNodes(mergeById(mergedNodes, updated)),
|
|
1082
1220
|
onComplete: () => options.onComplete?.()
|
|
@@ -1084,7 +1222,7 @@ function useCanvasExplosion(target) {
|
|
|
1084
1222
|
},
|
|
1085
1223
|
[target]
|
|
1086
1224
|
);
|
|
1087
|
-
const collapseNode = (0,
|
|
1225
|
+
const collapseNode = (0, import_react11.useCallback)(
|
|
1088
1226
|
(parentNodeId, options = {}) => {
|
|
1089
1227
|
const { nodes, setNodes, setEdges } = target;
|
|
1090
1228
|
const snapshot = snapshotsRef.current.get(parentNodeId);
|
|
@@ -1115,11 +1253,11 @@ function useCanvasExplosion(target) {
|
|
|
1115
1253
|
to: disp.originalPosition,
|
|
1116
1254
|
duration: options.duration ?? 300,
|
|
1117
1255
|
easing: options.easing,
|
|
1118
|
-
trajectory:
|
|
1256
|
+
trajectory: import_canvas6.linearPositionTrajectory
|
|
1119
1257
|
});
|
|
1120
1258
|
}
|
|
1121
1259
|
});
|
|
1122
|
-
(0,
|
|
1260
|
+
(0, import_canvas6.runMultiNodeTransition)(transitions, {
|
|
1123
1261
|
styleFormat: "object",
|
|
1124
1262
|
onUpdate: (updated) => setNodes(mergeById(nodes, updated)),
|
|
1125
1263
|
onComplete: () => {
|
|
@@ -1141,16 +1279,16 @@ function useCanvasExplosion(target) {
|
|
|
1141
1279
|
}
|
|
1142
1280
|
|
|
1143
1281
|
// src/canvas/useCanvasArrange.ts
|
|
1144
|
-
var
|
|
1145
|
-
var
|
|
1282
|
+
var import_react12 = require("react");
|
|
1283
|
+
var import_canvas7 = require("@pixerate/editor/canvas");
|
|
1146
1284
|
function useCanvasArrange(options) {
|
|
1147
|
-
const [guides, setGuides] = (0,
|
|
1148
|
-
const nodesRef = (0,
|
|
1285
|
+
const [guides, setGuides] = (0, import_react12.useState)([]);
|
|
1286
|
+
const nodesRef = (0, import_react12.useRef)(options.nodes);
|
|
1149
1287
|
nodesRef.current = options.nodes;
|
|
1150
|
-
const optionsRef = (0,
|
|
1288
|
+
const optionsRef = (0, import_react12.useRef)(options);
|
|
1151
1289
|
optionsRef.current = options;
|
|
1152
|
-
const controller = (0,
|
|
1153
|
-
() => (0,
|
|
1290
|
+
const controller = (0, import_react12.useMemo)(
|
|
1291
|
+
() => (0, import_canvas7.createCanvasArrangeController)({
|
|
1154
1292
|
getNodes: () => nodesRef.current,
|
|
1155
1293
|
setNodes: (next) => {
|
|
1156
1294
|
nodesRef.current = next;
|
|
@@ -1177,19 +1315,19 @@ function useCanvasArrange(options) {
|
|
|
1177
1315
|
}),
|
|
1178
1316
|
[]
|
|
1179
1317
|
);
|
|
1180
|
-
return (0,
|
|
1318
|
+
return (0, import_react12.useMemo)(() => ({ ...controller, guides }), [controller, guides]);
|
|
1181
1319
|
}
|
|
1182
1320
|
function useCanvasArrangeShortcuts(options) {
|
|
1183
|
-
const optionsRef = (0,
|
|
1321
|
+
const optionsRef = (0, import_react12.useRef)(options);
|
|
1184
1322
|
optionsRef.current = options;
|
|
1185
1323
|
const { targetElement, enabled = true } = options;
|
|
1186
|
-
(0,
|
|
1324
|
+
(0, import_react12.useEffect)(() => {
|
|
1187
1325
|
if (!enabled) return;
|
|
1188
1326
|
const target = targetElement ?? (typeof window !== "undefined" ? window : null);
|
|
1189
1327
|
if (!target) return;
|
|
1190
1328
|
function handleKeyDown(event) {
|
|
1191
1329
|
const { arrange, scenes, bindings } = optionsRef.current;
|
|
1192
|
-
const action = (0,
|
|
1330
|
+
const action = (0, import_canvas7.matchArrangeShortcut)(event, bindings);
|
|
1193
1331
|
if (!action) return;
|
|
1194
1332
|
let handled = false;
|
|
1195
1333
|
if (action === "nextScene" || action === "previousScene") {
|
|
@@ -1208,27 +1346,27 @@ function useCanvasArrangeShortcuts(options) {
|
|
|
1208
1346
|
}
|
|
1209
1347
|
|
|
1210
1348
|
// src/canvas/useCanvasScenes.ts
|
|
1211
|
-
var
|
|
1212
|
-
var
|
|
1349
|
+
var import_react13 = require("react");
|
|
1350
|
+
var import_canvas8 = require("@pixerate/editor/canvas");
|
|
1213
1351
|
function useCanvasScenes(options = {}) {
|
|
1214
|
-
const optionsRef = (0,
|
|
1352
|
+
const optionsRef = (0, import_react13.useRef)(options);
|
|
1215
1353
|
optionsRef.current = options;
|
|
1216
|
-
const storeRef = (0,
|
|
1217
|
-
if (!storeRef.current) storeRef.current = options.store ?? new
|
|
1354
|
+
const storeRef = (0, import_react13.useRef)(null);
|
|
1355
|
+
if (!storeRef.current) storeRef.current = options.store ?? new import_canvas8.CanvasScenesStore(options);
|
|
1218
1356
|
const store = storeRef.current;
|
|
1219
|
-
const state = (0,
|
|
1357
|
+
const state = (0, import_react13.useSyncExternalStore)(
|
|
1220
1358
|
(listener) => store.subscribe(listener),
|
|
1221
1359
|
() => store.getState(),
|
|
1222
1360
|
() => store.getState()
|
|
1223
1361
|
);
|
|
1224
|
-
const actions = (0,
|
|
1362
|
+
const actions = (0, import_react13.useMemo)(() => {
|
|
1225
1363
|
const show = (scene) => {
|
|
1226
1364
|
if (!scene) return scene;
|
|
1227
1365
|
const o = optionsRef.current;
|
|
1228
1366
|
const provider = o.transitions?.provider;
|
|
1229
1367
|
const element = o.transitions?.element();
|
|
1230
1368
|
if (scene.transition && provider && element) {
|
|
1231
|
-
void (0,
|
|
1369
|
+
void (0, import_canvas8.transitionCanvasView)({ provider, transition: scene.transition, element, jump: () => o.setViewport?.(scene.viewport, { duration: 0 }) });
|
|
1232
1370
|
} else o.setViewport?.(scene.viewport, { duration: o.duration ?? 300 });
|
|
1233
1371
|
return scene;
|
|
1234
1372
|
};
|
|
@@ -1242,7 +1380,7 @@ function useCanvasScenes(options = {}) {
|
|
|
1242
1380
|
},
|
|
1243
1381
|
/** Saves a scene framing the given nodes in a container of `size`. */
|
|
1244
1382
|
captureNodes(nodes, ids, size, name, fit) {
|
|
1245
|
-
const viewport = (0,
|
|
1383
|
+
const viewport = (0, import_canvas8.fitViewportToNodes)(nodes, size, ids, fit);
|
|
1246
1384
|
return viewport ? store.add({ viewport, name, nodeIds: ids }) : void 0;
|
|
1247
1385
|
},
|
|
1248
1386
|
/** Replaces a scene's viewport with the live one. */
|
|
@@ -1274,15 +1412,15 @@ function useCanvasScenes(options = {}) {
|
|
|
1274
1412
|
}
|
|
1275
1413
|
|
|
1276
1414
|
// src/canvas/useCanvasCapture.ts
|
|
1277
|
-
var
|
|
1278
|
-
var
|
|
1279
|
-
var
|
|
1415
|
+
var import_react14 = require("react");
|
|
1416
|
+
var import_canvas9 = require("@pixerate/editor/canvas");
|
|
1417
|
+
var import_tools2 = require("@pixerate/editor/tools");
|
|
1280
1418
|
function useCanvasCapture(options) {
|
|
1281
|
-
const optionsRef = (0,
|
|
1419
|
+
const optionsRef = (0, import_react14.useRef)(options);
|
|
1282
1420
|
optionsRef.current = options;
|
|
1283
|
-
return (0,
|
|
1421
|
+
return (0, import_react14.useMemo)(() => {
|
|
1284
1422
|
const latest = () => optionsRef.current;
|
|
1285
|
-
return (0,
|
|
1423
|
+
return (0, import_canvas9.createCanvasCaptureToolProvider)({
|
|
1286
1424
|
...options,
|
|
1287
1425
|
element: () => {
|
|
1288
1426
|
const el = latest().element;
|
|
@@ -1292,14 +1430,14 @@ function useCanvasCapture(options) {
|
|
|
1292
1430
|
},
|
|
1293
1431
|
getViewport: () => latest().getViewport(),
|
|
1294
1432
|
getNodes: () => latest().getNodes(),
|
|
1295
|
-
getNodeRect: (node, nodes) => (latest().getNodeRect ??
|
|
1296
|
-
rasterize: (element, raster) => (latest().rasterize ??
|
|
1433
|
+
getNodeRect: (node, nodes) => (latest().getNodeRect ?? import_canvas9.canvasNodeCaptureRect)(node, nodes),
|
|
1434
|
+
rasterize: (element, raster) => (latest().rasterize ?? import_tools2.rasterizeElement)(element, raster)
|
|
1297
1435
|
});
|
|
1298
1436
|
}, [options.id, options.namespace]);
|
|
1299
1437
|
}
|
|
1300
1438
|
|
|
1301
1439
|
// src/canvas/CanvasGuidesLayer.tsx
|
|
1302
|
-
var
|
|
1440
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1303
1441
|
var DEFAULT_VIEWPORT = { x: 0, y: 0, zoom: 1 };
|
|
1304
1442
|
function CanvasGuidesLayer({
|
|
1305
1443
|
guides,
|
|
@@ -1312,7 +1450,7 @@ function CanvasGuidesLayer({
|
|
|
1312
1450
|
if (!guides || guides.length === 0) return null;
|
|
1313
1451
|
const sx = (x) => x * viewport.zoom + viewport.x;
|
|
1314
1452
|
const sy = (y) => y * viewport.zoom + viewport.y;
|
|
1315
|
-
return /* @__PURE__ */ (0,
|
|
1453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1316
1454
|
"svg",
|
|
1317
1455
|
{
|
|
1318
1456
|
className: `pixerate-canvas-guides ${className}`,
|
|
@@ -1329,7 +1467,7 @@ function CanvasGuidesLayer({
|
|
|
1329
1467
|
children: [
|
|
1330
1468
|
guides.map((guide, i) => {
|
|
1331
1469
|
const measuring = guide.kind === "measure" || guide.kind === "extension";
|
|
1332
|
-
return /* @__PURE__ */ (0,
|
|
1470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1333
1471
|
"line",
|
|
1334
1472
|
{
|
|
1335
1473
|
"data-kind": guide.kind,
|
|
@@ -1351,15 +1489,15 @@ function CanvasGuidesLayer({
|
|
|
1351
1489
|
const y = sy((guide.y1 + guide.y2) / 2);
|
|
1352
1490
|
const vertical = guide.orientation === "vertical";
|
|
1353
1491
|
const width = guide.label.length * 6.5 + 8;
|
|
1354
|
-
return /* @__PURE__ */ (0,
|
|
1492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1355
1493
|
"g",
|
|
1356
1494
|
{
|
|
1357
1495
|
className: "pixerate-canvas-guides__label",
|
|
1358
1496
|
"data-label": guide.label,
|
|
1359
1497
|
transform: `translate(${vertical ? x + 4 : x - width / 2} ${vertical ? y - 8 : y + 4})`,
|
|
1360
1498
|
children: [
|
|
1361
|
-
/* @__PURE__ */ (0,
|
|
1362
|
-
/* @__PURE__ */ (0,
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { width, height: 16, rx: 3, fill: measureColor }),
|
|
1500
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1363
1501
|
"text",
|
|
1364
1502
|
{
|
|
1365
1503
|
x: width / 2,
|
|
@@ -1382,17 +1520,17 @@ function CanvasGuidesLayer({
|
|
|
1382
1520
|
}
|
|
1383
1521
|
|
|
1384
1522
|
// src/canvas/useCanvasDraw.ts
|
|
1385
|
-
var
|
|
1386
|
-
var
|
|
1523
|
+
var import_react15 = require("react");
|
|
1524
|
+
var import_canvas10 = require("@pixerate/editor/canvas");
|
|
1387
1525
|
function useCanvasDraw(options) {
|
|
1388
|
-
const nodesRef = (0,
|
|
1526
|
+
const nodesRef = (0, import_react15.useRef)(options.nodes);
|
|
1389
1527
|
nodesRef.current = options.nodes;
|
|
1390
|
-
const optionsRef = (0,
|
|
1528
|
+
const optionsRef = (0, import_react15.useRef)(options);
|
|
1391
1529
|
optionsRef.current = options;
|
|
1392
|
-
const [tool, setToolState] = (0,
|
|
1393
|
-
const [activeStroke, setActiveStroke] = (0,
|
|
1394
|
-
const controller = (0,
|
|
1395
|
-
() => (0,
|
|
1530
|
+
const [tool, setToolState] = (0, import_react15.useState)(options.initialTool ?? "select");
|
|
1531
|
+
const [activeStroke, setActiveStroke] = (0, import_react15.useState)(null);
|
|
1532
|
+
const controller = (0, import_react15.useMemo)(
|
|
1533
|
+
() => (0, import_canvas10.createCanvasDrawController)({
|
|
1396
1534
|
getNodes: () => nodesRef.current,
|
|
1397
1535
|
setNodes: (next) => {
|
|
1398
1536
|
nodesRef.current = next;
|
|
@@ -1413,13 +1551,13 @@ function useCanvasDraw(options) {
|
|
|
1413
1551
|
}),
|
|
1414
1552
|
[]
|
|
1415
1553
|
);
|
|
1416
|
-
const [style, setStyleState] = (0,
|
|
1417
|
-
(0,
|
|
1554
|
+
const [style, setStyleState] = (0, import_react15.useState)(controller.style);
|
|
1555
|
+
(0, import_react15.useEffect)(() => {
|
|
1418
1556
|
if (options.initialTool && options.initialTool !== controller.tool) {
|
|
1419
1557
|
controller.setTool(options.initialTool);
|
|
1420
1558
|
}
|
|
1421
1559
|
}, [options.initialTool, controller]);
|
|
1422
|
-
return (0,
|
|
1560
|
+
return (0, import_react15.useMemo)(
|
|
1423
1561
|
() => ({
|
|
1424
1562
|
tool,
|
|
1425
1563
|
style,
|
|
@@ -1440,9 +1578,9 @@ function useCanvasDraw(options) {
|
|
|
1440
1578
|
}
|
|
1441
1579
|
|
|
1442
1580
|
// src/canvas/CanvasDrawLayer.tsx
|
|
1443
|
-
var
|
|
1444
|
-
var
|
|
1445
|
-
var
|
|
1581
|
+
var import_react16 = require("react");
|
|
1582
|
+
var import_canvas11 = require("@pixerate/editor/canvas");
|
|
1583
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1446
1584
|
var DEFAULT_VIEWPORT2 = { x: 0, y: 0, zoom: 1 };
|
|
1447
1585
|
function CanvasDrawLayer({
|
|
1448
1586
|
draw,
|
|
@@ -1452,10 +1590,10 @@ function CanvasDrawLayer({
|
|
|
1452
1590
|
cursor,
|
|
1453
1591
|
eraserRadius = 12
|
|
1454
1592
|
}) {
|
|
1455
|
-
const svgRef = (0,
|
|
1456
|
-
const [spaceHeld, setSpaceHeld] = (0,
|
|
1457
|
-
const [eraserPos, setEraserPos] = (0,
|
|
1458
|
-
(0,
|
|
1593
|
+
const svgRef = (0, import_react16.useRef)(null);
|
|
1594
|
+
const [spaceHeld, setSpaceHeld] = (0, import_react16.useState)(false);
|
|
1595
|
+
const [eraserPos, setEraserPos] = (0, import_react16.useState)(null);
|
|
1596
|
+
(0, import_react16.useEffect)(() => {
|
|
1459
1597
|
function onKeyDown(e) {
|
|
1460
1598
|
if (e.code === "Space" && !e.repeat) {
|
|
1461
1599
|
const tag = e.target?.tagName;
|
|
@@ -1477,7 +1615,7 @@ function CanvasDrawLayer({
|
|
|
1477
1615
|
window.removeEventListener("keyup", onKeyUp);
|
|
1478
1616
|
};
|
|
1479
1617
|
}, []);
|
|
1480
|
-
const clientToFlow = (0,
|
|
1618
|
+
const clientToFlow = (0, import_react16.useCallback)(
|
|
1481
1619
|
(clientX, clientY) => {
|
|
1482
1620
|
if (!svgRef.current) return [0, 0];
|
|
1483
1621
|
const rect = svgRef.current.getBoundingClientRect();
|
|
@@ -1497,7 +1635,7 @@ function CanvasDrawLayer({
|
|
|
1497
1635
|
e.stopPropagation();
|
|
1498
1636
|
e.target.setPointerCapture?.(e.pointerId);
|
|
1499
1637
|
const flowPt = clientToFlow(e.clientX, e.clientY);
|
|
1500
|
-
draw.startStroke(flowPt, (0,
|
|
1638
|
+
draw.startStroke(flowPt, (0, import_canvas11.pointerPenSample)(e));
|
|
1501
1639
|
if (draw.tool === "eraser") {
|
|
1502
1640
|
setEraserPos([e.clientX, e.clientY]);
|
|
1503
1641
|
}
|
|
@@ -1512,7 +1650,7 @@ function CanvasDrawLayer({
|
|
|
1512
1650
|
e.stopPropagation();
|
|
1513
1651
|
const events = draw.style.brush !== void 0 ? e.nativeEvent.getCoalescedEvents?.() ?? [] : [];
|
|
1514
1652
|
for (const ev of events.length ? events : [e.nativeEvent]) {
|
|
1515
|
-
draw.continueStroke(clientToFlow(ev.clientX, ev.clientY), (0,
|
|
1653
|
+
draw.continueStroke(clientToFlow(ev.clientX, ev.clientY), (0, import_canvas11.pointerPenSample)(ev));
|
|
1516
1654
|
}
|
|
1517
1655
|
}
|
|
1518
1656
|
};
|
|
@@ -1530,11 +1668,11 @@ function CanvasDrawLayer({
|
|
|
1530
1668
|
setEraserPos(null);
|
|
1531
1669
|
};
|
|
1532
1670
|
const resolvedCursor = cursor ? cursor : spaceHeld ? "grab" : draw.tool === "eraser" ? "crosshair" : draw.tool === "pen" || draw.tool === "highlighter" ? "crosshair" : "default";
|
|
1533
|
-
const strokePath = draw.activeStroke ? (0,
|
|
1534
|
-
const activeGradient = draw.activeStroke ? (0,
|
|
1535
|
-
const resolvedGradientDef = activeGradient ? (0,
|
|
1671
|
+
const strokePath = draw.activeStroke ? (0, import_canvas11.strokePointsToPathData)(draw.activeStroke.points) : null;
|
|
1672
|
+
const activeGradient = draw.activeStroke ? (0, import_canvas11.resolveCanvasGradient)(draw.activeStroke.style.gradient ?? draw.activeStroke.style.color) : null;
|
|
1673
|
+
const resolvedGradientDef = activeGradient ? (0, import_canvas11.gradientToSvgDef)(activeGradient, "active-draw-stroke-gradient") : null;
|
|
1536
1674
|
const strokePaint = resolvedGradientDef ? `url(#${resolvedGradientDef.id})` : draw.activeStroke ? draw.activeStroke.style.color : "currentColor";
|
|
1537
|
-
return /* @__PURE__ */ (0,
|
|
1675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1538
1676
|
"svg",
|
|
1539
1677
|
{
|
|
1540
1678
|
ref: svgRef,
|
|
@@ -1556,11 +1694,11 @@ function CanvasDrawLayer({
|
|
|
1556
1694
|
onPointerUp: handlePointerUp,
|
|
1557
1695
|
onPointerLeave: handlePointerLeave,
|
|
1558
1696
|
children: [
|
|
1559
|
-
resolvedGradientDef && /* @__PURE__ */ (0,
|
|
1560
|
-
resolvedGradientDef.type === "linear" && /* @__PURE__ */ (0,
|
|
1561
|
-
resolvedGradientDef.type === "radial" && /* @__PURE__ */ (0,
|
|
1697
|
+
resolvedGradientDef && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("defs", { children: [
|
|
1698
|
+
resolvedGradientDef.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("linearGradient", { id: resolvedGradientDef.id, ...resolvedGradientDef.attrs, children: resolvedGradientDef.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
1699
|
+
resolvedGradientDef.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("radialGradient", { id: resolvedGradientDef.id, ...resolvedGradientDef.attrs, children: resolvedGradientDef.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
|
|
1562
1700
|
] }),
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { transform: `translate(${viewport.x}, ${viewport.y}) scale(${viewport.zoom})`, children: draw.activeStroke && strokePath && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1564
1702
|
"path",
|
|
1565
1703
|
{
|
|
1566
1704
|
className: "pixerate-canvas-draw-active",
|
|
@@ -1573,7 +1711,7 @@ function CanvasDrawLayer({
|
|
|
1573
1711
|
strokeLinejoin: draw.activeStroke.style.join ?? "round"
|
|
1574
1712
|
}
|
|
1575
1713
|
) }),
|
|
1576
|
-
draw.tool === "eraser" && eraserPos && svgRef.current && /* @__PURE__ */ (0,
|
|
1714
|
+
draw.tool === "eraser" && eraserPos && svgRef.current && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1577
1715
|
"circle",
|
|
1578
1716
|
{
|
|
1579
1717
|
cx: eraserPos[0] - svgRef.current.getBoundingClientRect().left,
|
|
@@ -1592,20 +1730,20 @@ function CanvasDrawLayer({
|
|
|
1592
1730
|
}
|
|
1593
1731
|
|
|
1594
1732
|
// src/canvas/useCanvasMeasure.ts
|
|
1595
|
-
var
|
|
1596
|
-
var
|
|
1733
|
+
var import_react17 = require("react");
|
|
1734
|
+
var import_canvas12 = require("@pixerate/editor/canvas");
|
|
1597
1735
|
var EMPTY = { guides: [], target: null, selection: null };
|
|
1598
1736
|
function useCanvasMeasure(options) {
|
|
1599
1737
|
const { nodes, enabled = true, requireModifier = true, targetElement, rectOptions } = options;
|
|
1600
|
-
const [hoveredId, setHoveredId] = (0,
|
|
1601
|
-
const [modifier, setModifier] = (0,
|
|
1602
|
-
const optionsRef = (0,
|
|
1738
|
+
const [hoveredId, setHoveredId] = (0, import_react17.useState)(null);
|
|
1739
|
+
const [modifier, setModifier] = (0, import_react17.useState)(false);
|
|
1740
|
+
const optionsRef = (0, import_react17.useRef)(options);
|
|
1603
1741
|
optionsRef.current = options;
|
|
1604
|
-
(0,
|
|
1742
|
+
(0, import_react17.useEffect)(() => {
|
|
1605
1743
|
if (!enabled) return;
|
|
1606
1744
|
const target = targetElement ?? (typeof window !== "undefined" ? window : null);
|
|
1607
1745
|
if (!target) return;
|
|
1608
|
-
const onKey = (event) => setModifier((0,
|
|
1746
|
+
const onKey = (event) => setModifier((0, import_canvas12.isMeasureModifierHeld)(event));
|
|
1609
1747
|
const onBlur = () => setModifier(false);
|
|
1610
1748
|
target.addEventListener("keydown", onKey);
|
|
1611
1749
|
target.addEventListener("keyup", onKey);
|
|
@@ -1618,16 +1756,16 @@ function useCanvasMeasure(options) {
|
|
|
1618
1756
|
};
|
|
1619
1757
|
}, [enabled, targetElement]);
|
|
1620
1758
|
const active = enabled && (!requireModifier || modifier);
|
|
1621
|
-
const result = (0,
|
|
1759
|
+
const result = (0, import_react17.useMemo)(() => {
|
|
1622
1760
|
if (!active) return EMPTY;
|
|
1623
1761
|
const ids = optionsRef.current.getSelectedIds?.() ?? nodes.filter((n) => n.selected).map((n) => n.id);
|
|
1624
|
-
return (0,
|
|
1762
|
+
return (0, import_canvas12.measureSelection)(nodes, ids, hoveredId, rectOptions);
|
|
1625
1763
|
}, [active, nodes, hoveredId, rectOptions]);
|
|
1626
|
-
const onNodeMouseEnter = (0,
|
|
1764
|
+
const onNodeMouseEnter = (0, import_react17.useCallback)((event, node) => {
|
|
1627
1765
|
setHoveredId(node.id);
|
|
1628
1766
|
if (event && typeof event.altKey === "boolean") setModifier(event.altKey);
|
|
1629
1767
|
}, []);
|
|
1630
|
-
const onNodeMouseLeave = (0,
|
|
1768
|
+
const onNodeMouseLeave = (0, import_react17.useCallback)((_event, node) => {
|
|
1631
1769
|
setHoveredId((current) => current === node.id ? null : current);
|
|
1632
1770
|
}, []);
|
|
1633
1771
|
return {
|
|
@@ -1647,39 +1785,39 @@ function useCanvasMeasure(options) {
|
|
|
1647
1785
|
}
|
|
1648
1786
|
|
|
1649
1787
|
// src/canvas/index.ts
|
|
1650
|
-
var import_canvas26 = require("@pixerate/editor/canvas");
|
|
1651
1788
|
var import_canvas27 = require("@pixerate/editor/canvas");
|
|
1789
|
+
var import_canvas28 = require("@pixerate/editor/canvas");
|
|
1652
1790
|
|
|
1653
1791
|
// src/canvas/ShapeNode.tsx
|
|
1654
|
-
var
|
|
1792
|
+
var import_canvas15 = require("@pixerate/editor/canvas");
|
|
1655
1793
|
|
|
1656
1794
|
// src/canvas/useShapeBrushstroke.tsx
|
|
1657
|
-
var
|
|
1658
|
-
var
|
|
1659
|
-
var
|
|
1660
|
-
var ShapeNodeZoomContext = (0,
|
|
1795
|
+
var import_react18 = require("react");
|
|
1796
|
+
var import_canvas13 = require("@pixerate/editor/canvas");
|
|
1797
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1798
|
+
var ShapeNodeZoomContext = (0, import_react18.createContext)(1);
|
|
1661
1799
|
function ShapeNodeZoomProvider({ zoom, children }) {
|
|
1662
|
-
const bucket = (0,
|
|
1663
|
-
return /* @__PURE__ */ (0,
|
|
1800
|
+
const bucket = (0, import_canvas13.brushstrokeScaleBucket)(zoom);
|
|
1801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ShapeNodeZoomContext.Provider, { value: bucket, children });
|
|
1664
1802
|
}
|
|
1665
1803
|
function useShapeBrushstroke(shape, width, height, position) {
|
|
1666
|
-
const zoom = (0,
|
|
1667
|
-
const brushed = (0,
|
|
1804
|
+
const zoom = (0, import_react18.useContext)(ShapeNodeZoomContext);
|
|
1805
|
+
const brushed = (0, import_canvas13.isBrushedShape)(shape) ? shape : null;
|
|
1668
1806
|
const vb = brushed?.viewBox;
|
|
1669
1807
|
const nodeScale = vb && width && height && vb[2] > 0 && vb[3] > 0 ? Math.max(width / vb[2], height / vb[3]) : 1;
|
|
1670
1808
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
1671
|
-
const scale = (0,
|
|
1809
|
+
const scale = (0, import_canvas13.brushstrokeScaleBucket)(zoom * nodeScale, dpr);
|
|
1672
1810
|
const unit = vb && width && vb[2] > 0 ? width / vb[2] : 1;
|
|
1673
1811
|
const ox = Math.round((position?.x ?? 0) - (vb?.[0] ?? 0) * unit);
|
|
1674
1812
|
const oy = Math.round((position?.y ?? 0) - (vb?.[1] ?? 0) * unit);
|
|
1675
|
-
const [image, setImage] = (0,
|
|
1676
|
-
(0,
|
|
1813
|
+
const [image, setImage] = (0, import_react18.useState)(null);
|
|
1814
|
+
(0, import_react18.useEffect)(() => {
|
|
1677
1815
|
if (!brushed) {
|
|
1678
1816
|
setImage(null);
|
|
1679
1817
|
return;
|
|
1680
1818
|
}
|
|
1681
1819
|
let live = true;
|
|
1682
|
-
(0,
|
|
1820
|
+
(0, import_canvas13.renderShapeBrushstroke)(brushed, { scale, origin: { x: ox, y: oy }, unit }).then(
|
|
1683
1821
|
(img) => live && setImage(img),
|
|
1684
1822
|
(error) => {
|
|
1685
1823
|
if (!live) return;
|
|
@@ -1694,12 +1832,12 @@ function useShapeBrushstroke(shape, width, height, position) {
|
|
|
1694
1832
|
return image;
|
|
1695
1833
|
}
|
|
1696
1834
|
function useCanvasBrushes(options = {}) {
|
|
1697
|
-
const [state, setState] = (0,
|
|
1835
|
+
const [state, setState] = (0, import_react18.useState)({ brushes: [], loading: true, error: null });
|
|
1698
1836
|
const swatches = options.swatches ? JSON.stringify(options.swatches) : "";
|
|
1699
|
-
(0,
|
|
1837
|
+
(0, import_react18.useEffect)(() => {
|
|
1700
1838
|
let live = true;
|
|
1701
1839
|
const opts = swatches ? JSON.parse(swatches) : null;
|
|
1702
|
-
(0,
|
|
1840
|
+
(0, import_canvas13.listCanvasBrushes)().then(async (list) => opts ? Promise.all(list.map(async (b) => ({ ...b, swatch: await (0, import_canvas13.renderCanvasBrushSwatch)(b.id, opts) }))) : list).then(
|
|
1703
1841
|
(brushes) => live && setState({ brushes, loading: false, error: null }),
|
|
1704
1842
|
(error) => live && setState({ brushes: [], loading: false, error: error instanceof Error ? error.message : String(error) })
|
|
1705
1843
|
);
|
|
@@ -1707,19 +1845,19 @@ function useCanvasBrushes(options = {}) {
|
|
|
1707
1845
|
live = false;
|
|
1708
1846
|
};
|
|
1709
1847
|
}, [swatches]);
|
|
1710
|
-
return (0,
|
|
1848
|
+
return (0, import_react18.useMemo)(() => state, [state]);
|
|
1711
1849
|
}
|
|
1712
1850
|
|
|
1713
1851
|
// src/canvas/CanvasEffects.tsx
|
|
1714
|
-
var
|
|
1715
|
-
var
|
|
1852
|
+
var import_react24 = require("react");
|
|
1853
|
+
var import_canvas14 = require("@pixerate/editor/canvas");
|
|
1716
1854
|
|
|
1717
1855
|
// src/effects/useEffects.ts
|
|
1718
|
-
var
|
|
1856
|
+
var import_react19 = require("react");
|
|
1719
1857
|
function useEffectDescription(provider, effect) {
|
|
1720
|
-
const [state, setState] = (0,
|
|
1858
|
+
const [state, setState] = (0, import_react19.useState)({ key: "", description: null, error: null });
|
|
1721
1859
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1722
|
-
(0,
|
|
1860
|
+
(0, import_react19.useEffect)(() => {
|
|
1723
1861
|
if (!provider || !effect) return;
|
|
1724
1862
|
let live = true;
|
|
1725
1863
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1734,13 +1872,13 @@ function useEffectDescription(provider, effect) {
|
|
|
1734
1872
|
}
|
|
1735
1873
|
|
|
1736
1874
|
// src/effects/EffectThumbnail.tsx
|
|
1737
|
-
var
|
|
1875
|
+
var import_react20 = require("react");
|
|
1738
1876
|
var import_effects = require("@pixerate/editor/effects");
|
|
1739
|
-
var
|
|
1877
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1740
1878
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1741
|
-
const ref = (0,
|
|
1742
|
-
const [failed, setFailed] = (0,
|
|
1743
|
-
(0,
|
|
1879
|
+
const ref = (0, import_react20.useRef)(null);
|
|
1880
|
+
const [failed, setFailed] = (0, import_react20.useState)(effect.kind === "motion");
|
|
1881
|
+
(0, import_react20.useEffect)(() => {
|
|
1744
1882
|
if (effect.kind === "motion") return;
|
|
1745
1883
|
let live = true;
|
|
1746
1884
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1755,28 +1893,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1755
1893
|
live = false;
|
|
1756
1894
|
};
|
|
1757
1895
|
}, [provider, effect, width, height]);
|
|
1758
|
-
return /* @__PURE__ */ (0,
|
|
1896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1759
1897
|
"div",
|
|
1760
1898
|
{
|
|
1761
1899
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1762
1900
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1763
1901
|
"data-effect-thumbnail": effect.id,
|
|
1764
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1902
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: effect.kind === "motion" ? "Motion" : "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
1765
1903
|
}
|
|
1766
1904
|
);
|
|
1767
1905
|
}
|
|
1768
1906
|
|
|
1769
1907
|
// src/effects/EffectsBrowser.tsx
|
|
1770
|
-
var
|
|
1908
|
+
var import_react21 = require("react");
|
|
1771
1909
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1772
|
-
var
|
|
1910
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1773
1911
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1774
|
-
const [all, setAll] = (0,
|
|
1775
|
-
const [query, setQuery] = (0,
|
|
1776
|
-
const [category, setCategory] = (0,
|
|
1777
|
-
const [use, setUse] = (0,
|
|
1778
|
-
const [error, setError] = (0,
|
|
1779
|
-
(0,
|
|
1912
|
+
const [all, setAll] = (0, import_react21.useState)([]);
|
|
1913
|
+
const [query, setQuery] = (0, import_react21.useState)("");
|
|
1914
|
+
const [category, setCategory] = (0, import_react21.useState)("");
|
|
1915
|
+
const [use, setUse] = (0, import_react21.useState)("");
|
|
1916
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
1917
|
+
(0, import_react21.useEffect)(() => {
|
|
1780
1918
|
if (!provider) return setAll([]);
|
|
1781
1919
|
let live = true;
|
|
1782
1920
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1787,8 +1925,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1787
1925
|
live = false;
|
|
1788
1926
|
};
|
|
1789
1927
|
}, [provider]);
|
|
1790
|
-
const [found, setFound] = (0,
|
|
1791
|
-
(0,
|
|
1928
|
+
const [found, setFound] = (0, import_react21.useState)([]);
|
|
1929
|
+
(0, import_react21.useEffect)(() => {
|
|
1792
1930
|
if (!provider) return setFound([]);
|
|
1793
1931
|
let live = true;
|
|
1794
1932
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1797,14 +1935,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1797
1935
|
};
|
|
1798
1936
|
}, [provider, query, category, use]);
|
|
1799
1937
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (uses ? e.kind !== "motion" || uses.includes("motion") : e.kind !== "motion") && (!uses || e.uses.some((u) => uses.includes(u)));
|
|
1800
|
-
const categories = (0,
|
|
1938
|
+
const categories = (0, import_react21.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1801
1939
|
const shown = found.filter(allowed);
|
|
1802
1940
|
if (!provider)
|
|
1803
|
-
return /* @__PURE__ */ (0,
|
|
1804
|
-
return /* @__PURE__ */ (0,
|
|
1805
|
-
title && /* @__PURE__ */ (0,
|
|
1806
|
-
/* @__PURE__ */ (0,
|
|
1807
|
-
/* @__PURE__ */ (0,
|
|
1941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
|
|
1942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
1943
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1808
1946
|
"input",
|
|
1809
1947
|
{
|
|
1810
1948
|
type: "search",
|
|
@@ -1815,17 +1953,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1815
1953
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1816
1954
|
}
|
|
1817
1955
|
),
|
|
1818
|
-
/* @__PURE__ */ (0,
|
|
1819
|
-
/* @__PURE__ */ (0,
|
|
1820
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
1956
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
|
|
1957
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "All categories" }),
|
|
1958
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: c, children: c }, c))
|
|
1821
1959
|
] }),
|
|
1822
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1823
|
-
/* @__PURE__ */ (0,
|
|
1824
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
1960
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
|
|
1961
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "Any use" }),
|
|
1962
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1825
1963
|
] })
|
|
1826
1964
|
] }),
|
|
1827
|
-
error && /* @__PURE__ */ (0,
|
|
1828
|
-
/* @__PURE__ */ (0,
|
|
1965
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1829
1967
|
"button",
|
|
1830
1968
|
{
|
|
1831
1969
|
type: "button",
|
|
@@ -1834,25 +1972,25 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1834
1972
|
"data-effect-id": e.id,
|
|
1835
1973
|
onClick: () => onPick(e),
|
|
1836
1974
|
children: [
|
|
1837
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1838
|
-
/* @__PURE__ */ (0,
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1975
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
1976
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
1977
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
1840
1978
|
]
|
|
1841
1979
|
}
|
|
1842
1980
|
) }, e.id)) }),
|
|
1843
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
1981
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
1844
1982
|
] });
|
|
1845
1983
|
}
|
|
1846
1984
|
|
|
1847
1985
|
// src/effects/EffectParameters.tsx
|
|
1848
|
-
var
|
|
1986
|
+
var import_react23 = __toESM(require("react"), 1);
|
|
1849
1987
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1850
1988
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1851
1989
|
|
|
1852
1990
|
// src/parameters/fields.tsx
|
|
1853
|
-
var
|
|
1991
|
+
var import_react22 = require("react");
|
|
1854
1992
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1855
|
-
var
|
|
1993
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1856
1994
|
var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
1857
1995
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
1858
1996
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
@@ -1876,7 +2014,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
1876
2014
|
onKeyDown: keyDown,
|
|
1877
2015
|
...rest
|
|
1878
2016
|
};
|
|
1879
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
2017
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { type: "text", ...props }, value);
|
|
1880
2018
|
}
|
|
1881
2019
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
1882
2020
|
function ParameterNumberInput({
|
|
@@ -1887,8 +2025,8 @@ function ParameterNumberInput({
|
|
|
1887
2025
|
id,
|
|
1888
2026
|
"aria-label": ariaLabel
|
|
1889
2027
|
}) {
|
|
1890
|
-
return /* @__PURE__ */ (0,
|
|
1891
|
-
/* @__PURE__ */ (0,
|
|
2028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1892
2030
|
ParameterCommitInput,
|
|
1893
2031
|
{
|
|
1894
2032
|
id,
|
|
@@ -1910,21 +2048,21 @@ function ParameterNumberInput({
|
|
|
1910
2048
|
}
|
|
1911
2049
|
}
|
|
1912
2050
|
),
|
|
1913
|
-
field.unit && /* @__PURE__ */ (0,
|
|
2051
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
1914
2052
|
] });
|
|
1915
2053
|
}
|
|
1916
2054
|
function ParameterSlider(props) {
|
|
1917
2055
|
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
1918
|
-
const dragging = (0,
|
|
2056
|
+
const dragging = (0, import_react22.useRef)(false);
|
|
1919
2057
|
const end = () => {
|
|
1920
2058
|
if (!dragging.current) return;
|
|
1921
2059
|
dragging.current = false;
|
|
1922
2060
|
onGestureEnd?.();
|
|
1923
2061
|
};
|
|
1924
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2062
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterNumberInput, { ...props });
|
|
1925
2063
|
const step = (0, import_parameters.parameterStep)(field);
|
|
1926
|
-
return /* @__PURE__ */ (0,
|
|
1927
|
-
/* @__PURE__ */ (0,
|
|
2064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2065
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1928
2066
|
"input",
|
|
1929
2067
|
{
|
|
1930
2068
|
type: "range",
|
|
@@ -1947,11 +2085,11 @@ function ParameterSlider(props) {
|
|
|
1947
2085
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
1948
2086
|
}
|
|
1949
2087
|
),
|
|
1950
|
-
/* @__PURE__ */ (0,
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
1951
2089
|
] });
|
|
1952
2090
|
}
|
|
1953
2091
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
1954
|
-
return /* @__PURE__ */ (0,
|
|
2092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1955
2093
|
"button",
|
|
1956
2094
|
{
|
|
1957
2095
|
type: "button",
|
|
@@ -1962,7 +2100,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1962
2100
|
disabled: disabled || field.readOnly,
|
|
1963
2101
|
onClick: () => onChange(!value),
|
|
1964
2102
|
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
|
|
1965
|
-
children: /* @__PURE__ */ (0,
|
|
2103
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1966
2104
|
"span",
|
|
1967
2105
|
{
|
|
1968
2106
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -1975,7 +2113,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1975
2113
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
1976
2114
|
const off = disabled || field.readOnly;
|
|
1977
2115
|
if (field.control === "segmented") {
|
|
1978
|
-
return /* @__PURE__ */ (0,
|
|
2116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1979
2117
|
"button",
|
|
1980
2118
|
{
|
|
1981
2119
|
type: "button",
|
|
@@ -1991,7 +2129,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1991
2129
|
)) });
|
|
1992
2130
|
}
|
|
1993
2131
|
const index = options.findIndex((o) => o.value === value);
|
|
1994
|
-
return /* @__PURE__ */ (0,
|
|
2132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1995
2133
|
"select",
|
|
1996
2134
|
{
|
|
1997
2135
|
id,
|
|
@@ -2003,12 +2141,12 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2003
2141
|
if (option) onChange(option.value);
|
|
2004
2142
|
},
|
|
2005
2143
|
className: parameterInputClass,
|
|
2006
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
2144
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2007
2145
|
}
|
|
2008
2146
|
);
|
|
2009
2147
|
}
|
|
2010
2148
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2011
|
-
const picking = (0,
|
|
2149
|
+
const picking = (0, import_react22.useRef)(false);
|
|
2012
2150
|
const alpha = !!field.alpha;
|
|
2013
2151
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2014
2152
|
const rgb = hex.slice(0, 7);
|
|
@@ -2024,11 +2162,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2024
2162
|
picking.current = false;
|
|
2025
2163
|
onGestureEnd?.();
|
|
2026
2164
|
};
|
|
2027
|
-
return /* @__PURE__ */ (0,
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2029
|
-
/* @__PURE__ */ (0,
|
|
2030
|
-
/* @__PURE__ */ (0,
|
|
2031
|
-
/* @__PURE__ */ (0,
|
|
2165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px]", children: [
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
|
|
2169
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2032
2170
|
"input",
|
|
2033
2171
|
{
|
|
2034
2172
|
type: "color",
|
|
@@ -2044,7 +2182,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2044
2182
|
}
|
|
2045
2183
|
)
|
|
2046
2184
|
] }),
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2185
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2048
2186
|
ParameterCommitInput,
|
|
2049
2187
|
{
|
|
2050
2188
|
id,
|
|
@@ -2060,7 +2198,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2060
2198
|
}
|
|
2061
2199
|
)
|
|
2062
2200
|
] }),
|
|
2063
|
-
alpha && /* @__PURE__ */ (0,
|
|
2201
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2064
2202
|
"input",
|
|
2065
2203
|
{
|
|
2066
2204
|
type: "range",
|
|
@@ -2078,10 +2216,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2078
2216
|
onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
|
|
2079
2217
|
}
|
|
2080
2218
|
),
|
|
2081
|
-
field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2219
|
+
field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-1", children: field.swatches.map((s) => {
|
|
2082
2220
|
const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
|
|
2083
2221
|
if (!swatch) return null;
|
|
2084
|
-
return /* @__PURE__ */ (0,
|
|
2222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2085
2223
|
"button",
|
|
2086
2224
|
{
|
|
2087
2225
|
type: "button",
|
|
@@ -2100,11 +2238,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2100
2238
|
}
|
|
2101
2239
|
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
2102
2240
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2103
|
-
return /* @__PURE__ */ (0,
|
|
2241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
2104
2242
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2105
|
-
return /* @__PURE__ */ (0,
|
|
2106
|
-
/* @__PURE__ */ (0,
|
|
2107
|
-
/* @__PURE__ */ (0,
|
|
2243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2244
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2245
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2108
2246
|
ParameterNumberInput,
|
|
2109
2247
|
{
|
|
2110
2248
|
field: component,
|
|
@@ -2121,11 +2259,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2121
2259
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2122
2260
|
const off = disabled || field.readOnly;
|
|
2123
2261
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2124
|
-
return /* @__PURE__ */ (0,
|
|
2125
|
-
/* @__PURE__ */ (0,
|
|
2126
|
-
/* @__PURE__ */ (0,
|
|
2127
|
-
/* @__PURE__ */ (0,
|
|
2128
|
-
/* @__PURE__ */ (0,
|
|
2262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2263
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
2265
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
2266
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2129
2267
|
ParameterCommitInput,
|
|
2130
2268
|
{
|
|
2131
2269
|
id,
|
|
@@ -2136,10 +2274,10 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2136
2274
|
onCommit: (text) => onChange(text.trim())
|
|
2137
2275
|
}
|
|
2138
2276
|
),
|
|
2139
|
-
/* @__PURE__ */ (0,
|
|
2140
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
2277
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex gap-1", children: [
|
|
2278
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
|
|
2141
2279
|
"Choose file\u2026",
|
|
2142
|
-
/* @__PURE__ */ (0,
|
|
2280
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2143
2281
|
"input",
|
|
2144
2282
|
{
|
|
2145
2283
|
type: "file",
|
|
@@ -2155,11 +2293,11 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2155
2293
|
}
|
|
2156
2294
|
)
|
|
2157
2295
|
] }),
|
|
2158
|
-
value && /* @__PURE__ */ (0,
|
|
2296
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
|
|
2159
2297
|
] })
|
|
2160
2298
|
] })
|
|
2161
2299
|
] }),
|
|
2162
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
2300
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2163
2301
|
"button",
|
|
2164
2302
|
{
|
|
2165
2303
|
type: "button",
|
|
@@ -2169,14 +2307,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2169
2307
|
disabled: off,
|
|
2170
2308
|
onClick: () => onChange(o.url),
|
|
2171
2309
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2172
|
-
children: /* @__PURE__ */ (0,
|
|
2310
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2173
2311
|
},
|
|
2174
2312
|
o.url
|
|
2175
2313
|
)) })
|
|
2176
2314
|
] });
|
|
2177
2315
|
}
|
|
2178
2316
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
2179
|
-
return /* @__PURE__ */ (0,
|
|
2317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2180
2318
|
ParameterCommitInput,
|
|
2181
2319
|
{
|
|
2182
2320
|
id,
|
|
@@ -2195,31 +2333,31 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
2195
2333
|
switch (field.type) {
|
|
2196
2334
|
case "number":
|
|
2197
2335
|
case "int":
|
|
2198
|
-
return /* @__PURE__ */ (0,
|
|
2336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
2199
2337
|
case "boolean":
|
|
2200
|
-
return /* @__PURE__ */ (0,
|
|
2338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
2201
2339
|
case "choice":
|
|
2202
|
-
return /* @__PURE__ */ (0,
|
|
2340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
2203
2341
|
case "color":
|
|
2204
|
-
return /* @__PURE__ */ (0,
|
|
2342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
2205
2343
|
case "vector":
|
|
2206
|
-
return /* @__PURE__ */ (0,
|
|
2344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
2207
2345
|
case "image":
|
|
2208
|
-
return /* @__PURE__ */ (0,
|
|
2346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
2209
2347
|
case "text":
|
|
2210
|
-
return /* @__PURE__ */ (0,
|
|
2348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
2211
2349
|
}
|
|
2212
2350
|
}
|
|
2213
2351
|
|
|
2214
2352
|
// src/effects/EffectParameters.tsx
|
|
2215
|
-
var
|
|
2353
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2216
2354
|
function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
|
|
2217
|
-
const fields = (0,
|
|
2218
|
-
const idBase = (0,
|
|
2219
|
-
const gesture =
|
|
2220
|
-
const count =
|
|
2221
|
-
return /* @__PURE__ */ (0,
|
|
2222
|
-
onPreset && description.presets.length > 0 && /* @__PURE__ */ (0,
|
|
2355
|
+
const fields = (0, import_react23.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
|
|
2356
|
+
const idBase = (0, import_react23.useId)();
|
|
2357
|
+
const gesture = import_react23.default.useRef(null);
|
|
2358
|
+
const count = import_react23.default.useRef(0);
|
|
2359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
2360
|
+
onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2223
2361
|
"select",
|
|
2224
2362
|
{
|
|
2225
2363
|
className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
|
|
@@ -2231,8 +2369,8 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
2231
2369
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
2232
2370
|
},
|
|
2233
2371
|
children: [
|
|
2234
|
-
/* @__PURE__ */ (0,
|
|
2235
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
2372
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", children: "Presets\u2026" }),
|
|
2373
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: p.name, children: p.name }, p.name))
|
|
2236
2374
|
]
|
|
2237
2375
|
}
|
|
2238
2376
|
),
|
|
@@ -2242,13 +2380,13 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
2242
2380
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
2243
2381
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
2244
2382
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
2245
|
-
return /* @__PURE__ */ (0,
|
|
2246
|
-
/* @__PURE__ */ (0,
|
|
2247
|
-
/* @__PURE__ */ (0,
|
|
2248
|
-
keyed && /* @__PURE__ */ (0,
|
|
2249
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
2383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
2384
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2385
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
2386
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2387
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
2250
2388
|
] }),
|
|
2251
|
-
/* @__PURE__ */ (0,
|
|
2389
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2252
2390
|
ParameterFieldControl,
|
|
2253
2391
|
{
|
|
2254
2392
|
field,
|
|
@@ -2262,47 +2400,47 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
2262
2400
|
)
|
|
2263
2401
|
] }, field.id);
|
|
2264
2402
|
}),
|
|
2265
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
2403
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
2266
2404
|
] });
|
|
2267
2405
|
}
|
|
2268
2406
|
|
|
2269
2407
|
// src/canvas/CanvasEffects.tsx
|
|
2270
|
-
var
|
|
2271
|
-
var ProviderContext = (0,
|
|
2408
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2409
|
+
var ProviderContext = (0, import_react24.createContext)(null);
|
|
2272
2410
|
function CanvasEffectsProvider({ provider, children }) {
|
|
2273
|
-
return /* @__PURE__ */ (0,
|
|
2411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ProviderContext.Provider, { value: provider ?? null, children });
|
|
2274
2412
|
}
|
|
2275
|
-
var useCanvasEffectsProviderContext = () => (0,
|
|
2413
|
+
var useCanvasEffectsProviderContext = () => (0, import_react24.useContext)(ProviderContext);
|
|
2276
2414
|
function CanvasNodeEffectLayer({ effect, width, height, clipPath, clipTransform }) {
|
|
2277
2415
|
const provider = useCanvasEffectsProviderContext();
|
|
2278
|
-
const ref = (0,
|
|
2279
|
-
const [failed, setFailed] = (0,
|
|
2416
|
+
const ref = (0, import_react24.useRef)(null);
|
|
2417
|
+
const [failed, setFailed] = (0, import_react24.useState)(false);
|
|
2280
2418
|
const dpr = typeof window !== "undefined" ? Math.min(2, window.devicePixelRatio || 1) : 1;
|
|
2281
2419
|
const pw = Math.max(1, Math.round(width * dpr));
|
|
2282
2420
|
const ph = Math.max(1, Math.round(height * dpr));
|
|
2283
2421
|
const key = JSON.stringify(effect);
|
|
2284
|
-
(0,
|
|
2422
|
+
(0, import_react24.useEffect)(() => {
|
|
2285
2423
|
const canvas2 = ref.current;
|
|
2286
2424
|
if (!provider || !canvas2) return;
|
|
2287
2425
|
setFailed(false);
|
|
2288
|
-
const run = (0,
|
|
2426
|
+
const run = (0, import_canvas14.runCanvasNodeEffect)({ provider, effect, target: canvas2, onError: () => setFailed(true) });
|
|
2289
2427
|
return () => run.stop();
|
|
2290
2428
|
}, [provider, key, pw, ph]);
|
|
2291
|
-
const clipId = (0,
|
|
2429
|
+
const clipId = (0, import_react24.useMemo)(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
|
|
2292
2430
|
if (!provider || failed || !(width > 0 && height > 0)) return null;
|
|
2293
2431
|
const style = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", opacity: effect.opacity ?? 1 };
|
|
2294
|
-
const canvas = /* @__PURE__ */ (0,
|
|
2295
|
-
if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0,
|
|
2296
|
-
return /* @__PURE__ */ (0,
|
|
2297
|
-
/* @__PURE__ */ (0,
|
|
2298
|
-
/* @__PURE__ */ (0,
|
|
2432
|
+
const canvas = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("canvas", { ref, width: pw, height: ph, style: { width: "100%", height: "100%", display: "block" }, "data-canvas-effect": effect.effect });
|
|
2433
|
+
if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style, children: canvas });
|
|
2434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { style, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", "aria-hidden": "true", children: [
|
|
2435
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: clipPath, transform: clipTransform }) }) }),
|
|
2436
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("foreignObject", { x: 0, y: 0, width, height, clipPath: `url(#${clipId})`, children: canvas })
|
|
2299
2437
|
] });
|
|
2300
2438
|
}
|
|
2301
2439
|
function useCanvasEffects(options) {
|
|
2302
|
-
const opts = (0,
|
|
2440
|
+
const opts = (0, import_react24.useRef)(options);
|
|
2303
2441
|
opts.current = options;
|
|
2304
|
-
const controller = (0,
|
|
2305
|
-
() => (0,
|
|
2442
|
+
const controller = (0, import_react24.useMemo)(
|
|
2443
|
+
() => (0, import_canvas14.createCanvasEffectsController)({
|
|
2306
2444
|
getNodes: () => opts.current.getNodes(),
|
|
2307
2445
|
setNodes: (n) => opts.current.setNodes(n),
|
|
2308
2446
|
history: { execute: (c) => opts.current.history ? opts.current.history.execute(c) : c.execute() },
|
|
@@ -2312,7 +2450,7 @@ function useCanvasEffects(options) {
|
|
|
2312
2450
|
}),
|
|
2313
2451
|
[]
|
|
2314
2452
|
);
|
|
2315
|
-
(0,
|
|
2453
|
+
(0, import_react24.useEffect)(() => {
|
|
2316
2454
|
if (!options.effects) return;
|
|
2317
2455
|
return controller.useEffects(options.effects);
|
|
2318
2456
|
}, [controller, options.effects]);
|
|
@@ -2320,20 +2458,20 @@ function useCanvasEffects(options) {
|
|
|
2320
2458
|
}
|
|
2321
2459
|
function useCanvasEffectsTools(registry, controller, options = {}) {
|
|
2322
2460
|
const { id, namespace, readOnly, subscribe } = options;
|
|
2323
|
-
(0,
|
|
2461
|
+
(0, import_react24.useEffect)(() => {
|
|
2324
2462
|
if (!registry) return;
|
|
2325
|
-
return registry.register((0,
|
|
2463
|
+
return registry.register((0, import_canvas14.createCanvasEffectsToolProvider)(controller, { id, namespace, readOnly, subscribe }));
|
|
2326
2464
|
}, [registry, controller, id, namespace, readOnly, subscribe]);
|
|
2327
2465
|
}
|
|
2328
2466
|
var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
2329
2467
|
function Controls({ controller, nodeId, effect }) {
|
|
2330
2468
|
const { description, error } = useEffectDescription(controller.effectsProvider, effect.effect);
|
|
2331
|
-
const [message, setMessage] = (0,
|
|
2469
|
+
const [message, setMessage] = (0, import_react24.useState)(null);
|
|
2332
2470
|
const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
2333
|
-
if (error) return /* @__PURE__ */ (0,
|
|
2334
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
2335
|
-
return /* @__PURE__ */ (0,
|
|
2336
|
-
/* @__PURE__ */ (0,
|
|
2471
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
2472
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
2473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2474
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2337
2475
|
EffectParameters,
|
|
2338
2476
|
{
|
|
2339
2477
|
description,
|
|
@@ -2343,75 +2481,75 @@ function Controls({ controller, nodeId, effect }) {
|
|
|
2343
2481
|
onPreset: (v) => run(controller.updateNodeEffect(nodeId, { values: v }))
|
|
2344
2482
|
}
|
|
2345
2483
|
),
|
|
2346
|
-
message && /* @__PURE__ */ (0,
|
|
2484
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2347
2485
|
] });
|
|
2348
2486
|
}
|
|
2349
2487
|
function CanvasEffectsPanel({ controller, nodeId, shape, sceneId, className = "" }) {
|
|
2350
|
-
const [, setTick] = (0,
|
|
2351
|
-
(0,
|
|
2488
|
+
const [, setTick] = (0, import_react24.useState)(0);
|
|
2489
|
+
(0, import_react24.useEffect)(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
2352
2490
|
const provider = controller.effectsProvider;
|
|
2353
|
-
const [browse, setBrowse] = (0,
|
|
2354
|
-
const [message, setMessage] = (0,
|
|
2491
|
+
const [browse, setBrowse] = (0, import_react24.useState)(null);
|
|
2492
|
+
const [message, setMessage] = (0, import_react24.useState)(null);
|
|
2355
2493
|
const run = (work) => {
|
|
2356
2494
|
setMessage(null);
|
|
2357
2495
|
Promise.resolve().then(work).then(() => setTick((n) => n + 1), (e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
2358
2496
|
};
|
|
2359
|
-
const effect = (0,
|
|
2497
|
+
const effect = (0, import_canvas14.isShapeDescription)(shape) ? shape.effect : void 0;
|
|
2360
2498
|
const transition = sceneId ? controller.sceneTransition(sceneId) : void 0;
|
|
2361
|
-
return /* @__PURE__ */ (0,
|
|
2362
|
-
/* @__PURE__ */ (0,
|
|
2363
|
-
/* @__PURE__ */ (0,
|
|
2364
|
-
/* @__PURE__ */ (0,
|
|
2365
|
-
/* @__PURE__ */ (0,
|
|
2366
|
-
/* @__PURE__ */ (0,
|
|
2499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Canvas effects", "data-canvas-effects": "", children: [
|
|
2500
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2501
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
2502
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "fill", onClick: () => setBrowse(browse === "fill" ? null : "fill"), children: "Fill\u2026" }),
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "overlay", onClick: () => setBrowse(browse === "overlay" ? null : "overlay"), children: "Overlay\u2026" }),
|
|
2504
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, disabled: !provider || !sceneId, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Scene transition\u2026" })
|
|
2367
2505
|
] }),
|
|
2368
|
-
!provider && /* @__PURE__ */ (0,
|
|
2369
|
-
browse === "fill" && nodeId && /* @__PURE__ */ (0,
|
|
2370
|
-
browse === "overlay" && nodeId && /* @__PURE__ */ (0,
|
|
2371
|
-
browse === "transition" && sceneId && /* @__PURE__ */ (0,
|
|
2372
|
-
effect && nodeId && /* @__PURE__ */ (0,
|
|
2373
|
-
/* @__PURE__ */ (0,
|
|
2374
|
-
/* @__PURE__ */ (0,
|
|
2506
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects on the canvas are kept." }),
|
|
2507
|
+
browse === "fill" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(EffectsBrowser, { provider, uses: ["generator", "interactive"], title: "Fills", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "fill" }))) }),
|
|
2508
|
+
browse === "overlay" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(EffectsBrowser, { provider, uses: ["overlay", "title", "interactive", "generator"], title: "Overlays", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "overlay" }))) }),
|
|
2509
|
+
browse === "transition" && sceneId && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), run(() => controller.setSceneTransition(sceneId, e.id))) }),
|
|
2510
|
+
effect && nodeId && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-canvas-node-effect": nodeId, children: [
|
|
2511
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2512
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
|
|
2375
2513
|
effect.name ?? effect.effect,
|
|
2376
2514
|
" ",
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
2378
2516
|
"\xB7 ",
|
|
2379
2517
|
effect.mode
|
|
2380
2518
|
] })
|
|
2381
2519
|
] }),
|
|
2382
|
-
/* @__PURE__ */ (0,
|
|
2383
|
-
/* @__PURE__ */ (0,
|
|
2520
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
2521
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: effect.playing !== false, "aria-label": "Play", onChange: (e) => {
|
|
2384
2522
|
const playing = e.currentTarget.checked;
|
|
2385
2523
|
run(() => controller.updateNodeEffect(nodeId, { playing }));
|
|
2386
2524
|
} }),
|
|
2387
2525
|
" Play"
|
|
2388
2526
|
] }),
|
|
2389
|
-
/* @__PURE__ */ (0,
|
|
2527
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, "aria-label": "Remove effect", onClick: () => run(() => controller.removeNodeEffect(nodeId)), children: "\u2715" })
|
|
2390
2528
|
] }),
|
|
2391
|
-
provider && /* @__PURE__ */ (0,
|
|
2529
|
+
provider && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Controls, { controller, nodeId, effect })
|
|
2392
2530
|
] }),
|
|
2393
|
-
sceneId && transition && /* @__PURE__ */ (0,
|
|
2394
|
-
/* @__PURE__ */ (0,
|
|
2531
|
+
sceneId && transition && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1", "data-canvas-scene-transition": sceneId, children: [
|
|
2532
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
2395
2533
|
"Into scene: ",
|
|
2396
2534
|
transition.name ?? transition.effect,
|
|
2397
2535
|
" (",
|
|
2398
2536
|
transition.duration ?? 600,
|
|
2399
2537
|
" ms)"
|
|
2400
2538
|
] }),
|
|
2401
|
-
/* @__PURE__ */ (0,
|
|
2539
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, "aria-label": "Remove transition", onClick: () => run(() => controller.setSceneTransition(sceneId, null)), children: "\u2715" })
|
|
2402
2540
|
] }),
|
|
2403
|
-
message && /* @__PURE__ */ (0,
|
|
2541
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2404
2542
|
] });
|
|
2405
2543
|
}
|
|
2406
2544
|
|
|
2407
2545
|
// src/canvas/ShapeNode.tsx
|
|
2408
|
-
var
|
|
2546
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2409
2547
|
function ShapeNode({ id, data, width, height, selected, className = "", children, positionAbsoluteX, positionAbsoluteY }) {
|
|
2410
2548
|
const shape = data?.shape;
|
|
2411
|
-
const brushImage = useShapeBrushstroke((0,
|
|
2412
|
-
if (!(0,
|
|
2413
|
-
const render = (0,
|
|
2414
|
-
return /* @__PURE__ */ (0,
|
|
2549
|
+
const brushImage = useShapeBrushstroke((0, import_canvas15.isShapeDescription)(shape) ? shape : null, width, height, { x: positionAbsoluteX ?? 0, y: positionAbsoluteY ?? 0 });
|
|
2550
|
+
if (!(0, import_canvas15.isShapeDescription)(shape)) return null;
|
|
2551
|
+
const render = (0, import_canvas15.getShapeRenderData)(shape, { width, height }, { id: id || data?.id });
|
|
2552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2415
2553
|
"div",
|
|
2416
2554
|
{
|
|
2417
2555
|
className: `pixerate-shape-node ${className}`.trim(),
|
|
@@ -2419,7 +2557,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2419
2557
|
"data-selected": selected ? "true" : void 0,
|
|
2420
2558
|
style: { position: "relative", width: "100%", height: "100%" },
|
|
2421
2559
|
children: [
|
|
2422
|
-
/* @__PURE__ */ (0,
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2423
2561
|
"svg",
|
|
2424
2562
|
{
|
|
2425
2563
|
viewBox: render.viewBox,
|
|
@@ -2429,13 +2567,13 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2429
2567
|
style: { display: "block", overflow: "visible" },
|
|
2430
2568
|
"aria-hidden": "true",
|
|
2431
2569
|
children: [
|
|
2432
|
-
(render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0,
|
|
2433
|
-
render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0,
|
|
2434
|
-
render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0,
|
|
2435
|
-
render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0,
|
|
2436
|
-
render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0,
|
|
2570
|
+
(render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("defs", { children: [
|
|
2571
|
+
render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("linearGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
2572
|
+
render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("radialGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
2573
|
+
render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("linearGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
2574
|
+
render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("radialGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
|
|
2437
2575
|
] }),
|
|
2438
|
-
brushImage ? /* @__PURE__ */ (0,
|
|
2576
|
+
brushImage ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { transform: render.transform, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2439
2577
|
"image",
|
|
2440
2578
|
{
|
|
2441
2579
|
className: "pixerate-shape-brushstroke",
|
|
@@ -2447,7 +2585,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2447
2585
|
preserveAspectRatio: "none",
|
|
2448
2586
|
opacity: render.opacity
|
|
2449
2587
|
}
|
|
2450
|
-
) }) : /* @__PURE__ */ (0,
|
|
2588
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2451
2589
|
"path",
|
|
2452
2590
|
{
|
|
2453
2591
|
d: render.d,
|
|
@@ -2465,7 +2603,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2465
2603
|
]
|
|
2466
2604
|
}
|
|
2467
2605
|
),
|
|
2468
|
-
shape.effect && width && height ? /* @__PURE__ */ (0,
|
|
2606
|
+
shape.effect && width && height ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CanvasNodeEffectLayer, { effect: shape.effect, width, height, clipPath: render.d, clipTransform: render.transform }) : null,
|
|
2469
2607
|
children
|
|
2470
2608
|
]
|
|
2471
2609
|
}
|
|
@@ -2473,22 +2611,22 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2473
2611
|
}
|
|
2474
2612
|
|
|
2475
2613
|
// src/canvas/index.ts
|
|
2476
|
-
var import_canvas28 = require("@pixerate/editor/canvas");
|
|
2477
2614
|
var import_canvas29 = require("@pixerate/editor/canvas");
|
|
2478
2615
|
var import_canvas30 = require("@pixerate/editor/canvas");
|
|
2479
2616
|
var import_canvas31 = require("@pixerate/editor/canvas");
|
|
2617
|
+
var import_canvas32 = require("@pixerate/editor/canvas");
|
|
2480
2618
|
|
|
2481
2619
|
// src/canvas/useCanvasAutoLayout.ts
|
|
2482
|
-
var
|
|
2483
|
-
var
|
|
2620
|
+
var import_react25 = require("react");
|
|
2621
|
+
var import_canvas16 = require("@pixerate/editor/canvas");
|
|
2484
2622
|
function useCanvasAutoLayout(options) {
|
|
2485
|
-
const [guides, setGuides] = (0,
|
|
2486
|
-
const nodesRef = (0,
|
|
2623
|
+
const [guides, setGuides] = (0, import_react25.useState)([]);
|
|
2624
|
+
const nodesRef = (0, import_react25.useRef)(options.nodes);
|
|
2487
2625
|
nodesRef.current = options.nodes;
|
|
2488
|
-
const optionsRef = (0,
|
|
2626
|
+
const optionsRef = (0, import_react25.useRef)(options);
|
|
2489
2627
|
optionsRef.current = options;
|
|
2490
|
-
const controller = (0,
|
|
2491
|
-
() => (0,
|
|
2628
|
+
const controller = (0, import_react25.useMemo)(
|
|
2629
|
+
() => (0, import_canvas16.createCanvasAutoLayoutController)({
|
|
2492
2630
|
getNodes: () => nodesRef.current,
|
|
2493
2631
|
setNodes: (next) => {
|
|
2494
2632
|
nodesRef.current = next;
|
|
@@ -2513,10 +2651,10 @@ function useCanvasAutoLayout(options) {
|
|
|
2513
2651
|
}),
|
|
2514
2652
|
[]
|
|
2515
2653
|
);
|
|
2516
|
-
(0,
|
|
2654
|
+
(0, import_react25.useLayoutEffect)(() => {
|
|
2517
2655
|
if (controller.hasPending) controller.flush();
|
|
2518
2656
|
}, [options.nodes, controller]);
|
|
2519
|
-
return (0,
|
|
2657
|
+
return (0, import_react25.useMemo)(
|
|
2520
2658
|
() => ({
|
|
2521
2659
|
...controller,
|
|
2522
2660
|
/** Drop marker of the active reorder drag (flow coordinates). */
|
|
@@ -2530,47 +2668,47 @@ function useCanvasAutoLayout(options) {
|
|
|
2530
2668
|
}
|
|
2531
2669
|
|
|
2532
2670
|
// src/canvas/useCanvasTokens.ts
|
|
2533
|
-
var
|
|
2534
|
-
var
|
|
2671
|
+
var import_react26 = require("react");
|
|
2672
|
+
var import_canvas17 = require("@pixerate/editor/canvas");
|
|
2535
2673
|
function useCanvasTokens(options) {
|
|
2536
2674
|
const { store, nodes, setNodes, modes, properties } = options;
|
|
2537
|
-
const state = (0,
|
|
2538
|
-
const latest = (0,
|
|
2675
|
+
const state = (0, import_react26.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
2676
|
+
const latest = (0, import_react26.useRef)({ nodes, setNodes, modes, properties });
|
|
2539
2677
|
latest.current = { nodes, setNodes, modes, properties };
|
|
2540
2678
|
const opts = () => ({ modes: latest.current.modes, properties: latest.current.properties });
|
|
2541
|
-
(0,
|
|
2679
|
+
(0, import_react26.useEffect)(
|
|
2542
2680
|
() => store.subscribe((event) => {
|
|
2543
2681
|
if (event.deletedVariableIds.length === 0) return;
|
|
2544
|
-
latest.current.setNodes((prev) => (0,
|
|
2682
|
+
latest.current.setNodes((prev) => (0, import_canvas17.detachTokenBindings)(prev, event.previous, event.deletedVariableIds, opts()));
|
|
2545
2683
|
}),
|
|
2546
2684
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2547
2685
|
[store]
|
|
2548
2686
|
);
|
|
2549
2687
|
const modesKey = JSON.stringify(modes ?? {});
|
|
2550
|
-
(0,
|
|
2551
|
-
const next = (0,
|
|
2688
|
+
(0, import_react26.useEffect)(() => {
|
|
2689
|
+
const next = (0, import_canvas17.resolveCanvasTokens)(nodes, state, opts());
|
|
2552
2690
|
if (next !== nodes) setNodes(next);
|
|
2553
2691
|
}, [nodes, state, modesKey, properties]);
|
|
2554
|
-
const bind = (0,
|
|
2692
|
+
const bind = (0, import_react26.useCallback)(
|
|
2555
2693
|
(ids, propertyKey, variableId) => {
|
|
2556
|
-
const next = (0,
|
|
2694
|
+
const next = (0, import_canvas17.bindCanvasToken)(latest.current.nodes, ids, propertyKey, variableId, store.getState(), opts());
|
|
2557
2695
|
if (next !== latest.current.nodes) latest.current.setNodes(next);
|
|
2558
2696
|
},
|
|
2559
2697
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2560
2698
|
[store]
|
|
2561
2699
|
);
|
|
2562
|
-
const setMode = (0,
|
|
2700
|
+
const setMode = (0, import_react26.useCallback)(
|
|
2563
2701
|
(ids, collectionId, modeId) => {
|
|
2564
|
-
const next = (0,
|
|
2702
|
+
const next = (0, import_canvas17.setCanvasTokenMode)(latest.current.nodes, ids, collectionId, modeId, store.getState(), opts());
|
|
2565
2703
|
if (next !== latest.current.nodes) latest.current.setNodes(next);
|
|
2566
2704
|
},
|
|
2567
2705
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2568
2706
|
[store]
|
|
2569
2707
|
);
|
|
2570
|
-
const modesOf = (0,
|
|
2708
|
+
const modesOf = (0, import_react26.useCallback)(
|
|
2571
2709
|
(nodeId) => {
|
|
2572
2710
|
const node = latest.current.nodes.find((n) => n.id === nodeId);
|
|
2573
|
-
return node ? (0,
|
|
2711
|
+
return node ? (0, import_canvas17.getEffectiveTokenModes)(node, latest.current.nodes, store.getState(), opts()) : {};
|
|
2574
2712
|
},
|
|
2575
2713
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2576
2714
|
[store]
|
|
@@ -2579,9 +2717,9 @@ function useCanvasTokens(options) {
|
|
|
2579
2717
|
}
|
|
2580
2718
|
|
|
2581
2719
|
// src/canvas/TokenBindingPicker.tsx
|
|
2582
|
-
var
|
|
2720
|
+
var import_canvas18 = require("@pixerate/editor/canvas");
|
|
2583
2721
|
var import_tokens = require("@pixerate/editor/tokens");
|
|
2584
|
-
var
|
|
2722
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2585
2723
|
function TokenBindingPicker({
|
|
2586
2724
|
state,
|
|
2587
2725
|
nodes,
|
|
@@ -2595,18 +2733,18 @@ function TokenBindingPicker({
|
|
|
2595
2733
|
const selected = nodes.filter((n) => selectedIds.includes(n.id));
|
|
2596
2734
|
const first = selected[0];
|
|
2597
2735
|
if (!first) return null;
|
|
2598
|
-
let rows = (0,
|
|
2736
|
+
let rows = (0, import_canvas18.getBindableTokenProperties)(first, options);
|
|
2599
2737
|
if (properties) rows = properties.map((key) => rows.find((p) => p.key === key)).filter((p) => !!p);
|
|
2600
|
-
const modes = (0,
|
|
2601
|
-
return /* @__PURE__ */ (0,
|
|
2738
|
+
const modes = (0, import_canvas18.getEffectiveTokenModes)(first, nodes, state, options);
|
|
2739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { "data-token-binding-picker": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
|
|
2602
2740
|
rows.map((property) => {
|
|
2603
|
-
const ids = new Set(selected.map((n) => (0,
|
|
2741
|
+
const ids = new Set(selected.map((n) => (0, import_canvas18.getNodeTokenBindings)(n)[property.key] ?? ""));
|
|
2604
2742
|
const value = ids.size === 1 ? [...ids][0] : "__mixed";
|
|
2605
|
-
const candidates = (0,
|
|
2743
|
+
const candidates = (0, import_canvas18.getTokensForProperty)(state, property, first);
|
|
2606
2744
|
const resolved = value && value !== "__mixed" ? (0, import_tokens.resolveToken)(state, value, modes) : null;
|
|
2607
|
-
return /* @__PURE__ */ (0,
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
/* @__PURE__ */ (0,
|
|
2745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-2", "data-token-property": property.key, children: [
|
|
2746
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-28 shrink-0 text-muted-foreground", children: property.label }),
|
|
2747
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2610
2748
|
"select",
|
|
2611
2749
|
{
|
|
2612
2750
|
"aria-label": `${property.label} variable`,
|
|
@@ -2615,17 +2753,17 @@ function TokenBindingPicker({
|
|
|
2615
2753
|
onChange: (e) => {
|
|
2616
2754
|
const id = e.currentTarget.value || null;
|
|
2617
2755
|
try {
|
|
2618
|
-
onChange((0,
|
|
2756
|
+
onChange((0, import_canvas18.bindCanvasToken)(nodes, selectedIds, property.key, id, state, options));
|
|
2619
2757
|
} catch (error) {
|
|
2620
2758
|
onError?.(error);
|
|
2621
2759
|
}
|
|
2622
2760
|
},
|
|
2623
2761
|
children: [
|
|
2624
|
-
value === "__mixed" ? /* @__PURE__ */ (0,
|
|
2625
|
-
/* @__PURE__ */ (0,
|
|
2762
|
+
value === "__mixed" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "__mixed", children: "Mixed" }) : null,
|
|
2763
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "None" }),
|
|
2626
2764
|
candidates.map((v) => {
|
|
2627
2765
|
const collection = state.collections.find((c) => c.id === v.collectionId);
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("option", { value: v.id, children: [
|
|
2629
2767
|
v.name,
|
|
2630
2768
|
collection && state.collections.length > 1 ? ` (${collection.name})` : ""
|
|
2631
2769
|
] }, v.id);
|
|
@@ -2633,17 +2771,17 @@ function TokenBindingPicker({
|
|
|
2633
2771
|
]
|
|
2634
2772
|
}
|
|
2635
2773
|
),
|
|
2636
|
-
/* @__PURE__ */ (0,
|
|
2774
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-16 shrink-0 truncate text-right text-muted-foreground", "data-token-resolved": "", children: resolved?.ok ? property.type === "color" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2637
2775
|
"span",
|
|
2638
2776
|
{
|
|
2639
2777
|
className: "inline-block h-3 w-3 rounded border border-border align-middle",
|
|
2640
2778
|
style: { background: String(resolved.value) },
|
|
2641
2779
|
title: String(resolved.value)
|
|
2642
2780
|
}
|
|
2643
|
-
) : String(resolved.value) : resolved ? /* @__PURE__ */ (0,
|
|
2781
|
+
) : String(resolved.value) : resolved ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { title: resolved.message, children: "\u26A0" }) : null })
|
|
2644
2782
|
] }, property.key);
|
|
2645
2783
|
}),
|
|
2646
|
-
state.collections.length === 0 ? /* @__PURE__ */ (0,
|
|
2784
|
+
state.collections.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-muted-foreground", children: "No variables yet." }) : null
|
|
2647
2785
|
] });
|
|
2648
2786
|
}
|
|
2649
2787
|
function TokenModeSwitcher({
|
|
@@ -2657,29 +2795,29 @@ function TokenModeSwitcher({
|
|
|
2657
2795
|
}) {
|
|
2658
2796
|
const first = nodes.find((n) => nodeIds.includes(n.id));
|
|
2659
2797
|
if (!first) return null;
|
|
2660
|
-
const own = (0,
|
|
2798
|
+
const own = (0, import_canvas18.getNodeTokenModes)(first);
|
|
2661
2799
|
const parent = first.parentId ? nodes.find((n) => n.id === first.parentId) : void 0;
|
|
2662
|
-
const inherited = parent ? (0,
|
|
2800
|
+
const inherited = parent ? (0, import_canvas18.getEffectiveTokenModes)(parent, nodes, state, options) : { ...options.modes };
|
|
2663
2801
|
const collections = state.collections.filter((c) => showSingleMode || c.modes.length > 1);
|
|
2664
|
-
return /* @__PURE__ */ (0,
|
|
2802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { "data-token-mode-switcher": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: collections.map((collection) => {
|
|
2665
2803
|
const auto = (0, import_tokens.getCurrentMode)(collection, inherited);
|
|
2666
2804
|
const explicit = collection.modes.some((m) => m.id === own[collection.id]) ? own[collection.id] : "";
|
|
2667
|
-
return /* @__PURE__ */ (0,
|
|
2668
|
-
/* @__PURE__ */ (0,
|
|
2669
|
-
/* @__PURE__ */ (0,
|
|
2805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-2", "data-token-collection": collection.id, children: [
|
|
2806
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-28 shrink-0 truncate text-muted-foreground", children: collection.name }),
|
|
2807
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2670
2808
|
"select",
|
|
2671
2809
|
{
|
|
2672
2810
|
"aria-label": `${collection.name} mode`,
|
|
2673
2811
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
2674
2812
|
value: explicit,
|
|
2675
|
-
onChange: (e) => onChange((0,
|
|
2813
|
+
onChange: (e) => onChange((0, import_canvas18.setCanvasTokenMode)(nodes, nodeIds, collection.id, e.currentTarget.value || null, state, options)),
|
|
2676
2814
|
children: [
|
|
2677
|
-
/* @__PURE__ */ (0,
|
|
2815
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("option", { value: "", children: [
|
|
2678
2816
|
"Auto (",
|
|
2679
2817
|
auto.name,
|
|
2680
2818
|
")"
|
|
2681
2819
|
] }),
|
|
2682
|
-
collection.modes.map((m) => /* @__PURE__ */ (0,
|
|
2820
|
+
collection.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: m.id, children: m.name }, m.id))
|
|
2683
2821
|
]
|
|
2684
2822
|
}
|
|
2685
2823
|
)
|
|
@@ -2688,18 +2826,18 @@ function TokenModeSwitcher({
|
|
|
2688
2826
|
}
|
|
2689
2827
|
|
|
2690
2828
|
// src/canvas/index.ts
|
|
2691
|
-
var
|
|
2829
|
+
var import_canvas33 = require("@pixerate/editor/canvas");
|
|
2692
2830
|
|
|
2693
2831
|
// src/canvas/useCanvasAnimation.ts
|
|
2694
|
-
var
|
|
2695
|
-
var
|
|
2832
|
+
var import_react27 = require("react");
|
|
2833
|
+
var import_canvas19 = require("@pixerate/editor/canvas");
|
|
2696
2834
|
function useCanvasAnimation(options) {
|
|
2697
|
-
const nodesRef = (0,
|
|
2835
|
+
const nodesRef = (0, import_react27.useRef)(options.nodes);
|
|
2698
2836
|
nodesRef.current = options.nodes;
|
|
2699
|
-
const optionsRef = (0,
|
|
2837
|
+
const optionsRef = (0, import_react27.useRef)(options);
|
|
2700
2838
|
optionsRef.current = options;
|
|
2701
|
-
const controller = (0,
|
|
2702
|
-
() => (0,
|
|
2839
|
+
const controller = (0, import_react27.useMemo)(
|
|
2840
|
+
() => (0, import_canvas19.createCanvasAnimationController)({
|
|
2703
2841
|
getNodes: () => nodesRef.current,
|
|
2704
2842
|
setNodes: (next) => {
|
|
2705
2843
|
nodesRef.current = next;
|
|
@@ -2725,26 +2863,26 @@ function useCanvasAnimation(options) {
|
|
|
2725
2863
|
}),
|
|
2726
2864
|
[]
|
|
2727
2865
|
);
|
|
2728
|
-
(0,
|
|
2729
|
-
(0,
|
|
2866
|
+
(0, import_react27.useEffect)(() => () => controller.destroy(), [controller]);
|
|
2867
|
+
(0, import_react27.useEffect)(() => {
|
|
2730
2868
|
if (options.loop !== void 0) controller.setLoop(options.loop);
|
|
2731
2869
|
}, [controller, options.loop]);
|
|
2732
|
-
(0,
|
|
2870
|
+
(0, import_react27.useEffect)(() => {
|
|
2733
2871
|
if (options.playbackRate !== void 0) controller.setPlaybackRate(options.playbackRate);
|
|
2734
2872
|
}, [controller, options.playbackRate]);
|
|
2735
|
-
(0,
|
|
2873
|
+
(0, import_react27.useEffect)(() => {
|
|
2736
2874
|
if (options.recording !== void 0) controller.setRecording(options.recording);
|
|
2737
2875
|
}, [controller, options.recording]);
|
|
2738
|
-
const state = (0,
|
|
2876
|
+
const state = (0, import_react27.useSyncExternalStore)(
|
|
2739
2877
|
(listener) => controller.subscribe(listener),
|
|
2740
2878
|
() => controller.getState(),
|
|
2741
2879
|
() => controller.getState()
|
|
2742
2880
|
);
|
|
2743
|
-
(0,
|
|
2881
|
+
(0, import_react27.useEffect)(() => {
|
|
2744
2882
|
controller.refresh();
|
|
2745
2883
|
}, [controller, options.nodes]);
|
|
2746
|
-
const displayNodes = (0,
|
|
2747
|
-
return (0,
|
|
2884
|
+
const displayNodes = (0, import_react27.useMemo)(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
|
|
2885
|
+
return (0, import_react27.useMemo)(
|
|
2748
2886
|
() => ({
|
|
2749
2887
|
...controller,
|
|
2750
2888
|
state,
|
|
@@ -2765,24 +2903,24 @@ function useCanvasAnimation(options) {
|
|
|
2765
2903
|
}
|
|
2766
2904
|
|
|
2767
2905
|
// src/canvas/AnimationTimeline.tsx
|
|
2768
|
-
var
|
|
2769
|
-
var
|
|
2770
|
-
var
|
|
2906
|
+
var import_react28 = require("react");
|
|
2907
|
+
var import_canvas20 = require("@pixerate/editor/canvas");
|
|
2908
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2771
2909
|
var LOOP_LABELS = { none: "Once", loop: "Loop", "ping-pong": "Ping-pong" };
|
|
2772
2910
|
var easingValue = (easing) => typeof easing === "string" ? easing : easing ? "custom" : "linear";
|
|
2773
2911
|
function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8, labelOf, className = "" }) {
|
|
2774
2912
|
const { state } = animation;
|
|
2775
2913
|
const duration = state.duration;
|
|
2776
2914
|
const rows = animation.timelineRows(nodeIds ?? void 0, labelOf ? { labelOf } : {});
|
|
2777
|
-
const ticks = (0,
|
|
2915
|
+
const ticks = (0, import_canvas20.getTimelineTicks)(duration, width);
|
|
2778
2916
|
const selectedEasing = (() => {
|
|
2779
2917
|
const first = state.selection[0];
|
|
2780
2918
|
if (!first) return "";
|
|
2781
2919
|
for (const row of rows) for (const k of row.keyframes) if (k.selected && k.ref.property === first.property && k.ref.nodeId === first.nodeId) return easingValue(k.easing);
|
|
2782
2920
|
return "";
|
|
2783
2921
|
})();
|
|
2784
|
-
const dragRef = (0,
|
|
2785
|
-
(0,
|
|
2922
|
+
const dragRef = (0, import_react28.useRef)(null);
|
|
2923
|
+
(0, import_react28.useEffect)(() => {
|
|
2786
2924
|
const onKey = (event) => {
|
|
2787
2925
|
if (event.key === "Escape" && dragRef.current) {
|
|
2788
2926
|
dragRef.current = null;
|
|
@@ -2795,8 +2933,8 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2795
2933
|
const onRulerDown = (event) => {
|
|
2796
2934
|
const lane = event.currentTarget;
|
|
2797
2935
|
const left = lane.getBoundingClientRect().left;
|
|
2798
|
-
animation.scrub((0,
|
|
2799
|
-
const move = (e) => animation.scrub((0,
|
|
2936
|
+
animation.scrub((0, import_canvas20.xToTime)(event.clientX - left, duration, width));
|
|
2937
|
+
const move = (e) => animation.scrub((0, import_canvas20.xToTime)(e.clientX - left, duration, width));
|
|
2800
2938
|
const up = () => {
|
|
2801
2939
|
window.removeEventListener("pointermove", move);
|
|
2802
2940
|
window.removeEventListener("pointerup", up);
|
|
@@ -2836,12 +2974,12 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2836
2974
|
}
|
|
2837
2975
|
};
|
|
2838
2976
|
const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-50";
|
|
2839
|
-
const playheadX = (0,
|
|
2977
|
+
const playheadX = (0, import_canvas20.timeToX)(state.time, duration, width);
|
|
2840
2978
|
const labelWidth = 120;
|
|
2841
|
-
return /* @__PURE__ */ (0,
|
|
2842
|
-
/* @__PURE__ */ (0,
|
|
2843
|
-
/* @__PURE__ */ (0,
|
|
2844
|
-
/* @__PURE__ */ (0,
|
|
2979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { "data-animation-timeline": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, tabIndex: 0, onKeyDown: onTimelineKey, children: [
|
|
2980
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "toolbar", "aria-label": "Animation", children: [
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn2, "data-action": "toggle-play", "aria-label": state.playing ? "Pause" : "Play", onClick: () => animation.toggle(), children: state.playing ? "\u275A\u275A" : "\u25B6" }),
|
|
2982
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2845
2983
|
"button",
|
|
2846
2984
|
{
|
|
2847
2985
|
type: "button",
|
|
@@ -2853,13 +2991,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2853
2991
|
children: "\u25CF Rec"
|
|
2854
2992
|
}
|
|
2855
2993
|
),
|
|
2856
|
-
/* @__PURE__ */ (0,
|
|
2857
|
-
/* @__PURE__ */ (0,
|
|
2858
|
-
(0,
|
|
2994
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn2, "data-action": "add-keyframe", onClick: () => animation.addKeyframe(), children: "\u25C6 Key" }),
|
|
2995
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { "data-time": "", className: "tabular-nums text-muted-foreground", children: [
|
|
2996
|
+
(0, import_canvas20.formatAnimationTime)(state.time),
|
|
2859
2997
|
" / ",
|
|
2860
|
-
(0,
|
|
2998
|
+
(0, import_canvas20.formatAnimationTime)(duration)
|
|
2861
2999
|
] }),
|
|
2862
|
-
/* @__PURE__ */ (0,
|
|
3000
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2863
3001
|
"select",
|
|
2864
3002
|
{
|
|
2865
3003
|
"aria-label": "Easing",
|
|
@@ -2869,13 +3007,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2869
3007
|
disabled: state.selection.length === 0,
|
|
2870
3008
|
onChange: (e) => e.target.value && e.target.value !== "custom" && animation.setEasing(e.target.value),
|
|
2871
3009
|
children: [
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
2873
|
-
|
|
2874
|
-
selectedEasing === "custom" ? /* @__PURE__ */ (0,
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "Easing\u2026" }),
|
|
3011
|
+
import_canvas20.ANIMATION_EASING_PRESETS.map((preset) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: preset, children: import_canvas20.ANIMATION_EASING_LABELS[preset] }, preset)),
|
|
3012
|
+
selectedEasing === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "custom", children: "Custom" }) : null
|
|
2875
3013
|
]
|
|
2876
3014
|
}
|
|
2877
3015
|
),
|
|
2878
|
-
/* @__PURE__ */ (0,
|
|
3016
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2879
3017
|
"select",
|
|
2880
3018
|
{
|
|
2881
3019
|
"aria-label": "Loop",
|
|
@@ -2883,13 +3021,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2883
3021
|
className: "rounded border border-border bg-background px-1 py-0.5",
|
|
2884
3022
|
value: state.loop,
|
|
2885
3023
|
onChange: (e) => animation.setLoop(e.target.value),
|
|
2886
|
-
children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0,
|
|
3024
|
+
children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: mode, children: LOOP_LABELS[mode] }, mode))
|
|
2887
3025
|
}
|
|
2888
3026
|
)
|
|
2889
3027
|
] }),
|
|
2890
|
-
/* @__PURE__ */ (0,
|
|
2891
|
-
/* @__PURE__ */ (0,
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
3028
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex", children: [
|
|
3029
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { width: labelWidth }, className: "shrink-0" }),
|
|
3030
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2893
3031
|
"div",
|
|
2894
3032
|
{
|
|
2895
3033
|
"data-timeline-ruler": "",
|
|
@@ -2897,15 +3035,15 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2897
3035
|
style: { width },
|
|
2898
3036
|
onPointerDown: onRulerDown,
|
|
2899
3037
|
children: [
|
|
2900
|
-
ticks.map((tick) => /* @__PURE__ */ (0,
|
|
2901
|
-
/* @__PURE__ */ (0,
|
|
3038
|
+
ticks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "absolute top-0 -translate-x-1/2 text-[10px] text-muted-foreground", style: { left: tick.x }, children: tick.label }, tick.time)),
|
|
3039
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { "data-playhead": "", className: "absolute top-0 h-5 w-px bg-red-500", style: { left: playheadX } })
|
|
2902
3040
|
]
|
|
2903
3041
|
}
|
|
2904
3042
|
)
|
|
2905
3043
|
] }),
|
|
2906
|
-
rows.length === 0 ? /* @__PURE__ */ (0,
|
|
2907
|
-
/* @__PURE__ */ (0,
|
|
2908
|
-
/* @__PURE__ */ (0,
|
|
3044
|
+
rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-muted-foreground", "data-timeline-empty": "", children: "Select an animated node, or press \u25C6 Key to add a keyframe." }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center", "data-track": row.id, children: [
|
|
3045
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex shrink-0 items-center gap-1 truncate pr-2", style: { width: labelWidth }, title: `${row.nodeLabel} \xB7 ${row.label}`, children: [
|
|
3046
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2909
3047
|
"input",
|
|
2910
3048
|
{
|
|
2911
3049
|
type: "checkbox",
|
|
@@ -2914,24 +3052,24 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2914
3052
|
onChange: (e) => animation.setTrackEnabled(row.nodeId, row.property, e.target.checked)
|
|
2915
3053
|
}
|
|
2916
3054
|
),
|
|
2917
|
-
/* @__PURE__ */ (0,
|
|
3055
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "truncate", children: [
|
|
2918
3056
|
rows.filter((r) => r.nodeId === row.nodeId).length < rows.length ? `${row.nodeLabel} \xB7 ` : "",
|
|
2919
3057
|
row.label
|
|
2920
3058
|
] })
|
|
2921
3059
|
] }),
|
|
2922
|
-
/* @__PURE__ */ (0,
|
|
2923
|
-
/* @__PURE__ */ (0,
|
|
2924
|
-
state.drag?.target != null ? /* @__PURE__ */ (0,
|
|
2925
|
-
row.keyframes.map((k) => /* @__PURE__ */ (0,
|
|
3060
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { "data-lane": "", className: `relative h-5 rounded bg-muted/40 ${row.enabled ? "" : "opacity-50"}`, style: { width }, children: [
|
|
3061
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "pointer-events-none absolute top-0 h-5 w-px bg-red-500/60", style: { left: playheadX } }),
|
|
3062
|
+
state.drag?.target != null ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { "data-snap-target": "", className: "pointer-events-none absolute top-0 h-5 w-px bg-sky-400", style: { left: (0, import_canvas20.timeToX)(state.drag.target, duration, width) } }) : null,
|
|
3063
|
+
row.keyframes.map((k) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2926
3064
|
"button",
|
|
2927
3065
|
{
|
|
2928
3066
|
type: "button",
|
|
2929
3067
|
"data-keyframe": k.ref.time,
|
|
2930
3068
|
"aria-pressed": k.selected,
|
|
2931
|
-
"aria-label": `${row.label} keyframe at ${(0,
|
|
2932
|
-
title: `${(0,
|
|
3069
|
+
"aria-label": `${row.label} keyframe at ${(0, import_canvas20.formatAnimationTime)(k.ref.time)}`,
|
|
3070
|
+
title: `${(0, import_canvas20.formatAnimationTime)(k.time)} \xB7 ${String(k.value)}`,
|
|
2933
3071
|
className: `absolute top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rotate-45 border ${k.selected ? "border-sky-300 bg-sky-500" : "border-foreground/60 bg-background"} ${k.easing === "hold" ? "rounded-none" : "rounded-[1px]"}`,
|
|
2934
|
-
style: { left: (0,
|
|
3072
|
+
style: { left: (0, import_canvas20.timeToX)(k.time, duration, width) },
|
|
2935
3073
|
onPointerDown: onKeyDown(k.ref)
|
|
2936
3074
|
},
|
|
2937
3075
|
k.ref.time
|
|
@@ -2942,18 +3080,18 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2942
3080
|
}
|
|
2943
3081
|
|
|
2944
3082
|
// src/canvas/index.ts
|
|
2945
|
-
var
|
|
3083
|
+
var import_canvas34 = require("@pixerate/editor/canvas");
|
|
2946
3084
|
|
|
2947
3085
|
// src/canvas/useCanvasComponents.ts
|
|
2948
|
-
var
|
|
2949
|
-
var
|
|
3086
|
+
var import_react29 = require("react");
|
|
3087
|
+
var import_canvas21 = require("@pixerate/editor/canvas");
|
|
2950
3088
|
function useCanvasComponents(options) {
|
|
2951
|
-
const nodesRef = (0,
|
|
3089
|
+
const nodesRef = (0, import_react29.useRef)(options.nodes);
|
|
2952
3090
|
nodesRef.current = options.nodes;
|
|
2953
|
-
const optionsRef = (0,
|
|
3091
|
+
const optionsRef = (0, import_react29.useRef)(options);
|
|
2954
3092
|
optionsRef.current = options;
|
|
2955
|
-
const controller = (0,
|
|
2956
|
-
() => (0,
|
|
3093
|
+
const controller = (0, import_react29.useMemo)(
|
|
3094
|
+
() => (0, import_canvas21.createCanvasComponentsController)({
|
|
2957
3095
|
getNodes: () => nodesRef.current,
|
|
2958
3096
|
setNodes: (next) => {
|
|
2959
3097
|
nodesRef.current = next;
|
|
@@ -2981,18 +3119,18 @@ function useCanvasComponents(options) {
|
|
|
2981
3119
|
}),
|
|
2982
3120
|
[]
|
|
2983
3121
|
);
|
|
2984
|
-
(0,
|
|
3122
|
+
(0, import_react29.useLayoutEffect)(() => {
|
|
2985
3123
|
if (optionsRef.current.autoSync !== false) controller.sync();
|
|
2986
3124
|
}, [options.nodes, controller]);
|
|
2987
3125
|
return controller;
|
|
2988
3126
|
}
|
|
2989
3127
|
|
|
2990
3128
|
// src/canvas/CanvasComponentsPanel.tsx
|
|
2991
|
-
var
|
|
2992
|
-
var
|
|
2993
|
-
var
|
|
3129
|
+
var import_react30 = require("react");
|
|
3130
|
+
var import_canvas22 = require("@pixerate/editor/canvas");
|
|
3131
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2994
3132
|
function InlineField({ value, label, onCommit }) {
|
|
2995
|
-
return /* @__PURE__ */ (0,
|
|
3133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2996
3134
|
"input",
|
|
2997
3135
|
{
|
|
2998
3136
|
type: "text",
|
|
@@ -3023,11 +3161,11 @@ function CanvasComponentsPanel({
|
|
|
3023
3161
|
search = true,
|
|
3024
3162
|
className = ""
|
|
3025
3163
|
}) {
|
|
3026
|
-
const [query, setQuery] = (0,
|
|
3027
|
-
const [propsOpen, setPropsOpen] = (0,
|
|
3028
|
-
const [menuFor, setMenuFor] = (0,
|
|
3029
|
-
const [editing, setEditing] = (0,
|
|
3030
|
-
const { components: all, sets } = (0,
|
|
3164
|
+
const [query, setQuery] = (0, import_react30.useState)("");
|
|
3165
|
+
const [propsOpen, setPropsOpen] = (0, import_react30.useState)(null);
|
|
3166
|
+
const [menuFor, setMenuFor] = (0, import_react30.useState)(null);
|
|
3167
|
+
const [editing, setEditing] = (0, import_react30.useState)(null);
|
|
3168
|
+
const { components: all, sets } = (0, import_canvas22.listCanvasComponents)(nodes);
|
|
3031
3169
|
const q = query.trim().toLowerCase();
|
|
3032
3170
|
const match = (name) => !q || name.toLowerCase().includes(q);
|
|
3033
3171
|
const lone = all.filter((c) => !c.setId && match(c.name));
|
|
@@ -3038,7 +3176,7 @@ function CanvasComponentsPanel({
|
|
|
3038
3176
|
};
|
|
3039
3177
|
const small = "shrink-0 rounded px-1 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40";
|
|
3040
3178
|
const menuItem = "rounded px-2 py-0.5 text-left hover:bg-muted disabled:opacity-40";
|
|
3041
|
-
const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0,
|
|
3179
|
+
const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3042
3180
|
"button",
|
|
3043
3181
|
{
|
|
3044
3182
|
type: "button",
|
|
@@ -3050,22 +3188,22 @@ function CanvasComponentsPanel({
|
|
|
3050
3188
|
onClick: () => onInsert(id),
|
|
3051
3189
|
onContextMenu,
|
|
3052
3190
|
onDragStart: (e) => {
|
|
3053
|
-
e.dataTransfer.setData(
|
|
3191
|
+
e.dataTransfer.setData(import_canvas22.CANVAS_COMPONENT_DRAG_TYPE, id);
|
|
3054
3192
|
e.dataTransfer.setData("text/plain", name);
|
|
3055
3193
|
e.dataTransfer.effectAllowed = "copy";
|
|
3056
3194
|
},
|
|
3057
3195
|
children: [
|
|
3058
|
-
/* @__PURE__ */ (0,
|
|
3059
|
-
/* @__PURE__ */ (0,
|
|
3196
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "truncate", children: [
|
|
3197
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": true, className: "mr-1 text-muted-foreground", children: "\u25C7" }),
|
|
3060
3198
|
name
|
|
3061
3199
|
] }),
|
|
3062
|
-
/* @__PURE__ */ (0,
|
|
3200
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[10px] text-muted-foreground", "data-instance-count": "", children: count })
|
|
3063
3201
|
]
|
|
3064
3202
|
},
|
|
3065
3203
|
id
|
|
3066
3204
|
);
|
|
3067
|
-
return /* @__PURE__ */ (0,
|
|
3068
|
-
search ? /* @__PURE__ */ (0,
|
|
3205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-components-panel": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
|
|
3206
|
+
search ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3069
3207
|
"input",
|
|
3070
3208
|
{
|
|
3071
3209
|
type: "search",
|
|
@@ -3075,11 +3213,11 @@ function CanvasComponentsPanel({
|
|
|
3075
3213
|
onInput: (e) => setQuery(e.target.value)
|
|
3076
3214
|
}
|
|
3077
3215
|
) : null,
|
|
3078
|
-
shownSets.map((set) => /* @__PURE__ */ (0,
|
|
3079
|
-
/* @__PURE__ */ (0,
|
|
3216
|
+
shownSets.map((set) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-component-set": set.id, className: "flex flex-col", children: [
|
|
3217
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3080
3218
|
item(set.id, set.name, set.variants.reduce((sum, v) => sum + v.instanceCount, 0), { "data-kind": "set" }),
|
|
3081
|
-
components ? /* @__PURE__ */ (0,
|
|
3082
|
-
/* @__PURE__ */ (0,
|
|
3219
|
+
components ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3083
3221
|
"button",
|
|
3084
3222
|
{
|
|
3085
3223
|
type: "button",
|
|
@@ -3091,7 +3229,7 @@ function CanvasComponentsPanel({
|
|
|
3091
3229
|
children: "+\xA0Variant"
|
|
3092
3230
|
}
|
|
3093
3231
|
),
|
|
3094
|
-
/* @__PURE__ */ (0,
|
|
3232
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3095
3233
|
"button",
|
|
3096
3234
|
{
|
|
3097
3235
|
type: "button",
|
|
@@ -3106,8 +3244,8 @@ function CanvasComponentsPanel({
|
|
|
3106
3244
|
)
|
|
3107
3245
|
] }) : null
|
|
3108
3246
|
] }),
|
|
3109
|
-
components && propsOpen === set.id ? /* @__PURE__ */ (0,
|
|
3110
|
-
/* @__PURE__ */ (0,
|
|
3247
|
+
components && propsOpen === set.id ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { "data-variant-properties": set.id, className: "ml-3 flex flex-col gap-1 border-l border-border py-1 pl-2", children: set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-variant-option": option.name, className: "flex flex-col gap-0.5", children: [
|
|
3248
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3111
3249
|
InlineField,
|
|
3112
3250
|
{
|
|
3113
3251
|
value: option.name,
|
|
@@ -3115,7 +3253,7 @@ function CanvasComponentsPanel({
|
|
|
3115
3253
|
onCommit: (next) => report(components.renameVariantProperty(option.name, next, set.id))
|
|
3116
3254
|
}
|
|
3117
3255
|
),
|
|
3118
|
-
/* @__PURE__ */ (0,
|
|
3256
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "ml-2 flex flex-wrap gap-1", children: option.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3119
3257
|
InlineField,
|
|
3120
3258
|
{
|
|
3121
3259
|
value,
|
|
@@ -3125,8 +3263,8 @@ function CanvasComponentsPanel({
|
|
|
3125
3263
|
value
|
|
3126
3264
|
)) })
|
|
3127
3265
|
] }, option.name)) }) : null,
|
|
3128
|
-
/* @__PURE__ */ (0,
|
|
3129
|
-
/* @__PURE__ */ (0,
|
|
3266
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "ml-3 flex flex-col border-l border-border pl-1", children: set.variants.map((v) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-variant-row": v.id, className: "flex flex-col", children: [
|
|
3267
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3130
3268
|
item(
|
|
3131
3269
|
v.id,
|
|
3132
3270
|
v.name,
|
|
@@ -3137,7 +3275,7 @@ function CanvasComponentsPanel({
|
|
|
3137
3275
|
setMenuFor(v.id);
|
|
3138
3276
|
} : void 0
|
|
3139
3277
|
),
|
|
3140
|
-
components ? /* @__PURE__ */ (0,
|
|
3278
|
+
components ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3141
3279
|
"button",
|
|
3142
3280
|
{
|
|
3143
3281
|
type: "button",
|
|
@@ -3151,8 +3289,8 @@ function CanvasComponentsPanel({
|
|
|
3151
3289
|
}
|
|
3152
3290
|
) : null
|
|
3153
3291
|
] }),
|
|
3154
|
-
components && menuFor === v.id ? /* @__PURE__ */ (0,
|
|
3155
|
-
/* @__PURE__ */ (0,
|
|
3292
|
+
components && menuFor === v.id ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { role: "menu", "data-variant-menu": v.id, className: "ml-2 flex flex-col rounded border border-border bg-background p-1 shadow", children: [
|
|
3293
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3156
3294
|
"button",
|
|
3157
3295
|
{
|
|
3158
3296
|
type: "button",
|
|
@@ -3166,7 +3304,7 @@ function CanvasComponentsPanel({
|
|
|
3166
3304
|
children: "Edit values\u2026"
|
|
3167
3305
|
}
|
|
3168
3306
|
),
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3307
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3170
3308
|
"button",
|
|
3171
3309
|
{
|
|
3172
3310
|
type: "button",
|
|
@@ -3180,7 +3318,7 @@ function CanvasComponentsPanel({
|
|
|
3180
3318
|
children: "Duplicate"
|
|
3181
3319
|
}
|
|
3182
3320
|
),
|
|
3183
|
-
/* @__PURE__ */ (0,
|
|
3321
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3184
3322
|
"button",
|
|
3185
3323
|
{
|
|
3186
3324
|
type: "button",
|
|
@@ -3197,7 +3335,7 @@ function CanvasComponentsPanel({
|
|
|
3197
3335
|
}
|
|
3198
3336
|
)
|
|
3199
3337
|
] }) : null,
|
|
3200
|
-
components && editing === v.id ? /* @__PURE__ */ (0,
|
|
3338
|
+
components && editing === v.id ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3201
3339
|
"form",
|
|
3202
3340
|
{
|
|
3203
3341
|
"data-variant-editor": v.id,
|
|
@@ -3211,9 +3349,9 @@ function CanvasComponentsPanel({
|
|
|
3211
3349
|
if (report(components.setVariantProperties(values, v.id))) setEditing(null);
|
|
3212
3350
|
},
|
|
3213
3351
|
children: [
|
|
3214
|
-
set.options.map((option) => /* @__PURE__ */ (0,
|
|
3215
|
-
/* @__PURE__ */ (0,
|
|
3216
|
-
/* @__PURE__ */ (0,
|
|
3352
|
+
set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
3353
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-16 shrink-0 truncate text-muted-foreground", children: option.name }),
|
|
3354
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3217
3355
|
"input",
|
|
3218
3356
|
{
|
|
3219
3357
|
type: "text",
|
|
@@ -3224,9 +3362,9 @@ function CanvasComponentsPanel({
|
|
|
3224
3362
|
}
|
|
3225
3363
|
)
|
|
3226
3364
|
] }, option.name)),
|
|
3227
|
-
/* @__PURE__ */ (0,
|
|
3228
|
-
/* @__PURE__ */ (0,
|
|
3229
|
-
/* @__PURE__ */ (0,
|
|
3365
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex gap-1", children: [
|
|
3366
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "submit", className: "rounded border border-border px-2 py-0.5 hover:bg-muted", "data-action": "save-variant", children: "Save" }),
|
|
3367
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: "rounded px-2 py-0.5 hover:bg-muted", "data-action": "cancel-variant", onClick: () => setEditing(null), children: "Cancel" })
|
|
3230
3368
|
] })
|
|
3231
3369
|
]
|
|
3232
3370
|
}
|
|
@@ -3234,7 +3372,7 @@ function CanvasComponentsPanel({
|
|
|
3234
3372
|
] }, v.id)) })
|
|
3235
3373
|
] }, set.id)),
|
|
3236
3374
|
lone.map((c) => item(c.id, c.name, c.instanceCount, { "data-kind": "component" })),
|
|
3237
|
-
all.length === 0 ? /* @__PURE__ */ (0,
|
|
3375
|
+
all.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-muted-foreground", children: "No components yet. Select a frame and choose Create Component." }) : null
|
|
3238
3376
|
] });
|
|
3239
3377
|
}
|
|
3240
3378
|
function CanvasInstanceInspector({
|
|
@@ -3244,36 +3382,36 @@ function CanvasInstanceInspector({
|
|
|
3244
3382
|
onError,
|
|
3245
3383
|
className = ""
|
|
3246
3384
|
}) {
|
|
3247
|
-
const info = nodeId ? (0,
|
|
3385
|
+
const info = nodeId ? (0, import_canvas22.inspectCanvasInstance)(nodes, nodeId) : void 0;
|
|
3248
3386
|
if (!info) return null;
|
|
3249
3387
|
const report = (result) => {
|
|
3250
3388
|
if (result && !result.ok && result.reason) onError?.(result.reason);
|
|
3251
3389
|
};
|
|
3252
3390
|
const setProp = (name, value) => report(components.setInstanceProperties({ [name]: value }, [info.id]));
|
|
3253
|
-
const allComponents = (0,
|
|
3391
|
+
const allComponents = (0, import_canvas22.listCanvasComponents)(nodes).components;
|
|
3254
3392
|
const linked = info.status === "linked";
|
|
3255
3393
|
const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-40";
|
|
3256
|
-
return /* @__PURE__ */ (0,
|
|
3257
|
-
/* @__PURE__ */ (0,
|
|
3258
|
-
/* @__PURE__ */ (0,
|
|
3259
|
-
info.nested ? /* @__PURE__ */ (0,
|
|
3394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-instance-inspector": "", "data-instance-id": info.id, className: `flex flex-col gap-2 text-xs text-foreground ${className}`, children: [
|
|
3395
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
3396
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate font-medium", "data-instance-main": "", children: linked ? info.componentName : "Main component missing" }),
|
|
3397
|
+
info.nested ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-muted-foreground", children: "Nested" }) : null
|
|
3260
3398
|
] }),
|
|
3261
|
-
info.variantOptions.map((option) => /* @__PURE__ */ (0,
|
|
3262
|
-
/* @__PURE__ */ (0,
|
|
3263
|
-
/* @__PURE__ */ (0,
|
|
3399
|
+
info.variantOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", "data-variant-property": option.name, children: [
|
|
3400
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: option.name }),
|
|
3401
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3264
3402
|
"select",
|
|
3265
3403
|
{
|
|
3266
3404
|
"aria-label": `${option.name} variant`,
|
|
3267
3405
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
3268
3406
|
value: info.variant[option.name] ?? "",
|
|
3269
3407
|
onChange: (e) => setProp(option.name, e.currentTarget.value),
|
|
3270
|
-
children: option.values.map((v) => /* @__PURE__ */ (0,
|
|
3408
|
+
children: option.values.map((v) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: v, children: v }, v))
|
|
3271
3409
|
}
|
|
3272
3410
|
)
|
|
3273
3411
|
] }, option.name)),
|
|
3274
|
-
info.properties.map((p) => /* @__PURE__ */ (0,
|
|
3275
|
-
/* @__PURE__ */ (0,
|
|
3276
|
-
p.type === "boolean" ? /* @__PURE__ */ (0,
|
|
3412
|
+
info.properties.map((p) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", "data-component-property": p.name, children: [
|
|
3413
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: p.name }),
|
|
3414
|
+
p.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { type: "checkbox", "aria-label": p.name, checked: p.value === true, onChange: (e) => setProp(p.name, e.currentTarget.checked) }) : p.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3277
3415
|
"input",
|
|
3278
3416
|
{
|
|
3279
3417
|
type: "text",
|
|
@@ -3288,22 +3426,22 @@ function CanvasInstanceInspector({
|
|
|
3288
3426
|
}
|
|
3289
3427
|
},
|
|
3290
3428
|
String(p.value)
|
|
3291
|
-
) : /* @__PURE__ */ (0,
|
|
3429
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3292
3430
|
"select",
|
|
3293
3431
|
{
|
|
3294
3432
|
"aria-label": p.name,
|
|
3295
3433
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
3296
3434
|
value: String(p.value),
|
|
3297
3435
|
onChange: (e) => setProp(p.name, e.currentTarget.value),
|
|
3298
|
-
children: allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value).map((c) => /* @__PURE__ */ (0,
|
|
3436
|
+
children: allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value).map((c) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: c.id, children: c.name }, c.id))
|
|
3299
3437
|
}
|
|
3300
3438
|
)
|
|
3301
3439
|
] }, p.name)),
|
|
3302
|
-
info.overrides.length ? /* @__PURE__ */ (0,
|
|
3303
|
-
/* @__PURE__ */ (0,
|
|
3304
|
-
info.overrides.map((o) => /* @__PURE__ */ (0,
|
|
3305
|
-
/* @__PURE__ */ (0,
|
|
3306
|
-
o.groups.map((g) => /* @__PURE__ */ (0,
|
|
3440
|
+
info.overrides.length ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1", "data-instance-overrides": "", children: [
|
|
3441
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-muted-foreground", children: "Overrides" }),
|
|
3442
|
+
info.overrides.map((o) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-override-layer": o.id, children: [
|
|
3443
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "mr-1 truncate", children: o.name }),
|
|
3444
|
+
o.groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3307
3445
|
"button",
|
|
3308
3446
|
{
|
|
3309
3447
|
type: "button",
|
|
@@ -3320,11 +3458,11 @@ function CanvasInstanceInspector({
|
|
|
3320
3458
|
))
|
|
3321
3459
|
] }, o.id))
|
|
3322
3460
|
] }) : null,
|
|
3323
|
-
/* @__PURE__ */ (0,
|
|
3324
|
-
linked ? /* @__PURE__ */ (0,
|
|
3325
|
-
/* @__PURE__ */ (0,
|
|
3326
|
-
/* @__PURE__ */ (0,
|
|
3327
|
-
/* @__PURE__ */ (0,
|
|
3461
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
3462
|
+
linked ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3463
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn2, "data-action": "reset", onClick: () => report(components.resetOverrides(info.id)), children: "Reset all" }),
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn2, "data-action": "go-to-main", onClick: () => components.goToMainComponent(info.id), children: "Go to main" }),
|
|
3465
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3328
3466
|
"button",
|
|
3329
3467
|
{
|
|
3330
3468
|
type: "button",
|
|
@@ -3335,8 +3473,8 @@ function CanvasInstanceInspector({
|
|
|
3335
3473
|
children: "Push changes"
|
|
3336
3474
|
}
|
|
3337
3475
|
)
|
|
3338
|
-
] }) : /* @__PURE__ */ (0,
|
|
3339
|
-
/* @__PURE__ */ (0,
|
|
3476
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn2, "data-action": "restore", onClick: () => report(components.restoreMainComponent(info.rootId)), children: "Restore main component" }),
|
|
3477
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3340
3478
|
"button",
|
|
3341
3479
|
{
|
|
3342
3480
|
type: "button",
|
|
@@ -3353,12 +3491,12 @@ function CanvasInstanceInspector({
|
|
|
3353
3491
|
}
|
|
3354
3492
|
|
|
3355
3493
|
// src/canvas/index.ts
|
|
3356
|
-
var
|
|
3494
|
+
var import_canvas35 = require("@pixerate/editor/canvas");
|
|
3357
3495
|
|
|
3358
3496
|
// src/canvas/MermaidFamilyScene.tsx
|
|
3359
|
-
var
|
|
3360
|
-
var
|
|
3361
|
-
var
|
|
3497
|
+
var import_react31 = require("react");
|
|
3498
|
+
var import_canvas23 = require("@pixerate/editor/canvas");
|
|
3499
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3362
3500
|
function MermaidFamilyScene({
|
|
3363
3501
|
scene,
|
|
3364
3502
|
padding = 16,
|
|
@@ -3371,7 +3509,7 @@ function MermaidFamilyScene({
|
|
|
3371
3509
|
style,
|
|
3372
3510
|
title
|
|
3373
3511
|
}) {
|
|
3374
|
-
const uid = (0,
|
|
3512
|
+
const uid = (0, import_react31.useId)().replace(/:/g, "");
|
|
3375
3513
|
const marker = (kind) => kind ? `url(#${uid}-${kind})` : void 0;
|
|
3376
3514
|
const x = scene.x - padding;
|
|
3377
3515
|
const y = scene.y - padding;
|
|
@@ -3389,7 +3527,7 @@ function MermaidFamilyScene({
|
|
|
3389
3527
|
cursor: "pointer"
|
|
3390
3528
|
} : { pointerEvents: "none" };
|
|
3391
3529
|
const stroke = (mark) => mark.selected ? { stroke: selectionColor, strokeWidth: Math.max(2, mark.strokeWidth ?? 0) } : { stroke: mark.stroke, strokeWidth: mark.strokeWidth };
|
|
3392
|
-
return /* @__PURE__ */ (0,
|
|
3530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3393
3531
|
"svg",
|
|
3394
3532
|
{
|
|
3395
3533
|
className: `pixerate-diagram-scene ${className}`.trim(),
|
|
@@ -3402,15 +3540,15 @@ function MermaidFamilyScene({
|
|
|
3402
3540
|
style: { display: "block", maxWidth: "100%", height: "auto", overflow: "visible", ...style },
|
|
3403
3541
|
onClick: interactive ? (event) => onSelect?.(null, event) : void 0,
|
|
3404
3542
|
children: [
|
|
3405
|
-
/* @__PURE__ */ (0,
|
|
3406
|
-
/* @__PURE__ */ (0,
|
|
3407
|
-
/* @__PURE__ */ (0,
|
|
3543
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("defs", { children: [
|
|
3544
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("marker", { id: `${uid}-arrowclosed`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M0,0 L10,5 L0,10 Z", style: { fill: markerColor } }) }),
|
|
3545
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("marker", { id: `${uid}-arrow`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M0,0 L10,5 L0,10", style: { fill: "none", stroke: markerColor, strokeWidth: 1.5 } }) })
|
|
3408
3546
|
] }),
|
|
3409
3547
|
scene.marks.map((mark) => {
|
|
3410
3548
|
const common = { "data-role": mark.role, "data-target": mark.target, "data-selected": mark.selected ? "" : void 0, opacity: mark.opacity, ...handlers(mark) };
|
|
3411
3549
|
switch (mark.kind) {
|
|
3412
3550
|
case "rect":
|
|
3413
|
-
return /* @__PURE__ */ (0,
|
|
3551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3414
3552
|
"rect",
|
|
3415
3553
|
{
|
|
3416
3554
|
...common,
|
|
@@ -3425,9 +3563,9 @@ function MermaidFamilyScene({
|
|
|
3425
3563
|
mark.key
|
|
3426
3564
|
);
|
|
3427
3565
|
case "circle":
|
|
3428
|
-
return /* @__PURE__ */ (0,
|
|
3566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, ...stroke(mark) } }, mark.key);
|
|
3429
3567
|
case "line":
|
|
3430
|
-
return /* @__PURE__ */ (0,
|
|
3568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3431
3569
|
"line",
|
|
3432
3570
|
{
|
|
3433
3571
|
...common,
|
|
@@ -3443,7 +3581,7 @@ function MermaidFamilyScene({
|
|
|
3443
3581
|
mark.key
|
|
3444
3582
|
);
|
|
3445
3583
|
case "path":
|
|
3446
|
-
return /* @__PURE__ */ (0,
|
|
3584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3447
3585
|
"path",
|
|
3448
3586
|
{
|
|
3449
3587
|
...common,
|
|
@@ -3457,14 +3595,14 @@ function MermaidFamilyScene({
|
|
|
3457
3595
|
mark.key
|
|
3458
3596
|
);
|
|
3459
3597
|
case "text":
|
|
3460
|
-
return /* @__PURE__ */ (0,
|
|
3598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3461
3599
|
"text",
|
|
3462
3600
|
{
|
|
3463
3601
|
...common,
|
|
3464
3602
|
x: mark.x,
|
|
3465
3603
|
y: mark.y,
|
|
3466
3604
|
textAnchor: mark.anchor,
|
|
3467
|
-
dominantBaseline: (0,
|
|
3605
|
+
dominantBaseline: (0, import_canvas23.diagramTextBaseline)(mark.baseline),
|
|
3468
3606
|
transform: mark.rotate ? `rotate(${mark.rotate} ${mark.x} ${mark.y})` : void 0,
|
|
3469
3607
|
style: {
|
|
3470
3608
|
fill: mark.selected ? selectionColor : mark.fill,
|
|
@@ -3485,14 +3623,14 @@ function MermaidFamilyScene({
|
|
|
3485
3623
|
}
|
|
3486
3624
|
|
|
3487
3625
|
// src/canvas/useMermaidDiagram.ts
|
|
3488
|
-
var
|
|
3626
|
+
var import_react32 = require("react");
|
|
3489
3627
|
var import_diagram = require("@pixerate/editor/diagram");
|
|
3490
|
-
var
|
|
3628
|
+
var import_canvas24 = require("@pixerate/editor/canvas");
|
|
3491
3629
|
function useDiagramState(controller) {
|
|
3492
|
-
return (0,
|
|
3630
|
+
return (0, import_react32.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
3493
3631
|
}
|
|
3494
3632
|
function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
3495
|
-
const own = (0,
|
|
3633
|
+
const own = (0, import_react32.useRef)(null);
|
|
3496
3634
|
let controller;
|
|
3497
3635
|
if (controllerOrOptions instanceof import_diagram.DiagramController) controller = controllerOrOptions;
|
|
3498
3636
|
else {
|
|
@@ -3502,24 +3640,24 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
3502
3640
|
const layoutOptions = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.layoutOptions) ?? view.layoutOptions;
|
|
3503
3641
|
const sceneTheme = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.sceneTheme) ?? view.sceneTheme;
|
|
3504
3642
|
const state = useDiagramState(controller);
|
|
3505
|
-
const canvas = (0,
|
|
3506
|
-
() => (0,
|
|
3643
|
+
const canvas = (0, import_react32.useMemo)(
|
|
3644
|
+
() => (0, import_canvas24.mermaidToCanvas)(state.document, { ...layoutOptions, editable: state.editable }),
|
|
3507
3645
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3508
3646
|
[state.document, state.editable]
|
|
3509
3647
|
);
|
|
3510
|
-
const scene = (0,
|
|
3511
|
-
() => state.document.tier === "editable" ? (0,
|
|
3648
|
+
const scene = (0, import_react32.useMemo)(
|
|
3649
|
+
() => state.document.tier === "editable" ? (0, import_canvas24.familySceneFromLayout)(state.document.family, state.document.graph, canvas.layout, { theme: { ...import_canvas24.CSS_VARIABLE_DIAGRAM_SCENE_THEME, ...sceneTheme }, selection: state.selection }) : null,
|
|
3512
3650
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3513
3651
|
[state.document, canvas.layout, state.selection]
|
|
3514
3652
|
);
|
|
3515
|
-
const layoutRef = (0,
|
|
3653
|
+
const layoutRef = (0, import_react32.useRef)(canvas.layout);
|
|
3516
3654
|
layoutRef.current = canvas.layout;
|
|
3517
|
-
const actions = (0,
|
|
3655
|
+
const actions = (0, import_react32.useMemo)(
|
|
3518
3656
|
() => ({
|
|
3519
3657
|
apply: (ops, label) => controller.apply(ops, label),
|
|
3520
3658
|
load: (source, options) => controller.load(source, options),
|
|
3521
3659
|
moveNodes: (moved, all = moved) => {
|
|
3522
|
-
const op = (0,
|
|
3660
|
+
const op = (0, import_canvas24.mermaidMovesFromCanvas)(layoutRef.current, moved, all, { stored: controller.getDocument().meta.layout ?? {} });
|
|
3523
3661
|
return op ? controller.apply(op, "Move") : null;
|
|
3524
3662
|
},
|
|
3525
3663
|
connect: (source, target, label) => controller.apply({ type: "addEdge", edge: { source, target, ...label ? { label } : {} } }, "Connect"),
|
|
@@ -3538,7 +3676,7 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
3538
3676
|
"Rename"
|
|
3539
3677
|
),
|
|
3540
3678
|
renameTarget: (target, label) => {
|
|
3541
|
-
const op = (0,
|
|
3679
|
+
const op = (0, import_canvas24.diagramRenameOp)(controller.getDocument(), target, label);
|
|
3542
3680
|
return op ? controller.apply(op, "Rename") : null;
|
|
3543
3681
|
},
|
|
3544
3682
|
select: (ids) => controller.select(ids),
|
|
@@ -3551,13 +3689,13 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
3551
3689
|
}
|
|
3552
3690
|
function useMermaidStream(source, options = {}) {
|
|
3553
3691
|
const { complete = false, duration = 300, ...layoutOptions } = options;
|
|
3554
|
-
const stream = (0,
|
|
3555
|
-
if (!stream.current) stream.current = new
|
|
3556
|
-
const result = (0,
|
|
3557
|
-
const [shown, setShown] = (0,
|
|
3558
|
-
const shownRef = (0,
|
|
3692
|
+
const stream = (0, import_react32.useRef)(null);
|
|
3693
|
+
if (!stream.current) stream.current = new import_canvas24.DiagramStream(layoutOptions);
|
|
3694
|
+
const result = (0, import_react32.useMemo)(() => stream.current.update(source, complete), [source, complete]);
|
|
3695
|
+
const [shown, setShown] = (0, import_react32.useState)({ layout: result.layout, settled: true });
|
|
3696
|
+
const shownRef = (0, import_react32.useRef)(shown.layout);
|
|
3559
3697
|
shownRef.current = shown.layout;
|
|
3560
|
-
(0,
|
|
3698
|
+
(0, import_react32.useEffect)(() => {
|
|
3561
3699
|
const target = result.layout;
|
|
3562
3700
|
if (!target) return setShown({ layout: null, settled: true });
|
|
3563
3701
|
const from = shownRef.current;
|
|
@@ -3567,14 +3705,14 @@ function useMermaidStream(source, options = {}) {
|
|
|
3567
3705
|
const start = performance.now();
|
|
3568
3706
|
const step = () => {
|
|
3569
3707
|
const t = Math.min(1, (performance.now() - start) / duration);
|
|
3570
|
-
setShown({ layout: (0,
|
|
3708
|
+
setShown({ layout: (0, import_canvas24.blendDiagramLayout)(from, target, (0, import_canvas24.easeDiagramTween)(t)), settled: t >= 1 });
|
|
3571
3709
|
if (t < 1) frame = requestAnimationFrame(step);
|
|
3572
3710
|
};
|
|
3573
3711
|
frame = requestAnimationFrame(step);
|
|
3574
3712
|
return () => cancelAnimationFrame(frame);
|
|
3575
3713
|
}, [result.layout, duration]);
|
|
3576
3714
|
const doc = result.document.tier === "editable" ? result.document : null;
|
|
3577
|
-
const canvas = (0,
|
|
3715
|
+
const canvas = (0, import_react32.useMemo)(() => {
|
|
3578
3716
|
if (!doc || !shown.layout) return { nodes: [], edges: [] };
|
|
3579
3717
|
const placed = new Set(Object.keys(shown.layout.positions));
|
|
3580
3718
|
const graph = {
|
|
@@ -3583,24 +3721,24 @@ function useMermaidStream(source, options = {}) {
|
|
|
3583
3721
|
groups: doc.graph.groups.filter((g) => placed.has(g.id)),
|
|
3584
3722
|
edges: doc.graph.edges.filter((e) => placed.has(e.source) && placed.has(e.target))
|
|
3585
3723
|
};
|
|
3586
|
-
return (0,
|
|
3724
|
+
return (0, import_canvas24.mermaidToCanvas)({ ...doc, graph }, { layout: shown.layout });
|
|
3587
3725
|
}, [doc, shown.layout]);
|
|
3588
3726
|
return { document: doc, ...canvas, layout: shown.layout, settled: shown.settled };
|
|
3589
3727
|
}
|
|
3590
3728
|
|
|
3591
3729
|
// src/canvas/MermaidDiagramNode.tsx
|
|
3592
|
-
var
|
|
3593
|
-
var
|
|
3730
|
+
var import_canvas25 = require("@pixerate/editor/canvas");
|
|
3731
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3594
3732
|
function mermaidNodeStyle(styles = {}, selected = false) {
|
|
3595
|
-
const paint = (0,
|
|
3733
|
+
const paint = (0, import_canvas25.mermaidNodePaint)(styles, selected);
|
|
3596
3734
|
const { color, "stroke-width": strokeWidth, "stroke-dasharray": strokeDasharray, ...vars } = paint;
|
|
3597
3735
|
return { ...vars, color, strokeWidth, strokeDasharray };
|
|
3598
3736
|
}
|
|
3599
3737
|
function MermaidDiagramNode({ data, width = 160, height = 56, selected, className = "", children }) {
|
|
3600
3738
|
const node = data.node;
|
|
3601
3739
|
if (!node) return null;
|
|
3602
|
-
const members = (0,
|
|
3603
|
-
return /* @__PURE__ */ (0,
|
|
3740
|
+
const members = (0, import_canvas25.mermaidNodeMembers)(node.data);
|
|
3741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3604
3742
|
"div",
|
|
3605
3743
|
{
|
|
3606
3744
|
className: `pixerate-diagram-node ${className}`.trim(),
|
|
@@ -3608,14 +3746,14 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
3608
3746
|
"data-selected": selected ? "true" : void 0,
|
|
3609
3747
|
style: { position: "relative", width: "100%", height: "100%", ...mermaidNodeStyle(data.resolvedStyles, selected) },
|
|
3610
3748
|
children: [
|
|
3611
|
-
/* @__PURE__ */ (0,
|
|
3612
|
-
/* @__PURE__ */ (0,
|
|
3749
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("svg", { viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", width: "100%", height: "100%", style: { position: "absolute", inset: 0, overflow: "visible" }, "aria-hidden": "true", children: (0, import_canvas25.mermaidShapePaths)(node.shape, width, height).map((path, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: path.d, style: { ...import_canvas25.MERMAID_SHAPE_PAINT[path.paint], vectorEffect: "non-scaling-stroke" } }, i)) }),
|
|
3750
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3613
3751
|
"div",
|
|
3614
3752
|
{
|
|
3615
3753
|
style: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: members.length ? "flex-start" : "center", height: "100%", padding: "6px 10px", boxSizing: "border-box", fontSize: 13, lineHeight: 1.3, textAlign: "center", pointerEvents: "none" },
|
|
3616
3754
|
children: [
|
|
3617
|
-
(0,
|
|
3618
|
-
members.length > 0 && /* @__PURE__ */ (0,
|
|
3755
|
+
(0, import_canvas25.mermaidLabelLines)(node.label).map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontWeight: members.length ? 600 : void 0 }, children: line }, i)),
|
|
3756
|
+
members.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { alignSelf: "stretch", marginTop: 4, paddingTop: 4, borderTop: "1px solid var(--pixerate-diagram-node-border)", textAlign: "left", fontSize: 12 }, children: members.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: m }, i)) })
|
|
3619
3757
|
]
|
|
3620
3758
|
}
|
|
3621
3759
|
),
|
|
@@ -3627,7 +3765,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
3627
3765
|
function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
3628
3766
|
const group = data.group;
|
|
3629
3767
|
if (!group) return null;
|
|
3630
|
-
return /* @__PURE__ */ (0,
|
|
3768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3631
3769
|
"div",
|
|
3632
3770
|
{
|
|
3633
3771
|
className: `pixerate-diagram-group ${className}`.trim(),
|
|
@@ -3642,7 +3780,7 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
3642
3780
|
color: data.resolvedStyles?.color ?? "var(--muted-foreground, #475569)"
|
|
3643
3781
|
},
|
|
3644
3782
|
children: [
|
|
3645
|
-
/* @__PURE__ */ (0,
|
|
3783
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { padding: "6px 10px", fontSize: 12, fontWeight: 600 }, children: (0, import_canvas25.mermaidLabelLines)(group.label).join(" ") }),
|
|
3646
3784
|
children
|
|
3647
3785
|
]
|
|
3648
3786
|
}
|
|
@@ -3650,29 +3788,29 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
3650
3788
|
}
|
|
3651
3789
|
|
|
3652
3790
|
// src/canvas/MermaidThumbnail.tsx
|
|
3653
|
-
var
|
|
3791
|
+
var import_react33 = require("react");
|
|
3654
3792
|
var import_diagram2 = require("@pixerate/editor/diagram");
|
|
3655
|
-
var
|
|
3656
|
-
var
|
|
3793
|
+
var import_canvas26 = require("@pixerate/editor/canvas");
|
|
3794
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3657
3795
|
function MermaidThumbnail({ source, className = "", fallback = null, ...options }) {
|
|
3658
|
-
const doc = (0,
|
|
3796
|
+
const doc = (0, import_react33.useMemo)(() => typeof source === "string" ? (0, import_diagram2.parseMermaid)(source) : source, [source]);
|
|
3659
3797
|
const key = JSON.stringify(options);
|
|
3660
|
-
const drawn = (0,
|
|
3661
|
-
() => doc.tier === "editable" && doc.graph.nodes.length ? (0,
|
|
3798
|
+
const drawn = (0, import_react33.useMemo)(
|
|
3799
|
+
() => doc.tier === "editable" && doc.graph.nodes.length ? (0, import_canvas26.mermaidThumbnailSvg)(doc, options) : null,
|
|
3662
3800
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3663
3801
|
[doc, key]
|
|
3664
3802
|
);
|
|
3665
|
-
if (!drawn) return /* @__PURE__ */ (0,
|
|
3666
|
-
return /* @__PURE__ */ (0,
|
|
3803
|
+
if (!drawn) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: fallback });
|
|
3804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: `pixerate-diagram-thumbnail ${className}`.trim(), style: { display: "inline-block", lineHeight: 0 }, dangerouslySetInnerHTML: { __html: drawn.svg } });
|
|
3667
3805
|
}
|
|
3668
3806
|
|
|
3669
3807
|
// src/canvas/useDiagramDirector.ts
|
|
3670
|
-
var
|
|
3808
|
+
var import_react34 = require("react");
|
|
3671
3809
|
var import_diagram3 = require("@pixerate/editor/diagram");
|
|
3672
3810
|
function useDiagramDirector(controller, options) {
|
|
3673
|
-
const placement = (0,
|
|
3811
|
+
const placement = (0, import_react34.useRef)(options.placement);
|
|
3674
3812
|
placement.current = options.placement;
|
|
3675
|
-
const ref = (0,
|
|
3813
|
+
const ref = (0, import_react34.useRef)(null);
|
|
3676
3814
|
if (!ref.current) {
|
|
3677
3815
|
const presence = new import_diagram3.PresenceStore();
|
|
3678
3816
|
ref.current = {
|
|
@@ -3683,17 +3821,17 @@ function useDiagramDirector(controller, options) {
|
|
|
3683
3821
|
return ref.current;
|
|
3684
3822
|
}
|
|
3685
3823
|
function usePresenceState(presence) {
|
|
3686
|
-
return (0,
|
|
3824
|
+
return (0, import_react34.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
3687
3825
|
}
|
|
3688
3826
|
|
|
3689
3827
|
// src/canvas/DiagramPresenceLayer.tsx
|
|
3690
|
-
var
|
|
3828
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3691
3829
|
function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
3692
3830
|
const { actors } = usePresenceState(presence);
|
|
3693
3831
|
if (!actors.length) return null;
|
|
3694
|
-
return /* @__PURE__ */ (0,
|
|
3695
|
-
/* @__PURE__ */ (0,
|
|
3696
|
-
/* @__PURE__ */ (0,
|
|
3832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `pixerate-diagram-presence ${className}`.trim(), "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 }, children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${a.x * viewport.zoom + viewport.x}px, ${a.y * viewport.zoom + viewport.y}px)` }, children: [
|
|
3833
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
3834
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { style: { position: "absolute", left: 14, top: 16, whiteSpace: "nowrap", borderRadius: 4, padding: "1px 6px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.message ?? a.name })
|
|
3697
3835
|
] }, a.id)) });
|
|
3698
3836
|
}
|
|
3699
3837
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -3731,6 +3869,7 @@ function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
|
3731
3869
|
MermaidDiagramNode,
|
|
3732
3870
|
MermaidFamilyScene,
|
|
3733
3871
|
MermaidThumbnail,
|
|
3872
|
+
PresenceLayer,
|
|
3734
3873
|
RESIZE_HANDLES,
|
|
3735
3874
|
SHAPE_DATA_KEY,
|
|
3736
3875
|
SHAPE_KINDS,
|
|
@@ -4045,6 +4184,7 @@ function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
|
4045
4184
|
useCanvasGraph,
|
|
4046
4185
|
useCanvasLayout,
|
|
4047
4186
|
useCanvasMeasure,
|
|
4187
|
+
useCanvasPlaybackSurface,
|
|
4048
4188
|
useCanvasScenes,
|
|
4049
4189
|
useCanvasShortcuts,
|
|
4050
4190
|
useCanvasTokens,
|