Visualize Your Ideas With Code
build: enforce naming conventions (#452)
Jacob1532f4fb77f1
diff --git a/.eslintrc.json b/.eslintrc.jsonindex cf464371..ad1e9135 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -23,6 +23,54 @@"@typescript-eslint/ban-ts-comment": "off","@typescript-eslint/no-non-null-assertion": "off","@typescript-eslint/no-namespace": "off",- "tsdoc/syntax": "error"+ "tsdoc/syntax": "error",+ "@typescript-eslint/no-unused-vars": "error",+ "@typescript-eslint/naming-convention": [+ "error",+ {+ "selector": "default",+ "format": ["camelCase"],+ "leadingUnderscore": "forbid",+ "trailingUnderscore": "forbid",+ "filter": {+ "regex": "^__html$",+ "match": false+ }+ },+ {+ "selector": "variable",+ "format": ["camelCase", "PascalCase"]+ },+ {+ "selector": "variable",+ "modifiers": ["global"],+ "format": ["PascalCase", "UPPER_CASE"]+ },+ {+ "selector": "variable",+ "modifiers": ["exported"],+ "format": ["camelCase", "PascalCase"]+ },+ {+ "selector": ["parameter", "variable"],+ "modifiers": ["unused"],+ "format": ["camelCase"],+ "leadingUnderscore": "require"+ },+ {+ "selector": "function",+ "modifiers": ["global"],+ "format": ["camelCase", "PascalCase"]+ },+ {+ "selector": ["typeLike", "enumMember"],+ "format": ["PascalCase"]+ },+ {+ "selector": "typeParameter",+ "format": ["PascalCase"],+ "prefix": ["T"]+ }+ ]}}diff --git a/packages/2d/src/components/Latex.ts b/packages/2d/src/components/Latex.tsindex bf1feb19..c3e128e5 100644--- a/packages/2d/src/components/Latex.ts+++ b/packages/2d/src/components/Latex.ts@@ -14,11 +14,13 @@ import {import {OptionList} from 'mathjax-full/js/util/Options';import {useLogger} from '@motion-canvas/core/lib/utils';-const adaptor = liteAdaptor();-RegisterHTMLHandler(adaptor);+const Adaptor = liteAdaptor();+RegisterHTMLHandler(Adaptor);-const jaxDocument = mathjax.document('', {+const JaxDocument = mathjax.document('', {+ // eslint-disable-next-line @typescript-eslint/naming-conventionInputJax: new TeX({packages: AllPackages}),+ // eslint-disable-next-line @typescript-eslint/naming-conventionOutputJax: new SVG({fontCache: 'local'}),});@@ -54,7 +56,7 @@ export class Latex extends Img {// Convert to TeX, look for any errorsconst tex = this.tex();- const svg = adaptor.innerHTML(jaxDocument.convert(tex, this.options()));+ const svg = Adaptor.innerHTML(JaxDocument.convert(tex, this.options()));if (svg.includes('data-mjx-error')) {const errors = svg.match(/data-mjx-error="(.*?)"/);if (errors && errors.length > 0) {diff --git a/packages/2d/src/scenes/Scene2D.ts b/packages/2d/src/scenes/Scene2D.tsindex 2e6f57c0..86407ac2 100644--- a/packages/2d/src/scenes/Scene2D.ts+++ b/packages/2d/src/scenes/Scene2D.ts@@ -8,7 +8,6 @@ import {SceneRenderEvent,ThreadGeneratorFactory,} from '@motion-canvas/core/lib/scenes';-import {endScene, startScene} from '@motion-canvas/core/lib/utils';import {Vector2} from '@motion-canvas/core/lib/types';import {Node, View2D} from '../components';diff --git a/packages/core/src/decorators/threadable.ts b/packages/core/src/decorators/threadable.tsindex 67c37b94..d666d10b 100644--- a/packages/core/src/decorators/threadable.ts+++ b/packages/core/src/decorators/threadable.ts@@ -1,6 +1,6 @@export function threadable(customName?: string): MethodDecorator {return function (- target: unknown,+ _: unknown,propertyKey: string | symbol,descriptor: PropertyDescriptor,) {diff --git a/packages/core/src/media/loadImage.ts b/packages/core/src/media/loadImage.tsindex ee05fc66..f7b5236d 100644--- a/packages/core/src/media/loadImage.ts+++ b/packages/core/src/media/loadImage.ts@@ -1,7 +1,7 @@import {getContext} from '../utils';-let canvas: HTMLCanvasElement;-let context: CanvasRenderingContext2D;+let Canvas: HTMLCanvasElement;+let Context: CanvasRenderingContext2D;export type ImageDataSource = CanvasImageSource & {width: number;@@ -26,13 +26,13 @@ export function loadAnimation(sources: string[]): Promise<HTMLImageElement[]> {}export function getImageData(image: ImageDataSource) {- canvas ??= document.createElement('canvas');- context ??= getContext({willReadFrequently: true}, canvas);+ Canvas ??= document.createElement('canvas');+ Context ??= getContext({willReadFrequently: true}, Canvas);- canvas.width = image.width;- canvas.height = image.height;- context.clearRect(0, 0, image.width, image.height);- context.drawImage(image, 0, 0);+ Canvas.width = image.width;+ Canvas.height = image.height;+ Context.clearRect(0, 0, image.width, image.height);+ Context.drawImage(image, 0, 0);- return context.getImageData(0, 0, image.width, image.height);+ return Context.getImageData(0, 0, image.width, image.height);}diff --git a/packages/core/src/scenes/GeneratorScene.ts b/packages/core/src/scenes/GeneratorScene.tsindex 1ed5f5e7..a3ee1851 100644--- a/packages/core/src/scenes/GeneratorScene.ts+++ b/packages/core/src/scenes/GeneratorScene.ts@@ -92,7 +92,14 @@ export abstract class GeneratorScene<T>}private readonly afterReset = new EventDispatcher<void>();- public readonly LifecycleEvents: LifecycleEvents = new LifecycleEvents(this);+ public readonly lifecycleEvents: LifecycleEvents = new LifecycleEvents(this);+ // eslint-disable-next-line @typescript-eslint/naming-convention+ public get LifecycleEvents() {+ this.logger.warn(+ 'LifecycleEvents is deprecated. Use lifecycleEvents instead.',+ );+ return this.lifecycleEvents;+ }public get previous() {return this.previousScene;diff --git a/packages/core/src/scenes/Scene.ts b/packages/core/src/scenes/Scene.tsindex c6e53e7e..6e6ecd53 100644--- a/packages/core/src/scenes/Scene.ts+++ b/packages/core/src/scenes/Scene.ts@@ -170,8 +170,16 @@ export interface Scene<T = unknown> {get onRecalculated(): SubscribableEvent<void>;/**- * The scene's {@link LifecycleEvents}.+ * The {@link scenes.LifecycleEvents} of this scene.*/+ get lifecycleEvents(): LifecycleEvents;++ /**+ * The {@link scenes.LifecycleEvents} of this scene.+ *+ * @deprecated Use {@link lifecycleEvents} instead.+ */+ // eslint-disable-next-line @typescript-eslint/naming-conventionget LifecycleEvents(): LifecycleEvents;/**diff --git a/packages/core/src/transitions/useTransition.ts b/packages/core/src/transitions/useTransition.tsindex 3d770ff3..1eabd1b6 100644--- a/packages/core/src/transitions/useTransition.ts+++ b/packages/core/src/transitions/useTransition.ts@@ -19,8 +19,8 @@ export function useTransition(const scene = useScene();const prior = scene.previous;- const unsubPrev = prior?.LifecycleEvents.onBeforeRender.subscribe(previous);- const unsubNext = scene.LifecycleEvents.onBeforeRender.subscribe(current);+ const unsubPrev = prior?.lifecycleEvents.onBeforeRender.subscribe(previous);+ const unsubNext = scene.lifecycleEvents.onBeforeRender.subscribe(current);scene.enterInitial();diff --git a/packages/core/src/tweening/interpolationFunctions.ts b/packages/core/src/tweening/interpolationFunctions.tsindex 166d4099..a4cfb091 100644--- a/packages/core/src/tweening/interpolationFunctions.ts+++ b/packages/core/src/tweening/interpolationFunctions.ts@@ -1,8 +1,8 @@import {useLogger} from '../utils';import {Vector2} from '../types';-export interface InterpolationFunction<T, Rest extends any[] = any[]> {- (from: T, to: T, value: number, ...args: Rest): T;+export interface InterpolationFunction<T, TRest extends any[] = any[]> {+ (from: T, to: T, value: number, ...args: TRest): T;}export function textLerp(from: string, to: string, value: number) {diff --git a/packages/core/src/tweening/spring.test.ts b/packages/core/src/tweening/spring.test.tsindex 86300b58..3ede54e8 100644--- a/packages/core/src/tweening/spring.test.ts+++ b/packages/core/src/tweening/spring.test.ts@@ -24,7 +24,7 @@ describe('spring()', () => {},0,300,- x => {+ _ => {// do nothing},);@@ -41,7 +41,7 @@ describe('spring()', () => {},0,300,- x => {+ _ => {// do nothing},);@@ -58,7 +58,7 @@ describe('spring()', () => {},0,300,- x => {+ _ => {// do nothing},);@@ -99,7 +99,7 @@ describe('spring()', () => {},0,300,- x => {+ _ => {// do nothing},);diff --git a/packages/core/src/types/Color.ts b/packages/core/src/types/Color.tsindex a44d8df8..89a24837 100644--- a/packages/core/src/types/Color.ts+++ b/packages/core/src/types/Color.ts@@ -39,6 +39,7 @@ declare module 'chroma-js' {): ColorSignal<void>;}interface ChromaStatic {+ // eslint-disable-next-line @typescript-eslint/naming-conventionColor: ColorStatic & (new (color: PossibleColor) => ColorInterface);}}diff --git a/packages/core/src/utils/proxyUtils.test.ts b/packages/core/src/utils/proxyUtils.test.tsindex e7257fb9..b347dc97 100644--- a/packages/core/src/utils/proxyUtils.test.ts+++ b/packages/core/src/utils/proxyUtils.test.ts@@ -1,6 +1,6 @@import {beforeEach, describe, expect, it, vi} from 'vitest';import {isProxyEnabled, viaProxy} from './proxyUtils';-const windowMock = {+const WindowMock = {location: {toString: () => 'https://mockhostname:1234',},@@ -41,7 +41,7 @@ describe('proxyUtils', () => {beforeEach(() => {import.meta.env.VITE_MC_PROXY_ENABLED = 'true';import.meta.env.VITE_MC_PROXY_ALLOW_LIST = undefined;- vi.stubGlobal('window', windowMock);+ vi.stubGlobal('window', WindowMock);});const input = 'https://via.placeholder.com/300.png/09f/fff';const proxiedInput = proxy(input);@@ -69,7 +69,7 @@ describe('proxyUtils', () => {});it('should not proxy if the host is the same as the server', () => {import.meta.env['VITE_MC_PROXY_ALLOW_LIST'] = JSON.stringify([]);- const input = windowMock.location.toString() + '/some/example.png';+ const input = WindowMock.location.toString() + '/some/example.png';expect(viaProxy(input)).toStrictEqual(input);});}),@@ -77,7 +77,7 @@ describe('proxyUtils', () => {beforeEach(() => {import.meta.env.VITE_MC_PROXY_ENABLED = 'true';import.meta.env.VITE_MC_PROXY_ALLOW_LIST = JSON.stringify([]);- vi.stubGlobal('window', windowMock);+ vi.stubGlobal('window', WindowMock);});it('should proxy if the request protocol is http and https', () => {diff --git a/packages/core/src/utils/proxyUtils.ts b/packages/core/src/utils/proxyUtils.tsindex 9907c20b..de4f6a9b 100644--- a/packages/core/src/utils/proxyUtils.ts+++ b/packages/core/src/utils/proxyUtils.ts@@ -98,7 +98,7 @@ export function isProxyEnabled() {* try to parse the Env var on every call,* spamming the console in the process*/-let getAllowListCache: string[] | undefined = undefined;+let AllowListCache: string[] | undefined = undefined;/*** Return the list of allowed hosts* from the Plugin Config@@ -106,8 +106,8 @@ let getAllowListCache: string[] | undefined = undefined;function getAllowList() {// Condition should get optimized away for Prodif (import.meta.env.VITEST !== 'true') {- if (getAllowListCache) {- return [...getAllowListCache];+ if (AllowListCache) {+ return [...AllowListCache];}}@@ -144,6 +144,6 @@ function getAllowList() {}return validatedEntries;})();- getAllowListCache = result;- return [...getAllowListCache];+ AllowListCache = result;+ return [...AllowListCache];}diff --git a/packages/core/src/utils/useContext.ts b/packages/core/src/utils/useContext.tsindex d496bfd0..55b81b6f 100644--- a/packages/core/src/utils/useContext.ts+++ b/packages/core/src/utils/useContext.ts@@ -8,7 +8,7 @@ import {useScene} from './useScene';export function useContext(callback: (ctx: CanvasRenderingContext2D) => void,): () => void {- return useScene().LifecycleEvents.onBeginRender.subscribe(callback);+ return useScene().lifecycleEvents.onBeginRender.subscribe(callback);}/**@@ -19,5 +19,5 @@ export function useContext(export function useContextAfter(callback: (ctx: CanvasRenderingContext2D) => void,): () => void {- return useScene().LifecycleEvents.onFinishRender.subscribe(callback);+ return useScene().lifecycleEvents.onFinishRender.subscribe(callback);}diff --git a/packages/core/src/utils/usePlayback.ts b/packages/core/src/utils/usePlayback.tsindex 64f2630c..3fd78150 100644--- a/packages/core/src/utils/usePlayback.ts+++ b/packages/core/src/utils/usePlayback.ts@@ -1,12 +1,12 @@import {PlaybackStatus} from '../app';-const playbackStack: PlaybackStatus[] = [];+const PlaybackStack: PlaybackStatus[] = [];/*** Get a reference to the playback status.*/export function usePlayback() {- const playback = playbackStack.at(-1);+ const playback = PlaybackStack.at(-1);if (!playback) {throw new Error('The playback is not available in the current context.');}@@ -14,11 +14,11 @@ export function usePlayback() {}export function startPlayback(playback: PlaybackStatus) {- playbackStack.push(playback);+ PlaybackStack.push(playback);}export function endPlayback(playback: PlaybackStatus) {- if (playbackStack.pop() !== playback) {+ if (PlaybackStack.pop() !== playback) {throw new Error('startPlayback/endPlayback were called out of order.');}}diff --git a/packages/core/src/utils/useScene.ts b/packages/core/src/utils/useScene.tsindex 4e97e55e..7888e9d7 100644--- a/packages/core/src/utils/useScene.ts+++ b/packages/core/src/utils/useScene.ts@@ -1,12 +1,12 @@import type {Scene} from '../scenes';-const sceneStack: Scene[] = [];+const SceneStack: Scene[] = [];/*** Get a reference to the current scene.*/export function useScene(): Scene {- const scene = sceneStack.at(-1);+ const scene = SceneStack.at(-1);if (!scene) {throw new Error('The scene is not available in the current context.');}@@ -14,17 +14,17 @@ export function useScene(): Scene {}export function startScene(scene: Scene) {- sceneStack.push(scene);+ SceneStack.push(scene);}export function endScene(scene: Scene) {- if (sceneStack.pop() !== scene) {+ if (SceneStack.pop() !== scene) {throw new Error('startScene/endScene were called out of order.');}}export function useLogger() {- return sceneStack.at(-1)?.logger ?? console;+ return SceneStack.at(-1)?.logger ?? console;}/**diff --git a/packages/core/src/utils/useThread.ts b/packages/core/src/utils/useThread.tsindex 6c1027ef..242b4820 100644--- a/packages/core/src/utils/useThread.ts+++ b/packages/core/src/utils/useThread.ts@@ -1,13 +1,13 @@import type {Thread} from '../threading';import {DetailedError} from '../utils';-const threadStack: Thread[] = [];+const ThreadStack: Thread[] = [];/*** Get a reference to the current thread.*/export function useThread(): Thread {- const thread = threadStack.at(-1);+ const thread = ThreadStack.at(-1);if (!thread) {throw new DetailedError('The thread is not available in the current context.',@@ -20,11 +20,11 @@ export function useThread(): Thread {}export function startThread(thread: Thread) {- threadStack.push(thread);+ ThreadStack.push(thread);}export function endThread(thread: Thread) {- if (threadStack.pop() !== thread) {+ if (ThreadStack.pop() !== thread) {throw new Error('startThread/endThread was called out of order.');}}diff --git a/packages/docs/src/components/AnimationPlayer/index.tsx b/packages/docs/src/components/AnimationPlayer/index.tsxindex 7ce83a37..f5b61a34 100644--- a/packages/docs/src/components/AnimationPlayer/index.tsx+++ b/packages/docs/src/components/AnimationPlayer/index.tsx@@ -12,6 +12,7 @@ if (ExecutionEnvironment.canUseDOM) {declare global {namespace JSX {interface IntrinsicElements {+ // eslint-disable-next-line @typescript-eslint/naming-convention'motion-canvas-player': MotionCanvasPlayerProps & ComponentProps<'div'>;}}diff --git a/packages/docs/src/components/Api/Code/TokenList.tsx b/packages/docs/src/components/Api/Code/TokenList.tsxindex bc4896e2..0cfa676b 100644--- a/packages/docs/src/components/Api/Code/TokenList.tsx+++ b/packages/docs/src/components/Api/Code/TokenList.tsx@@ -17,7 +17,7 @@ export enum Separator {Ampersand = ' & ',}-const classes: Record<ListType, string> = {+const Classes: Record<ListType, string> = {[ListType.None]: styles.none,[ListType.Angle]: styles.angle,[ListType.Curly]: styles.curly,@@ -35,7 +35,7 @@ export default function TokenList({separator?: Separator;}) {return (- <span className={clsx(styles.list, classes[type ?? ListType.None])}>+ <span className={clsx(styles.list, Classes[type ?? ListType.None])}><spanclassName={clsx(styles.elements,diff --git a/packages/docs/src/components/Api/Preview/ClassPreview.tsx b/packages/docs/src/components/Api/Preview/ClassPreview.tsxindex ed221e29..30c82b2d 100644--- a/packages/docs/src/components/Api/Preview/ClassPreview.tsx+++ b/packages/docs/src/components/Api/Preview/ClassPreview.tsx@@ -9,7 +9,7 @@ import {ReflectionKind} from '@site/src/components/Api/ReflectionKind';import TypeParameterPreview from '@site/src/components/Api/Preview/TypeParameterPreview';import {useApiFinder} from '@site/src/contexts/api';-const mainKeyword = {+const MainKeyword = {[ReflectionKind.Namespace]: 'namespace',[ReflectionKind.Enum]: 'enum',[ReflectionKind.Class]: 'class',@@ -25,7 +25,7 @@ export default function ClassPreview({return (<><FlagsPreview flags={reflection.flags} />- <Token type="keyword">{mainKeyword[reflection.kind]} </Token>+ <Token type="keyword">{MainKeyword[reflection.kind]} </Token><Token type="class-name">{reflection.name}</Token>{!!reflection.typeParameters?.length && (<TokenList type={ListType.Angle}>diff --git a/packages/docs/src/components/Homepage/Features.tsx b/packages/docs/src/components/Homepage/Features.tsxindex 2280b3b3..69bf64d5 100644--- a/packages/docs/src/components/Homepage/Features.tsx+++ b/packages/docs/src/components/Homepage/Features.tsx@@ -8,7 +8,7 @@ import YouTubeVideo from '@site/src/components/YouTubeVideo';import UI from '@site/static/img/ui.svg';-const codeSample = `export makeScene(function* (view) {+const CodeSample = `export makeScene(function* (view) {const circle = createRef<Circle>();view.add(<Circle@@ -75,7 +75,7 @@ export default function HomepageFeatures(): JSX.Element {</a></p></Feature>- <Feature content={<CodeBlock language="tsx">{codeSample}</CodeBlock>}>+ <Feature content={<CodeBlock language="tsx">{CodeSample}</CodeBlock>}><h3><b>Procedural</b> for a Change</h3>diff --git a/packages/docs/src/components/Release/IssueGroup.tsx b/packages/docs/src/components/Release/IssueGroup.tsxindex 10e5a7f1..6e29f36f 100644--- a/packages/docs/src/components/Release/IssueGroup.tsx+++ b/packages/docs/src/components/Release/IssueGroup.tsx@@ -7,12 +7,12 @@ export interface IssueGroupProps {children: ReactNode | ReactNode[];}-const titles = {+const Titles = {feat: 'New features π',fix: 'Fixed bugs π',};-const ids = {+const IDs = {feat: 'new-features',fix: 'fixed-bugs',};@@ -20,8 +20,8 @@ const ids = {export default function IssueGroup({type, children}: IssueGroupProps) {return (<>- <Heading id={ids[type]} as="h3">- {titles[type]}+ <Heading id={IDs[type]} as="h3">+ {Titles[type]}</Heading><ul className={styles.group}>{children}</ul></>diff --git a/packages/docs/src/contexts/filters.tsx b/packages/docs/src/contexts/filters.tsxindex 3feb6244..df7c73ec 100644--- a/packages/docs/src/contexts/filters.tsx+++ b/packages/docs/src/contexts/filters.tsx@@ -12,25 +12,25 @@ type FiltersContext = [Filters, (value: Filters) => void];const FILTERS_KEY = 'api-filters';-const storedValue = ExecutionEnvironment.canUseDOM+const StoredValue = ExecutionEnvironment.canUseDOM? localStorage.getItem(FILTERS_KEY): null;-const defaultValue = storedValue- ? JSON.parse(storedValue)+const DefaultValue = StoredValue+ ? JSON.parse(StoredValue): {inherited: true,private: false,};const Context = React.createContext<FiltersContext>([- defaultValue,+ DefaultValue,() => {// do nothing},]);export function FiltersProvider({children}: {children: ReactNode}) {- const [filters, setFilters] = useState<Filters>(defaultValue);+ const [filters, setFilters] = useState<Filters>(DefaultValue);const isBrowser = useIsBrowser();return (diff --git a/packages/e2e/src/app.ts b/packages/e2e/src/app.tsindex 6fb0254a..363f81c4 100644--- a/packages/e2e/src/app.ts+++ b/packages/e2e/src/app.ts@@ -3,7 +3,7 @@ import puppeteer, {Page} from 'puppeteer';import {fileURLToPath} from 'url';import {createServer} from 'vite';-const __dirname = fileURLToPath(new URL('.', import.meta.url));+const Root = fileURLToPath(new URL('.', import.meta.url));export interface App {page: Page;@@ -14,8 +14,8 @@ export async function start(): Promise<App> {const [browser, server] = await Promise.all([puppeteer.launch(),createServer({- root: __dirname,- configFile: path.resolve(__dirname, '../vite.config.ts'),+ root: Root,+ configFile: path.resolve(Root, '../vite.config.ts'),server: {port: 9000,},diff --git a/packages/player/src/main.ts b/packages/player/src/main.tsindex e99d5e8a..f78b8eac 100644--- a/packages/player/src/main.ts+++ b/packages/player/src/main.ts@@ -208,7 +208,7 @@ class MotionCanvasPlayer extends HTMLElement {this.setState(State.Ready);}- private attributeChangedCallback(name: string, oldValue: any, newValue: any) {+ private attributeChangedCallback(name: string, _: any, newValue: any) {switch (name) {case 'auto':this.setPlaying(this.playing);diff --git a/packages/ui/src/components/layout/ResizeableLayout.tsx b/packages/ui/src/components/layout/ResizeableLayout.tsxindex f61ddba8..b7ece79c 100644--- a/packages/ui/src/components/layout/ResizeableLayout.tsx+++ b/packages/ui/src/components/layout/ResizeableLayout.tsx@@ -27,7 +27,7 @@ export function ResizeableLayout({const [handleDrag] = useDrag(useCallback(- (dx, dy, x, y) => {+ (_dx, _dy, x, y) => {const rect = containerRef.current.getBoundingClientRect();setSize(vertical ? (y - rect.y) / rect.height : (x - rect.x) / rect.width,diff --git a/packages/ui/src/components/timeline/Timeline.tsx b/packages/ui/src/components/timeline/Timeline.tsxindex 97d72ef8..a5c398d3 100644--- a/packages/ui/src/components/timeline/Timeline.tsx+++ b/packages/ui/src/components/timeline/Timeline.tsx@@ -59,7 +59,7 @@ export function Timeline() {[rect.width, scale],);- const ZOOM_MAX = (MAX_FRAME_SIZE / sizes.viewLength) * duration;+ const zoomMax = (MAX_FRAME_SIZE / sizes.viewLength) * duration;const conversion = useMemo(() => ({@@ -113,7 +113,7 @@ export function Timeline() {newScale *= prevWidth / rect.width;}if (!isNaN(newScale) && duration > 0) {- setScale(clamp(ZOOM_MIN, ZOOM_MAX, newScale));+ setScale(clamp(ZOOM_MIN, zoomMax, newScale));}},[duration / fps, rect.width],@@ -159,8 +159,8 @@ export function Timeline() {newScale = ZOOM_MIN;ratio = newScale / scale;}- if (newScale > ZOOM_MAX) {- newScale = ZOOM_MAX;+ if (newScale > zoomMax) {+ newScale = zoomMax;ratio = newScale / scale;}if (newScale === scale) {diff --git a/packages/ui/src/hooks/useDocumentEvent.ts b/packages/ui/src/hooks/useDocumentEvent.tsindex 466adbcd..f63522fa 100644--- a/packages/ui/src/hooks/useDocumentEvent.ts+++ b/packages/ui/src/hooks/useDocumentEvent.ts@@ -1,8 +1,8 @@import {useEffect} from 'preact/hooks';-export function useDocumentEvent<K extends keyof DocumentEventMap>(- type: K,- listener: (this: Document, ev: DocumentEventMap[K]) => void,+export function useDocumentEvent<T extends keyof DocumentEventMap>(+ type: T,+ listener: (this: Document, ev: DocumentEventMap[T]) => void,enabled = true,capture = false,) {diff --git a/packages/ui/src/utils/sourceMaps.ts b/packages/ui/src/utils/sourceMaps.tsindex a852476c..3d03c9a8 100644--- a/packages/ui/src/utils/sourceMaps.ts+++ b/packages/ui/src/utils/sourceMaps.ts@@ -2,24 +2,24 @@ import {SourceMapConsumer} from 'source-map-js';import {withLoader} from './withLoader';import highlight from 'highlight.js';-const externalFileRegex = /^\/(@fs|@id|node_modules)\//;-const stackTraceRegex = navigator.userAgent.toLowerCase().includes('chrome')+const ExternalFileRegex = /^\/(@fs|@id|node_modules)\//;+const StackTraceRegex = navigator.userAgent.toLowerCase().includes('chrome')? /^ +at.* \(?(.*):([0-9]+):([0-9]+)/: /@(.*):([0-9]+):([0-9]+)/;-const cache = new Map<string, SourceMapConsumer>();+const Cache = new Map<string, SourceMapConsumer>();async function getSourceMap(file: string,search = '',): Promise<SourceMapConsumer> {const key = `${file}.map${search}`;- if (cache.has(key)) {- return cache.get(key);+ if (Cache.has(key)) {+ return Cache.get(key);}const response = await fetch(`${file}.map${search}`);const consumer = new SourceMapConsumer(await response.json());- cache.set(key, consumer);+ Cache.set(key, consumer);return consumer;}@@ -46,7 +46,7 @@ export async function resolveStackTrace(): Promise<StackTraceEntry[] | StackTraceEntry> {const result: StackTraceEntry[] = [];for (const textLine of stack.split('\n')) {- const match = textLine.match(stackTraceRegex);+ const match = textLine.match(StackTraceRegex);if (!match) continue;const [, uri, line, column] = match;const parsed = new URL(uri);@@ -56,10 +56,10 @@ export async function resolveStackTrace(uri,line: parseInt(line),column: parseInt(column),- isExternal: externalFileRegex.test(file),+ isExternal: ExternalFileRegex.test(file),};- if (!externalFileRegex.test(file)) {+ if (!ExternalFileRegex.test(file)) {try {const sourceMap = await getSourceMap(file, parsed.search);const position = sourceMap.originalPositionFor(entry);diff --git a/packages/ui/src/utils/withLoader.ts b/packages/ui/src/utils/withLoader.tsindex 4858fd20..06d09359 100644--- a/packages/ui/src/utils/withLoader.ts+++ b/packages/ui/src/utils/withLoader.ts@@ -1,4 +1,4 @@-let loaderCount = 0;+let LoaderCount = 0;/*** Execute a given async function while displaying a loading indication.@@ -6,13 +6,13 @@ let loaderCount = 0;* @param callback - A function to execute.*/export async function withLoader(callback: () => Promise<unknown>) {- loaderCount++;+ LoaderCount++;document.body.classList.add('wait');try {await callback();} finally {- loaderCount--;- if (loaderCount == 0) {+ LoaderCount--;+ if (LoaderCount == 0) {document.body.classList.remove('wait');}}