| 39 | // |
| 40 | |
| 41 | export class Source { |
| 42 | public readonly sourceReference: number; |
| 43 | private readonly _name: string; |
| 44 | private readonly _fqname: string; |
| 45 | |
| 46 | /** |
| 47 | * Function to retrieve the content of the source. |
| 48 | */ |
| 49 | private readonly _contentGetter: ContentGetter; |
| 50 | |
| 51 | private readonly _container: SourceContainer; |
| 52 | |
| 53 | /** |
| 54 | * Hypothesized absolute path for the source. May or may not actually exist. |
| 55 | */ |
| 56 | public readonly absolutePath: string; |
| 57 | |
| 58 | public sourceMap?: SourceLocationProvider; |
| 59 | |
| 60 | // This is the same as |_absolutePath|, but additionally checks that file exists to |
| 61 | // avoid errors when page refers to non-existing paths/urls. |
| 62 | private readonly _existingAbsolutePath: Promise<string | undefined>; |
| 63 | private _scripts: ISourceScript[] = []; |
| 64 | |
| 65 | /** |
| 66 | * Gets whether the source should be sent to the client lazily. |
| 67 | * This is true for evaluated scripts. (#1939) |
| 68 | */ |
| 69 | public get sendLazy() { |
| 70 | return !this.url; |
| 71 | } |
| 72 | |
| 73 | /** @internal */ |
| 74 | public hasBeenAnnounced = false; |
| 75 | |
| 76 | /** |
| 77 | * @param inlineScriptOffset Offset of the start location of the script in |
| 78 | * its source file. This is used on scripts in HTML pages, where the script |
| 79 | * is nested in the content. |
| 80 | * @param contentHash Optional hash of the file contents. This is used to |
| 81 | * check whether the script we get is the same one as what's on disk. This |
| 82 | * can be used to detect in-place transpilation. |
| 83 | * @param runtimeScriptOffset Offset of the start location of the script |
| 84 | * in the runtime *only*. This differs from the inlineScriptOffset, as the |
| 85 | * inline offset of also reflected in the file. This is used to deal with |
| 86 | * the runtime wrapping the source and offsetting locations which should |
| 87 | * not be shown to the user. |
| 88 | */ |
| 89 | constructor( |
| 90 | container: SourceContainer, |
| 91 | public readonly url: string, |
| 92 | absolutePath: string | undefined, |
| 93 | contentGetter: ContentGetter, |
| 94 | sourceMapMetadata?: ISourceMapMetadata, |
| 95 | public readonly inlineScriptOffset?: InlineScriptOffset, |
| 96 | public readonly runtimeScriptOffset?: InlineScriptOffset, |
| 97 | public readonly contentHash?: string, |
| 98 | ) { |
nothing calls this directly
no outgoing calls
no test coverage detected