1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getExportLazyStyleCode = getExportLazyStyleCode;
|
7 | exports.getExportStyleCode = getExportStyleCode;
|
8 | exports.getImportInsertBySelectorCode = getImportInsertBySelectorCode;
|
9 | exports.getImportInsertStyleElementCode = getImportInsertStyleElementCode;
|
10 | exports.getImportIsOldIECode = getImportIsOldIECode;
|
11 | exports.getImportLinkAPICode = getImportLinkAPICode;
|
12 | exports.getImportLinkContentCode = getImportLinkContentCode;
|
13 | exports.getImportStyleAPICode = getImportStyleAPICode;
|
14 | exports.getImportStyleContentCode = getImportStyleContentCode;
|
15 | exports.getImportStyleDomAPICode = getImportStyleDomAPICode;
|
16 | exports.getInsertOptionCode = getInsertOptionCode;
|
17 | exports.getLinkHmrCode = getLinkHmrCode;
|
18 | exports.getSetAttributesCode = getSetAttributesCode;
|
19 | exports.getStyleHmrCode = getStyleHmrCode;
|
20 | exports.getStyleTagTransformFn = getStyleTagTransformFn;
|
21 | exports.getStyleTagTransformFnCode = getStyleTagTransformFnCode;
|
22 | exports.getdomAPI = getdomAPI;
|
23 | exports.stringifyRequest = stringifyRequest;
|
24 | var _path = _interopRequireDefault(require("path"));
|
25 | var _isEqualLocals = _interopRequireDefault(require("./runtime/isEqualLocals"));
|
26 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27 | function stringifyRequest(loaderContext, request) {
|
28 | return JSON.stringify(loaderContext.utils.contextify(loaderContext.context, request));
|
29 | }
|
30 | function getImportLinkAPICode(esModule, loaderContext) {
|
31 | const modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/injectStylesIntoLinkTag.js")}`);
|
32 | return esModule ? `import API from ${modulePath};` : `var API = require(${modulePath});`;
|
33 | }
|
34 | function getImportLinkContentCode(esModule, loaderContext, request) {
|
35 | const modulePath = stringifyRequest(loaderContext, `!!${request}`);
|
36 | return esModule ? `import content from ${modulePath};` : `var content = require(${modulePath});`;
|
37 | }
|
38 | function getImportStyleAPICode(esModule, loaderContext) {
|
39 | const modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/injectStylesIntoStyleTag.js")}`);
|
40 | return esModule ? `import API from ${modulePath};` : `var API = require(${modulePath});`;
|
41 | }
|
42 | function getImportStyleDomAPICode(esModule, loaderContext, isSingleton, isAuto) {
|
43 | const styleAPI = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/styleDomAPI.js")}`);
|
44 | const singletonAPI = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/singletonStyleDomAPI.js")}`);
|
45 | if (isAuto) {
|
46 | return esModule ? `import domAPI from ${styleAPI};
|
47 | import domAPISingleton from ${singletonAPI};` : `var domAPI = require(${styleAPI});
|
48 | var domAPISingleton = require(${singletonAPI});`;
|
49 | }
|
50 | return esModule ? `import domAPI from ${isSingleton ? singletonAPI : styleAPI};` : `var domAPI = require(${isSingleton ? singletonAPI : styleAPI});`;
|
51 | }
|
52 | function getImportStyleContentCode(esModule, loaderContext, request) {
|
53 | const modulePath = stringifyRequest(loaderContext, `!!${request}`);
|
54 | return esModule ? `import content, * as namedExport from ${modulePath};` : `var content = require(${modulePath});`;
|
55 | }
|
56 | function getImportInsertBySelectorCode(esModule, loaderContext, insertType, options) {
|
57 | if (insertType === "module-path") {
|
58 | const modulePath = stringifyRequest(loaderContext, `${options.insert}`);
|
59 | loaderContext.addBuildDependency(options.insert);
|
60 | return esModule ? `import insertFn from ${modulePath};` : `var insertFn = require(${modulePath});`;
|
61 | }
|
62 | const modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/insertBySelector.js")}`);
|
63 | return esModule ? `import insertFn from ${modulePath};` : `var insertFn = require(${modulePath});`;
|
64 | }
|
65 | function getInsertOptionCode(insertType, options) {
|
66 | if (insertType === "module-path") {
|
67 | return `options.insert = insertFn;`;
|
68 | }
|
69 | const insert = options.insert ? JSON.stringify(options.insert) : '"head"';
|
70 | return `options.insert = insertFn.bind(null, ${insert});`;
|
71 | }
|
72 | function getImportInsertStyleElementCode(esModule, loaderContext) {
|
73 | const modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/insertStyleElement.js")}`);
|
74 | return esModule ? `import insertStyleElement from ${modulePath};` : `var insertStyleElement = require(${modulePath});`;
|
75 | }
|
76 | function getStyleHmrCode(esModule, loaderContext, request, lazy) {
|
77 | const modulePath = stringifyRequest(loaderContext, `!!${request}`);
|
78 | return `
|
79 | if (module.hot) {
|
80 | if (!content.locals || module.hot.invalidate) {
|
81 | var isEqualLocals = ${_isEqualLocals.default.toString()};
|
82 | var isNamedExport = ${esModule ? "!content.locals" : false};
|
83 | var oldLocals = isNamedExport ? namedExport : content.locals;
|
84 |
|
85 | module.hot.accept(
|
86 | ${modulePath},
|
87 | function () {
|
88 | ${esModule ? `if (!isEqualLocals(oldLocals, isNamedExport ? namedExport : content.locals, isNamedExport)) {
|
89 | module.hot.invalidate();
|
90 |
|
91 | return;
|
92 | }
|
93 |
|
94 | oldLocals = isNamedExport ? namedExport : content.locals;
|
95 |
|
96 | ${lazy ? `if (update && refs > 0) {
|
97 | update(content);
|
98 | }` : `update(content);`}` : `content = require(${modulePath});
|
99 |
|
100 | content = content.__esModule ? content.default : content;
|
101 |
|
102 | ${lazy ? "" : `if (typeof content === 'string') {
|
103 | content = [[module.id, content, '']];
|
104 | }`}
|
105 |
|
106 | if (!isEqualLocals(oldLocals, content.locals)) {
|
107 | module.hot.invalidate();
|
108 |
|
109 | return;
|
110 | }
|
111 |
|
112 | oldLocals = content.locals;
|
113 |
|
114 | ${lazy ? `if (update && refs > 0) {
|
115 | update(content);
|
116 | }` : `update(content);`}`}
|
117 | }
|
118 | )
|
119 | }
|
120 |
|
121 | module.hot.dispose(function() {
|
122 | ${lazy ? `if (update) {
|
123 | update();
|
124 | }` : `update();`}
|
125 | });
|
126 | }
|
127 | `;
|
128 | }
|
129 | function getLinkHmrCode(esModule, loaderContext, request) {
|
130 | const modulePath = stringifyRequest(loaderContext, `!!${request}`);
|
131 | return `
|
132 | if (module.hot) {
|
133 | module.hot.accept(
|
134 | ${modulePath},
|
135 | function() {
|
136 | ${esModule ? "update(content);" : `content = require(${modulePath});
|
137 |
|
138 | content = content.__esModule ? content.default : content;
|
139 |
|
140 | update(content);`}
|
141 | }
|
142 | );
|
143 |
|
144 | module.hot.dispose(function() {
|
145 | update();
|
146 | });
|
147 | }`;
|
148 | }
|
149 | function getdomAPI(isAuto) {
|
150 | return isAuto ? "isOldIE() ? domAPISingleton : domAPI" : "domAPI";
|
151 | }
|
152 | function getImportIsOldIECode(esModule, loaderContext) {
|
153 | const modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/isOldIE.js")}`);
|
154 | return esModule ? `import isOldIE from ${modulePath};` : `var isOldIE = require(${modulePath});`;
|
155 | }
|
156 | function getStyleTagTransformFnCode(esModule, loaderContext, options, isSingleton) {
|
157 | if (isSingleton) {
|
158 | return "";
|
159 | }
|
160 | if (typeof options.styleTagTransform !== "undefined") {
|
161 | const modulePath = stringifyRequest(loaderContext, `${options.styleTagTransform}`);
|
162 | loaderContext.addBuildDependency(options.styleTagTransform);
|
163 | return esModule ? `import styleTagTransformFn from ${modulePath};` : `var styleTagTransformFn = require(${modulePath});`;
|
164 | }
|
165 | const modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/styleTagTransform.js")}`);
|
166 | return esModule ? `import styleTagTransformFn from ${modulePath};` : `var styleTagTransformFn = require(${modulePath});`;
|
167 | }
|
168 | function getStyleTagTransformFn(options, isSingleton) {
|
169 | return isSingleton ? "" : `options.styleTagTransform = styleTagTransformFn`;
|
170 | }
|
171 | function getExportStyleCode(esModule, loaderContext, request) {
|
172 | const modulePath = stringifyRequest(loaderContext, `!!${request}`);
|
173 | return esModule ? `export * from ${modulePath};
|
174 | export default content && content.locals ? content.locals : undefined;` : "module.exports = content && content.locals || {};";
|
175 | }
|
176 | function getExportLazyStyleCode(esModule, loaderContext, request) {
|
177 | const modulePath = stringifyRequest(loaderContext, `!!${request}`);
|
178 | return esModule ? `export * from ${modulePath};
|
179 | export default exported;` : "module.exports = exported;";
|
180 | }
|
181 | function getSetAttributesCode(esModule, loaderContext, options) {
|
182 | let modulePath;
|
183 | if (typeof options.attributes !== "undefined") {
|
184 | modulePath = options.attributes.nonce !== "undefined" ? stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/setAttributesWithAttributesAndNonce.js")}`) : stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/setAttributesWithAttributes.js")}`);
|
185 | } else {
|
186 | modulePath = stringifyRequest(loaderContext, `!${_path.default.join(__dirname, "runtime/setAttributesWithoutAttributes.js")}`);
|
187 | }
|
188 | return esModule ? `import setAttributes from ${modulePath};` : `var setAttributes = require(${modulePath});`;
|
189 | }
|
190 |
|
191 |
|
\ | No newline at end of file |