@tendaui/react 1.2.4 → 1.3.1
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/es/_chunks/dep--nQ-cjme.js +45 -0
- package/es/_chunks/dep--nQ-cjme.js.map +1 -0
- package/es/_chunks/{dep-DTlQ2dCA.js → dep--qagmRQa.js} +2 -2
- package/es/_chunks/{dep-DTlQ2dCA.js.map → dep--qagmRQa.js.map} +1 -1
- package/es/_chunks/{dep-Dr5wkz0z.js → dep--svkhMCP.js} +12 -12
- package/es/_chunks/{dep-Dr5wkz0z.js.map → dep--svkhMCP.js.map} +1 -1
- package/es/_chunks/{dep-Bjfn7Zv_.js → dep-2HsCYcmp.js} +5 -5
- package/es/_chunks/{dep-Bjfn7Zv_.js.map → dep-2HsCYcmp.js.map} +1 -1
- package/es/_chunks/{dep-CkmtEv0Y.js → dep-B2D1svZy.js} +4 -2
- package/es/_chunks/dep-B2D1svZy.js.map +1 -0
- package/es/_chunks/{dep-BuIAffJt.js → dep-BI5F2D3y.js} +23 -13
- package/es/_chunks/dep-BI5F2D3y.js.map +1 -0
- package/es/_chunks/dep-BK4_iOSv.js +68 -0
- package/es/_chunks/dep-BK4_iOSv.js.map +1 -0
- package/es/_chunks/{dep-BYlJzn45.js → dep-BOj-ayw6.js} +26 -26
- package/es/_chunks/{dep-BYlJzn45.js.map → dep-BOj-ayw6.js.map} +1 -1
- package/es/_chunks/{dep-D68MD94M.js → dep-BZdpKjaa.js} +18 -18
- package/es/_chunks/{dep-D68MD94M.js.map → dep-BZdpKjaa.js.map} +1 -1
- package/es/_chunks/{dep-aX8qrQpB.js → dep-BbOvNxhg.js} +4 -4
- package/es/_chunks/{dep-aX8qrQpB.js.map → dep-BbOvNxhg.js.map} +1 -1
- package/es/_chunks/{dep-oUgTcXgm.js → dep-Blkje0_M.js} +2 -2
- package/es/_chunks/{dep-oUgTcXgm.js.map → dep-Blkje0_M.js.map} +1 -1
- package/es/_chunks/{dep-DJmE940f.js → dep-CHpQ3xhh.js} +2 -2
- package/es/_chunks/dep-CHpQ3xhh.js.map +1 -0
- package/es/_chunks/{dep-DX65P8M9.js → dep-CPjkUfQu.js} +2 -2
- package/es/_chunks/{dep-DX65P8M9.js.map → dep-CPjkUfQu.js.map} +1 -1
- package/es/_chunks/dep-CSzOEACo.js +165 -0
- package/es/_chunks/dep-CSzOEACo.js.map +1 -0
- package/es/_chunks/{dep-CJCt0IS0.js → dep-Cd1UOXnJ.js} +14 -14
- package/es/_chunks/{dep-CJCt0IS0.js.map → dep-Cd1UOXnJ.js.map} +1 -1
- package/es/_chunks/{dep-DQ6kXoi8.js → dep-DHWwZ2Nj.js} +2 -2
- package/es/_chunks/{dep-DQ6kXoi8.js.map → dep-DHWwZ2Nj.js.map} +1 -1
- package/es/_chunks/{dep-Tshfumgl.js → dep-DYFbjXzW.js} +2 -2
- package/es/_chunks/{dep-Tshfumgl.js.map → dep-DYFbjXzW.js.map} +1 -1
- package/es/_chunks/{dep-C_wPqvpm.js → dep-D_qcGLah.js} +2 -2
- package/es/_chunks/{dep-C_wPqvpm.js.map → dep-D_qcGLah.js.map} +1 -1
- package/es/_chunks/{dep-CsSvR9wN.js → dep-DfsP8eqT.js} +21 -21
- package/es/_chunks/{dep-CsSvR9wN.js.map → dep-DfsP8eqT.js.map} +1 -1
- package/es/_chunks/dep-Dl5DFuGU.js +2001 -0
- package/es/_chunks/dep-Dl5DFuGU.js.map +1 -0
- package/es/_chunks/{dep-DURB9x8g.js → dep-Dnwq3YvL.js} +36 -21
- package/es/_chunks/dep-Dnwq3YvL.js.map +1 -0
- package/es/_chunks/{dep-B4_O1Vgv.js → dep-Dr3i7zFt.js} +12 -12
- package/es/_chunks/{dep-B4_O1Vgv.js.map → dep-Dr3i7zFt.js.map} +1 -1
- package/es/_chunks/{dep-CD_4-1Xb.js → dep-UHQn9biR.js} +5 -5
- package/es/_chunks/dep-UHQn9biR.js.map +1 -0
- package/es/_chunks/{dep-ByzdZjUR.js → dep-bWaVq_y3.js} +2 -2
- package/es/_chunks/{dep-ByzdZjUR.js.map → dep-bWaVq_y3.js.map} +1 -1
- package/es/_chunks/{dep-DwWrhxkd.js → dep-grkSd2UB.js} +3 -3
- package/es/_chunks/{dep-DwWrhxkd.js.map → dep-grkSd2UB.js.map} +1 -1
- package/es/_chunks/{dep-CMPsNAXF.js → dep-hCWFQAqL.js} +15 -9
- package/es/_chunks/dep-hCWFQAqL.js.map +1 -0
- package/es/_chunks/{dep-D6YxJv-F.js → dep-spxR0DG0.js} +3 -3
- package/es/_chunks/{dep-D6YxJv-F.js.map → dep-spxR0DG0.js.map} +1 -1
- package/es/_chunks/{dep-gy8uvBaS.js → dep-u1x3x6MJ.js} +2 -2
- package/es/_chunks/{dep-gy8uvBaS.js.map → dep-u1x3x6MJ.js.map} +1 -1
- package/es/alert/Alert.js +25 -24
- package/es/alert/Alert.js.map +1 -1
- package/es/alert/_example/base.js +27 -0
- package/es/alert/_example/base.js.map +1 -0
- package/es/alert/_example/collapse.js +14 -0
- package/es/alert/_example/collapse.js.map +1 -0
- package/es/alert/index.js +6 -5
- package/es/alert/index.js.map +1 -1
- package/es/badge/Badge.js +6 -5
- package/es/badge/Badge.js.map +1 -1
- package/es/badge/_example/base.js +11 -0
- package/es/badge/_example/base.js.map +1 -0
- package/es/badge/_example/count.js +38 -0
- package/es/badge/_example/count.js.map +1 -0
- package/es/badge/_example/custom-color.js +48 -0
- package/es/badge/_example/custom-color.js.map +1 -0
- package/es/badge/_example/dot.js +36 -0
- package/es/badge/_example/dot.js.map +1 -0
- package/es/badge/_example/max-count.js +37 -0
- package/es/badge/_example/max-count.js.map +1 -0
- package/es/badge/_example/offset.js +41 -0
- package/es/badge/_example/offset.js.map +1 -0
- package/es/badge/_example/shape.js +47 -0
- package/es/badge/_example/shape.js.map +1 -0
- package/es/badge/_example/show-zero.js +31 -0
- package/es/badge/_example/show-zero.js.map +1 -0
- package/es/badge/_example/size.js +54 -0
- package/es/badge/_example/size.js.map +1 -0
- package/es/badge/_example/standalone.js +27 -0
- package/es/badge/_example/standalone.js.map +1 -0
- package/es/badge/_example/text-count.js +32 -0
- package/es/badge/_example/text-count.js.map +1 -0
- package/es/badge/_example/with-button.js +33 -0
- package/es/badge/_example/with-button.js.map +1 -0
- package/es/badge/index.js +3 -2
- package/es/badge/index.js.map +1 -1
- package/es/button/Button.js +10 -9
- package/es/button/Button.js.map +1 -1
- package/es/button/__tests__/Button.test.js +54700 -0
- package/es/button/__tests__/Button.test.js.map +1 -0
- package/es/button/_example/base.js +3 -3
- package/es/button/_example/base.js.map +1 -1
- package/es/button/_example/block.js +26 -0
- package/es/button/_example/block.js.map +1 -0
- package/es/button/_example/disabled.js +32 -0
- package/es/button/_example/disabled.js.map +1 -0
- package/es/button/_example/ghost.js +28 -0
- package/es/button/_example/ghost.js.map +1 -0
- package/es/button/_example/icon.js +10 -10
- package/es/button/_example/icon.js.map +1 -1
- package/es/button/_example/link.js +24 -0
- package/es/button/_example/link.js.map +1 -0
- package/es/button/_example/loading.js +28 -0
- package/es/button/_example/loading.js.map +1 -0
- package/es/button/_example/shape.js +31 -0
- package/es/button/_example/shape.js.map +1 -0
- package/es/button/_example/size.js +25 -0
- package/es/button/_example/size.js.map +1 -0
- package/es/button/_example/suffix.js +23 -0
- package/es/button/_example/suffix.js.map +1 -0
- package/es/button/_example/theme.js +25 -0
- package/es/button/_example/theme.js.map +1 -0
- package/es/button/_example/variant-base.js +30 -0
- package/es/button/_example/variant-base.js.map +1 -0
- package/es/button/_example/variant-dashed.js +30 -0
- package/es/button/_example/variant-dashed.js.map +1 -0
- package/es/button/_example/variant-outline.js +30 -0
- package/es/button/_example/variant-outline.js.map +1 -0
- package/es/button/_example/variant-text.js +30 -0
- package/es/button/_example/variant-text.js.map +1 -0
- package/es/button/index.js +5 -4
- package/es/button/index.js.map +1 -1
- package/es/button/style/index.css +3 -3
- package/es/checkbox/Checkbox.js +6 -5
- package/es/checkbox/Checkbox.js.map +1 -1
- package/es/checkbox/CheckboxGroup.js +6 -5
- package/es/checkbox/CheckboxGroup.js.map +1 -1
- package/es/checkbox/_example/base.js +9 -0
- package/es/checkbox/_example/base.js.map +1 -0
- package/es/checkbox/_example/controlled.js +19 -0
- package/es/checkbox/_example/controlled.js.map +1 -0
- package/es/checkbox/_example/group-disabled.js +20 -0
- package/es/checkbox/_example/group-disabled.js.map +1 -0
- package/es/checkbox/_example/group-with-check-all.js +41 -0
- package/es/checkbox/_example/group-with-check-all.js.map +1 -0
- package/es/checkbox/_example/group-with-max.js +34 -0
- package/es/checkbox/_example/group-with-max.js.map +1 -0
- package/es/checkbox/_example/group-with-options.js +40 -0
- package/es/checkbox/_example/group-with-options.js.map +1 -0
- package/es/checkbox/_example/group.js +33 -0
- package/es/checkbox/_example/group.js.map +1 -0
- package/es/checkbox/_example/states.js +27 -0
- package/es/checkbox/_example/states.js.map +1 -0
- package/es/checkbox/index.js +6 -5
- package/es/checkbox/index.js.map +1 -1
- package/es/color-picker/ColorPickPanel.js +76 -12
- package/es/color-picker/ColorPickPanel.js.map +1 -1
- package/es/color-picker/ColorPicker.js +67 -18
- package/es/color-picker/ColorPicker.js.map +1 -1
- package/es/color-picker/_example/base.js +26 -0
- package/es/color-picker/_example/base.js.map +1 -0
- package/es/color-picker/_example/borderless.js +29 -0
- package/es/color-picker/_example/borderless.js.map +1 -0
- package/es/color-picker/_example/clearable.js +29 -0
- package/es/color-picker/_example/clearable.js.map +1 -0
- package/es/color-picker/_example/disabled.js +29 -0
- package/es/color-picker/_example/disabled.js.map +1 -0
- package/es/color-picker/_example/formats.js +79 -0
- package/es/color-picker/_example/formats.js.map +1 -0
- package/es/color-picker/_example/manual-input.js +91 -0
- package/es/color-picker/_example/manual-input.js.map +1 -0
- package/es/color-picker/_example/recent-colors.js +31 -0
- package/es/color-picker/_example/recent-colors.js.map +1 -0
- package/es/color-picker/_example/swatch-colors.js +27 -0
- package/es/color-picker/_example/swatch-colors.js.map +1 -0
- package/es/color-picker/_example/with-alpha.js +35 -0
- package/es/color-picker/_example/with-alpha.js.map +1 -0
- package/es/color-picker/components/panel/alpha.js +5 -4
- package/es/color-picker/components/panel/alpha.js.map +1 -1
- package/es/color-picker/components/panel/format/index.js +25 -23
- package/es/color-picker/components/panel/format/index.js.map +1 -1
- package/es/color-picker/components/panel/format/inputs.js +20 -18
- package/es/color-picker/components/panel/format/inputs.js.map +1 -1
- package/es/color-picker/components/panel/header.js +16 -14
- package/es/color-picker/components/panel/header.js.map +1 -1
- package/es/color-picker/components/panel/hue.js +5 -4
- package/es/color-picker/components/panel/hue.js.map +1 -1
- package/es/color-picker/components/panel/index.js +73 -9
- package/es/color-picker/components/panel/index.js.map +1 -1
- package/es/color-picker/components/panel/saturation.js +6 -5
- package/es/color-picker/components/panel/saturation.js.map +1 -1
- package/es/color-picker/components/panel/slider.js +9 -8
- package/es/color-picker/components/panel/slider.js.map +1 -1
- package/es/color-picker/components/panel/swatches.js +17 -16
- package/es/color-picker/components/panel/swatches.js.map +1 -1
- package/es/color-picker/components/trigger.js +58 -25
- package/es/color-picker/components/trigger.js.map +1 -1
- package/es/color-picker/index.js +63 -20
- package/es/color-picker/index.js.map +1 -1
- package/es/color-picker/utils/color-picker/index.js +4 -67
- package/es/color-picker/utils/color-picker/index.js.map +1 -1
- package/es/common/Check.js +11 -10
- package/es/common/Check.js.map +1 -1
- package/es/common/FakeArrow.js +6 -5
- package/es/common/FakeArrow.js.map +1 -1
- package/es/common/PluginContainer.js +4 -3
- package/es/common/PluginContainer.js.map +1 -1
- package/es/common/Portal.js +3 -2
- package/es/common/Portal.js.map +1 -1
- package/es/config-provider/ConfigContext.js +303 -4
- package/es/config-provider/ConfigContext.js.map +1 -1
- package/es/config-provider/ConfigProvider.js +17 -4
- package/es/config-provider/ConfigProvider.js.map +1 -1
- package/es/config-provider/index.js +2 -1
- package/es/config-provider/index.js.map +1 -1
- package/es/dialog/Dialog.js +19 -18
- package/es/dialog/Dialog.js.map +1 -1
- package/es/dialog/DialogCard.js +8 -7
- package/es/dialog/DialogCard.js.map +1 -1
- package/es/dialog/_example/base.js +32 -0
- package/es/dialog/_example/base.js.map +1 -0
- package/es/dialog/_example/confirm-loading.js +38 -0
- package/es/dialog/_example/confirm-loading.js.map +1 -0
- package/es/dialog/_example/custom-buttons.js +36 -0
- package/es/dialog/_example/custom-buttons.js.map +1 -0
- package/es/dialog/_example/full-screen.js +33 -0
- package/es/dialog/_example/full-screen.js.map +1 -0
- package/es/dialog/_example/hide-buttons.js +50 -0
- package/es/dialog/_example/hide-buttons.js.map +1 -0
- package/es/dialog/_example/modeless.js +30 -0
- package/es/dialog/_example/modeless.js.map +1 -0
- package/es/dialog/_example/placement.js +53 -0
- package/es/dialog/_example/placement.js.map +1 -0
- package/es/dialog/_example/plugin-example.js +81 -0
- package/es/dialog/_example/plugin-example.js.map +1 -0
- package/es/dialog/_example/themes.js +62 -0
- package/es/dialog/_example/themes.js.map +1 -0
- package/es/dialog/index.js +10 -9
- package/es/dialog/index.js.map +1 -1
- package/es/dialog/plugin.js +15 -14
- package/es/dialog/plugin.js.map +1 -1
- package/es/dialog/style/index.css +3 -3
- package/es/drawer/Drawer.js +46 -37
- package/es/drawer/Drawer.js.map +1 -1
- package/es/drawer/_example/custom-header-footer.js +78 -0
- package/es/drawer/_example/custom-header-footer.js.map +1 -0
- package/es/drawer/_example/default.js +61 -0
- package/es/drawer/_example/default.js.map +1 -0
- package/es/drawer/_example/events.js +81 -0
- package/es/drawer/_example/events.js.map +1 -0
- package/es/drawer/_example/no-footer.js +62 -0
- package/es/drawer/_example/no-footer.js.map +1 -0
- package/es/drawer/_example/no-overlay.js +62 -0
- package/es/drawer/_example/no-overlay.js.map +1 -0
- package/es/drawer/_example/placement.js +91 -0
- package/es/drawer/_example/placement.js.map +1 -0
- package/es/drawer/_example/size-draggable.js +65 -0
- package/es/drawer/_example/size-draggable.js.map +1 -0
- package/es/drawer/_example/size.js +96 -0
- package/es/drawer/_example/size.js.map +1 -0
- package/es/drawer/index.js +9 -8
- package/es/drawer/index.js.map +1 -1
- package/es/drawer/style/index.css +4 -4
- package/es/fireworks/Fireworks.js +7 -6
- package/es/fireworks/Fireworks.js.map +1 -1
- package/es/fireworks/index.js +3 -2
- package/es/fireworks/index.js.map +1 -1
- package/es/form/Form.js +26 -173
- package/es/form/Form.js.map +1 -1
- package/es/form/FormContext.js +5 -5
- package/es/form/FormContext.js.map +1 -1
- package/es/form/FormItem.js +12 -11
- package/es/form/FormItem.js.map +1 -1
- package/es/form/FormList.js +2 -2
- package/es/form/FormList.js.map +1 -1
- package/es/form/_example/complex.js +105 -0
- package/es/form/_example/complex.js.map +1 -0
- package/es/form/_example/default.js +87 -0
- package/es/form/_example/default.js.map +1 -0
- package/es/form/_example/disabled.js +40 -0
- package/es/form/_example/disabled.js.map +1 -0
- package/es/form/_example/form-list.js +122 -0
- package/es/form/_example/form-list.js.map +1 -0
- package/es/form/_example/inline-layout.js +32 -0
- package/es/form/_example/inline-layout.js.map +1 -0
- package/es/form/_example/label-align.js +73 -0
- package/es/form/_example/label-align.js.map +1 -0
- package/es/form/_example/methods.js +118 -0
- package/es/form/_example/methods.js.map +1 -0
- package/es/form/_example/validation.js +97 -0
- package/es/form/_example/validation.js.map +1 -0
- package/es/form/hooks/useFormItemStyle.js +5 -4
- package/es/form/hooks/useFormItemStyle.js.map +1 -1
- package/es/form/hooks/useInstance.js +5 -4
- package/es/form/hooks/useInstance.js.map +1 -1
- package/es/form/index.js +22 -17
- package/es/form/index.js.map +1 -1
- package/es/form/style/index.css +6 -6
- package/es/hooks/useDragSorter.js +4 -4
- package/es/hooks/useDragSorter.js.map +1 -1
- package/es/index.js +37 -30
- package/es/index.js.map +1 -1
- package/es/input/Input.js +165 -26
- package/es/input/Input.js.map +1 -1
- package/es/input/InputGroup.js +2 -2
- package/es/input/InputGroup.js.map +1 -1
- package/es/input/_example/auto-width.js +53 -0
- package/es/input/_example/auto-width.js.map +1 -0
- package/es/input/_example/borderless.js +52 -0
- package/es/input/_example/borderless.js.map +1 -0
- package/es/input/_example/clearable.js +54 -0
- package/es/input/_example/clearable.js.map +1 -0
- package/es/input/_example/default.js +37 -0
- package/es/input/_example/default.js.map +1 -0
- package/es/input/_example/disabled-readonly.js +48 -0
- package/es/input/_example/disabled-readonly.js.map +1 -0
- package/es/input/_example/events.js +87 -0
- package/es/input/_example/events.js.map +1 -0
- package/es/input/_example/group.js +47 -0
- package/es/input/_example/group.js.map +1 -0
- package/es/input/_example/label-suffix.js +48 -0
- package/es/input/_example/label-suffix.js.map +1 -0
- package/es/input/_example/max-length.js +44 -0
- package/es/input/_example/max-length.js.map +1 -0
- package/es/input/_example/password.js +43 -0
- package/es/input/_example/password.js.map +1 -0
- package/es/input/_example/sizes.js +47 -0
- package/es/input/_example/sizes.js.map +1 -0
- package/es/input/_example/status.js +55 -0
- package/es/input/_example/status.js.map +1 -0
- package/es/input/_example/text-align.js +50 -0
- package/es/input/_example/text-align.js.map +1 -0
- package/es/input/_example/with-icon.js +48 -0
- package/es/input/_example/with-icon.js.map +1 -0
- package/es/input/index.js +6 -5
- package/es/input/index.js.map +1 -1
- package/es/input/style/index.css +18 -9
- package/es/input-number/InputNumber.js +19 -18
- package/es/input-number/InputNumber.js.map +1 -1
- package/es/input-number/_example/align.js +88 -0
- package/es/input-number/_example/align.js.map +1 -0
- package/es/input-number/_example/auto-width.js +54 -0
- package/es/input-number/_example/auto-width.js.map +1 -0
- package/es/input-number/_example/default.js +55 -0
- package/es/input-number/_example/default.js.map +1 -0
- package/es/input-number/_example/events.js +103 -0
- package/es/input-number/_example/events.js.map +1 -0
- package/es/input-number/_example/format.js +94 -0
- package/es/input-number/_example/format.js.map +1 -0
- package/es/input-number/_example/large-number.js +81 -0
- package/es/input-number/_example/large-number.js.map +1 -0
- package/es/input-number/_example/min-max.js +70 -0
- package/es/input-number/_example/min-max.js.map +1 -0
- package/es/input-number/_example/sizes.js +128 -0
- package/es/input-number/_example/sizes.js.map +1 -0
- package/es/input-number/_example/status.js +175 -0
- package/es/input-number/_example/status.js.map +1 -0
- package/es/input-number/_example/step-and-decimal.js +70 -0
- package/es/input-number/_example/step-and-decimal.js.map +1 -0
- package/es/input-number/_example/themes.js +80 -0
- package/es/input-number/_example/themes.js.map +1 -0
- package/es/input-number/_example/with-suffix.js +74 -0
- package/es/input-number/_example/with-suffix.js.map +1 -0
- package/es/input-number/index.js +9 -8
- package/es/input-number/index.js.map +1 -1
- package/es/input-number/style/index.css +12 -12
- package/es/input-number/useInputNumber.js +5 -4
- package/es/input-number/useInputNumber.js.map +1 -1
- package/es/ip-input/IPInput.js +5 -4
- package/es/ip-input/IPInput.js.map +1 -1
- package/es/ip-input/_example/controlled.js +65 -0
- package/es/ip-input/_example/controlled.js.map +1 -0
- package/es/ip-input/_example/default.js +27 -0
- package/es/ip-input/_example/default.js.map +1 -0
- package/es/ip-input/_example/full-featured.js +48 -0
- package/es/ip-input/_example/full-featured.js.map +1 -0
- package/es/ip-input/_example/ipv6.js +47 -0
- package/es/ip-input/_example/ipv6.js.map +1 -0
- package/es/ip-input/_example/keyboard-navigation.js +46 -0
- package/es/ip-input/_example/keyboard-navigation.js.map +1 -0
- package/es/ip-input/_example/paste-demo.js +54 -0
- package/es/ip-input/_example/paste-demo.js.map +1 -0
- package/es/ip-input/_example/states.js +52 -0
- package/es/ip-input/_example/states.js.map +1 -0
- package/es/ip-input/_example/with-cidr.js +47 -0
- package/es/ip-input/_example/with-cidr.js.map +1 -0
- package/es/ip-input/index.js +5 -4
- package/es/ip-input/index.js.map +1 -1
- package/es/layout/Aside.js +5 -4
- package/es/layout/Aside.js.map +1 -1
- package/es/layout/Layout.js +10 -9
- package/es/layout/Layout.js.map +1 -1
- package/es/layout/_example/combine-left.js +68 -0
- package/es/layout/_example/combine-left.js.map +1 -0
- package/es/layout/_example/combine-right.js +68 -0
- package/es/layout/_example/combine-right.js.map +1 -0
- package/es/layout/_example/custom-aside-width.js +69 -0
- package/es/layout/_example/custom-aside-width.js.map +1 -0
- package/es/layout/_example/custom-height.js +59 -0
- package/es/layout/_example/custom-height.js.map +1 -0
- package/es/layout/_example/double-sidebar.js +72 -0
- package/es/layout/_example/double-sidebar.js.map +1 -0
- package/es/layout/_example/side-navigation-right.js +66 -0
- package/es/layout/_example/side-navigation-right.js.map +1 -0
- package/es/layout/_example/side-navigation.js +66 -0
- package/es/layout/_example/side-navigation.js.map +1 -0
- package/es/layout/_example/top-navigation.js +57 -0
- package/es/layout/_example/top-navigation.js.map +1 -0
- package/es/layout/index.js +4 -3
- package/es/layout/index.js.map +1 -1
- package/es/list/List.js +18 -17
- package/es/list/List.js.map +1 -1
- package/es/list/ListItem.js +7 -6
- package/es/list/ListItem.js.map +1 -1
- package/es/list/ListItemMeta.js +12 -11
- package/es/list/ListItemMeta.js.map +1 -1
- package/es/list/_example/async-loading.js +114 -0
- package/es/list/_example/async-loading.js.map +1 -0
- package/es/list/_example/default.js +62 -0
- package/es/list/_example/default.js.map +1 -0
- package/es/list/_example/header-footer.js +98 -0
- package/es/list/_example/header-footer.js.map +1 -0
- package/es/list/_example/multiline.js +66 -0
- package/es/list/_example/multiline.js.map +1 -0
- package/es/list/_example/scroll-loading.js +133 -0
- package/es/list/_example/scroll-loading.js.map +1 -0
- package/es/list/_example/sizes.js +94 -0
- package/es/list/_example/sizes.js.map +1 -0
- package/es/list/_example/split.js +93 -0
- package/es/list/_example/split.js.map +1 -0
- package/es/list/_example/stripe.js +68 -0
- package/es/list/_example/stripe.js.map +1 -0
- package/es/list/_example/virtual-scroll.js +97 -0
- package/es/list/_example/virtual-scroll.js.map +1 -0
- package/es/list/_example/with-image.js +72 -0
- package/es/list/_example/with-image.js.map +1 -0
- package/es/list/index.js +6 -5
- package/es/list/index.js.map +1 -1
- package/es/list/style/index.css +5 -5
- package/es/loading/Gradient.js +8 -7
- package/es/loading/Gradient.js.map +1 -1
- package/es/loading/Loading.js +14 -13
- package/es/loading/Loading.js.map +1 -1
- package/es/loading/_example/default.js +30 -0
- package/es/loading/_example/default.js.map +1 -0
- package/es/loading/_example/delay.js +70 -0
- package/es/loading/_example/delay.js.map +1 -0
- package/es/loading/_example/fullscreen.js +38 -0
- package/es/loading/_example/fullscreen.js.map +1 -0
- package/es/loading/_example/inherit-color.js +58 -0
- package/es/loading/_example/inherit-color.js.map +1 -0
- package/es/loading/_example/no-overlay.js +28 -0
- package/es/loading/_example/no-overlay.js.map +1 -0
- package/es/loading/_example/sizes.js +84 -0
- package/es/loading/_example/sizes.js.map +1 -0
- package/es/loading/_example/with-text.js +41 -0
- package/es/loading/_example/with-text.js.map +1 -0
- package/es/loading/_example/wrapper.js +41 -0
- package/es/loading/_example/wrapper.js.map +1 -0
- package/es/loading/index.js +4 -3
- package/es/loading/index.js.map +1 -1
- package/es/notification/NotifyContainer.js +7 -6
- package/es/notification/NotifyContainer.js.map +1 -1
- package/es/notification/NotifyContext.js +7 -6
- package/es/notification/NotifyContext.js.map +1 -1
- package/es/notification/NotifyItem.js +20 -19
- package/es/notification/NotifyItem.js.map +1 -1
- package/es/notification/_example/default.js +55 -0
- package/es/notification/_example/default.js.map +1 -0
- package/es/notification/_example/long-content.js +36 -0
- package/es/notification/_example/long-content.js.map +1 -0
- package/es/notification/_example/stacking.js +56 -0
- package/es/notification/_example/stacking.js.map +1 -0
- package/es/notification/_example/types.js +75 -0
- package/es/notification/_example/types.js.map +1 -0
- package/es/notification/_example/usage-example.js +68 -0
- package/es/notification/_example/usage-example.js.map +1 -0
- package/es/notification/index.js +3 -2
- package/es/notification/index.js.map +1 -1
- package/es/notification/style/index.css +4 -4
- package/es/popup/Popup.js +30 -17
- package/es/popup/Popup.js.map +1 -1
- package/es/popup/_example/controlled.js +55 -0
- package/es/popup/_example/controlled.js.map +1 -0
- package/es/popup/_example/custom-content.js +81 -0
- package/es/popup/_example/custom-content.js.map +1 -0
- package/es/popup/_example/default.js +24 -0
- package/es/popup/_example/default.js.map +1 -0
- package/es/popup/_example/delay.js +43 -0
- package/es/popup/_example/delay.js.map +1 -0
- package/es/popup/_example/disabled.js +35 -0
- package/es/popup/_example/disabled.js.map +1 -0
- package/es/popup/_example/no-arrow.js +32 -0
- package/es/popup/_example/no-arrow.js.map +1 -0
- package/es/popup/_example/placements.js +138 -0
- package/es/popup/_example/placements.js.map +1 -0
- package/es/popup/_example/triggers.js +49 -0
- package/es/popup/_example/triggers.js.map +1 -0
- package/es/popup/index.js +5 -4
- package/es/popup/index.js.map +1 -1
- package/es/radio/Radio.js +8 -7
- package/es/radio/Radio.js.map +1 -1
- package/es/radio/RadioGroup.js +8 -7
- package/es/radio/RadioGroup.js.map +1 -1
- package/es/radio/_example/allow-uncheck.js +37 -0
- package/es/radio/_example/allow-uncheck.js.map +1 -0
- package/es/radio/_example/button-style.js +79 -0
- package/es/radio/_example/button-style.js.map +1 -0
- package/es/radio/_example/controlled.js +19 -0
- package/es/radio/_example/controlled.js.map +1 -0
- package/es/radio/_example/default.js +16 -0
- package/es/radio/_example/default.js.map +1 -0
- package/es/radio/_example/group-disabled.js +34 -0
- package/es/radio/_example/group-disabled.js.map +1 -0
- package/es/radio/_example/group-with-options.js +40 -0
- package/es/radio/_example/group-with-options.js.map +1 -0
- package/es/radio/_example/group.js +33 -0
- package/es/radio/_example/group.js.map +1 -0
- package/es/radio/_example/sizes.js +57 -0
- package/es/radio/_example/sizes.js.map +1 -0
- package/es/radio/_example/states.js +25 -0
- package/es/radio/_example/states.js.map +1 -0
- package/es/radio/index.js +8 -7
- package/es/radio/index.js.map +1 -1
- package/es/select/Option.js +10 -9
- package/es/select/Option.js.map +1 -1
- package/es/select/OptionGroup.js +4 -3
- package/es/select/OptionGroup.js.map +1 -1
- package/es/select/PopupContent.js +5 -4
- package/es/select/PopupContent.js.map +1 -1
- package/es/select/Select.js +21 -20
- package/es/select/Select.js.map +1 -1
- package/es/select/_example/collapsed.js +55 -0
- package/es/select/_example/collapsed.js.map +1 -0
- package/es/select/_example/creatable.js +61 -0
- package/es/select/_example/creatable.js.map +1 -0
- package/es/select/_example/custom-content.js +41 -0
- package/es/select/_example/custom-content.js.map +1 -0
- package/es/select/_example/default.js +54 -0
- package/es/select/_example/default.js.map +1 -0
- package/es/select/_example/disabled.js +54 -0
- package/es/select/_example/disabled.js.map +1 -0
- package/es/select/_example/filterable.js +44 -0
- package/es/select/_example/filterable.js.map +1 -0
- package/es/select/_example/group-options.js +57 -0
- package/es/select/_example/group-options.js.map +1 -0
- package/es/select/_example/label-suffix.js +51 -0
- package/es/select/_example/label-suffix.js.map +1 -0
- package/es/select/_example/loading.js +45 -0
- package/es/select/_example/loading.js.map +1 -0
- package/es/select/_example/multiple.js +58 -0
- package/es/select/_example/multiple.js.map +1 -0
- package/es/select/_example/sizes.js +54 -0
- package/es/select/_example/sizes.js.map +1 -0
- package/es/select/_example/status.js +66 -0
- package/es/select/_example/status.js.map +1 -0
- package/es/select/index.js +12 -11
- package/es/select/index.js.map +1 -1
- package/es/select-input/SelectInput.js +14 -13
- package/es/select-input/SelectInput.js.map +1 -1
- package/es/select-input/hook/useMultiple.js +9 -8
- package/es/select-input/hook/useMultiple.js.map +1 -1
- package/es/select-input/hook/useSingle.js +9 -8
- package/es/select-input/hook/useSingle.js.map +1 -1
- package/es/select-input/index.js +8 -7
- package/es/select-input/index.js.map +1 -1
- package/es/slider/Slider.js +37 -27
- package/es/slider/Slider.js.map +1 -1
- package/es/slider/SliderHandleButton.js +3 -3
- package/es/slider/SliderHandleButton.js.map +1 -1
- package/es/slider/_example/custom-label.js +33 -0
- package/es/slider/_example/custom-label.js.map +1 -0
- package/es/slider/_example/default.js +33 -0
- package/es/slider/_example/default.js.map +1 -0
- package/es/slider/_example/disabled.js +38 -0
- package/es/slider/_example/disabled.js.map +1 -0
- package/es/slider/_example/marks.js +61 -0
- package/es/slider/_example/marks.js.map +1 -0
- package/es/slider/_example/range.js +30 -0
- package/es/slider/_example/range.js.map +1 -0
- package/es/slider/_example/step.js +31 -0
- package/es/slider/_example/step.js.map +1 -0
- package/es/slider/_example/vertical.js +67 -0
- package/es/slider/_example/vertical.js.map +1 -0
- package/es/slider/_example/with-input-number.js +55 -0
- package/es/slider/_example/with-input-number.js.map +1 -0
- package/es/slider/index.js +9 -8
- package/es/slider/index.js.map +1 -1
- package/es/slider/style/index.css +8 -8
- package/es/switch/Switch.js +13 -12
- package/es/switch/Switch.js.map +1 -1
- package/es/switch/_example/async-change.js +36 -0
- package/es/switch/_example/async-change.js.map +1 -0
- package/es/switch/_example/before-change.js +31 -0
- package/es/switch/_example/before-change.js.map +1 -0
- package/es/switch/_example/controlled.js +23 -0
- package/es/switch/_example/controlled.js.map +1 -0
- package/es/switch/_example/custom-value.js +50 -0
- package/es/switch/_example/custom-value.js.map +1 -0
- package/es/switch/_example/default.js +11 -0
- package/es/switch/_example/default.js.map +1 -0
- package/es/switch/_example/disabled.js +72 -0
- package/es/switch/_example/disabled.js.map +1 -0
- package/es/switch/_example/loading.js +44 -0
- package/es/switch/_example/loading.js.map +1 -0
- package/es/switch/_example/sizes.js +60 -0
- package/es/switch/_example/sizes.js.map +1 -0
- package/es/switch/_example/with-label.js +54 -0
- package/es/switch/_example/with-label.js.map +1 -0
- package/es/switch/index.js +6 -5
- package/es/switch/index.js.map +1 -1
- package/es/switch/style/index.css +56 -0
- package/es/tab/TabBar.js +8 -7
- package/es/tab/TabBar.js.map +1 -1
- package/es/tab/TabNav.js +12 -11
- package/es/tab/TabNav.js.map +1 -1
- package/es/tab/TabNavItem.js +11 -10
- package/es/tab/TabNavItem.js.map +1 -1
- package/es/tab/TabPanel.js +6 -4
- package/es/tab/TabPanel.js.map +1 -1
- package/es/tab/Tabs.js +20 -19
- package/es/tab/Tabs.js.map +1 -1
- package/es/tab/_example/addable.js +92 -0
- package/es/tab/_example/addable.js.map +1 -0
- package/es/tab/_example/card-theme.js +66 -0
- package/es/tab/_example/card-theme.js.map +1 -0
- package/es/tab/_example/default.js +65 -0
- package/es/tab/_example/default.js.map +1 -0
- package/es/tab/_example/disabled.js +99 -0
- package/es/tab/_example/disabled.js.map +1 -0
- package/es/tab/_example/lazy.js +73 -0
- package/es/tab/_example/lazy.js.map +1 -0
- package/es/tab/_example/placement.js +96 -0
- package/es/tab/_example/placement.js.map +1 -0
- package/es/tab/_example/removable.js +78 -0
- package/es/tab/_example/removable.js.map +1 -0
- package/es/tab/_example/sizes.js +85 -0
- package/es/tab/_example/sizes.js.map +1 -0
- package/es/tab/_example/with-action.js +71 -0
- package/es/tab/_example/with-action.js.map +1 -0
- package/es/tab/index.js +8 -7
- package/es/tab/index.js.map +1 -1
- package/es/tab/style/index.css +8 -8
- package/es/table/Cell.js +10 -11
- package/es/table/Cell.js.map +1 -1
- package/es/table/Ellipsis.js +77 -0
- package/es/table/Ellipsis.js.map +1 -0
- package/es/table/TBody.js +16 -13
- package/es/table/TBody.js.map +1 -1
- package/es/table/THead.js +7 -6
- package/es/table/THead.js.map +1 -1
- package/es/table/TR.js +9 -5
- package/es/table/TR.js.map +1 -1
- package/es/table/Table.js +14 -11
- package/es/table/Table.js.map +1 -1
- package/es/table/_example/alignment.js +96 -0
- package/es/table/_example/alignment.js.map +1 -0
- package/es/table/_example/auto-width.js +90 -0
- package/es/table/_example/auto-width.js.map +1 -0
- package/es/table/_example/bordered-stripe-hover.js +96 -0
- package/es/table/_example/bordered-stripe-hover.js.map +1 -0
- package/es/table/_example/bordered.js +94 -0
- package/es/table/_example/bordered.js.map +1 -0
- package/es/table/_example/cell-click.js +107 -0
- package/es/table/_example/cell-click.js.map +1 -0
- package/es/table/_example/complex.js +131 -0
- package/es/table/_example/complex.js.map +1 -0
- package/es/table/_example/custom-cell.js +115 -0
- package/es/table/_example/custom-cell.js.map +1 -0
- package/es/table/_example/custom-empty.js +64 -0
- package/es/table/_example/custom-empty.js.map +1 -0
- package/es/table/_example/custom-row-class-name.js +105 -0
- package/es/table/_example/custom-row-class-name.js.map +1 -0
- package/es/table/_example/default.js +93 -0
- package/es/table/_example/default.js.map +1 -0
- package/es/table/_example/ellipsis.js +96 -0
- package/es/table/_example/ellipsis.js.map +1 -0
- package/es/table/_example/empty.js +58 -0
- package/es/table/_example/empty.js.map +1 -0
- package/es/table/_example/fixed-width.js +98 -0
- package/es/table/_example/fixed-width.js.map +1 -0
- package/es/table/_example/hover.js +94 -0
- package/es/table/_example/hover.js.map +1 -0
- package/es/table/_example/row-click.js +100 -0
- package/es/table/_example/row-click.js.map +1 -0
- package/es/table/_example/sizes.js +111 -0
- package/es/table/_example/sizes.js.map +1 -0
- package/es/table/_example/stripe.js +94 -0
- package/es/table/_example/stripe.js.map +1 -0
- package/es/table/_example/vertical-align.js +110 -0
- package/es/table/_example/vertical-align.js.map +1 -0
- package/es/table/hooks/index.js +6 -5
- package/es/table/hooks/index.js.map +1 -1
- package/es/table/index.js +6 -3
- package/es/table/index.js.map +1 -1
- package/es/table/style/index.css +11 -10
- package/es/tag/Tag.js +8 -7
- package/es/tag/Tag.js.map +1 -1
- package/es/tag/_example/closable.js +43 -0
- package/es/tag/_example/closable.js.map +1 -0
- package/es/tag/_example/default.js +24 -0
- package/es/tag/_example/default.js.map +1 -0
- package/es/tag/_example/disabled.js +26 -0
- package/es/tag/_example/disabled.js.map +1 -0
- package/es/tag/_example/sizes.js +24 -0
- package/es/tag/_example/sizes.js.map +1 -0
- package/es/tag/_example/variants.js +49 -0
- package/es/tag/_example/variants.js.map +1 -0
- package/es/tag/index.js +4 -3
- package/es/tag/index.js.map +1 -1
- package/es/tag-input/TagInput.js +10 -9
- package/es/tag-input/TagInput.js.map +1 -1
- package/es/tag-input/_example/collapsed.js +39 -0
- package/es/tag-input/_example/collapsed.js.map +1 -0
- package/es/tag-input/_example/controlled-uncontrolled.js +47 -0
- package/es/tag-input/_example/controlled-uncontrolled.js.map +1 -0
- package/es/tag-input/_example/default.js +31 -0
- package/es/tag-input/_example/default.js.map +1 -0
- package/es/tag-input/_example/disabled-readonly.js +50 -0
- package/es/tag-input/_example/disabled-readonly.js.map +1 -0
- package/es/tag-input/_example/events.js +84 -0
- package/es/tag-input/_example/events.js.map +1 -0
- package/es/tag-input/_example/excess-display.js +40 -0
- package/es/tag-input/_example/excess-display.js.map +1 -0
- package/es/tag-input/_example/max-tags.js +36 -0
- package/es/tag-input/_example/max-tags.js.map +1 -0
- package/es/tag-input/_example/sizes.js +51 -0
- package/es/tag-input/_example/sizes.js.map +1 -0
- package/es/tag-input/_example/status.js +49 -0
- package/es/tag-input/_example/status.js.map +1 -0
- package/es/tag-input/_example/with-label.js +31 -0
- package/es/tag-input/_example/with-label.js.map +1 -0
- package/es/tag-input/hooks/useTagList.js +11 -10
- package/es/tag-input/hooks/useTagList.js.map +1 -1
- package/es/tag-input/index.js +7 -6
- package/es/tag-input/index.js.map +1 -1
- package/es/tag-input/useTagList.js +11 -10
- package/es/tag-input/useTagList.js.map +1 -1
- package/es/tooltip/Tooltip.js +100 -0
- package/es/tooltip/Tooltip.js.map +1 -0
- package/es/tooltip/_example/base.js +32 -0
- package/es/tooltip/_example/base.js.map +1 -0
- package/es/tooltip/_example/custom-content.js +62 -0
- package/es/tooltip/_example/custom-content.js.map +1 -0
- package/es/tooltip/_example/placement.js +31 -0
- package/es/tooltip/_example/placement.js.map +1 -0
- package/es/tooltip/_example/theme.js +47 -0
- package/es/tooltip/_example/theme.js.map +1 -0
- package/es/tooltip/index.js +36 -0
- package/es/tooltip/index.js.map +1 -0
- package/es/tooltip/style/index.css +59 -0
- package/es/tooltip/style/index.js +2 -0
- package/es/tooltip/style/index.js.map +1 -0
- package/es/utils/log/index.js.map +1 -1
- package/package.json +3 -3
- package/es/_chunks/dep-5U9UjDaf.js +0 -345
- package/es/_chunks/dep-5U9UjDaf.js.map +0 -1
- package/es/_chunks/dep-BuIAffJt.js.map +0 -1
- package/es/_chunks/dep-CD_4-1Xb.js.map +0 -1
- package/es/_chunks/dep-CMPsNAXF.js.map +0 -1
- package/es/_chunks/dep-CkmtEv0Y.js.map +0 -1
- package/es/_chunks/dep-DJmE940f.js.map +0 -1
- package/es/_chunks/dep-DURB9x8g.js.map +0 -1
|
@@ -0,0 +1,2001 @@
|
|
|
1
|
+
// src/vlq.ts
|
|
2
|
+
var comma = ",".charCodeAt(0);
|
|
3
|
+
var semicolon = ";".charCodeAt(0);
|
|
4
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
5
|
+
var intToChar = new Uint8Array(64);
|
|
6
|
+
var charToInt = new Uint8Array(128);
|
|
7
|
+
for (let i = 0; i < chars.length; i++) {
|
|
8
|
+
const c = chars.charCodeAt(i);
|
|
9
|
+
intToChar[i] = c;
|
|
10
|
+
charToInt[c] = i;
|
|
11
|
+
}
|
|
12
|
+
function decodeInteger(reader, relative) {
|
|
13
|
+
let value = 0;
|
|
14
|
+
let shift = 0;
|
|
15
|
+
let integer = 0;
|
|
16
|
+
do {
|
|
17
|
+
const c = reader.next();
|
|
18
|
+
integer = charToInt[c];
|
|
19
|
+
value |= (integer & 31) << shift;
|
|
20
|
+
shift += 5;
|
|
21
|
+
} while (integer & 32);
|
|
22
|
+
const shouldNegate = value & 1;
|
|
23
|
+
value >>>= 1;
|
|
24
|
+
if (shouldNegate) {
|
|
25
|
+
value = -2147483648 | -value;
|
|
26
|
+
}
|
|
27
|
+
return relative + value;
|
|
28
|
+
}
|
|
29
|
+
function encodeInteger(builder, num, relative) {
|
|
30
|
+
let delta = num - relative;
|
|
31
|
+
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
32
|
+
do {
|
|
33
|
+
let clamped = delta & 31;
|
|
34
|
+
delta >>>= 5;
|
|
35
|
+
if (delta > 0) clamped |= 32;
|
|
36
|
+
builder.write(intToChar[clamped]);
|
|
37
|
+
} while (delta > 0);
|
|
38
|
+
return num;
|
|
39
|
+
}
|
|
40
|
+
function hasMoreVlq(reader, max) {
|
|
41
|
+
if (reader.pos >= max) return false;
|
|
42
|
+
return reader.peek() !== comma;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/strings.ts
|
|
46
|
+
var bufLength = 1024 * 16;
|
|
47
|
+
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
|
48
|
+
decode(buf) {
|
|
49
|
+
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
50
|
+
return out.toString();
|
|
51
|
+
}
|
|
52
|
+
} : {
|
|
53
|
+
decode(buf) {
|
|
54
|
+
let out = "";
|
|
55
|
+
for (let i = 0; i < buf.length; i++) {
|
|
56
|
+
out += String.fromCharCode(buf[i]);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var StringWriter = class {
|
|
62
|
+
constructor() {
|
|
63
|
+
this.pos = 0;
|
|
64
|
+
this.out = "";
|
|
65
|
+
this.buffer = new Uint8Array(bufLength);
|
|
66
|
+
}
|
|
67
|
+
write(v) {
|
|
68
|
+
const { buffer } = this;
|
|
69
|
+
buffer[this.pos++] = v;
|
|
70
|
+
if (this.pos === bufLength) {
|
|
71
|
+
this.out += td.decode(buffer);
|
|
72
|
+
this.pos = 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
flush() {
|
|
76
|
+
const { buffer, out, pos } = this;
|
|
77
|
+
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var StringReader = class {
|
|
81
|
+
constructor(buffer) {
|
|
82
|
+
this.pos = 0;
|
|
83
|
+
this.buffer = buffer;
|
|
84
|
+
}
|
|
85
|
+
next() {
|
|
86
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
87
|
+
}
|
|
88
|
+
peek() {
|
|
89
|
+
return this.buffer.charCodeAt(this.pos);
|
|
90
|
+
}
|
|
91
|
+
indexOf(char) {
|
|
92
|
+
const { buffer, pos } = this;
|
|
93
|
+
const idx = buffer.indexOf(char, pos);
|
|
94
|
+
return idx === -1 ? buffer.length : idx;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/scopes.ts
|
|
99
|
+
var EMPTY = [];
|
|
100
|
+
function decodeOriginalScopes(input) {
|
|
101
|
+
const { length } = input;
|
|
102
|
+
const reader = new StringReader(input);
|
|
103
|
+
const scopes = [];
|
|
104
|
+
const stack = [];
|
|
105
|
+
let line = 0;
|
|
106
|
+
for (; reader.pos < length; reader.pos++) {
|
|
107
|
+
line = decodeInteger(reader, line);
|
|
108
|
+
const column = decodeInteger(reader, 0);
|
|
109
|
+
if (!hasMoreVlq(reader, length)) {
|
|
110
|
+
const last = stack.pop();
|
|
111
|
+
last[2] = line;
|
|
112
|
+
last[3] = column;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const kind = decodeInteger(reader, 0);
|
|
116
|
+
const fields = decodeInteger(reader, 0);
|
|
117
|
+
const hasName = fields & 1;
|
|
118
|
+
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
|
119
|
+
let vars = EMPTY;
|
|
120
|
+
if (hasMoreVlq(reader, length)) {
|
|
121
|
+
vars = [];
|
|
122
|
+
do {
|
|
123
|
+
const varsIndex = decodeInteger(reader, 0);
|
|
124
|
+
vars.push(varsIndex);
|
|
125
|
+
} while (hasMoreVlq(reader, length));
|
|
126
|
+
}
|
|
127
|
+
scope.vars = vars;
|
|
128
|
+
scopes.push(scope);
|
|
129
|
+
stack.push(scope);
|
|
130
|
+
}
|
|
131
|
+
return scopes;
|
|
132
|
+
}
|
|
133
|
+
function encodeOriginalScopes(scopes) {
|
|
134
|
+
const writer = new StringWriter();
|
|
135
|
+
for (let i = 0; i < scopes.length; ) {
|
|
136
|
+
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
|
137
|
+
}
|
|
138
|
+
return writer.flush();
|
|
139
|
+
}
|
|
140
|
+
function _encodeOriginalScopes(scopes, index, writer, state) {
|
|
141
|
+
const scope = scopes[index];
|
|
142
|
+
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
|
143
|
+
if (index > 0) writer.write(comma);
|
|
144
|
+
state[0] = encodeInteger(writer, startLine, state[0]);
|
|
145
|
+
encodeInteger(writer, startColumn, 0);
|
|
146
|
+
encodeInteger(writer, kind, 0);
|
|
147
|
+
const fields = scope.length === 6 ? 1 : 0;
|
|
148
|
+
encodeInteger(writer, fields, 0);
|
|
149
|
+
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
|
150
|
+
for (const v of vars) {
|
|
151
|
+
encodeInteger(writer, v, 0);
|
|
152
|
+
}
|
|
153
|
+
for (index++; index < scopes.length; ) {
|
|
154
|
+
const next = scopes[index];
|
|
155
|
+
const { 0: l, 1: c } = next;
|
|
156
|
+
if (l > endLine || l === endLine && c >= endColumn) {
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
index = _encodeOriginalScopes(scopes, index, writer, state);
|
|
160
|
+
}
|
|
161
|
+
writer.write(comma);
|
|
162
|
+
state[0] = encodeInteger(writer, endLine, state[0]);
|
|
163
|
+
encodeInteger(writer, endColumn, 0);
|
|
164
|
+
return index;
|
|
165
|
+
}
|
|
166
|
+
function decodeGeneratedRanges(input) {
|
|
167
|
+
const { length } = input;
|
|
168
|
+
const reader = new StringReader(input);
|
|
169
|
+
const ranges = [];
|
|
170
|
+
const stack = [];
|
|
171
|
+
let genLine = 0;
|
|
172
|
+
let definitionSourcesIndex = 0;
|
|
173
|
+
let definitionScopeIndex = 0;
|
|
174
|
+
let callsiteSourcesIndex = 0;
|
|
175
|
+
let callsiteLine = 0;
|
|
176
|
+
let callsiteColumn = 0;
|
|
177
|
+
let bindingLine = 0;
|
|
178
|
+
let bindingColumn = 0;
|
|
179
|
+
do {
|
|
180
|
+
const semi = reader.indexOf(";");
|
|
181
|
+
let genColumn = 0;
|
|
182
|
+
for (; reader.pos < semi; reader.pos++) {
|
|
183
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
184
|
+
if (!hasMoreVlq(reader, semi)) {
|
|
185
|
+
const last = stack.pop();
|
|
186
|
+
last[2] = genLine;
|
|
187
|
+
last[3] = genColumn;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const fields = decodeInteger(reader, 0);
|
|
191
|
+
const hasDefinition = fields & 1;
|
|
192
|
+
const hasCallsite = fields & 2;
|
|
193
|
+
const hasScope = fields & 4;
|
|
194
|
+
let callsite = null;
|
|
195
|
+
let bindings = EMPTY;
|
|
196
|
+
let range;
|
|
197
|
+
if (hasDefinition) {
|
|
198
|
+
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
|
199
|
+
definitionScopeIndex = decodeInteger(
|
|
200
|
+
reader,
|
|
201
|
+
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
|
|
202
|
+
);
|
|
203
|
+
definitionSourcesIndex = defSourcesIndex;
|
|
204
|
+
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
|
|
205
|
+
} else {
|
|
206
|
+
range = [genLine, genColumn, 0, 0];
|
|
207
|
+
}
|
|
208
|
+
range.isScope = !!hasScope;
|
|
209
|
+
if (hasCallsite) {
|
|
210
|
+
const prevCsi = callsiteSourcesIndex;
|
|
211
|
+
const prevLine = callsiteLine;
|
|
212
|
+
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
|
213
|
+
const sameSource = prevCsi === callsiteSourcesIndex;
|
|
214
|
+
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
|
215
|
+
callsiteColumn = decodeInteger(
|
|
216
|
+
reader,
|
|
217
|
+
sameSource && prevLine === callsiteLine ? callsiteColumn : 0
|
|
218
|
+
);
|
|
219
|
+
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
|
220
|
+
}
|
|
221
|
+
range.callsite = callsite;
|
|
222
|
+
if (hasMoreVlq(reader, semi)) {
|
|
223
|
+
bindings = [];
|
|
224
|
+
do {
|
|
225
|
+
bindingLine = genLine;
|
|
226
|
+
bindingColumn = genColumn;
|
|
227
|
+
const expressionsCount = decodeInteger(reader, 0);
|
|
228
|
+
let expressionRanges;
|
|
229
|
+
if (expressionsCount < -1) {
|
|
230
|
+
expressionRanges = [[decodeInteger(reader, 0)]];
|
|
231
|
+
for (let i = -1; i > expressionsCount; i--) {
|
|
232
|
+
const prevBl = bindingLine;
|
|
233
|
+
bindingLine = decodeInteger(reader, bindingLine);
|
|
234
|
+
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
|
235
|
+
const expression = decodeInteger(reader, 0);
|
|
236
|
+
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
expressionRanges = [[expressionsCount]];
|
|
240
|
+
}
|
|
241
|
+
bindings.push(expressionRanges);
|
|
242
|
+
} while (hasMoreVlq(reader, semi));
|
|
243
|
+
}
|
|
244
|
+
range.bindings = bindings;
|
|
245
|
+
ranges.push(range);
|
|
246
|
+
stack.push(range);
|
|
247
|
+
}
|
|
248
|
+
genLine++;
|
|
249
|
+
reader.pos = semi + 1;
|
|
250
|
+
} while (reader.pos < length);
|
|
251
|
+
return ranges;
|
|
252
|
+
}
|
|
253
|
+
function encodeGeneratedRanges(ranges) {
|
|
254
|
+
if (ranges.length === 0) return "";
|
|
255
|
+
const writer = new StringWriter();
|
|
256
|
+
for (let i = 0; i < ranges.length; ) {
|
|
257
|
+
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
|
258
|
+
}
|
|
259
|
+
return writer.flush();
|
|
260
|
+
}
|
|
261
|
+
function _encodeGeneratedRanges(ranges, index, writer, state) {
|
|
262
|
+
const range = ranges[index];
|
|
263
|
+
const {
|
|
264
|
+
0: startLine,
|
|
265
|
+
1: startColumn,
|
|
266
|
+
2: endLine,
|
|
267
|
+
3: endColumn,
|
|
268
|
+
isScope,
|
|
269
|
+
callsite,
|
|
270
|
+
bindings
|
|
271
|
+
} = range;
|
|
272
|
+
if (state[0] < startLine) {
|
|
273
|
+
catchupLine(writer, state[0], startLine);
|
|
274
|
+
state[0] = startLine;
|
|
275
|
+
state[1] = 0;
|
|
276
|
+
} else if (index > 0) {
|
|
277
|
+
writer.write(comma);
|
|
278
|
+
}
|
|
279
|
+
state[1] = encodeInteger(writer, range[1], state[1]);
|
|
280
|
+
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
|
281
|
+
encodeInteger(writer, fields, 0);
|
|
282
|
+
if (range.length === 6) {
|
|
283
|
+
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
|
284
|
+
if (sourcesIndex !== state[2]) {
|
|
285
|
+
state[3] = 0;
|
|
286
|
+
}
|
|
287
|
+
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
|
288
|
+
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
|
289
|
+
}
|
|
290
|
+
if (callsite) {
|
|
291
|
+
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
|
292
|
+
if (sourcesIndex !== state[4]) {
|
|
293
|
+
state[5] = 0;
|
|
294
|
+
state[6] = 0;
|
|
295
|
+
} else if (callLine !== state[5]) {
|
|
296
|
+
state[6] = 0;
|
|
297
|
+
}
|
|
298
|
+
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
|
299
|
+
state[5] = encodeInteger(writer, callLine, state[5]);
|
|
300
|
+
state[6] = encodeInteger(writer, callColumn, state[6]);
|
|
301
|
+
}
|
|
302
|
+
if (bindings) {
|
|
303
|
+
for (const binding of bindings) {
|
|
304
|
+
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
|
305
|
+
const expression = binding[0][0];
|
|
306
|
+
encodeInteger(writer, expression, 0);
|
|
307
|
+
let bindingStartLine = startLine;
|
|
308
|
+
let bindingStartColumn = startColumn;
|
|
309
|
+
for (let i = 1; i < binding.length; i++) {
|
|
310
|
+
const expRange = binding[i];
|
|
311
|
+
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
|
312
|
+
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
|
313
|
+
encodeInteger(writer, expRange[0], 0);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
for (index++; index < ranges.length; ) {
|
|
318
|
+
const next = ranges[index];
|
|
319
|
+
const { 0: l, 1: c } = next;
|
|
320
|
+
if (l > endLine || l === endLine && c >= endColumn) {
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
|
324
|
+
}
|
|
325
|
+
if (state[0] < endLine) {
|
|
326
|
+
catchupLine(writer, state[0], endLine);
|
|
327
|
+
state[0] = endLine;
|
|
328
|
+
state[1] = 0;
|
|
329
|
+
} else {
|
|
330
|
+
writer.write(comma);
|
|
331
|
+
}
|
|
332
|
+
state[1] = encodeInteger(writer, endColumn, state[1]);
|
|
333
|
+
return index;
|
|
334
|
+
}
|
|
335
|
+
function catchupLine(writer, lastLine, line) {
|
|
336
|
+
do {
|
|
337
|
+
writer.write(semicolon);
|
|
338
|
+
} while (++lastLine < line);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/sourcemap-codec.ts
|
|
342
|
+
function decode(mappings) {
|
|
343
|
+
const { length } = mappings;
|
|
344
|
+
const reader = new StringReader(mappings);
|
|
345
|
+
const decoded = [];
|
|
346
|
+
let genColumn = 0;
|
|
347
|
+
let sourcesIndex = 0;
|
|
348
|
+
let sourceLine = 0;
|
|
349
|
+
let sourceColumn = 0;
|
|
350
|
+
let namesIndex = 0;
|
|
351
|
+
do {
|
|
352
|
+
const semi = reader.indexOf(";");
|
|
353
|
+
const line = [];
|
|
354
|
+
let sorted = true;
|
|
355
|
+
let lastCol = 0;
|
|
356
|
+
genColumn = 0;
|
|
357
|
+
while (reader.pos < semi) {
|
|
358
|
+
let seg;
|
|
359
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
360
|
+
if (genColumn < lastCol) sorted = false;
|
|
361
|
+
lastCol = genColumn;
|
|
362
|
+
if (hasMoreVlq(reader, semi)) {
|
|
363
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
364
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
365
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
366
|
+
if (hasMoreVlq(reader, semi)) {
|
|
367
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
368
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
369
|
+
} else {
|
|
370
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
371
|
+
}
|
|
372
|
+
} else {
|
|
373
|
+
seg = [genColumn];
|
|
374
|
+
}
|
|
375
|
+
line.push(seg);
|
|
376
|
+
reader.pos++;
|
|
377
|
+
}
|
|
378
|
+
if (!sorted) sort(line);
|
|
379
|
+
decoded.push(line);
|
|
380
|
+
reader.pos = semi + 1;
|
|
381
|
+
} while (reader.pos <= length);
|
|
382
|
+
return decoded;
|
|
383
|
+
}
|
|
384
|
+
function sort(line) {
|
|
385
|
+
line.sort(sortComparator);
|
|
386
|
+
}
|
|
387
|
+
function sortComparator(a, b) {
|
|
388
|
+
return a[0] - b[0];
|
|
389
|
+
}
|
|
390
|
+
function encode(decoded) {
|
|
391
|
+
const writer = new StringWriter();
|
|
392
|
+
let sourcesIndex = 0;
|
|
393
|
+
let sourceLine = 0;
|
|
394
|
+
let sourceColumn = 0;
|
|
395
|
+
let namesIndex = 0;
|
|
396
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
397
|
+
const line = decoded[i];
|
|
398
|
+
if (i > 0) writer.write(semicolon);
|
|
399
|
+
if (line.length === 0) continue;
|
|
400
|
+
let genColumn = 0;
|
|
401
|
+
for (let j = 0; j < line.length; j++) {
|
|
402
|
+
const segment = line[j];
|
|
403
|
+
if (j > 0) writer.write(comma);
|
|
404
|
+
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
405
|
+
if (segment.length === 1) continue;
|
|
406
|
+
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
407
|
+
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
408
|
+
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
409
|
+
if (segment.length === 4) continue;
|
|
410
|
+
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return writer.flush();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
class BitSet {
|
|
417
|
+
constructor(arg) {
|
|
418
|
+
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
add(n) {
|
|
422
|
+
this.bits[n >> 5] |= 1 << (n & 31);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
has(n) {
|
|
426
|
+
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
class Chunk {
|
|
431
|
+
constructor(start, end, content) {
|
|
432
|
+
this.start = start;
|
|
433
|
+
this.end = end;
|
|
434
|
+
this.original = content;
|
|
435
|
+
|
|
436
|
+
this.intro = '';
|
|
437
|
+
this.outro = '';
|
|
438
|
+
|
|
439
|
+
this.content = content;
|
|
440
|
+
this.storeName = false;
|
|
441
|
+
this.edited = false;
|
|
442
|
+
|
|
443
|
+
{
|
|
444
|
+
this.previous = null;
|
|
445
|
+
this.next = null;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
appendLeft(content) {
|
|
450
|
+
this.outro += content;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
appendRight(content) {
|
|
454
|
+
this.intro = this.intro + content;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
clone() {
|
|
458
|
+
const chunk = new Chunk(this.start, this.end, this.original);
|
|
459
|
+
|
|
460
|
+
chunk.intro = this.intro;
|
|
461
|
+
chunk.outro = this.outro;
|
|
462
|
+
chunk.content = this.content;
|
|
463
|
+
chunk.storeName = this.storeName;
|
|
464
|
+
chunk.edited = this.edited;
|
|
465
|
+
|
|
466
|
+
return chunk;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
contains(index) {
|
|
470
|
+
return this.start < index && index < this.end;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
eachNext(fn) {
|
|
474
|
+
let chunk = this;
|
|
475
|
+
while (chunk) {
|
|
476
|
+
fn(chunk);
|
|
477
|
+
chunk = chunk.next;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
eachPrevious(fn) {
|
|
482
|
+
let chunk = this;
|
|
483
|
+
while (chunk) {
|
|
484
|
+
fn(chunk);
|
|
485
|
+
chunk = chunk.previous;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
edit(content, storeName, contentOnly) {
|
|
490
|
+
this.content = content;
|
|
491
|
+
if (!contentOnly) {
|
|
492
|
+
this.intro = '';
|
|
493
|
+
this.outro = '';
|
|
494
|
+
}
|
|
495
|
+
this.storeName = storeName;
|
|
496
|
+
|
|
497
|
+
this.edited = true;
|
|
498
|
+
|
|
499
|
+
return this;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
prependLeft(content) {
|
|
503
|
+
this.outro = content + this.outro;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
prependRight(content) {
|
|
507
|
+
this.intro = content + this.intro;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
reset() {
|
|
511
|
+
this.intro = '';
|
|
512
|
+
this.outro = '';
|
|
513
|
+
if (this.edited) {
|
|
514
|
+
this.content = this.original;
|
|
515
|
+
this.storeName = false;
|
|
516
|
+
this.edited = false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
split(index) {
|
|
521
|
+
const sliceIndex = index - this.start;
|
|
522
|
+
|
|
523
|
+
const originalBefore = this.original.slice(0, sliceIndex);
|
|
524
|
+
const originalAfter = this.original.slice(sliceIndex);
|
|
525
|
+
|
|
526
|
+
this.original = originalBefore;
|
|
527
|
+
|
|
528
|
+
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
529
|
+
newChunk.outro = this.outro;
|
|
530
|
+
this.outro = '';
|
|
531
|
+
|
|
532
|
+
this.end = index;
|
|
533
|
+
|
|
534
|
+
if (this.edited) {
|
|
535
|
+
// after split we should save the edit content record into the correct chunk
|
|
536
|
+
// to make sure sourcemap correct
|
|
537
|
+
// For example:
|
|
538
|
+
// ' test'.trim()
|
|
539
|
+
// split -> ' ' + 'test'
|
|
540
|
+
// ✔️ edit -> '' + 'test'
|
|
541
|
+
// ✖️ edit -> 'test' + ''
|
|
542
|
+
// TODO is this block necessary?...
|
|
543
|
+
newChunk.edit('', false);
|
|
544
|
+
this.content = '';
|
|
545
|
+
} else {
|
|
546
|
+
this.content = originalBefore;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
newChunk.next = this.next;
|
|
550
|
+
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
551
|
+
newChunk.previous = this;
|
|
552
|
+
this.next = newChunk;
|
|
553
|
+
|
|
554
|
+
return newChunk;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
toString() {
|
|
558
|
+
return this.intro + this.content + this.outro;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
trimEnd(rx) {
|
|
562
|
+
this.outro = this.outro.replace(rx, '');
|
|
563
|
+
if (this.outro.length) return true;
|
|
564
|
+
|
|
565
|
+
const trimmed = this.content.replace(rx, '');
|
|
566
|
+
|
|
567
|
+
if (trimmed.length) {
|
|
568
|
+
if (trimmed !== this.content) {
|
|
569
|
+
this.split(this.start + trimmed.length).edit('', undefined, true);
|
|
570
|
+
if (this.edited) {
|
|
571
|
+
// save the change, if it has been edited
|
|
572
|
+
this.edit(trimmed, this.storeName, true);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return true;
|
|
576
|
+
} else {
|
|
577
|
+
this.edit('', undefined, true);
|
|
578
|
+
|
|
579
|
+
this.intro = this.intro.replace(rx, '');
|
|
580
|
+
if (this.intro.length) return true;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
trimStart(rx) {
|
|
585
|
+
this.intro = this.intro.replace(rx, '');
|
|
586
|
+
if (this.intro.length) return true;
|
|
587
|
+
|
|
588
|
+
const trimmed = this.content.replace(rx, '');
|
|
589
|
+
|
|
590
|
+
if (trimmed.length) {
|
|
591
|
+
if (trimmed !== this.content) {
|
|
592
|
+
const newChunk = this.split(this.end - trimmed.length);
|
|
593
|
+
if (this.edited) {
|
|
594
|
+
// save the change, if it has been edited
|
|
595
|
+
newChunk.edit(trimmed, this.storeName, true);
|
|
596
|
+
}
|
|
597
|
+
this.edit('', undefined, true);
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
} else {
|
|
601
|
+
this.edit('', undefined, true);
|
|
602
|
+
|
|
603
|
+
this.outro = this.outro.replace(rx, '');
|
|
604
|
+
if (this.outro.length) return true;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function getBtoa() {
|
|
610
|
+
if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
|
|
611
|
+
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
612
|
+
} else if (typeof Buffer === 'function') {
|
|
613
|
+
return (str) => Buffer.from(str, 'utf-8').toString('base64');
|
|
614
|
+
} else {
|
|
615
|
+
return () => {
|
|
616
|
+
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const btoa = /*#__PURE__*/ getBtoa();
|
|
622
|
+
|
|
623
|
+
class SourceMap {
|
|
624
|
+
constructor(properties) {
|
|
625
|
+
this.version = 3;
|
|
626
|
+
this.file = properties.file;
|
|
627
|
+
this.sources = properties.sources;
|
|
628
|
+
this.sourcesContent = properties.sourcesContent;
|
|
629
|
+
this.names = properties.names;
|
|
630
|
+
this.mappings = encode(properties.mappings);
|
|
631
|
+
if (typeof properties.x_google_ignoreList !== 'undefined') {
|
|
632
|
+
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
633
|
+
}
|
|
634
|
+
if (typeof properties.debugId !== 'undefined') {
|
|
635
|
+
this.debugId = properties.debugId;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
toString() {
|
|
640
|
+
return JSON.stringify(this);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
toUrl() {
|
|
644
|
+
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function guessIndent(code) {
|
|
649
|
+
const lines = code.split('\n');
|
|
650
|
+
|
|
651
|
+
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
652
|
+
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
653
|
+
|
|
654
|
+
if (tabbed.length === 0 && spaced.length === 0) {
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// More lines tabbed than spaced? Assume tabs, and
|
|
659
|
+
// default to tabs in the case of a tie (or nothing
|
|
660
|
+
// to go on)
|
|
661
|
+
if (tabbed.length >= spaced.length) {
|
|
662
|
+
return '\t';
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// Otherwise, we need to guess the multiple
|
|
666
|
+
const min = spaced.reduce((previous, current) => {
|
|
667
|
+
const numSpaces = /^ +/.exec(current)[0].length;
|
|
668
|
+
return Math.min(numSpaces, previous);
|
|
669
|
+
}, Infinity);
|
|
670
|
+
|
|
671
|
+
return new Array(min + 1).join(' ');
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function getRelativePath(from, to) {
|
|
675
|
+
const fromParts = from.split(/[/\\]/);
|
|
676
|
+
const toParts = to.split(/[/\\]/);
|
|
677
|
+
|
|
678
|
+
fromParts.pop(); // get dirname
|
|
679
|
+
|
|
680
|
+
while (fromParts[0] === toParts[0]) {
|
|
681
|
+
fromParts.shift();
|
|
682
|
+
toParts.shift();
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (fromParts.length) {
|
|
686
|
+
let i = fromParts.length;
|
|
687
|
+
while (i--) fromParts[i] = '..';
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
return fromParts.concat(toParts).join('/');
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const toString = Object.prototype.toString;
|
|
694
|
+
|
|
695
|
+
function isObject(thing) {
|
|
696
|
+
return toString.call(thing) === '[object Object]';
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function getLocator(source) {
|
|
700
|
+
const originalLines = source.split('\n');
|
|
701
|
+
const lineOffsets = [];
|
|
702
|
+
|
|
703
|
+
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
704
|
+
lineOffsets.push(pos);
|
|
705
|
+
pos += originalLines[i].length + 1;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return function locate(index) {
|
|
709
|
+
let i = 0;
|
|
710
|
+
let j = lineOffsets.length;
|
|
711
|
+
while (i < j) {
|
|
712
|
+
const m = (i + j) >> 1;
|
|
713
|
+
if (index < lineOffsets[m]) {
|
|
714
|
+
j = m;
|
|
715
|
+
} else {
|
|
716
|
+
i = m + 1;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const line = i - 1;
|
|
720
|
+
const column = index - lineOffsets[line];
|
|
721
|
+
return { line, column };
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const wordRegex = /\w/;
|
|
726
|
+
|
|
727
|
+
class Mappings {
|
|
728
|
+
constructor(hires) {
|
|
729
|
+
this.hires = hires;
|
|
730
|
+
this.generatedCodeLine = 0;
|
|
731
|
+
this.generatedCodeColumn = 0;
|
|
732
|
+
this.raw = [];
|
|
733
|
+
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
734
|
+
this.pending = null;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
738
|
+
if (content.length) {
|
|
739
|
+
const contentLengthMinusOne = content.length - 1;
|
|
740
|
+
let contentLineEnd = content.indexOf('\n', 0);
|
|
741
|
+
let previousContentLineEnd = -1;
|
|
742
|
+
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
|
743
|
+
// else code afterwards would fill one line too many
|
|
744
|
+
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
745
|
+
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
746
|
+
if (nameIndex >= 0) {
|
|
747
|
+
segment.push(nameIndex);
|
|
748
|
+
}
|
|
749
|
+
this.rawSegments.push(segment);
|
|
750
|
+
|
|
751
|
+
this.generatedCodeLine += 1;
|
|
752
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
753
|
+
this.generatedCodeColumn = 0;
|
|
754
|
+
|
|
755
|
+
previousContentLineEnd = contentLineEnd;
|
|
756
|
+
contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
760
|
+
if (nameIndex >= 0) {
|
|
761
|
+
segment.push(nameIndex);
|
|
762
|
+
}
|
|
763
|
+
this.rawSegments.push(segment);
|
|
764
|
+
|
|
765
|
+
this.advance(content.slice(previousContentLineEnd + 1));
|
|
766
|
+
} else if (this.pending) {
|
|
767
|
+
this.rawSegments.push(this.pending);
|
|
768
|
+
this.advance(content);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
this.pending = null;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
775
|
+
let originalCharIndex = chunk.start;
|
|
776
|
+
let first = true;
|
|
777
|
+
// when iterating each char, check if it's in a word boundary
|
|
778
|
+
let charInHiresBoundary = false;
|
|
779
|
+
|
|
780
|
+
while (originalCharIndex < chunk.end) {
|
|
781
|
+
if (original[originalCharIndex] === '\n') {
|
|
782
|
+
loc.line += 1;
|
|
783
|
+
loc.column = 0;
|
|
784
|
+
this.generatedCodeLine += 1;
|
|
785
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
786
|
+
this.generatedCodeColumn = 0;
|
|
787
|
+
first = true;
|
|
788
|
+
charInHiresBoundary = false;
|
|
789
|
+
} else {
|
|
790
|
+
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
791
|
+
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
792
|
+
|
|
793
|
+
if (this.hires === 'boundary') {
|
|
794
|
+
// in hires "boundary", group segments per word boundary than per char
|
|
795
|
+
if (wordRegex.test(original[originalCharIndex])) {
|
|
796
|
+
// for first char in the boundary found, start the boundary by pushing a segment
|
|
797
|
+
if (!charInHiresBoundary) {
|
|
798
|
+
this.rawSegments.push(segment);
|
|
799
|
+
charInHiresBoundary = true;
|
|
800
|
+
}
|
|
801
|
+
} else {
|
|
802
|
+
// for non-word char, end the boundary by pushing a segment
|
|
803
|
+
this.rawSegments.push(segment);
|
|
804
|
+
charInHiresBoundary = false;
|
|
805
|
+
}
|
|
806
|
+
} else {
|
|
807
|
+
this.rawSegments.push(segment);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
loc.column += 1;
|
|
812
|
+
this.generatedCodeColumn += 1;
|
|
813
|
+
first = false;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
originalCharIndex += 1;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
this.pending = null;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
advance(str) {
|
|
823
|
+
if (!str) return;
|
|
824
|
+
|
|
825
|
+
const lines = str.split('\n');
|
|
826
|
+
|
|
827
|
+
if (lines.length > 1) {
|
|
828
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
829
|
+
this.generatedCodeLine++;
|
|
830
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
831
|
+
}
|
|
832
|
+
this.generatedCodeColumn = 0;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
const n = '\n';
|
|
840
|
+
|
|
841
|
+
const warned = {
|
|
842
|
+
insertLeft: false,
|
|
843
|
+
insertRight: false,
|
|
844
|
+
storeName: false,
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
class MagicString {
|
|
848
|
+
constructor(string, options = {}) {
|
|
849
|
+
const chunk = new Chunk(0, string.length, string);
|
|
850
|
+
|
|
851
|
+
Object.defineProperties(this, {
|
|
852
|
+
original: { writable: true, value: string },
|
|
853
|
+
outro: { writable: true, value: '' },
|
|
854
|
+
intro: { writable: true, value: '' },
|
|
855
|
+
firstChunk: { writable: true, value: chunk },
|
|
856
|
+
lastChunk: { writable: true, value: chunk },
|
|
857
|
+
lastSearchedChunk: { writable: true, value: chunk },
|
|
858
|
+
byStart: { writable: true, value: {} },
|
|
859
|
+
byEnd: { writable: true, value: {} },
|
|
860
|
+
filename: { writable: true, value: options.filename },
|
|
861
|
+
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
862
|
+
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
863
|
+
storedNames: { writable: true, value: {} },
|
|
864
|
+
indentStr: { writable: true, value: undefined },
|
|
865
|
+
ignoreList: { writable: true, value: options.ignoreList },
|
|
866
|
+
offset: { writable: true, value: options.offset || 0 },
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
this.byStart[0] = chunk;
|
|
870
|
+
this.byEnd[string.length] = chunk;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
addSourcemapLocation(char) {
|
|
874
|
+
this.sourcemapLocations.add(char);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
append(content) {
|
|
878
|
+
if (typeof content !== 'string') throw new TypeError('outro content must be a string');
|
|
879
|
+
|
|
880
|
+
this.outro += content;
|
|
881
|
+
return this;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
appendLeft(index, content) {
|
|
885
|
+
index = index + this.offset;
|
|
886
|
+
|
|
887
|
+
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
888
|
+
|
|
889
|
+
this._split(index);
|
|
890
|
+
|
|
891
|
+
const chunk = this.byEnd[index];
|
|
892
|
+
|
|
893
|
+
if (chunk) {
|
|
894
|
+
chunk.appendLeft(content);
|
|
895
|
+
} else {
|
|
896
|
+
this.intro += content;
|
|
897
|
+
}
|
|
898
|
+
return this;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
appendRight(index, content) {
|
|
902
|
+
index = index + this.offset;
|
|
903
|
+
|
|
904
|
+
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
905
|
+
|
|
906
|
+
this._split(index);
|
|
907
|
+
|
|
908
|
+
const chunk = this.byStart[index];
|
|
909
|
+
|
|
910
|
+
if (chunk) {
|
|
911
|
+
chunk.appendRight(content);
|
|
912
|
+
} else {
|
|
913
|
+
this.outro += content;
|
|
914
|
+
}
|
|
915
|
+
return this;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
clone() {
|
|
919
|
+
const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
|
|
920
|
+
|
|
921
|
+
let originalChunk = this.firstChunk;
|
|
922
|
+
let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
|
|
923
|
+
|
|
924
|
+
while (originalChunk) {
|
|
925
|
+
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
926
|
+
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
927
|
+
|
|
928
|
+
const nextOriginalChunk = originalChunk.next;
|
|
929
|
+
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
930
|
+
|
|
931
|
+
if (nextClonedChunk) {
|
|
932
|
+
clonedChunk.next = nextClonedChunk;
|
|
933
|
+
nextClonedChunk.previous = clonedChunk;
|
|
934
|
+
|
|
935
|
+
clonedChunk = nextClonedChunk;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
originalChunk = nextOriginalChunk;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
cloned.lastChunk = clonedChunk;
|
|
942
|
+
|
|
943
|
+
if (this.indentExclusionRanges) {
|
|
944
|
+
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
948
|
+
|
|
949
|
+
cloned.intro = this.intro;
|
|
950
|
+
cloned.outro = this.outro;
|
|
951
|
+
|
|
952
|
+
return cloned;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
generateDecodedMap(options) {
|
|
956
|
+
options = options || {};
|
|
957
|
+
|
|
958
|
+
const sourceIndex = 0;
|
|
959
|
+
const names = Object.keys(this.storedNames);
|
|
960
|
+
const mappings = new Mappings(options.hires);
|
|
961
|
+
|
|
962
|
+
const locate = getLocator(this.original);
|
|
963
|
+
|
|
964
|
+
if (this.intro) {
|
|
965
|
+
mappings.advance(this.intro);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
this.firstChunk.eachNext((chunk) => {
|
|
969
|
+
const loc = locate(chunk.start);
|
|
970
|
+
|
|
971
|
+
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
972
|
+
|
|
973
|
+
if (chunk.edited) {
|
|
974
|
+
mappings.addEdit(
|
|
975
|
+
sourceIndex,
|
|
976
|
+
chunk.content,
|
|
977
|
+
loc,
|
|
978
|
+
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
979
|
+
);
|
|
980
|
+
} else {
|
|
981
|
+
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
985
|
+
});
|
|
986
|
+
|
|
987
|
+
if (this.outro) {
|
|
988
|
+
mappings.advance(this.outro);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
return {
|
|
992
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
993
|
+
sources: [
|
|
994
|
+
options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
|
|
995
|
+
],
|
|
996
|
+
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
997
|
+
names,
|
|
998
|
+
mappings: mappings.raw,
|
|
999
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
generateMap(options) {
|
|
1004
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
_ensureindentStr() {
|
|
1008
|
+
if (this.indentStr === undefined) {
|
|
1009
|
+
this.indentStr = guessIndent(this.original);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
_getRawIndentString() {
|
|
1014
|
+
this._ensureindentStr();
|
|
1015
|
+
return this.indentStr;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
getIndentString() {
|
|
1019
|
+
this._ensureindentStr();
|
|
1020
|
+
return this.indentStr === null ? '\t' : this.indentStr;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
indent(indentStr, options) {
|
|
1024
|
+
const pattern = /^[^\r\n]/gm;
|
|
1025
|
+
|
|
1026
|
+
if (isObject(indentStr)) {
|
|
1027
|
+
options = indentStr;
|
|
1028
|
+
indentStr = undefined;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
if (indentStr === undefined) {
|
|
1032
|
+
this._ensureindentStr();
|
|
1033
|
+
indentStr = this.indentStr || '\t';
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
if (indentStr === '') return this; // noop
|
|
1037
|
+
|
|
1038
|
+
options = options || {};
|
|
1039
|
+
|
|
1040
|
+
// Process exclusion ranges
|
|
1041
|
+
const isExcluded = {};
|
|
1042
|
+
|
|
1043
|
+
if (options.exclude) {
|
|
1044
|
+
const exclusions =
|
|
1045
|
+
typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
|
1046
|
+
exclusions.forEach((exclusion) => {
|
|
1047
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
1048
|
+
isExcluded[i] = true;
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
1054
|
+
const replacer = (match) => {
|
|
1055
|
+
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
1056
|
+
shouldIndentNextCharacter = true;
|
|
1057
|
+
return match;
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
this.intro = this.intro.replace(pattern, replacer);
|
|
1061
|
+
|
|
1062
|
+
let charIndex = 0;
|
|
1063
|
+
let chunk = this.firstChunk;
|
|
1064
|
+
|
|
1065
|
+
while (chunk) {
|
|
1066
|
+
const end = chunk.end;
|
|
1067
|
+
|
|
1068
|
+
if (chunk.edited) {
|
|
1069
|
+
if (!isExcluded[charIndex]) {
|
|
1070
|
+
chunk.content = chunk.content.replace(pattern, replacer);
|
|
1071
|
+
|
|
1072
|
+
if (chunk.content.length) {
|
|
1073
|
+
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
} else {
|
|
1077
|
+
charIndex = chunk.start;
|
|
1078
|
+
|
|
1079
|
+
while (charIndex < end) {
|
|
1080
|
+
if (!isExcluded[charIndex]) {
|
|
1081
|
+
const char = this.original[charIndex];
|
|
1082
|
+
|
|
1083
|
+
if (char === '\n') {
|
|
1084
|
+
shouldIndentNextCharacter = true;
|
|
1085
|
+
} else if (char !== '\r' && shouldIndentNextCharacter) {
|
|
1086
|
+
shouldIndentNextCharacter = false;
|
|
1087
|
+
|
|
1088
|
+
if (charIndex === chunk.start) {
|
|
1089
|
+
chunk.prependRight(indentStr);
|
|
1090
|
+
} else {
|
|
1091
|
+
this._splitChunk(chunk, charIndex);
|
|
1092
|
+
chunk = chunk.next;
|
|
1093
|
+
chunk.prependRight(indentStr);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
charIndex += 1;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
charIndex = chunk.end;
|
|
1103
|
+
chunk = chunk.next;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
this.outro = this.outro.replace(pattern, replacer);
|
|
1107
|
+
|
|
1108
|
+
return this;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
insert() {
|
|
1112
|
+
throw new Error(
|
|
1113
|
+
'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
insertLeft(index, content) {
|
|
1118
|
+
if (!warned.insertLeft) {
|
|
1119
|
+
console.warn(
|
|
1120
|
+
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
1121
|
+
);
|
|
1122
|
+
warned.insertLeft = true;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
return this.appendLeft(index, content);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
insertRight(index, content) {
|
|
1129
|
+
if (!warned.insertRight) {
|
|
1130
|
+
console.warn(
|
|
1131
|
+
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
1132
|
+
);
|
|
1133
|
+
warned.insertRight = true;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return this.prependRight(index, content);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
move(start, end, index) {
|
|
1140
|
+
start = start + this.offset;
|
|
1141
|
+
end = end + this.offset;
|
|
1142
|
+
index = index + this.offset;
|
|
1143
|
+
|
|
1144
|
+
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
|
1145
|
+
|
|
1146
|
+
this._split(start);
|
|
1147
|
+
this._split(end);
|
|
1148
|
+
this._split(index);
|
|
1149
|
+
|
|
1150
|
+
const first = this.byStart[start];
|
|
1151
|
+
const last = this.byEnd[end];
|
|
1152
|
+
|
|
1153
|
+
const oldLeft = first.previous;
|
|
1154
|
+
const oldRight = last.next;
|
|
1155
|
+
|
|
1156
|
+
const newRight = this.byStart[index];
|
|
1157
|
+
if (!newRight && last === this.lastChunk) return this;
|
|
1158
|
+
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
1159
|
+
|
|
1160
|
+
if (oldLeft) oldLeft.next = oldRight;
|
|
1161
|
+
if (oldRight) oldRight.previous = oldLeft;
|
|
1162
|
+
|
|
1163
|
+
if (newLeft) newLeft.next = first;
|
|
1164
|
+
if (newRight) newRight.previous = last;
|
|
1165
|
+
|
|
1166
|
+
if (!first.previous) this.firstChunk = last.next;
|
|
1167
|
+
if (!last.next) {
|
|
1168
|
+
this.lastChunk = first.previous;
|
|
1169
|
+
this.lastChunk.next = null;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
first.previous = newLeft;
|
|
1173
|
+
last.next = newRight || null;
|
|
1174
|
+
|
|
1175
|
+
if (!newLeft) this.firstChunk = first;
|
|
1176
|
+
if (!newRight) this.lastChunk = last;
|
|
1177
|
+
return this;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
overwrite(start, end, content, options) {
|
|
1181
|
+
options = options || {};
|
|
1182
|
+
return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
update(start, end, content, options) {
|
|
1186
|
+
start = start + this.offset;
|
|
1187
|
+
end = end + this.offset;
|
|
1188
|
+
|
|
1189
|
+
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
1190
|
+
|
|
1191
|
+
if (this.original.length !== 0) {
|
|
1192
|
+
while (start < 0) start += this.original.length;
|
|
1193
|
+
while (end < 0) end += this.original.length;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
if (end > this.original.length) throw new Error('end is out of bounds');
|
|
1197
|
+
if (start === end)
|
|
1198
|
+
throw new Error(
|
|
1199
|
+
'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
|
|
1200
|
+
);
|
|
1201
|
+
|
|
1202
|
+
this._split(start);
|
|
1203
|
+
this._split(end);
|
|
1204
|
+
|
|
1205
|
+
if (options === true) {
|
|
1206
|
+
if (!warned.storeName) {
|
|
1207
|
+
console.warn(
|
|
1208
|
+
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
1209
|
+
);
|
|
1210
|
+
warned.storeName = true;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
options = { storeName: true };
|
|
1214
|
+
}
|
|
1215
|
+
const storeName = options !== undefined ? options.storeName : false;
|
|
1216
|
+
const overwrite = options !== undefined ? options.overwrite : false;
|
|
1217
|
+
|
|
1218
|
+
if (storeName) {
|
|
1219
|
+
const original = this.original.slice(start, end);
|
|
1220
|
+
Object.defineProperty(this.storedNames, original, {
|
|
1221
|
+
writable: true,
|
|
1222
|
+
value: true,
|
|
1223
|
+
enumerable: true,
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
const first = this.byStart[start];
|
|
1228
|
+
const last = this.byEnd[end];
|
|
1229
|
+
|
|
1230
|
+
if (first) {
|
|
1231
|
+
let chunk = first;
|
|
1232
|
+
while (chunk !== last) {
|
|
1233
|
+
if (chunk.next !== this.byStart[chunk.end]) {
|
|
1234
|
+
throw new Error('Cannot overwrite across a split point');
|
|
1235
|
+
}
|
|
1236
|
+
chunk = chunk.next;
|
|
1237
|
+
chunk.edit('', false);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
first.edit(content, storeName, !overwrite);
|
|
1241
|
+
} else {
|
|
1242
|
+
// must be inserting at the end
|
|
1243
|
+
const newChunk = new Chunk(start, end, '').edit(content, storeName);
|
|
1244
|
+
|
|
1245
|
+
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
1246
|
+
last.next = newChunk;
|
|
1247
|
+
newChunk.previous = last;
|
|
1248
|
+
}
|
|
1249
|
+
return this;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
prepend(content) {
|
|
1253
|
+
if (typeof content !== 'string') throw new TypeError('outro content must be a string');
|
|
1254
|
+
|
|
1255
|
+
this.intro = content + this.intro;
|
|
1256
|
+
return this;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
prependLeft(index, content) {
|
|
1260
|
+
index = index + this.offset;
|
|
1261
|
+
|
|
1262
|
+
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1263
|
+
|
|
1264
|
+
this._split(index);
|
|
1265
|
+
|
|
1266
|
+
const chunk = this.byEnd[index];
|
|
1267
|
+
|
|
1268
|
+
if (chunk) {
|
|
1269
|
+
chunk.prependLeft(content);
|
|
1270
|
+
} else {
|
|
1271
|
+
this.intro = content + this.intro;
|
|
1272
|
+
}
|
|
1273
|
+
return this;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
prependRight(index, content) {
|
|
1277
|
+
index = index + this.offset;
|
|
1278
|
+
|
|
1279
|
+
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1280
|
+
|
|
1281
|
+
this._split(index);
|
|
1282
|
+
|
|
1283
|
+
const chunk = this.byStart[index];
|
|
1284
|
+
|
|
1285
|
+
if (chunk) {
|
|
1286
|
+
chunk.prependRight(content);
|
|
1287
|
+
} else {
|
|
1288
|
+
this.outro = content + this.outro;
|
|
1289
|
+
}
|
|
1290
|
+
return this;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
remove(start, end) {
|
|
1294
|
+
start = start + this.offset;
|
|
1295
|
+
end = end + this.offset;
|
|
1296
|
+
|
|
1297
|
+
if (this.original.length !== 0) {
|
|
1298
|
+
while (start < 0) start += this.original.length;
|
|
1299
|
+
while (end < 0) end += this.original.length;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
if (start === end) return this;
|
|
1303
|
+
|
|
1304
|
+
if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
|
|
1305
|
+
if (start > end) throw new Error('end must be greater than start');
|
|
1306
|
+
|
|
1307
|
+
this._split(start);
|
|
1308
|
+
this._split(end);
|
|
1309
|
+
|
|
1310
|
+
let chunk = this.byStart[start];
|
|
1311
|
+
|
|
1312
|
+
while (chunk) {
|
|
1313
|
+
chunk.intro = '';
|
|
1314
|
+
chunk.outro = '';
|
|
1315
|
+
chunk.edit('');
|
|
1316
|
+
|
|
1317
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1318
|
+
}
|
|
1319
|
+
return this;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
reset(start, end) {
|
|
1323
|
+
start = start + this.offset;
|
|
1324
|
+
end = end + this.offset;
|
|
1325
|
+
|
|
1326
|
+
if (this.original.length !== 0) {
|
|
1327
|
+
while (start < 0) start += this.original.length;
|
|
1328
|
+
while (end < 0) end += this.original.length;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
if (start === end) return this;
|
|
1332
|
+
|
|
1333
|
+
if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
|
|
1334
|
+
if (start > end) throw new Error('end must be greater than start');
|
|
1335
|
+
|
|
1336
|
+
this._split(start);
|
|
1337
|
+
this._split(end);
|
|
1338
|
+
|
|
1339
|
+
let chunk = this.byStart[start];
|
|
1340
|
+
|
|
1341
|
+
while (chunk) {
|
|
1342
|
+
chunk.reset();
|
|
1343
|
+
|
|
1344
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1345
|
+
}
|
|
1346
|
+
return this;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
lastChar() {
|
|
1350
|
+
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
1351
|
+
let chunk = this.lastChunk;
|
|
1352
|
+
do {
|
|
1353
|
+
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
1354
|
+
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
1355
|
+
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
1356
|
+
} while ((chunk = chunk.previous));
|
|
1357
|
+
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
1358
|
+
return '';
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
lastLine() {
|
|
1362
|
+
let lineIndex = this.outro.lastIndexOf(n);
|
|
1363
|
+
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
1364
|
+
let lineStr = this.outro;
|
|
1365
|
+
let chunk = this.lastChunk;
|
|
1366
|
+
do {
|
|
1367
|
+
if (chunk.outro.length > 0) {
|
|
1368
|
+
lineIndex = chunk.outro.lastIndexOf(n);
|
|
1369
|
+
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
1370
|
+
lineStr = chunk.outro + lineStr;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
if (chunk.content.length > 0) {
|
|
1374
|
+
lineIndex = chunk.content.lastIndexOf(n);
|
|
1375
|
+
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
1376
|
+
lineStr = chunk.content + lineStr;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
if (chunk.intro.length > 0) {
|
|
1380
|
+
lineIndex = chunk.intro.lastIndexOf(n);
|
|
1381
|
+
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
1382
|
+
lineStr = chunk.intro + lineStr;
|
|
1383
|
+
}
|
|
1384
|
+
} while ((chunk = chunk.previous));
|
|
1385
|
+
lineIndex = this.intro.lastIndexOf(n);
|
|
1386
|
+
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
1387
|
+
return this.intro + lineStr;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
slice(start = 0, end = this.original.length - this.offset) {
|
|
1391
|
+
start = start + this.offset;
|
|
1392
|
+
end = end + this.offset;
|
|
1393
|
+
|
|
1394
|
+
if (this.original.length !== 0) {
|
|
1395
|
+
while (start < 0) start += this.original.length;
|
|
1396
|
+
while (end < 0) end += this.original.length;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
let result = '';
|
|
1400
|
+
|
|
1401
|
+
// find start chunk
|
|
1402
|
+
let chunk = this.firstChunk;
|
|
1403
|
+
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
1404
|
+
// found end chunk before start
|
|
1405
|
+
if (chunk.start < end && chunk.end >= end) {
|
|
1406
|
+
return result;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
chunk = chunk.next;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
if (chunk && chunk.edited && chunk.start !== start)
|
|
1413
|
+
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1414
|
+
|
|
1415
|
+
const startChunk = chunk;
|
|
1416
|
+
while (chunk) {
|
|
1417
|
+
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
|
|
1418
|
+
result += chunk.intro;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
1422
|
+
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
1423
|
+
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1424
|
+
|
|
1425
|
+
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
1426
|
+
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
1427
|
+
|
|
1428
|
+
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
1429
|
+
|
|
1430
|
+
if (chunk.outro && (!containsEnd || chunk.end === end)) {
|
|
1431
|
+
result += chunk.outro;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
if (containsEnd) {
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
chunk = chunk.next;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
return result;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// TODO deprecate this? not really very useful
|
|
1445
|
+
snip(start, end) {
|
|
1446
|
+
const clone = this.clone();
|
|
1447
|
+
clone.remove(0, start);
|
|
1448
|
+
clone.remove(end, clone.original.length);
|
|
1449
|
+
|
|
1450
|
+
return clone;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
_split(index) {
|
|
1454
|
+
if (this.byStart[index] || this.byEnd[index]) return;
|
|
1455
|
+
|
|
1456
|
+
let chunk = this.lastSearchedChunk;
|
|
1457
|
+
let previousChunk = chunk;
|
|
1458
|
+
const searchForward = index > chunk.end;
|
|
1459
|
+
|
|
1460
|
+
while (chunk) {
|
|
1461
|
+
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
1462
|
+
|
|
1463
|
+
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
1464
|
+
|
|
1465
|
+
// Prevent infinite loop (e.g. via empty chunks, where start === end)
|
|
1466
|
+
if (chunk === previousChunk) return;
|
|
1467
|
+
|
|
1468
|
+
previousChunk = chunk;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
_splitChunk(chunk, index) {
|
|
1473
|
+
if (chunk.edited && chunk.content.length) {
|
|
1474
|
+
// zero-length edited chunks are a special case (overlapping replacements)
|
|
1475
|
+
const loc = getLocator(this.original)(index);
|
|
1476
|
+
throw new Error(
|
|
1477
|
+
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const newChunk = chunk.split(index);
|
|
1482
|
+
|
|
1483
|
+
this.byEnd[index] = chunk;
|
|
1484
|
+
this.byStart[index] = newChunk;
|
|
1485
|
+
this.byEnd[newChunk.end] = newChunk;
|
|
1486
|
+
|
|
1487
|
+
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
1488
|
+
|
|
1489
|
+
this.lastSearchedChunk = chunk;
|
|
1490
|
+
return true;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
toString() {
|
|
1494
|
+
let str = this.intro;
|
|
1495
|
+
|
|
1496
|
+
let chunk = this.firstChunk;
|
|
1497
|
+
while (chunk) {
|
|
1498
|
+
str += chunk.toString();
|
|
1499
|
+
chunk = chunk.next;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
return str + this.outro;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
isEmpty() {
|
|
1506
|
+
let chunk = this.firstChunk;
|
|
1507
|
+
do {
|
|
1508
|
+
if (
|
|
1509
|
+
(chunk.intro.length && chunk.intro.trim()) ||
|
|
1510
|
+
(chunk.content.length && chunk.content.trim()) ||
|
|
1511
|
+
(chunk.outro.length && chunk.outro.trim())
|
|
1512
|
+
)
|
|
1513
|
+
return false;
|
|
1514
|
+
} while ((chunk = chunk.next));
|
|
1515
|
+
return true;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
length() {
|
|
1519
|
+
let chunk = this.firstChunk;
|
|
1520
|
+
let length = 0;
|
|
1521
|
+
do {
|
|
1522
|
+
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
1523
|
+
} while ((chunk = chunk.next));
|
|
1524
|
+
return length;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
trimLines() {
|
|
1528
|
+
return this.trim('[\\r\\n]');
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
trim(charType) {
|
|
1532
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
trimEndAborted(charType) {
|
|
1536
|
+
const rx = new RegExp((charType || '\\s') + '+$');
|
|
1537
|
+
|
|
1538
|
+
this.outro = this.outro.replace(rx, '');
|
|
1539
|
+
if (this.outro.length) return true;
|
|
1540
|
+
|
|
1541
|
+
let chunk = this.lastChunk;
|
|
1542
|
+
|
|
1543
|
+
do {
|
|
1544
|
+
const end = chunk.end;
|
|
1545
|
+
const aborted = chunk.trimEnd(rx);
|
|
1546
|
+
|
|
1547
|
+
// if chunk was trimmed, we have a new lastChunk
|
|
1548
|
+
if (chunk.end !== end) {
|
|
1549
|
+
if (this.lastChunk === chunk) {
|
|
1550
|
+
this.lastChunk = chunk.next;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
this.byEnd[chunk.end] = chunk;
|
|
1554
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1555
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
if (aborted) return true;
|
|
1559
|
+
chunk = chunk.previous;
|
|
1560
|
+
} while (chunk);
|
|
1561
|
+
|
|
1562
|
+
return false;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
trimEnd(charType) {
|
|
1566
|
+
this.trimEndAborted(charType);
|
|
1567
|
+
return this;
|
|
1568
|
+
}
|
|
1569
|
+
trimStartAborted(charType) {
|
|
1570
|
+
const rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1571
|
+
|
|
1572
|
+
this.intro = this.intro.replace(rx, '');
|
|
1573
|
+
if (this.intro.length) return true;
|
|
1574
|
+
|
|
1575
|
+
let chunk = this.firstChunk;
|
|
1576
|
+
|
|
1577
|
+
do {
|
|
1578
|
+
const end = chunk.end;
|
|
1579
|
+
const aborted = chunk.trimStart(rx);
|
|
1580
|
+
|
|
1581
|
+
if (chunk.end !== end) {
|
|
1582
|
+
// special case...
|
|
1583
|
+
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
1584
|
+
|
|
1585
|
+
this.byEnd[chunk.end] = chunk;
|
|
1586
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1587
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
if (aborted) return true;
|
|
1591
|
+
chunk = chunk.next;
|
|
1592
|
+
} while (chunk);
|
|
1593
|
+
|
|
1594
|
+
return false;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
trimStart(charType) {
|
|
1598
|
+
this.trimStartAborted(charType);
|
|
1599
|
+
return this;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
hasChanged() {
|
|
1603
|
+
return this.original !== this.toString();
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
_replaceRegexp(searchValue, replacement) {
|
|
1607
|
+
function getReplacement(match, str) {
|
|
1608
|
+
if (typeof replacement === 'string') {
|
|
1609
|
+
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
1610
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
|
|
1611
|
+
if (i === '$') return '$';
|
|
1612
|
+
if (i === '&') return match[0];
|
|
1613
|
+
const num = +i;
|
|
1614
|
+
if (num < match.length) return match[+i];
|
|
1615
|
+
return `$${i}`;
|
|
1616
|
+
});
|
|
1617
|
+
} else {
|
|
1618
|
+
return replacement(...match, match.index, str, match.groups);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
function matchAll(re, str) {
|
|
1622
|
+
let match;
|
|
1623
|
+
const matches = [];
|
|
1624
|
+
while ((match = re.exec(str))) {
|
|
1625
|
+
matches.push(match);
|
|
1626
|
+
}
|
|
1627
|
+
return matches;
|
|
1628
|
+
}
|
|
1629
|
+
if (searchValue.global) {
|
|
1630
|
+
const matches = matchAll(searchValue, this.original);
|
|
1631
|
+
matches.forEach((match) => {
|
|
1632
|
+
if (match.index != null) {
|
|
1633
|
+
const replacement = getReplacement(match, this.original);
|
|
1634
|
+
if (replacement !== match[0]) {
|
|
1635
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
});
|
|
1639
|
+
} else {
|
|
1640
|
+
const match = this.original.match(searchValue);
|
|
1641
|
+
if (match && match.index != null) {
|
|
1642
|
+
const replacement = getReplacement(match, this.original);
|
|
1643
|
+
if (replacement !== match[0]) {
|
|
1644
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return this;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
_replaceString(string, replacement) {
|
|
1652
|
+
const { original } = this;
|
|
1653
|
+
const index = original.indexOf(string);
|
|
1654
|
+
|
|
1655
|
+
if (index !== -1) {
|
|
1656
|
+
if (typeof replacement === 'function') {
|
|
1657
|
+
replacement = replacement(string, index, original);
|
|
1658
|
+
}
|
|
1659
|
+
if (string !== replacement) {
|
|
1660
|
+
this.overwrite(index, index + string.length, replacement);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
return this;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
replace(searchValue, replacement) {
|
|
1668
|
+
if (typeof searchValue === 'string') {
|
|
1669
|
+
return this._replaceString(searchValue, replacement);
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
_replaceAllString(string, replacement) {
|
|
1676
|
+
const { original } = this;
|
|
1677
|
+
const stringLength = string.length;
|
|
1678
|
+
for (
|
|
1679
|
+
let index = original.indexOf(string);
|
|
1680
|
+
index !== -1;
|
|
1681
|
+
index = original.indexOf(string, index + stringLength)
|
|
1682
|
+
) {
|
|
1683
|
+
const previous = original.slice(index, index + stringLength);
|
|
1684
|
+
let _replacement = replacement;
|
|
1685
|
+
if (typeof replacement === 'function') {
|
|
1686
|
+
_replacement = replacement(previous, index, original);
|
|
1687
|
+
}
|
|
1688
|
+
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
return this;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
replaceAll(searchValue, replacement) {
|
|
1695
|
+
if (typeof searchValue === 'string') {
|
|
1696
|
+
return this._replaceAllString(searchValue, replacement);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
if (!searchValue.global) {
|
|
1700
|
+
throw new TypeError(
|
|
1701
|
+
'MagicString.prototype.replaceAll called with a non-global RegExp argument',
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1710
|
+
|
|
1711
|
+
class Bundle {
|
|
1712
|
+
constructor(options = {}) {
|
|
1713
|
+
this.intro = options.intro || '';
|
|
1714
|
+
this.separator = options.separator !== undefined ? options.separator : '\n';
|
|
1715
|
+
this.sources = [];
|
|
1716
|
+
this.uniqueSources = [];
|
|
1717
|
+
this.uniqueSourceIndexByFilename = {};
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
addSource(source) {
|
|
1721
|
+
if (source instanceof MagicString) {
|
|
1722
|
+
return this.addSource({
|
|
1723
|
+
content: source,
|
|
1724
|
+
filename: source.filename,
|
|
1725
|
+
separator: this.separator,
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
if (!isObject(source) || !source.content) {
|
|
1730
|
+
throw new Error(
|
|
1731
|
+
'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
|
|
1732
|
+
);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
['filename', 'ignoreList', 'indentExclusionRanges', 'separator'].forEach((option) => {
|
|
1736
|
+
if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
|
1737
|
+
});
|
|
1738
|
+
|
|
1739
|
+
if (source.separator === undefined) {
|
|
1740
|
+
// TODO there's a bunch of this sort of thing, needs cleaning up
|
|
1741
|
+
source.separator = this.separator;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
if (source.filename) {
|
|
1745
|
+
if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
|
1746
|
+
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
|
1747
|
+
this.uniqueSources.push({ filename: source.filename, content: source.content.original });
|
|
1748
|
+
} else {
|
|
1749
|
+
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
1750
|
+
if (source.content.original !== uniqueSource.content) {
|
|
1751
|
+
throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
this.sources.push(source);
|
|
1757
|
+
return this;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
append(str, options) {
|
|
1761
|
+
this.addSource({
|
|
1762
|
+
content: new MagicString(str),
|
|
1763
|
+
separator: (options && options.separator) || '',
|
|
1764
|
+
});
|
|
1765
|
+
|
|
1766
|
+
return this;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
clone() {
|
|
1770
|
+
const bundle = new Bundle({
|
|
1771
|
+
intro: this.intro,
|
|
1772
|
+
separator: this.separator,
|
|
1773
|
+
});
|
|
1774
|
+
|
|
1775
|
+
this.sources.forEach((source) => {
|
|
1776
|
+
bundle.addSource({
|
|
1777
|
+
filename: source.filename,
|
|
1778
|
+
content: source.content.clone(),
|
|
1779
|
+
separator: source.separator,
|
|
1780
|
+
});
|
|
1781
|
+
});
|
|
1782
|
+
|
|
1783
|
+
return bundle;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
generateDecodedMap(options = {}) {
|
|
1787
|
+
const names = [];
|
|
1788
|
+
let x_google_ignoreList = undefined;
|
|
1789
|
+
this.sources.forEach((source) => {
|
|
1790
|
+
Object.keys(source.content.storedNames).forEach((name) => {
|
|
1791
|
+
if (!~names.indexOf(name)) names.push(name);
|
|
1792
|
+
});
|
|
1793
|
+
});
|
|
1794
|
+
|
|
1795
|
+
const mappings = new Mappings(options.hires);
|
|
1796
|
+
|
|
1797
|
+
if (this.intro) {
|
|
1798
|
+
mappings.advance(this.intro);
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
this.sources.forEach((source, i) => {
|
|
1802
|
+
if (i > 0) {
|
|
1803
|
+
mappings.advance(this.separator);
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
1807
|
+
const magicString = source.content;
|
|
1808
|
+
const locate = getLocator(magicString.original);
|
|
1809
|
+
|
|
1810
|
+
if (magicString.intro) {
|
|
1811
|
+
mappings.advance(magicString.intro);
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
magicString.firstChunk.eachNext((chunk) => {
|
|
1815
|
+
const loc = locate(chunk.start);
|
|
1816
|
+
|
|
1817
|
+
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
1818
|
+
|
|
1819
|
+
if (source.filename) {
|
|
1820
|
+
if (chunk.edited) {
|
|
1821
|
+
mappings.addEdit(
|
|
1822
|
+
sourceIndex,
|
|
1823
|
+
chunk.content,
|
|
1824
|
+
loc,
|
|
1825
|
+
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
1826
|
+
);
|
|
1827
|
+
} else {
|
|
1828
|
+
mappings.addUneditedChunk(
|
|
1829
|
+
sourceIndex,
|
|
1830
|
+
chunk,
|
|
1831
|
+
magicString.original,
|
|
1832
|
+
loc,
|
|
1833
|
+
magicString.sourcemapLocations,
|
|
1834
|
+
);
|
|
1835
|
+
}
|
|
1836
|
+
} else {
|
|
1837
|
+
mappings.advance(chunk.content);
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
1841
|
+
});
|
|
1842
|
+
|
|
1843
|
+
if (magicString.outro) {
|
|
1844
|
+
mappings.advance(magicString.outro);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
if (source.ignoreList && sourceIndex !== -1) {
|
|
1848
|
+
if (x_google_ignoreList === undefined) {
|
|
1849
|
+
x_google_ignoreList = [];
|
|
1850
|
+
}
|
|
1851
|
+
x_google_ignoreList.push(sourceIndex);
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1855
|
+
return {
|
|
1856
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
1857
|
+
sources: this.uniqueSources.map((source) => {
|
|
1858
|
+
return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
|
1859
|
+
}),
|
|
1860
|
+
sourcesContent: this.uniqueSources.map((source) => {
|
|
1861
|
+
return options.includeContent ? source.content : null;
|
|
1862
|
+
}),
|
|
1863
|
+
names,
|
|
1864
|
+
mappings: mappings.raw,
|
|
1865
|
+
x_google_ignoreList,
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
generateMap(options) {
|
|
1870
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
getIndentString() {
|
|
1874
|
+
const indentStringCounts = {};
|
|
1875
|
+
|
|
1876
|
+
this.sources.forEach((source) => {
|
|
1877
|
+
const indentStr = source.content._getRawIndentString();
|
|
1878
|
+
|
|
1879
|
+
if (indentStr === null) return;
|
|
1880
|
+
|
|
1881
|
+
if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
|
|
1882
|
+
indentStringCounts[indentStr] += 1;
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1885
|
+
return (
|
|
1886
|
+
Object.keys(indentStringCounts).sort((a, b) => {
|
|
1887
|
+
return indentStringCounts[a] - indentStringCounts[b];
|
|
1888
|
+
})[0] || '\t'
|
|
1889
|
+
);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
indent(indentStr) {
|
|
1893
|
+
if (!arguments.length) {
|
|
1894
|
+
indentStr = this.getIndentString();
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
if (indentStr === '') return this; // noop
|
|
1898
|
+
|
|
1899
|
+
let trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
|
|
1900
|
+
|
|
1901
|
+
this.sources.forEach((source, i) => {
|
|
1902
|
+
const separator = source.separator !== undefined ? source.separator : this.separator;
|
|
1903
|
+
const indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator));
|
|
1904
|
+
|
|
1905
|
+
source.content.indent(indentStr, {
|
|
1906
|
+
exclude: source.indentExclusionRanges,
|
|
1907
|
+
indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
|
|
1908
|
+
});
|
|
1909
|
+
|
|
1910
|
+
trailingNewline = source.content.lastChar() === '\n';
|
|
1911
|
+
});
|
|
1912
|
+
|
|
1913
|
+
if (this.intro) {
|
|
1914
|
+
this.intro =
|
|
1915
|
+
indentStr +
|
|
1916
|
+
this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
1917
|
+
return index > 0 ? indentStr + match : match;
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
return this;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
prepend(str) {
|
|
1925
|
+
this.intro = str + this.intro;
|
|
1926
|
+
return this;
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
toString() {
|
|
1930
|
+
const body = this.sources
|
|
1931
|
+
.map((source, i) => {
|
|
1932
|
+
const separator = source.separator !== undefined ? source.separator : this.separator;
|
|
1933
|
+
const str = (i > 0 ? separator : '') + source.content.toString();
|
|
1934
|
+
|
|
1935
|
+
return str;
|
|
1936
|
+
})
|
|
1937
|
+
.join('');
|
|
1938
|
+
|
|
1939
|
+
return this.intro + body;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
isEmpty() {
|
|
1943
|
+
if (this.intro.length && this.intro.trim()) return false;
|
|
1944
|
+
if (this.sources.some((source) => !source.content.isEmpty())) return false;
|
|
1945
|
+
return true;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
length() {
|
|
1949
|
+
return this.sources.reduce(
|
|
1950
|
+
(length, source) => length + source.content.length(),
|
|
1951
|
+
this.intro.length,
|
|
1952
|
+
);
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
trimLines() {
|
|
1956
|
+
return this.trim('[\\r\\n]');
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
trim(charType) {
|
|
1960
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
trimStart(charType) {
|
|
1964
|
+
const rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1965
|
+
this.intro = this.intro.replace(rx, '');
|
|
1966
|
+
|
|
1967
|
+
if (!this.intro) {
|
|
1968
|
+
let source;
|
|
1969
|
+
let i = 0;
|
|
1970
|
+
|
|
1971
|
+
do {
|
|
1972
|
+
source = this.sources[i++];
|
|
1973
|
+
if (!source) {
|
|
1974
|
+
break;
|
|
1975
|
+
}
|
|
1976
|
+
} while (!source.content.trimStartAborted(charType));
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
return this;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
trimEnd(charType) {
|
|
1983
|
+
const rx = new RegExp((charType || '\\s') + '+$');
|
|
1984
|
+
|
|
1985
|
+
let source;
|
|
1986
|
+
let i = this.sources.length - 1;
|
|
1987
|
+
|
|
1988
|
+
do {
|
|
1989
|
+
source = this.sources[i--];
|
|
1990
|
+
if (!source) {
|
|
1991
|
+
this.intro = this.intro.replace(rx, '');
|
|
1992
|
+
break;
|
|
1993
|
+
}
|
|
1994
|
+
} while (!source.content.trimEndAborted(charType));
|
|
1995
|
+
|
|
1996
|
+
return this;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
export { Bundle, SourceMap, MagicString as default };
|
|
2001
|
+
//# sourceMappingURL=dep-Dl5DFuGU.js.map
|