Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
No EOL
1.8 KiB
Text
45 lines
No EOL
1.8 KiB
Text
// Copyright 2023 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
import * as Platform from '../../../core/platform/platform.js';
|
|
// Cache film strips based on:
|
|
// 1. The trace parsed data object
|
|
// 2. The start time.
|
|
const filmStripCache = new WeakMap();
|
|
export function fromParsedTrace(parsedTrace, customZeroTime) {
|
|
const frames = [];
|
|
const zeroTime = typeof customZeroTime !== 'undefined' ? customZeroTime : parsedTrace.Meta.traceBounds.min;
|
|
const spanTime = parsedTrace.Meta.traceBounds.range;
|
|
const fromCache = filmStripCache.get(parsedTrace)?.get(zeroTime);
|
|
if (fromCache) {
|
|
return fromCache;
|
|
}
|
|
const screenshots = parsedTrace.Screenshots.screenshots ?? parsedTrace.Screenshots.legacySyntheticScreenshots ?? [];
|
|
for (const screenshotEvent of screenshots) {
|
|
if (screenshotEvent.ts < zeroTime) {
|
|
continue;
|
|
}
|
|
const frame = {
|
|
index: frames.length,
|
|
screenshotEvent,
|
|
};
|
|
frames.push(frame);
|
|
}
|
|
const result = {
|
|
zeroTime,
|
|
spanTime,
|
|
frames: Array.from(frames),
|
|
};
|
|
const cachedForData = Platform.MapUtilities.getWithDefault(filmStripCache, parsedTrace, () => new Map());
|
|
cachedForData.set(zeroTime, result);
|
|
return result;
|
|
}
|
|
export function frameClosestToTimestamp(filmStrip, searchTimestamp) {
|
|
const closestFrameIndexBeforeTimestamp = Platform.ArrayUtilities.nearestIndexFromEnd(filmStrip.frames, frame => frame.screenshotEvent.ts < searchTimestamp);
|
|
if (closestFrameIndexBeforeTimestamp === null) {
|
|
return null;
|
|
}
|
|
return filmStrip.frames[closestFrameIndexBeforeTimestamp];
|
|
}
|
|
//# sourceMappingURL=FilmStrip.js.map |