@epilot/zenith-react 0.2.0-next.3 → 0.2.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/codemods/README.md +168 -0
- package/codemods/migrate/base-elements/accordion.ts +132 -0
- package/codemods/migrate/base-elements/alert.ts +81 -0
- package/codemods/migrate/base-elements/avatar.ts +116 -0
- package/codemods/migrate/base-elements/button.ts +188 -0
- package/codemods/migrate/base-elements/checkbox.ts +17 -0
- package/codemods/migrate/base-elements/chip.ts +87 -0
- package/codemods/migrate/base-elements/chip360.ts +162 -0
- package/codemods/migrate/base-elements/circular-progress.ts +73 -0
- package/codemods/migrate/base-elements/dialog.ts +323 -0
- package/codemods/migrate/base-elements/divider.ts +61 -0
- package/codemods/migrate/base-elements/feedback-message.ts +95 -0
- package/codemods/migrate/base-elements/icon-button.ts +203 -0
- package/codemods/migrate/base-elements/index.ts +55 -0
- package/codemods/migrate/base-elements/mui-props.ts +29 -0
- package/codemods/migrate/base-elements/notification.ts +98 -0
- package/codemods/migrate/base-elements/paper.ts +78 -0
- package/codemods/migrate/base-elements/select.ts +328 -0
- package/codemods/migrate/base-elements/shared.ts +910 -0
- package/codemods/migrate/base-elements/skeleton.ts +83 -0
- package/codemods/migrate/base-elements/switch.ts +19 -0
- package/codemods/migrate/base-elements/tabs.ts +222 -0
- package/codemods/migrate/base-elements/text-field.ts +425 -0
- package/codemods/migrate/base-elements/toggle-button.ts +185 -0
- package/codemods/migrate/base-elements/tooltip.ts +231 -0
- package/codemods/migrate/base-elements/typography.ts +247 -0
- package/codemods/migrate/base-elements/unsupported.ts +277 -0
- package/codemods/migrate/from-base-elements.ts +20 -0
- package/codemods/migrate/from-volt.ts +20 -0
- package/codemods/migrate/lib/imports.ts +399 -0
- package/codemods/migrate/lib/jsx.ts +313 -0
- package/codemods/migrate/lib/run-migration.ts +528 -0
- package/codemods/migrate/lib/source.ts +6 -0
- package/codemods/migrate/lib/todo.ts +107 -0
- package/codemods/migrate/lib/types.ts +114 -0
- package/codemods/migrate/volt/class-helpers.ts +37 -0
- package/codemods/migrate/volt/index.ts +18 -0
- package/codemods/migrate/volt/pagination.ts +26 -0
- package/codemods/migrate/volt/same-name.ts +293 -0
- package/codemods/migrate/volt/stylesheets.ts +18 -0
- package/codemods/migrate/volt/tanstack-types.ts +20 -0
- package/codemods/radix-to-base-ui.ts +389 -0
- package/dist/_virtual/_zenith-runtime-family_accordion.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_accordion.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_alert-dialog.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_alert-dialog.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_avatar.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_avatar.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_button.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_button.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_checkbox.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_checkbox.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_csp-provider.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_csp-provider.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_dialog.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_dialog.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_direction-provider.js +8 -0
- package/dist/_virtual/_zenith-runtime-family_direction-provider.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_menu.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_menu.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_merge-props.js +11 -0
- package/dist/_virtual/_zenith-runtime-family_merge-props.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_popover.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_popover.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_radio-group.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_radio-group.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_radio.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_radio.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_scroll-area.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_scroll-area.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_select.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_select.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_separator.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_separator.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_switch.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_switch.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_tabs.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_tabs.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_toast.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_toast.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_toggle-group.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_toggle-group.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_toggle.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_toggle.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_tooltip.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_tooltip.js.map +1 -0
- package/dist/_virtual/_zenith-runtime-family_use-render.js +7 -0
- package/dist/_virtual/_zenith-runtime-family_use-render.js.map +1 -0
- package/dist/components/accordion/accordion.js +179 -96
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +243 -206
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/avatar/avatar.js +94 -82
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.js +11 -11
- package/dist/components/breadcrumb/breadcrumb.js +69 -70
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button.js +119 -102
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +68 -51
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +100 -90
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-input.js +118 -108
- package/dist/components/date-time-picker/date-time-picker-input.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-panel.js +91 -94
- package/dist/components/date-time-picker/date-time-picker-panel.js.map +1 -1
- package/dist/components/dialog/dialog.js +238 -228
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.js +259 -321
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +533 -279
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field-combobox.js +87 -77
- package/dist/components/field/field-combobox.js.map +1 -1
- package/dist/components/list/list-sortable.js +104 -0
- package/dist/components/list/list-sortable.js.map +1 -0
- package/dist/components/list/list.js +246 -324
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/option-card/option-card.js +121 -117
- package/dist/components/option-card/option-card.js.map +1 -1
- package/dist/components/pill/pill.js +7 -7
- package/dist/components/popover/popover.js +223 -127
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/radio/radio-group-base.js +54 -0
- package/dist/components/radio/radio-group-base.js.map +1 -0
- package/dist/components/radio/radio.js +71 -60
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +142 -108
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/scroll-overflow/scroll-overflow.js +156 -127
- package/dist/components/scroll-overflow/scroll-overflow.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +93 -81
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.js +485 -310
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/slot/compose-as-child.js +15 -12
- package/dist/components/slot/compose-as-child.js.map +1 -1
- package/dist/components/switch/switch.js +75 -68
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table-pagination.js +212 -175
- package/dist/components/table/table-pagination.js.map +1 -1
- package/dist/components/tabs/tabs.js +193 -190
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/toast/toast.js +610 -148
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toggle/toggle-group.js +143 -32
- package/dist/components/toggle/toggle-group.js.map +1 -1
- package/dist/components/toggle/toggle.js +83 -53
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/tooltip/tooltip.js +298 -138
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.d.ts +2335 -2129
- package/dist/index.js +24 -23
- package/dist/list/sortable/index.d.ts +29 -0
- package/dist/list/sortable/index.js +5 -0
- package/dist/{_virtual → list/sortable}/index.js.map +1 -1
- package/dist/packages/tokens/dist/delivery/index.js +10 -10
- package/dist/packages/tokens/dist/delivery/index.js.map +1 -1
- package/dist/packages/tokens/dist/generated/core.generated.js +6 -15
- package/dist/packages/tokens/dist/generated/core.generated.js.map +1 -1
- package/dist/packages/tokens/dist/generated/palette.generated.js +4 -5
- package/dist/packages/tokens/dist/generated/palette.generated.js.map +1 -1
- package/dist/packages/tokens/dist/generated/palette.meta.generated.js +5 -0
- package/dist/packages/tokens/dist/generated/palette.meta.generated.js.map +1 -0
- package/dist/packages/tokens/dist/install.js +40 -17
- package/dist/packages/tokens/dist/install.js.map +1 -1
- package/dist/renderer/runtime-contract.generated.js +8 -0
- package/dist/renderer/runtime-contract.generated.js.map +1 -0
- package/dist/renderer/served.js +34 -0
- package/dist/renderer/served.js.map +1 -0
- package/dist/tokens/core.meta.generated.js +2 -2
- package/dist/tokens/core.meta.generated.js.map +1 -1
- package/dist/tokens/index.d.ts +1028 -1028
- package/dist/tokens/index.js +863 -863
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/palette.meta.generated.js +5 -0
- package/dist/tokens/palette.meta.generated.js.map +1 -0
- package/dist/tokens.json +1 -1
- package/dist/vendor/.bun/@radix-ui_react-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-dialog/dist/index.js +57 -62
- package/dist/vendor/.bun/@radix-ui_react-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-dialog/dist/index.js.map +1 -1
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.3_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js +32 -38
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.3_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js.map +1 -1
- package/package.json +28 -21
- package/scripts/migration-diagnostics-core.mjs +18 -10
- package/scripts/migration-diagnostics.mjs +31 -8
- package/dist/_virtual/index.js +0 -6
- package/dist/_virtual/index2.js +0 -5
- package/dist/_virtual/index2.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.development.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.production.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/tokens/palette.generated.js +0 -5
- package/dist/tokens/palette.generated.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_core@1.8.0/vendor/@floating-ui/core/dist/floating-ui.core.js +0 -512
- package/dist/vendor/.bun/@floating-ui_core@1.8.0/vendor/@floating-ui/core/dist/floating-ui.core.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_dom@1.8.0/vendor/@floating-ui/dom/dist/floating-ui.dom.js +0 -396
- package/dist/vendor/.bun/@floating-ui_dom@1.8.0/vendor/@floating-ui/dom/dist/floating-ui.dom.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_react-dom@2.1.9_6f4b9a1cfb20c0ae/vendor/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -233
- package/dist/vendor/.bun/@floating-ui_react-dom@2.1.9_6f4b9a1cfb20c0ae/vendor/@floating-ui/react-dom/dist/floating-ui.react-dom.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -137
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +0 -1
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.js +0 -129
- package/dist/vendor/.bun/@floating-ui_utils@0.2.12/vendor/@floating-ui/utils/dist/floating-ui.utils.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_number@1.1.1/vendor/@radix-ui/number/dist/index.js +0 -7
- package/dist/vendor/.bun/@radix-ui_number@1.1.1/vendor/@radix-ui/number/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-accordion@1.2.12_2b23df507bdda662/vendor/@radix-ui/react-accordion/dist/index.js +0 -240
- package/dist/vendor/.bun/@radix-ui_react-accordion@1.2.12_2b23df507bdda662/vendor/@radix-ui/react-accordion/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-alert-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-alert-dialog/dist/index.js +0 -128
- package/dist/vendor/.bun/@radix-ui_react-alert-dialog@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-alert-dialog/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-arrow@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-arrow/dist/index.js +0 -25
- package/dist/vendor/.bun/@radix-ui_react-arrow@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-arrow/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-avatar@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-avatar/dist/index.js +0 -76
- package/dist/vendor/.bun/@radix-ui_react-avatar@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-avatar/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-checkbox@1.3.3_2b23df507bdda662/vendor/@radix-ui/react-checkbox/dist/index.js +0 -252
- package/dist/vendor/.bun/@radix-ui_react-checkbox@1.3.3_2b23df507bdda662/vendor/@radix-ui/react-checkbox/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-collapsible@1.1.12_2b23df507bdda662/vendor/@radix-ui/react-collapsible/dist/index.js +0 -121
- package/dist/vendor/.bun/@radix-ui_react-collapsible@1.1.12_2b23df507bdda662/vendor/@radix-ui/react-collapsible/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-collection@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-collection/dist/index.js +0 -49
- package/dist/vendor/.bun/@radix-ui_react-collection@1.1.7_2b23df507bdda662/vendor/@radix-ui/react-collection/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-direction@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-direction/dist/index.js +0 -11
- package/dist/vendor/.bun/@radix-ui_react-direction@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-direction/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-dropdown-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-dropdown-menu/dist/index.js +0 -228
- package/dist/vendor/.bun/@radix-ui_react-dropdown-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-dropdown-menu/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-menu/dist/index.js +0 -653
- package/dist/vendor/.bun/@radix-ui_react-menu@2.1.16_2b23df507bdda662/vendor/@radix-ui/react-menu/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-popover@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-popover/dist/index.js +0 -244
- package/dist/vendor/.bun/@radix-ui_react-popover@1.1.15_2b23df507bdda662/vendor/@radix-ui/react-popover/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-popper@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-popper/dist/index.js +0 -222
- package/dist/vendor/.bun/@radix-ui_react-popper@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-popper/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-radio-group@1.3.8_2b23df507bdda662/vendor/@radix-ui/react-radio-group/dist/index.js +0 -239
- package/dist/vendor/.bun/@radix-ui_react-radio-group@1.3.8_2b23df507bdda662/vendor/@radix-ui/react-radio-group/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-roving-focus@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-roving-focus/dist/index.js +0 -184
- package/dist/vendor/.bun/@radix-ui_react-roving-focus@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-roving-focus/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-scroll-area@1.2.10_2b23df507bdda662/vendor/@radix-ui/react-scroll-area/dist/index.js +0 -535
- package/dist/vendor/.bun/@radix-ui_react-scroll-area@1.2.10_2b23df507bdda662/vendor/@radix-ui/react-scroll-area/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-select@2.2.6_2b23df507bdda662/vendor/@radix-ui/react-select/dist/index.js +0 -863
- package/dist/vendor/.bun/@radix-ui_react-select@2.2.6_2b23df507bdda662/vendor/@radix-ui/react-select/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.4_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js +0 -63
- package/dist/vendor/.bun/@radix-ui_react-slot@1.2.4_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-switch@1.2.6_2b23df507bdda662/vendor/@radix-ui/react-switch/dist/index.js +0 -133
- package/dist/vendor/.bun/@radix-ui_react-switch@1.2.6_2b23df507bdda662/vendor/@radix-ui/react-switch/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-tabs@1.1.13_2b23df507bdda662/vendor/@radix-ui/react-tabs/dist/index.js +0 -164
- package/dist/vendor/.bun/@radix-ui_react-tabs@1.1.13_2b23df507bdda662/vendor/@radix-ui/react-tabs/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-toggle-group@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-toggle-group/dist/index.js +0 -138
- package/dist/vendor/.bun/@radix-ui_react-toggle-group@1.1.11_2b23df507bdda662/vendor/@radix-ui/react-toggle-group/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-toggle@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-toggle/dist/index.js +0 -34
- package/dist/vendor/.bun/@radix-ui_react-toggle@1.1.10_2b23df507bdda662/vendor/@radix-ui/react-toggle/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-tooltip@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-tooltip/dist/index.js +0 -340
- package/dist/vendor/.bun/@radix-ui_react-tooltip@1.2.8_2b23df507bdda662/vendor/@radix-ui/react-tooltip/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-use-is-hydrated@0.1.0_0ac650c021fb1b59/vendor/@radix-ui/react-use-is-hydrated/dist/index.js +0 -16
- package/dist/vendor/.bun/@radix-ui_react-use-is-hydrated@0.1.0_0ac650c021fb1b59/vendor/@radix-ui/react-use-is-hydrated/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-use-previous@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-previous/dist/index.js +0 -9
- package/dist/vendor/.bun/@radix-ui_react-use-previous@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-previous/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-use-size@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-size/dist/index.js +0 -28
- package/dist/vendor/.bun/@radix-ui_react-use-size@1.1.1_0ac650c021fb1b59/vendor/@radix-ui/react-use-size/dist/index.js.map +0 -1
- package/dist/vendor/.bun/@radix-ui_react-visually-hidden@1.2.3_2b23df507bdda662/vendor/@radix-ui/react-visually-hidden/dist/index.js +0 -33
- package/dist/vendor/.bun/@radix-ui_react-visually-hidden@1.2.3_2b23df507bdda662/vendor/@radix-ui/react-visually-hidden/dist/index.js.map +0 -1
- package/dist/vendor/.bun/sonner@2.0.7_6f4b9a1cfb20c0ae/vendor/sonner/dist/index.js +0 -747
- package/dist/vendor/.bun/sonner@2.0.7_6f4b9a1cfb20c0ae/vendor/sonner/dist/index.js.map +0 -1
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -68
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -56
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/shim/index.js +0 -11
- package/dist/vendor/.bun/use-sync-external-store@1.7.0_62547eec5a2188e3/vendor/use-sync-external-store/shim/index.js.map +0 -1
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry algorithm shared by `from-volt.ts` and `from-base-elements.ts`:
|
|
3
|
+
*
|
|
4
|
+
* 1. Find what the file imports from the legacy package (named imports, aliases resolved).
|
|
5
|
+
* 2. Run every registry rule that handles at least one of those names (or an imported module).
|
|
6
|
+
* 3. Rebuild the imports from the rules' decisions: moved names go onto the Zenith import, kept
|
|
7
|
+
* names stay on the legacy import with a TODO, names no rule claimed are kept with a generic
|
|
8
|
+
* TODO, dropped names vanish, and a default or namespace import is kept with a TODO.
|
|
9
|
+
* 4. Report every TODO as `<line> <Component>: <message>` and return the new source when the
|
|
10
|
+
* file changed.
|
|
11
|
+
*/
|
|
12
|
+
import type {
|
|
13
|
+
API,
|
|
14
|
+
ASTPath,
|
|
15
|
+
Collection,
|
|
16
|
+
FileInfo,
|
|
17
|
+
JSCodeshift,
|
|
18
|
+
ImportDeclaration,
|
|
19
|
+
ImportSpecifier,
|
|
20
|
+
Options,
|
|
21
|
+
} from "jscodeshift"
|
|
22
|
+
import {
|
|
23
|
+
addToZenithImport,
|
|
24
|
+
hoistLeadingComments,
|
|
25
|
+
importedNames,
|
|
26
|
+
isBoundAnywhere,
|
|
27
|
+
isFirstStatementAfterDirective,
|
|
28
|
+
programIfFirstStatement,
|
|
29
|
+
referenceSeesBinding,
|
|
30
|
+
isTopLevelBound,
|
|
31
|
+
localNames,
|
|
32
|
+
renameBinding,
|
|
33
|
+
valueUses,
|
|
34
|
+
type ImportedName,
|
|
35
|
+
type Moved,
|
|
36
|
+
} from "./imports"
|
|
37
|
+
import { makeJsxHelpers } from "./jsx"
|
|
38
|
+
import { detectQuote } from "./source"
|
|
39
|
+
import { attachTodoComment, formatReport, formatTodo, lineOf } from "./todo"
|
|
40
|
+
import {
|
|
41
|
+
ZENITH,
|
|
42
|
+
type MigrateContext,
|
|
43
|
+
type MigrationRule,
|
|
44
|
+
type TodoEntry,
|
|
45
|
+
} from "./types"
|
|
46
|
+
|
|
47
|
+
export type MigrationOptions = {
|
|
48
|
+
file: FileInfo
|
|
49
|
+
api: API
|
|
50
|
+
options: Options
|
|
51
|
+
/** The legacy package, e.g. `@epilot/base-elements`. */
|
|
52
|
+
source: string
|
|
53
|
+
rules: readonly MigrationRule[]
|
|
54
|
+
/** Message for a name no rule handles. Receives the name. */
|
|
55
|
+
unhandled?: (name: string) => string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function runMigration({
|
|
59
|
+
file,
|
|
60
|
+
api,
|
|
61
|
+
options,
|
|
62
|
+
source,
|
|
63
|
+
rules,
|
|
64
|
+
unhandled = () =>
|
|
65
|
+
`no Zenith rule; still imported from ${source} (migrate by hand or drop)`,
|
|
66
|
+
}: MigrationOptions): string | undefined {
|
|
67
|
+
void options
|
|
68
|
+
const j = api.jscodeshift
|
|
69
|
+
const root = j(file.source)
|
|
70
|
+
const quote = detectQuote(file.source)
|
|
71
|
+
const jsx = makeJsxHelpers(j)
|
|
72
|
+
|
|
73
|
+
const legacyImports = root.find(j.ImportDeclaration).filter((p) => {
|
|
74
|
+
const value = String(p.node.source.value)
|
|
75
|
+
return value === source || value.startsWith(`${source}/`)
|
|
76
|
+
})
|
|
77
|
+
const rulesByModule = new Map<string, MigrationRule>()
|
|
78
|
+
for (const rule of rules)
|
|
79
|
+
for (const m of rule.handlesModules ?? []) rulesByModule.set(m, rule)
|
|
80
|
+
const importsModule = (m: string) =>
|
|
81
|
+
root.find(j.ImportDeclaration, { source: { value: m } }).size() > 0
|
|
82
|
+
const hasRuleWork = rules.some((r) =>
|
|
83
|
+
(r.handlesModules ?? []).some(importsModule)
|
|
84
|
+
)
|
|
85
|
+
const otherReferences = findOtherReferences(j, root, source)
|
|
86
|
+
if (
|
|
87
|
+
legacyImports.size() === 0 &&
|
|
88
|
+
!hasRuleWork &&
|
|
89
|
+
otherReferences.length === 0
|
|
90
|
+
)
|
|
91
|
+
return undefined
|
|
92
|
+
|
|
93
|
+
const names = importedNames(j, root, source)
|
|
94
|
+
const byImported = new Map<string, ImportedName>()
|
|
95
|
+
for (const n of names) byImported.set(n.imported, n)
|
|
96
|
+
const ruleByName = new Map<string, MigrationRule>()
|
|
97
|
+
for (const rule of rules) {
|
|
98
|
+
for (const name of rule.handles) {
|
|
99
|
+
if (ruleByName.has(name))
|
|
100
|
+
throw new Error(`migrate: two rules handle ${name} for ${source}`)
|
|
101
|
+
ruleByName.set(name, rule)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const todos: TodoEntry[] = []
|
|
106
|
+
const moves = new Map<string, { module: string; target: string }>()
|
|
107
|
+
const keeps = new Map<string, string | undefined>()
|
|
108
|
+
const drops = new Set<string>()
|
|
109
|
+
const zenithNames = () => localNames(importedNames(j, root, ZENITH))
|
|
110
|
+
const removedDeclarations = new Set<ImportDeclaration>()
|
|
111
|
+
|
|
112
|
+
const ctx: MigrateContext = {
|
|
113
|
+
j,
|
|
114
|
+
root,
|
|
115
|
+
file,
|
|
116
|
+
source,
|
|
117
|
+
names: localNames(names),
|
|
118
|
+
get zenith() {
|
|
119
|
+
return zenithNames()
|
|
120
|
+
},
|
|
121
|
+
jsx,
|
|
122
|
+
move(name, target = name) {
|
|
123
|
+
ctx.moveTo(ZENITH, name, target)
|
|
124
|
+
},
|
|
125
|
+
moveTo(module, name, target = name) {
|
|
126
|
+
if (!byImported.has(name)) return
|
|
127
|
+
keeps.delete(name)
|
|
128
|
+
moves.set(name, { module, target })
|
|
129
|
+
},
|
|
130
|
+
keep(name, message) {
|
|
131
|
+
if (!byImported.has(name)) return
|
|
132
|
+
moves.delete(name)
|
|
133
|
+
keeps.set(name, message)
|
|
134
|
+
},
|
|
135
|
+
valueUses(name) {
|
|
136
|
+
const local = byImported.get(name)?.local
|
|
137
|
+
return local
|
|
138
|
+
? valueUses(j, root, local)
|
|
139
|
+
: (root.find(j.Identifier, { name: "\0" }) as never)
|
|
140
|
+
},
|
|
141
|
+
moveElements(name, target = name) {
|
|
142
|
+
const entry = byImported.get(name)
|
|
143
|
+
if (!entry) return undefined
|
|
144
|
+
const uses = valueUses(j, root, entry.local)
|
|
145
|
+
if (uses.size() === 0) {
|
|
146
|
+
ctx.move(name, target)
|
|
147
|
+
return entry.local
|
|
148
|
+
}
|
|
149
|
+
const local = ctx.ensureZenith(target)
|
|
150
|
+
ctx.elements(name).forEach((path) => jsx.rename(path.node, local))
|
|
151
|
+
uses.forEach((path) => {
|
|
152
|
+
let statement = (j(path).closest(j.Statement).paths()[0] ??
|
|
153
|
+
path) as ASTPath
|
|
154
|
+
const parentType = String(statement.parent?.node.type ?? "")
|
|
155
|
+
if (/^Export(Named|Default)Declaration$/.test(parentType))
|
|
156
|
+
statement = statement.parent
|
|
157
|
+
ctx.todo(
|
|
158
|
+
statement,
|
|
159
|
+
name,
|
|
160
|
+
`${j(path.parent.node as never).toSource()}: ${name} is used as a value here, so it stays on ${source}; ${target} from Zenith has a different API, migrate this use by hand`
|
|
161
|
+
)
|
|
162
|
+
})
|
|
163
|
+
ctx.keep(name)
|
|
164
|
+
return local
|
|
165
|
+
},
|
|
166
|
+
drop(name) {
|
|
167
|
+
if (!byImported.has(name)) return
|
|
168
|
+
moves.delete(name)
|
|
169
|
+
keeps.delete(name)
|
|
170
|
+
drops.add(name)
|
|
171
|
+
},
|
|
172
|
+
todo(path, component, message) {
|
|
173
|
+
todos.push({ line: lineOf(path), component, message })
|
|
174
|
+
attachTodoComment(j, path, formatTodo(component, message))
|
|
175
|
+
},
|
|
176
|
+
ensureZenith(name) {
|
|
177
|
+
const existing = zenithNames()[name]
|
|
178
|
+
if (existing) return existing
|
|
179
|
+
// A legacy import of the same name that another rule already moved onto Zenith's `name`
|
|
180
|
+
// becomes that binding; otherwise the name is taken and the alias is merged by the
|
|
181
|
+
// post-pass below if the move comes later.
|
|
182
|
+
const movedToSelf =
|
|
183
|
+
moves.get(name)?.module === ZENITH && moves.get(name)?.target === name
|
|
184
|
+
const local =
|
|
185
|
+
(isBoundAnywhere(j, root, name) || byImported.has(name)) && !movedToSelf
|
|
186
|
+
? `Zenith${name}`
|
|
187
|
+
: name
|
|
188
|
+
const anchor =
|
|
189
|
+
legacyImports.paths()[0] ?? root.find(j.ImportDeclaration).paths()[0]
|
|
190
|
+
if (anchor) {
|
|
191
|
+
const program = programIfFirstStatement(anchor)
|
|
192
|
+
const afterDirective = isFirstStatementAfterDirective(anchor)
|
|
193
|
+
const inserted = addToZenithImport(
|
|
194
|
+
j,
|
|
195
|
+
root,
|
|
196
|
+
ZENITH,
|
|
197
|
+
[{ imported: name, local, typeOnly: false }],
|
|
198
|
+
anchor,
|
|
199
|
+
quote
|
|
200
|
+
)
|
|
201
|
+
if (inserted.length && (program || afterDirective))
|
|
202
|
+
hoistLeadingComments(anchor.node, program ?? inserted[0])
|
|
203
|
+
} else {
|
|
204
|
+
root
|
|
205
|
+
.get()
|
|
206
|
+
.node.program.body.unshift(
|
|
207
|
+
j.importDeclaration(
|
|
208
|
+
[
|
|
209
|
+
j.importSpecifier(
|
|
210
|
+
j.identifier(name),
|
|
211
|
+
local === name ? null : j.identifier(local)
|
|
212
|
+
),
|
|
213
|
+
],
|
|
214
|
+
j.stringLiteral(ZENITH)
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
return local
|
|
219
|
+
},
|
|
220
|
+
elements(name) {
|
|
221
|
+
const local = byImported.get(name)?.local
|
|
222
|
+
return root
|
|
223
|
+
.find(j.JSXElement)
|
|
224
|
+
.filter((p) => !!local && jsx.tagName(p.node) === local) as never
|
|
225
|
+
},
|
|
226
|
+
imports(moduleSpecifier) {
|
|
227
|
+
return root.find(j.ImportDeclaration, {
|
|
228
|
+
source: { value: moduleSpecifier },
|
|
229
|
+
})
|
|
230
|
+
},
|
|
231
|
+
removeImport(path) {
|
|
232
|
+
removedDeclarations.add(path.node)
|
|
233
|
+
path.prune()
|
|
234
|
+
},
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// 2. Rules.
|
|
238
|
+
const ran = new Set<MigrationRule>()
|
|
239
|
+
for (const rule of rules) {
|
|
240
|
+
const wanted =
|
|
241
|
+
rule.handles.some((n) => byImported.has(n)) ||
|
|
242
|
+
(rule.handlesModules ?? []).some(importsModule)
|
|
243
|
+
if (!wanted || ran.has(rule)) continue
|
|
244
|
+
ran.add(rule)
|
|
245
|
+
rule.migrate(ctx)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// 3. Imports.
|
|
249
|
+
for (const n of names) {
|
|
250
|
+
if (drops.has(n.imported)) continue
|
|
251
|
+
if (moves.has(n.imported) || keeps.has(n.imported)) continue
|
|
252
|
+
keeps.set(n.imported, unhandled(n.imported))
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const declarations = root
|
|
256
|
+
.find(j.ImportDeclaration, { source: { value: source } })
|
|
257
|
+
.paths()
|
|
258
|
+
for (const declaration of declarations) {
|
|
259
|
+
if (removedDeclarations.has(declaration.node)) continue
|
|
260
|
+
const specifiers = declaration.node.specifiers ?? []
|
|
261
|
+
// The declaration's own comments, before any TODO is attached to it below.
|
|
262
|
+
const originalComments = [...(declaration.node.comments ?? [])]
|
|
263
|
+
const moved = new Map<string, Moved[]>()
|
|
264
|
+
const kept: typeof specifiers = []
|
|
265
|
+
for (const s of specifiers) {
|
|
266
|
+
if (s.type !== "ImportSpecifier") {
|
|
267
|
+
const kind =
|
|
268
|
+
s.type === "ImportDefaultSpecifier" ? "default" : "namespace"
|
|
269
|
+
const local = String(s.local?.name ?? "")
|
|
270
|
+
todos.push({
|
|
271
|
+
line: lineOf(declaration),
|
|
272
|
+
component: local,
|
|
273
|
+
message: `${kind} import of ${source}: import the named exports instead, then rerun`,
|
|
274
|
+
})
|
|
275
|
+
attachTodoComment(
|
|
276
|
+
j,
|
|
277
|
+
declaration,
|
|
278
|
+
formatTodo(
|
|
279
|
+
local,
|
|
280
|
+
`${kind} import of ${source}: import the named exports instead, then rerun`
|
|
281
|
+
)
|
|
282
|
+
)
|
|
283
|
+
kept.push(s)
|
|
284
|
+
continue
|
|
285
|
+
}
|
|
286
|
+
const entry = byImported.get(String(s.imported.name))!
|
|
287
|
+
if (drops.has(entry.imported)) continue
|
|
288
|
+
const move = moves.get(entry.imported)
|
|
289
|
+
if (move === undefined) {
|
|
290
|
+
kept.push(s)
|
|
291
|
+
const message = keeps.get(entry.imported)
|
|
292
|
+
if (message === undefined) continue
|
|
293
|
+
todos.push({
|
|
294
|
+
line: lineOf(declaration),
|
|
295
|
+
component: entry.imported,
|
|
296
|
+
message,
|
|
297
|
+
})
|
|
298
|
+
attachTodoComment(j, declaration, formatTodo(entry.imported, message))
|
|
299
|
+
continue
|
|
300
|
+
}
|
|
301
|
+
const { module, target } = move
|
|
302
|
+
const aliased = entry.local !== entry.imported
|
|
303
|
+
let local = entry.local
|
|
304
|
+
if (!aliased && target !== entry.local) {
|
|
305
|
+
// `target` is free when nothing binds it, when the module already imports it under its
|
|
306
|
+
// own name, or when the binding is a legacy specifier being moved to that same name (so
|
|
307
|
+
// after the rewrite both names are the one Zenith export).
|
|
308
|
+
const movedToSelf =
|
|
309
|
+
byImported.has(target) &&
|
|
310
|
+
moves.get(target)?.module === module &&
|
|
311
|
+
moves.get(target)?.target === target
|
|
312
|
+
const taken =
|
|
313
|
+
(isTopLevelBound(j, root, target) ||
|
|
314
|
+
referenceSeesBinding(j, root, entry.local, target)) &&
|
|
315
|
+
localNames(importedNames(j, root, module))[target] !== target &&
|
|
316
|
+
!movedToSelf
|
|
317
|
+
if (!taken) {
|
|
318
|
+
renameBinding(j, root, entry.local, target)
|
|
319
|
+
local = target
|
|
320
|
+
} else {
|
|
321
|
+
// Something in scope of a use is already called `target` (a prop, a local, another
|
|
322
|
+
// import): import under an alias so no use is captured.
|
|
323
|
+
const alias = `Zenith${target}`
|
|
324
|
+
if (
|
|
325
|
+
!isBoundAnywhere(j, root, alias) &&
|
|
326
|
+
!referenceSeesBinding(j, root, entry.local, alias)
|
|
327
|
+
) {
|
|
328
|
+
renameBinding(j, root, entry.local, alias)
|
|
329
|
+
local = alias
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const list = moved.get(module) ?? []
|
|
334
|
+
list.push({ imported: target, local, typeOnly: entry.typeOnly })
|
|
335
|
+
moved.set(module, list)
|
|
336
|
+
}
|
|
337
|
+
// Zenith first so it sits right above the legacy import; other modules follow it.
|
|
338
|
+
const modules = [...moved.keys()].sort((a, b) =>
|
|
339
|
+
a === ZENITH ? -1 : b === ZENITH ? 1 : a.localeCompare(b)
|
|
340
|
+
)
|
|
341
|
+
// Decided before the inserts below push the declaration down the body.
|
|
342
|
+
const program = programIfFirstStatement(declaration)
|
|
343
|
+
const afterDirective = isFirstStatementAfterDirective(declaration)
|
|
344
|
+
const inserted = modules.flatMap((module) =>
|
|
345
|
+
addToZenithImport(j, root, module, moved.get(module)!, declaration, quote)
|
|
346
|
+
)
|
|
347
|
+
if (program && (inserted.length || kept.length === 0)) {
|
|
348
|
+
// A file-leading comment stays at the top of the file.
|
|
349
|
+
hoistLeadingComments(declaration.node, program, originalComments)
|
|
350
|
+
} else if (afterDirective && inserted.length) {
|
|
351
|
+
// After `"use client"` the directive stays first; the comment heads the inserted import.
|
|
352
|
+
hoistLeadingComments(declaration.node, inserted[0], originalComments)
|
|
353
|
+
} else if (kept.length === 0) {
|
|
354
|
+
// A removed import's comments move to what now stands in its place.
|
|
355
|
+
const body = (declaration.parent.node as { body?: unknown[] }).body ?? []
|
|
356
|
+
const next = (inserted[0] ?? body[body.indexOf(declaration.node) + 1]) as
|
|
357
|
+
{ comments?: unknown[] | null } | undefined
|
|
358
|
+
if (next)
|
|
359
|
+
hoistLeadingComments(declaration.node, next as never, originalComments)
|
|
360
|
+
}
|
|
361
|
+
if (kept.length === 0) declaration.prune()
|
|
362
|
+
else declaration.node.specifiers = kept
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// `ensureZenith(X)` before another rule moved the legacy X onto Zenith's X leaves the Zenith
|
|
366
|
+
// import with both `X` and `X as ZenithX`: one export, two bindings. Merge them.
|
|
367
|
+
root
|
|
368
|
+
.find(j.ImportDeclaration, { source: { value: ZENITH } })
|
|
369
|
+
.forEach((declaration) => {
|
|
370
|
+
const specifiers = (declaration.node.specifiers ?? []).filter(
|
|
371
|
+
(s): s is ImportSpecifier => s.type === "ImportSpecifier"
|
|
372
|
+
)
|
|
373
|
+
const plain = new Set(
|
|
374
|
+
specifiers
|
|
375
|
+
.filter(
|
|
376
|
+
(s) =>
|
|
377
|
+
String(s.local?.name ?? s.imported.name) ===
|
|
378
|
+
String(s.imported.name)
|
|
379
|
+
)
|
|
380
|
+
.map((s) => String(s.imported.name))
|
|
381
|
+
)
|
|
382
|
+
const aliases = specifiers.filter(
|
|
383
|
+
(s) =>
|
|
384
|
+
String(s.local?.name) === `Zenith${String(s.imported.name)}` &&
|
|
385
|
+
plain.has(String(s.imported.name))
|
|
386
|
+
)
|
|
387
|
+
for (const alias of aliases) {
|
|
388
|
+
renameBinding(
|
|
389
|
+
j,
|
|
390
|
+
root,
|
|
391
|
+
String(alias.local?.name),
|
|
392
|
+
String(alias.imported.name)
|
|
393
|
+
)
|
|
394
|
+
declaration.node.specifiers = declaration.node.specifiers!.filter(
|
|
395
|
+
(s) => s !== alias
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
// Legacy references that are not import declarations: reported, never rewritten.
|
|
401
|
+
for (const { path, component, message } of otherReferences) {
|
|
402
|
+
todos.push({ line: lineOf(path), component, message })
|
|
403
|
+
attachTodoComment(j, path, formatTodo(component, message))
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Subpath imports a rule did not claim (rules may have pruned theirs, hence the re-find).
|
|
407
|
+
root.find(j.ImportDeclaration).forEach((p) => {
|
|
408
|
+
const value = String(p.node.source.value)
|
|
409
|
+
if (!value.startsWith(`${source}/`) || rulesByModule.has(value)) return
|
|
410
|
+
const message = `subpath import ${value}: no rule; import from ${source} or drop it`
|
|
411
|
+
todos.push({ line: lineOf(p), component: value, message })
|
|
412
|
+
attachTodoComment(j, p, formatTodo(value, message))
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
// 4. Report.
|
|
416
|
+
todos.sort((a, b) => a.line - b.line)
|
|
417
|
+
for (const t of todos) api.report(formatReport(t))
|
|
418
|
+
|
|
419
|
+
const output = applySemicolonStyle(root.toSource(), file.source)
|
|
420
|
+
return output === file.source ? undefined : output
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
type OtherReference = { path: ASTPath; component: string; message: string }
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* References to the legacy package outside `import` declarations: re-exports, dynamic imports,
|
|
427
|
+
* `require`, and test mocks. None has a safe rewrite; each gets a TODO with the fix.
|
|
428
|
+
*/
|
|
429
|
+
function findOtherReferences(
|
|
430
|
+
j: JSCodeshift,
|
|
431
|
+
root: Collection,
|
|
432
|
+
source: string
|
|
433
|
+
): OtherReference[] {
|
|
434
|
+
const found: OtherReference[] = []
|
|
435
|
+
const isLegacy = (value: unknown) =>
|
|
436
|
+
typeof value === "string" &&
|
|
437
|
+
(value === source || value.startsWith(`${source}/`))
|
|
438
|
+
const literalValue = (node: { type: string; value?: unknown } | undefined) =>
|
|
439
|
+
node && (node.type === "StringLiteral" || node.type === "Literal")
|
|
440
|
+
? node.value
|
|
441
|
+
: undefined
|
|
442
|
+
|
|
443
|
+
root.find(j.ExportNamedDeclaration).forEach((path) => {
|
|
444
|
+
const value = literalValue(path.node.source as never)
|
|
445
|
+
if (!isLegacy(value)) return
|
|
446
|
+
const names = (path.node.specifiers ?? [])
|
|
447
|
+
.map((s) => String((s as { exported: { name: string } }).exported.name))
|
|
448
|
+
.join(", ")
|
|
449
|
+
found.push({
|
|
450
|
+
path: path as ASTPath,
|
|
451
|
+
component: names || "re-export",
|
|
452
|
+
message: `re-exported from ${value}: migrate the files importing it to @epilot/zenith-react, then delete this re-export`,
|
|
453
|
+
})
|
|
454
|
+
})
|
|
455
|
+
root.find(j.ExportAllDeclaration).forEach((path) => {
|
|
456
|
+
const value = literalValue(path.node.source as never)
|
|
457
|
+
if (!isLegacy(value)) return
|
|
458
|
+
found.push({
|
|
459
|
+
path: path as ASTPath,
|
|
460
|
+
component: "export *",
|
|
461
|
+
message: `re-exports all of ${value}: migrate the files importing from here to @epilot/zenith-react, then delete this re-export`,
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
root.find(j.CallExpression).forEach((path) => {
|
|
465
|
+
const callee = path.node.callee as {
|
|
466
|
+
type: string
|
|
467
|
+
name?: string
|
|
468
|
+
object?: { type: string; name?: string }
|
|
469
|
+
property?: { type: string; name?: string }
|
|
470
|
+
}
|
|
471
|
+
const first = literalValue(path.node.arguments[0] as never)
|
|
472
|
+
if (!isLegacy(first)) return
|
|
473
|
+
const statement = (j(path).closest(j.Statement).paths()[0] ??
|
|
474
|
+
path) as ASTPath
|
|
475
|
+
if (callee.type === "Import") {
|
|
476
|
+
found.push({
|
|
477
|
+
path: statement,
|
|
478
|
+
component: "import()",
|
|
479
|
+
message: `dynamic import of ${first}: no rewrite; import the named exports from @epilot/zenith-react statically, or migrate the awaited names by hand`,
|
|
480
|
+
})
|
|
481
|
+
} else if (callee.type === "Identifier" && callee.name === "require") {
|
|
482
|
+
found.push({
|
|
483
|
+
path: statement,
|
|
484
|
+
component: "require",
|
|
485
|
+
message: `require of ${first}: no rewrite; import the named exports from @epilot/zenith-react`,
|
|
486
|
+
})
|
|
487
|
+
} else if (
|
|
488
|
+
callee.type === "MemberExpression" &&
|
|
489
|
+
callee.property?.type === "Identifier" &&
|
|
490
|
+
/^(mock|unmock|doMock|requireActual|requireMock|importActual)$/.test(
|
|
491
|
+
String(callee.property.name)
|
|
492
|
+
) &&
|
|
493
|
+
callee.object?.type === "Identifier" &&
|
|
494
|
+
/^(jest|vi)$/.test(String(callee.object.name))
|
|
495
|
+
) {
|
|
496
|
+
found.push({
|
|
497
|
+
path: statement,
|
|
498
|
+
component: `${callee.object.name}.${callee.property.name}`,
|
|
499
|
+
message: `test mock of ${first}: point it at @epilot/zenith-react once the code under test is migrated, or delete it`,
|
|
500
|
+
})
|
|
501
|
+
}
|
|
502
|
+
})
|
|
503
|
+
return found
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* recast prints every reprinted statement with a semicolon (a rebuilt import, a `return (…)`
|
|
508
|
+
* whose JSX changed) whatever the file does. In a file that writes none, strip the semicolon
|
|
509
|
+
* from the lines the migration produced; lines the file already had keep theirs.
|
|
510
|
+
*/
|
|
511
|
+
export function applySemicolonStyle(output: string, original: string): string {
|
|
512
|
+
const originalLines = original.split("\n")
|
|
513
|
+
const code = originalLines.filter((line) => line.trim() !== "")
|
|
514
|
+
if (code.length === 0) return output
|
|
515
|
+
const withSemicolon = code.filter((line) => /;[ \t]*$/.test(line)).length
|
|
516
|
+
// Prettier's `semi: false` leaves a file with (nearly) no line-ending semicolons; a file with
|
|
517
|
+
// 1 in 10 or more writes them and is left alone.
|
|
518
|
+
if (withSemicolon * 10 >= code.length) return output
|
|
519
|
+
const known = new Set(originalLines)
|
|
520
|
+
return output
|
|
521
|
+
.split("\n")
|
|
522
|
+
.map((line) =>
|
|
523
|
+
/;[ \t]*$/.test(line) && !known.has(line) && !/^\s*for\b/.test(line)
|
|
524
|
+
? line.replace(/;[ \t]*$/, "")
|
|
525
|
+
: line
|
|
526
|
+
)
|
|
527
|
+
.join("\n")
|
|
528
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Which quote the file prefers in its import declarations (ties go to double). */
|
|
2
|
+
export function detectQuote(source: string): "single" | "double" {
|
|
3
|
+
const singles = (source.match(/from\s+'[^']+'/g) ?? []).length
|
|
4
|
+
const doubles = (source.match(/from\s+"[^"]+"/g) ?? []).length
|
|
5
|
+
return singles > doubles ? "single" : "double"
|
|
6
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODO bookkeeping: one comment in the code and one report line per finding. Report lines are
|
|
3
|
+
* `<line> <Component>: <message>`; jscodeshift prefixes the file path (` REP <path> …`).
|
|
4
|
+
*/
|
|
5
|
+
import type { ASTPath, JSCodeshift } from "jscodeshift"
|
|
6
|
+
import { TODO_TAG, type TodoEntry } from "./types"
|
|
7
|
+
|
|
8
|
+
export function formatTodo(component: string, message: string): string {
|
|
9
|
+
return `${TODO_TAG}: ${component}: ${message}`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function formatReport(entry: TodoEntry): string {
|
|
13
|
+
return `${entry.line} ${entry.component}: ${entry.message}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Attaches the TODO comment where it is legal and nearest: a JSX comment sibling when the node
|
|
18
|
+
* sits among JSX children (walking up to the enclosing child when it is nested in an attribute),
|
|
19
|
+
* otherwise a leading block comment on the node itself (recast prints it before the node; for a
|
|
20
|
+
* JSX root the element's own line keeps the report's line number).
|
|
21
|
+
*/
|
|
22
|
+
export function attachTodoComment(
|
|
23
|
+
j: JSCodeshift,
|
|
24
|
+
path: ASTPath,
|
|
25
|
+
text: string
|
|
26
|
+
): void {
|
|
27
|
+
let current: ASTPath | null = path
|
|
28
|
+
while (current) {
|
|
29
|
+
const parent = current.parent?.node as { type?: string } | undefined
|
|
30
|
+
if (parent?.type === "JSXElement" || parent?.type === "JSXFragment") {
|
|
31
|
+
if (hasJsxSiblingComment(current, text)) return
|
|
32
|
+
const empty = j.jsxEmptyExpression()
|
|
33
|
+
;(empty as { comments?: unknown[] }).comments = [
|
|
34
|
+
j.commentBlock(` ${text} `, false, true),
|
|
35
|
+
]
|
|
36
|
+
current.insertBefore(j.jsxExpressionContainer(empty))
|
|
37
|
+
current.insertBefore(j.jsxText("\n"))
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (!parent || /Statement$|Declaration$/.test(String(current.node.type)))
|
|
41
|
+
break
|
|
42
|
+
const type = String(current.node.type)
|
|
43
|
+
if (!type.startsWith("JSX")) break
|
|
44
|
+
current = current.parent
|
|
45
|
+
}
|
|
46
|
+
// A declaration inside `export …` takes its comment on the export, not between the keywords.
|
|
47
|
+
const parentType = String(path.parent?.node?.type ?? "")
|
|
48
|
+
if (/^Export(Named|Default)Declaration$/.test(parentType)) path = path.parent
|
|
49
|
+
const node = path.node as {
|
|
50
|
+
type: string
|
|
51
|
+
comments?: unknown[]
|
|
52
|
+
openingElement?: { comments?: unknown[] }
|
|
53
|
+
}
|
|
54
|
+
const target =
|
|
55
|
+
node.type === "JSXElement" && node.openingElement
|
|
56
|
+
? node.openingElement
|
|
57
|
+
: node
|
|
58
|
+
if (hasComment(target.comments, text)) return
|
|
59
|
+
target.comments = [
|
|
60
|
+
...(target.comments ?? []),
|
|
61
|
+
j.commentBlock(` ${text} `, true, false),
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type CommentLike = { value?: string }
|
|
66
|
+
|
|
67
|
+
/** Reruns must not stack the same TODO twice: the comment is already there. */
|
|
68
|
+
export function hasComment(
|
|
69
|
+
comments: unknown[] | undefined,
|
|
70
|
+
text: string
|
|
71
|
+
): boolean {
|
|
72
|
+
return (comments ?? []).some((c) =>
|
|
73
|
+
String((c as CommentLike).value ?? "").includes(text)
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function hasJsxSiblingComment(path: ASTPath, text: string): boolean {
|
|
78
|
+
const siblings =
|
|
79
|
+
(
|
|
80
|
+
path.parent.node as {
|
|
81
|
+
children?: {
|
|
82
|
+
type: string
|
|
83
|
+
value?: string
|
|
84
|
+
expression?: { comments?: unknown[] }
|
|
85
|
+
}[]
|
|
86
|
+
}
|
|
87
|
+
).children ?? []
|
|
88
|
+
let index = siblings.indexOf(path.node as never) - 1
|
|
89
|
+
while (index >= 0) {
|
|
90
|
+
const sibling = siblings[index]
|
|
91
|
+
if (sibling.type === "JSXText" && !sibling.value?.trim()) {
|
|
92
|
+
index -= 1
|
|
93
|
+
continue
|
|
94
|
+
}
|
|
95
|
+
return (
|
|
96
|
+
sibling.type === "JSXExpressionContainer" &&
|
|
97
|
+
sibling.expression?.comments !== undefined &&
|
|
98
|
+
hasComment(sibling.expression.comments, text)
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
return false
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function lineOf(path: ASTPath): number {
|
|
105
|
+
const loc = (path.node as { loc?: { start: { line: number } } }).loc
|
|
106
|
+
return loc?.start.line ?? 0
|
|
107
|
+
}
|