| 504 | handle_identifier(node, state, path); |
| 505 | }, |
| 506 | ImportDeclaration(node, { state }) { |
| 507 | state.props_insertion_point = node.end ?? state.props_insertion_point; |
| 508 | if (node.source.value === 'svelte') { |
| 509 | let illegal_specifiers = []; |
| 510 | let removed_specifiers = 0; |
| 511 | for (let specifier of node.specifiers) { |
| 512 | if ( |
| 513 | specifier.type === 'ImportSpecifier' && |
| 514 | specifier.imported.type === 'Identifier' && |
| 515 | ['beforeUpdate', 'afterUpdate'].includes(specifier.imported.name) |
| 516 | ) { |
| 517 | const references = state.scope.references.get(specifier.local.name); |
| 518 | if (!references) { |
| 519 | let end = /** @type {number} */ ( |
| 520 | state.str.original.indexOf(',', specifier.end) !== -1 && |
| 521 | state.str.original.indexOf(',', specifier.end) < |
| 522 | state.str.original.indexOf('}', specifier.end) |
| 523 | ? state.str.original.indexOf(',', specifier.end) + 1 |
| 524 | : specifier.end |
| 525 | ); |
| 526 | while (state.str.original[end].trim() === '') end++; |
| 527 | state.str.remove(/** @type {number} */ (specifier.start), end); |
| 528 | removed_specifiers++; |
| 529 | continue; |
| 530 | } |
| 531 | illegal_specifiers.push(specifier.imported.name); |
| 532 | } |
| 533 | } |
| 534 | if (removed_specifiers === node.specifiers.length) { |
| 535 | state.str.remove(/** @type {number} */ (node.start), /** @type {number} */ (node.end)); |
| 536 | } |
| 537 | if (illegal_specifiers.length > 0) { |
| 538 | throw new MigrationError( |
| 539 | `Can't migrate code with ${illegal_specifiers.join(' and ')}. Please migrate by hand.` |
| 540 | ); |
| 541 | } |
| 542 | } |
| 543 | }, |
| 544 | ExportNamedDeclaration(node, { state, next }) { |
| 545 | if (node.declaration) { |
| 546 | next(); |