@revideo/2d 0.3.7-beta.987 → 0.3.7-blue.987
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.css +1 -1
- package/editor/index.js +96 -151
- package/lib/code/CodeCursor.js +286 -352
- package/lib/code/CodeScope.js +61 -59
- package/lib/code/CodeSignal.js +189 -206
- package/lib/code/LezerHighlighter.js +101 -101
- package/lib/components/Audio.js +114 -120
- package/lib/components/Bezier.js +75 -86
- package/lib/components/CodeBlock.d.ts +1 -1
- package/lib/components/Media.d.ts +2 -0
- package/lib/components/Media.d.ts.map +1 -1
- package/lib/components/Media.js +18 -2
- package/lib/components/Node.d.ts +1 -1
- package/lib/components/Path.d.ts +1 -1
- package/lib/components/SVG.d.ts +1 -1
- package/lib/components/Shape.d.ts +1 -1
- package/lib/components/Video.d.ts.map +1 -1
- package/lib/components/Video.js +2 -4
- package/lib/scenes/Scene2D.js +3 -3
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/utils/CanvasUtils.d.ts +1 -1
- package/package.json +3 -3
package/editor/index.css
CHANGED
package/editor/index.js
CHANGED
|
@@ -1,101 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@
|
|
8
|
-
import {NODE_NAME} from '@revideo/2d';
|
|
9
|
-
import {SceneRenderEvent, Vector2} from '@revideo/core';
|
|
10
|
-
import {
|
|
11
|
-
AccountTree,
|
|
12
|
-
AutoField,
|
|
13
|
-
Button,
|
|
14
|
-
Collapse,
|
|
15
|
-
Group,
|
|
16
|
-
Label,
|
|
17
|
-
MouseButton,
|
|
18
|
-
OverlayWrapper,
|
|
19
|
-
Pane,
|
|
20
|
-
Separator,
|
|
21
|
-
Tab,
|
|
22
|
-
Toggle,
|
|
23
|
-
UnknownField,
|
|
24
|
-
emphasize,
|
|
25
|
-
findAndOpenFirstUserFile,
|
|
26
|
-
makeEditorPlugin,
|
|
27
|
-
useApplication,
|
|
28
|
-
useCurrentScene,
|
|
29
|
-
usePanels,
|
|
30
|
-
useReducedMotion,
|
|
31
|
-
useViewportContext,
|
|
32
|
-
useViewportMatrix,
|
|
33
|
-
} from '@revideo/ui';
|
|
34
|
-
import {createContext} from 'preact';
|
|
35
|
-
import {useContext, useEffect, useMemo, useRef} from 'preact/hooks';
|
|
36
|
-
import {Fragment, jsx, jsxs} from 'preact/jsx-runtime';
|
|
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';
|
|
2
|
+
import { signal, computed, useSignalEffect, useComputed, useSignal } from '@preact/signals';
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'preact/jsx-runtime';
|
|
4
|
+
import { SceneRenderEvent, Vector2 } from '@revideo/core';
|
|
5
|
+
import { createContext } from 'preact';
|
|
6
|
+
import { useMemo, useContext, useRef, useEffect } from 'preact/hooks';
|
|
7
|
+
import { NODE_NAME } from '@revideo/2d';
|
|
37
8
|
import './index.css';
|
|
38
9
|
|
|
39
10
|
const PluginContext = createContext(null);
|
|
40
11
|
const NodeInspectorKey = '@revideo/2d/node-inspector';
|
|
41
12
|
function usePluginState() {
|
|
42
|
-
|
|
13
|
+
return useContext(PluginContext);
|
|
43
14
|
}
|
|
44
|
-
function Provider({children}) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
15
|
+
function Provider({ children }) {
|
|
16
|
+
const { inspection } = useApplication();
|
|
17
|
+
const currentScene = useCurrentScene();
|
|
18
|
+
const state = useMemo(() => {
|
|
19
|
+
const scene = signal(currentScene);
|
|
20
|
+
const selectedKey = signal(null);
|
|
21
|
+
const afterRender = signal(0);
|
|
22
|
+
const hoveredKey = signal(null);
|
|
23
|
+
const openNodes = new Map();
|
|
24
|
+
const selectedChain = computed(() => {
|
|
25
|
+
const chain = new Set();
|
|
26
|
+
const key = selectedKey.value;
|
|
27
|
+
const selectedNode = scene.value?.getNode(key);
|
|
28
|
+
if (selectedNode) {
|
|
29
|
+
let node = selectedNode.parent() ?? null;
|
|
30
|
+
while (node) {
|
|
31
|
+
chain.add(node.key);
|
|
32
|
+
node = node.parent();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return chain;
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
selectedKey,
|
|
39
|
+
hoveredKey,
|
|
40
|
+
afterRender,
|
|
41
|
+
openNodes,
|
|
42
|
+
selectedChain,
|
|
43
|
+
scene,
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
state.scene.value = currentScene;
|
|
47
|
+
useSignalEffect(() => state.scene.value?.onRenderLifecycle.subscribe(([event]) => {
|
|
48
|
+
if (event === SceneRenderEvent.AfterRender) {
|
|
49
|
+
state.afterRender.value++;
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
useSignalEffect(() => {
|
|
53
|
+
const { key, payload } = inspection.value;
|
|
54
|
+
if (key === NodeInspectorKey) {
|
|
55
|
+
state.selectedKey.value = payload;
|
|
62
56
|
}
|
|
63
|
-
}
|
|
64
|
-
return chain;
|
|
65
57
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
state.scene.value?.onRenderLifecycle.subscribe(([event]) => {
|
|
78
|
-
if (event === SceneRenderEvent.AfterRender) {
|
|
79
|
-
state.afterRender.value++;
|
|
80
|
-
}
|
|
81
|
-
}),
|
|
82
|
-
);
|
|
83
|
-
useSignalEffect(() => {
|
|
84
|
-
const {key, payload} = inspection.value;
|
|
85
|
-
if (key === NodeInspectorKey) {
|
|
86
|
-
state.selectedKey.value = payload;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
useSignalEffect(() => {
|
|
90
|
-
const nodeKey = state.selectedKey.value;
|
|
91
|
-
const {key, payload} = inspection.peek();
|
|
92
|
-
if (key === NodeInspectorKey && !nodeKey) {
|
|
93
|
-
inspection.value = {key: '', payload: null};
|
|
94
|
-
} else if (payload !== nodeKey) {
|
|
95
|
-
inspection.value = {key: NodeInspectorKey, payload: nodeKey};
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return jsx(PluginContext.Provider, {value: state, children: children});
|
|
58
|
+
useSignalEffect(() => {
|
|
59
|
+
const nodeKey = state.selectedKey.value;
|
|
60
|
+
const { key, payload } = inspection.peek();
|
|
61
|
+
if (key === NodeInspectorKey && !nodeKey) {
|
|
62
|
+
inspection.value = { key: '', payload: null };
|
|
63
|
+
}
|
|
64
|
+
else if (payload !== nodeKey) {
|
|
65
|
+
inspection.value = { key: NodeInspectorKey, payload: nodeKey };
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return (jsx(PluginContext.Provider, { value: state, children: children }));
|
|
99
69
|
}
|
|
100
70
|
|
|
101
71
|
function Component$1() {
|
|
@@ -168,46 +138,43 @@ const NodeInspectorConfig = {
|
|
|
168
138
|
component: Component$1,
|
|
169
139
|
};
|
|
170
140
|
|
|
171
|
-
function Component({children}) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
selectedKey.value = scene.value.inspectPosition(position.x, position.y);
|
|
185
|
-
},
|
|
186
|
-
children: children,
|
|
187
|
-
});
|
|
141
|
+
function Component({ children }) {
|
|
142
|
+
const state = useViewportContext();
|
|
143
|
+
const { scene, selectedKey } = usePluginState();
|
|
144
|
+
const matrix = useViewportMatrix();
|
|
145
|
+
return (jsx(OverlayWrapper, { onPointerDown: event => {
|
|
146
|
+
if (event.button !== MouseButton.Left || event.shiftKey)
|
|
147
|
+
return;
|
|
148
|
+
if (!scene.value)
|
|
149
|
+
return;
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
const position = new Vector2(event.x - state.rect.x, event.y - state.rect.y).transformAsPoint(matrix.inverse());
|
|
152
|
+
selectedKey.value = scene.value.inspectPosition(position.x, position.y);
|
|
153
|
+
}, children: children }));
|
|
188
154
|
}
|
|
189
155
|
function drawHook() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
156
|
+
const { selectedKey, hoveredKey, afterRender, scene } = usePluginState();
|
|
157
|
+
selectedKey.value;
|
|
158
|
+
hoveredKey.value;
|
|
159
|
+
afterRender.value;
|
|
160
|
+
return (ctx, matrix) => {
|
|
161
|
+
const currentScene = scene.peek();
|
|
162
|
+
if (!currentScene)
|
|
163
|
+
return;
|
|
164
|
+
let node = currentScene.getNode(selectedKey.value);
|
|
165
|
+
if (node) {
|
|
166
|
+
currentScene.drawOverlay(node.key, matrix, ctx);
|
|
167
|
+
}
|
|
168
|
+
node = currentScene.getNode(hoveredKey.value);
|
|
169
|
+
if (node && hoveredKey.value !== selectedKey.value) {
|
|
170
|
+
ctx.globalAlpha = 0.5;
|
|
171
|
+
currentScene.drawOverlay(hoveredKey.value, matrix, ctx);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
207
174
|
}
|
|
208
175
|
const PreviewOverlayConfig = {
|
|
209
|
-
|
|
210
|
-
|
|
176
|
+
drawHook,
|
|
177
|
+
component: Component,
|
|
211
178
|
};
|
|
212
179
|
|
|
213
180
|
function CircleIcon() {
|
|
@@ -391,31 +358,9 @@ const IconMap = {
|
|
|
391
358
|
View2D: View2DIcon,
|
|
392
359
|
};
|
|
393
360
|
|
|
394
|
-
function r(e) {
|
|
395
|
-
var t,
|
|
396
|
-
f,
|
|
397
|
-
n = '';
|
|
398
|
-
if ('string' == typeof e || 'number' == typeof e) n += e;
|
|
399
|
-
else if ('object' == typeof e)
|
|
400
|
-
if (Array.isArray(e)) {
|
|
401
|
-
var o = e.length;
|
|
402
|
-
for (t = 0; t < o; t++)
|
|
403
|
-
e[t] && (f = r(e[t])) && (n && (n += ' '), (n += f));
|
|
404
|
-
} else for (f in e) e[f] && (n && (n += ' '), (n += f));
|
|
405
|
-
return n;
|
|
406
|
-
}
|
|
407
|
-
function clsx() {
|
|
408
|
-
for (var e, t, f = 0, n = '', o = arguments.length; f < o; f++)
|
|
409
|
-
(e = arguments[f]) && (t = r(e)) && (n && (n += ' '), (n += t));
|
|
410
|
-
return n;
|
|
411
|
-
}
|
|
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}
|
|
412
362
|
|
|
413
|
-
var styles = {
|
|
414
|
-
root: 'index-module_root__omEd0',
|
|
415
|
-
label: 'index-module_label__9BJvW',
|
|
416
|
-
active: 'index-module_active__KevXv',
|
|
417
|
-
parent: 'index-module_parent__5nc9I',
|
|
418
|
-
};
|
|
363
|
+
var styles = {"root":"index-module_root__omEd0","label":"index-module_label__9BJvW","active":"index-module_active__KevXv","parent":"index-module_parent__5nc9I"};
|
|
419
364
|
|
|
420
365
|
const DEPTH_VAR = '--depth';
|
|
421
366
|
function TreeElement({
|
|
@@ -620,5 +565,5 @@ var index = makeEditorPlugin(() => {
|
|
|
620
565
|
};
|
|
621
566
|
});
|
|
622
567
|
|
|
623
|
-
export {index as default};
|
|
568
|
+
export { index as default };
|
|
624
569
|
//# sourceMappingURL=index.js.map
|