@revideo/2d 0.4.6 → 0.4.7-alpha.1022
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/editor/editor/tsconfig.build.tsbuildinfo +1 -1
- package/editor/index.js +380 -151
- package/editor/index.js.map +1 -1
- package/lib/code/CodeCursor.d.ts +74 -74
- package/lib/code/CodeDiffer.d.ts +21 -16
- package/lib/code/CodeDiffer.js +39 -41
- package/lib/code/CodeFragment.d.ts +16 -8
- package/lib/code/CodeFragment.js +36 -36
- package/lib/code/CodeHighlighter.d.ts +59 -59
- package/lib/code/CodeHighlighter.js +1 -1
- package/lib/code/CodeMetrics.d.ts +12 -8
- package/lib/code/CodeMetrics.js +26 -24
- package/lib/code/CodeRange.d.ts +21 -5
- package/lib/code/CodeRange.js +131 -124
- package/lib/code/CodeScope.d.ts +18 -8
- package/lib/code/CodeSelection.d.ts +9 -4
- package/lib/code/CodeSelection.js +8 -8
- package/lib/code/CodeSignal.d.ts +74 -47
- package/lib/code/CodeTokenizer.d.ts +1 -1
- package/lib/code/CodeTokenizer.js +41 -41
- package/lib/code/DefaultHighlightStyle.d.ts +2 -2
- package/lib/code/DefaultHighlightStyle.js +96 -96
- package/lib/code/LezerHighlighter.d.ts +21 -19
- package/lib/code/diff.d.ts +12 -9
- package/lib/code/diff.js +218 -205
- package/lib/code/extractRange.d.ts +7 -4
- package/lib/code/extractRange.js +79 -71
- package/lib/code/index.d.ts +1 -1
- package/lib/code/index.js +1 -1
- package/lib/components/Audio.d.ts +11 -11
- package/lib/components/Bezier.d.ts +18 -18
- package/lib/components/Circle.d.ts +95 -90
- package/lib/components/Code.d.ts +244 -211
- package/lib/components/CodeBlock.d.ts +1 -1
- package/lib/components/CubicBezier.d.ts +36 -36
- package/lib/components/Curve.d.ts +208 -198
- package/lib/components/Grid.d.ts +47 -42
- package/lib/components/HlsVideo.d.ts +62 -0
- package/lib/components/HlsVideo.d.ts.map +1 -0
- package/lib/components/HlsVideo.js +169 -0
- package/lib/components/Icon.d.ts +55 -50
- package/lib/components/Img.d.ts +86 -79
- package/lib/components/Knot.d.ts +97 -78
- package/lib/components/Latex.d.ts +12 -12
- package/lib/components/Layout.d.ts +455 -413
- package/lib/components/Line.d.ts +61 -49
- package/lib/components/Media.d.ts +37 -37
- package/lib/components/Node.d.ts +1 -1
- package/lib/components/Path.d.ts +1 -1
- package/lib/components/Polygon.d.ts +60 -55
- package/lib/components/QuadBezier.d.ts +29 -29
- package/lib/components/Ray.d.ts +28 -28
- package/lib/components/Rect.d.ts +115 -108
- package/lib/components/SVG.d.ts +1 -1
- package/lib/components/Shape.d.ts +1 -1
- package/lib/components/Spline.d.ts +46 -40
- package/lib/components/Txt.d.ts +55 -44
- package/lib/components/TxtLeaf.d.ts +20 -16
- package/lib/components/Video.d.ts +1 -1
- package/lib/components/Video.d.ts.map +1 -1
- package/lib/components/Video.js +5 -1
- package/lib/components/View2D.d.ts +22 -22
- package/lib/components/index.d.ts +1 -1
- package/lib/components/types.d.ts +22 -9
- package/lib/curves/ArcSegment.d.ts +36 -24
- package/lib/curves/CircleSegment.d.ts +26 -16
- package/lib/curves/CubicBezierSegment.d.ts +18 -13
- package/lib/curves/CurveDrawingInfo.d.ts +9 -9
- package/lib/curves/CurvePoint.d.ts +13 -13
- package/lib/curves/CurveProfile.d.ts +5 -5
- package/lib/curves/CurveProfile.js +1 -1
- package/lib/curves/KnotInfo.d.ts +8 -8
- package/lib/curves/LineSegment.d.ts +19 -14
- package/lib/curves/Polynomial.d.ts +110 -110
- package/lib/curves/Polynomial2D.d.ts +20 -20
- package/lib/curves/PolynomialSegment.d.ts +42 -37
- package/lib/curves/QuadBezierSegment.d.ts +12 -12
- package/lib/curves/Segment.d.ts +12 -7
- package/lib/curves/UniformPolynomialCurveSampler.d.ts +34 -34
- package/lib/curves/createCurveProfileLerp.d.ts +17 -6
- package/lib/curves/getBezierSplineProfile.d.ts +8 -4
- package/lib/curves/getCircleProfile.d.ts +10 -4
- package/lib/curves/getPathProfile.d.ts +2 -2
- package/lib/curves/getPointAtDistance.d.ts +7 -4
- package/lib/curves/getPolylineProfile.d.ts +8 -4
- package/lib/curves/getRectProfile.d.ts +9 -4
- package/lib/curves/index.d.ts +1 -1
- package/lib/curves/index.js +1 -1
- package/lib/decorators/canvasStyleSignal.d.ts +3 -3
- package/lib/decorators/colorSignal.d.ts +1 -1
- package/lib/decorators/compound.d.ts +4 -2
- package/lib/decorators/computed.d.ts +1 -1
- package/lib/decorators/defaultStyle.d.ts +5 -2
- package/lib/decorators/filtersSignal.d.ts +28 -8
- package/lib/decorators/index.d.ts +1 -1
- package/lib/decorators/index.js +1 -1
- package/lib/decorators/initializers.d.ts +5 -2
- package/lib/decorators/initializers.js +18 -19
- package/lib/decorators/nodeName.d.ts +1 -1
- package/lib/decorators/nodeName.js +4 -4
- package/lib/decorators/signal.d.ts +40 -20
- package/lib/decorators/spacingSignal.d.ts +1 -1
- package/lib/decorators/vector2Signal.d.ts +13 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/jsx-dev-runtime.d.ts +3 -3
- package/lib/jsx-dev-runtime.js +3 -3
- package/lib/jsx-runtime.d.ts +19 -9
- package/lib/jsx-runtime.js +18 -18
- package/lib/partials/Filter.d.ts +24 -16
- package/lib/partials/Gradient.d.ts +30 -24
- package/lib/partials/Pattern.d.ts +14 -9
- package/lib/partials/ShaderConfig.d.ts +81 -74
- package/lib/partials/index.d.ts +1 -1
- package/lib/partials/index.js +1 -1
- package/lib/partials/types.d.ts +19 -6
- package/lib/scenes/Scene2D.d.ts +42 -23
- package/lib/scenes/index.d.ts +1 -1
- package/lib/scenes/index.js +1 -1
- package/lib/scenes/makeScene2D.d.ts +7 -5
- package/lib/scenes/useScene2D.d.ts +2 -2
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/utils/diff.d.ts +25 -18
- package/lib/utils/diff.js +84 -87
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/is.d.ts +4 -2
- package/lib/utils/is.js +2 -2
- package/lib/utils/makeSignalExtensions.d.ts +11 -4
- package/package.json +5 -5
- package/src/lib/components/Video.ts +7 -2
package/editor/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import './index.css';
|
|
2
1
|
import { useApplication, useCurrentScene, Pane, Separator, Group, Label, Button, findAndOpenFirstUserFile, UnknownField, AutoField, useViewportContext, useViewportMatrix, OverlayWrapper, MouseButton, Toggle, Collapse, usePanels, useReducedMotion, emphasize, Tab, AccountTree, makeEditorPlugin } from '@revideo/ui';
|
|
3
|
-
import { jsx, jsxs, Fragment } from 'preact/jsx-runtime';
|
|
4
2
|
import { signal, computed, useSignalEffect, useComputed, useSignal } from '@preact/signals';
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'preact/jsx-runtime';
|
|
5
4
|
import { SceneRenderEvent, Vector2 } from '@revideo/core';
|
|
6
5
|
import { createContext } from 'preact';
|
|
7
6
|
import { useMemo, useContext, useRef, useEffect } from 'preact/hooks';
|
|
8
7
|
import { NODE_NAME } from '@revideo/2d';
|
|
8
|
+
import './index.css';
|
|
9
9
|
|
|
10
10
|
const PluginContext = createContext(null);
|
|
11
11
|
const NodeInspectorKey = '@revideo/2d/node-inspector';
|
|
@@ -69,32 +69,73 @@ function Provider({ children }) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function Component$1() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
const {inspection} = useApplication();
|
|
73
|
+
const {scene, afterRender} = usePluginState();
|
|
74
|
+
const node = useComputed(() => {
|
|
75
|
+
afterRender.value;
|
|
76
|
+
const {payload} = inspection.value;
|
|
77
|
+
return scene.value?.getNode(payload);
|
|
78
|
+
});
|
|
79
|
+
const attributes = useComputed(() => {
|
|
80
|
+
afterRender.value;
|
|
81
|
+
const currentNode = node.value;
|
|
82
|
+
const attributes = [];
|
|
83
|
+
if (currentNode) {
|
|
84
|
+
for (const {key, meta, signal} of currentNode) {
|
|
85
|
+
if (!meta.inspectable) continue;
|
|
86
|
+
attributes.push([key, signal()]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return attributes;
|
|
90
|
+
});
|
|
91
|
+
const stack = node.value?.creationStack;
|
|
92
|
+
return jsxs(Pane, {
|
|
93
|
+
title: 'Node Inspector',
|
|
94
|
+
id: 'node-inspector-pane',
|
|
95
|
+
children: [
|
|
96
|
+
jsx(Separator, {size: 1}),
|
|
97
|
+
stack &&
|
|
98
|
+
jsxs(Group, {
|
|
99
|
+
children: [
|
|
100
|
+
jsx(Label, {}),
|
|
101
|
+
jsx(Button, {
|
|
102
|
+
onClick: () => findAndOpenFirstUserFile(stack),
|
|
103
|
+
main: true,
|
|
104
|
+
children: 'GO TO SOURCE',
|
|
105
|
+
}),
|
|
106
|
+
],
|
|
107
|
+
}),
|
|
108
|
+
jsxs(Group, {
|
|
109
|
+
children: [
|
|
110
|
+
jsx(Label, {children: 'key'}),
|
|
111
|
+
jsx(UnknownField, {value: inspection.value.payload}),
|
|
112
|
+
],
|
|
113
|
+
}),
|
|
114
|
+
!node.value &&
|
|
115
|
+
jsxs(Group, {
|
|
116
|
+
children: [
|
|
117
|
+
jsx(Label, {}),
|
|
118
|
+
"Couldn't find the node. It may have been deleted or doesn't exist yet.",
|
|
119
|
+
],
|
|
120
|
+
}),
|
|
121
|
+
attributes.value.map(([key, value]) =>
|
|
122
|
+
jsxs(
|
|
123
|
+
Group,
|
|
124
|
+
{
|
|
125
|
+
children: [
|
|
126
|
+
jsx(Label, {children: key}),
|
|
127
|
+
jsx(AutoField, {value: value}),
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
key,
|
|
131
|
+
),
|
|
132
|
+
),
|
|
133
|
+
],
|
|
134
|
+
});
|
|
94
135
|
}
|
|
95
136
|
const NodeInspectorConfig = {
|
|
96
|
-
|
|
97
|
-
|
|
137
|
+
key: NodeInspectorKey,
|
|
138
|
+
component: Component$1,
|
|
98
139
|
};
|
|
99
140
|
|
|
100
141
|
function Component({ children }) {
|
|
@@ -137,78 +178,184 @@ const PreviewOverlayConfig = {
|
|
|
137
178
|
};
|
|
138
179
|
|
|
139
180
|
function CircleIcon() {
|
|
140
|
-
|
|
181
|
+
return jsx('svg', {
|
|
182
|
+
viewBox: '0 0 20 20',
|
|
183
|
+
fill: 'currentColor',
|
|
184
|
+
children: jsx('path', {
|
|
185
|
+
d: 'M10,5C12.76,5 15,7.24 15,10C15,12.76 12.76,15 10,15C7.24,15 5,12.76 5,10C5,7.24 7.24,5 10,5ZM10,7C8.344,7 7,8.344 7,10C7,11.656 8.344,13 10,13C11.656,13 13,11.656 13,10C13,8.344 11.656,7 10,7Z',
|
|
186
|
+
}),
|
|
187
|
+
});
|
|
141
188
|
}
|
|
142
189
|
|
|
143
190
|
function CodeBlockIcon() {
|
|
144
|
-
|
|
191
|
+
return jsxs('svg', {
|
|
192
|
+
viewBox: '0 0 20 20',
|
|
193
|
+
fill: 'currentColor',
|
|
194
|
+
children: [
|
|
195
|
+
jsx('path', {
|
|
196
|
+
d: 'M5,9L5,6.999C5,6.469 5.211,5.96 5.585,5.586C5.96,5.211 6.469,5 6.999,5L9,5L9,7L6.999,7L7,9L7,11L7,13L8.985,13L9,15L7,15C5.895,15 5,14.105 5,13L5,11L4,11L4,9L5,9Z',
|
|
197
|
+
}),
|
|
198
|
+
jsx('path', {
|
|
199
|
+
d: 'M15,11L15,13.001C15,13.531 14.789,14.04 14.415,14.414C14.04,14.789 13.531,15 13.001,15L11,15L11,13L13,13L13,11L13,9L13,7L11.015,7L11,5L13,5C14.105,5 15,5.895 15,7L15,9L16,9L16,11L15,11Z',
|
|
200
|
+
}),
|
|
201
|
+
],
|
|
202
|
+
});
|
|
145
203
|
}
|
|
146
204
|
|
|
147
205
|
function CurveIcon() {
|
|
148
|
-
|
|
206
|
+
return jsx('svg', {
|
|
207
|
+
viewBox: '0 0 20 20',
|
|
208
|
+
fill: 'currentColor',
|
|
209
|
+
children: jsx('path', {
|
|
210
|
+
d: 'M12.19,6.47L13.595,5.047C15.519,6.947 15.187,8.932 14.229,9.951C13.675,10.541 12.879,10.861 12.016,10.767C11.261,10.685 10.426,10.278 9.708,9.348C9.292,8.809 8.878,8.441 8.471,8.249C8.217,8.13 7.979,8.084 7.77,8.154C7.565,8.222 7.409,8.394 7.287,8.621C7.097,8.975 7.001,9.444 7,10.003C6.996,11.584 7.848,12.746 8.91,12.946C9.535,13.064 10.185,12.783 10.687,12.082L12.313,13.247C11,15.079 9.118,15.344 7.581,14.591C6.161,13.896 4.994,12.246 5,9.997C5.005,7.945 5.963,6.649 7.136,6.257C8.281,5.874 9.866,6.278 11.292,8.126C11.81,8.799 12.421,8.954 12.772,8.581C13.196,8.13 13.042,7.312 12.19,6.47Z',
|
|
211
|
+
}),
|
|
212
|
+
});
|
|
149
213
|
}
|
|
150
214
|
|
|
151
215
|
function GridIcon() {
|
|
152
|
-
|
|
216
|
+
return jsx('svg', {
|
|
217
|
+
viewBox: '0 0 20 20',
|
|
218
|
+
fill: 'currentColor',
|
|
219
|
+
children: jsx('path', {
|
|
220
|
+
d: 'M6,8L4,8L4,6L6,6L6,4L8,4L8,6L12,6L12,4L14,4L14,6L16,6L16,8L14,8L14,12L16,12L16,14L14,14L14,16L12,16L12,14L8,14L8,16L6,16L6,14L4,14L4,12L6,12L6,8ZM8,12L12,12L12,8L8,8L8,12Z',
|
|
221
|
+
}),
|
|
222
|
+
});
|
|
153
223
|
}
|
|
154
224
|
|
|
155
225
|
function ImgIcon() {
|
|
156
|
-
|
|
226
|
+
return jsxs('svg', {
|
|
227
|
+
viewBox: '0 0 20 20',
|
|
228
|
+
fill: 'currentColor',
|
|
229
|
+
children: [
|
|
230
|
+
jsx('path', {d: 'M5,15L15,15L15,10L13,8L8,13L5,10L5,15Z'}),
|
|
231
|
+
jsx('circle', {cx: '8', cy: '7', r: '2'}),
|
|
232
|
+
],
|
|
233
|
+
});
|
|
157
234
|
}
|
|
158
235
|
|
|
159
236
|
function LayoutIcon() {
|
|
160
|
-
|
|
237
|
+
return jsxs('svg', {
|
|
238
|
+
viewBox: '0 0 20 20',
|
|
239
|
+
fill: 'currentColor',
|
|
240
|
+
children: [
|
|
241
|
+
jsx('path', {
|
|
242
|
+
d: 'M14,5C14.552,5 15,5.448 15,6C15,7.916 15,12.084 15,14C15,14.552 14.552,15 14,15C12.815,15 11,15 11,15L11,5L14,5Z',
|
|
243
|
+
}),
|
|
244
|
+
jsx('path', {d: 'M9,5L9,9L5,9L5,6C5,5.448 5.448,5 6,5L9,5Z'}),
|
|
245
|
+
jsx('path', {d: 'M9,11L9,15L6,15C5.448,15 5,14.552 5,14L5,11L9,11Z'}),
|
|
246
|
+
],
|
|
247
|
+
});
|
|
161
248
|
}
|
|
162
249
|
|
|
163
250
|
function LineIcon() {
|
|
164
|
-
|
|
251
|
+
return jsx('svg', {
|
|
252
|
+
viewBox: '0 0 20 20',
|
|
253
|
+
fill: 'currentColor',
|
|
254
|
+
children: jsx('path', {
|
|
255
|
+
d: 'M9.906,4.589L11.411,5.906L8.529,9.2L13.859,8.439C14.273,8.379 14.68,8.584 14.879,8.952C15.078,9.319 15.028,9.772 14.753,10.087L10.094,15.411L8.589,14.094L11.471,10.8L6.141,11.561C5.727,11.621 5.32,11.416 5.121,11.048C4.922,10.681 4.972,10.228 5.247,9.913L9.906,4.589Z',
|
|
256
|
+
}),
|
|
257
|
+
});
|
|
165
258
|
}
|
|
166
259
|
|
|
167
260
|
function NodeIcon() {
|
|
168
|
-
|
|
261
|
+
return jsx('svg', {
|
|
262
|
+
viewBox: '0 0 20 20',
|
|
263
|
+
fill: 'currentColor',
|
|
264
|
+
children: jsx('path', {
|
|
265
|
+
d: 'M7,9L5,9L5,7L7,7L7,5L9,5L9,7L12,7L12,5L15,8L12,11L12,9L9,9L9,12L11,12L8,15L5,12L7,12L7,9Z',
|
|
266
|
+
}),
|
|
267
|
+
});
|
|
169
268
|
}
|
|
170
269
|
|
|
171
270
|
function RayIcon() {
|
|
172
|
-
|
|
271
|
+
return jsx('svg', {
|
|
272
|
+
viewBox: '0 0 20 20',
|
|
273
|
+
fill: 'currentColor',
|
|
274
|
+
children: jsx('path', {
|
|
275
|
+
d: 'M12,9.414L6.707,14.707L5.293,13.293L10.586,8L8,8L8,6L13,6C13.552,6 14,6.448 14,7L14,12L12,12L12,9.414Z',
|
|
276
|
+
}),
|
|
277
|
+
});
|
|
173
278
|
}
|
|
174
279
|
|
|
175
280
|
function RectIcon() {
|
|
176
|
-
|
|
281
|
+
return jsx('svg', {
|
|
282
|
+
viewBox: '0 0 20 20',
|
|
283
|
+
fill: 'currentColor',
|
|
284
|
+
children: jsx('path', {
|
|
285
|
+
d: 'M15,6L15,14C15,14.552 14.552,15 14,15L6,15C5.448,15 5,14.552 5,14L5,6C5,5.448 5.448,5 6,5L14,5C14.552,5 15,5.448 15,6ZM13,7L7,7L7,13L13,13L13,7Z',
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
177
288
|
}
|
|
178
289
|
|
|
179
290
|
function ShapeIcon() {
|
|
180
|
-
|
|
291
|
+
return jsx('svg', {
|
|
292
|
+
viewBox: '0 0 20 20',
|
|
293
|
+
fill: 'currentColor',
|
|
294
|
+
children: jsx('path', {
|
|
295
|
+
d: 'M11.746,10.93C12.637,12.664 11.973,14.504 10.611,15.244C9.692,15.743 8.385,15.804 6.94,14.829C5.555,13.893 4.689,12.16 4.544,10.388C4.395,8.572 5,6.752 6.399,5.701C8.069,4.445 10.793,4.271 12.765,4.921C14.324,5.436 15.374,6.473 15.495,7.691C15.651,9.262 14.613,10.061 13.26,10.5C12.847,10.634 12.41,10.735 12.02,10.841C11.936,10.864 11.838,10.897 11.746,10.93ZM7.601,7.299C6.737,7.949 6.445,9.103 6.537,10.224C6.633,11.389 7.149,12.556 8.06,13.171C8.696,13.601 9.251,13.706 9.656,13.486C10.207,13.187 10.315,12.395 9.886,11.701C9.48,11.044 9.513,10.523 9.68,10.122C9.835,9.75 10.164,9.417 10.678,9.187C11.243,8.935 12.157,8.8 12.908,8.503C13.216,8.381 13.542,8.264 13.505,7.888C13.485,7.691 13.359,7.53 13.197,7.384C12.928,7.143 12.558,6.959 12.138,6.821C10.736,6.358 8.789,6.406 7.601,7.299Z',
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
181
298
|
}
|
|
182
299
|
|
|
183
300
|
function TxtIcon() {
|
|
184
|
-
|
|
301
|
+
return jsxs('svg', {
|
|
302
|
+
viewBox: '0 0 20 20',
|
|
303
|
+
fill: 'currentColor',
|
|
304
|
+
children: [
|
|
305
|
+
jsx('path', {d: 'M9,13L9,6L11,6L11,13L12,13L12,15L8,15L8,13L9,13Z'}),
|
|
306
|
+
jsx('path', {
|
|
307
|
+
d: 'M7,8L5,8L5,6C5,5.448 5.448,5 6,5L14,5C14.552,5 15,5.448 15,6L15,8L13,8L13,7L7,7L7,8Z',
|
|
308
|
+
}),
|
|
309
|
+
],
|
|
310
|
+
});
|
|
185
311
|
}
|
|
186
312
|
|
|
187
313
|
function VideoIcon() {
|
|
188
|
-
|
|
314
|
+
return jsx('svg', {
|
|
315
|
+
viewBox: '0 0 20 20',
|
|
316
|
+
fill: 'currentColor',
|
|
317
|
+
children: jsx('path', {
|
|
318
|
+
d: 'M14,10.866L7.25,14.763C6.941,14.942 6.559,14.942 6.25,14.763C5.941,14.585 5.75,14.254 5.75,13.897L5.75,6.103C5.75,5.746 5.941,5.415 6.25,5.237C6.559,5.058 6.941,5.058 7.25,5.237L14,9.134C14.309,9.313 14.5,9.643 14.5,10C14.5,10.357 14.309,10.687 14,10.866ZM11.5,10L7.75,7.835L7.75,12.165L11.5,10Z',
|
|
319
|
+
}),
|
|
320
|
+
});
|
|
189
321
|
}
|
|
190
322
|
|
|
191
323
|
function View2DIcon() {
|
|
192
|
-
|
|
324
|
+
return jsxs('svg', {
|
|
325
|
+
viewBox: '0 0 20 20',
|
|
326
|
+
fill: 'currentColor',
|
|
327
|
+
children: [
|
|
328
|
+
jsx('path', {d: 'M9,5L9,7L7,7L7,9L5,9L5,6C5,5.448 5.448,5 6,5L9,5Z'}),
|
|
329
|
+
jsx('path', {
|
|
330
|
+
d: 'M5,11L7,11L7,13L9,13L9,15L6,15C5.448,15 5,14.552 5,14L5,11Z',
|
|
331
|
+
}),
|
|
332
|
+
jsx('path', {
|
|
333
|
+
d: 'M11,15L11,13L13,13L13,11L15,11L15,14C15,14.552 14.552,15 14,15L11,15Z',
|
|
334
|
+
}),
|
|
335
|
+
jsx('path', {
|
|
336
|
+
d: 'M15,9L13,9L13,7L11,7L11,5L14,5C14.552,5 15,5.448 15,6L15,9Z',
|
|
337
|
+
}),
|
|
338
|
+
],
|
|
339
|
+
});
|
|
193
340
|
}
|
|
194
341
|
|
|
195
342
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
196
343
|
const IconMap = {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
344
|
+
Circle: CircleIcon,
|
|
345
|
+
CodeBlock: CodeBlockIcon,
|
|
346
|
+
Curve: CurveIcon,
|
|
347
|
+
Grid: GridIcon,
|
|
348
|
+
Img: ImgIcon,
|
|
349
|
+
Layout: LayoutIcon,
|
|
350
|
+
Line: LineIcon,
|
|
351
|
+
Node: NodeIcon,
|
|
352
|
+
Ray: RayIcon,
|
|
353
|
+
Rect: RectIcon,
|
|
354
|
+
Shape: ShapeIcon,
|
|
355
|
+
Txt: TxtIcon,
|
|
356
|
+
TxtLeaf: TxtIcon,
|
|
357
|
+
Video: VideoIcon,
|
|
358
|
+
View2D: View2DIcon,
|
|
212
359
|
};
|
|
213
360
|
|
|
214
361
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
@@ -216,124 +363,206 @@ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else i
|
|
|
216
363
|
var styles = {"root":"index-module_root__omEd0","label":"index-module_label__9BJvW","active":"index-module_active__KevXv","parent":"index-module_parent__5nc9I"};
|
|
217
364
|
|
|
218
365
|
const DEPTH_VAR = '--depth';
|
|
219
|
-
function TreeElement({
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
366
|
+
function TreeElement({
|
|
367
|
+
label,
|
|
368
|
+
children,
|
|
369
|
+
selected,
|
|
370
|
+
depth = 0,
|
|
371
|
+
open,
|
|
372
|
+
icon,
|
|
373
|
+
forwardRef,
|
|
374
|
+
...props
|
|
375
|
+
}) {
|
|
376
|
+
const hasChildren = !!children;
|
|
377
|
+
return jsxs(Fragment, {
|
|
378
|
+
children: [
|
|
379
|
+
jsxs('div', {
|
|
380
|
+
ref: forwardRef,
|
|
381
|
+
className: clsx(
|
|
382
|
+
styles.label,
|
|
383
|
+
selected && styles.active,
|
|
384
|
+
hasChildren && styles.parent,
|
|
385
|
+
),
|
|
386
|
+
onDblClick: () => {
|
|
387
|
+
if (hasChildren) {
|
|
388
|
+
open.value = !open.value;
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
...props,
|
|
392
|
+
style: {[DEPTH_VAR]: `${depth}`},
|
|
393
|
+
children: [
|
|
394
|
+
hasChildren &&
|
|
395
|
+
jsx(Toggle, {
|
|
396
|
+
animated: false,
|
|
397
|
+
open: open.value,
|
|
398
|
+
onToggle: value => {
|
|
399
|
+
open.value = value;
|
|
400
|
+
},
|
|
401
|
+
onDblClick: e => {
|
|
402
|
+
e.stopPropagation();
|
|
403
|
+
},
|
|
404
|
+
}),
|
|
405
|
+
icon,
|
|
406
|
+
label,
|
|
407
|
+
],
|
|
408
|
+
}),
|
|
409
|
+
hasChildren &&
|
|
410
|
+
jsx(Collapse, {open: open.value, animated: false, children: children}),
|
|
411
|
+
],
|
|
412
|
+
});
|
|
230
413
|
}
|
|
231
414
|
|
|
232
|
-
function NodeElement({
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
415
|
+
function NodeElement({node, depth = 0}) {
|
|
416
|
+
const {selectedKey, hoveredKey, openNodes, selectedChain, afterRender} =
|
|
417
|
+
usePluginState();
|
|
418
|
+
const ref = useRef(null);
|
|
419
|
+
const open = useSignal(
|
|
420
|
+
selectedChain.peek().has(node.key) || (openNodes.get(node.key) ?? false),
|
|
421
|
+
);
|
|
422
|
+
const nodeSignal = useSignal(node);
|
|
423
|
+
nodeSignal.value = node;
|
|
424
|
+
const children = useComputed(() => {
|
|
425
|
+
afterRender.value;
|
|
426
|
+
return nodeSignal.value.peekChildren();
|
|
427
|
+
});
|
|
428
|
+
useSignalEffect(() => {
|
|
429
|
+
open.value = openNodes.get(nodeSignal.value.key) ?? false;
|
|
430
|
+
});
|
|
431
|
+
useSignalEffect(() => {
|
|
432
|
+
const chain = selectedChain.value;
|
|
433
|
+
if (chain.has(nodeSignal.value.key)) {
|
|
434
|
+
open.value = true;
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
useSignalEffect(() => {
|
|
438
|
+
openNodes.set(nodeSignal.value.key, open.value);
|
|
439
|
+
});
|
|
440
|
+
useSignalEffect(() => {
|
|
441
|
+
const key = selectedKey.value;
|
|
442
|
+
if (node.key === key) {
|
|
443
|
+
ref.current?.scrollIntoView({block: 'nearest', behavior: 'instant'});
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
const Icon = IconMap[node[NODE_NAME]] ?? IconMap.Node;
|
|
447
|
+
return jsx(TreeElement, {
|
|
448
|
+
forwardRef: ref,
|
|
449
|
+
open: open,
|
|
450
|
+
depth: depth,
|
|
451
|
+
icon: jsx(Icon, {}),
|
|
452
|
+
label: node.key,
|
|
453
|
+
selected: selectedKey.value === node.key,
|
|
454
|
+
onClick: event => {
|
|
455
|
+
selectedKey.value = node.key;
|
|
456
|
+
event.stopPropagation();
|
|
457
|
+
},
|
|
458
|
+
onPointerEnter: () => (hoveredKey.value = node.key),
|
|
459
|
+
onPointerLeave: () => (hoveredKey.value = null),
|
|
460
|
+
children:
|
|
461
|
+
children.value.length > 0 &&
|
|
462
|
+
children.value.map(child =>
|
|
463
|
+
jsx(NodeElement, {node: child, depth: depth + 1}),
|
|
464
|
+
),
|
|
465
|
+
});
|
|
266
466
|
}
|
|
267
467
|
|
|
268
|
-
function TreeRoot({
|
|
269
|
-
|
|
468
|
+
function TreeRoot({className, ...props}) {
|
|
469
|
+
return jsx('div', {className: clsx(styles.root, className), ...props});
|
|
270
470
|
}
|
|
271
471
|
|
|
272
472
|
function DetachedRoot() {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
473
|
+
const {afterRender, scene} = usePluginState();
|
|
474
|
+
const open = useSignal(false);
|
|
475
|
+
const currentScene = scene.value;
|
|
476
|
+
const children = currentScene ? [...currentScene.getDetachedNodes()] : [];
|
|
477
|
+
afterRender.value;
|
|
478
|
+
return children.length > 0
|
|
479
|
+
? jsx(TreeRoot, {
|
|
480
|
+
children: jsx(TreeElement, {
|
|
481
|
+
open: open,
|
|
482
|
+
label: 'Detached nodes',
|
|
483
|
+
children: children.map(child =>
|
|
484
|
+
jsx(NodeElement, {node: child, depth: 1}),
|
|
485
|
+
),
|
|
486
|
+
}),
|
|
487
|
+
})
|
|
488
|
+
: null;
|
|
279
489
|
}
|
|
280
490
|
|
|
281
491
|
function ViewRoot() {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
});
|
|
492
|
+
const {scene} = usePluginState();
|
|
493
|
+
const view = useSignal(scene.value?.getView());
|
|
494
|
+
useSignalEffect(() => {
|
|
495
|
+
view.value = scene.value?.getView();
|
|
496
|
+
return scene.value?.onReset.subscribe(() => {
|
|
497
|
+
view.value = scene.value?.getView();
|
|
289
498
|
});
|
|
290
|
-
|
|
499
|
+
});
|
|
500
|
+
return view.value
|
|
501
|
+
? jsx(TreeRoot, {children: jsx(NodeElement, {node: view.value})})
|
|
502
|
+
: null;
|
|
291
503
|
}
|
|
292
504
|
|
|
293
|
-
function TabComponent({
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
505
|
+
function TabComponent({tab}) {
|
|
506
|
+
const {sidebar} = usePanels();
|
|
507
|
+
const inspectorTab = useRef(null);
|
|
508
|
+
const reducedMotion = useReducedMotion();
|
|
509
|
+
const {selectedKey} = usePluginState();
|
|
510
|
+
const {logger} = useApplication();
|
|
511
|
+
useEffect(
|
|
512
|
+
() =>
|
|
513
|
+
logger.onInspected.subscribe(key => {
|
|
300
514
|
sidebar.set(tab);
|
|
301
515
|
selectedKey.value = key;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
516
|
+
}),
|
|
517
|
+
[tab],
|
|
518
|
+
);
|
|
519
|
+
useSignalEffect(() => {
|
|
520
|
+
if (
|
|
521
|
+
selectedKey.value &&
|
|
522
|
+
sidebar.current.peek() !== tab &&
|
|
523
|
+
!reducedMotion &&
|
|
524
|
+
inspectorTab.current &&
|
|
525
|
+
inspectorTab.current.getAnimations().length < 2
|
|
526
|
+
) {
|
|
527
|
+
inspectorTab.current.animate(emphasize(), {duration: 400});
|
|
528
|
+
inspectorTab.current.animate([{color: 'white'}, {color: ''}], {
|
|
529
|
+
duration: 800,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
return jsx(Tab, {
|
|
534
|
+
forwardRef: inspectorTab,
|
|
535
|
+
title: 'Scene Graph',
|
|
536
|
+
id: 'scene-graph-tab',
|
|
537
|
+
tab: tab,
|
|
538
|
+
children: jsx(AccountTree, {}),
|
|
539
|
+
});
|
|
316
540
|
}
|
|
317
541
|
function PaneComponent() {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
542
|
+
const {selectedKey} = usePluginState();
|
|
543
|
+
return jsxs(Pane, {
|
|
544
|
+
title: 'Scene Graph',
|
|
545
|
+
id: 'scene-graph-pane',
|
|
546
|
+
onClick: () => {
|
|
547
|
+
selectedKey.value = null;
|
|
548
|
+
},
|
|
549
|
+
children: [jsx(ViewRoot, {}), jsx(DetachedRoot, {})],
|
|
550
|
+
});
|
|
322
551
|
}
|
|
323
552
|
const SceneGraphTabConfig = {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
553
|
+
name: 'scene-graph',
|
|
554
|
+
tabComponent: TabComponent,
|
|
555
|
+
paneComponent: PaneComponent,
|
|
327
556
|
};
|
|
328
557
|
|
|
329
558
|
var index = makeEditorPlugin(() => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
559
|
+
return {
|
|
560
|
+
name: '@revideo/2d',
|
|
561
|
+
provider: Provider,
|
|
562
|
+
previewOverlay: PreviewOverlayConfig,
|
|
563
|
+
tabs: [SceneGraphTabConfig],
|
|
564
|
+
inspectors: [NodeInspectorConfig],
|
|
565
|
+
};
|
|
337
566
|
});
|
|
338
567
|
|
|
339
568
|
export { index as default };
|