@pixerate/editor-react 0.91.0 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/AgentPresenceLayer.d.cts +3 -0
- package/dist/canvas/AgentPresenceLayer.d.ts +3 -0
- package/dist/canvas/index.cjs +1032 -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/{chunk-SMMO7CZB.js → chunk-6MDTFAPY.js} +84 -2
- package/dist/chunk-ECBC4HD7.js +95 -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 +1027 -864
- package/dist/image-editor/index.js +2 -1
- package/dist/index.cjs +1986 -1810
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -2
- 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 +3 -0
- package/dist/playback/index.d.ts +3 -0
- package/dist/playback/usePlaybackSurface.d.cts +9 -0
- package/dist/playback/usePlaybackSurface.d.ts +9 -0
- package/dist/vector/VectorCanvas.d.cts +11 -1
- package/dist/vector/VectorCanvas.d.ts +11 -1
- package/dist/vector/index.cjs +945 -826
- package/dist/vector/index.js +42 -3
- package/package.json +13 -13
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,148 @@ 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 = {}) {
|
|
528
|
+
const ambient = useAgentPlayback();
|
|
529
|
+
const target = playback === void 0 ? ambient : playback;
|
|
530
|
+
const [presence] = (0, import_react3.useState)(() => new import_tools.PresenceStore());
|
|
531
|
+
const latest = (0, import_react3.useRef)(options);
|
|
532
|
+
latest.current = options;
|
|
533
|
+
(0, import_react3.useEffect)(() => {
|
|
534
|
+
if (!target || !id) return;
|
|
535
|
+
const o = () => latest.current;
|
|
536
|
+
const surface = {
|
|
537
|
+
presence,
|
|
538
|
+
locate: (ref) => o().locate?.(ref) ?? null,
|
|
539
|
+
bounds: () => o().bounds?.() ?? null,
|
|
540
|
+
visible: () => o().visible?.() ?? true,
|
|
541
|
+
toViewport: (p) => o().toViewport?.(p) ?? p,
|
|
542
|
+
fromViewport: (p) => o().fromViewport?.(p) ?? p,
|
|
543
|
+
beginGesture: (key) => o().beginGesture?.(key),
|
|
544
|
+
endGesture: () => o().endGesture?.(),
|
|
545
|
+
reveal: () => o().reveal?.(),
|
|
546
|
+
open: (ref) => o().open?.(ref),
|
|
547
|
+
get defaultKind() {
|
|
548
|
+
return o().defaultKind;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
const detach = target.attach(id, surface);
|
|
552
|
+
return () => {
|
|
553
|
+
detach();
|
|
554
|
+
for (const a of presence.getState().actors) presence.remove(a.id);
|
|
555
|
+
};
|
|
556
|
+
}, [target, id, presence]);
|
|
557
|
+
return presence;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// src/canvas/useCanvasPlaybackSurface.ts
|
|
561
|
+
function useCanvasPlaybackSurface(playback, id, options) {
|
|
562
|
+
const latest = (0, import_react4.useRef)(options);
|
|
563
|
+
latest.current = options;
|
|
564
|
+
const locate = (0, import_react4.useMemo)(
|
|
565
|
+
() => (0, import_canvas.createCanvasPlaybackLocator)({
|
|
566
|
+
getNodes: () => latest.current.getNodes(),
|
|
567
|
+
getEdges: () => latest.current.getEdges?.() ?? [],
|
|
568
|
+
get rectOptions() {
|
|
569
|
+
return latest.current.rectOptions;
|
|
570
|
+
}
|
|
571
|
+
}),
|
|
572
|
+
[]
|
|
573
|
+
);
|
|
574
|
+
const box = () => latest.current.container.current?.getBoundingClientRect() ?? null;
|
|
575
|
+
return usePlaybackSurface(playback, id, {
|
|
576
|
+
defaultKind: "node",
|
|
577
|
+
locate,
|
|
578
|
+
bounds: () => {
|
|
579
|
+
const r = box();
|
|
580
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
581
|
+
return r && r.width > 0 ? { x: -x / zoom, y: -y / zoom, width: r.width / zoom, height: r.height / zoom } : null;
|
|
582
|
+
},
|
|
583
|
+
visible: () => {
|
|
584
|
+
if (latest.current.visible) return latest.current.visible();
|
|
585
|
+
const r = box();
|
|
586
|
+
const hidden = typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
587
|
+
return !!r && r.width > 0 && r.height > 0 && !hidden;
|
|
588
|
+
},
|
|
589
|
+
toViewport: (p) => {
|
|
590
|
+
const r = box();
|
|
591
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
592
|
+
return { x: (r?.left ?? 0) + p.x * zoom + x, y: (r?.top ?? 0) + p.y * zoom + y };
|
|
593
|
+
},
|
|
594
|
+
fromViewport: (p) => {
|
|
595
|
+
const r = box();
|
|
596
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
597
|
+
return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
|
|
598
|
+
},
|
|
599
|
+
reveal: () => latest.current.reveal?.()
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// src/canvas/useStreamingCanvas.ts
|
|
604
|
+
var import_react5 = require("react");
|
|
605
|
+
var import_canvas2 = require("@pixerate/editor/canvas");
|
|
469
606
|
function useStreamingCanvas(options) {
|
|
470
|
-
const managerRef = (0,
|
|
471
|
-
(0,
|
|
472
|
-
const manager = new
|
|
607
|
+
const managerRef = (0, import_react5.useRef)(null);
|
|
608
|
+
(0, import_react5.useEffect)(() => {
|
|
609
|
+
const manager = new import_canvas2.StreamingLayoutManager({
|
|
473
610
|
throttleMs: options.throttleMs,
|
|
474
611
|
glideDurationMs: options.glideDurationMs,
|
|
475
612
|
connectedOnly: options.connectedOnly,
|
|
@@ -489,13 +626,13 @@ function useStreamingCanvas(options) {
|
|
|
489
626
|
options.clock,
|
|
490
627
|
options.onPositionsChange
|
|
491
628
|
]);
|
|
492
|
-
const pushStreamUpdate = (0,
|
|
629
|
+
const pushStreamUpdate = (0, import_react5.useCallback)(
|
|
493
630
|
(nodes, edges, currentPositions) => {
|
|
494
631
|
managerRef.current?.pushStreamUpdate(nodes, edges, currentPositions);
|
|
495
632
|
},
|
|
496
633
|
[]
|
|
497
634
|
);
|
|
498
|
-
const flush = (0,
|
|
635
|
+
const flush = (0, import_react5.useCallback)(
|
|
499
636
|
(nodes, edges, currentPositions) => {
|
|
500
637
|
managerRef.current?.flush(nodes, edges, currentPositions);
|
|
501
638
|
},
|
|
@@ -508,13 +645,13 @@ function useStreamingCanvas(options) {
|
|
|
508
645
|
}
|
|
509
646
|
|
|
510
647
|
// src/canvas/useCanvasGraph.ts
|
|
511
|
-
var
|
|
648
|
+
var import_react6 = require("react");
|
|
512
649
|
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,
|
|
650
|
+
const [nodes, setNodesState] = (0, import_react6.useState)(options.initialNodes ?? []);
|
|
651
|
+
const [edges, setEdgesState] = (0, import_react6.useState)(options.initialEdges ?? []);
|
|
652
|
+
const baselineNodesRef = (0, import_react6.useRef)(options.initialNodes ?? []);
|
|
653
|
+
const baselineEdgesRef = (0, import_react6.useRef)(options.initialEdges ?? []);
|
|
654
|
+
const setNodes = (0, import_react6.useCallback)(
|
|
518
655
|
(updater) => {
|
|
519
656
|
setNodesState((prev) => {
|
|
520
657
|
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
@@ -524,7 +661,7 @@ function useCanvasGraph(options = {}) {
|
|
|
524
661
|
},
|
|
525
662
|
[options.onNodesChange]
|
|
526
663
|
);
|
|
527
|
-
const setEdges = (0,
|
|
664
|
+
const setEdges = (0, import_react6.useCallback)(
|
|
528
665
|
(updater) => {
|
|
529
666
|
setEdgesState((prev) => {
|
|
530
667
|
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
@@ -534,13 +671,13 @@ function useCanvasGraph(options = {}) {
|
|
|
534
671
|
},
|
|
535
672
|
[options.onEdgesChange]
|
|
536
673
|
);
|
|
537
|
-
const addNode = (0,
|
|
674
|
+
const addNode = (0, import_react6.useCallback)(
|
|
538
675
|
(node) => {
|
|
539
676
|
setNodes((prev) => [...prev, node]);
|
|
540
677
|
},
|
|
541
678
|
[setNodes]
|
|
542
679
|
);
|
|
543
|
-
const removeNodes = (0,
|
|
680
|
+
const removeNodes = (0, import_react6.useCallback)(
|
|
544
681
|
(ids) => {
|
|
545
682
|
const idSet = new Set(ids);
|
|
546
683
|
setNodes((prev) => prev.filter((n) => !idSet.has(n.id)));
|
|
@@ -548,7 +685,7 @@ function useCanvasGraph(options = {}) {
|
|
|
548
685
|
},
|
|
549
686
|
[setNodes, setEdges]
|
|
550
687
|
);
|
|
551
|
-
const updateNodeData = (0,
|
|
688
|
+
const updateNodeData = (0, import_react6.useCallback)(
|
|
552
689
|
(id, patch) => {
|
|
553
690
|
setNodes(
|
|
554
691
|
(prev) => prev.map((node) => {
|
|
@@ -562,7 +699,7 @@ function useCanvasGraph(options = {}) {
|
|
|
562
699
|
},
|
|
563
700
|
[setNodes]
|
|
564
701
|
);
|
|
565
|
-
const updateNodePosition = (0,
|
|
702
|
+
const updateNodePosition = (0, import_react6.useCallback)(
|
|
566
703
|
(id, position) => {
|
|
567
704
|
setNodes(
|
|
568
705
|
(prev) => prev.map((node) => {
|
|
@@ -576,24 +713,24 @@ function useCanvasGraph(options = {}) {
|
|
|
576
713
|
},
|
|
577
714
|
[setNodes]
|
|
578
715
|
);
|
|
579
|
-
const addEdge = (0,
|
|
716
|
+
const addEdge = (0, import_react6.useCallback)(
|
|
580
717
|
(edge) => {
|
|
581
718
|
setEdges((prev) => [...prev, edge]);
|
|
582
719
|
},
|
|
583
720
|
[setEdges]
|
|
584
721
|
);
|
|
585
|
-
const removeEdges = (0,
|
|
722
|
+
const removeEdges = (0, import_react6.useCallback)(
|
|
586
723
|
(ids) => {
|
|
587
724
|
const idSet = new Set(ids);
|
|
588
725
|
setEdges((prev) => prev.filter((e) => !idSet.has(e.id)));
|
|
589
726
|
},
|
|
590
727
|
[setEdges]
|
|
591
728
|
);
|
|
592
|
-
const resetBaseline = (0,
|
|
729
|
+
const resetBaseline = (0, import_react6.useCallback)(() => {
|
|
593
730
|
baselineNodesRef.current = nodes;
|
|
594
731
|
baselineEdgesRef.current = edges;
|
|
595
732
|
}, [nodes, edges]);
|
|
596
|
-
const getDifferences = (0,
|
|
733
|
+
const getDifferences = (0, import_react6.useCallback)(() => {
|
|
597
734
|
const currentNodesMap = new Map(nodes.map((n) => [n.id, n]));
|
|
598
735
|
const currentEdgesMap = new Map(edges.map((e) => [e.id, e]));
|
|
599
736
|
const baselineNodesMap = new Map(baselineNodesRef.current.map((n) => [n.id, n]));
|
|
@@ -643,22 +780,22 @@ function useCanvasGraph(options = {}) {
|
|
|
643
780
|
}
|
|
644
781
|
|
|
645
782
|
// src/canvas/useCanvasLayout.ts
|
|
646
|
-
var
|
|
647
|
-
var
|
|
783
|
+
var import_react7 = require("react");
|
|
784
|
+
var import_canvas3 = require("@pixerate/editor/canvas");
|
|
648
785
|
function useCanvasLayout(options) {
|
|
649
786
|
const { nodes, edges, setNodes, getNodesBounds, screenToFlowPosition } = options;
|
|
650
|
-
const applyLayout = (0,
|
|
787
|
+
const applyLayout = (0, import_react7.useCallback)(
|
|
651
788
|
(layoutOptions = {}) => {
|
|
652
|
-
const layouted = (0,
|
|
789
|
+
const layouted = (0, import_canvas3.getLayoutedNodes)(nodes, edges, getNodesBounds, layoutOptions);
|
|
653
790
|
setNodes(layouted);
|
|
654
791
|
return layouted;
|
|
655
792
|
},
|
|
656
793
|
[nodes, edges, getNodesBounds, setNodes]
|
|
657
794
|
);
|
|
658
|
-
const applyIncrementalLayout = (0,
|
|
795
|
+
const applyIncrementalLayout = (0, import_react7.useCallback)(
|
|
659
796
|
(incrementalOptions = {}) => {
|
|
660
797
|
const storedPositions = incrementalOptions.storedPositions ?? Object.fromEntries(nodes.map((n) => [n.id, n.position]));
|
|
661
|
-
const blended = (0,
|
|
798
|
+
const blended = (0, import_canvas3.ensureLayout)(nodes, edges, {
|
|
662
799
|
...incrementalOptions,
|
|
663
800
|
storedPositions
|
|
664
801
|
});
|
|
@@ -667,7 +804,7 @@ function useCanvasLayout(options) {
|
|
|
667
804
|
},
|
|
668
805
|
[nodes, edges, setNodes]
|
|
669
806
|
);
|
|
670
|
-
const center = (0,
|
|
807
|
+
const center = (0, import_react7.useCallback)(
|
|
671
808
|
(screenDimensions) => {
|
|
672
809
|
if (!screenToFlowPosition || !getNodesBounds) {
|
|
673
810
|
console.warn(
|
|
@@ -675,12 +812,12 @@ function useCanvasLayout(options) {
|
|
|
675
812
|
);
|
|
676
813
|
return;
|
|
677
814
|
}
|
|
678
|
-
const centered = (0,
|
|
815
|
+
const centered = (0, import_canvas3.centerNodes)(nodes, screenToFlowPosition, getNodesBounds, screenDimensions);
|
|
679
816
|
setNodes(centered);
|
|
680
817
|
},
|
|
681
818
|
[nodes, screenToFlowPosition, getNodesBounds, setNodes]
|
|
682
819
|
);
|
|
683
|
-
const getPlacementPosition = (0,
|
|
820
|
+
const getPlacementPosition = (0, import_react7.useCallback)(
|
|
684
821
|
(size, side = "right", nearNodeId, placementOptions = {}) => {
|
|
685
822
|
const rects = {};
|
|
686
823
|
for (const node of nodes) {
|
|
@@ -693,7 +830,7 @@ function useCanvasLayout(options) {
|
|
|
693
830
|
height
|
|
694
831
|
};
|
|
695
832
|
}
|
|
696
|
-
return (0,
|
|
833
|
+
return (0, import_canvas3.placeBeside)(rects, size, side, nearNodeId, placementOptions);
|
|
697
834
|
},
|
|
698
835
|
[nodes]
|
|
699
836
|
);
|
|
@@ -702,22 +839,22 @@ function useCanvasLayout(options) {
|
|
|
702
839
|
applyIncrementalLayout,
|
|
703
840
|
center,
|
|
704
841
|
getPlacementPosition,
|
|
705
|
-
getCenteredNodePosition:
|
|
842
|
+
getCenteredNodePosition: import_canvas3.getCenteredNodePosition
|
|
706
843
|
};
|
|
707
844
|
}
|
|
708
845
|
|
|
709
846
|
// src/canvas/useCanvasClipboard.ts
|
|
710
|
-
var
|
|
711
|
-
var
|
|
847
|
+
var import_react8 = require("react");
|
|
848
|
+
var import_canvas4 = require("@pixerate/editor/canvas");
|
|
712
849
|
function useCanvasClipboard(options = {}) {
|
|
713
|
-
const copySelectedNodes = (0,
|
|
850
|
+
const copySelectedNodes = (0, import_react8.useCallback)(
|
|
714
851
|
(selectedNodes, connectedEdges, event) => {
|
|
715
852
|
const native = event && "nativeEvent" in event ? event.nativeEvent : event;
|
|
716
|
-
if (native && (0,
|
|
853
|
+
if (native && (0, import_canvas4.isEventFromTextInput)(native)) {
|
|
717
854
|
return false;
|
|
718
855
|
}
|
|
719
856
|
if (selectedNodes.length === 0) return false;
|
|
720
|
-
const serialized = (0,
|
|
857
|
+
const serialized = (0, import_canvas4.serializeCanvasNodes)(selectedNodes, connectedEdges);
|
|
721
858
|
const clipboardData = event?.clipboardData || native?.clipboardData;
|
|
722
859
|
if (clipboardData) {
|
|
723
860
|
clipboardData.setData("application/json", serialized);
|
|
@@ -731,10 +868,10 @@ function useCanvasClipboard(options = {}) {
|
|
|
731
868
|
},
|
|
732
869
|
[]
|
|
733
870
|
);
|
|
734
|
-
const handlePasteEvent = (0,
|
|
871
|
+
const handlePasteEvent = (0, import_react8.useCallback)(
|
|
735
872
|
async (event) => {
|
|
736
873
|
const native = "nativeEvent" in event ? event.nativeEvent : event;
|
|
737
|
-
if ((0,
|
|
874
|
+
if ((0, import_canvas4.isEventFromTextInput)(native)) {
|
|
738
875
|
return false;
|
|
739
876
|
}
|
|
740
877
|
const clipboardData = native?.clipboardData || event?.clipboardData;
|
|
@@ -745,24 +882,24 @@ function useCanvasClipboard(options = {}) {
|
|
|
745
882
|
};
|
|
746
883
|
const jsonText = clipboardData.getData("application/json");
|
|
747
884
|
if (jsonText) {
|
|
748
|
-
const parsed = (0,
|
|
885
|
+
const parsed = (0, import_canvas4.parseCanvasClipboardData)(jsonText);
|
|
749
886
|
if (parsed && parsed.nodes.length > 0) {
|
|
750
887
|
prevent();
|
|
751
|
-
const remapped = (0,
|
|
888
|
+
const remapped = (0, import_canvas4.remapPastedNodes)(parsed.nodes, parsed.edges);
|
|
752
889
|
await options.onPasteNodes?.(remapped.nodes, remapped.edges);
|
|
753
890
|
return true;
|
|
754
891
|
}
|
|
755
892
|
}
|
|
756
893
|
const text = clipboardData.getData("text/plain")?.trim();
|
|
757
894
|
if (text) {
|
|
758
|
-
const parsed = (0,
|
|
895
|
+
const parsed = (0, import_canvas4.parseCanvasClipboardData)(text);
|
|
759
896
|
if (parsed && parsed.nodes.length > 0) {
|
|
760
897
|
prevent();
|
|
761
|
-
const remapped = (0,
|
|
898
|
+
const remapped = (0, import_canvas4.remapPastedNodes)(parsed.nodes, parsed.edges);
|
|
762
899
|
await options.onPasteNodes?.(remapped.nodes, remapped.edges);
|
|
763
900
|
return true;
|
|
764
901
|
}
|
|
765
|
-
if ((0,
|
|
902
|
+
if ((0, import_canvas4.isValidUrl)(text)) {
|
|
766
903
|
prevent();
|
|
767
904
|
options.onPasteUrl?.(text);
|
|
768
905
|
return true;
|
|
@@ -784,8 +921,8 @@ function useCanvasClipboard(options = {}) {
|
|
|
784
921
|
}
|
|
785
922
|
|
|
786
923
|
// src/canvas/useCanvasShortcuts.ts
|
|
787
|
-
var
|
|
788
|
-
var
|
|
924
|
+
var import_react9 = require("react");
|
|
925
|
+
var import_canvas5 = require("@pixerate/editor/canvas");
|
|
789
926
|
function useCanvasShortcuts(options = {}) {
|
|
790
927
|
const {
|
|
791
928
|
targetElement,
|
|
@@ -803,13 +940,13 @@ function useCanvasShortcuts(options = {}) {
|
|
|
803
940
|
onFitView,
|
|
804
941
|
getSelectedNodes
|
|
805
942
|
} = options;
|
|
806
|
-
(0,
|
|
943
|
+
(0, import_react9.useEffect)(() => {
|
|
807
944
|
if (!enabled) return;
|
|
808
945
|
const target = targetElement ?? (typeof window !== "undefined" ? window : null);
|
|
809
946
|
if (!target) return;
|
|
810
947
|
function handleKeyDown(event) {
|
|
811
948
|
const keyboardEvent = event;
|
|
812
|
-
if ((0,
|
|
949
|
+
if ((0, import_canvas5.isEventFromTextInput)(keyboardEvent)) {
|
|
813
950
|
return;
|
|
814
951
|
}
|
|
815
952
|
const isMac = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
@@ -888,7 +1025,7 @@ function useCanvasShortcuts(options = {}) {
|
|
|
888
1025
|
}
|
|
889
1026
|
|
|
890
1027
|
// src/canvas/useCanvasDocking.ts
|
|
891
|
-
var
|
|
1028
|
+
var import_react10 = require("react");
|
|
892
1029
|
function useCanvasDocking(options = {}) {
|
|
893
1030
|
const {
|
|
894
1031
|
strategy = "center-point",
|
|
@@ -898,22 +1035,22 @@ function useCanvasDocking(options = {}) {
|
|
|
898
1035
|
onDockLeave,
|
|
899
1036
|
onDockDrop
|
|
900
1037
|
} = options;
|
|
901
|
-
const activeDockTargetRef = (0,
|
|
902
|
-
const isDockable = (0,
|
|
1038
|
+
const activeDockTargetRef = (0, import_react10.useRef)(null);
|
|
1039
|
+
const isDockable = (0, import_react10.useCallback)(
|
|
903
1040
|
(node) => {
|
|
904
1041
|
if (!dockableTypes || dockableTypes.length === 0) return true;
|
|
905
1042
|
return !!node.type && dockableTypes.includes(node.type);
|
|
906
1043
|
},
|
|
907
1044
|
[dockableTypes]
|
|
908
1045
|
);
|
|
909
|
-
const isTarget = (0,
|
|
1046
|
+
const isTarget = (0, import_react10.useCallback)(
|
|
910
1047
|
(node) => {
|
|
911
1048
|
if (!targetTypes || targetTypes.length === 0) return true;
|
|
912
1049
|
return !!node.type && targetTypes.includes(node.type);
|
|
913
1050
|
},
|
|
914
1051
|
[targetTypes]
|
|
915
1052
|
);
|
|
916
|
-
const findDockTarget = (0,
|
|
1053
|
+
const findDockTarget = (0, import_react10.useCallback)(
|
|
917
1054
|
(draggedNode, candidates, cursorPos) => {
|
|
918
1055
|
if (!isDockable(draggedNode)) return null;
|
|
919
1056
|
const draggedWidth = draggedNode.measured?.width ?? draggedNode.width ?? 200;
|
|
@@ -972,7 +1109,7 @@ function useCanvasDocking(options = {}) {
|
|
|
972
1109
|
},
|
|
973
1110
|
[isDockable, isTarget, strategy]
|
|
974
1111
|
);
|
|
975
|
-
const updateDragOver = (0,
|
|
1112
|
+
const updateDragOver = (0, import_react10.useCallback)(
|
|
976
1113
|
(draggedNode, candidates, cursorPos) => {
|
|
977
1114
|
const target = findDockTarget(draggedNode, candidates, cursorPos);
|
|
978
1115
|
if (target?.id !== activeDockTargetRef.current?.id) {
|
|
@@ -987,7 +1124,7 @@ function useCanvasDocking(options = {}) {
|
|
|
987
1124
|
},
|
|
988
1125
|
[findDockTarget, onDockHover, onDockLeave]
|
|
989
1126
|
);
|
|
990
|
-
const finalizeDock = (0,
|
|
1127
|
+
const finalizeDock = (0, import_react10.useCallback)(
|
|
991
1128
|
(draggedNode) => {
|
|
992
1129
|
if (activeDockTargetRef.current) {
|
|
993
1130
|
onDockDrop?.(activeDockTargetRef.current, draggedNode);
|
|
@@ -1005,22 +1142,22 @@ function useCanvasDocking(options = {}) {
|
|
|
1005
1142
|
}
|
|
1006
1143
|
|
|
1007
1144
|
// src/canvas/useCanvasExplosion.ts
|
|
1008
|
-
var
|
|
1009
|
-
var
|
|
1145
|
+
var import_react11 = require("react");
|
|
1146
|
+
var import_canvas6 = require("@pixerate/editor/canvas");
|
|
1010
1147
|
function mergeById(base, updated) {
|
|
1011
1148
|
if (updated.length === 0) return [...base];
|
|
1012
1149
|
const byId = new Map(updated.map((n) => [n.id, n]));
|
|
1013
1150
|
return base.map((n) => byId.get(n.id) ?? n);
|
|
1014
1151
|
}
|
|
1015
1152
|
function useCanvasExplosion(target) {
|
|
1016
|
-
const snapshotsRef = (0,
|
|
1017
|
-
const explodeNode = (0,
|
|
1153
|
+
const snapshotsRef = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
|
|
1154
|
+
const explodeNode = (0, import_react11.useCallback)(
|
|
1018
1155
|
(parentNodeId, options) => {
|
|
1019
1156
|
const { nodes, edges, setNodes, setEdges } = target;
|
|
1020
1157
|
const parent = nodes.find((n) => n.id === parentNodeId);
|
|
1021
1158
|
if (!parent || options.childNodes.length === 0) return;
|
|
1022
1159
|
const originPos = { ...parent.position };
|
|
1023
|
-
const displacedMap = options.displacementStrategy === "directional" ? (0,
|
|
1160
|
+
const displacedMap = options.displacementStrategy === "directional" ? (0, import_canvas6.calculateDirectionalDisplacement)({
|
|
1024
1161
|
existingNodes: nodes,
|
|
1025
1162
|
originNode: parent,
|
|
1026
1163
|
childNodes: options.childNodes,
|
|
@@ -1046,7 +1183,7 @@ function useCanvasExplosion(target) {
|
|
|
1046
1183
|
if (options.childEdges && options.childEdges.length > 0) {
|
|
1047
1184
|
setEdges((prev) => [...prev, ...options.childEdges]);
|
|
1048
1185
|
}
|
|
1049
|
-
const trajectory = options.trajectory ?? (0,
|
|
1186
|
+
const trajectory = options.trajectory ?? (0, import_canvas6.createFanOutTrajectory)();
|
|
1050
1187
|
const transitions = [];
|
|
1051
1188
|
options.childNodes.forEach((child, index) => {
|
|
1052
1189
|
const liveChild = mergedNodes.find((n) => n.id === child.id);
|
|
@@ -1070,13 +1207,13 @@ function useCanvasExplosion(target) {
|
|
|
1070
1207
|
node,
|
|
1071
1208
|
from: { ...node.position },
|
|
1072
1209
|
to: targetPos,
|
|
1073
|
-
trajectory:
|
|
1210
|
+
trajectory: import_canvas6.linearPositionTrajectory,
|
|
1074
1211
|
duration: options.duration ?? 400,
|
|
1075
1212
|
easing: options.easing
|
|
1076
1213
|
});
|
|
1077
1214
|
}
|
|
1078
1215
|
});
|
|
1079
|
-
(0,
|
|
1216
|
+
(0, import_canvas6.runMultiNodeTransition)(transitions, {
|
|
1080
1217
|
styleFormat: "object",
|
|
1081
1218
|
onUpdate: (updated) => setNodes(mergeById(mergedNodes, updated)),
|
|
1082
1219
|
onComplete: () => options.onComplete?.()
|
|
@@ -1084,7 +1221,7 @@ function useCanvasExplosion(target) {
|
|
|
1084
1221
|
},
|
|
1085
1222
|
[target]
|
|
1086
1223
|
);
|
|
1087
|
-
const collapseNode = (0,
|
|
1224
|
+
const collapseNode = (0, import_react11.useCallback)(
|
|
1088
1225
|
(parentNodeId, options = {}) => {
|
|
1089
1226
|
const { nodes, setNodes, setEdges } = target;
|
|
1090
1227
|
const snapshot = snapshotsRef.current.get(parentNodeId);
|
|
@@ -1115,11 +1252,11 @@ function useCanvasExplosion(target) {
|
|
|
1115
1252
|
to: disp.originalPosition,
|
|
1116
1253
|
duration: options.duration ?? 300,
|
|
1117
1254
|
easing: options.easing,
|
|
1118
|
-
trajectory:
|
|
1255
|
+
trajectory: import_canvas6.linearPositionTrajectory
|
|
1119
1256
|
});
|
|
1120
1257
|
}
|
|
1121
1258
|
});
|
|
1122
|
-
(0,
|
|
1259
|
+
(0, import_canvas6.runMultiNodeTransition)(transitions, {
|
|
1123
1260
|
styleFormat: "object",
|
|
1124
1261
|
onUpdate: (updated) => setNodes(mergeById(nodes, updated)),
|
|
1125
1262
|
onComplete: () => {
|
|
@@ -1141,16 +1278,16 @@ function useCanvasExplosion(target) {
|
|
|
1141
1278
|
}
|
|
1142
1279
|
|
|
1143
1280
|
// src/canvas/useCanvasArrange.ts
|
|
1144
|
-
var
|
|
1145
|
-
var
|
|
1281
|
+
var import_react12 = require("react");
|
|
1282
|
+
var import_canvas7 = require("@pixerate/editor/canvas");
|
|
1146
1283
|
function useCanvasArrange(options) {
|
|
1147
|
-
const [guides, setGuides] = (0,
|
|
1148
|
-
const nodesRef = (0,
|
|
1284
|
+
const [guides, setGuides] = (0, import_react12.useState)([]);
|
|
1285
|
+
const nodesRef = (0, import_react12.useRef)(options.nodes);
|
|
1149
1286
|
nodesRef.current = options.nodes;
|
|
1150
|
-
const optionsRef = (0,
|
|
1287
|
+
const optionsRef = (0, import_react12.useRef)(options);
|
|
1151
1288
|
optionsRef.current = options;
|
|
1152
|
-
const controller = (0,
|
|
1153
|
-
() => (0,
|
|
1289
|
+
const controller = (0, import_react12.useMemo)(
|
|
1290
|
+
() => (0, import_canvas7.createCanvasArrangeController)({
|
|
1154
1291
|
getNodes: () => nodesRef.current,
|
|
1155
1292
|
setNodes: (next) => {
|
|
1156
1293
|
nodesRef.current = next;
|
|
@@ -1177,19 +1314,19 @@ function useCanvasArrange(options) {
|
|
|
1177
1314
|
}),
|
|
1178
1315
|
[]
|
|
1179
1316
|
);
|
|
1180
|
-
return (0,
|
|
1317
|
+
return (0, import_react12.useMemo)(() => ({ ...controller, guides }), [controller, guides]);
|
|
1181
1318
|
}
|
|
1182
1319
|
function useCanvasArrangeShortcuts(options) {
|
|
1183
|
-
const optionsRef = (0,
|
|
1320
|
+
const optionsRef = (0, import_react12.useRef)(options);
|
|
1184
1321
|
optionsRef.current = options;
|
|
1185
1322
|
const { targetElement, enabled = true } = options;
|
|
1186
|
-
(0,
|
|
1323
|
+
(0, import_react12.useEffect)(() => {
|
|
1187
1324
|
if (!enabled) return;
|
|
1188
1325
|
const target = targetElement ?? (typeof window !== "undefined" ? window : null);
|
|
1189
1326
|
if (!target) return;
|
|
1190
1327
|
function handleKeyDown(event) {
|
|
1191
1328
|
const { arrange, scenes, bindings } = optionsRef.current;
|
|
1192
|
-
const action = (0,
|
|
1329
|
+
const action = (0, import_canvas7.matchArrangeShortcut)(event, bindings);
|
|
1193
1330
|
if (!action) return;
|
|
1194
1331
|
let handled = false;
|
|
1195
1332
|
if (action === "nextScene" || action === "previousScene") {
|
|
@@ -1208,27 +1345,27 @@ function useCanvasArrangeShortcuts(options) {
|
|
|
1208
1345
|
}
|
|
1209
1346
|
|
|
1210
1347
|
// src/canvas/useCanvasScenes.ts
|
|
1211
|
-
var
|
|
1212
|
-
var
|
|
1348
|
+
var import_react13 = require("react");
|
|
1349
|
+
var import_canvas8 = require("@pixerate/editor/canvas");
|
|
1213
1350
|
function useCanvasScenes(options = {}) {
|
|
1214
|
-
const optionsRef = (0,
|
|
1351
|
+
const optionsRef = (0, import_react13.useRef)(options);
|
|
1215
1352
|
optionsRef.current = options;
|
|
1216
|
-
const storeRef = (0,
|
|
1217
|
-
if (!storeRef.current) storeRef.current = options.store ?? new
|
|
1353
|
+
const storeRef = (0, import_react13.useRef)(null);
|
|
1354
|
+
if (!storeRef.current) storeRef.current = options.store ?? new import_canvas8.CanvasScenesStore(options);
|
|
1218
1355
|
const store = storeRef.current;
|
|
1219
|
-
const state = (0,
|
|
1356
|
+
const state = (0, import_react13.useSyncExternalStore)(
|
|
1220
1357
|
(listener) => store.subscribe(listener),
|
|
1221
1358
|
() => store.getState(),
|
|
1222
1359
|
() => store.getState()
|
|
1223
1360
|
);
|
|
1224
|
-
const actions = (0,
|
|
1361
|
+
const actions = (0, import_react13.useMemo)(() => {
|
|
1225
1362
|
const show = (scene) => {
|
|
1226
1363
|
if (!scene) return scene;
|
|
1227
1364
|
const o = optionsRef.current;
|
|
1228
1365
|
const provider = o.transitions?.provider;
|
|
1229
1366
|
const element = o.transitions?.element();
|
|
1230
1367
|
if (scene.transition && provider && element) {
|
|
1231
|
-
void (0,
|
|
1368
|
+
void (0, import_canvas8.transitionCanvasView)({ provider, transition: scene.transition, element, jump: () => o.setViewport?.(scene.viewport, { duration: 0 }) });
|
|
1232
1369
|
} else o.setViewport?.(scene.viewport, { duration: o.duration ?? 300 });
|
|
1233
1370
|
return scene;
|
|
1234
1371
|
};
|
|
@@ -1242,7 +1379,7 @@ function useCanvasScenes(options = {}) {
|
|
|
1242
1379
|
},
|
|
1243
1380
|
/** Saves a scene framing the given nodes in a container of `size`. */
|
|
1244
1381
|
captureNodes(nodes, ids, size, name, fit) {
|
|
1245
|
-
const viewport = (0,
|
|
1382
|
+
const viewport = (0, import_canvas8.fitViewportToNodes)(nodes, size, ids, fit);
|
|
1246
1383
|
return viewport ? store.add({ viewport, name, nodeIds: ids }) : void 0;
|
|
1247
1384
|
},
|
|
1248
1385
|
/** Replaces a scene's viewport with the live one. */
|
|
@@ -1274,15 +1411,15 @@ function useCanvasScenes(options = {}) {
|
|
|
1274
1411
|
}
|
|
1275
1412
|
|
|
1276
1413
|
// src/canvas/useCanvasCapture.ts
|
|
1277
|
-
var
|
|
1278
|
-
var
|
|
1279
|
-
var
|
|
1414
|
+
var import_react14 = require("react");
|
|
1415
|
+
var import_canvas9 = require("@pixerate/editor/canvas");
|
|
1416
|
+
var import_tools2 = require("@pixerate/editor/tools");
|
|
1280
1417
|
function useCanvasCapture(options) {
|
|
1281
|
-
const optionsRef = (0,
|
|
1418
|
+
const optionsRef = (0, import_react14.useRef)(options);
|
|
1282
1419
|
optionsRef.current = options;
|
|
1283
|
-
return (0,
|
|
1420
|
+
return (0, import_react14.useMemo)(() => {
|
|
1284
1421
|
const latest = () => optionsRef.current;
|
|
1285
|
-
return (0,
|
|
1422
|
+
return (0, import_canvas9.createCanvasCaptureToolProvider)({
|
|
1286
1423
|
...options,
|
|
1287
1424
|
element: () => {
|
|
1288
1425
|
const el = latest().element;
|
|
@@ -1292,14 +1429,14 @@ function useCanvasCapture(options) {
|
|
|
1292
1429
|
},
|
|
1293
1430
|
getViewport: () => latest().getViewport(),
|
|
1294
1431
|
getNodes: () => latest().getNodes(),
|
|
1295
|
-
getNodeRect: (node, nodes) => (latest().getNodeRect ??
|
|
1296
|
-
rasterize: (element, raster) => (latest().rasterize ??
|
|
1432
|
+
getNodeRect: (node, nodes) => (latest().getNodeRect ?? import_canvas9.canvasNodeCaptureRect)(node, nodes),
|
|
1433
|
+
rasterize: (element, raster) => (latest().rasterize ?? import_tools2.rasterizeElement)(element, raster)
|
|
1297
1434
|
});
|
|
1298
1435
|
}, [options.id, options.namespace]);
|
|
1299
1436
|
}
|
|
1300
1437
|
|
|
1301
1438
|
// src/canvas/CanvasGuidesLayer.tsx
|
|
1302
|
-
var
|
|
1439
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1303
1440
|
var DEFAULT_VIEWPORT = { x: 0, y: 0, zoom: 1 };
|
|
1304
1441
|
function CanvasGuidesLayer({
|
|
1305
1442
|
guides,
|
|
@@ -1312,7 +1449,7 @@ function CanvasGuidesLayer({
|
|
|
1312
1449
|
if (!guides || guides.length === 0) return null;
|
|
1313
1450
|
const sx = (x) => x * viewport.zoom + viewport.x;
|
|
1314
1451
|
const sy = (y) => y * viewport.zoom + viewport.y;
|
|
1315
|
-
return /* @__PURE__ */ (0,
|
|
1452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1316
1453
|
"svg",
|
|
1317
1454
|
{
|
|
1318
1455
|
className: `pixerate-canvas-guides ${className}`,
|
|
@@ -1329,7 +1466,7 @@ function CanvasGuidesLayer({
|
|
|
1329
1466
|
children: [
|
|
1330
1467
|
guides.map((guide, i) => {
|
|
1331
1468
|
const measuring = guide.kind === "measure" || guide.kind === "extension";
|
|
1332
|
-
return /* @__PURE__ */ (0,
|
|
1469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1333
1470
|
"line",
|
|
1334
1471
|
{
|
|
1335
1472
|
"data-kind": guide.kind,
|
|
@@ -1351,15 +1488,15 @@ function CanvasGuidesLayer({
|
|
|
1351
1488
|
const y = sy((guide.y1 + guide.y2) / 2);
|
|
1352
1489
|
const vertical = guide.orientation === "vertical";
|
|
1353
1490
|
const width = guide.label.length * 6.5 + 8;
|
|
1354
|
-
return /* @__PURE__ */ (0,
|
|
1491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1355
1492
|
"g",
|
|
1356
1493
|
{
|
|
1357
1494
|
className: "pixerate-canvas-guides__label",
|
|
1358
1495
|
"data-label": guide.label,
|
|
1359
1496
|
transform: `translate(${vertical ? x + 4 : x - width / 2} ${vertical ? y - 8 : y + 4})`,
|
|
1360
1497
|
children: [
|
|
1361
|
-
/* @__PURE__ */ (0,
|
|
1362
|
-
/* @__PURE__ */ (0,
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { width, height: 16, rx: 3, fill: measureColor }),
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1363
1500
|
"text",
|
|
1364
1501
|
{
|
|
1365
1502
|
x: width / 2,
|
|
@@ -1382,17 +1519,17 @@ function CanvasGuidesLayer({
|
|
|
1382
1519
|
}
|
|
1383
1520
|
|
|
1384
1521
|
// src/canvas/useCanvasDraw.ts
|
|
1385
|
-
var
|
|
1386
|
-
var
|
|
1522
|
+
var import_react15 = require("react");
|
|
1523
|
+
var import_canvas10 = require("@pixerate/editor/canvas");
|
|
1387
1524
|
function useCanvasDraw(options) {
|
|
1388
|
-
const nodesRef = (0,
|
|
1525
|
+
const nodesRef = (0, import_react15.useRef)(options.nodes);
|
|
1389
1526
|
nodesRef.current = options.nodes;
|
|
1390
|
-
const optionsRef = (0,
|
|
1527
|
+
const optionsRef = (0, import_react15.useRef)(options);
|
|
1391
1528
|
optionsRef.current = options;
|
|
1392
|
-
const [tool, setToolState] = (0,
|
|
1393
|
-
const [activeStroke, setActiveStroke] = (0,
|
|
1394
|
-
const controller = (0,
|
|
1395
|
-
() => (0,
|
|
1529
|
+
const [tool, setToolState] = (0, import_react15.useState)(options.initialTool ?? "select");
|
|
1530
|
+
const [activeStroke, setActiveStroke] = (0, import_react15.useState)(null);
|
|
1531
|
+
const controller = (0, import_react15.useMemo)(
|
|
1532
|
+
() => (0, import_canvas10.createCanvasDrawController)({
|
|
1396
1533
|
getNodes: () => nodesRef.current,
|
|
1397
1534
|
setNodes: (next) => {
|
|
1398
1535
|
nodesRef.current = next;
|
|
@@ -1413,13 +1550,13 @@ function useCanvasDraw(options) {
|
|
|
1413
1550
|
}),
|
|
1414
1551
|
[]
|
|
1415
1552
|
);
|
|
1416
|
-
const [style, setStyleState] = (0,
|
|
1417
|
-
(0,
|
|
1553
|
+
const [style, setStyleState] = (0, import_react15.useState)(controller.style);
|
|
1554
|
+
(0, import_react15.useEffect)(() => {
|
|
1418
1555
|
if (options.initialTool && options.initialTool !== controller.tool) {
|
|
1419
1556
|
controller.setTool(options.initialTool);
|
|
1420
1557
|
}
|
|
1421
1558
|
}, [options.initialTool, controller]);
|
|
1422
|
-
return (0,
|
|
1559
|
+
return (0, import_react15.useMemo)(
|
|
1423
1560
|
() => ({
|
|
1424
1561
|
tool,
|
|
1425
1562
|
style,
|
|
@@ -1440,9 +1577,9 @@ function useCanvasDraw(options) {
|
|
|
1440
1577
|
}
|
|
1441
1578
|
|
|
1442
1579
|
// src/canvas/CanvasDrawLayer.tsx
|
|
1443
|
-
var
|
|
1444
|
-
var
|
|
1445
|
-
var
|
|
1580
|
+
var import_react16 = require("react");
|
|
1581
|
+
var import_canvas11 = require("@pixerate/editor/canvas");
|
|
1582
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1446
1583
|
var DEFAULT_VIEWPORT2 = { x: 0, y: 0, zoom: 1 };
|
|
1447
1584
|
function CanvasDrawLayer({
|
|
1448
1585
|
draw,
|
|
@@ -1452,10 +1589,10 @@ function CanvasDrawLayer({
|
|
|
1452
1589
|
cursor,
|
|
1453
1590
|
eraserRadius = 12
|
|
1454
1591
|
}) {
|
|
1455
|
-
const svgRef = (0,
|
|
1456
|
-
const [spaceHeld, setSpaceHeld] = (0,
|
|
1457
|
-
const [eraserPos, setEraserPos] = (0,
|
|
1458
|
-
(0,
|
|
1592
|
+
const svgRef = (0, import_react16.useRef)(null);
|
|
1593
|
+
const [spaceHeld, setSpaceHeld] = (0, import_react16.useState)(false);
|
|
1594
|
+
const [eraserPos, setEraserPos] = (0, import_react16.useState)(null);
|
|
1595
|
+
(0, import_react16.useEffect)(() => {
|
|
1459
1596
|
function onKeyDown(e) {
|
|
1460
1597
|
if (e.code === "Space" && !e.repeat) {
|
|
1461
1598
|
const tag = e.target?.tagName;
|
|
@@ -1477,7 +1614,7 @@ function CanvasDrawLayer({
|
|
|
1477
1614
|
window.removeEventListener("keyup", onKeyUp);
|
|
1478
1615
|
};
|
|
1479
1616
|
}, []);
|
|
1480
|
-
const clientToFlow = (0,
|
|
1617
|
+
const clientToFlow = (0, import_react16.useCallback)(
|
|
1481
1618
|
(clientX, clientY) => {
|
|
1482
1619
|
if (!svgRef.current) return [0, 0];
|
|
1483
1620
|
const rect = svgRef.current.getBoundingClientRect();
|
|
@@ -1497,7 +1634,7 @@ function CanvasDrawLayer({
|
|
|
1497
1634
|
e.stopPropagation();
|
|
1498
1635
|
e.target.setPointerCapture?.(e.pointerId);
|
|
1499
1636
|
const flowPt = clientToFlow(e.clientX, e.clientY);
|
|
1500
|
-
draw.startStroke(flowPt, (0,
|
|
1637
|
+
draw.startStroke(flowPt, (0, import_canvas11.pointerPenSample)(e));
|
|
1501
1638
|
if (draw.tool === "eraser") {
|
|
1502
1639
|
setEraserPos([e.clientX, e.clientY]);
|
|
1503
1640
|
}
|
|
@@ -1512,7 +1649,7 @@ function CanvasDrawLayer({
|
|
|
1512
1649
|
e.stopPropagation();
|
|
1513
1650
|
const events = draw.style.brush !== void 0 ? e.nativeEvent.getCoalescedEvents?.() ?? [] : [];
|
|
1514
1651
|
for (const ev of events.length ? events : [e.nativeEvent]) {
|
|
1515
|
-
draw.continueStroke(clientToFlow(ev.clientX, ev.clientY), (0,
|
|
1652
|
+
draw.continueStroke(clientToFlow(ev.clientX, ev.clientY), (0, import_canvas11.pointerPenSample)(ev));
|
|
1516
1653
|
}
|
|
1517
1654
|
}
|
|
1518
1655
|
};
|
|
@@ -1530,11 +1667,11 @@ function CanvasDrawLayer({
|
|
|
1530
1667
|
setEraserPos(null);
|
|
1531
1668
|
};
|
|
1532
1669
|
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,
|
|
1670
|
+
const strokePath = draw.activeStroke ? (0, import_canvas11.strokePointsToPathData)(draw.activeStroke.points) : null;
|
|
1671
|
+
const activeGradient = draw.activeStroke ? (0, import_canvas11.resolveCanvasGradient)(draw.activeStroke.style.gradient ?? draw.activeStroke.style.color) : null;
|
|
1672
|
+
const resolvedGradientDef = activeGradient ? (0, import_canvas11.gradientToSvgDef)(activeGradient, "active-draw-stroke-gradient") : null;
|
|
1536
1673
|
const strokePaint = resolvedGradientDef ? `url(#${resolvedGradientDef.id})` : draw.activeStroke ? draw.activeStroke.style.color : "currentColor";
|
|
1537
|
-
return /* @__PURE__ */ (0,
|
|
1674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1538
1675
|
"svg",
|
|
1539
1676
|
{
|
|
1540
1677
|
ref: svgRef,
|
|
@@ -1556,11 +1693,11 @@ function CanvasDrawLayer({
|
|
|
1556
1693
|
onPointerUp: handlePointerUp,
|
|
1557
1694
|
onPointerLeave: handlePointerLeave,
|
|
1558
1695
|
children: [
|
|
1559
|
-
resolvedGradientDef && /* @__PURE__ */ (0,
|
|
1560
|
-
resolvedGradientDef.type === "linear" && /* @__PURE__ */ (0,
|
|
1561
|
-
resolvedGradientDef.type === "radial" && /* @__PURE__ */ (0,
|
|
1696
|
+
resolvedGradientDef && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("defs", { children: [
|
|
1697
|
+
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)) }),
|
|
1698
|
+
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
1699
|
] }),
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1700
|
+
/* @__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
1701
|
"path",
|
|
1565
1702
|
{
|
|
1566
1703
|
className: "pixerate-canvas-draw-active",
|
|
@@ -1573,7 +1710,7 @@ function CanvasDrawLayer({
|
|
|
1573
1710
|
strokeLinejoin: draw.activeStroke.style.join ?? "round"
|
|
1574
1711
|
}
|
|
1575
1712
|
) }),
|
|
1576
|
-
draw.tool === "eraser" && eraserPos && svgRef.current && /* @__PURE__ */ (0,
|
|
1713
|
+
draw.tool === "eraser" && eraserPos && svgRef.current && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1577
1714
|
"circle",
|
|
1578
1715
|
{
|
|
1579
1716
|
cx: eraserPos[0] - svgRef.current.getBoundingClientRect().left,
|
|
@@ -1592,20 +1729,20 @@ function CanvasDrawLayer({
|
|
|
1592
1729
|
}
|
|
1593
1730
|
|
|
1594
1731
|
// src/canvas/useCanvasMeasure.ts
|
|
1595
|
-
var
|
|
1596
|
-
var
|
|
1732
|
+
var import_react17 = require("react");
|
|
1733
|
+
var import_canvas12 = require("@pixerate/editor/canvas");
|
|
1597
1734
|
var EMPTY = { guides: [], target: null, selection: null };
|
|
1598
1735
|
function useCanvasMeasure(options) {
|
|
1599
1736
|
const { nodes, enabled = true, requireModifier = true, targetElement, rectOptions } = options;
|
|
1600
|
-
const [hoveredId, setHoveredId] = (0,
|
|
1601
|
-
const [modifier, setModifier] = (0,
|
|
1602
|
-
const optionsRef = (0,
|
|
1737
|
+
const [hoveredId, setHoveredId] = (0, import_react17.useState)(null);
|
|
1738
|
+
const [modifier, setModifier] = (0, import_react17.useState)(false);
|
|
1739
|
+
const optionsRef = (0, import_react17.useRef)(options);
|
|
1603
1740
|
optionsRef.current = options;
|
|
1604
|
-
(0,
|
|
1741
|
+
(0, import_react17.useEffect)(() => {
|
|
1605
1742
|
if (!enabled) return;
|
|
1606
1743
|
const target = targetElement ?? (typeof window !== "undefined" ? window : null);
|
|
1607
1744
|
if (!target) return;
|
|
1608
|
-
const onKey = (event) => setModifier((0,
|
|
1745
|
+
const onKey = (event) => setModifier((0, import_canvas12.isMeasureModifierHeld)(event));
|
|
1609
1746
|
const onBlur = () => setModifier(false);
|
|
1610
1747
|
target.addEventListener("keydown", onKey);
|
|
1611
1748
|
target.addEventListener("keyup", onKey);
|
|
@@ -1618,16 +1755,16 @@ function useCanvasMeasure(options) {
|
|
|
1618
1755
|
};
|
|
1619
1756
|
}, [enabled, targetElement]);
|
|
1620
1757
|
const active = enabled && (!requireModifier || modifier);
|
|
1621
|
-
const result = (0,
|
|
1758
|
+
const result = (0, import_react17.useMemo)(() => {
|
|
1622
1759
|
if (!active) return EMPTY;
|
|
1623
1760
|
const ids = optionsRef.current.getSelectedIds?.() ?? nodes.filter((n) => n.selected).map((n) => n.id);
|
|
1624
|
-
return (0,
|
|
1761
|
+
return (0, import_canvas12.measureSelection)(nodes, ids, hoveredId, rectOptions);
|
|
1625
1762
|
}, [active, nodes, hoveredId, rectOptions]);
|
|
1626
|
-
const onNodeMouseEnter = (0,
|
|
1763
|
+
const onNodeMouseEnter = (0, import_react17.useCallback)((event, node) => {
|
|
1627
1764
|
setHoveredId(node.id);
|
|
1628
1765
|
if (event && typeof event.altKey === "boolean") setModifier(event.altKey);
|
|
1629
1766
|
}, []);
|
|
1630
|
-
const onNodeMouseLeave = (0,
|
|
1767
|
+
const onNodeMouseLeave = (0, import_react17.useCallback)((_event, node) => {
|
|
1631
1768
|
setHoveredId((current) => current === node.id ? null : current);
|
|
1632
1769
|
}, []);
|
|
1633
1770
|
return {
|
|
@@ -1647,39 +1784,39 @@ function useCanvasMeasure(options) {
|
|
|
1647
1784
|
}
|
|
1648
1785
|
|
|
1649
1786
|
// src/canvas/index.ts
|
|
1650
|
-
var import_canvas26 = require("@pixerate/editor/canvas");
|
|
1651
1787
|
var import_canvas27 = require("@pixerate/editor/canvas");
|
|
1788
|
+
var import_canvas28 = require("@pixerate/editor/canvas");
|
|
1652
1789
|
|
|
1653
1790
|
// src/canvas/ShapeNode.tsx
|
|
1654
|
-
var
|
|
1791
|
+
var import_canvas15 = require("@pixerate/editor/canvas");
|
|
1655
1792
|
|
|
1656
1793
|
// src/canvas/useShapeBrushstroke.tsx
|
|
1657
|
-
var
|
|
1658
|
-
var
|
|
1659
|
-
var
|
|
1660
|
-
var ShapeNodeZoomContext = (0,
|
|
1794
|
+
var import_react18 = require("react");
|
|
1795
|
+
var import_canvas13 = require("@pixerate/editor/canvas");
|
|
1796
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1797
|
+
var ShapeNodeZoomContext = (0, import_react18.createContext)(1);
|
|
1661
1798
|
function ShapeNodeZoomProvider({ zoom, children }) {
|
|
1662
|
-
const bucket = (0,
|
|
1663
|
-
return /* @__PURE__ */ (0,
|
|
1799
|
+
const bucket = (0, import_canvas13.brushstrokeScaleBucket)(zoom);
|
|
1800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ShapeNodeZoomContext.Provider, { value: bucket, children });
|
|
1664
1801
|
}
|
|
1665
1802
|
function useShapeBrushstroke(shape, width, height, position) {
|
|
1666
|
-
const zoom = (0,
|
|
1667
|
-
const brushed = (0,
|
|
1803
|
+
const zoom = (0, import_react18.useContext)(ShapeNodeZoomContext);
|
|
1804
|
+
const brushed = (0, import_canvas13.isBrushedShape)(shape) ? shape : null;
|
|
1668
1805
|
const vb = brushed?.viewBox;
|
|
1669
1806
|
const nodeScale = vb && width && height && vb[2] > 0 && vb[3] > 0 ? Math.max(width / vb[2], height / vb[3]) : 1;
|
|
1670
1807
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
1671
|
-
const scale = (0,
|
|
1808
|
+
const scale = (0, import_canvas13.brushstrokeScaleBucket)(zoom * nodeScale, dpr);
|
|
1672
1809
|
const unit = vb && width && vb[2] > 0 ? width / vb[2] : 1;
|
|
1673
1810
|
const ox = Math.round((position?.x ?? 0) - (vb?.[0] ?? 0) * unit);
|
|
1674
1811
|
const oy = Math.round((position?.y ?? 0) - (vb?.[1] ?? 0) * unit);
|
|
1675
|
-
const [image, setImage] = (0,
|
|
1676
|
-
(0,
|
|
1812
|
+
const [image, setImage] = (0, import_react18.useState)(null);
|
|
1813
|
+
(0, import_react18.useEffect)(() => {
|
|
1677
1814
|
if (!brushed) {
|
|
1678
1815
|
setImage(null);
|
|
1679
1816
|
return;
|
|
1680
1817
|
}
|
|
1681
1818
|
let live = true;
|
|
1682
|
-
(0,
|
|
1819
|
+
(0, import_canvas13.renderShapeBrushstroke)(brushed, { scale, origin: { x: ox, y: oy }, unit }).then(
|
|
1683
1820
|
(img) => live && setImage(img),
|
|
1684
1821
|
(error) => {
|
|
1685
1822
|
if (!live) return;
|
|
@@ -1694,12 +1831,12 @@ function useShapeBrushstroke(shape, width, height, position) {
|
|
|
1694
1831
|
return image;
|
|
1695
1832
|
}
|
|
1696
1833
|
function useCanvasBrushes(options = {}) {
|
|
1697
|
-
const [state, setState] = (0,
|
|
1834
|
+
const [state, setState] = (0, import_react18.useState)({ brushes: [], loading: true, error: null });
|
|
1698
1835
|
const swatches = options.swatches ? JSON.stringify(options.swatches) : "";
|
|
1699
|
-
(0,
|
|
1836
|
+
(0, import_react18.useEffect)(() => {
|
|
1700
1837
|
let live = true;
|
|
1701
1838
|
const opts = swatches ? JSON.parse(swatches) : null;
|
|
1702
|
-
(0,
|
|
1839
|
+
(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
1840
|
(brushes) => live && setState({ brushes, loading: false, error: null }),
|
|
1704
1841
|
(error) => live && setState({ brushes: [], loading: false, error: error instanceof Error ? error.message : String(error) })
|
|
1705
1842
|
);
|
|
@@ -1707,19 +1844,19 @@ function useCanvasBrushes(options = {}) {
|
|
|
1707
1844
|
live = false;
|
|
1708
1845
|
};
|
|
1709
1846
|
}, [swatches]);
|
|
1710
|
-
return (0,
|
|
1847
|
+
return (0, import_react18.useMemo)(() => state, [state]);
|
|
1711
1848
|
}
|
|
1712
1849
|
|
|
1713
1850
|
// src/canvas/CanvasEffects.tsx
|
|
1714
|
-
var
|
|
1715
|
-
var
|
|
1851
|
+
var import_react24 = require("react");
|
|
1852
|
+
var import_canvas14 = require("@pixerate/editor/canvas");
|
|
1716
1853
|
|
|
1717
1854
|
// src/effects/useEffects.ts
|
|
1718
|
-
var
|
|
1855
|
+
var import_react19 = require("react");
|
|
1719
1856
|
function useEffectDescription(provider, effect) {
|
|
1720
|
-
const [state, setState] = (0,
|
|
1857
|
+
const [state, setState] = (0, import_react19.useState)({ key: "", description: null, error: null });
|
|
1721
1858
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1722
|
-
(0,
|
|
1859
|
+
(0, import_react19.useEffect)(() => {
|
|
1723
1860
|
if (!provider || !effect) return;
|
|
1724
1861
|
let live = true;
|
|
1725
1862
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1734,13 +1871,13 @@ function useEffectDescription(provider, effect) {
|
|
|
1734
1871
|
}
|
|
1735
1872
|
|
|
1736
1873
|
// src/effects/EffectThumbnail.tsx
|
|
1737
|
-
var
|
|
1874
|
+
var import_react20 = require("react");
|
|
1738
1875
|
var import_effects = require("@pixerate/editor/effects");
|
|
1739
|
-
var
|
|
1876
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1740
1877
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1741
|
-
const ref = (0,
|
|
1742
|
-
const [failed, setFailed] = (0,
|
|
1743
|
-
(0,
|
|
1878
|
+
const ref = (0, import_react20.useRef)(null);
|
|
1879
|
+
const [failed, setFailed] = (0, import_react20.useState)(effect.kind === "motion");
|
|
1880
|
+
(0, import_react20.useEffect)(() => {
|
|
1744
1881
|
if (effect.kind === "motion") return;
|
|
1745
1882
|
let live = true;
|
|
1746
1883
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1755,28 +1892,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1755
1892
|
live = false;
|
|
1756
1893
|
};
|
|
1757
1894
|
}, [provider, effect, width, height]);
|
|
1758
|
-
return /* @__PURE__ */ (0,
|
|
1895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1759
1896
|
"div",
|
|
1760
1897
|
{
|
|
1761
1898
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1762
1899
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1763
1900
|
"data-effect-thumbnail": effect.id,
|
|
1764
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1901
|
+
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
1902
|
}
|
|
1766
1903
|
);
|
|
1767
1904
|
}
|
|
1768
1905
|
|
|
1769
1906
|
// src/effects/EffectsBrowser.tsx
|
|
1770
|
-
var
|
|
1907
|
+
var import_react21 = require("react");
|
|
1771
1908
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1772
|
-
var
|
|
1909
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1773
1910
|
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,
|
|
1911
|
+
const [all, setAll] = (0, import_react21.useState)([]);
|
|
1912
|
+
const [query, setQuery] = (0, import_react21.useState)("");
|
|
1913
|
+
const [category, setCategory] = (0, import_react21.useState)("");
|
|
1914
|
+
const [use, setUse] = (0, import_react21.useState)("");
|
|
1915
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
1916
|
+
(0, import_react21.useEffect)(() => {
|
|
1780
1917
|
if (!provider) return setAll([]);
|
|
1781
1918
|
let live = true;
|
|
1782
1919
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1787,8 +1924,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1787
1924
|
live = false;
|
|
1788
1925
|
};
|
|
1789
1926
|
}, [provider]);
|
|
1790
|
-
const [found, setFound] = (0,
|
|
1791
|
-
(0,
|
|
1927
|
+
const [found, setFound] = (0, import_react21.useState)([]);
|
|
1928
|
+
(0, import_react21.useEffect)(() => {
|
|
1792
1929
|
if (!provider) return setFound([]);
|
|
1793
1930
|
let live = true;
|
|
1794
1931
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1797,14 +1934,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1797
1934
|
};
|
|
1798
1935
|
}, [provider, query, category, use]);
|
|
1799
1936
|
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,
|
|
1937
|
+
const categories = (0, import_react21.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1801
1938
|
const shown = found.filter(allowed);
|
|
1802
1939
|
if (!provider)
|
|
1803
|
-
return /* @__PURE__ */ (0,
|
|
1804
|
-
return /* @__PURE__ */ (0,
|
|
1805
|
-
title && /* @__PURE__ */ (0,
|
|
1806
|
-
/* @__PURE__ */ (0,
|
|
1807
|
-
/* @__PURE__ */ (0,
|
|
1940
|
+
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." });
|
|
1941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
1942
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
1943
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1808
1945
|
"input",
|
|
1809
1946
|
{
|
|
1810
1947
|
type: "search",
|
|
@@ -1815,17 +1952,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1815
1952
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1816
1953
|
}
|
|
1817
1954
|
),
|
|
1818
|
-
/* @__PURE__ */ (0,
|
|
1819
|
-
/* @__PURE__ */ (0,
|
|
1820
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
1955
|
+
/* @__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: [
|
|
1956
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "All categories" }),
|
|
1957
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: c, children: c }, c))
|
|
1821
1958
|
] }),
|
|
1822
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1823
|
-
/* @__PURE__ */ (0,
|
|
1824
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
1959
|
+
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: [
|
|
1960
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "Any use" }),
|
|
1961
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1825
1962
|
] })
|
|
1826
1963
|
] }),
|
|
1827
|
-
error && /* @__PURE__ */ (0,
|
|
1828
|
-
/* @__PURE__ */ (0,
|
|
1964
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
1965
|
+
/* @__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
1966
|
"button",
|
|
1830
1967
|
{
|
|
1831
1968
|
type: "button",
|
|
@@ -1834,25 +1971,25 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1834
1971
|
"data-effect-id": e.id,
|
|
1835
1972
|
onClick: () => onPick(e),
|
|
1836
1973
|
children: [
|
|
1837
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1838
|
-
/* @__PURE__ */ (0,
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1974
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
1975
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
1976
|
+
/* @__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
1977
|
]
|
|
1841
1978
|
}
|
|
1842
1979
|
) }, e.id)) }),
|
|
1843
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
1980
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
1844
1981
|
] });
|
|
1845
1982
|
}
|
|
1846
1983
|
|
|
1847
1984
|
// src/effects/EffectParameters.tsx
|
|
1848
|
-
var
|
|
1985
|
+
var import_react23 = __toESM(require("react"), 1);
|
|
1849
1986
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1850
1987
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1851
1988
|
|
|
1852
1989
|
// src/parameters/fields.tsx
|
|
1853
|
-
var
|
|
1990
|
+
var import_react22 = require("react");
|
|
1854
1991
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1855
|
-
var
|
|
1992
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1856
1993
|
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
1994
|
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
1995
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
@@ -1876,7 +2013,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
1876
2013
|
onKeyDown: keyDown,
|
|
1877
2014
|
...rest
|
|
1878
2015
|
};
|
|
1879
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
2016
|
+
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
2017
|
}
|
|
1881
2018
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
1882
2019
|
function ParameterNumberInput({
|
|
@@ -1887,8 +2024,8 @@ function ParameterNumberInput({
|
|
|
1887
2024
|
id,
|
|
1888
2025
|
"aria-label": ariaLabel
|
|
1889
2026
|
}) {
|
|
1890
|
-
return /* @__PURE__ */ (0,
|
|
1891
|
-
/* @__PURE__ */ (0,
|
|
2027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2028
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1892
2029
|
ParameterCommitInput,
|
|
1893
2030
|
{
|
|
1894
2031
|
id,
|
|
@@ -1910,21 +2047,21 @@ function ParameterNumberInput({
|
|
|
1910
2047
|
}
|
|
1911
2048
|
}
|
|
1912
2049
|
),
|
|
1913
|
-
field.unit && /* @__PURE__ */ (0,
|
|
2050
|
+
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
2051
|
] });
|
|
1915
2052
|
}
|
|
1916
2053
|
function ParameterSlider(props) {
|
|
1917
2054
|
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
1918
|
-
const dragging = (0,
|
|
2055
|
+
const dragging = (0, import_react22.useRef)(false);
|
|
1919
2056
|
const end = () => {
|
|
1920
2057
|
if (!dragging.current) return;
|
|
1921
2058
|
dragging.current = false;
|
|
1922
2059
|
onGestureEnd?.();
|
|
1923
2060
|
};
|
|
1924
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2061
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterNumberInput, { ...props });
|
|
1925
2062
|
const step = (0, import_parameters.parameterStep)(field);
|
|
1926
|
-
return /* @__PURE__ */ (0,
|
|
1927
|
-
/* @__PURE__ */ (0,
|
|
2063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1928
2065
|
"input",
|
|
1929
2066
|
{
|
|
1930
2067
|
type: "range",
|
|
@@ -1947,11 +2084,11 @@ function ParameterSlider(props) {
|
|
|
1947
2084
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
1948
2085
|
}
|
|
1949
2086
|
),
|
|
1950
|
-
/* @__PURE__ */ (0,
|
|
2087
|
+
/* @__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
2088
|
] });
|
|
1952
2089
|
}
|
|
1953
2090
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
1954
|
-
return /* @__PURE__ */ (0,
|
|
2091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1955
2092
|
"button",
|
|
1956
2093
|
{
|
|
1957
2094
|
type: "button",
|
|
@@ -1962,7 +2099,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1962
2099
|
disabled: disabled || field.readOnly,
|
|
1963
2100
|
onClick: () => onChange(!value),
|
|
1964
2101
|
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,
|
|
2102
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1966
2103
|
"span",
|
|
1967
2104
|
{
|
|
1968
2105
|
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 +2112,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1975
2112
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
1976
2113
|
const off = disabled || field.readOnly;
|
|
1977
2114
|
if (field.control === "segmented") {
|
|
1978
|
-
return /* @__PURE__ */ (0,
|
|
2115
|
+
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
2116
|
"button",
|
|
1980
2117
|
{
|
|
1981
2118
|
type: "button",
|
|
@@ -1991,7 +2128,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1991
2128
|
)) });
|
|
1992
2129
|
}
|
|
1993
2130
|
const index = options.findIndex((o) => o.value === value);
|
|
1994
|
-
return /* @__PURE__ */ (0,
|
|
2131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1995
2132
|
"select",
|
|
1996
2133
|
{
|
|
1997
2134
|
id,
|
|
@@ -2003,12 +2140,12 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2003
2140
|
if (option) onChange(option.value);
|
|
2004
2141
|
},
|
|
2005
2142
|
className: parameterInputClass,
|
|
2006
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
2143
|
+
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
2144
|
}
|
|
2008
2145
|
);
|
|
2009
2146
|
}
|
|
2010
2147
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2011
|
-
const picking = (0,
|
|
2148
|
+
const picking = (0, import_react22.useRef)(false);
|
|
2012
2149
|
const alpha = !!field.alpha;
|
|
2013
2150
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2014
2151
|
const rgb = hex.slice(0, 7);
|
|
@@ -2024,11 +2161,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2024
2161
|
picking.current = false;
|
|
2025
2162
|
onGestureEnd?.();
|
|
2026
2163
|
};
|
|
2027
|
-
return /* @__PURE__ */ (0,
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2029
|
-
/* @__PURE__ */ (0,
|
|
2030
|
-
/* @__PURE__ */ (0,
|
|
2031
|
-
/* @__PURE__ */ (0,
|
|
2164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2165
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2166
|
+
/* @__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: [
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2032
2169
|
"input",
|
|
2033
2170
|
{
|
|
2034
2171
|
type: "color",
|
|
@@ -2044,7 +2181,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2044
2181
|
}
|
|
2045
2182
|
)
|
|
2046
2183
|
] }),
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2048
2185
|
ParameterCommitInput,
|
|
2049
2186
|
{
|
|
2050
2187
|
id,
|
|
@@ -2060,7 +2197,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2060
2197
|
}
|
|
2061
2198
|
)
|
|
2062
2199
|
] }),
|
|
2063
|
-
alpha && /* @__PURE__ */ (0,
|
|
2200
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2064
2201
|
"input",
|
|
2065
2202
|
{
|
|
2066
2203
|
type: "range",
|
|
@@ -2078,10 +2215,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2078
2215
|
onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
|
|
2079
2216
|
}
|
|
2080
2217
|
),
|
|
2081
|
-
field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2218
|
+
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
2219
|
const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
|
|
2083
2220
|
if (!swatch) return null;
|
|
2084
|
-
return /* @__PURE__ */ (0,
|
|
2221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2085
2222
|
"button",
|
|
2086
2223
|
{
|
|
2087
2224
|
type: "button",
|
|
@@ -2100,11 +2237,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2100
2237
|
}
|
|
2101
2238
|
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
2102
2239
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2103
|
-
return /* @__PURE__ */ (0,
|
|
2240
|
+
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
2241
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2105
|
-
return /* @__PURE__ */ (0,
|
|
2106
|
-
/* @__PURE__ */ (0,
|
|
2107
|
-
/* @__PURE__ */ (0,
|
|
2242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2244
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2108
2245
|
ParameterNumberInput,
|
|
2109
2246
|
{
|
|
2110
2247
|
field: component,
|
|
@@ -2121,11 +2258,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2121
2258
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2122
2259
|
const off = disabled || field.readOnly;
|
|
2123
2260
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2124
|
-
return /* @__PURE__ */ (0,
|
|
2125
|
-
/* @__PURE__ */ (0,
|
|
2126
|
-
/* @__PURE__ */ (0,
|
|
2127
|
-
/* @__PURE__ */ (0,
|
|
2128
|
-
/* @__PURE__ */ (0,
|
|
2261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2262
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2263
|
+
/* @__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" }) }),
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
2265
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2129
2266
|
ParameterCommitInput,
|
|
2130
2267
|
{
|
|
2131
2268
|
id,
|
|
@@ -2136,10 +2273,10 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2136
2273
|
onCommit: (text) => onChange(text.trim())
|
|
2137
2274
|
}
|
|
2138
2275
|
),
|
|
2139
|
-
/* @__PURE__ */ (0,
|
|
2140
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
2276
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex gap-1", children: [
|
|
2277
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
|
|
2141
2278
|
"Choose file\u2026",
|
|
2142
|
-
/* @__PURE__ */ (0,
|
|
2279
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2143
2280
|
"input",
|
|
2144
2281
|
{
|
|
2145
2282
|
type: "file",
|
|
@@ -2155,11 +2292,11 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2155
2292
|
}
|
|
2156
2293
|
)
|
|
2157
2294
|
] }),
|
|
2158
|
-
value && /* @__PURE__ */ (0,
|
|
2295
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
|
|
2159
2296
|
] })
|
|
2160
2297
|
] })
|
|
2161
2298
|
] }),
|
|
2162
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
2299
|
+
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
2300
|
"button",
|
|
2164
2301
|
{
|
|
2165
2302
|
type: "button",
|
|
@@ -2169,14 +2306,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2169
2306
|
disabled: off,
|
|
2170
2307
|
onClick: () => onChange(o.url),
|
|
2171
2308
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2172
|
-
children: /* @__PURE__ */ (0,
|
|
2309
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2173
2310
|
},
|
|
2174
2311
|
o.url
|
|
2175
2312
|
)) })
|
|
2176
2313
|
] });
|
|
2177
2314
|
}
|
|
2178
2315
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
2179
|
-
return /* @__PURE__ */ (0,
|
|
2316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2180
2317
|
ParameterCommitInput,
|
|
2181
2318
|
{
|
|
2182
2319
|
id,
|
|
@@ -2195,31 +2332,31 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
2195
2332
|
switch (field.type) {
|
|
2196
2333
|
case "number":
|
|
2197
2334
|
case "int":
|
|
2198
|
-
return /* @__PURE__ */ (0,
|
|
2335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
2199
2336
|
case "boolean":
|
|
2200
|
-
return /* @__PURE__ */ (0,
|
|
2337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
2201
2338
|
case "choice":
|
|
2202
|
-
return /* @__PURE__ */ (0,
|
|
2339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
2203
2340
|
case "color":
|
|
2204
|
-
return /* @__PURE__ */ (0,
|
|
2341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
2205
2342
|
case "vector":
|
|
2206
|
-
return /* @__PURE__ */ (0,
|
|
2343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
2207
2344
|
case "image":
|
|
2208
|
-
return /* @__PURE__ */ (0,
|
|
2345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
2209
2346
|
case "text":
|
|
2210
|
-
return /* @__PURE__ */ (0,
|
|
2347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
2211
2348
|
}
|
|
2212
2349
|
}
|
|
2213
2350
|
|
|
2214
2351
|
// src/effects/EffectParameters.tsx
|
|
2215
|
-
var
|
|
2352
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2216
2353
|
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,
|
|
2354
|
+
const fields = (0, import_react23.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
|
|
2355
|
+
const idBase = (0, import_react23.useId)();
|
|
2356
|
+
const gesture = import_react23.default.useRef(null);
|
|
2357
|
+
const count = import_react23.default.useRef(0);
|
|
2358
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
2359
|
+
onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2223
2360
|
"select",
|
|
2224
2361
|
{
|
|
2225
2362
|
className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
|
|
@@ -2231,8 +2368,8 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
2231
2368
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
2232
2369
|
},
|
|
2233
2370
|
children: [
|
|
2234
|
-
/* @__PURE__ */ (0,
|
|
2235
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
2371
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", children: "Presets\u2026" }),
|
|
2372
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: p.name, children: p.name }, p.name))
|
|
2236
2373
|
]
|
|
2237
2374
|
}
|
|
2238
2375
|
),
|
|
@@ -2242,13 +2379,13 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
2242
2379
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
2243
2380
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
2244
2381
|
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,
|
|
2382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
2383
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2384
|
+
/* @__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 }),
|
|
2385
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2386
|
+
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
2387
|
] }),
|
|
2251
|
-
/* @__PURE__ */ (0,
|
|
2388
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2252
2389
|
ParameterFieldControl,
|
|
2253
2390
|
{
|
|
2254
2391
|
field,
|
|
@@ -2262,47 +2399,47 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
2262
2399
|
)
|
|
2263
2400
|
] }, field.id);
|
|
2264
2401
|
}),
|
|
2265
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
2402
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
2266
2403
|
] });
|
|
2267
2404
|
}
|
|
2268
2405
|
|
|
2269
2406
|
// src/canvas/CanvasEffects.tsx
|
|
2270
|
-
var
|
|
2271
|
-
var ProviderContext = (0,
|
|
2407
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2408
|
+
var ProviderContext = (0, import_react24.createContext)(null);
|
|
2272
2409
|
function CanvasEffectsProvider({ provider, children }) {
|
|
2273
|
-
return /* @__PURE__ */ (0,
|
|
2410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ProviderContext.Provider, { value: provider ?? null, children });
|
|
2274
2411
|
}
|
|
2275
|
-
var useCanvasEffectsProviderContext = () => (0,
|
|
2412
|
+
var useCanvasEffectsProviderContext = () => (0, import_react24.useContext)(ProviderContext);
|
|
2276
2413
|
function CanvasNodeEffectLayer({ effect, width, height, clipPath, clipTransform }) {
|
|
2277
2414
|
const provider = useCanvasEffectsProviderContext();
|
|
2278
|
-
const ref = (0,
|
|
2279
|
-
const [failed, setFailed] = (0,
|
|
2415
|
+
const ref = (0, import_react24.useRef)(null);
|
|
2416
|
+
const [failed, setFailed] = (0, import_react24.useState)(false);
|
|
2280
2417
|
const dpr = typeof window !== "undefined" ? Math.min(2, window.devicePixelRatio || 1) : 1;
|
|
2281
2418
|
const pw = Math.max(1, Math.round(width * dpr));
|
|
2282
2419
|
const ph = Math.max(1, Math.round(height * dpr));
|
|
2283
2420
|
const key = JSON.stringify(effect);
|
|
2284
|
-
(0,
|
|
2421
|
+
(0, import_react24.useEffect)(() => {
|
|
2285
2422
|
const canvas2 = ref.current;
|
|
2286
2423
|
if (!provider || !canvas2) return;
|
|
2287
2424
|
setFailed(false);
|
|
2288
|
-
const run = (0,
|
|
2425
|
+
const run = (0, import_canvas14.runCanvasNodeEffect)({ provider, effect, target: canvas2, onError: () => setFailed(true) });
|
|
2289
2426
|
return () => run.stop();
|
|
2290
2427
|
}, [provider, key, pw, ph]);
|
|
2291
|
-
const clipId = (0,
|
|
2428
|
+
const clipId = (0, import_react24.useMemo)(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
|
|
2292
2429
|
if (!provider || failed || !(width > 0 && height > 0)) return null;
|
|
2293
2430
|
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,
|
|
2431
|
+
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 });
|
|
2432
|
+
if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style, children: canvas });
|
|
2433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { style, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", "aria-hidden": "true", children: [
|
|
2434
|
+
/* @__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 }) }) }),
|
|
2435
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("foreignObject", { x: 0, y: 0, width, height, clipPath: `url(#${clipId})`, children: canvas })
|
|
2299
2436
|
] });
|
|
2300
2437
|
}
|
|
2301
2438
|
function useCanvasEffects(options) {
|
|
2302
|
-
const opts = (0,
|
|
2439
|
+
const opts = (0, import_react24.useRef)(options);
|
|
2303
2440
|
opts.current = options;
|
|
2304
|
-
const controller = (0,
|
|
2305
|
-
() => (0,
|
|
2441
|
+
const controller = (0, import_react24.useMemo)(
|
|
2442
|
+
() => (0, import_canvas14.createCanvasEffectsController)({
|
|
2306
2443
|
getNodes: () => opts.current.getNodes(),
|
|
2307
2444
|
setNodes: (n) => opts.current.setNodes(n),
|
|
2308
2445
|
history: { execute: (c) => opts.current.history ? opts.current.history.execute(c) : c.execute() },
|
|
@@ -2312,7 +2449,7 @@ function useCanvasEffects(options) {
|
|
|
2312
2449
|
}),
|
|
2313
2450
|
[]
|
|
2314
2451
|
);
|
|
2315
|
-
(0,
|
|
2452
|
+
(0, import_react24.useEffect)(() => {
|
|
2316
2453
|
if (!options.effects) return;
|
|
2317
2454
|
return controller.useEffects(options.effects);
|
|
2318
2455
|
}, [controller, options.effects]);
|
|
@@ -2320,20 +2457,20 @@ function useCanvasEffects(options) {
|
|
|
2320
2457
|
}
|
|
2321
2458
|
function useCanvasEffectsTools(registry, controller, options = {}) {
|
|
2322
2459
|
const { id, namespace, readOnly, subscribe } = options;
|
|
2323
|
-
(0,
|
|
2460
|
+
(0, import_react24.useEffect)(() => {
|
|
2324
2461
|
if (!registry) return;
|
|
2325
|
-
return registry.register((0,
|
|
2462
|
+
return registry.register((0, import_canvas14.createCanvasEffectsToolProvider)(controller, { id, namespace, readOnly, subscribe }));
|
|
2326
2463
|
}, [registry, controller, id, namespace, readOnly, subscribe]);
|
|
2327
2464
|
}
|
|
2328
2465
|
var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
2329
2466
|
function Controls({ controller, nodeId, effect }) {
|
|
2330
2467
|
const { description, error } = useEffectDescription(controller.effectsProvider, effect.effect);
|
|
2331
|
-
const [message, setMessage] = (0,
|
|
2468
|
+
const [message, setMessage] = (0, import_react24.useState)(null);
|
|
2332
2469
|
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,
|
|
2470
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
2471
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
2472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2473
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2337
2474
|
EffectParameters,
|
|
2338
2475
|
{
|
|
2339
2476
|
description,
|
|
@@ -2343,75 +2480,75 @@ function Controls({ controller, nodeId, effect }) {
|
|
|
2343
2480
|
onPreset: (v) => run(controller.updateNodeEffect(nodeId, { values: v }))
|
|
2344
2481
|
}
|
|
2345
2482
|
),
|
|
2346
|
-
message && /* @__PURE__ */ (0,
|
|
2483
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2347
2484
|
] });
|
|
2348
2485
|
}
|
|
2349
2486
|
function CanvasEffectsPanel({ controller, nodeId, shape, sceneId, className = "" }) {
|
|
2350
|
-
const [, setTick] = (0,
|
|
2351
|
-
(0,
|
|
2487
|
+
const [, setTick] = (0, import_react24.useState)(0);
|
|
2488
|
+
(0, import_react24.useEffect)(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
2352
2489
|
const provider = controller.effectsProvider;
|
|
2353
|
-
const [browse, setBrowse] = (0,
|
|
2354
|
-
const [message, setMessage] = (0,
|
|
2490
|
+
const [browse, setBrowse] = (0, import_react24.useState)(null);
|
|
2491
|
+
const [message, setMessage] = (0, import_react24.useState)(null);
|
|
2355
2492
|
const run = (work) => {
|
|
2356
2493
|
setMessage(null);
|
|
2357
2494
|
Promise.resolve().then(work).then(() => setTick((n) => n + 1), (e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
2358
2495
|
};
|
|
2359
|
-
const effect = (0,
|
|
2496
|
+
const effect = (0, import_canvas14.isShapeDescription)(shape) ? shape.effect : void 0;
|
|
2360
2497
|
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,
|
|
2498
|
+
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: [
|
|
2499
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2500
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
2501
|
+
/* @__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" }),
|
|
2502
|
+
/* @__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" }),
|
|
2503
|
+
/* @__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
2504
|
] }),
|
|
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,
|
|
2505
|
+
!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." }),
|
|
2506
|
+
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" }))) }),
|
|
2507
|
+
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" }))) }),
|
|
2508
|
+
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))) }),
|
|
2509
|
+
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: [
|
|
2510
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2511
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
|
|
2375
2512
|
effect.name ?? effect.effect,
|
|
2376
2513
|
" ",
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
2514
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
2378
2515
|
"\xB7 ",
|
|
2379
2516
|
effect.mode
|
|
2380
2517
|
] })
|
|
2381
2518
|
] }),
|
|
2382
|
-
/* @__PURE__ */ (0,
|
|
2383
|
-
/* @__PURE__ */ (0,
|
|
2519
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
2520
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: effect.playing !== false, "aria-label": "Play", onChange: (e) => {
|
|
2384
2521
|
const playing = e.currentTarget.checked;
|
|
2385
2522
|
run(() => controller.updateNodeEffect(nodeId, { playing }));
|
|
2386
2523
|
} }),
|
|
2387
2524
|
" Play"
|
|
2388
2525
|
] }),
|
|
2389
|
-
/* @__PURE__ */ (0,
|
|
2526
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, "aria-label": "Remove effect", onClick: () => run(() => controller.removeNodeEffect(nodeId)), children: "\u2715" })
|
|
2390
2527
|
] }),
|
|
2391
|
-
provider && /* @__PURE__ */ (0,
|
|
2528
|
+
provider && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Controls, { controller, nodeId, effect })
|
|
2392
2529
|
] }),
|
|
2393
|
-
sceneId && transition && /* @__PURE__ */ (0,
|
|
2394
|
-
/* @__PURE__ */ (0,
|
|
2530
|
+
sceneId && transition && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1", "data-canvas-scene-transition": sceneId, children: [
|
|
2531
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
2395
2532
|
"Into scene: ",
|
|
2396
2533
|
transition.name ?? transition.effect,
|
|
2397
2534
|
" (",
|
|
2398
2535
|
transition.duration ?? 600,
|
|
2399
2536
|
" ms)"
|
|
2400
2537
|
] }),
|
|
2401
|
-
/* @__PURE__ */ (0,
|
|
2538
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn, "aria-label": "Remove transition", onClick: () => run(() => controller.setSceneTransition(sceneId, null)), children: "\u2715" })
|
|
2402
2539
|
] }),
|
|
2403
|
-
message && /* @__PURE__ */ (0,
|
|
2540
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2404
2541
|
] });
|
|
2405
2542
|
}
|
|
2406
2543
|
|
|
2407
2544
|
// src/canvas/ShapeNode.tsx
|
|
2408
|
-
var
|
|
2545
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2409
2546
|
function ShapeNode({ id, data, width, height, selected, className = "", children, positionAbsoluteX, positionAbsoluteY }) {
|
|
2410
2547
|
const shape = data?.shape;
|
|
2411
|
-
const brushImage = useShapeBrushstroke((0,
|
|
2412
|
-
if (!(0,
|
|
2413
|
-
const render = (0,
|
|
2414
|
-
return /* @__PURE__ */ (0,
|
|
2548
|
+
const brushImage = useShapeBrushstroke((0, import_canvas15.isShapeDescription)(shape) ? shape : null, width, height, { x: positionAbsoluteX ?? 0, y: positionAbsoluteY ?? 0 });
|
|
2549
|
+
if (!(0, import_canvas15.isShapeDescription)(shape)) return null;
|
|
2550
|
+
const render = (0, import_canvas15.getShapeRenderData)(shape, { width, height }, { id: id || data?.id });
|
|
2551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2415
2552
|
"div",
|
|
2416
2553
|
{
|
|
2417
2554
|
className: `pixerate-shape-node ${className}`.trim(),
|
|
@@ -2419,7 +2556,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2419
2556
|
"data-selected": selected ? "true" : void 0,
|
|
2420
2557
|
style: { position: "relative", width: "100%", height: "100%" },
|
|
2421
2558
|
children: [
|
|
2422
|
-
/* @__PURE__ */ (0,
|
|
2559
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2423
2560
|
"svg",
|
|
2424
2561
|
{
|
|
2425
2562
|
viewBox: render.viewBox,
|
|
@@ -2429,13 +2566,13 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2429
2566
|
style: { display: "block", overflow: "visible" },
|
|
2430
2567
|
"aria-hidden": "true",
|
|
2431
2568
|
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,
|
|
2569
|
+
(render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("defs", { children: [
|
|
2570
|
+
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)) }),
|
|
2571
|
+
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)) }),
|
|
2572
|
+
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)) }),
|
|
2573
|
+
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
2574
|
] }),
|
|
2438
|
-
brushImage ? /* @__PURE__ */ (0,
|
|
2575
|
+
brushImage ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("g", { transform: render.transform, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2439
2576
|
"image",
|
|
2440
2577
|
{
|
|
2441
2578
|
className: "pixerate-shape-brushstroke",
|
|
@@ -2447,7 +2584,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2447
2584
|
preserveAspectRatio: "none",
|
|
2448
2585
|
opacity: render.opacity
|
|
2449
2586
|
}
|
|
2450
|
-
) }) : /* @__PURE__ */ (0,
|
|
2587
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2451
2588
|
"path",
|
|
2452
2589
|
{
|
|
2453
2590
|
d: render.d,
|
|
@@ -2465,7 +2602,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2465
2602
|
]
|
|
2466
2603
|
}
|
|
2467
2604
|
),
|
|
2468
|
-
shape.effect && width && height ? /* @__PURE__ */ (0,
|
|
2605
|
+
shape.effect && width && height ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CanvasNodeEffectLayer, { effect: shape.effect, width, height, clipPath: render.d, clipTransform: render.transform }) : null,
|
|
2469
2606
|
children
|
|
2470
2607
|
]
|
|
2471
2608
|
}
|
|
@@ -2473,22 +2610,22 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
2473
2610
|
}
|
|
2474
2611
|
|
|
2475
2612
|
// src/canvas/index.ts
|
|
2476
|
-
var import_canvas28 = require("@pixerate/editor/canvas");
|
|
2477
2613
|
var import_canvas29 = require("@pixerate/editor/canvas");
|
|
2478
2614
|
var import_canvas30 = require("@pixerate/editor/canvas");
|
|
2479
2615
|
var import_canvas31 = require("@pixerate/editor/canvas");
|
|
2616
|
+
var import_canvas32 = require("@pixerate/editor/canvas");
|
|
2480
2617
|
|
|
2481
2618
|
// src/canvas/useCanvasAutoLayout.ts
|
|
2482
|
-
var
|
|
2483
|
-
var
|
|
2619
|
+
var import_react25 = require("react");
|
|
2620
|
+
var import_canvas16 = require("@pixerate/editor/canvas");
|
|
2484
2621
|
function useCanvasAutoLayout(options) {
|
|
2485
|
-
const [guides, setGuides] = (0,
|
|
2486
|
-
const nodesRef = (0,
|
|
2622
|
+
const [guides, setGuides] = (0, import_react25.useState)([]);
|
|
2623
|
+
const nodesRef = (0, import_react25.useRef)(options.nodes);
|
|
2487
2624
|
nodesRef.current = options.nodes;
|
|
2488
|
-
const optionsRef = (0,
|
|
2625
|
+
const optionsRef = (0, import_react25.useRef)(options);
|
|
2489
2626
|
optionsRef.current = options;
|
|
2490
|
-
const controller = (0,
|
|
2491
|
-
() => (0,
|
|
2627
|
+
const controller = (0, import_react25.useMemo)(
|
|
2628
|
+
() => (0, import_canvas16.createCanvasAutoLayoutController)({
|
|
2492
2629
|
getNodes: () => nodesRef.current,
|
|
2493
2630
|
setNodes: (next) => {
|
|
2494
2631
|
nodesRef.current = next;
|
|
@@ -2513,10 +2650,10 @@ function useCanvasAutoLayout(options) {
|
|
|
2513
2650
|
}),
|
|
2514
2651
|
[]
|
|
2515
2652
|
);
|
|
2516
|
-
(0,
|
|
2653
|
+
(0, import_react25.useLayoutEffect)(() => {
|
|
2517
2654
|
if (controller.hasPending) controller.flush();
|
|
2518
2655
|
}, [options.nodes, controller]);
|
|
2519
|
-
return (0,
|
|
2656
|
+
return (0, import_react25.useMemo)(
|
|
2520
2657
|
() => ({
|
|
2521
2658
|
...controller,
|
|
2522
2659
|
/** Drop marker of the active reorder drag (flow coordinates). */
|
|
@@ -2530,47 +2667,47 @@ function useCanvasAutoLayout(options) {
|
|
|
2530
2667
|
}
|
|
2531
2668
|
|
|
2532
2669
|
// src/canvas/useCanvasTokens.ts
|
|
2533
|
-
var
|
|
2534
|
-
var
|
|
2670
|
+
var import_react26 = require("react");
|
|
2671
|
+
var import_canvas17 = require("@pixerate/editor/canvas");
|
|
2535
2672
|
function useCanvasTokens(options) {
|
|
2536
2673
|
const { store, nodes, setNodes, modes, properties } = options;
|
|
2537
|
-
const state = (0,
|
|
2538
|
-
const latest = (0,
|
|
2674
|
+
const state = (0, import_react26.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
2675
|
+
const latest = (0, import_react26.useRef)({ nodes, setNodes, modes, properties });
|
|
2539
2676
|
latest.current = { nodes, setNodes, modes, properties };
|
|
2540
2677
|
const opts = () => ({ modes: latest.current.modes, properties: latest.current.properties });
|
|
2541
|
-
(0,
|
|
2678
|
+
(0, import_react26.useEffect)(
|
|
2542
2679
|
() => store.subscribe((event) => {
|
|
2543
2680
|
if (event.deletedVariableIds.length === 0) return;
|
|
2544
|
-
latest.current.setNodes((prev) => (0,
|
|
2681
|
+
latest.current.setNodes((prev) => (0, import_canvas17.detachTokenBindings)(prev, event.previous, event.deletedVariableIds, opts()));
|
|
2545
2682
|
}),
|
|
2546
2683
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2547
2684
|
[store]
|
|
2548
2685
|
);
|
|
2549
2686
|
const modesKey = JSON.stringify(modes ?? {});
|
|
2550
|
-
(0,
|
|
2551
|
-
const next = (0,
|
|
2687
|
+
(0, import_react26.useEffect)(() => {
|
|
2688
|
+
const next = (0, import_canvas17.resolveCanvasTokens)(nodes, state, opts());
|
|
2552
2689
|
if (next !== nodes) setNodes(next);
|
|
2553
2690
|
}, [nodes, state, modesKey, properties]);
|
|
2554
|
-
const bind = (0,
|
|
2691
|
+
const bind = (0, import_react26.useCallback)(
|
|
2555
2692
|
(ids, propertyKey, variableId) => {
|
|
2556
|
-
const next = (0,
|
|
2693
|
+
const next = (0, import_canvas17.bindCanvasToken)(latest.current.nodes, ids, propertyKey, variableId, store.getState(), opts());
|
|
2557
2694
|
if (next !== latest.current.nodes) latest.current.setNodes(next);
|
|
2558
2695
|
},
|
|
2559
2696
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2560
2697
|
[store]
|
|
2561
2698
|
);
|
|
2562
|
-
const setMode = (0,
|
|
2699
|
+
const setMode = (0, import_react26.useCallback)(
|
|
2563
2700
|
(ids, collectionId, modeId) => {
|
|
2564
|
-
const next = (0,
|
|
2701
|
+
const next = (0, import_canvas17.setCanvasTokenMode)(latest.current.nodes, ids, collectionId, modeId, store.getState(), opts());
|
|
2565
2702
|
if (next !== latest.current.nodes) latest.current.setNodes(next);
|
|
2566
2703
|
},
|
|
2567
2704
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2568
2705
|
[store]
|
|
2569
2706
|
);
|
|
2570
|
-
const modesOf = (0,
|
|
2707
|
+
const modesOf = (0, import_react26.useCallback)(
|
|
2571
2708
|
(nodeId) => {
|
|
2572
2709
|
const node = latest.current.nodes.find((n) => n.id === nodeId);
|
|
2573
|
-
return node ? (0,
|
|
2710
|
+
return node ? (0, import_canvas17.getEffectiveTokenModes)(node, latest.current.nodes, store.getState(), opts()) : {};
|
|
2574
2711
|
},
|
|
2575
2712
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2576
2713
|
[store]
|
|
@@ -2579,9 +2716,9 @@ function useCanvasTokens(options) {
|
|
|
2579
2716
|
}
|
|
2580
2717
|
|
|
2581
2718
|
// src/canvas/TokenBindingPicker.tsx
|
|
2582
|
-
var
|
|
2719
|
+
var import_canvas18 = require("@pixerate/editor/canvas");
|
|
2583
2720
|
var import_tokens = require("@pixerate/editor/tokens");
|
|
2584
|
-
var
|
|
2721
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2585
2722
|
function TokenBindingPicker({
|
|
2586
2723
|
state,
|
|
2587
2724
|
nodes,
|
|
@@ -2595,18 +2732,18 @@ function TokenBindingPicker({
|
|
|
2595
2732
|
const selected = nodes.filter((n) => selectedIds.includes(n.id));
|
|
2596
2733
|
const first = selected[0];
|
|
2597
2734
|
if (!first) return null;
|
|
2598
|
-
let rows = (0,
|
|
2735
|
+
let rows = (0, import_canvas18.getBindableTokenProperties)(first, options);
|
|
2599
2736
|
if (properties) rows = properties.map((key) => rows.find((p) => p.key === key)).filter((p) => !!p);
|
|
2600
|
-
const modes = (0,
|
|
2601
|
-
return /* @__PURE__ */ (0,
|
|
2737
|
+
const modes = (0, import_canvas18.getEffectiveTokenModes)(first, nodes, state, options);
|
|
2738
|
+
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
2739
|
rows.map((property) => {
|
|
2603
|
-
const ids = new Set(selected.map((n) => (0,
|
|
2740
|
+
const ids = new Set(selected.map((n) => (0, import_canvas18.getNodeTokenBindings)(n)[property.key] ?? ""));
|
|
2604
2741
|
const value = ids.size === 1 ? [...ids][0] : "__mixed";
|
|
2605
|
-
const candidates = (0,
|
|
2742
|
+
const candidates = (0, import_canvas18.getTokensForProperty)(state, property, first);
|
|
2606
2743
|
const resolved = value && value !== "__mixed" ? (0, import_tokens.resolveToken)(state, value, modes) : null;
|
|
2607
|
-
return /* @__PURE__ */ (0,
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
/* @__PURE__ */ (0,
|
|
2744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-2", "data-token-property": property.key, children: [
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-28 shrink-0 text-muted-foreground", children: property.label }),
|
|
2746
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2610
2747
|
"select",
|
|
2611
2748
|
{
|
|
2612
2749
|
"aria-label": `${property.label} variable`,
|
|
@@ -2615,17 +2752,17 @@ function TokenBindingPicker({
|
|
|
2615
2752
|
onChange: (e) => {
|
|
2616
2753
|
const id = e.currentTarget.value || null;
|
|
2617
2754
|
try {
|
|
2618
|
-
onChange((0,
|
|
2755
|
+
onChange((0, import_canvas18.bindCanvasToken)(nodes, selectedIds, property.key, id, state, options));
|
|
2619
2756
|
} catch (error) {
|
|
2620
2757
|
onError?.(error);
|
|
2621
2758
|
}
|
|
2622
2759
|
},
|
|
2623
2760
|
children: [
|
|
2624
|
-
value === "__mixed" ? /* @__PURE__ */ (0,
|
|
2625
|
-
/* @__PURE__ */ (0,
|
|
2761
|
+
value === "__mixed" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "__mixed", children: "Mixed" }) : null,
|
|
2762
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "None" }),
|
|
2626
2763
|
candidates.map((v) => {
|
|
2627
2764
|
const collection = state.collections.find((c) => c.id === v.collectionId);
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("option", { value: v.id, children: [
|
|
2629
2766
|
v.name,
|
|
2630
2767
|
collection && state.collections.length > 1 ? ` (${collection.name})` : ""
|
|
2631
2768
|
] }, v.id);
|
|
@@ -2633,17 +2770,17 @@ function TokenBindingPicker({
|
|
|
2633
2770
|
]
|
|
2634
2771
|
}
|
|
2635
2772
|
),
|
|
2636
|
-
/* @__PURE__ */ (0,
|
|
2773
|
+
/* @__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
2774
|
"span",
|
|
2638
2775
|
{
|
|
2639
2776
|
className: "inline-block h-3 w-3 rounded border border-border align-middle",
|
|
2640
2777
|
style: { background: String(resolved.value) },
|
|
2641
2778
|
title: String(resolved.value)
|
|
2642
2779
|
}
|
|
2643
|
-
) : String(resolved.value) : resolved ? /* @__PURE__ */ (0,
|
|
2780
|
+
) : String(resolved.value) : resolved ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { title: resolved.message, children: "\u26A0" }) : null })
|
|
2644
2781
|
] }, property.key);
|
|
2645
2782
|
}),
|
|
2646
|
-
state.collections.length === 0 ? /* @__PURE__ */ (0,
|
|
2783
|
+
state.collections.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-muted-foreground", children: "No variables yet." }) : null
|
|
2647
2784
|
] });
|
|
2648
2785
|
}
|
|
2649
2786
|
function TokenModeSwitcher({
|
|
@@ -2657,29 +2794,29 @@ function TokenModeSwitcher({
|
|
|
2657
2794
|
}) {
|
|
2658
2795
|
const first = nodes.find((n) => nodeIds.includes(n.id));
|
|
2659
2796
|
if (!first) return null;
|
|
2660
|
-
const own = (0,
|
|
2797
|
+
const own = (0, import_canvas18.getNodeTokenModes)(first);
|
|
2661
2798
|
const parent = first.parentId ? nodes.find((n) => n.id === first.parentId) : void 0;
|
|
2662
|
-
const inherited = parent ? (0,
|
|
2799
|
+
const inherited = parent ? (0, import_canvas18.getEffectiveTokenModes)(parent, nodes, state, options) : { ...options.modes };
|
|
2663
2800
|
const collections = state.collections.filter((c) => showSingleMode || c.modes.length > 1);
|
|
2664
|
-
return /* @__PURE__ */ (0,
|
|
2801
|
+
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
2802
|
const auto = (0, import_tokens.getCurrentMode)(collection, inherited);
|
|
2666
2803
|
const explicit = collection.modes.some((m) => m.id === own[collection.id]) ? own[collection.id] : "";
|
|
2667
|
-
return /* @__PURE__ */ (0,
|
|
2668
|
-
/* @__PURE__ */ (0,
|
|
2669
|
-
/* @__PURE__ */ (0,
|
|
2804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-2", "data-token-collection": collection.id, children: [
|
|
2805
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-28 shrink-0 truncate text-muted-foreground", children: collection.name }),
|
|
2806
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2670
2807
|
"select",
|
|
2671
2808
|
{
|
|
2672
2809
|
"aria-label": `${collection.name} mode`,
|
|
2673
2810
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
2674
2811
|
value: explicit,
|
|
2675
|
-
onChange: (e) => onChange((0,
|
|
2812
|
+
onChange: (e) => onChange((0, import_canvas18.setCanvasTokenMode)(nodes, nodeIds, collection.id, e.currentTarget.value || null, state, options)),
|
|
2676
2813
|
children: [
|
|
2677
|
-
/* @__PURE__ */ (0,
|
|
2814
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("option", { value: "", children: [
|
|
2678
2815
|
"Auto (",
|
|
2679
2816
|
auto.name,
|
|
2680
2817
|
")"
|
|
2681
2818
|
] }),
|
|
2682
|
-
collection.modes.map((m) => /* @__PURE__ */ (0,
|
|
2819
|
+
collection.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: m.id, children: m.name }, m.id))
|
|
2683
2820
|
]
|
|
2684
2821
|
}
|
|
2685
2822
|
)
|
|
@@ -2688,18 +2825,18 @@ function TokenModeSwitcher({
|
|
|
2688
2825
|
}
|
|
2689
2826
|
|
|
2690
2827
|
// src/canvas/index.ts
|
|
2691
|
-
var
|
|
2828
|
+
var import_canvas33 = require("@pixerate/editor/canvas");
|
|
2692
2829
|
|
|
2693
2830
|
// src/canvas/useCanvasAnimation.ts
|
|
2694
|
-
var
|
|
2695
|
-
var
|
|
2831
|
+
var import_react27 = require("react");
|
|
2832
|
+
var import_canvas19 = require("@pixerate/editor/canvas");
|
|
2696
2833
|
function useCanvasAnimation(options) {
|
|
2697
|
-
const nodesRef = (0,
|
|
2834
|
+
const nodesRef = (0, import_react27.useRef)(options.nodes);
|
|
2698
2835
|
nodesRef.current = options.nodes;
|
|
2699
|
-
const optionsRef = (0,
|
|
2836
|
+
const optionsRef = (0, import_react27.useRef)(options);
|
|
2700
2837
|
optionsRef.current = options;
|
|
2701
|
-
const controller = (0,
|
|
2702
|
-
() => (0,
|
|
2838
|
+
const controller = (0, import_react27.useMemo)(
|
|
2839
|
+
() => (0, import_canvas19.createCanvasAnimationController)({
|
|
2703
2840
|
getNodes: () => nodesRef.current,
|
|
2704
2841
|
setNodes: (next) => {
|
|
2705
2842
|
nodesRef.current = next;
|
|
@@ -2725,26 +2862,26 @@ function useCanvasAnimation(options) {
|
|
|
2725
2862
|
}),
|
|
2726
2863
|
[]
|
|
2727
2864
|
);
|
|
2728
|
-
(0,
|
|
2729
|
-
(0,
|
|
2865
|
+
(0, import_react27.useEffect)(() => () => controller.destroy(), [controller]);
|
|
2866
|
+
(0, import_react27.useEffect)(() => {
|
|
2730
2867
|
if (options.loop !== void 0) controller.setLoop(options.loop);
|
|
2731
2868
|
}, [controller, options.loop]);
|
|
2732
|
-
(0,
|
|
2869
|
+
(0, import_react27.useEffect)(() => {
|
|
2733
2870
|
if (options.playbackRate !== void 0) controller.setPlaybackRate(options.playbackRate);
|
|
2734
2871
|
}, [controller, options.playbackRate]);
|
|
2735
|
-
(0,
|
|
2872
|
+
(0, import_react27.useEffect)(() => {
|
|
2736
2873
|
if (options.recording !== void 0) controller.setRecording(options.recording);
|
|
2737
2874
|
}, [controller, options.recording]);
|
|
2738
|
-
const state = (0,
|
|
2875
|
+
const state = (0, import_react27.useSyncExternalStore)(
|
|
2739
2876
|
(listener) => controller.subscribe(listener),
|
|
2740
2877
|
() => controller.getState(),
|
|
2741
2878
|
() => controller.getState()
|
|
2742
2879
|
);
|
|
2743
|
-
(0,
|
|
2880
|
+
(0, import_react27.useEffect)(() => {
|
|
2744
2881
|
controller.refresh();
|
|
2745
2882
|
}, [controller, options.nodes]);
|
|
2746
|
-
const displayNodes = (0,
|
|
2747
|
-
return (0,
|
|
2883
|
+
const displayNodes = (0, import_react27.useMemo)(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
|
|
2884
|
+
return (0, import_react27.useMemo)(
|
|
2748
2885
|
() => ({
|
|
2749
2886
|
...controller,
|
|
2750
2887
|
state,
|
|
@@ -2765,24 +2902,24 @@ function useCanvasAnimation(options) {
|
|
|
2765
2902
|
}
|
|
2766
2903
|
|
|
2767
2904
|
// src/canvas/AnimationTimeline.tsx
|
|
2768
|
-
var
|
|
2769
|
-
var
|
|
2770
|
-
var
|
|
2905
|
+
var import_react28 = require("react");
|
|
2906
|
+
var import_canvas20 = require("@pixerate/editor/canvas");
|
|
2907
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2771
2908
|
var LOOP_LABELS = { none: "Once", loop: "Loop", "ping-pong": "Ping-pong" };
|
|
2772
2909
|
var easingValue = (easing) => typeof easing === "string" ? easing : easing ? "custom" : "linear";
|
|
2773
2910
|
function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8, labelOf, className = "" }) {
|
|
2774
2911
|
const { state } = animation;
|
|
2775
2912
|
const duration = state.duration;
|
|
2776
2913
|
const rows = animation.timelineRows(nodeIds ?? void 0, labelOf ? { labelOf } : {});
|
|
2777
|
-
const ticks = (0,
|
|
2914
|
+
const ticks = (0, import_canvas20.getTimelineTicks)(duration, width);
|
|
2778
2915
|
const selectedEasing = (() => {
|
|
2779
2916
|
const first = state.selection[0];
|
|
2780
2917
|
if (!first) return "";
|
|
2781
2918
|
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
2919
|
return "";
|
|
2783
2920
|
})();
|
|
2784
|
-
const dragRef = (0,
|
|
2785
|
-
(0,
|
|
2921
|
+
const dragRef = (0, import_react28.useRef)(null);
|
|
2922
|
+
(0, import_react28.useEffect)(() => {
|
|
2786
2923
|
const onKey = (event) => {
|
|
2787
2924
|
if (event.key === "Escape" && dragRef.current) {
|
|
2788
2925
|
dragRef.current = null;
|
|
@@ -2795,8 +2932,8 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2795
2932
|
const onRulerDown = (event) => {
|
|
2796
2933
|
const lane = event.currentTarget;
|
|
2797
2934
|
const left = lane.getBoundingClientRect().left;
|
|
2798
|
-
animation.scrub((0,
|
|
2799
|
-
const move = (e) => animation.scrub((0,
|
|
2935
|
+
animation.scrub((0, import_canvas20.xToTime)(event.clientX - left, duration, width));
|
|
2936
|
+
const move = (e) => animation.scrub((0, import_canvas20.xToTime)(e.clientX - left, duration, width));
|
|
2800
2937
|
const up = () => {
|
|
2801
2938
|
window.removeEventListener("pointermove", move);
|
|
2802
2939
|
window.removeEventListener("pointerup", up);
|
|
@@ -2836,12 +2973,12 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2836
2973
|
}
|
|
2837
2974
|
};
|
|
2838
2975
|
const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-50";
|
|
2839
|
-
const playheadX = (0,
|
|
2976
|
+
const playheadX = (0, import_canvas20.timeToX)(state.time, duration, width);
|
|
2840
2977
|
const labelWidth = 120;
|
|
2841
|
-
return /* @__PURE__ */ (0,
|
|
2842
|
-
/* @__PURE__ */ (0,
|
|
2843
|
-
/* @__PURE__ */ (0,
|
|
2844
|
-
/* @__PURE__ */ (0,
|
|
2978
|
+
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: [
|
|
2979
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "toolbar", "aria-label": "Animation", children: [
|
|
2980
|
+
/* @__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" }),
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2845
2982
|
"button",
|
|
2846
2983
|
{
|
|
2847
2984
|
type: "button",
|
|
@@ -2853,13 +2990,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2853
2990
|
children: "\u25CF Rec"
|
|
2854
2991
|
}
|
|
2855
2992
|
),
|
|
2856
|
-
/* @__PURE__ */ (0,
|
|
2857
|
-
/* @__PURE__ */ (0,
|
|
2858
|
-
(0,
|
|
2993
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn2, "data-action": "add-keyframe", onClick: () => animation.addKeyframe(), children: "\u25C6 Key" }),
|
|
2994
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { "data-time": "", className: "tabular-nums text-muted-foreground", children: [
|
|
2995
|
+
(0, import_canvas20.formatAnimationTime)(state.time),
|
|
2859
2996
|
" / ",
|
|
2860
|
-
(0,
|
|
2997
|
+
(0, import_canvas20.formatAnimationTime)(duration)
|
|
2861
2998
|
] }),
|
|
2862
|
-
/* @__PURE__ */ (0,
|
|
2999
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2863
3000
|
"select",
|
|
2864
3001
|
{
|
|
2865
3002
|
"aria-label": "Easing",
|
|
@@ -2869,13 +3006,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2869
3006
|
disabled: state.selection.length === 0,
|
|
2870
3007
|
onChange: (e) => e.target.value && e.target.value !== "custom" && animation.setEasing(e.target.value),
|
|
2871
3008
|
children: [
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
2873
|
-
|
|
2874
|
-
selectedEasing === "custom" ? /* @__PURE__ */ (0,
|
|
3009
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "Easing\u2026" }),
|
|
3010
|
+
import_canvas20.ANIMATION_EASING_PRESETS.map((preset) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: preset, children: import_canvas20.ANIMATION_EASING_LABELS[preset] }, preset)),
|
|
3011
|
+
selectedEasing === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "custom", children: "Custom" }) : null
|
|
2875
3012
|
]
|
|
2876
3013
|
}
|
|
2877
3014
|
),
|
|
2878
|
-
/* @__PURE__ */ (0,
|
|
3015
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2879
3016
|
"select",
|
|
2880
3017
|
{
|
|
2881
3018
|
"aria-label": "Loop",
|
|
@@ -2883,13 +3020,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2883
3020
|
className: "rounded border border-border bg-background px-1 py-0.5",
|
|
2884
3021
|
value: state.loop,
|
|
2885
3022
|
onChange: (e) => animation.setLoop(e.target.value),
|
|
2886
|
-
children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0,
|
|
3023
|
+
children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: mode, children: LOOP_LABELS[mode] }, mode))
|
|
2887
3024
|
}
|
|
2888
3025
|
)
|
|
2889
3026
|
] }),
|
|
2890
|
-
/* @__PURE__ */ (0,
|
|
2891
|
-
/* @__PURE__ */ (0,
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
3027
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex", children: [
|
|
3028
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { width: labelWidth }, className: "shrink-0" }),
|
|
3029
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2893
3030
|
"div",
|
|
2894
3031
|
{
|
|
2895
3032
|
"data-timeline-ruler": "",
|
|
@@ -2897,15 +3034,15 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2897
3034
|
style: { width },
|
|
2898
3035
|
onPointerDown: onRulerDown,
|
|
2899
3036
|
children: [
|
|
2900
|
-
ticks.map((tick) => /* @__PURE__ */ (0,
|
|
2901
|
-
/* @__PURE__ */ (0,
|
|
3037
|
+
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)),
|
|
3038
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { "data-playhead": "", className: "absolute top-0 h-5 w-px bg-red-500", style: { left: playheadX } })
|
|
2902
3039
|
]
|
|
2903
3040
|
}
|
|
2904
3041
|
)
|
|
2905
3042
|
] }),
|
|
2906
|
-
rows.length === 0 ? /* @__PURE__ */ (0,
|
|
2907
|
-
/* @__PURE__ */ (0,
|
|
2908
|
-
/* @__PURE__ */ (0,
|
|
3043
|
+
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: [
|
|
3044
|
+
/* @__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: [
|
|
3045
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2909
3046
|
"input",
|
|
2910
3047
|
{
|
|
2911
3048
|
type: "checkbox",
|
|
@@ -2914,24 +3051,24 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2914
3051
|
onChange: (e) => animation.setTrackEnabled(row.nodeId, row.property, e.target.checked)
|
|
2915
3052
|
}
|
|
2916
3053
|
),
|
|
2917
|
-
/* @__PURE__ */ (0,
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "truncate", children: [
|
|
2918
3055
|
rows.filter((r) => r.nodeId === row.nodeId).length < rows.length ? `${row.nodeLabel} \xB7 ` : "",
|
|
2919
3056
|
row.label
|
|
2920
3057
|
] })
|
|
2921
3058
|
] }),
|
|
2922
|
-
/* @__PURE__ */ (0,
|
|
2923
|
-
/* @__PURE__ */ (0,
|
|
2924
|
-
state.drag?.target != null ? /* @__PURE__ */ (0,
|
|
2925
|
-
row.keyframes.map((k) => /* @__PURE__ */ (0,
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { "data-lane": "", className: `relative h-5 rounded bg-muted/40 ${row.enabled ? "" : "opacity-50"}`, style: { width }, children: [
|
|
3060
|
+
/* @__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 } }),
|
|
3061
|
+
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,
|
|
3062
|
+
row.keyframes.map((k) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2926
3063
|
"button",
|
|
2927
3064
|
{
|
|
2928
3065
|
type: "button",
|
|
2929
3066
|
"data-keyframe": k.ref.time,
|
|
2930
3067
|
"aria-pressed": k.selected,
|
|
2931
|
-
"aria-label": `${row.label} keyframe at ${(0,
|
|
2932
|
-
title: `${(0,
|
|
3068
|
+
"aria-label": `${row.label} keyframe at ${(0, import_canvas20.formatAnimationTime)(k.ref.time)}`,
|
|
3069
|
+
title: `${(0, import_canvas20.formatAnimationTime)(k.time)} \xB7 ${String(k.value)}`,
|
|
2933
3070
|
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,
|
|
3071
|
+
style: { left: (0, import_canvas20.timeToX)(k.time, duration, width) },
|
|
2935
3072
|
onPointerDown: onKeyDown(k.ref)
|
|
2936
3073
|
},
|
|
2937
3074
|
k.ref.time
|
|
@@ -2942,18 +3079,18 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
2942
3079
|
}
|
|
2943
3080
|
|
|
2944
3081
|
// src/canvas/index.ts
|
|
2945
|
-
var
|
|
3082
|
+
var import_canvas34 = require("@pixerate/editor/canvas");
|
|
2946
3083
|
|
|
2947
3084
|
// src/canvas/useCanvasComponents.ts
|
|
2948
|
-
var
|
|
2949
|
-
var
|
|
3085
|
+
var import_react29 = require("react");
|
|
3086
|
+
var import_canvas21 = require("@pixerate/editor/canvas");
|
|
2950
3087
|
function useCanvasComponents(options) {
|
|
2951
|
-
const nodesRef = (0,
|
|
3088
|
+
const nodesRef = (0, import_react29.useRef)(options.nodes);
|
|
2952
3089
|
nodesRef.current = options.nodes;
|
|
2953
|
-
const optionsRef = (0,
|
|
3090
|
+
const optionsRef = (0, import_react29.useRef)(options);
|
|
2954
3091
|
optionsRef.current = options;
|
|
2955
|
-
const controller = (0,
|
|
2956
|
-
() => (0,
|
|
3092
|
+
const controller = (0, import_react29.useMemo)(
|
|
3093
|
+
() => (0, import_canvas21.createCanvasComponentsController)({
|
|
2957
3094
|
getNodes: () => nodesRef.current,
|
|
2958
3095
|
setNodes: (next) => {
|
|
2959
3096
|
nodesRef.current = next;
|
|
@@ -2981,18 +3118,18 @@ function useCanvasComponents(options) {
|
|
|
2981
3118
|
}),
|
|
2982
3119
|
[]
|
|
2983
3120
|
);
|
|
2984
|
-
(0,
|
|
3121
|
+
(0, import_react29.useLayoutEffect)(() => {
|
|
2985
3122
|
if (optionsRef.current.autoSync !== false) controller.sync();
|
|
2986
3123
|
}, [options.nodes, controller]);
|
|
2987
3124
|
return controller;
|
|
2988
3125
|
}
|
|
2989
3126
|
|
|
2990
3127
|
// src/canvas/CanvasComponentsPanel.tsx
|
|
2991
|
-
var
|
|
2992
|
-
var
|
|
2993
|
-
var
|
|
3128
|
+
var import_react30 = require("react");
|
|
3129
|
+
var import_canvas22 = require("@pixerate/editor/canvas");
|
|
3130
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2994
3131
|
function InlineField({ value, label, onCommit }) {
|
|
2995
|
-
return /* @__PURE__ */ (0,
|
|
3132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2996
3133
|
"input",
|
|
2997
3134
|
{
|
|
2998
3135
|
type: "text",
|
|
@@ -3023,11 +3160,11 @@ function CanvasComponentsPanel({
|
|
|
3023
3160
|
search = true,
|
|
3024
3161
|
className = ""
|
|
3025
3162
|
}) {
|
|
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,
|
|
3163
|
+
const [query, setQuery] = (0, import_react30.useState)("");
|
|
3164
|
+
const [propsOpen, setPropsOpen] = (0, import_react30.useState)(null);
|
|
3165
|
+
const [menuFor, setMenuFor] = (0, import_react30.useState)(null);
|
|
3166
|
+
const [editing, setEditing] = (0, import_react30.useState)(null);
|
|
3167
|
+
const { components: all, sets } = (0, import_canvas22.listCanvasComponents)(nodes);
|
|
3031
3168
|
const q = query.trim().toLowerCase();
|
|
3032
3169
|
const match = (name) => !q || name.toLowerCase().includes(q);
|
|
3033
3170
|
const lone = all.filter((c) => !c.setId && match(c.name));
|
|
@@ -3038,7 +3175,7 @@ function CanvasComponentsPanel({
|
|
|
3038
3175
|
};
|
|
3039
3176
|
const small = "shrink-0 rounded px-1 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40";
|
|
3040
3177
|
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,
|
|
3178
|
+
const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3042
3179
|
"button",
|
|
3043
3180
|
{
|
|
3044
3181
|
type: "button",
|
|
@@ -3050,22 +3187,22 @@ function CanvasComponentsPanel({
|
|
|
3050
3187
|
onClick: () => onInsert(id),
|
|
3051
3188
|
onContextMenu,
|
|
3052
3189
|
onDragStart: (e) => {
|
|
3053
|
-
e.dataTransfer.setData(
|
|
3190
|
+
e.dataTransfer.setData(import_canvas22.CANVAS_COMPONENT_DRAG_TYPE, id);
|
|
3054
3191
|
e.dataTransfer.setData("text/plain", name);
|
|
3055
3192
|
e.dataTransfer.effectAllowed = "copy";
|
|
3056
3193
|
},
|
|
3057
3194
|
children: [
|
|
3058
|
-
/* @__PURE__ */ (0,
|
|
3059
|
-
/* @__PURE__ */ (0,
|
|
3195
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "truncate", children: [
|
|
3196
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": true, className: "mr-1 text-muted-foreground", children: "\u25C7" }),
|
|
3060
3197
|
name
|
|
3061
3198
|
] }),
|
|
3062
|
-
/* @__PURE__ */ (0,
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[10px] text-muted-foreground", "data-instance-count": "", children: count })
|
|
3063
3200
|
]
|
|
3064
3201
|
},
|
|
3065
3202
|
id
|
|
3066
3203
|
);
|
|
3067
|
-
return /* @__PURE__ */ (0,
|
|
3068
|
-
search ? /* @__PURE__ */ (0,
|
|
3204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-components-panel": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
|
|
3205
|
+
search ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3069
3206
|
"input",
|
|
3070
3207
|
{
|
|
3071
3208
|
type: "search",
|
|
@@ -3075,11 +3212,11 @@ function CanvasComponentsPanel({
|
|
|
3075
3212
|
onInput: (e) => setQuery(e.target.value)
|
|
3076
3213
|
}
|
|
3077
3214
|
) : null,
|
|
3078
|
-
shownSets.map((set) => /* @__PURE__ */ (0,
|
|
3079
|
-
/* @__PURE__ */ (0,
|
|
3215
|
+
shownSets.map((set) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-component-set": set.id, className: "flex flex-col", children: [
|
|
3216
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3080
3217
|
item(set.id, set.name, set.variants.reduce((sum, v) => sum + v.instanceCount, 0), { "data-kind": "set" }),
|
|
3081
|
-
components ? /* @__PURE__ */ (0,
|
|
3082
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
components ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3083
3220
|
"button",
|
|
3084
3221
|
{
|
|
3085
3222
|
type: "button",
|
|
@@ -3091,7 +3228,7 @@ function CanvasComponentsPanel({
|
|
|
3091
3228
|
children: "+\xA0Variant"
|
|
3092
3229
|
}
|
|
3093
3230
|
),
|
|
3094
|
-
/* @__PURE__ */ (0,
|
|
3231
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3095
3232
|
"button",
|
|
3096
3233
|
{
|
|
3097
3234
|
type: "button",
|
|
@@ -3106,8 +3243,8 @@ function CanvasComponentsPanel({
|
|
|
3106
3243
|
)
|
|
3107
3244
|
] }) : null
|
|
3108
3245
|
] }),
|
|
3109
|
-
components && propsOpen === set.id ? /* @__PURE__ */ (0,
|
|
3110
|
-
/* @__PURE__ */ (0,
|
|
3246
|
+
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: [
|
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3111
3248
|
InlineField,
|
|
3112
3249
|
{
|
|
3113
3250
|
value: option.name,
|
|
@@ -3115,7 +3252,7 @@ function CanvasComponentsPanel({
|
|
|
3115
3252
|
onCommit: (next) => report(components.renameVariantProperty(option.name, next, set.id))
|
|
3116
3253
|
}
|
|
3117
3254
|
),
|
|
3118
|
-
/* @__PURE__ */ (0,
|
|
3255
|
+
/* @__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
3256
|
InlineField,
|
|
3120
3257
|
{
|
|
3121
3258
|
value,
|
|
@@ -3125,8 +3262,8 @@ function CanvasComponentsPanel({
|
|
|
3125
3262
|
value
|
|
3126
3263
|
)) })
|
|
3127
3264
|
] }, option.name)) }) : null,
|
|
3128
|
-
/* @__PURE__ */ (0,
|
|
3129
|
-
/* @__PURE__ */ (0,
|
|
3265
|
+
/* @__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: [
|
|
3266
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3130
3267
|
item(
|
|
3131
3268
|
v.id,
|
|
3132
3269
|
v.name,
|
|
@@ -3137,7 +3274,7 @@ function CanvasComponentsPanel({
|
|
|
3137
3274
|
setMenuFor(v.id);
|
|
3138
3275
|
} : void 0
|
|
3139
3276
|
),
|
|
3140
|
-
components ? /* @__PURE__ */ (0,
|
|
3277
|
+
components ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3141
3278
|
"button",
|
|
3142
3279
|
{
|
|
3143
3280
|
type: "button",
|
|
@@ -3151,8 +3288,8 @@ function CanvasComponentsPanel({
|
|
|
3151
3288
|
}
|
|
3152
3289
|
) : null
|
|
3153
3290
|
] }),
|
|
3154
|
-
components && menuFor === v.id ? /* @__PURE__ */ (0,
|
|
3155
|
-
/* @__PURE__ */ (0,
|
|
3291
|
+
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: [
|
|
3292
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3156
3293
|
"button",
|
|
3157
3294
|
{
|
|
3158
3295
|
type: "button",
|
|
@@ -3166,7 +3303,7 @@ function CanvasComponentsPanel({
|
|
|
3166
3303
|
children: "Edit values\u2026"
|
|
3167
3304
|
}
|
|
3168
3305
|
),
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3306
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3170
3307
|
"button",
|
|
3171
3308
|
{
|
|
3172
3309
|
type: "button",
|
|
@@ -3180,7 +3317,7 @@ function CanvasComponentsPanel({
|
|
|
3180
3317
|
children: "Duplicate"
|
|
3181
3318
|
}
|
|
3182
3319
|
),
|
|
3183
|
-
/* @__PURE__ */ (0,
|
|
3320
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3184
3321
|
"button",
|
|
3185
3322
|
{
|
|
3186
3323
|
type: "button",
|
|
@@ -3197,7 +3334,7 @@ function CanvasComponentsPanel({
|
|
|
3197
3334
|
}
|
|
3198
3335
|
)
|
|
3199
3336
|
] }) : null,
|
|
3200
|
-
components && editing === v.id ? /* @__PURE__ */ (0,
|
|
3337
|
+
components && editing === v.id ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3201
3338
|
"form",
|
|
3202
3339
|
{
|
|
3203
3340
|
"data-variant-editor": v.id,
|
|
@@ -3211,9 +3348,9 @@ function CanvasComponentsPanel({
|
|
|
3211
3348
|
if (report(components.setVariantProperties(values, v.id))) setEditing(null);
|
|
3212
3349
|
},
|
|
3213
3350
|
children: [
|
|
3214
|
-
set.options.map((option) => /* @__PURE__ */ (0,
|
|
3215
|
-
/* @__PURE__ */ (0,
|
|
3216
|
-
/* @__PURE__ */ (0,
|
|
3351
|
+
set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
3352
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-16 shrink-0 truncate text-muted-foreground", children: option.name }),
|
|
3353
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3217
3354
|
"input",
|
|
3218
3355
|
{
|
|
3219
3356
|
type: "text",
|
|
@@ -3224,9 +3361,9 @@ function CanvasComponentsPanel({
|
|
|
3224
3361
|
}
|
|
3225
3362
|
)
|
|
3226
3363
|
] }, option.name)),
|
|
3227
|
-
/* @__PURE__ */ (0,
|
|
3228
|
-
/* @__PURE__ */ (0,
|
|
3229
|
-
/* @__PURE__ */ (0,
|
|
3364
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex gap-1", children: [
|
|
3365
|
+
/* @__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" }),
|
|
3366
|
+
/* @__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
3367
|
] })
|
|
3231
3368
|
]
|
|
3232
3369
|
}
|
|
@@ -3234,7 +3371,7 @@ function CanvasComponentsPanel({
|
|
|
3234
3371
|
] }, v.id)) })
|
|
3235
3372
|
] }, set.id)),
|
|
3236
3373
|
lone.map((c) => item(c.id, c.name, c.instanceCount, { "data-kind": "component" })),
|
|
3237
|
-
all.length === 0 ? /* @__PURE__ */ (0,
|
|
3374
|
+
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
3375
|
] });
|
|
3239
3376
|
}
|
|
3240
3377
|
function CanvasInstanceInspector({
|
|
@@ -3244,36 +3381,36 @@ function CanvasInstanceInspector({
|
|
|
3244
3381
|
onError,
|
|
3245
3382
|
className = ""
|
|
3246
3383
|
}) {
|
|
3247
|
-
const info = nodeId ? (0,
|
|
3384
|
+
const info = nodeId ? (0, import_canvas22.inspectCanvasInstance)(nodes, nodeId) : void 0;
|
|
3248
3385
|
if (!info) return null;
|
|
3249
3386
|
const report = (result) => {
|
|
3250
3387
|
if (result && !result.ok && result.reason) onError?.(result.reason);
|
|
3251
3388
|
};
|
|
3252
3389
|
const setProp = (name, value) => report(components.setInstanceProperties({ [name]: value }, [info.id]));
|
|
3253
|
-
const allComponents = (0,
|
|
3390
|
+
const allComponents = (0, import_canvas22.listCanvasComponents)(nodes).components;
|
|
3254
3391
|
const linked = info.status === "linked";
|
|
3255
3392
|
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,
|
|
3393
|
+
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: [
|
|
3394
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
3395
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate font-medium", "data-instance-main": "", children: linked ? info.componentName : "Main component missing" }),
|
|
3396
|
+
info.nested ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-muted-foreground", children: "Nested" }) : null
|
|
3260
3397
|
] }),
|
|
3261
|
-
info.variantOptions.map((option) => /* @__PURE__ */ (0,
|
|
3262
|
-
/* @__PURE__ */ (0,
|
|
3263
|
-
/* @__PURE__ */ (0,
|
|
3398
|
+
info.variantOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", "data-variant-property": option.name, children: [
|
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: option.name }),
|
|
3400
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3264
3401
|
"select",
|
|
3265
3402
|
{
|
|
3266
3403
|
"aria-label": `${option.name} variant`,
|
|
3267
3404
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
3268
3405
|
value: info.variant[option.name] ?? "",
|
|
3269
3406
|
onChange: (e) => setProp(option.name, e.currentTarget.value),
|
|
3270
|
-
children: option.values.map((v) => /* @__PURE__ */ (0,
|
|
3407
|
+
children: option.values.map((v) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: v, children: v }, v))
|
|
3271
3408
|
}
|
|
3272
3409
|
)
|
|
3273
3410
|
] }, option.name)),
|
|
3274
|
-
info.properties.map((p) => /* @__PURE__ */ (0,
|
|
3275
|
-
/* @__PURE__ */ (0,
|
|
3276
|
-
p.type === "boolean" ? /* @__PURE__ */ (0,
|
|
3411
|
+
info.properties.map((p) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", "data-component-property": p.name, children: [
|
|
3412
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: p.name }),
|
|
3413
|
+
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
3414
|
"input",
|
|
3278
3415
|
{
|
|
3279
3416
|
type: "text",
|
|
@@ -3288,22 +3425,22 @@ function CanvasInstanceInspector({
|
|
|
3288
3425
|
}
|
|
3289
3426
|
},
|
|
3290
3427
|
String(p.value)
|
|
3291
|
-
) : /* @__PURE__ */ (0,
|
|
3428
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3292
3429
|
"select",
|
|
3293
3430
|
{
|
|
3294
3431
|
"aria-label": p.name,
|
|
3295
3432
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
3296
3433
|
value: String(p.value),
|
|
3297
3434
|
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,
|
|
3435
|
+
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
3436
|
}
|
|
3300
3437
|
)
|
|
3301
3438
|
] }, 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,
|
|
3439
|
+
info.overrides.length ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1", "data-instance-overrides": "", children: [
|
|
3440
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-muted-foreground", children: "Overrides" }),
|
|
3441
|
+
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: [
|
|
3442
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "mr-1 truncate", children: o.name }),
|
|
3443
|
+
o.groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3307
3444
|
"button",
|
|
3308
3445
|
{
|
|
3309
3446
|
type: "button",
|
|
@@ -3320,11 +3457,11 @@ function CanvasInstanceInspector({
|
|
|
3320
3457
|
))
|
|
3321
3458
|
] }, o.id))
|
|
3322
3459
|
] }) : null,
|
|
3323
|
-
/* @__PURE__ */ (0,
|
|
3324
|
-
linked ? /* @__PURE__ */ (0,
|
|
3325
|
-
/* @__PURE__ */ (0,
|
|
3326
|
-
/* @__PURE__ */ (0,
|
|
3327
|
-
/* @__PURE__ */ (0,
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
3461
|
+
linked ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3462
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn2, "data-action": "reset", onClick: () => report(components.resetOverrides(info.id)), children: "Reset all" }),
|
|
3463
|
+
/* @__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" }),
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3328
3465
|
"button",
|
|
3329
3466
|
{
|
|
3330
3467
|
type: "button",
|
|
@@ -3335,8 +3472,8 @@ function CanvasInstanceInspector({
|
|
|
3335
3472
|
children: "Push changes"
|
|
3336
3473
|
}
|
|
3337
3474
|
)
|
|
3338
|
-
] }) : /* @__PURE__ */ (0,
|
|
3339
|
-
/* @__PURE__ */ (0,
|
|
3475
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn2, "data-action": "restore", onClick: () => report(components.restoreMainComponent(info.rootId)), children: "Restore main component" }),
|
|
3476
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3340
3477
|
"button",
|
|
3341
3478
|
{
|
|
3342
3479
|
type: "button",
|
|
@@ -3353,12 +3490,12 @@ function CanvasInstanceInspector({
|
|
|
3353
3490
|
}
|
|
3354
3491
|
|
|
3355
3492
|
// src/canvas/index.ts
|
|
3356
|
-
var
|
|
3493
|
+
var import_canvas35 = require("@pixerate/editor/canvas");
|
|
3357
3494
|
|
|
3358
3495
|
// src/canvas/MermaidFamilyScene.tsx
|
|
3359
|
-
var
|
|
3360
|
-
var
|
|
3361
|
-
var
|
|
3496
|
+
var import_react31 = require("react");
|
|
3497
|
+
var import_canvas23 = require("@pixerate/editor/canvas");
|
|
3498
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3362
3499
|
function MermaidFamilyScene({
|
|
3363
3500
|
scene,
|
|
3364
3501
|
padding = 16,
|
|
@@ -3371,7 +3508,7 @@ function MermaidFamilyScene({
|
|
|
3371
3508
|
style,
|
|
3372
3509
|
title
|
|
3373
3510
|
}) {
|
|
3374
|
-
const uid = (0,
|
|
3511
|
+
const uid = (0, import_react31.useId)().replace(/:/g, "");
|
|
3375
3512
|
const marker = (kind) => kind ? `url(#${uid}-${kind})` : void 0;
|
|
3376
3513
|
const x = scene.x - padding;
|
|
3377
3514
|
const y = scene.y - padding;
|
|
@@ -3389,7 +3526,7 @@ function MermaidFamilyScene({
|
|
|
3389
3526
|
cursor: "pointer"
|
|
3390
3527
|
} : { pointerEvents: "none" };
|
|
3391
3528
|
const stroke = (mark) => mark.selected ? { stroke: selectionColor, strokeWidth: Math.max(2, mark.strokeWidth ?? 0) } : { stroke: mark.stroke, strokeWidth: mark.strokeWidth };
|
|
3392
|
-
return /* @__PURE__ */ (0,
|
|
3529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3393
3530
|
"svg",
|
|
3394
3531
|
{
|
|
3395
3532
|
className: `pixerate-diagram-scene ${className}`.trim(),
|
|
@@ -3402,15 +3539,15 @@ function MermaidFamilyScene({
|
|
|
3402
3539
|
style: { display: "block", maxWidth: "100%", height: "auto", overflow: "visible", ...style },
|
|
3403
3540
|
onClick: interactive ? (event) => onSelect?.(null, event) : void 0,
|
|
3404
3541
|
children: [
|
|
3405
|
-
/* @__PURE__ */ (0,
|
|
3406
|
-
/* @__PURE__ */ (0,
|
|
3407
|
-
/* @__PURE__ */ (0,
|
|
3542
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("defs", { children: [
|
|
3543
|
+
/* @__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 } }) }),
|
|
3544
|
+
/* @__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
3545
|
] }),
|
|
3409
3546
|
scene.marks.map((mark) => {
|
|
3410
3547
|
const common = { "data-role": mark.role, "data-target": mark.target, "data-selected": mark.selected ? "" : void 0, opacity: mark.opacity, ...handlers(mark) };
|
|
3411
3548
|
switch (mark.kind) {
|
|
3412
3549
|
case "rect":
|
|
3413
|
-
return /* @__PURE__ */ (0,
|
|
3550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3414
3551
|
"rect",
|
|
3415
3552
|
{
|
|
3416
3553
|
...common,
|
|
@@ -3425,9 +3562,9 @@ function MermaidFamilyScene({
|
|
|
3425
3562
|
mark.key
|
|
3426
3563
|
);
|
|
3427
3564
|
case "circle":
|
|
3428
|
-
return /* @__PURE__ */ (0,
|
|
3565
|
+
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
3566
|
case "line":
|
|
3430
|
-
return /* @__PURE__ */ (0,
|
|
3567
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3431
3568
|
"line",
|
|
3432
3569
|
{
|
|
3433
3570
|
...common,
|
|
@@ -3443,7 +3580,7 @@ function MermaidFamilyScene({
|
|
|
3443
3580
|
mark.key
|
|
3444
3581
|
);
|
|
3445
3582
|
case "path":
|
|
3446
|
-
return /* @__PURE__ */ (0,
|
|
3583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3447
3584
|
"path",
|
|
3448
3585
|
{
|
|
3449
3586
|
...common,
|
|
@@ -3457,14 +3594,14 @@ function MermaidFamilyScene({
|
|
|
3457
3594
|
mark.key
|
|
3458
3595
|
);
|
|
3459
3596
|
case "text":
|
|
3460
|
-
return /* @__PURE__ */ (0,
|
|
3597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3461
3598
|
"text",
|
|
3462
3599
|
{
|
|
3463
3600
|
...common,
|
|
3464
3601
|
x: mark.x,
|
|
3465
3602
|
y: mark.y,
|
|
3466
3603
|
textAnchor: mark.anchor,
|
|
3467
|
-
dominantBaseline: (0,
|
|
3604
|
+
dominantBaseline: (0, import_canvas23.diagramTextBaseline)(mark.baseline),
|
|
3468
3605
|
transform: mark.rotate ? `rotate(${mark.rotate} ${mark.x} ${mark.y})` : void 0,
|
|
3469
3606
|
style: {
|
|
3470
3607
|
fill: mark.selected ? selectionColor : mark.fill,
|
|
@@ -3485,14 +3622,14 @@ function MermaidFamilyScene({
|
|
|
3485
3622
|
}
|
|
3486
3623
|
|
|
3487
3624
|
// src/canvas/useMermaidDiagram.ts
|
|
3488
|
-
var
|
|
3625
|
+
var import_react32 = require("react");
|
|
3489
3626
|
var import_diagram = require("@pixerate/editor/diagram");
|
|
3490
|
-
var
|
|
3627
|
+
var import_canvas24 = require("@pixerate/editor/canvas");
|
|
3491
3628
|
function useDiagramState(controller) {
|
|
3492
|
-
return (0,
|
|
3629
|
+
return (0, import_react32.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
3493
3630
|
}
|
|
3494
3631
|
function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
3495
|
-
const own = (0,
|
|
3632
|
+
const own = (0, import_react32.useRef)(null);
|
|
3496
3633
|
let controller;
|
|
3497
3634
|
if (controllerOrOptions instanceof import_diagram.DiagramController) controller = controllerOrOptions;
|
|
3498
3635
|
else {
|
|
@@ -3502,24 +3639,24 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
3502
3639
|
const layoutOptions = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.layoutOptions) ?? view.layoutOptions;
|
|
3503
3640
|
const sceneTheme = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.sceneTheme) ?? view.sceneTheme;
|
|
3504
3641
|
const state = useDiagramState(controller);
|
|
3505
|
-
const canvas = (0,
|
|
3506
|
-
() => (0,
|
|
3642
|
+
const canvas = (0, import_react32.useMemo)(
|
|
3643
|
+
() => (0, import_canvas24.mermaidToCanvas)(state.document, { ...layoutOptions, editable: state.editable }),
|
|
3507
3644
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3508
3645
|
[state.document, state.editable]
|
|
3509
3646
|
);
|
|
3510
|
-
const scene = (0,
|
|
3511
|
-
() => state.document.tier === "editable" ? (0,
|
|
3647
|
+
const scene = (0, import_react32.useMemo)(
|
|
3648
|
+
() => 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
3649
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3513
3650
|
[state.document, canvas.layout, state.selection]
|
|
3514
3651
|
);
|
|
3515
|
-
const layoutRef = (0,
|
|
3652
|
+
const layoutRef = (0, import_react32.useRef)(canvas.layout);
|
|
3516
3653
|
layoutRef.current = canvas.layout;
|
|
3517
|
-
const actions = (0,
|
|
3654
|
+
const actions = (0, import_react32.useMemo)(
|
|
3518
3655
|
() => ({
|
|
3519
3656
|
apply: (ops, label) => controller.apply(ops, label),
|
|
3520
3657
|
load: (source, options) => controller.load(source, options),
|
|
3521
3658
|
moveNodes: (moved, all = moved) => {
|
|
3522
|
-
const op = (0,
|
|
3659
|
+
const op = (0, import_canvas24.mermaidMovesFromCanvas)(layoutRef.current, moved, all, { stored: controller.getDocument().meta.layout ?? {} });
|
|
3523
3660
|
return op ? controller.apply(op, "Move") : null;
|
|
3524
3661
|
},
|
|
3525
3662
|
connect: (source, target, label) => controller.apply({ type: "addEdge", edge: { source, target, ...label ? { label } : {} } }, "Connect"),
|
|
@@ -3538,7 +3675,7 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
3538
3675
|
"Rename"
|
|
3539
3676
|
),
|
|
3540
3677
|
renameTarget: (target, label) => {
|
|
3541
|
-
const op = (0,
|
|
3678
|
+
const op = (0, import_canvas24.diagramRenameOp)(controller.getDocument(), target, label);
|
|
3542
3679
|
return op ? controller.apply(op, "Rename") : null;
|
|
3543
3680
|
},
|
|
3544
3681
|
select: (ids) => controller.select(ids),
|
|
@@ -3551,13 +3688,13 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
3551
3688
|
}
|
|
3552
3689
|
function useMermaidStream(source, options = {}) {
|
|
3553
3690
|
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,
|
|
3691
|
+
const stream = (0, import_react32.useRef)(null);
|
|
3692
|
+
if (!stream.current) stream.current = new import_canvas24.DiagramStream(layoutOptions);
|
|
3693
|
+
const result = (0, import_react32.useMemo)(() => stream.current.update(source, complete), [source, complete]);
|
|
3694
|
+
const [shown, setShown] = (0, import_react32.useState)({ layout: result.layout, settled: true });
|
|
3695
|
+
const shownRef = (0, import_react32.useRef)(shown.layout);
|
|
3559
3696
|
shownRef.current = shown.layout;
|
|
3560
|
-
(0,
|
|
3697
|
+
(0, import_react32.useEffect)(() => {
|
|
3561
3698
|
const target = result.layout;
|
|
3562
3699
|
if (!target) return setShown({ layout: null, settled: true });
|
|
3563
3700
|
const from = shownRef.current;
|
|
@@ -3567,14 +3704,14 @@ function useMermaidStream(source, options = {}) {
|
|
|
3567
3704
|
const start = performance.now();
|
|
3568
3705
|
const step = () => {
|
|
3569
3706
|
const t = Math.min(1, (performance.now() - start) / duration);
|
|
3570
|
-
setShown({ layout: (0,
|
|
3707
|
+
setShown({ layout: (0, import_canvas24.blendDiagramLayout)(from, target, (0, import_canvas24.easeDiagramTween)(t)), settled: t >= 1 });
|
|
3571
3708
|
if (t < 1) frame = requestAnimationFrame(step);
|
|
3572
3709
|
};
|
|
3573
3710
|
frame = requestAnimationFrame(step);
|
|
3574
3711
|
return () => cancelAnimationFrame(frame);
|
|
3575
3712
|
}, [result.layout, duration]);
|
|
3576
3713
|
const doc = result.document.tier === "editable" ? result.document : null;
|
|
3577
|
-
const canvas = (0,
|
|
3714
|
+
const canvas = (0, import_react32.useMemo)(() => {
|
|
3578
3715
|
if (!doc || !shown.layout) return { nodes: [], edges: [] };
|
|
3579
3716
|
const placed = new Set(Object.keys(shown.layout.positions));
|
|
3580
3717
|
const graph = {
|
|
@@ -3583,24 +3720,24 @@ function useMermaidStream(source, options = {}) {
|
|
|
3583
3720
|
groups: doc.graph.groups.filter((g) => placed.has(g.id)),
|
|
3584
3721
|
edges: doc.graph.edges.filter((e) => placed.has(e.source) && placed.has(e.target))
|
|
3585
3722
|
};
|
|
3586
|
-
return (0,
|
|
3723
|
+
return (0, import_canvas24.mermaidToCanvas)({ ...doc, graph }, { layout: shown.layout });
|
|
3587
3724
|
}, [doc, shown.layout]);
|
|
3588
3725
|
return { document: doc, ...canvas, layout: shown.layout, settled: shown.settled };
|
|
3589
3726
|
}
|
|
3590
3727
|
|
|
3591
3728
|
// src/canvas/MermaidDiagramNode.tsx
|
|
3592
|
-
var
|
|
3593
|
-
var
|
|
3729
|
+
var import_canvas25 = require("@pixerate/editor/canvas");
|
|
3730
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3594
3731
|
function mermaidNodeStyle(styles = {}, selected = false) {
|
|
3595
|
-
const paint = (0,
|
|
3732
|
+
const paint = (0, import_canvas25.mermaidNodePaint)(styles, selected);
|
|
3596
3733
|
const { color, "stroke-width": strokeWidth, "stroke-dasharray": strokeDasharray, ...vars } = paint;
|
|
3597
3734
|
return { ...vars, color, strokeWidth, strokeDasharray };
|
|
3598
3735
|
}
|
|
3599
3736
|
function MermaidDiagramNode({ data, width = 160, height = 56, selected, className = "", children }) {
|
|
3600
3737
|
const node = data.node;
|
|
3601
3738
|
if (!node) return null;
|
|
3602
|
-
const members = (0,
|
|
3603
|
-
return /* @__PURE__ */ (0,
|
|
3739
|
+
const members = (0, import_canvas25.mermaidNodeMembers)(node.data);
|
|
3740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3604
3741
|
"div",
|
|
3605
3742
|
{
|
|
3606
3743
|
className: `pixerate-diagram-node ${className}`.trim(),
|
|
@@ -3608,14 +3745,14 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
3608
3745
|
"data-selected": selected ? "true" : void 0,
|
|
3609
3746
|
style: { position: "relative", width: "100%", height: "100%", ...mermaidNodeStyle(data.resolvedStyles, selected) },
|
|
3610
3747
|
children: [
|
|
3611
|
-
/* @__PURE__ */ (0,
|
|
3612
|
-
/* @__PURE__ */ (0,
|
|
3748
|
+
/* @__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)) }),
|
|
3749
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3613
3750
|
"div",
|
|
3614
3751
|
{
|
|
3615
3752
|
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
3753
|
children: [
|
|
3617
|
-
(0,
|
|
3618
|
-
members.length > 0 && /* @__PURE__ */ (0,
|
|
3754
|
+
(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)),
|
|
3755
|
+
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
3756
|
]
|
|
3620
3757
|
}
|
|
3621
3758
|
),
|
|
@@ -3627,7 +3764,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
3627
3764
|
function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
3628
3765
|
const group = data.group;
|
|
3629
3766
|
if (!group) return null;
|
|
3630
|
-
return /* @__PURE__ */ (0,
|
|
3767
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3631
3768
|
"div",
|
|
3632
3769
|
{
|
|
3633
3770
|
className: `pixerate-diagram-group ${className}`.trim(),
|
|
@@ -3642,7 +3779,7 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
3642
3779
|
color: data.resolvedStyles?.color ?? "var(--muted-foreground, #475569)"
|
|
3643
3780
|
},
|
|
3644
3781
|
children: [
|
|
3645
|
-
/* @__PURE__ */ (0,
|
|
3782
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { padding: "6px 10px", fontSize: 12, fontWeight: 600 }, children: (0, import_canvas25.mermaidLabelLines)(group.label).join(" ") }),
|
|
3646
3783
|
children
|
|
3647
3784
|
]
|
|
3648
3785
|
}
|
|
@@ -3650,29 +3787,29 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
3650
3787
|
}
|
|
3651
3788
|
|
|
3652
3789
|
// src/canvas/MermaidThumbnail.tsx
|
|
3653
|
-
var
|
|
3790
|
+
var import_react33 = require("react");
|
|
3654
3791
|
var import_diagram2 = require("@pixerate/editor/diagram");
|
|
3655
|
-
var
|
|
3656
|
-
var
|
|
3792
|
+
var import_canvas26 = require("@pixerate/editor/canvas");
|
|
3793
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3657
3794
|
function MermaidThumbnail({ source, className = "", fallback = null, ...options }) {
|
|
3658
|
-
const doc = (0,
|
|
3795
|
+
const doc = (0, import_react33.useMemo)(() => typeof source === "string" ? (0, import_diagram2.parseMermaid)(source) : source, [source]);
|
|
3659
3796
|
const key = JSON.stringify(options);
|
|
3660
|
-
const drawn = (0,
|
|
3661
|
-
() => doc.tier === "editable" && doc.graph.nodes.length ? (0,
|
|
3797
|
+
const drawn = (0, import_react33.useMemo)(
|
|
3798
|
+
() => doc.tier === "editable" && doc.graph.nodes.length ? (0, import_canvas26.mermaidThumbnailSvg)(doc, options) : null,
|
|
3662
3799
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3663
3800
|
[doc, key]
|
|
3664
3801
|
);
|
|
3665
|
-
if (!drawn) return /* @__PURE__ */ (0,
|
|
3666
|
-
return /* @__PURE__ */ (0,
|
|
3802
|
+
if (!drawn) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: fallback });
|
|
3803
|
+
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
3804
|
}
|
|
3668
3805
|
|
|
3669
3806
|
// src/canvas/useDiagramDirector.ts
|
|
3670
|
-
var
|
|
3807
|
+
var import_react34 = require("react");
|
|
3671
3808
|
var import_diagram3 = require("@pixerate/editor/diagram");
|
|
3672
3809
|
function useDiagramDirector(controller, options) {
|
|
3673
|
-
const placement = (0,
|
|
3810
|
+
const placement = (0, import_react34.useRef)(options.placement);
|
|
3674
3811
|
placement.current = options.placement;
|
|
3675
|
-
const ref = (0,
|
|
3812
|
+
const ref = (0, import_react34.useRef)(null);
|
|
3676
3813
|
if (!ref.current) {
|
|
3677
3814
|
const presence = new import_diagram3.PresenceStore();
|
|
3678
3815
|
ref.current = {
|
|
@@ -3683,17 +3820,17 @@ function useDiagramDirector(controller, options) {
|
|
|
3683
3820
|
return ref.current;
|
|
3684
3821
|
}
|
|
3685
3822
|
function usePresenceState(presence) {
|
|
3686
|
-
return (0,
|
|
3823
|
+
return (0, import_react34.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
3687
3824
|
}
|
|
3688
3825
|
|
|
3689
3826
|
// src/canvas/DiagramPresenceLayer.tsx
|
|
3690
|
-
var
|
|
3827
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3691
3828
|
function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
3692
3829
|
const { actors } = usePresenceState(presence);
|
|
3693
3830
|
if (!actors.length) return null;
|
|
3694
|
-
return /* @__PURE__ */ (0,
|
|
3695
|
-
/* @__PURE__ */ (0,
|
|
3696
|
-
/* @__PURE__ */ (0,
|
|
3831
|
+
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: [
|
|
3832
|
+
/* @__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 } }) }),
|
|
3833
|
+
/* @__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
3834
|
] }, a.id)) });
|
|
3698
3835
|
}
|
|
3699
3836
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -3731,6 +3868,7 @@ function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
|
3731
3868
|
MermaidDiagramNode,
|
|
3732
3869
|
MermaidFamilyScene,
|
|
3733
3870
|
MermaidThumbnail,
|
|
3871
|
+
PresenceLayer,
|
|
3734
3872
|
RESIZE_HANDLES,
|
|
3735
3873
|
SHAPE_DATA_KEY,
|
|
3736
3874
|
SHAPE_KINDS,
|
|
@@ -4045,6 +4183,7 @@ function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
|
4045
4183
|
useCanvasGraph,
|
|
4046
4184
|
useCanvasLayout,
|
|
4047
4185
|
useCanvasMeasure,
|
|
4186
|
+
useCanvasPlaybackSurface,
|
|
4048
4187
|
useCanvasScenes,
|
|
4049
4188
|
useCanvasShortcuts,
|
|
4050
4189
|
useCanvasTokens,
|