|
1 | 1 | import type { Context as OTELContext } from '@opentelemetry/api' |
2 | 2 | import type { GlobalChannelIncomingEvent, IframeChannelIncomingEvent, IframeChannelOutgoingEvent, IframeViewportDoneEvent, IframeViewportFailEvent } from '@vitest/browser/client' |
3 | | -import type { FileSpecification } from '@vitest/runner' |
4 | 3 | import type { BrowserTesterOptions, SerializedConfig } from 'vitest' |
| 4 | +import type { FileSpecification } from 'vitest/internal/browser' |
5 | 5 | import { channel, client, globalChannel } from '@vitest/browser/client' |
6 | 6 | import { relative } from 'pathe' |
7 | 7 | import { Traces } from 'vitest/internal/traces' |
| 8 | +// This needs to be tree shaken properly to not include the whole runner by accident |
| 9 | +import { generateFileHash } from '../../../vitest/src/utils/tasks.js' |
8 | 10 | import { getUiAPI } from './ui' |
9 | 11 | import { getBrowserState, getConfig } from './utils' |
10 | 12 |
|
@@ -481,39 +483,6 @@ function generateFileId(file: string) { |
481 | 483 | ) |
482 | 484 | } |
483 | 485 |
|
484 | | -// TODO: copied from packages/runner/src/utils/collect.ts |
485 | | -interface HashMeta { |
486 | | - typecheck?: boolean |
487 | | - __vitest_label__?: string |
488 | | -} |
489 | | - |
490 | | -function generateFileHash( |
491 | | - file: string, |
492 | | - projectName: string | undefined, |
493 | | - meta?: HashMeta, |
494 | | -): string { |
495 | | - const seed = [ |
496 | | - file, |
497 | | - projectName || '', |
498 | | - meta?.typecheck ? '__typecheck__' : '', |
499 | | - meta?.__vitest_label__ || '', |
500 | | - ].join('\0') |
501 | | - return generateHash(seed) |
502 | | -} |
503 | | - |
504 | | -function generateHash(str: string): string { |
505 | | - let hash = 0 |
506 | | - if (str.length === 0) { |
507 | | - return `${hash}` |
508 | | - } |
509 | | - for (let i = 0; i < str.length; i++) { |
510 | | - const char = str.charCodeAt(i) |
511 | | - hash = (hash << 5) - hash + char |
512 | | - hash = hash & hash // Convert to 32bit integer |
513 | | - } |
514 | | - return `${hash}` |
515 | | -} |
516 | | - |
517 | 486 | async function setIframeViewport( |
518 | 487 | width: number, |
519 | 488 | height: number, |
|
0 commit comments