🎥 Make videos programmatically with React
let's go
Jonny Burger9bf95da63ac2
diff --git a/packages/studio/src/components/Timeline/TimelineStack/get-stack.ts b/packages/studio/src/components/Timeline/TimelineStack/get-stack.tsnew file mode 100644index 0000000000..89c19759ee--- /dev/null+++ b/packages/studio/src/components/Timeline/TimelineStack/get-stack.ts@@ -0,0 +1,25 @@+import {SourceMapConsumer} from 'source-map';+import {getOriginalPosition} from '../../../error-overlay/react-overlay/utils/get-source-map';+import {getLocationOfSequence} from '../../../helpers/get-location-of-sequence';++export const getOriginalLocationFromStack = async (stack: string) => {+ const location = getLocationOfSequence(stack);+ if (!location) {+ return null;+ }++ const res = await fetch(`${location.fileName}.map`);+ const json = await res.json();++ const map = await new Promise((resolve) => {+ SourceMapConsumer.with(json, null, (consumer) => {+ resolve(consumer);+ });+ });+ const originalPosition = getOriginalPosition(+ map as SourceMapConsumer,+ location.lineNumber as number,+ location.columnNumber as number,+ );+ return originalPosition;+};diff --git a/packages/studio/src/components/Timeline/TimelineStack.tsx b/packages/studio/src/components/Timeline/TimelineStack/index.tsxsimilarity index 63%rename from packages/studio/src/components/Timeline/TimelineStack.tsxrename to packages/studio/src/components/Timeline/TimelineStack/index.tsxindex 1143e705bc..20d6f94644 100644--- a/packages/studio/src/components/Timeline/TimelineStack.tsx+++ b/packages/studio/src/components/Timeline/TimelineStack/index.tsx@@ -1,14 +1,14 @@import {useCallback, useEffect, useState} from 'react';import {SourceMapConsumer} from 'source-map';-import type {OriginalPosition} from '../../error-overlay/react-overlay/utils/get-source-map';-import {getOriginalPosition} from '../../error-overlay/react-overlay/utils/get-source-map';-import {SOURCE_MAP_ENDPOINT} from '../../error-overlay/react-overlay/utils/source-map-endpoint';-import {LIGHT_TEXT, VERY_LIGHT_TEXT} from '../../helpers/colors';-import {getLocationOfSequence} from '../../helpers/get-location-of-sequence';-import {openInEditor} from '../../helpers/open-in-editor';-import {Spacing} from '../layout';-import {sendErrorNotification} from '../Notifications/NotificationCenter';-import {Spinner} from '../Spinner';+import type {OriginalPosition} from '../../../error-overlay/react-overlay/utils/get-source-map';+import {SOURCE_MAP_ENDPOINT} from '../../../error-overlay/react-overlay/utils/source-map-endpoint';+import {LIGHT_TEXT, VERY_LIGHT_TEXT} from '../../../helpers/colors';+import {getLocationOfSequence} from '../../../helpers/get-location-of-sequence';+import {openInEditor} from '../../../helpers/open-in-editor';+import {Spacing} from '../../layout';+import {sendErrorNotification} from '../../Notifications/NotificationCenter';+import {Spinner} from '../../Spinner';+import {getOriginalLocationFromStack} from './get-stack';// @ts-expect-errorSourceMapConsumer.initialize({@@ -49,28 +49,16 @@ export const TimelineStack: React.FC<{const location = getLocationOfSequence(stack);if (location) {- fetch(`${location.fileName}.map`)- .then((res) => res.json())- .then((sourceMap) => {- return new Promise((resolve) => {- SourceMapConsumer.with(sourceMap, null, (consumer) => {- resolve(consumer);- });- });- })- .then((map) => {- return getOriginalPosition(- map as SourceMapConsumer,- location.lineNumber as number,- location.columnNumber as number,- );- })+ getOriginalLocationFromStack(stack).then((frame) => {setOriginalLocation(frame);}).catch((err) => {- console.log(err);+ // eslint-disable-next-line no-console+ console.error('Could not get original location of Sequence', err);});+ } else {+ setOriginalLocation(null);}}, [stack]);