@getcortexlabs/mavis 0.1.0-alpha.3 → 0.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/files.d.ts +4 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +3 -0
- package/dist/files.js.map +1 -0
- package/dist/native/avatar-image.d.ts +4 -0
- package/dist/native/avatar-image.d.ts.map +1 -0
- package/dist/native/avatar-image.js +12 -0
- package/dist/native/avatar-image.js.map +1 -0
- package/dist/native/avatar-label.android.d.ts +9 -0
- package/dist/native/avatar-label.android.d.ts.map +1 -0
- package/dist/native/avatar-label.android.js +9 -0
- package/dist/native/avatar-label.android.js.map +1 -0
- package/dist/native/avatar-label.d.ts +2 -0
- package/dist/native/avatar-label.d.ts.map +1 -0
- package/dist/native/avatar-label.js +2 -0
- package/dist/native/avatar-label.js.map +1 -0
- package/dist/native/box.ios.d.ts.map +1 -1
- package/dist/native/box.ios.js +16 -1
- package/dist/native/box.ios.js.map +1 -1
- package/dist/native/button.ios.d.ts +9 -1
- package/dist/native/button.ios.d.ts.map +1 -1
- package/dist/native/button.ios.js +17 -1
- package/dist/native/button.ios.js.map +1 -1
- package/dist/native/checkbox.android.d.ts +7 -0
- package/dist/native/checkbox.android.d.ts.map +1 -0
- package/dist/native/checkbox.android.js +26 -0
- package/dist/native/checkbox.android.js.map +1 -0
- package/dist/native/checkbox.d.ts +7 -0
- package/dist/native/checkbox.d.ts.map +1 -0
- package/dist/native/checkbox.js +7 -0
- package/dist/native/checkbox.js.map +1 -0
- package/dist/native/combobox-editor.android.d.ts +3 -0
- package/dist/native/combobox-editor.android.d.ts.map +1 -0
- package/dist/native/combobox-editor.android.js +5 -0
- package/dist/native/combobox-editor.android.js.map +1 -0
- package/dist/native/combobox-editor.d.ts +4 -0
- package/dist/native/combobox-editor.d.ts.map +1 -0
- package/dist/native/combobox-editor.js +5 -0
- package/dist/native/combobox-editor.js.map +1 -0
- package/dist/native/composed-button.android.d.ts +4 -0
- package/dist/native/composed-button.android.d.ts.map +1 -0
- package/dist/native/composed-button.android.js +53 -0
- package/dist/native/composed-button.android.js.map +1 -0
- package/dist/native/composed-button.d.ts +3 -0
- package/dist/native/composed-button.d.ts.map +1 -0
- package/dist/native/composed-button.js +4 -0
- package/dist/native/composed-button.js.map +1 -0
- package/dist/native/dialog.android.d.ts +12 -0
- package/dist/native/dialog.android.d.ts.map +1 -0
- package/dist/native/dialog.android.js +46 -0
- package/dist/native/dialog.android.js.map +1 -0
- package/dist/native/dialog.d.ts +12 -0
- package/dist/native/dialog.d.ts.map +1 -0
- package/dist/native/dialog.ios.d.ts +12 -0
- package/dist/native/dialog.ios.d.ts.map +1 -0
- package/dist/native/dialog.ios.js +13 -0
- package/dist/native/dialog.ios.js.map +1 -0
- package/dist/native/dialog.js +4 -0
- package/dist/native/dialog.js.map +1 -0
- package/dist/native/dynamic-type.d.ts +15 -0
- package/dist/native/dynamic-type.d.ts.map +1 -0
- package/dist/native/dynamic-type.js +47 -0
- package/dist/native/dynamic-type.js.map +1 -0
- package/dist/native/file-access.d.ts +23 -0
- package/dist/native/file-access.d.ts.map +1 -0
- package/dist/native/file-access.js +55 -0
- package/dist/native/file-access.js.map +1 -0
- package/dist/native/file-picker.android.d.ts +3 -0
- package/dist/native/file-picker.android.d.ts.map +1 -0
- package/dist/native/file-picker.android.js +147 -0
- package/dist/native/file-picker.android.js.map +1 -0
- package/dist/native/file-picker.d.ts +4 -0
- package/dist/native/file-picker.d.ts.map +1 -0
- package/dist/native/file-picker.ios.d.ts +3 -0
- package/dist/native/file-picker.ios.d.ts.map +1 -0
- package/dist/native/file-picker.ios.js +152 -0
- package/dist/native/file-picker.ios.js.map +1 -0
- package/dist/native/file-picker.js +7 -0
- package/dist/native/file-picker.js.map +1 -0
- package/dist/native/flex-layout.ios.d.ts +5 -0
- package/dist/native/flex-layout.ios.d.ts.map +1 -1
- package/dist/native/flex-layout.ios.js +63 -2
- package/dist/native/flex-layout.ios.js.map +1 -1
- package/dist/native/input-action.d.ts +5 -0
- package/dist/native/input-action.d.ts.map +1 -0
- package/dist/native/input-action.js +13 -0
- package/dist/native/input-action.js.map +1 -0
- package/dist/native/keyboard-dismiss.ios.d.ts.map +1 -1
- package/dist/native/keyboard-dismiss.ios.js +3 -0
- package/dist/native/keyboard-dismiss.ios.js.map +1 -1
- package/dist/native/label.android.d.ts +12 -0
- package/dist/native/label.android.d.ts.map +1 -0
- package/dist/native/label.android.js +19 -0
- package/dist/native/label.android.js.map +1 -0
- package/dist/native/label.ios.d.ts +10 -1
- package/dist/native/label.ios.d.ts.map +1 -1
- package/dist/native/label.ios.js +25 -1
- package/dist/native/label.ios.js.map +1 -1
- package/dist/native/motion-owner.d.ts +5 -0
- package/dist/native/motion-owner.d.ts.map +1 -0
- package/dist/native/motion-owner.js +53 -0
- package/dist/native/motion-owner.js.map +1 -0
- package/dist/native/motion-region.d.ts +6 -0
- package/dist/native/motion-region.d.ts.map +1 -0
- package/dist/native/motion-region.js +199 -0
- package/dist/native/motion-region.js.map +1 -0
- package/dist/native/motion-surface.d.ts +9 -0
- package/dist/native/motion-surface.d.ts.map +1 -0
- package/dist/native/motion-surface.js +137 -0
- package/dist/native/motion-surface.js.map +1 -0
- package/dist/native/press.d.ts +5 -2
- package/dist/native/press.d.ts.map +1 -1
- package/dist/native/press.js +52 -8
- package/dist/native/press.js.map +1 -1
- package/dist/native/progress.d.ts +7 -0
- package/dist/native/progress.d.ts.map +1 -0
- package/dist/native/progress.js +77 -0
- package/dist/native/progress.js.map +1 -0
- package/dist/native/scroll-motion.d.ts +12 -0
- package/dist/native/scroll-motion.d.ts.map +1 -0
- package/dist/native/scroll-motion.js +100 -0
- package/dist/native/scroll-motion.js.map +1 -0
- package/dist/native/segmented.d.ts +14 -0
- package/dist/native/segmented.d.ts.map +1 -0
- package/dist/native/segmented.js +86 -0
- package/dist/native/segmented.js.map +1 -0
- package/dist/native/sheet.android.d.ts +5 -1
- package/dist/native/sheet.android.d.ts.map +1 -1
- package/dist/native/sheet.android.js +2 -2
- package/dist/native/sheet.android.js.map +1 -1
- package/dist/native/sheet.d.ts +5 -1
- package/dist/native/sheet.d.ts.map +1 -1
- package/dist/native/sheet.ios.d.ts +5 -1
- package/dist/native/sheet.ios.d.ts.map +1 -1
- package/dist/native/sheet.ios.js +12 -3
- package/dist/native/sheet.ios.js.map +1 -1
- package/dist/native/sheet.js +2 -2
- package/dist/native/sheet.js.map +1 -1
- package/dist/native/tabs.android.d.ts +3 -0
- package/dist/native/tabs.android.d.ts.map +1 -0
- package/dist/native/tabs.android.js +29 -0
- package/dist/native/tabs.android.js.map +1 -0
- package/dist/native/tabs.d.ts +3 -0
- package/dist/native/tabs.d.ts.map +1 -0
- package/dist/native/tabs.js +4 -0
- package/dist/native/tabs.js.map +1 -0
- package/dist/native/text-field.android.d.ts +1 -0
- package/dist/native/text-field.android.d.ts.map +1 -1
- package/dist/native/text-field.android.js +13 -0
- package/dist/native/text-field.android.js.map +1 -1
- package/dist/native/text-field.ios.d.ts +9 -0
- package/dist/native/text-field.ios.d.ts.map +1 -0
- package/dist/native/text-field.ios.js +52 -0
- package/dist/native/text-field.ios.js.map +1 -0
- package/dist/native/text-view.ios.d.ts +7 -0
- package/dist/native/text-view.ios.d.ts.map +1 -0
- package/dist/native/text-view.ios.js +10 -0
- package/dist/native/text-view.ios.js.map +1 -0
- package/dist/native/toast.android.d.ts +4 -0
- package/dist/native/toast.android.d.ts.map +1 -0
- package/dist/native/toast.android.js +10 -0
- package/dist/native/toast.android.js.map +1 -0
- package/dist/native/toast.d.ts +4 -0
- package/dist/native/toast.d.ts.map +1 -0
- package/dist/native/toast.ios.d.ts +4 -0
- package/dist/native/toast.ios.d.ts.map +1 -0
- package/dist/native/toast.ios.js +8 -0
- package/dist/native/toast.ios.js.map +1 -0
- package/dist/native/toast.js +5 -0
- package/dist/native/toast.js.map +1 -0
- package/dist/vue/components/ChoiceControl.d.ts +111 -0
- package/dist/vue/components/ChoiceControl.d.ts.map +1 -0
- package/dist/vue/components/ChoiceControl.js +196 -0
- package/dist/vue/components/ChoiceControl.js.map +1 -0
- package/dist/vue/components/DateCalendar.d.ts +94 -0
- package/dist/vue/components/DateCalendar.d.ts.map +1 -0
- package/dist/vue/components/DateCalendar.js +96 -0
- package/dist/vue/components/DateCalendar.js.map +1 -0
- package/dist/vue/components/MAccordion.d.ts +119 -0
- package/dist/vue/components/MAccordion.d.ts.map +1 -0
- package/dist/vue/components/MAccordion.js +83 -0
- package/dist/vue/components/MAccordion.js.map +1 -0
- package/dist/vue/components/MAlert.d.ts +109 -0
- package/dist/vue/components/MAlert.d.ts.map +1 -0
- package/dist/vue/components/MAlert.js +126 -0
- package/dist/vue/components/MAlert.js.map +1 -0
- package/dist/vue/components/MAvatar.d.ts +80 -0
- package/dist/vue/components/MAvatar.d.ts.map +1 -0
- package/dist/vue/components/MAvatar.js +86 -0
- package/dist/vue/components/MAvatar.js.map +1 -0
- package/dist/vue/components/MBadge.d.ts +70 -0
- package/dist/vue/components/MBadge.d.ts.map +1 -0
- package/dist/vue/components/MBadge.js +30 -0
- package/dist/vue/components/MBadge.js.map +1 -0
- package/dist/vue/components/MButton.d.ts +126 -32
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +129 -11
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +70 -24
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +14 -4
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MCheckbox.d.ts +103 -0
- package/dist/vue/components/MCheckbox.d.ts.map +1 -0
- package/dist/vue/components/MCheckbox.js +26 -0
- package/dist/vue/components/MCheckbox.js.map +1 -0
- package/dist/vue/components/MChip.d.ts +117 -0
- package/dist/vue/components/MChip.d.ts.map +1 -0
- package/dist/vue/components/MChip.js +120 -0
- package/dist/vue/components/MChip.js.map +1 -0
- package/dist/vue/components/MCombobox.d.ts +279 -0
- package/dist/vue/components/MCombobox.d.ts.map +1 -0
- package/dist/vue/components/MCombobox.js +234 -0
- package/dist/vue/components/MCombobox.js.map +1 -0
- package/dist/vue/components/MDatePicker.d.ts +1254 -0
- package/dist/vue/components/MDatePicker.d.ts.map +1 -0
- package/dist/vue/components/MDatePicker.js +35 -0
- package/dist/vue/components/MDatePicker.js.map +1 -0
- package/dist/vue/components/MDialog.d.ts +97 -0
- package/dist/vue/components/MDialog.d.ts.map +1 -0
- package/dist/vue/components/MDialog.js +245 -0
- package/dist/vue/components/MDialog.js.map +1 -0
- package/dist/vue/components/MEmptyState.d.ts +117 -0
- package/dist/vue/components/MEmptyState.d.ts.map +1 -0
- package/dist/vue/components/MEmptyState.js +79 -0
- package/dist/vue/components/MEmptyState.js.map +1 -0
- package/dist/vue/components/MFilePicker.d.ts +112 -0
- package/dist/vue/components/MFilePicker.d.ts.map +1 -0
- package/dist/vue/components/MFilePicker.js +196 -0
- package/dist/vue/components/MFilePicker.js.map +1 -0
- package/dist/vue/components/MIcon.d.ts +5 -3
- package/dist/vue/components/MIcon.d.ts.map +1 -1
- package/dist/vue/components/MInput.d.ts +178 -51
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +88 -14
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MListItem.d.ts +104 -0
- package/dist/vue/components/MListItem.d.ts.map +1 -0
- package/dist/vue/components/MListItem.js +53 -0
- package/dist/vue/components/MListItem.js.map +1 -0
- package/dist/vue/components/MProgress.d.ts +122 -0
- package/dist/vue/components/MProgress.d.ts.map +1 -0
- package/dist/vue/components/MProgress.js +75 -0
- package/dist/vue/components/MProgress.js.map +1 -0
- package/dist/vue/components/MRadioGroup.d.ts +103 -0
- package/dist/vue/components/MRadioGroup.d.ts.map +1 -0
- package/dist/vue/components/MRadioGroup.js +57 -0
- package/dist/vue/components/MRadioGroup.js.map +1 -0
- package/dist/vue/components/MReveal.d.ts +75 -39
- package/dist/vue/components/MReveal.d.ts.map +1 -1
- package/dist/vue/components/MReveal.js +5 -7
- package/dist/vue/components/MReveal.js.map +1 -1
- package/dist/vue/components/MScreen.d.ts +21 -6
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +19 -4
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSegmentedControl.d.ts +95 -0
- package/dist/vue/components/MSegmentedControl.d.ts.map +1 -0
- package/dist/vue/components/MSegmentedControl.js +172 -0
- package/dist/vue/components/MSegmentedControl.js.map +1 -0
- package/dist/vue/components/MSelect.d.ts +140 -0
- package/dist/vue/components/MSelect.d.ts.map +1 -0
- package/dist/vue/components/MSelect.js +158 -0
- package/dist/vue/components/MSelect.js.map +1 -0
- package/dist/vue/components/MSeparator.d.ts +56 -0
- package/dist/vue/components/MSeparator.d.ts.map +1 -0
- package/dist/vue/components/MSeparator.js +36 -0
- package/dist/vue/components/MSeparator.js.map +1 -0
- package/dist/vue/components/MSheet.d.ts +26 -14
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/MSheet.js +66 -34
- package/dist/vue/components/MSheet.js.map +1 -1
- package/dist/vue/components/MSkeleton.d.ts +78 -0
- package/dist/vue/components/MSkeleton.d.ts.map +1 -0
- package/dist/vue/components/MSkeleton.js +87 -0
- package/dist/vue/components/MSkeleton.js.map +1 -0
- package/dist/vue/components/MSlider.d.ts +8 -4
- package/dist/vue/components/MSlider.d.ts.map +1 -1
- package/dist/vue/components/MSlider.js +2 -1
- package/dist/vue/components/MSlider.js.map +1 -1
- package/dist/vue/components/MSwitch.d.ts +89 -0
- package/dist/vue/components/MSwitch.d.ts.map +1 -0
- package/dist/vue/components/MSwitch.js +163 -0
- package/dist/vue/components/MSwitch.js.map +1 -0
- package/dist/vue/components/MTabs.d.ts +101 -0
- package/dist/vue/components/MTabs.d.ts.map +1 -0
- package/dist/vue/components/MTabs.js +245 -0
- package/dist/vue/components/MTabs.js.map +1 -0
- package/dist/vue/components/MText.d.ts +51 -26
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +43 -17
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/MToast.d.ts +23 -0
- package/dist/vue/components/MToast.d.ts.map +1 -0
- package/dist/vue/components/MToast.js +242 -0
- package/dist/vue/components/MToast.js.map +1 -0
- package/dist/vue/components/layout.d.ts +206 -97
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +6 -4
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/components/workflows.d.ts +251 -0
- package/dist/vue/components/workflows.d.ts.map +1 -0
- package/dist/vue/components/workflows.js +35 -0
- package/dist/vue/components/workflows.js.map +1 -0
- package/dist/vue/index.d.ts +29 -3
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +56 -4
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/layers.d.ts +2 -0
- package/dist/vue/layers.d.ts.map +1 -1
- package/dist/vue/layers.js.map +1 -1
- package/dist/vue/reveal-motion.d.ts +13 -0
- package/dist/vue/reveal-motion.d.ts.map +1 -0
- package/dist/vue/reveal-motion.js +55 -0
- package/dist/vue/reveal-motion.js.map +1 -0
- package/dist/vue/use-motion-region.d.ts +7 -0
- package/dist/vue/use-motion-region.d.ts.map +1 -0
- package/dist/vue/use-motion-region.js +28 -0
- package/dist/vue/use-motion-region.js.map +1 -0
- package/dist/vue/use-motion-surface.d.ts +8 -0
- package/dist/vue/use-motion-surface.d.ts.map +1 -0
- package/dist/vue/use-motion-surface.js +76 -0
- package/dist/vue/use-motion-surface.js.map +1 -0
- package/dist/vue/use-press.d.ts +1 -1
- package/dist/vue/use-press.d.ts.map +1 -1
- package/dist/vue/use-press.js +12 -4
- package/dist/vue/use-press.js.map +1 -1
- package/dist/vue/use-scroll-motion.d.ts +7 -0
- package/dist/vue/use-scroll-motion.d.ts.map +1 -0
- package/dist/vue/use-scroll-motion.js +30 -0
- package/dist/vue/use-scroll-motion.js.map +1 -0
- package/package.json +3 -3
- package/platforms/android/java/com/mavis/ui/Box.java +3 -1
- package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
- package/platforms/android/java/com/mavis/ui/FlexLayout.java +5 -1
- package/src/files.ts +3 -0
- package/src/native/avatar-image.ts +9 -0
- package/src/native/avatar-label.android.ts +14 -0
- package/src/native/avatar-label.ts +1 -0
- package/src/native/box.ios.ts +21 -1
- package/src/native/button.ios.ts +40 -2
- package/src/native/checkbox.android.ts +35 -0
- package/src/native/checkbox.ts +9 -0
- package/src/native/combobox-editor.android.ts +11 -0
- package/src/native/combobox-editor.ts +6 -0
- package/src/native/composed-button.android.ts +74 -0
- package/src/native/composed-button.ts +9 -0
- package/src/native/dialog.android.ts +56 -0
- package/src/native/dialog.ios.ts +23 -0
- package/src/native/dialog.ts +10 -0
- package/src/native/dynamic-type.ts +71 -0
- package/src/native/file-access.ts +71 -0
- package/src/native/file-picker.android.ts +191 -0
- package/src/native/file-picker.ios.ts +230 -0
- package/src/native/file-picker.ts +8 -0
- package/src/native/flex-layout.ios.ts +74 -2
- package/src/native/input-action.ts +15 -0
- package/src/native/keyboard-dismiss.ios.ts +2 -0
- package/src/native/label.android.ts +27 -0
- package/src/native/label.ios.ts +40 -1
- package/src/native/motion-owner.ts +59 -0
- package/src/native/motion-region.ts +213 -0
- package/src/native/motion-surface.ts +162 -0
- package/src/native/press.ts +52 -10
- package/src/native/progress.ts +78 -0
- package/src/native/scroll-motion.ts +106 -0
- package/src/native/segmented.ts +95 -0
- package/src/native/sheet.android.ts +2 -2
- package/src/native/sheet.ios.ts +12 -3
- package/src/native/sheet.ts +2 -2
- package/src/native/tabs.android.ts +58 -0
- package/src/native/tabs.ts +8 -0
- package/src/native/text-field.android.ts +19 -0
- package/src/native/text-field.ios.ts +53 -0
- package/src/native/text-view.ios.ts +10 -0
- package/src/native/toast.android.ts +9 -0
- package/src/native/toast.ios.ts +13 -0
- package/src/native/toast.ts +6 -0
- package/src/vue/components/ChoiceControl.ts +238 -0
- package/src/vue/components/DateCalendar.ts +117 -0
- package/src/vue/components/MAccordion.ts +123 -0
- package/src/vue/components/MAlert.ts +156 -0
- package/src/vue/components/MAvatar.ts +103 -0
- package/src/vue/components/MBadge.ts +34 -0
- package/src/vue/components/MButton.ts +176 -9
- package/src/vue/components/MCard.ts +23 -3
- package/src/vue/components/MCheckbox.ts +25 -0
- package/src/vue/components/MChip.ts +134 -0
- package/src/vue/components/MCombobox.ts +257 -0
- package/src/vue/components/MDatePicker.ts +33 -0
- package/src/vue/components/MDialog.ts +312 -0
- package/src/vue/components/MEmptyState.ts +96 -0
- package/src/vue/components/MFilePicker.ts +226 -0
- package/src/vue/components/MInput.ts +96 -12
- package/src/vue/components/MListItem.ts +66 -0
- package/src/vue/components/MProgress.ts +94 -0
- package/src/vue/components/MRadioGroup.ts +64 -0
- package/src/vue/components/MReveal.ts +6 -7
- package/src/vue/components/MScreen.ts +21 -6
- package/src/vue/components/MSegmentedControl.ts +214 -0
- package/src/vue/components/MSelect.ts +185 -0
- package/src/vue/components/MSeparator.ts +40 -0
- package/src/vue/components/MSheet.ts +83 -43
- package/src/vue/components/MSkeleton.ts +100 -0
- package/src/vue/components/MSlider.ts +7 -1
- package/src/vue/components/MSwitch.ts +187 -0
- package/src/vue/components/MTabs.ts +302 -0
- package/src/vue/components/MText.ts +37 -6
- package/src/vue/components/MToast.ts +289 -0
- package/src/vue/components/layout.ts +6 -3
- package/src/vue/components/workflows.ts +38 -0
- package/src/vue/index.ts +93 -2
- package/src/vue/layers.ts +2 -0
- package/src/vue/reveal-motion.ts +61 -0
- package/src/vue/use-motion-region.ts +29 -0
- package/src/vue/use-motion-surface.ts +84 -0
- package/src/vue/use-press.ts +12 -4
- package/src/vue/use-scroll-motion.ts +31 -0
- package/dist/native/input-description.android.d.ts +0 -4
- package/dist/native/input-description.android.d.ts.map +0 -1
- package/dist/native/input-description.android.js +0 -18
- package/dist/native/input-description.android.js.map +0 -1
- package/dist/theme/resolve.d.ts +0 -3
- package/dist/theme/resolve.d.ts.map +0 -1
- package/dist/theme/resolve.js +0 -8
- package/dist/theme/resolve.js.map +0 -1
- package/dist/theme/themes.d.ts +0 -6
- package/dist/theme/themes.d.ts.map +0 -1
- package/dist/theme/themes.js +0 -83
- package/dist/theme/themes.js.map +0 -1
- package/dist/theme/types.d.ts +0 -50
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js +0 -2
- package/dist/theme/types.js.map +0 -1
- package/dist/vue/global-components.d.ts +0 -21
- package/dist/vue/global-components.d.ts.map +0 -1
- package/dist/vue/global-components.js +0 -2
- package/dist/vue/global-components.js.map +0 -1
- package/dist/vue/layout-context.d.ts +0 -5
- package/dist/vue/layout-context.d.ts.map +0 -1
- package/dist/vue/layout-context.js +0 -7
- package/dist/vue/layout-context.js.map +0 -1
- package/dist/vue/text-content.d.ts +0 -4
- package/dist/vue/text-content.d.ts.map +0 -1
- package/dist/vue/text-content.js +0 -17
- package/dist/vue/text-content.js.map +0 -1
- package/dist/vue/theme.d.ts +0 -177
- package/dist/vue/theme.d.ts.map +0 -1
- package/dist/vue/theme.js +0 -17
- package/dist/vue/theme.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core'
|
|
2
|
+
import { notifyAccessibilityLayout } from './accessibility-layout'
|
|
3
|
+
export interface DialogFocusViews {
|
|
4
|
+
panel: View
|
|
5
|
+
title: View
|
|
6
|
+
cancel: View
|
|
7
|
+
confirm: View
|
|
8
|
+
}
|
|
9
|
+
declare function UIAccessibilityFocusedElement(technology: string): unknown
|
|
10
|
+
declare const UIAccessibilityNotificationVoiceOverIdentifier: string
|
|
11
|
+
declare const UIAccessibilityLayoutChangedNotification: number
|
|
12
|
+
declare function UIAccessibilityPostNotification(notification: number, argument: unknown): void
|
|
13
|
+
export function bindDialogFocus(views: DialogFocusViews, _escape: () => void) {
|
|
14
|
+
const previous = UIAccessibilityFocusedElement(UIAccessibilityNotificationVoiceOverIdentifier)
|
|
15
|
+
notifyAccessibilityLayout(views.title)
|
|
16
|
+
return {
|
|
17
|
+
update(_loading: boolean) {},
|
|
18
|
+
dispose(restore: boolean) {
|
|
19
|
+
if (restore && previous)
|
|
20
|
+
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, previous)
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core'
|
|
2
|
+
export interface DialogFocusViews {
|
|
3
|
+
panel: View
|
|
4
|
+
title: View
|
|
5
|
+
cancel: View
|
|
6
|
+
confirm: View
|
|
7
|
+
}
|
|
8
|
+
export function bindDialogFocus(_views: DialogFocusViews, _escape: () => void) {
|
|
9
|
+
return { update(_loading: boolean) {}, dispose(_restore: boolean) {} }
|
|
10
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Font, type TextBase } from '@nativescript/core'
|
|
2
|
+
import type { TextVariant } from '@getcortexlabs/mavis-core'
|
|
3
|
+
|
|
4
|
+
interface Metrics {
|
|
5
|
+
scaledValueForValueCompatibleWithTraitCollection(value: number, traits: unknown): number
|
|
6
|
+
}
|
|
7
|
+
declare const UIApplication: { sharedApplication: { preferredContentSizeCategory: string } }
|
|
8
|
+
declare const UITraitCollection: {
|
|
9
|
+
traitCollectionWithPreferredContentSizeCategory(category: string): unknown
|
|
10
|
+
}
|
|
11
|
+
declare const UIFontMetrics: { metricsForTextStyle(style: string): Metrics }
|
|
12
|
+
declare const UIButton: unknown
|
|
13
|
+
declare const UIFontTextStyleLargeTitle: string
|
|
14
|
+
declare const UIFontTextStyleTitle1: string
|
|
15
|
+
declare const UIFontTextStyleTitle3: string
|
|
16
|
+
declare const UIFontTextStyleBody: string
|
|
17
|
+
declare const UIFontTextStyleFootnote: string
|
|
18
|
+
declare const UIFontTextStyleCaption2: string
|
|
19
|
+
|
|
20
|
+
export interface DynamicTypeView extends TextBase {
|
|
21
|
+
dynamicTypeStyle?: TextVariant
|
|
22
|
+
}
|
|
23
|
+
interface NativeText {
|
|
24
|
+
font: { pointSize: number }
|
|
25
|
+
titleLabel?: { font: { pointSize: number } }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The iOS text style whose default size is closest to each Mavis variant.
|
|
29
|
+
const textStyle = (variant: TextVariant) =>
|
|
30
|
+
({
|
|
31
|
+
display: UIFontTextStyleLargeTitle,
|
|
32
|
+
title: UIFontTextStyleTitle1,
|
|
33
|
+
heading: UIFontTextStyleTitle3,
|
|
34
|
+
body: UIFontTextStyleBody,
|
|
35
|
+
caption: UIFontTextStyleFootnote,
|
|
36
|
+
overline: UIFontTextStyleCaption2,
|
|
37
|
+
})[variant]
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The ratio iOS applies to a font of `size` points in the view's text style at the current
|
|
41
|
+
* content size category. Core maps the categories to its own table, which halves text at the
|
|
42
|
+
* smallest size and snaps any other value back to it, so Mavis reads the system's Dynamic Type
|
|
43
|
+
* curve instead. The curve is not linear since iOS 17, so the ratio depends on the size.
|
|
44
|
+
*/
|
|
45
|
+
export function dynamicTypeScale(view: DynamicTypeView, size: number): number {
|
|
46
|
+
if (!view.iosAccessibilityAdjustsFontSize || !(size > 0)) return 1
|
|
47
|
+
const category = UIApplication.sharedApplication.preferredContentSizeCategory
|
|
48
|
+
const traits = UITraitCollection.traitCollectionWithPreferredContentSizeCategory(category)
|
|
49
|
+
const metrics = UIFontMetrics.metricsForTextStyle(textStyle(view.dynamicTypeStyle ?? 'body'))
|
|
50
|
+
let scale = metrics.scaledValueForValueCompatibleWithTraitCollection(size, traits) / size
|
|
51
|
+
const { iosAccessibilityMinFontScale: min, iosAccessibilityMaxFontScale: max } = view
|
|
52
|
+
if (min && min > scale) scale = min
|
|
53
|
+
if (max && max < scale) scale = max
|
|
54
|
+
return scale
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Core's font scale setter with the system ratio in place of Core's table. */
|
|
58
|
+
export function applyDynamicType(view: DynamicTypeView) {
|
|
59
|
+
const native = view.nativeTextViewProtected as NativeText | undefined
|
|
60
|
+
if (!native) return
|
|
61
|
+
const label =
|
|
62
|
+
native instanceof (UIButton as never) && native.titleLabel ? native.titleLabel : native
|
|
63
|
+
const font = view.style.fontInternal || Font.default.withFontSize(label.font.pointSize)
|
|
64
|
+
const scale = dynamicTypeScale(view, font.fontSize)
|
|
65
|
+
if (font.fontScale !== scale) {
|
|
66
|
+
view.style.fontInternal = font.withFontScale(scale)
|
|
67
|
+
view.requestLayout()
|
|
68
|
+
} else if (!view.style.fontInternal) {
|
|
69
|
+
view.style.fontInternal = font
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FileHandle } from '@getcortexlabs/mavis-core'
|
|
2
|
+
|
|
3
|
+
export interface NativeFileReadHandle {
|
|
4
|
+
/** Android java.io.InputStream or an opened iOS NSInputStream. */
|
|
5
|
+
readonly native: unknown
|
|
6
|
+
close(): void
|
|
7
|
+
}
|
|
8
|
+
export interface NativeFileAccess {
|
|
9
|
+
readonly platform: 'android' | 'ios'
|
|
10
|
+
/** Android content Uri or iOS NSURL. Never a portable filesystem path. */
|
|
11
|
+
readonly native: unknown
|
|
12
|
+
/** Close after use. Removing/disposal also closes streams still owned by this handle. */
|
|
13
|
+
openRead(): NativeFileReadHandle
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const handles = new WeakMap<FileHandle, NativeFileAccess>()
|
|
17
|
+
|
|
18
|
+
export function getNativeFile(handle: FileHandle): NativeFileAccess {
|
|
19
|
+
const access = handles.get(handle)
|
|
20
|
+
if (!access) throw new Error('This native file handle is unavailable or has been released')
|
|
21
|
+
return access
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** @internal Platform adapters register a resource without exposing it in item metadata. */
|
|
25
|
+
export function ownNativeFile(
|
|
26
|
+
platform: NativeFileAccess['platform'],
|
|
27
|
+
native: unknown,
|
|
28
|
+
open: () => { native: unknown; close(): void },
|
|
29
|
+
cleanup: () => void,
|
|
30
|
+
) {
|
|
31
|
+
const handle = Object.freeze({}) as FileHandle
|
|
32
|
+
const readers = new Set<NativeFileReadHandle>()
|
|
33
|
+
let released = false
|
|
34
|
+
const access: NativeFileAccess = {
|
|
35
|
+
platform,
|
|
36
|
+
native,
|
|
37
|
+
openRead() {
|
|
38
|
+
if (released) throw new Error('This native file has been released')
|
|
39
|
+
const reader = open()
|
|
40
|
+
let closed = false
|
|
41
|
+
const owned = {
|
|
42
|
+
native: reader.native,
|
|
43
|
+
close() {
|
|
44
|
+
if (closed) return
|
|
45
|
+
closed = true
|
|
46
|
+
readers.delete(owned)
|
|
47
|
+
reader.close()
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
readers.add(owned)
|
|
51
|
+
return owned
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
handles.set(handle, access)
|
|
55
|
+
return {
|
|
56
|
+
handle,
|
|
57
|
+
release() {
|
|
58
|
+
if (released) return
|
|
59
|
+
released = true
|
|
60
|
+
handles.delete(handle)
|
|
61
|
+
for (const reader of readers) {
|
|
62
|
+
try {
|
|
63
|
+
reader.close()
|
|
64
|
+
} catch {
|
|
65
|
+
/* continue cleanup */
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
cleanup()
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Application, ImageSource } from '@nativescript/core'
|
|
2
|
+
import { SDK_VERSION } from '@nativescript/core/utils/constants'
|
|
3
|
+
import type { FilePickerAdapter, SelectedFile } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { ownNativeFile } from './file-access.js'
|
|
5
|
+
|
|
6
|
+
interface Uri {
|
|
7
|
+
toString(): string
|
|
8
|
+
getLastPathSegment(): string
|
|
9
|
+
}
|
|
10
|
+
interface Stream {
|
|
11
|
+
close(): void
|
|
12
|
+
}
|
|
13
|
+
interface Cursor {
|
|
14
|
+
moveToFirst(): boolean
|
|
15
|
+
getColumnIndex(name: string): number
|
|
16
|
+
isNull(index: number): boolean
|
|
17
|
+
getString(index: number): string
|
|
18
|
+
getLong(index: number): number
|
|
19
|
+
close(): void
|
|
20
|
+
}
|
|
21
|
+
interface Resolver {
|
|
22
|
+
getType(uri: Uri): string | null
|
|
23
|
+
query(uri: Uri, projection: null, selection: null, args: null, order: null): Cursor | null
|
|
24
|
+
openInputStream(uri: Uri): Stream | null
|
|
25
|
+
loadThumbnail(uri: Uri, size: unknown, cancellation: null): unknown
|
|
26
|
+
}
|
|
27
|
+
interface Intent {
|
|
28
|
+
addCategory(value: string): Intent
|
|
29
|
+
setType(type: string): Intent
|
|
30
|
+
putExtra(name: string, value: unknown): Intent
|
|
31
|
+
addFlags(flags: number): Intent
|
|
32
|
+
getData(): Uri | null
|
|
33
|
+
getClipData(): { getItemCount(): number; getItemAt(index: number): { getUri(): Uri } } | null
|
|
34
|
+
}
|
|
35
|
+
declare const android: {
|
|
36
|
+
content: {
|
|
37
|
+
Intent: {
|
|
38
|
+
new (action: string): Intent
|
|
39
|
+
ACTION_OPEN_DOCUMENT: string
|
|
40
|
+
CATEGORY_OPENABLE: string
|
|
41
|
+
EXTRA_ALLOW_MULTIPLE: string
|
|
42
|
+
EXTRA_MIME_TYPES: string
|
|
43
|
+
FLAG_GRANT_READ_URI_PERMISSION: number
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
util: { Size: new (width: number, height: number) => unknown }
|
|
47
|
+
webkit: {
|
|
48
|
+
MimeTypeMap: { getSingleton(): { getMimeTypeFromExtension(extension: string): string | null } }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// One active system picker per adapter; unique codes prevent cross-delivery between owners.
|
|
53
|
+
let requestSequence = 0x4d00
|
|
54
|
+
export function createNativeFilePicker(): FilePickerAdapter {
|
|
55
|
+
return {
|
|
56
|
+
pick(request, cancellation) {
|
|
57
|
+
if (cancellation.cancelled) return Promise.resolve(null)
|
|
58
|
+
const app = Application.android
|
|
59
|
+
const activity = app.foregroundActivity ?? app.startActivity
|
|
60
|
+
if (!activity)
|
|
61
|
+
return Promise.reject(new Error('File selection requires a foreground Activity'))
|
|
62
|
+
const resolver = activity.getContentResolver() as Resolver
|
|
63
|
+
const requestCode = requestSequence++
|
|
64
|
+
if (requestSequence > 0x5d00) requestSequence = 0x4d00
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
let done = false
|
|
67
|
+
let unsubscribe = () => {}
|
|
68
|
+
function finish(files: readonly SelectedFile[] | null, error?: unknown) {
|
|
69
|
+
if (done) {
|
|
70
|
+
for (const file of files ?? []) file.release()
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
done = true
|
|
74
|
+
unsubscribe()
|
|
75
|
+
app.off('activityResult', result)
|
|
76
|
+
if (error) reject(error)
|
|
77
|
+
else resolve(files)
|
|
78
|
+
}
|
|
79
|
+
function result(event: { requestCode: number; resultCode: number; intent?: Intent }) {
|
|
80
|
+
if (event.requestCode !== requestCode) return
|
|
81
|
+
if (event.resultCode !== -1 || !event.intent) {
|
|
82
|
+
finish(null)
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
const files: SelectedFile[] = []
|
|
86
|
+
try {
|
|
87
|
+
const uris: Uri[] = []
|
|
88
|
+
const clip = event.intent.getClipData()
|
|
89
|
+
if (clip)
|
|
90
|
+
for (let index = 0; index < clip.getItemCount(); index++)
|
|
91
|
+
uris.push(clip.getItemAt(index).getUri())
|
|
92
|
+
else {
|
|
93
|
+
const uri = event.intent.getData()
|
|
94
|
+
if (uri) uris.push(uri)
|
|
95
|
+
}
|
|
96
|
+
const unique = new Set<string>()
|
|
97
|
+
for (const uri of uris) {
|
|
98
|
+
if (unique.has(uri.toString())) continue
|
|
99
|
+
unique.add(uri.toString())
|
|
100
|
+
let name = uri.getLastPathSegment()?.split('/').at(-1) || 'Document'
|
|
101
|
+
let size: number | undefined
|
|
102
|
+
const cursor = resolver.query(uri, null, null, null, null)
|
|
103
|
+
try {
|
|
104
|
+
if (cursor?.moveToFirst()) {
|
|
105
|
+
const nameColumn = cursor.getColumnIndex('_display_name')
|
|
106
|
+
const sizeColumn = cursor.getColumnIndex('_size')
|
|
107
|
+
if (nameColumn >= 0 && !cursor.isNull(nameColumn))
|
|
108
|
+
name = cursor.getString(nameColumn)
|
|
109
|
+
if (sizeColumn >= 0 && !cursor.isNull(sizeColumn))
|
|
110
|
+
size = Number(cursor.getLong(sizeColumn))
|
|
111
|
+
}
|
|
112
|
+
} finally {
|
|
113
|
+
cursor?.close()
|
|
114
|
+
}
|
|
115
|
+
let released = false
|
|
116
|
+
const owner = ownNativeFile(
|
|
117
|
+
'android',
|
|
118
|
+
uri,
|
|
119
|
+
() => {
|
|
120
|
+
const stream = resolver.openInputStream(uri)
|
|
121
|
+
if (!stream) throw new Error('The document provider did not open this file')
|
|
122
|
+
return { native: stream, close: () => stream.close() }
|
|
123
|
+
},
|
|
124
|
+
() => {
|
|
125
|
+
released = true
|
|
126
|
+
},
|
|
127
|
+
)
|
|
128
|
+
files.push({
|
|
129
|
+
name,
|
|
130
|
+
size,
|
|
131
|
+
type: resolver.getType(uri) ?? undefined,
|
|
132
|
+
...owner,
|
|
133
|
+
async preview() {
|
|
134
|
+
if (released || SDK_VERSION < 29) return
|
|
135
|
+
// The provider creates a bounded thumbnail; failures retain the file.
|
|
136
|
+
const bitmap = resolver.loadThumbnail(uri, new android.util.Size(160, 160), null)
|
|
137
|
+
if (released || !bitmap) return
|
|
138
|
+
return new ImageSource(bitmap)
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
finish(files)
|
|
143
|
+
} catch (error) {
|
|
144
|
+
for (const file of files) file.release()
|
|
145
|
+
finish(null, error)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
app.on('activityResult', result)
|
|
149
|
+
unsubscribe = cancellation.onCancel(() => {
|
|
150
|
+
// finishActivity only dismisses the child Activity launched by this request.
|
|
151
|
+
try {
|
|
152
|
+
activity.finishActivity(requestCode)
|
|
153
|
+
} finally {
|
|
154
|
+
finish(null)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
try {
|
|
158
|
+
const intent = new android.content.Intent(android.content.Intent.ACTION_OPEN_DOCUMENT)
|
|
159
|
+
intent.addCategory(android.content.Intent.CATEGORY_OPENABLE)
|
|
160
|
+
const hints = request.accept.map((hint) =>
|
|
161
|
+
hint.startsWith('.')
|
|
162
|
+
? android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
|
163
|
+
hint.slice(1).toLowerCase(),
|
|
164
|
+
)
|
|
165
|
+
: hint,
|
|
166
|
+
)
|
|
167
|
+
const types = hints.filter((hint): hint is string => Boolean(hint))
|
|
168
|
+
// Unknown extensions widen the platform hint; core checks names after selection.
|
|
169
|
+
intent.setType(types.length === 1 && types.length === hints.length ? types[0]! : '*/*')
|
|
170
|
+
if (types.length > 1 && types.length === hints.length) {
|
|
171
|
+
// A JS array selects the Bundle overload in the NativeScript bridge.
|
|
172
|
+
const nativeTypes = (
|
|
173
|
+
Array as ArrayConstructor & {
|
|
174
|
+
create(type: string, length: number): string[]
|
|
175
|
+
}
|
|
176
|
+
).create('java.lang.String', types.length)
|
|
177
|
+
types.forEach((type, index) => {
|
|
178
|
+
nativeTypes[index] = type
|
|
179
|
+
})
|
|
180
|
+
intent.putExtra(android.content.Intent.EXTRA_MIME_TYPES, nativeTypes)
|
|
181
|
+
}
|
|
182
|
+
intent.putExtra(android.content.Intent.EXTRA_ALLOW_MULTIPLE, request.multiple)
|
|
183
|
+
intent.addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
|
184
|
+
activity.startActivityForResult(intent, requestCode)
|
|
185
|
+
} catch (error) {
|
|
186
|
+
finish(null, error)
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Application, ImageSource } from '@nativescript/core'
|
|
2
|
+
import type { FilePickerAdapter, SelectedFile } from '@getcortexlabs/mavis-core'
|
|
3
|
+
import { ownNativeFile } from './file-access.js'
|
|
4
|
+
|
|
5
|
+
interface URLValue {
|
|
6
|
+
path: string
|
|
7
|
+
lastPathComponent: string
|
|
8
|
+
pathExtension: string
|
|
9
|
+
}
|
|
10
|
+
interface ContentType {
|
|
11
|
+
identifier: string
|
|
12
|
+
preferredMIMEType?: string
|
|
13
|
+
}
|
|
14
|
+
interface Controller {
|
|
15
|
+
presentedViewController?: Controller
|
|
16
|
+
presentViewControllerAnimatedCompletion(
|
|
17
|
+
controller: Controller,
|
|
18
|
+
animated: boolean,
|
|
19
|
+
completion: (() => void) | null,
|
|
20
|
+
): void
|
|
21
|
+
dismissViewControllerAnimatedCompletion(animated: boolean, completion: (() => void) | null): void
|
|
22
|
+
}
|
|
23
|
+
interface Picker extends Controller {
|
|
24
|
+
delegate: object | null
|
|
25
|
+
allowsMultipleSelection: boolean
|
|
26
|
+
presentationController?: { delegate: object | null }
|
|
27
|
+
}
|
|
28
|
+
interface ThumbnailRequest {}
|
|
29
|
+
interface ThumbnailGenerator {
|
|
30
|
+
generateBestRepresentationForRequestCompletionHandler(
|
|
31
|
+
request: ThumbnailRequest,
|
|
32
|
+
completion: (representation: { UIImage: unknown } | null, error: unknown) => void,
|
|
33
|
+
): void
|
|
34
|
+
cancelRequest(request: ThumbnailRequest): void
|
|
35
|
+
}
|
|
36
|
+
declare const NSObject: { extend(members: object, options: object): { new (): object } }
|
|
37
|
+
declare const UIDocumentPickerDelegate: unknown
|
|
38
|
+
declare const UIAdaptivePresentationControllerDelegate: unknown
|
|
39
|
+
declare const UIDocumentPickerViewController: {
|
|
40
|
+
alloc(): { initForOpeningContentTypesAsCopy(types: ContentType[], asCopy: boolean): Picker }
|
|
41
|
+
}
|
|
42
|
+
declare const UTType: {
|
|
43
|
+
typeWithMIMEType(type: string): ContentType | null
|
|
44
|
+
typeWithFilenameExtension(extension: string): ContentType | null
|
|
45
|
+
typeWithIdentifier(identifier: string): ContentType
|
|
46
|
+
}
|
|
47
|
+
declare const NSFileManager: {
|
|
48
|
+
defaultManager: {
|
|
49
|
+
attributesOfItemAtPathError(path: string): { objectForKey(name: string): unknown }
|
|
50
|
+
removeItemAtURLError(url: URLValue): boolean
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
declare const NSInputStream: { inputStreamWithURL(url: URLValue): { open(): void; close(): void } }
|
|
54
|
+
declare const QLThumbnailGenerationRequest: {
|
|
55
|
+
alloc(): {
|
|
56
|
+
initWithFileAtURLSizeScaleRepresentationTypes(
|
|
57
|
+
url: URLValue,
|
|
58
|
+
size: { width: number; height: number },
|
|
59
|
+
scale: number,
|
|
60
|
+
types: number,
|
|
61
|
+
): ThumbnailRequest
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
declare const QLThumbnailGenerator: { sharedGenerator: ThumbnailGenerator }
|
|
65
|
+
|
|
66
|
+
const families: Readonly<Record<string, string>> = {
|
|
67
|
+
'image/*': 'public.image',
|
|
68
|
+
'video/*': 'public.movie',
|
|
69
|
+
'audio/*': 'public.audio',
|
|
70
|
+
'text/*': 'public.text',
|
|
71
|
+
}
|
|
72
|
+
interface PickerCallbacks {
|
|
73
|
+
cancel(): void
|
|
74
|
+
selected(urls: { count: number; objectAtIndex(index: number): URLValue }): void
|
|
75
|
+
}
|
|
76
|
+
const delegates = new WeakMap<object, PickerCallbacks>()
|
|
77
|
+
let Delegate: { new (): object } | undefined
|
|
78
|
+
function delegateClass() {
|
|
79
|
+
Delegate ??= NSObject.extend(
|
|
80
|
+
{
|
|
81
|
+
documentPickerWasCancelled(this: object) {
|
|
82
|
+
delegates.get(this)?.cancel()
|
|
83
|
+
},
|
|
84
|
+
presentationControllerDidDismiss(this: object) {
|
|
85
|
+
delegates.get(this)?.cancel()
|
|
86
|
+
},
|
|
87
|
+
documentPickerDidPickDocumentsAtURLs(
|
|
88
|
+
this: object,
|
|
89
|
+
_controller: Picker,
|
|
90
|
+
urls: { count: number; objectAtIndex(index: number): URLValue },
|
|
91
|
+
) {
|
|
92
|
+
delegates.get(this)?.selected(urls)
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{ protocols: [UIDocumentPickerDelegate, UIAdaptivePresentationControllerDelegate] },
|
|
96
|
+
)
|
|
97
|
+
return Delegate
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function createNativeFilePicker(): FilePickerAdapter {
|
|
101
|
+
return {
|
|
102
|
+
pick(request, cancellation) {
|
|
103
|
+
if (cancellation.cancelled) return Promise.resolve(null)
|
|
104
|
+
let presenter = Application.ios.rootController as Controller | undefined
|
|
105
|
+
while (presenter?.presentedViewController) presenter = presenter.presentedViewController
|
|
106
|
+
if (!presenter)
|
|
107
|
+
return Promise.reject(new Error('File selection requires a mounted iOS view controller'))
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
let done = false
|
|
110
|
+
let unsubscribe = () => {}
|
|
111
|
+
let picker: Picker | undefined
|
|
112
|
+
// UIKit delegates are weak. Keep this reference until the picker has finished.
|
|
113
|
+
let delegate: object | undefined
|
|
114
|
+
const finish = (files: readonly SelectedFile[] | null, error?: unknown) => {
|
|
115
|
+
if (done) {
|
|
116
|
+
for (const file of files ?? []) file.release()
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
done = true
|
|
120
|
+
unsubscribe()
|
|
121
|
+
if (picker) {
|
|
122
|
+
picker.delegate = null
|
|
123
|
+
if (picker.presentationController) picker.presentationController.delegate = null
|
|
124
|
+
}
|
|
125
|
+
if (delegate) delegates.delete(delegate)
|
|
126
|
+
delegate = undefined
|
|
127
|
+
if (error) reject(error)
|
|
128
|
+
else resolve(files)
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const types = request.accept.map((hint) => {
|
|
132
|
+
if (hint.startsWith('.')) return UTType.typeWithFilenameExtension(hint.slice(1))
|
|
133
|
+
if (hint.endsWith('/*'))
|
|
134
|
+
return families[hint] ? UTType.typeWithIdentifier(families[hint]) : null
|
|
135
|
+
return UTType.typeWithMIMEType(hint)
|
|
136
|
+
})
|
|
137
|
+
const effective =
|
|
138
|
+
!types.length || types.some((type) => !type)
|
|
139
|
+
? [UTType.typeWithIdentifier('public.data')]
|
|
140
|
+
: (types as ContentType[])
|
|
141
|
+
// Import a private temporary copy: no security-scoped bookmark or broad permission.
|
|
142
|
+
picker = UIDocumentPickerViewController.alloc().initForOpeningContentTypesAsCopy(
|
|
143
|
+
effective,
|
|
144
|
+
true,
|
|
145
|
+
)
|
|
146
|
+
picker.allowsMultipleSelection = request.multiple
|
|
147
|
+
const PickerDelegate = delegateClass()
|
|
148
|
+
delegate = new PickerDelegate()
|
|
149
|
+
delegates.set(delegate, {
|
|
150
|
+
cancel() {
|
|
151
|
+
finish(null)
|
|
152
|
+
},
|
|
153
|
+
selected(urls) {
|
|
154
|
+
const files: SelectedFile[] = []
|
|
155
|
+
try {
|
|
156
|
+
for (let index = 0; index < urls.count; index++) {
|
|
157
|
+
const url = urls.objectAtIndex(index)
|
|
158
|
+
const attributes = NSFileManager.defaultManager.attributesOfItemAtPathError(
|
|
159
|
+
url.path,
|
|
160
|
+
)
|
|
161
|
+
const size = attributes?.objectForKey('NSFileSize')
|
|
162
|
+
let thumbnail: ThumbnailRequest | undefined
|
|
163
|
+
let released = false
|
|
164
|
+
const owner = ownNativeFile(
|
|
165
|
+
'ios',
|
|
166
|
+
url,
|
|
167
|
+
() => {
|
|
168
|
+
const stream = NSInputStream.inputStreamWithURL(url)
|
|
169
|
+
stream.open()
|
|
170
|
+
return { native: stream, close: () => stream.close() }
|
|
171
|
+
},
|
|
172
|
+
() => {
|
|
173
|
+
released = true
|
|
174
|
+
if (thumbnail) QLThumbnailGenerator.sharedGenerator.cancelRequest(thumbnail)
|
|
175
|
+
// asCopy=true guarantees that this is the imported sandbox copy.
|
|
176
|
+
NSFileManager.defaultManager.removeItemAtURLError(url)
|
|
177
|
+
},
|
|
178
|
+
)
|
|
179
|
+
files.push({
|
|
180
|
+
name: url.lastPathComponent,
|
|
181
|
+
size: size == null ? undefined : Number(size),
|
|
182
|
+
type:
|
|
183
|
+
UTType.typeWithFilenameExtension(url.pathExtension)?.preferredMIMEType ||
|
|
184
|
+
undefined,
|
|
185
|
+
...owner,
|
|
186
|
+
preview() {
|
|
187
|
+
if (released) return Promise.resolve(undefined)
|
|
188
|
+
return new Promise((previewResolve, previewReject) => {
|
|
189
|
+
thumbnail =
|
|
190
|
+
QLThumbnailGenerationRequest.alloc().initWithFileAtURLSizeScaleRepresentationTypes(
|
|
191
|
+
url,
|
|
192
|
+
{ width: 160, height: 160 },
|
|
193
|
+
1,
|
|
194
|
+
4,
|
|
195
|
+
)
|
|
196
|
+
QLThumbnailGenerator.sharedGenerator.generateBestRepresentationForRequestCompletionHandler(
|
|
197
|
+
thumbnail,
|
|
198
|
+
(representation, error) => {
|
|
199
|
+
thumbnail = undefined
|
|
200
|
+
if (released) previewResolve(undefined)
|
|
201
|
+
else if (representation)
|
|
202
|
+
previewResolve(new ImageSource(representation.UIImage))
|
|
203
|
+
else previewReject(error ?? new Error('Preview unavailable'))
|
|
204
|
+
},
|
|
205
|
+
)
|
|
206
|
+
})
|
|
207
|
+
},
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
finish(files)
|
|
211
|
+
} catch (error) {
|
|
212
|
+
for (const file of files) file.release()
|
|
213
|
+
finish(null, error)
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
picker.delegate = delegate
|
|
218
|
+
if (picker.presentationController) picker.presentationController.delegate = delegate
|
|
219
|
+
unsubscribe = cancellation.onCancel(() => {
|
|
220
|
+
picker?.dismissViewControllerAnimatedCompletion(true, null)
|
|
221
|
+
finish(null)
|
|
222
|
+
})
|
|
223
|
+
presenter!.presentViewControllerAnimatedCompletion(picker, true, null)
|
|
224
|
+
} catch (error) {
|
|
225
|
+
finish(null, error)
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
},
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FilePickerAdapter } from '@getcortexlabs/mavis-core'
|
|
2
|
+
|
|
3
|
+
/** NativeScript resolves this module to the .ios/.android implementation at bundle time. */
|
|
4
|
+
export function createNativeFilePicker(): FilePickerAdapter {
|
|
5
|
+
return {
|
|
6
|
+
pick: () => Promise.reject(new Error('File picking requires the iOS or Android runtime')),
|
|
7
|
+
}
|
|
8
|
+
}
|