source: imaps-frontend/node_modules/@babel/generator/lib/generators/modules.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 6 months ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 8.0 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.ExportAllDeclaration = ExportAllDeclaration;
7exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
8exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
9exports.ExportNamedDeclaration = ExportNamedDeclaration;
10exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
11exports.ExportSpecifier = ExportSpecifier;
12exports.ImportAttribute = ImportAttribute;
13exports.ImportDeclaration = ImportDeclaration;
14exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
15exports.ImportExpression = ImportExpression;
16exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
17exports.ImportSpecifier = ImportSpecifier;
18exports._printAttributes = _printAttributes;
19var _t = require("@babel/types");
20var _index = require("../node/index.js");
21const {
22 isClassDeclaration,
23 isExportDefaultSpecifier,
24 isExportNamespaceSpecifier,
25 isImportDefaultSpecifier,
26 isImportNamespaceSpecifier,
27 isStatement
28} = _t;
29function ImportSpecifier(node) {
30 if (node.importKind === "type" || node.importKind === "typeof") {
31 this.word(node.importKind);
32 this.space();
33 }
34 this.print(node.imported);
35 if (node.local && node.local.name !== node.imported.name) {
36 this.space();
37 this.word("as");
38 this.space();
39 this.print(node.local);
40 }
41}
42function ImportDefaultSpecifier(node) {
43 this.print(node.local);
44}
45function ExportDefaultSpecifier(node) {
46 this.print(node.exported);
47}
48function ExportSpecifier(node) {
49 if (node.exportKind === "type") {
50 this.word("type");
51 this.space();
52 }
53 this.print(node.local);
54 if (node.exported && node.local.name !== node.exported.name) {
55 this.space();
56 this.word("as");
57 this.space();
58 this.print(node.exported);
59 }
60}
61function ExportNamespaceSpecifier(node) {
62 this.tokenChar(42);
63 this.space();
64 this.word("as");
65 this.space();
66 this.print(node.exported);
67}
68let warningShown = false;
69function _printAttributes(node, hasPreviousBrace) {
70 const {
71 importAttributesKeyword
72 } = this.format;
73 const {
74 attributes,
75 assertions
76 } = node;
77 if (attributes && !importAttributesKeyword && !warningShown) {
78 warningShown = true;
79 console.warn(`\
80You are using import attributes, without specifying the desired output syntax.
81Please specify the "importAttributesKeyword" generator option, whose value can be one of:
82 - "with" : \`import { a } from "b" with { type: "json" };\`
83 - "assert" : \`import { a } from "b" assert { type: "json" };\`
84 - "with-legacy" : \`import { a } from "b" with type: "json";\`
85`);
86 }
87 const useAssertKeyword = importAttributesKeyword === "assert" || !importAttributesKeyword && assertions;
88 this.word(useAssertKeyword ? "assert" : "with");
89 this.space();
90 if (!useAssertKeyword && importAttributesKeyword !== "with") {
91 this.printList(attributes || assertions);
92 return;
93 }
94 const occurrenceCount = hasPreviousBrace ? 1 : 0;
95 this.token("{", null, occurrenceCount);
96 this.space();
97 this.printList(attributes || assertions, this.shouldPrintTrailingComma("}"));
98 this.space();
99 this.token("}", null, occurrenceCount);
100}
101function ExportAllDeclaration(node) {
102 var _node$attributes, _node$assertions;
103 this.word("export");
104 this.space();
105 if (node.exportKind === "type") {
106 this.word("type");
107 this.space();
108 }
109 this.tokenChar(42);
110 this.space();
111 this.word("from");
112 this.space();
113 if ((_node$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) {
114 this.print(node.source, true);
115 this.space();
116 this._printAttributes(node, false);
117 } else {
118 this.print(node.source);
119 }
120 this.semicolon();
121}
122function maybePrintDecoratorsBeforeExport(printer, node) {
123 if (isClassDeclaration(node.declaration) && printer._shouldPrintDecoratorsBeforeExport(node)) {
124 printer.printJoin(node.declaration.decorators);
125 }
126}
127function ExportNamedDeclaration(node) {
128 maybePrintDecoratorsBeforeExport(this, node);
129 this.word("export");
130 this.space();
131 if (node.declaration) {
132 const declar = node.declaration;
133 this.print(declar);
134 if (!isStatement(declar)) this.semicolon();
135 } else {
136 if (node.exportKind === "type") {
137 this.word("type");
138 this.space();
139 }
140 const specifiers = node.specifiers.slice(0);
141 let hasSpecial = false;
142 for (;;) {
143 const first = specifiers[0];
144 if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
145 hasSpecial = true;
146 this.print(specifiers.shift());
147 if (specifiers.length) {
148 this.tokenChar(44);
149 this.space();
150 }
151 } else {
152 break;
153 }
154 }
155 let hasBrace = false;
156 if (specifiers.length || !specifiers.length && !hasSpecial) {
157 hasBrace = true;
158 this.tokenChar(123);
159 if (specifiers.length) {
160 this.space();
161 this.printList(specifiers, this.shouldPrintTrailingComma("}"));
162 this.space();
163 }
164 this.tokenChar(125);
165 }
166 if (node.source) {
167 var _node$attributes2, _node$assertions2;
168 this.space();
169 this.word("from");
170 this.space();
171 if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
172 this.print(node.source, true);
173 this.space();
174 this._printAttributes(node, hasBrace);
175 } else {
176 this.print(node.source);
177 }
178 }
179 this.semicolon();
180 }
181}
182function ExportDefaultDeclaration(node) {
183 maybePrintDecoratorsBeforeExport(this, node);
184 this.word("export");
185 this.noIndentInnerCommentsHere();
186 this.space();
187 this.word("default");
188 this.space();
189 this.tokenContext |= _index.TokenContext.exportDefault;
190 const declar = node.declaration;
191 this.print(declar);
192 if (!isStatement(declar)) this.semicolon();
193}
194function ImportDeclaration(node) {
195 var _node$attributes3, _node$assertions3;
196 this.word("import");
197 this.space();
198 const isTypeKind = node.importKind === "type" || node.importKind === "typeof";
199 if (isTypeKind) {
200 this.noIndentInnerCommentsHere();
201 this.word(node.importKind);
202 this.space();
203 } else if (node.module) {
204 this.noIndentInnerCommentsHere();
205 this.word("module");
206 this.space();
207 } else if (node.phase) {
208 this.noIndentInnerCommentsHere();
209 this.word(node.phase);
210 this.space();
211 }
212 const specifiers = node.specifiers.slice(0);
213 const hasSpecifiers = !!specifiers.length;
214 while (hasSpecifiers) {
215 const first = specifiers[0];
216 if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
217 this.print(specifiers.shift());
218 if (specifiers.length) {
219 this.tokenChar(44);
220 this.space();
221 }
222 } else {
223 break;
224 }
225 }
226 let hasBrace = false;
227 if (specifiers.length) {
228 hasBrace = true;
229 this.tokenChar(123);
230 this.space();
231 this.printList(specifiers, this.shouldPrintTrailingComma("}"));
232 this.space();
233 this.tokenChar(125);
234 } else if (isTypeKind && !hasSpecifiers) {
235 hasBrace = true;
236 this.tokenChar(123);
237 this.tokenChar(125);
238 }
239 if (hasSpecifiers || isTypeKind) {
240 this.space();
241 this.word("from");
242 this.space();
243 }
244 if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
245 this.print(node.source, true);
246 this.space();
247 this._printAttributes(node, hasBrace);
248 } else {
249 this.print(node.source);
250 }
251 this.semicolon();
252}
253function ImportAttribute(node) {
254 this.print(node.key);
255 this.tokenChar(58);
256 this.space();
257 this.print(node.value);
258}
259function ImportNamespaceSpecifier(node) {
260 this.tokenChar(42);
261 this.space();
262 this.word("as");
263 this.space();
264 this.print(node.local);
265}
266function ImportExpression(node) {
267 this.word("import");
268 if (node.phase) {
269 this.tokenChar(46);
270 this.word(node.phase);
271 }
272 this.tokenChar(40);
273 this.print(node.source);
274 if (node.options != null) {
275 this.tokenChar(44);
276 this.space();
277 this.print(node.options);
278 }
279 this.tokenChar(41);
280}
281
282//# sourceMappingURL=modules.js.map
Note: See TracBrowser for help on using the repository browser.