1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.ImportSpecifier = ImportSpecifier; 7exports.ImportDefaultSpecifier = ImportDefaultSpecifier; 8exports.ExportDefaultSpecifier = ExportDefaultSpecifier; 9exports.ExportSpecifier = ExportSpecifier; 10exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier; 11exports.ExportAllDeclaration = ExportAllDeclaration; 12exports.ExportNamedDeclaration = ExportNamedDeclaration; 13exports.ExportDefaultDeclaration = ExportDefaultDeclaration; 14exports.ImportDeclaration = ImportDeclaration; 15exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; 16 17function t() { 18 const data = _interopRequireWildcard(require("@babel/types")); 19 20 t = function () { 21 return data; 22 }; 23 24 return data; 25} 26 27function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } 28 29function ImportSpecifier(node) { 30 if (node.importKind === "type" || node.importKind === "typeof") { 31 this.word(node.importKind); 32 this.space(); 33 } 34 35 this.print(node.imported, node); 36 37 if (node.local && node.local.name !== node.imported.name) { 38 this.space(); 39 this.word("as"); 40 this.space(); 41 this.print(node.local, node); 42 } 43} 44 45function ImportDefaultSpecifier(node) { 46 this.print(node.local, node); 47} 48 49function ExportDefaultSpecifier(node) { 50 this.print(node.exported, node); 51} 52 53function ExportSpecifier(node) { 54 this.print(node.local, node); 55 56 if (node.exported && node.local.name !== node.exported.name) { 57 this.space(); 58 this.word("as"); 59 this.space(); 60 this.print(node.exported, node); 61 } 62} 63 64function ExportNamespaceSpecifier(node) { 65 this.token("*"); 66 this.space(); 67 this.word("as"); 68 this.space(); 69 this.print(node.exported, node); 70} 71 72function ExportAllDeclaration(node) { 73 this.word("export"); 74 this.space(); 75 76 if (node.exportKind === "type") { 77 this.word("type"); 78 this.space(); 79 } 80 81 this.token("*"); 82 this.space(); 83 this.word("from"); 84 this.space(); 85 this.print(node.source, node); 86 this.semicolon(); 87} 88 89function ExportNamedDeclaration(node) { 90 if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) { 91 this.printJoin(node.declaration.decorators, node); 92 } 93 94 this.word("export"); 95 this.space(); 96 ExportDeclaration.apply(this, arguments); 97} 98 99function ExportDefaultDeclaration(node) { 100 if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) { 101 this.printJoin(node.declaration.decorators, node); 102 } 103 104 this.word("export"); 105 this.space(); 106 this.word("default"); 107 this.space(); 108 ExportDeclaration.apply(this, arguments); 109} 110 111function ExportDeclaration(node) { 112 if (node.declaration) { 113 const declar = node.declaration; 114 this.print(declar, node); 115 if (!t().isStatement(declar)) this.semicolon(); 116 } else { 117 if (node.exportKind === "type") { 118 this.word("type"); 119 this.space(); 120 } 121 122 const specifiers = node.specifiers.slice(0); 123 let hasSpecial = false; 124 125 while (true) { 126 const first = specifiers[0]; 127 128 if (t().isExportDefaultSpecifier(first) || t().isExportNamespaceSpecifier(first)) { 129 hasSpecial = true; 130 this.print(specifiers.shift(), node); 131 132 if (specifiers.length) { 133 this.token(","); 134 this.space(); 135 } 136 } else { 137 break; 138 } 139 } 140 141 if (specifiers.length || !specifiers.length && !hasSpecial) { 142 this.token("{"); 143 144 if (specifiers.length) { 145 this.space(); 146 this.printList(specifiers, node); 147 this.space(); 148 } 149 150 this.token("}"); 151 } 152 153 if (node.source) { 154 this.space(); 155 this.word("from"); 156 this.space(); 157 this.print(node.source, node); 158 } 159 160 this.semicolon(); 161 } 162} 163 164function ImportDeclaration(node) { 165 this.word("import"); 166 this.space(); 167 168 if (node.importKind === "type" || node.importKind === "typeof") { 169 this.word(node.importKind); 170 this.space(); 171 } 172 173 const specifiers = node.specifiers.slice(0); 174 175 if (specifiers && specifiers.length) { 176 while (true) { 177 const first = specifiers[0]; 178 179 if (t().isImportDefaultSpecifier(first) || t().isImportNamespaceSpecifier(first)) { 180 this.print(specifiers.shift(), node); 181 182 if (specifiers.length) { 183 this.token(","); 184 this.space(); 185 } 186 } else { 187 break; 188 } 189 } 190 191 if (specifiers.length) { 192 this.token("{"); 193 this.space(); 194 this.printList(specifiers, node); 195 this.space(); 196 this.token("}"); 197 } 198 199 this.space(); 200 this.word("from"); 201 this.space(); 202 } 203 204 this.print(node.source, node); 205 this.semicolon(); 206} 207 208function ImportNamespaceSpecifier(node) { 209 this.token("*"); 210 this.space(); 211 this.word("as"); 212 this.space(); 213 this.print(node.local, node); 214}