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/src/aot/util", ["require", "exports"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.createLoweredSymbol = exports.isLoweredSymbol = exports.stripSummaryForJitNameSuffix = exports.summaryForJitName = exports.stripSummaryForJitFileSuffix = exports.summaryForJitFileName = exports.summaryFileName = exports.normalizeGenFileSuffix = exports.splitTypescriptSuffix = exports.isGeneratedFile = exports.stripGeneratedFileSuffix = exports.ngfactoryFilePath = void 0;
|
---|
20 | var STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
|
---|
21 | var GENERATED_FILE = /\.ngfactory\.|\.ngsummary\./;
|
---|
22 | var JIT_SUMMARY_FILE = /\.ngsummary\./;
|
---|
23 | var JIT_SUMMARY_NAME = /NgSummary$/;
|
---|
24 | function ngfactoryFilePath(filePath, forceSourceFile) {
|
---|
25 | if (forceSourceFile === void 0) { forceSourceFile = false; }
|
---|
26 | var urlWithSuffix = splitTypescriptSuffix(filePath, forceSourceFile);
|
---|
27 | return urlWithSuffix[0] + ".ngfactory" + normalizeGenFileSuffix(urlWithSuffix[1]);
|
---|
28 | }
|
---|
29 | exports.ngfactoryFilePath = ngfactoryFilePath;
|
---|
30 | function stripGeneratedFileSuffix(filePath) {
|
---|
31 | return filePath.replace(GENERATED_FILE, '.');
|
---|
32 | }
|
---|
33 | exports.stripGeneratedFileSuffix = stripGeneratedFileSuffix;
|
---|
34 | function isGeneratedFile(filePath) {
|
---|
35 | return GENERATED_FILE.test(filePath);
|
---|
36 | }
|
---|
37 | exports.isGeneratedFile = isGeneratedFile;
|
---|
38 | function splitTypescriptSuffix(path, forceSourceFile) {
|
---|
39 | if (forceSourceFile === void 0) { forceSourceFile = false; }
|
---|
40 | if (path.endsWith('.d.ts')) {
|
---|
41 | return [path.slice(0, -5), forceSourceFile ? '.ts' : '.d.ts'];
|
---|
42 | }
|
---|
43 | var lastDot = path.lastIndexOf('.');
|
---|
44 | if (lastDot !== -1) {
|
---|
45 | return [path.substring(0, lastDot), path.substring(lastDot)];
|
---|
46 | }
|
---|
47 | return [path, ''];
|
---|
48 | }
|
---|
49 | exports.splitTypescriptSuffix = splitTypescriptSuffix;
|
---|
50 | function normalizeGenFileSuffix(srcFileSuffix) {
|
---|
51 | return srcFileSuffix === '.tsx' ? '.ts' : srcFileSuffix;
|
---|
52 | }
|
---|
53 | exports.normalizeGenFileSuffix = normalizeGenFileSuffix;
|
---|
54 | function summaryFileName(fileName) {
|
---|
55 | var fileNameWithoutSuffix = fileName.replace(STRIP_SRC_FILE_SUFFIXES, '');
|
---|
56 | return fileNameWithoutSuffix + ".ngsummary.json";
|
---|
57 | }
|
---|
58 | exports.summaryFileName = summaryFileName;
|
---|
59 | function summaryForJitFileName(fileName, forceSourceFile) {
|
---|
60 | if (forceSourceFile === void 0) { forceSourceFile = false; }
|
---|
61 | var urlWithSuffix = splitTypescriptSuffix(stripGeneratedFileSuffix(fileName), forceSourceFile);
|
---|
62 | return urlWithSuffix[0] + ".ngsummary" + urlWithSuffix[1];
|
---|
63 | }
|
---|
64 | exports.summaryForJitFileName = summaryForJitFileName;
|
---|
65 | function stripSummaryForJitFileSuffix(filePath) {
|
---|
66 | return filePath.replace(JIT_SUMMARY_FILE, '.');
|
---|
67 | }
|
---|
68 | exports.stripSummaryForJitFileSuffix = stripSummaryForJitFileSuffix;
|
---|
69 | function summaryForJitName(symbolName) {
|
---|
70 | return symbolName + "NgSummary";
|
---|
71 | }
|
---|
72 | exports.summaryForJitName = summaryForJitName;
|
---|
73 | function stripSummaryForJitNameSuffix(symbolName) {
|
---|
74 | return symbolName.replace(JIT_SUMMARY_NAME, '');
|
---|
75 | }
|
---|
76 | exports.stripSummaryForJitNameSuffix = stripSummaryForJitNameSuffix;
|
---|
77 | var LOWERED_SYMBOL = /\u0275\d+/;
|
---|
78 | function isLoweredSymbol(name) {
|
---|
79 | return LOWERED_SYMBOL.test(name);
|
---|
80 | }
|
---|
81 | exports.isLoweredSymbol = isLoweredSymbol;
|
---|
82 | function createLoweredSymbol(id) {
|
---|
83 | return "\u0275" + id;
|
---|
84 | }
|
---|
85 | exports.createLoweredSymbol = createLoweredSymbol;
|
---|
86 | });
|
---|
87 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9hb3QvdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7Ozs7SUFFSCxJQUFNLHVCQUF1QixHQUFHLGtDQUFrQyxDQUFDO0lBQ25FLElBQU0sY0FBYyxHQUFHLDZCQUE2QixDQUFDO0lBQ3JELElBQU0sZ0JBQWdCLEdBQUcsZUFBZSxDQUFDO0lBQ3pDLElBQU0sZ0JBQWdCLEdBQUcsWUFBWSxDQUFDO0lBRXRDLFNBQWdCLGlCQUFpQixDQUFDLFFBQWdCLEVBQUUsZUFBdUI7UUFBdkIsZ0NBQUEsRUFBQSx1QkFBdUI7UUFDekUsSUFBTSxhQUFhLEdBQUcscUJBQXFCLENBQUMsUUFBUSxFQUFFLGVBQWUsQ0FBQyxDQUFDO1FBQ3ZFLE9BQVUsYUFBYSx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