1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler/testing/src/output/source_map_util", ["require", "exports"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.extractSourceMap = exports.originalPositionFor = void 0;
|
---|
20 | var b64 = require('base64-js');
|
---|
21 | var SourceMapConsumer = require('source-map').SourceMapConsumer;
|
---|
22 | function originalPositionFor(sourceMap, genPosition) {
|
---|
23 | var smc = new SourceMapConsumer(sourceMap);
|
---|
24 | // Note: We don't return the original object as it also contains a `name` property
|
---|
25 | // which is always null and we don't want to include that in our assertions...
|
---|
26 | var _a = smc.originalPositionFor(genPosition), line = _a.line, column = _a.column, source = _a.source;
|
---|
27 | return { line: line, column: column, source: source };
|
---|
28 | }
|
---|
29 | exports.originalPositionFor = originalPositionFor;
|
---|
30 | function extractSourceMap(source) {
|
---|
31 | var idx = source.lastIndexOf('\n//#');
|
---|
32 | if (idx == -1)
|
---|
33 | return null;
|
---|
34 | var smComment = source.slice(idx).split('\n', 2)[1].trim();
|
---|
35 | var smB64 = smComment.split('sourceMappingURL=data:application/json;base64,')[1];
|
---|
36 | return smB64 ? JSON.parse(decodeB64String(smB64)) : null;
|
---|
37 | }
|
---|
38 | exports.extractSourceMap = extractSourceMap;
|
---|
39 | function decodeB64String(s) {
|
---|
40 | return b64.toByteArray(s).reduce(function (s, c) { return s + String.fromCharCode(c); }, '');
|
---|
41 | }
|
---|
42 | });
|
---|
43 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