UNPKG

2.32 kBJavaScriptView Raw
1"use strict";
2
3/*
4 MIT License http://www.opensource.org/licenses/mit-license.php
5 Author Tobias Koppers @sokra
6*/
7module.exports = function (cssWithMappingToString) {
8 var list = []; // return the list of modules as css string
9
10 list.toString = function toString() {
11 return this.map(function (item) {
12 var content = "";
13 var needLayer = typeof item[5] !== "undefined";
14
15 if (item[4]) {
16 content += "@supports (".concat(item[4], ") {");
17 }
18
19 if (item[2]) {
20 content += "@media ".concat(item[2], " {");
21 }
22
23 if (needLayer) {
24 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
25 }
26
27 content += cssWithMappingToString(item);
28
29 if (needLayer) {
30 content += "}";
31 }
32
33 if (item[2]) {
34 content += "}";
35 }
36
37 if (item[4]) {
38 content += "}";
39 }
40
41 return content;
42 }).join("");
43 }; // import a list of modules into the list
44
45
46 list.i = function i(modules, media, dedupe, supports, layer) {
47 if (typeof modules === "string") {
48 modules = [[null, modules, undefined]];
49 }
50
51 var alreadyImportedModules = {};
52
53 if (dedupe) {
54 for (var k = 0; k < this.length; k++) {
55 var id = this[k][0];
56
57 if (id != null) {
58 alreadyImportedModules[id] = true;
59 }
60 }
61 }
62
63 for (var _k = 0; _k < modules.length; _k++) {
64 var item = [].concat(modules[_k]);
65
66 if (dedupe && alreadyImportedModules[item[0]]) {
67 continue;
68 }
69
70 if (typeof layer !== "undefined") {
71 if (typeof item[5] === "undefined") {
72 item[5] = layer;
73 } else {
74 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
75 item[5] = layer;
76 }
77 }
78
79 if (media) {
80 if (!item[2]) {
81 item[2] = media;
82 } else {
83 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
84 item[2] = media;
85 }
86 }
87
88 if (supports) {
89 if (!item[4]) {
90 item[4] = "".concat(supports);
91 } else {
92 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
93 item[4] = supports;
94 }
95 }
96
97 list.push(item);
98 }
99 };
100
101 return list;
102};
\No newline at end of file