1 | 'use strict';
|
2 |
|
3 | var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
4 |
|
5 | var _getIterator3 = _interopRequireDefault(_getIterator2);
|
6 |
|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | var maximumSizeTransform = require('./maximum-size-transform');
|
26 | var modifyUrlPrefixTranform = require('./modify-url-prefix-transform');
|
27 | var noRevisionForUrlsMatchingTransform = require('./no-revision-for-urls-matching-transform');
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | module.exports = function (_ref) {
|
80 | var dontCacheBustUrlsMatching = _ref.dontCacheBustUrlsMatching,
|
81 | fileDetails = _ref.fileDetails,
|
82 | manifestTransforms = _ref.manifestTransforms,
|
83 | maximumFileSizeToCacheInBytes = _ref.maximumFileSizeToCacheInBytes,
|
84 | modifyUrlPrefix = _ref.modifyUrlPrefix;
|
85 |
|
86 | var allWarnings = [];
|
87 |
|
88 |
|
89 |
|
90 | var normalizedManifest = fileDetails.map(function (fileDetails) {
|
91 | return {
|
92 | url: fileDetails.file.replace(/\\/g, '/'),
|
93 | revision: fileDetails.hash,
|
94 | size: fileDetails.size
|
95 | };
|
96 | });
|
97 |
|
98 | var transformsToApply = [];
|
99 |
|
100 | if (maximumFileSizeToCacheInBytes) {
|
101 | transformsToApply.push(maximumSizeTransform(maximumFileSizeToCacheInBytes));
|
102 | }
|
103 |
|
104 | if (modifyUrlPrefix) {
|
105 | transformsToApply.push(modifyUrlPrefixTranform(modifyUrlPrefix));
|
106 | }
|
107 |
|
108 | if (dontCacheBustUrlsMatching) {
|
109 | transformsToApply.push(noRevisionForUrlsMatchingTransform(dontCacheBustUrlsMatching));
|
110 | }
|
111 |
|
112 |
|
113 | transformsToApply = transformsToApply.concat(manifestTransforms || []);
|
114 |
|
115 | var transformedManifest = normalizedManifest;
|
116 | var _iteratorNormalCompletion = true;
|
117 | var _didIteratorError = false;
|
118 | var _iteratorError = undefined;
|
119 |
|
120 | try {
|
121 | for (var _iterator = (0, _getIterator3.default)(transformsToApply), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
122 | var transform = _step.value;
|
123 |
|
124 | var _transform = transform(transformedManifest),
|
125 | manifest = _transform.manifest,
|
126 | warnings = _transform.warnings;
|
127 |
|
128 | transformedManifest = manifest;
|
129 | allWarnings = allWarnings.concat(warnings || []);
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 | } catch (err) {
|
135 | _didIteratorError = true;
|
136 | _iteratorError = err;
|
137 | } finally {
|
138 | try {
|
139 | if (!_iteratorNormalCompletion && _iterator.return) {
|
140 | _iterator.return();
|
141 | }
|
142 | } finally {
|
143 | if (_didIteratorError) {
|
144 | throw _iteratorError;
|
145 | }
|
146 | }
|
147 | }
|
148 |
|
149 | var count = transformedManifest.length;
|
150 | var size = 0;
|
151 | var _iteratorNormalCompletion2 = true;
|
152 | var _didIteratorError2 = false;
|
153 | var _iteratorError2 = undefined;
|
154 |
|
155 | try {
|
156 | for (var _iterator2 = (0, _getIterator3.default)(transformedManifest), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
157 | var manifestEntry = _step2.value;
|
158 |
|
159 | size += manifestEntry.size;
|
160 | delete manifestEntry.size;
|
161 | }
|
162 | } catch (err) {
|
163 | _didIteratorError2 = true;
|
164 | _iteratorError2 = err;
|
165 | } finally {
|
166 | try {
|
167 | if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
168 | _iterator2.return();
|
169 | }
|
170 | } finally {
|
171 | if (_didIteratorError2) {
|
172 | throw _iteratorError2;
|
173 | }
|
174 | }
|
175 | }
|
176 |
|
177 | return {
|
178 | count,
|
179 | size,
|
180 | manifestEntries: transformedManifest,
|
181 | warnings: allWarnings
|
182 | };
|
183 | }; |
\ | No newline at end of file |