@remotion/bundler 4.0.438 → 4.0.440

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Forked from css-loader v5.2.7
3
+ * MIT License http://www.opensource.org/licenses/mit-license.php
4
+ */
5
+ "use strict";
6
+
7
+ class CssSyntaxError extends Error {
8
+ constructor(error) {
9
+ super(error);
10
+ const {reason, line, column, file} = error;
11
+ this.name = "CssSyntaxError";
12
+
13
+ this.message = `${this.name}\n\n`;
14
+
15
+ if (typeof line !== "undefined") {
16
+ this.message += `(${line}:${column}) `;
17
+ }
18
+
19
+ this.message += file ? `${file} ` : "<css input> ";
20
+ this.message += `${reason}`;
21
+ const code = error.showSourceCode();
22
+
23
+ if (code) {
24
+ this.message += `\n\n${code}\n`;
25
+ }
26
+
27
+ this.stack = false;
28
+ }
29
+ }
30
+
31
+ module.exports = CssSyntaxError;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Forked from css-loader v5.2.7
3
+ * MIT License http://www.opensource.org/licenses/mit-license.php
4
+ */
5
+ "use strict";
6
+
7
+ class Warning extends Error {
8
+ constructor(warning) {
9
+ super(warning);
10
+ const {text, line, column} = warning;
11
+ this.name = "Warning";
12
+
13
+ this.message = `${this.name}\n\n`;
14
+
15
+ if (typeof line !== "undefined") {
16
+ this.message += `(${line}:${column}) `;
17
+ }
18
+
19
+ this.message += `${text}`;
20
+
21
+ this.stack = false;
22
+ }
23
+ }
24
+
25
+ module.exports = Warning;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Forked from css-loader v5.2.7
3
+ * MIT License http://www.opensource.org/licenses/mit-license.php
4
+ * Author Tobias Koppers @sokra
5
+ *
6
+ * Simplified for Remotion's use case:
7
+ * - No CSS Modules support
8
+ * - No ICSS support
9
+ * - No schema-utils validation (we control the options)
10
+ * - No semver postcss version check
11
+ * - Hardcoded default options (url: true, import: true, esModule: true)
12
+ */
13
+ 'use strict';
14
+
15
+ const {getOptions, stringifyRequest} = require('loader-utils');
16
+ const postcss = require('postcss');
17
+ const CssSyntaxError = require('./CssSyntaxError');
18
+ const Warning = require('./Warning');
19
+ const {importParser, urlParser} = require('./plugins');
20
+ const {
21
+ normalizeUrl,
22
+ requestify,
23
+ getFilter,
24
+ getPreRequester,
25
+ getImportCode,
26
+ getModuleCode,
27
+ getExportCode,
28
+ resolveRequests,
29
+ isUrlRequestable,
30
+ normalizeSourceMap,
31
+ sort,
32
+ combineRequests,
33
+ WEBPACK_IGNORE_COMMENT_REGEXP,
34
+ } = require('./utils');
35
+
36
+ async function loader(content, map, meta) {
37
+ const callback = this.async();
38
+
39
+ const sourceMap = this.sourceMap || false;
40
+ const esModule = true;
41
+
42
+ const replacements = [];
43
+
44
+ // Import plugin
45
+ const importPluginImports = [];
46
+ const importPluginApi = [];
47
+
48
+ const importResolver = this.getResolve({
49
+ conditionNames: ['style'],
50
+ extensions: ['.css'],
51
+ mainFields: ['css', 'style', 'main', '...'],
52
+ mainFiles: ['index', '...'],
53
+ });
54
+
55
+ const plugins = [
56
+ importParser({
57
+ imports: importPluginImports,
58
+ api: importPluginApi,
59
+ context: this.context,
60
+ rootContext: this.rootContext,
61
+ filter: getFilter(true, this.resourcePath),
62
+ resolver: importResolver,
63
+ urlHandler: (url) =>
64
+ stringifyRequest(
65
+ this,
66
+ combineRequests(getPreRequester(this)(undefined), url),
67
+ ),
68
+ }),
69
+ ];
70
+
71
+ // URL plugin
72
+ const urlPluginImports = [];
73
+
74
+ const urlResolver = this.getResolve({
75
+ conditionNames: ['asset'],
76
+ mainFields: ['asset'],
77
+ mainFiles: [],
78
+ extensions: [],
79
+ });
80
+
81
+ plugins.push(
82
+ urlParser({
83
+ imports: urlPluginImports,
84
+ replacements,
85
+ context: this.context,
86
+ rootContext: this.rootContext,
87
+ filter: getFilter(true, this.resourcePath),
88
+ resolver: urlResolver,
89
+ urlHandler: (url) => stringifyRequest(this, url),
90
+ }),
91
+ );
92
+
93
+ const {resourcePath} = this;
94
+ let result;
95
+
96
+ try {
97
+ result = await postcss(plugins).process(content, {
98
+ hideNothingWarning: true,
99
+ from: resourcePath,
100
+ to: resourcePath,
101
+ map: sourceMap
102
+ ? {
103
+ prev: map ? normalizeSourceMap(map, resourcePath) : null,
104
+ inline: false,
105
+ annotation: false,
106
+ }
107
+ : false,
108
+ });
109
+ } catch (error) {
110
+ if (error.file) {
111
+ this.addDependency(error.file);
112
+ }
113
+
114
+ callback(
115
+ error.name === 'CssSyntaxError' ? new CssSyntaxError(error) : error,
116
+ );
117
+ return;
118
+ }
119
+
120
+ for (const warning of result.warnings()) {
121
+ this.emitWarning(new Warning(warning));
122
+ }
123
+
124
+ const imports = []
125
+ .concat(importPluginImports.sort(sort))
126
+ .concat(urlPluginImports.sort(sort));
127
+ const api = [].concat(importPluginApi.sort(sort));
128
+
129
+ imports.unshift({
130
+ importName: '___CSS_LOADER_API_IMPORT___',
131
+ url: stringifyRequest(this, require.resolve('./runtime/api')),
132
+ });
133
+
134
+ if (sourceMap) {
135
+ imports.unshift({
136
+ importName: '___CSS_LOADER_API_SOURCEMAP_IMPORT___',
137
+ url: stringifyRequest(
138
+ this,
139
+ require.resolve('./runtime/cssWithMappingToString'),
140
+ ),
141
+ });
142
+ }
143
+
144
+ const options = {
145
+ sourceMap,
146
+ esModule,
147
+ modules: false,
148
+ };
149
+
150
+ const importCode = getImportCode(imports, options);
151
+ const moduleCode = getModuleCode(result, api, replacements, options, this);
152
+ const exportCode = getExportCode([], replacements, false, options);
153
+
154
+ callback(null, `${importCode}${moduleCode}${exportCode}`);
155
+ }
156
+
157
+ module.exports = loader;
158
+ module.exports.default = loader;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Forked from css-loader v5.2.7
3
+ * MIT License http://www.opensource.org/licenses/mit-license.php
4
+ *
5
+ * Removed ICSS parser (not used in Remotion).
6
+ */
7
+ "use strict";
8
+
9
+ const importParser = require("./postcss-import-parser");
10
+ const urlParser = require("./postcss-url-parser");
11
+
12
+ exports.importParser = importParser;
13
+ exports.urlParser = urlParser;
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Forked from css-loader v5.2.7
3
+ * MIT License http://www.opensource.org/licenses/mit-license.php
4
+ */
5
+ "use strict";
6
+
7
+ const valueParser = require("postcss-value-parser");
8
+ const {
9
+ normalizeUrl,
10
+ isUrlRequestable,
11
+ requestify,
12
+ resolveRequests,
13
+ WEBPACK_IGNORE_COMMENT_REGEXP,
14
+ } = require("../utils");
15
+
16
+ function parseNode(atRule, key) {
17
+ // Convert only top-level @import
18
+ if (atRule.parent.type !== "root") {
19
+ return;
20
+ }
21
+
22
+ if (
23
+ atRule.raws &&
24
+ atRule.raws.afterName &&
25
+ atRule.raws.afterName.trim().length > 0
26
+ ) {
27
+ const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
28
+ const matched = atRule.raws.afterName
29
+ .slice(lastCommentIndex)
30
+ .match(WEBPACK_IGNORE_COMMENT_REGEXP);
31
+
32
+ if (matched && matched[2] === "true") {
33
+ return;
34
+ }
35
+ }
36
+
37
+ const prevNode = atRule.prev();
38
+
39
+ if (prevNode && prevNode.type === "comment") {
40
+ const matched = prevNode.text.match(WEBPACK_IGNORE_COMMENT_REGEXP);
41
+
42
+ if (matched && matched[2] === "true") {
43
+ return;
44
+ }
45
+ }
46
+
47
+ if (atRule.nodes) {
48
+ const error = new Error(
49
+ "It looks like you didn't end your @import statement correctly. Child nodes are attached to it.",
50
+ );
51
+ error.node = atRule;
52
+ throw error;
53
+ }
54
+
55
+ const {nodes: paramsNodes} = valueParser(atRule[key]);
56
+
57
+ if (
58
+ paramsNodes.length === 0 ||
59
+ (paramsNodes[0].type !== "string" && paramsNodes[0].type !== "function")
60
+ ) {
61
+ const error = new Error(
62
+ `Unable to find uri in "${atRule.toString()}"`,
63
+ );
64
+ error.node = atRule;
65
+ throw error;
66
+ }
67
+
68
+ let isStringValue;
69
+ let url;
70
+
71
+ if (paramsNodes[0].type === "string") {
72
+ isStringValue = true;
73
+ url = paramsNodes[0].value;
74
+ } else {
75
+ if (paramsNodes[0].value.toLowerCase() !== "url") {
76
+ const error = new Error(
77
+ `Unable to find uri in "${atRule.toString()}"`,
78
+ );
79
+ error.node = atRule;
80
+ throw error;
81
+ }
82
+
83
+ isStringValue =
84
+ paramsNodes[0].nodes.length !== 0 &&
85
+ paramsNodes[0].nodes[0].type === "string";
86
+ url = isStringValue
87
+ ? paramsNodes[0].nodes[0].value
88
+ : valueParser.stringify(paramsNodes[0].nodes);
89
+ }
90
+
91
+ url = normalizeUrl(url, isStringValue);
92
+ const isRequestable = isUrlRequestable(url);
93
+ let prefix;
94
+
95
+ if (isRequestable) {
96
+ const queryParts = url.split("!");
97
+
98
+ if (queryParts.length > 1) {
99
+ url = queryParts.pop();
100
+ prefix = queryParts.join("!");
101
+ }
102
+ }
103
+
104
+ if (url.trim().length === 0) {
105
+ const error = new Error(
106
+ `Unable to find uri in "${atRule.toString()}"`,
107
+ );
108
+ error.node = atRule;
109
+ throw error;
110
+ }
111
+
112
+ const mediaNodes = paramsNodes.slice(1);
113
+ let media;
114
+
115
+ if (mediaNodes.length > 0) {
116
+ media = valueParser.stringify(mediaNodes).trim().toLowerCase();
117
+ }
118
+
119
+ return {
120
+ atRule,
121
+ prefix,
122
+ url,
123
+ media,
124
+ isRequestable,
125
+ };
126
+ }
127
+
128
+ const plugin = (options = {}) => {
129
+ return {
130
+ postcssPlugin: "postcss-import-parser",
131
+
132
+ prepare(result) {
133
+ const parsedAtRules = [];
134
+ return {
135
+ AtRule: {
136
+ import(atRule) {
137
+ let parsedAtRule;
138
+
139
+ try {
140
+ parsedAtRule = parseNode(atRule, "params", result);
141
+ } catch (error) {
142
+ result.warn(error.message, {
143
+ node: error.node,
144
+ });
145
+ }
146
+
147
+ if (!parsedAtRule) {
148
+ return;
149
+ }
150
+
151
+ parsedAtRules.push(parsedAtRule);
152
+ },
153
+ },
154
+
155
+ async OnceExit() {
156
+ if (parsedAtRules.length === 0) {
157
+ return;
158
+ }
159
+
160
+ const resolvedAtRules = await Promise.all(
161
+ parsedAtRules.map(async (parsedAtRule) => {
162
+ const {atRule, isRequestable, prefix, url, media} =
163
+ parsedAtRule;
164
+
165
+ if (options.filter) {
166
+ const needKeep = await options.filter(url, media);
167
+
168
+ if (!needKeep) {
169
+ return;
170
+ }
171
+ }
172
+
173
+ if (isRequestable) {
174
+ const request = requestify(url, options.rootContext);
175
+ const {resolver, context} = options;
176
+ const resolvedUrl = await resolveRequests(
177
+ resolver,
178
+ context,
179
+ [...new Set([request, url])],
180
+ );
181
+
182
+ if (!resolvedUrl) {
183
+ return;
184
+ }
185
+
186
+ atRule.remove();
187
+
188
+ return {
189
+ url: resolvedUrl,
190
+ media,
191
+ prefix,
192
+ isRequestable,
193
+ };
194
+ }
195
+
196
+ atRule.remove();
197
+
198
+ return {
199
+ url,
200
+ media,
201
+ prefix,
202
+ isRequestable,
203
+ };
204
+ }),
205
+ );
206
+ const urlToNameMap = new Map();
207
+
208
+ for (
209
+ let index = 0;
210
+ index <= resolvedAtRules.length - 1;
211
+ index++
212
+ ) {
213
+ const resolvedAtRule = resolvedAtRules[index];
214
+
215
+ if (!resolvedAtRule) {
216
+ continue;
217
+ }
218
+
219
+ const {url, isRequestable, media} = resolvedAtRule;
220
+
221
+ if (!isRequestable) {
222
+ options.api.push({
223
+ url,
224
+ media,
225
+ index,
226
+ });
227
+
228
+ continue;
229
+ }
230
+
231
+ const {prefix} = resolvedAtRule;
232
+ const newUrl = prefix ? `${prefix}!${url}` : url;
233
+ let importName = urlToNameMap.get(newUrl);
234
+
235
+ if (!importName) {
236
+ importName = `___CSS_LOADER_AT_RULE_IMPORT_${urlToNameMap.size}___`;
237
+ urlToNameMap.set(newUrl, importName);
238
+ options.imports.push({
239
+ importName,
240
+ url: options.urlHandler(newUrl),
241
+ index,
242
+ });
243
+ }
244
+
245
+ options.api.push({
246
+ importName,
247
+ media,
248
+ index,
249
+ });
250
+ }
251
+ },
252
+ };
253
+ },
254
+ };
255
+ };
256
+
257
+ plugin.postcss = true;
258
+ module.exports = plugin;