Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See License.txt in the project root for license information.
--------------------------------------------------------------------------------------------/
import type as ts from 'typescript';
import as lazy from 'lazy.js';
import { duplex, through } from 'event-stream';
import as File from 'vinyl';
import as sm from 'source-map';
import * as path from 'path';
declare class FileSourceMap extends File {
public sourceMap: sm.RawSourceMap;
}
enum CollectStepResult {
Yes,
YesAndRecurse,
No,
NoAndRecurse
}
Copyright (C) Microsoft Corporation. All rights reserved.
--------------------------------------------------------/
define([], [${wrap + lines.map(l => indent + l).join(',\n') + wrap}]);`;
}
/**
Returns a stream containing the patched JavaScript and source maps.
*/
export function nls(): NodeJS.ReadWriteStream {
const input = through();
const output = input.pipe(through(function (f: FileSourceMap) {
if (!f.sourceMap) {
return this.emit('error', new Error(File ${f.relative} does not have sourcemaps.));
}
let source = f.sourceMap.sources[0];
if (!source) {
return this.emit('error', new Error(`File ${f.relative} does not have a source in the source map.`));
}
const root = f.sourceMap.sourceRoot;
if (root) {
source = path.join(root, source);
}
const typescript = f.sourceMap.sourcesContent![0];
if (!typescript) {
return this.emit('error', new Error(`File ${f.relative} does not have the original content in the source map.`));
}
_nls.patchFiles(f, typescript).forEach(f => this.emit('data', f));
/*---------------------------------------------------------------------------------------------
import type as ts from 'typescript'; import as lazy from 'lazy.js'; import { duplex, through } from 'event-stream'; import as File from 'vinyl'; import as sm from 'source-map'; import * as path from 'path';
declare class FileSourceMap extends File { public sourceMap: sm.RawSourceMap; }
enum CollectStepResult { Yes, YesAndRecurse, No, NoAndRecurse }
function collect(ts: typeof import('typescript'), node: ts.Node, fn: (node: ts.Node) => CollectStepResult): ts.Node[] { const result: ts.Node[] = [];
}
function clone(object: T): T {
const result = {};
for (const id in object) {
result[id] = object[id];
}
return result;
}
function template(lines: string[]): string { let indent = '', wrap = '';
/**
Returns a stream containing the patched JavaScript and source maps. */ export function nls(): NodeJS.ReadWriteStream { const input = through(); const output = input.pipe(through(function (f: FileSourceMap) { if (!f.sourceMap) { return this.emit('error', new Error(
File ${f.relative} does not have sourcemaps.
)); }}));
return duplex(input, output); }
function isImportNode(ts: typeof import('typescript'), node: ts.Node): boolean { return node.kind === ts.SyntaxKind.ImportDeclaration || node.kind === ts.SyntaxKind.ImportEqualsDeclaration; }
module _nls {
}