UNPKG

tempus

Version:
1 lines 25.3 kB
{"version":3,"sources":["../packages/core/src/clock.ts","../packages/core/src/uid.ts","../package.json","../packages/core/src/tempus.ts"],"sourcesContent":["export default class Clock {\r\n private _elapsed = 0\r\n private _currentTime = 0\r\n private _startTime: number | undefined = undefined\r\n private _lastTime: number | undefined = undefined\r\n private _isPlaying = false\r\n private _deltaTime = 0\r\n\r\n play() {\r\n if (this._isPlaying) return\r\n this._currentTime = 0\r\n this._startTime = undefined\r\n this._isPlaying = true\r\n }\r\n\r\n pause() {\r\n if (!this._isPlaying) return\r\n this._deltaTime = 0\r\n this._isPlaying = false\r\n }\r\n\r\n reset() {\r\n this._elapsed = 0\r\n this._deltaTime = 0\r\n this._currentTime = 0\r\n this._lastTime = undefined\r\n this._isPlaying = false\r\n }\r\n\r\n update(browserTime: number) {\r\n if (!this._isPlaying) return\r\n\r\n if (!this._startTime) {\r\n /**\r\n * We always rely on the browser's tick time from the requestAnimationFrame, avoid mixing it\r\n * with performance.now() because it's not in sync with the browser's rendering timeline.\r\n */\r\n this._startTime = browserTime\r\n }\r\n\r\n if (this._lastTime === undefined) {\r\n this._lastTime = this._startTime\r\n this._currentTime = 0\r\n this._deltaTime = 0\r\n } else {\r\n this._lastTime = this._currentTime\r\n this._currentTime = browserTime - this._startTime\r\n this._deltaTime = this._currentTime - this._lastTime\r\n this._elapsed += this._deltaTime\r\n }\r\n }\r\n\r\n get time() {\r\n return this._elapsed\r\n }\r\n\r\n get isPlaying() {\r\n return this._isPlaying\r\n }\r\n\r\n get deltaTime() {\r\n return this._deltaTime\r\n }\r\n}\r\n","let index = 0\r\n\r\nexport function getUID(): number {\r\n return index++\r\n}\r\n","{\n \"name\": \"tempus\",\n \"version\": \"1.0.0-dev.18\",\n \"description\": \"one rAF to rule them all\",\n \"type\": \"module\",\n \"sideEffects\": false,\n \"unpkg\": \"./dist/tempus.mjs\",\n \"main\": \"./dist/tempus.mjs\",\n \"module\": \"./dist/tempus.mjs\",\n \"types\": \"./dist/tempus.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/tempus.d.ts\",\n \"default\": \"./dist/tempus.mjs\"\n },\n \"./react\": {\n \"types\": \"./dist/tempus-react.d.ts\",\n \"default\": \"./dist/tempus-react.mjs\"\n },\n \"./profiler\": {\n \"types\": \"./dist/tempus-profiler.d.ts\",\n \"default\": \"./dist/tempus-profiler.mjs\"\n },\n \"./dist/*\": \"./dist/*\"\n },\n \"scripts\": {\n \"build\": \"pnpm build:core && pnpm build:all\",\n \"build:core\": \"tsup --config tsup.core.ts\",\n \"build:all\": \"tsup\",\n \"dev\": \"pnpm run -w --parallel /^dev:.*/\",\n \"dev:build\": \"tsup --watch\",\n \"dev:playground\": \"pnpm --filter playground dev\",\n \"readme\": \"node ./scripts/update-readme.js\",\n \"version:dev\": \"npm version prerelease --preid dev --force --no-git-tag-version\",\n \"version:patch\": \"npm version patch --force --no-git-tag-version\",\n \"version:minor\": \"npm version minor --force --no-git-tag-version\",\n \"version:major\": \"npm version major --force --no-git-tag-version\",\n \"postversion\": \"pnpm build && pnpm readme\",\n \"publish:main\": \"npm publish\",\n \"publish:dev\": \"npm publish --tag dev\"\n },\n \"files\": [\n \"dist\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/darkroomengineering/tempus.git\"\n },\n \"keywords\": [\n \"raf\",\n \"ticker\",\n \"framerate\",\n \"fps\"\n ],\n \"author\": \"darkroom.engineering\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/darkroomengineering/tempus/issues\"\n },\n \"homepage\": \"https://github.com/darkroomengineering/tempus\",\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/darkroomengineering\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"1.9.4\",\n \"tsup\": \"^8.3.6\",\n \"typescript\": \"^5.7.3\",\n \"lottie-web\": \"^5.13.0\",\n \"motion\": \"^12.40.0\"\n },\n \"peerDependencies\": {\n \"react\": \">=17.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"react\": {\n \"optional\": true\n }\n }\n}\n","// Infinity = max FPS (system default)\r\n\r\nimport Clock from './clock'\r\nimport type {\r\n TempusCallback,\r\n TempusCallbackInfo,\r\n TempusOptions,\r\n TempusState,\r\n UID,\r\n} from './types'\r\nimport { getUID } from './uid'\r\nimport { version } from '../../../package.json'\r\n\r\nconst isClient = typeof window !== 'undefined'\r\n\r\n// Bound so they can be called bare (`originalRAF(cb)`) without \"Illegal\r\n// invocation\" — native rAF requires `this === window` in some browsers.\r\nconst originalRAF = (isClient &&\r\n window.requestAnimationFrame.bind(\r\n window\r\n )) as typeof window.requestAnimationFrame\r\nconst originalCancelRAF = (isClient &&\r\n window.cancelAnimationFrame.bind(\r\n window\r\n )) as typeof window.cancelAnimationFrame\r\n\r\nif (isClient) {\r\n ;(window as any).tempusVersion = version\r\n}\r\n\r\nfunction stopwatch(callback: () => void) {\r\n const now = performance.now()\r\n callback()\r\n return performance.now() - now\r\n}\r\n\r\n// How many recent per-frame durations to retain per callback — shared by both\r\n// Tempus.add() callbacks and loops absorbed by Tempus.patch() so timing is\r\n// sampled identically everywhere.\r\nconst SAMPLE_WINDOW = 60\r\n\r\n// Record a per-frame duration in a rolling window, mutating in place.\r\nfunction pushSample(samples: number[], duration: number) {\r\n samples.push(duration)\r\n if (samples.length > SAMPLE_WINDOW) samples.shift()\r\n}\r\n\r\n// Drop an absorbed loop's row once it hasn't run for this many frames (it\r\n// stopped rescheduling), so dead loops disappear from the profiler view.\r\nconst PATCH_STALE_FRAMES = 120\r\n\r\ntype PatchEntry = {\r\n callback: FrameRequestCallback\r\n label: string\r\n samples: number[]\r\n lastFrame: number\r\n}\r\n\r\nclass Framerate {\r\n callbacks: {\r\n callback: TempusCallback\r\n order: number\r\n uid: UID\r\n label: string\r\n samples: number[]\r\n }[] = []\r\n fps: number | string\r\n time = 0\r\n lastTickDate = 0\r\n framesCount = 0\r\n\r\n constructor(fps: number | string = Number.POSITIVE_INFINITY) {\r\n this.fps = fps\r\n }\r\n\r\n get isRelativeFps() {\r\n // eg: '33%'\r\n return typeof this.fps === 'string' && this.fps.endsWith('%')\r\n }\r\n\r\n get maxFramesCount() {\r\n if (!this.isRelativeFps) return 1\r\n\r\n // @ts-ignore\r\n return Math.max(1, Math.round(100 / Number(this.fps.replace('%', ''))))\r\n }\r\n\r\n get executionTime() {\r\n if (this.isRelativeFps) return 0\r\n\r\n // @ts-ignore\r\n return 1000 / this.fps\r\n }\r\n\r\n dispatch(state: TempusState) {\r\n for (let i = 0; i < this.callbacks.length; i++) {\r\n const duration = stopwatch(() => {\r\n this.callbacks[i]?.callback(state)\r\n })\r\n\r\n pushSample(this.callbacks[i]!.samples, duration)\r\n }\r\n }\r\n\r\n raf(state: TempusState) {\r\n this.time += state.deltaTime\r\n\r\n if (this.isRelativeFps) {\r\n if (this.framesCount === 0) {\r\n // Frame-skipped buckets report the longer delta since they last ran;\r\n // override on the shared state, then restore for the other buckets.\r\n const frameDelta = state.deltaTime\r\n state.deltaTime = state.time - this.lastTickDate\r\n this.lastTickDate = state.time\r\n this.dispatch(state)\r\n state.deltaTime = frameDelta\r\n }\r\n\r\n this.framesCount++\r\n this.framesCount %= this.maxFramesCount\r\n } else {\r\n if (this.fps === Number.POSITIVE_INFINITY) {\r\n this.dispatch(state)\r\n } else if (this.time >= this.executionTime) {\r\n this.time = this.time % this.executionTime\r\n\r\n // Throttled buckets report the longer delta since they last ran;\r\n // override on the shared state, then restore for the other buckets.\r\n const frameDelta = state.deltaTime\r\n state.deltaTime = state.time - this.lastTickDate\r\n this.lastTickDate = state.time\r\n this.dispatch(state)\r\n state.deltaTime = frameDelta\r\n }\r\n }\r\n }\r\n\r\n add({\r\n callback,\r\n order,\r\n label,\r\n }: {\r\n callback: TempusCallback\r\n order: number\r\n label: string\r\n }) {\r\n if (typeof callback !== 'function') {\r\n console.warn('Tempus.add: callback is not a function')\r\n return\r\n }\r\n\r\n const uid = getUID()\r\n this.callbacks.push({ callback, order, uid, label, samples: [] })\r\n this.callbacks.sort((a, b) => a.order - b.order)\r\n\r\n return () => this.remove(uid)\r\n }\r\n\r\n remove(uid: UID) {\r\n this.callbacks = this.callbacks.filter(({ uid: u }) => uid !== u)\r\n }\r\n}\r\n\r\nclass TempusImpl {\r\n framerates: Record<number | string, Framerate> = {}\r\n clock = new Clock()\r\n fps?: number\r\n usage = 0\r\n private rafId: number | undefined\r\n frameCount = 0\r\n\r\n // Frame rate the per-callback `budget` is measured against. At 60fps the\r\n // budget is ~16.67ms; callbacks call `state.budget()` to see how much of it\r\n // is left and decide whether to do expensive work this frame.\r\n targetFps = 60\r\n private frameStartTime = performance.now()\r\n\r\n get frameBudget() {\r\n return 1000 / this.targetFps\r\n }\r\n\r\n // The single object handed to every callback each tick. Reused (not\r\n // reallocated) to avoid per-frame GC; `budget()` is a live method (built in\r\n // the constructor) so it always reflects the time left at the moment called.\r\n private state!: TempusState\r\n\r\n // patch() state\r\n private patched = false\r\n private rafQueue = new Map<number, FrameRequestCallback>()\r\n private rafHandleId = 0\r\n private patchedRAF?: typeof window.requestAnimationFrame\r\n private patchedCancelRAF?: typeof window.cancelAnimationFrame\r\n private flushUnsubscribe?: () => void\r\n // Per-absorbed-callback timing, keyed by the callback identity so a\r\n // self-rescheduling loop keeps one stable row across frames. The map and\r\n // array hold the SAME entry objects — the array stays enumerable for the\r\n // profiler view, the map gives O(1) identity lookup.\r\n private patchMeta = new WeakMap<FrameRequestCallback, PatchEntry>()\r\n private patchEntries: PatchEntry[] = []\r\n private patchAnonCount = 0\r\n\r\n constructor() {\r\n const impl = this\r\n this.state = {\r\n time: 0,\r\n deltaTime: 0,\r\n frame: 0,\r\n budget() {\r\n return impl.frameBudget - (performance.now() - impl.frameStartTime)\r\n },\r\n }\r\n\r\n if (!isClient) return\r\n\r\n this.play()\r\n }\r\n\r\n restart() {\r\n if (this.rafId) {\r\n originalCancelRAF(this.rafId)\r\n }\r\n this.frameCount = 0\r\n\r\n for (const framerate of Object.values(this.framerates)) {\r\n framerate.framesCount = 0\r\n framerate.time = 0\r\n framerate.lastTickDate = performance.now()\r\n }\r\n\r\n this.clock.reset()\r\n this.play()\r\n }\r\n\r\n play() {\r\n if (!isClient || this.clock.isPlaying) return\r\n\r\n this.clock.play()\r\n this.rafId = originalRAF(this.raf)\r\n }\r\n\r\n pause() {\r\n if (!isClient || !this.rafId || !this.clock.isPlaying) return\r\n\r\n originalCancelRAF(this.rafId)\r\n this.rafId = undefined\r\n this.clock.pause()\r\n }\r\n\r\n get isPlaying() {\r\n return this.clock.isPlaying\r\n }\r\n\r\n add(\r\n callback: TempusCallback,\r\n {\r\n order,\r\n priority,\r\n fps = Number.POSITIVE_INFINITY,\r\n label = '',\r\n }: TempusOptions = {}\r\n ) {\r\n if (!isClient) return\r\n\r\n // `priority` is the deprecated alias for `order`; `order` wins when both\r\n // are set, otherwise fall back through priority to the default 0.\r\n const resolvedOrder = order ?? priority ?? 0\r\n\r\n if (\r\n typeof fps === 'number' ||\r\n (typeof fps === 'string' && fps.endsWith('%'))\r\n ) {\r\n if (!this.framerates[fps]) this.framerates[fps] = new Framerate(fps)\r\n return this.framerates[fps].add({ callback, order: resolvedOrder, label })\r\n }\r\n\r\n console.warn('Tempus.add: fps is not a number or a string ending with \"%\"')\r\n }\r\n\r\n private raf = (browserElapsed: number) => {\r\n if (!isClient) return\r\n\r\n this.clock.update(browserElapsed)\r\n\r\n const elapsed = this.clock.time\r\n const deltaTime = this.clock.deltaTime\r\n\r\n this.fps = 1000 / deltaTime\r\n this.frameStartTime = performance.now()\r\n\r\n this.state.time = elapsed\r\n this.state.deltaTime = deltaTime\r\n this.state.frame = this.frameCount\r\n\r\n const duration = stopwatch(() => {\r\n for (const framerate of Object.values(this.framerates)) {\r\n framerate.raf(this.state)\r\n }\r\n })\r\n\r\n if (deltaTime) {\r\n this.usage = duration / deltaTime\r\n }\r\n\r\n this.frameCount++\r\n\r\n this.rafId = originalRAF(this.raf)\r\n }\r\n\r\n patch() {\r\n if (!isClient || this.patched) return\r\n this.patched = true\r\n\r\n // A single Tempus subscription drains the rAF queue once per frame.\r\n // Every patched rAF callback is absorbed — no detection, no string\r\n // matching, so minified/third-party/arrow/bound loops all work.\r\n this.flushUnsubscribe = this.add(\r\n () => {\r\n if (this.rafQueue.size === 0) return\r\n\r\n // Snapshot then clear: callbacks that re-register during the flush\r\n // run NEXT frame, matching native one-shot rAF semantics (so a tight\r\n // requestAnimationFrame(loop) doesn't recurse synchronously forever).\r\n const batch = Array.from(this.rafQueue.values())\r\n this.rafQueue.clear()\r\n\r\n // Pass a performance.now()-comparable timestamp, as the browser does.\r\n const now = performance.now()\r\n const frame = this.frameCount\r\n for (const callback of batch) {\r\n // Time each absorbed loop individually and attribute it to a stable\r\n // row keyed by callback identity, so tempus/profiler can break the\r\n // single shim slot back down into per-loop cost.\r\n let meta = this.patchMeta.get(callback)\r\n if (!meta) {\r\n meta = {\r\n callback,\r\n label: callback.name || `anonymous#${++this.patchAnonCount}`,\r\n samples: [],\r\n lastFrame: frame,\r\n }\r\n this.patchMeta.set(callback, meta)\r\n this.patchEntries.push(meta)\r\n }\r\n\r\n const duration = stopwatch(() => {\r\n try {\r\n callback(now)\r\n } catch (error) {\r\n console.error('Tempus.patch: rAF callback threw', error)\r\n }\r\n })\r\n\r\n pushSample(meta.samples, duration)\r\n meta.lastFrame = frame\r\n }\r\n\r\n this.prunePatchEntries(frame)\r\n },\r\n { label: 'tempus' }\r\n )\r\n\r\n this.patchedRAF = ((callback: FrameRequestCallback): number => {\r\n const id = ++this.rafHandleId\r\n this.rafQueue.set(id, callback)\r\n return id\r\n }) as typeof window.requestAnimationFrame\r\n window.requestAnimationFrame = this.patchedRAF\r\n\r\n this.patchedCancelRAF = ((handle: number): void => {\r\n this.rafQueue.delete(handle)\r\n }) as typeof window.cancelAnimationFrame\r\n window.cancelAnimationFrame = this.patchedCancelRAF\r\n }\r\n\r\n unpatch() {\r\n if (!isClient || !this.patched) return\r\n\r\n // Only restore if nobody else re-patched on top of us, otherwise we'd\r\n // clobber their wrapper.\r\n if (window.requestAnimationFrame === this.patchedRAF) {\r\n window.requestAnimationFrame = originalRAF\r\n }\r\n if (window.cancelAnimationFrame === this.patchedCancelRAF) {\r\n window.cancelAnimationFrame = originalCancelRAF\r\n }\r\n\r\n this.flushUnsubscribe?.()\r\n this.flushUnsubscribe = undefined\r\n this.rafQueue.clear()\r\n this.patchedRAF = undefined\r\n this.patchedCancelRAF = undefined\r\n this.patchMeta = new WeakMap()\r\n this.patchEntries = []\r\n this.patchAnonCount = 0\r\n this.patched = false\r\n }\r\n\r\n // Drop rows for loops that stopped rescheduling, so they fall off the\r\n // profiler view instead of lingering as stale 0ms entries.\r\n private prunePatchEntries(frame: number) {\r\n for (let i = this.patchEntries.length - 1; i >= 0; i--) {\r\n const entry = this.patchEntries[i]!\r\n if (frame - entry.lastFrame > PATCH_STALE_FRAMES) {\r\n this.patchMeta.delete(entry.callback)\r\n this.patchEntries.splice(i, 1)\r\n }\r\n }\r\n }\r\n\r\n // Unified timing snapshot for tempus/profiler: every Tempus.add() callback and\r\n // every loop absorbed by Tempus.patch(), normalized to one shape. Samples\r\n // are copied so consumers can't mutate live state.\r\n inspect(): TempusCallbackInfo[] {\r\n const added = Object.values(this.framerates).flatMap((framerate) =>\r\n framerate.callbacks.map((callback) => ({\r\n label: callback.label,\r\n samples: callback.samples.slice(),\r\n order: callback.order,\r\n fps: framerate.fps,\r\n source: 'add' as const,\r\n }))\r\n )\r\n\r\n // Absorbed loops all run inside the single shim slot: every frame, never\r\n // skipped, no individual order.\r\n const patched = this.patchEntries.map((entry) => ({\r\n label: entry.label,\r\n samples: entry.samples.slice(),\r\n order: 0,\r\n fps: Number.POSITIVE_INFINITY,\r\n source: 'patch' as const,\r\n }))\r\n\r\n return [...added, ...patched]\r\n }\r\n}\r\n\r\nconst Tempus = new TempusImpl()\r\n\r\nexport { Tempus }\r\n"],"mappings":";AAAA,IAAqB,QAArB,MAA2B;AAAA,EACjB,WAA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