react-isoform 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +104 -2
- package/android/build.gradle +212 -0
- package/android/consumer-rules.pro +10 -0
- package/android/src/audio/java/com/isoform/IsoAudioControls.kt +531 -0
- package/android/src/audio/java/com/isoform/IsoAudioView.kt +328 -0
- package/android/src/audio/java/com/isoform/IsoAudioViewManager.kt +88 -0
- package/android/src/camera/AndroidManifest.xml +6 -0
- package/android/src/camera/java/com/isoform/IsoCamera.kt +99 -0
- package/android/src/camera/java/com/isoform/IsoCameraController.kt +232 -0
- package/android/src/camera/java/com/isoform/IsoCameraLifecycle.kt +26 -0
- package/android/src/camera/java/com/isoform/IsoCameraView.kt +392 -0
- package/android/src/camera/java/com/isoform/IsoCameraViewManager.kt +76 -0
- package/android/src/cameraCodes/java/com/isoform/IsoCodeScanner.kt +90 -0
- package/android/src/cameraCodesOff/java/com/isoform/IsoCodeScanner.kt +17 -0
- package/android/src/cameraVideo/AndroidManifest.xml +4 -0
- package/android/src/cameraVideo/java/com/isoform/IsoCameraRecorder.kt +83 -0
- package/android/src/cameraVideoOff/java/com/isoform/IsoCameraRecorder.kt +22 -0
- package/android/src/datePicker/java/com/isoform/IsoDatePicker.kt +724 -0
- package/android/src/datePicker/java/com/isoform/IsoDatePickerView.kt +137 -0
- package/android/src/datePicker/java/com/isoform/IsoDatePickerViewManager.kt +56 -0
- package/android/src/image/java/com/isoform/IsoImageModule.kt +33 -0
- package/android/src/image/java/com/isoform/IsoImagePipeline.kt +516 -0
- package/android/src/image/java/com/isoform/IsoImageView.kt +573 -0
- package/android/src/image/java/com/isoform/IsoImageViewManager.kt +119 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/isoform/IsoformPackage.kt +52 -0
- package/android/src/mediaSession/AndroidManifest.xml +18 -0
- package/android/src/mediaSession/java/com/isoform/IsoMediaService.kt +21 -0
- package/android/src/mediaSession/java/com/isoform/IsoMediaSession.kt +92 -0
- package/android/src/mediaSessionOff/java/com/isoform/IsoMediaSession.kt +18 -0
- package/android/src/modal/java/com/isoform/IsoModal.kt +182 -0
- package/android/src/modal/java/com/isoform/IsoModalView.kt +137 -0
- package/android/src/modal/java/com/isoform/IsoModalViewManager.kt +70 -0
- package/android/src/pdf/java/com/isoform/IsoPdfDocument.kt +157 -0
- package/android/src/pdf/java/com/isoform/IsoPdfEngine.kt +161 -0
- package/android/src/pdf/java/com/isoform/IsoPdfIcons.kt +76 -0
- package/android/src/pdf/java/com/isoform/IsoPdfReader.kt +176 -0
- package/android/src/pdf/java/com/isoform/IsoPdfView.kt +372 -0
- package/android/src/pdf/java/com/isoform/IsoPdfViewManager.kt +100 -0
- package/android/src/pdf/java/com/isoform/IsoPdfViewer.kt +849 -0
- package/android/src/sheet/java/com/isoform/IsoSheet.kt +247 -0
- package/android/src/sheet/java/com/isoform/IsoSheetView.kt +188 -0
- package/android/src/sheet/java/com/isoform/IsoSheetViewManager.kt +76 -0
- package/android/src/video/java/com/isoform/IsoVideoControls.kt +921 -0
- package/android/src/video/java/com/isoform/IsoVideoPlaylistPanel.kt +247 -0
- package/android/src/video/java/com/isoform/IsoVideoView.kt +324 -0
- package/android/src/video/java/com/isoform/IsoVideoViewManager.kt +84 -0
- package/babel.js +133 -0
- package/dist/adapters/react-dom/adapter.d.ts +3 -0
- package/dist/adapters/react-dom/adapter.js +108 -0
- package/dist/adapters/react-dom/camera/CameraElement.d.ts +15 -0
- package/dist/adapters/react-dom/camera/CameraElement.js +293 -0
- package/dist/adapters/react-dom/camera/LazyCamera.d.ts +4 -0
- package/dist/adapters/react-dom/camera/LazyCamera.js +21 -0
- package/dist/adapters/react-dom/camera/webCamera.d.ts +27 -0
- package/dist/adapters/react-dom/camera/webCamera.js +51 -0
- package/dist/adapters/react-dom/css/sheet.d.ts +43 -0
- package/dist/adapters/react-dom/css/sheet.js +183 -0
- package/dist/adapters/react-dom/datePicker/DatePicker.d.ts +19 -0
- package/dist/adapters/react-dom/datePicker/DatePicker.js +31 -0
- package/dist/adapters/react-dom/image/Image.d.ts +23 -0
- package/dist/adapters/react-dom/image/Image.js +256 -0
- package/dist/adapters/react-dom/media/audio/AudioControls.d.ts +44 -0
- package/dist/adapters/react-dom/media/audio/AudioControls.js +53 -0
- package/dist/adapters/react-dom/media/audio/AudioElement.d.ts +18 -0
- package/dist/adapters/react-dom/media/audio/AudioElement.js +139 -0
- package/dist/adapters/react-dom/media/audio/LazyAudio.d.ts +3 -0
- package/dist/adapters/react-dom/media/audio/LazyAudio.js +22 -0
- package/dist/adapters/react-dom/media/audio/audioStyles.d.ts +3 -0
- package/dist/adapters/react-dom/media/audio/audioStyles.js +52 -0
- package/dist/adapters/react-dom/media/index.d.ts +4 -0
- package/dist/adapters/react-dom/media/index.js +10 -0
- package/dist/adapters/react-dom/media/pdf/LazyPdf.d.ts +4 -0
- package/dist/adapters/react-dom/media/pdf/LazyPdf.js +22 -0
- package/dist/adapters/react-dom/media/pdf/PdfElement.d.ts +20 -0
- package/dist/adapters/react-dom/media/pdf/PdfElement.js +622 -0
- package/dist/adapters/react-dom/media/pdf/PdfPage.d.ts +31 -0
- package/dist/adapters/react-dom/media/pdf/PdfPage.js +154 -0
- package/dist/adapters/react-dom/media/pdf/PdfThumbnails.d.ts +12 -0
- package/dist/adapters/react-dom/media/pdf/PdfThumbnails.js +56 -0
- package/dist/adapters/react-dom/media/pdf/PdfToolbar.d.ts +82 -0
- package/dist/adapters/react-dom/media/pdf/PdfToolbar.js +92 -0
- package/dist/adapters/react-dom/media/pdf/pdfDocument.d.ts +90 -0
- package/dist/adapters/react-dom/media/pdf/pdfDocument.js +118 -0
- package/dist/adapters/react-dom/media/pdf/pdfStyles.d.ts +3 -0
- package/dist/adapters/react-dom/media/pdf/pdfStyles.js +107 -0
- package/dist/adapters/react-dom/media/pdf/pdfjs.d.ts +12 -0
- package/dist/adapters/react-dom/media/pdf/pdfjs.js +31 -0
- package/dist/adapters/react-dom/media/pdf/readAloud.d.ts +27 -0
- package/dist/adapters/react-dom/media/pdf/readAloud.js +136 -0
- package/dist/adapters/react-dom/media/pdf/search.d.ts +48 -0
- package/dist/adapters/react-dom/media/pdf/search.js +57 -0
- package/dist/adapters/react-dom/media/shared/Playlist.d.ts +21 -0
- package/dist/adapters/react-dom/media/shared/Playlist.js +240 -0
- package/dist/adapters/react-dom/media/shared/Track.d.ts +21 -0
- package/dist/adapters/react-dom/media/shared/Track.js +47 -0
- package/dist/adapters/react-dom/media/shared/controlStyles.d.ts +3 -0
- package/dist/adapters/react-dom/media/shared/controlStyles.js +46 -0
- package/dist/adapters/react-dom/media/shared/helpers.d.ts +22 -0
- package/dist/adapters/react-dom/media/shared/helpers.js +46 -0
- package/dist/adapters/react-dom/media/shared/icons.d.ts +49 -0
- package/dist/adapters/react-dom/media/shared/icons.js +52 -0
- package/dist/adapters/react-dom/media/shared/playlistHandle.d.ts +13 -0
- package/dist/adapters/react-dom/media/shared/playlistHandle.js +17 -0
- package/dist/adapters/react-dom/media/shared/withPlaylist.d.ts +4 -0
- package/dist/adapters/react-dom/media/shared/withPlaylist.js +24 -0
- package/dist/adapters/react-dom/media/video/LazyVideo.d.ts +4 -0
- package/dist/adapters/react-dom/media/video/LazyVideo.js +22 -0
- package/dist/adapters/react-dom/media/video/VideoControls.d.ts +43 -0
- package/dist/adapters/react-dom/media/video/VideoControls.js +89 -0
- package/dist/adapters/react-dom/media/video/VideoElement.d.ts +19 -0
- package/dist/adapters/react-dom/media/video/VideoElement.js +161 -0
- package/dist/adapters/react-dom/media/video/fullscreen.d.ts +17 -0
- package/dist/adapters/react-dom/media/video/fullscreen.js +43 -0
- package/dist/adapters/react-dom/media/video/pictureInPicture.d.ts +11 -0
- package/dist/adapters/react-dom/media/video/pictureInPicture.js +34 -0
- package/dist/adapters/react-dom/media/video/videoStyles.d.ts +3 -0
- package/dist/adapters/react-dom/media/video/videoStyles.js +49 -0
- package/dist/adapters/react-dom/modal/LazyModal.d.ts +8 -0
- package/dist/adapters/react-dom/modal/LazyModal.js +22 -0
- package/dist/adapters/react-dom/modal/Modal.d.ts +16 -0
- package/dist/adapters/react-dom/modal/Modal.js +101 -0
- package/dist/adapters/react-dom/normalize/domProps.d.ts +9 -0
- package/dist/adapters/react-dom/normalize/domProps.js +279 -0
- package/dist/adapters/react-dom/normalize/props.d.ts +5 -0
- package/dist/adapters/react-dom/normalize/props.js +258 -0
- package/dist/adapters/react-dom/normalize/style.d.ts +14 -0
- package/dist/adapters/react-dom/normalize/style.js +165 -0
- package/dist/adapters/react-dom/primitives.d.ts +6 -0
- package/dist/adapters/react-dom/primitives.js +37 -0
- package/dist/adapters/react-dom/sheet/LazySheet.d.ts +7 -0
- package/dist/adapters/react-dom/sheet/LazySheet.js +26 -0
- package/dist/adapters/react-dom/sheet/SheetElement.d.ts +17 -0
- package/dist/adapters/react-dom/sheet/SheetElement.js +223 -0
- package/dist/adapters/react-dom/sheet/sheetStyles.d.ts +3 -0
- package/dist/adapters/react-dom/sheet/sheetStyles.js +36 -0
- package/dist/adapters/react-dom/svg/elements.d.ts +5 -0
- package/dist/adapters/react-dom/svg/elements.js +32 -0
- package/dist/adapters/react-dom/themeToggle.bench.d.ts +2 -0
- package/dist/adapters/react-dom/themeToggle.bench.js +111 -0
- package/dist/adapters/react-native/adapter.d.ts +24 -0
- package/dist/adapters/react-native/adapter.js +356 -0
- package/dist/adapters/react-native/animatedHost.d.ts +21 -0
- package/dist/adapters/react-native/animatedHost.js +84 -0
- package/dist/adapters/react-native/animation.d.ts +63 -0
- package/dist/adapters/react-native/animation.js +340 -0
- package/dist/adapters/react-native/breakpoint.bench.d.ts +2 -0
- package/dist/adapters/react-native/breakpoint.bench.js +112 -0
- package/dist/adapters/react-native/camera/Camera.d.ts +12 -0
- package/dist/adapters/react-native/camera/Camera.disabled.d.ts +8 -0
- package/dist/adapters/react-native/camera/Camera.disabled.js +14 -0
- package/dist/adapters/react-native/camera/Camera.js +103 -0
- package/dist/adapters/react-native/camera/native/IsoCameraViewNativeComponent.d.ts +83 -0
- package/dist/adapters/react-native/camera/native/IsoCameraViewNativeComponent.js +6 -0
- package/dist/adapters/react-native/datePicker/DatePicker.d.ts +16 -0
- package/dist/adapters/react-native/datePicker/DatePicker.disabled.d.ts +10 -0
- package/dist/adapters/react-native/datePicker/DatePicker.disabled.js +13 -0
- package/dist/adapters/react-native/datePicker/DatePicker.js +43 -0
- package/dist/adapters/react-native/datePicker/native/IsoDatePickerViewNativeComponent.d.ts +35 -0
- package/dist/adapters/react-native/datePicker/native/IsoDatePickerViewNativeComponent.js +13 -0
- package/dist/adapters/react-native/image/Image.d.ts +26 -0
- package/dist/adapters/react-native/image/Image.disabled.d.ts +7 -0
- package/dist/adapters/react-native/image/Image.disabled.js +7 -0
- package/dist/adapters/react-native/image/Image.js +56 -0
- package/dist/adapters/react-native/image/PlainImage.d.ts +18 -0
- package/dist/adapters/react-native/image/PlainImage.js +18 -0
- package/dist/adapters/react-native/image/imageCache.d.ts +4 -0
- package/dist/adapters/react-native/image/imageCache.js +17 -0
- package/dist/adapters/react-native/image/native/IsoImageViewNativeComponent.d.ts +86 -0
- package/dist/adapters/react-native/image/native/IsoImageViewNativeComponent.js +14 -0
- package/dist/adapters/react-native/image/native/NativeIsoImageModule.d.ts +17 -0
- package/dist/adapters/react-native/image/native/NativeIsoImageModule.js +9 -0
- package/dist/adapters/react-native/media/audio/Audio.d.ts +19 -0
- package/dist/adapters/react-native/media/audio/Audio.disabled.d.ts +8 -0
- package/dist/adapters/react-native/media/audio/Audio.disabled.js +16 -0
- package/dist/adapters/react-native/media/audio/Audio.js +40 -0
- package/dist/adapters/react-native/media/audio/native/IsoAudioViewNativeComponent.d.ts +77 -0
- package/dist/adapters/react-native/media/audio/native/IsoAudioViewNativeComponent.js +6 -0
- package/dist/adapters/react-native/media/index.d.ts +4 -0
- package/dist/adapters/react-native/media/index.js +9 -0
- package/dist/adapters/react-native/media/pdf/Pdf.d.ts +19 -0
- package/dist/adapters/react-native/media/pdf/Pdf.disabled.d.ts +9 -0
- package/dist/adapters/react-native/media/pdf/Pdf.disabled.js +16 -0
- package/dist/adapters/react-native/media/pdf/Pdf.js +46 -0
- package/dist/adapters/react-native/media/pdf/native/IsoPdfViewNativeComponent.d.ts +77 -0
- package/dist/adapters/react-native/media/pdf/native/IsoPdfViewNativeComponent.js +6 -0
- package/dist/adapters/react-native/media/shared/Playlist.d.ts +18 -0
- package/dist/adapters/react-native/media/shared/Playlist.js +242 -0
- package/dist/adapters/react-native/media/video/Video.d.ts +25 -0
- package/dist/adapters/react-native/media/video/Video.disabled.d.ts +9 -0
- package/dist/adapters/react-native/media/video/Video.disabled.js +16 -0
- package/dist/adapters/react-native/media/video/Video.js +46 -0
- package/dist/adapters/react-native/media/video/native/IsoVideoViewNativeComponent.d.ts +87 -0
- package/dist/adapters/react-native/media/video/native/IsoVideoViewNativeComponent.js +6 -0
- package/dist/adapters/react-native/miss.bench.d.ts +2 -0
- package/dist/adapters/react-native/miss.bench.js +78 -0
- package/dist/adapters/react-native/modal/Modal.d.ts +18 -0
- package/dist/adapters/react-native/modal/Modal.disabled.d.ts +7 -0
- package/dist/adapters/react-native/modal/Modal.disabled.js +7 -0
- package/dist/adapters/react-native/modal/Modal.js +71 -0
- package/dist/adapters/react-native/modal/PlainModal.d.ts +16 -0
- package/dist/adapters/react-native/modal/PlainModal.js +26 -0
- package/dist/adapters/react-native/modal/native/IsoModalViewNativeComponent.d.ts +35 -0
- package/dist/adapters/react-native/modal/native/IsoModalViewNativeComponent.js +14 -0
- package/dist/adapters/react-native/normalize.d.ts +13 -0
- package/dist/adapters/react-native/normalize.js +221 -0
- package/dist/adapters/react-native/pseudo.d.ts +27 -0
- package/dist/adapters/react-native/pseudo.js +39 -0
- package/dist/adapters/react-native/sheet/BottomSheet.d.ts +12 -0
- package/dist/adapters/react-native/sheet/BottomSheet.disabled.d.ts +8 -0
- package/dist/adapters/react-native/sheet/BottomSheet.disabled.js +14 -0
- package/dist/adapters/react-native/sheet/BottomSheet.js +89 -0
- package/dist/adapters/react-native/sheet/native/IsoSheetViewNativeComponent.d.ts +40 -0
- package/dist/adapters/react-native/sheet/native/IsoSheetViewNativeComponent.js +14 -0
- package/dist/adapters/react-native/styleHost.d.ts +21 -0
- package/dist/adapters/react-native/styleHost.js +72 -0
- package/dist/adapters/react-native/svg/Svg.d.ts +5 -0
- package/dist/adapters/react-native/svg/Svg.disabled.d.ts +5 -0
- package/dist/adapters/react-native/svg/Svg.disabled.js +18 -0
- package/dist/adapters/react-native/svg/Svg.js +60 -0
- package/dist/adapters/react-native/transition.d.ts +41 -0
- package/dist/adapters/react-native/transition.js +145 -0
- package/dist/adapters/react-native/transitionHost.d.ts +11 -0
- package/dist/adapters/react-native/transitionHost.js +147 -0
- package/dist/adapters/react-native/windowWidth.d.ts +15 -0
- package/dist/adapters/react-native/windowWidth.js +49 -0
- package/dist/cache/lru.d.ts +11 -0
- package/dist/cache/lru.js +32 -0
- package/dist/config/index.d.ts +239 -0
- package/dist/config/index.js +161 -0
- package/dist/core/adapter.d.ts +72 -0
- package/dist/core/adapter.js +2 -0
- package/dist/core/builder.d.ts +95 -0
- package/dist/core/builder.js +431 -0
- package/dist/core/camera.d.ts +142 -0
- package/dist/core/camera.js +43 -0
- package/dist/core/cameraRequests.d.ts +18 -0
- package/dist/core/cameraRequests.js +44 -0
- package/dist/core/conditions.d.ts +54 -0
- package/dist/core/conditions.js +123 -0
- package/dist/core/datePicker.d.ts +92 -0
- package/dist/core/datePicker.js +92 -0
- package/dist/core/dev.d.ts +5 -0
- package/dist/core/dev.js +18 -0
- package/dist/core/engine.d.ts +62 -0
- package/dist/core/engine.js +26 -0
- package/dist/core/flatten.d.ts +6 -0
- package/dist/core/flatten.js +22 -0
- package/dist/core/image.d.ts +246 -0
- package/dist/core/image.js +171 -0
- package/dist/core/inline.d.ts +33 -0
- package/dist/core/inline.js +25 -0
- package/dist/core/keyframes.d.ts +40 -0
- package/dist/core/keyframes.js +38 -0
- package/dist/core/media.d.ts +118 -0
- package/dist/core/media.js +2 -0
- package/dist/core/modal.d.ts +76 -0
- package/dist/core/modal.js +35 -0
- package/dist/core/modules.d.ts +7 -0
- package/dist/core/modules.js +9 -0
- package/dist/core/pdf.d.ts +133 -0
- package/dist/core/pdf.js +2 -0
- package/dist/core/playlist.d.ts +97 -0
- package/dist/core/playlist.js +58 -0
- package/dist/core/primitives.d.ts +410 -0
- package/dist/core/primitives.js +2 -0
- package/dist/core/proxy.d.ts +2 -0
- package/dist/core/proxy.js +25 -0
- package/dist/core/sheet.d.ts +95 -0
- package/dist/core/sheet.js +71 -0
- package/dist/core/style/types.d.ts +88 -0
- package/dist/core/style/types.js +2 -0
- package/dist/core/svg.d.ts +121 -0
- package/dist/core/svg.js +76 -0
- package/dist/core/testing/benchHarness.d.ts +42 -0
- package/dist/core/testing/benchHarness.js +75 -0
- package/dist/core/types.d.ts +222 -0
- package/dist/core/types.js +2 -0
- package/dist/hash/optimizedHash.d.ts +10 -0
- package/dist/hash/optimizedHash.js +63 -0
- package/dist/hash/stringHash.d.ts +6 -0
- package/dist/hash/stringHash.js +17 -0
- package/dist/hash/trackReads.d.ts +20 -0
- package/dist/hash/trackReads.js +49 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +21 -0
- package/dist/jsx-dev-runtime.d.ts +7 -0
- package/dist/jsx-dev-runtime.js +13 -0
- package/dist/jsx-runtime.d.ts +19 -0
- package/dist/jsx-runtime.js +25 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +5 -0
- package/dist/providers/index.native.d.ts +2 -0
- package/dist/providers/index.native.js +5 -0
- package/dist/theme/index.d.ts +46 -0
- package/dist/theme/index.js +51 -0
- package/dist/theme/store/helpers.d.ts +50 -0
- package/dist/theme/store/helpers.js +116 -0
- package/dist/theme/store/index.d.ts +196 -0
- package/dist/theme/store/index.js +259 -0
- package/dist/theme/variables.d.ts +23 -0
- package/dist/theme/variables.js +127 -0
- package/ios/audio/IsoAudioCard.swift +471 -0
- package/ios/audio/IsoAudioPlayer.swift +326 -0
- package/ios/audio/IsoAudioView.mm +173 -0
- package/ios/camera/IsoCamera.swift +682 -0
- package/ios/camera/IsoCameraView.mm +206 -0
- package/ios/datePicker/IsoDatePicker.swift +826 -0
- package/ios/datePicker/IsoDatePickerView.mm +118 -0
- package/ios/datePicker/IsoWheelView.swift +190 -0
- package/ios/image/IsoImage.swift +568 -0
- package/ios/image/IsoImageModule.mm +45 -0
- package/ios/image/IsoImagePipeline.swift +612 -0
- package/ios/image/IsoImageView.mm +173 -0
- package/ios/mediaSession/IsoNowPlaying.swift +150 -0
- package/ios/mediaSessionOff/IsoNowPlaying.swift +18 -0
- package/ios/modal/IsoModal.swift +301 -0
- package/ios/modal/IsoModalView.mm +132 -0
- package/ios/pdf/IsoPdfSupport.swift +247 -0
- package/ios/pdf/IsoPdfToolbar.swift +403 -0
- package/ios/pdf/IsoPdfView.mm +194 -0
- package/ios/pdf/IsoPdfViewer.swift +547 -0
- package/ios/shared/IsoAudioSession.swift +42 -0
- package/ios/sheet/IsoSheet.swift +259 -0
- package/ios/sheet/IsoSheetView.mm +143 -0
- package/ios/stubs/audio/IsoAudioViewStub.mm +32 -0
- package/ios/stubs/camera/IsoCameraViewStub.mm +32 -0
- package/ios/stubs/datePicker/IsoDatePickerViewStub.mm +32 -0
- package/ios/stubs/image/IsoImageViewStub.mm +62 -0
- package/ios/stubs/modal/IsoModalViewStub.mm +32 -0
- package/ios/stubs/pdf/IsoPdfViewStub.mm +32 -0
- package/ios/stubs/sheet/IsoSheetViewStub.mm +32 -0
- package/ios/stubs/video/IsoVideoViewStub.mm +32 -0
- package/ios/video/IsoVideoControls.swift +569 -0
- package/ios/video/IsoVideoFullscreen.swift +280 -0
- package/ios/video/IsoVideoPlayer.swift +421 -0
- package/ios/video/IsoVideoPlaylistPanel.swift +360 -0
- package/ios/video/IsoVideoView.mm +187 -0
- package/isoform.podspec +132 -0
- package/metro.js +81 -0
- package/package.json +180 -4
- package/react-native.config.js +12 -0
- package/scripts/setup-ios.js +85 -0
- package/src/adapters/react-native/camera/native/IsoCameraViewNativeComponent.ts +79 -0
- package/src/adapters/react-native/datePicker/native/IsoDatePickerViewNativeComponent.ts +44 -0
- package/src/adapters/react-native/image/native/IsoImageViewNativeComponent.ts +90 -0
- package/src/adapters/react-native/image/native/NativeIsoImageModule.ts +24 -0
- package/src/adapters/react-native/media/audio/native/IsoAudioViewNativeComponent.ts +69 -0
- package/src/adapters/react-native/media/pdf/native/IsoPdfViewNativeComponent.ts +71 -0
- package/src/adapters/react-native/media/video/native/IsoVideoViewNativeComponent.ts +74 -0
- package/src/adapters/react-native/modal/native/IsoModalViewNativeComponent.ts +47 -0
- package/src/adapters/react-native/sheet/native/IsoSheetViewNativeComponent.ts +50 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import React, { forwardRef, useSyncExternalStore } from 'react';
|
|
4
|
+
import { getProvider, getThemeVariableKeys, isInlineEnabled } from '../config';
|
|
5
|
+
import { LRUCache } from '../cache/lru';
|
|
6
|
+
import { optimizedHash } from '../hash/optimizedHash';
|
|
7
|
+
import { beginPropReads, createReads, endPropReads, trackReads } from '../hash/trackReads';
|
|
8
|
+
import { getTheme, themeStore } from '../theme/store';
|
|
9
|
+
import { beginThemeReads, endThemeReads, themeView } from '../theme/variables';
|
|
10
|
+
import { getBreakpoints } from '../config';
|
|
11
|
+
import { evaluateCondition, isPseudoCondition, isStaticCondition, parseBreakpoint, stateOf } from './conditions';
|
|
12
|
+
import { warnOnce } from './dev';
|
|
13
|
+
import { flattenStyle } from './flatten';
|
|
14
|
+
import { INLINE, isThemeFree } from './inline';
|
|
15
|
+
import { keyframes } from './keyframes';
|
|
16
|
+
/** Dynamic styles are cached per theme, up to this many distinct prop combinations. */
|
|
17
|
+
const CACHE_LIMIT = 300;
|
|
18
|
+
let builderCount = 0;
|
|
19
|
+
/**
|
|
20
|
+
* Cache key shared by every theme, for styles that do not depend on the theme object (they only read
|
|
21
|
+
* CSS-variable tokens, see `theme/variables.ts`): a theme switch then keeps their cache.
|
|
22
|
+
*/
|
|
23
|
+
const ANY_THEME = {};
|
|
24
|
+
/** Snapshot of a component that does not follow the theme: never changes, so the store never re-renders it. */
|
|
25
|
+
const noTheme = () => 0;
|
|
26
|
+
/** Theme keys turned into CSS variables when none are configured: every theme read is a real value. */
|
|
27
|
+
const NO_VARIABLE_KEYS = [];
|
|
28
|
+
function resolveStyle(style, ctx) {
|
|
29
|
+
return typeof style === 'function' ? style(ctx) : style;
|
|
30
|
+
}
|
|
31
|
+
/** `animationName: { from, to }` (keyframes inline) → nome registrado via `keyframes()`. */
|
|
32
|
+
function resolveInlineKeyframes(style) {
|
|
33
|
+
const name = style.animationName;
|
|
34
|
+
if (name && typeof name === 'object') {
|
|
35
|
+
const list = Array.isArray(name) ? name : [name];
|
|
36
|
+
style.animationName = list
|
|
37
|
+
.map((frames) => (typeof frames === 'string' ? frames : keyframes(frames)))
|
|
38
|
+
.join(', ');
|
|
39
|
+
}
|
|
40
|
+
return style;
|
|
41
|
+
}
|
|
42
|
+
/** Every function a rule holds: a style function, a `when()` condition, an attrs function, a style inside attrs. */
|
|
43
|
+
const functionsOf = (rule) => {
|
|
44
|
+
const attrs = rule.kind === 'style' ? undefined : rule.attrs;
|
|
45
|
+
const candidates = [
|
|
46
|
+
rule.kind === 'style' ? rule.style : undefined,
|
|
47
|
+
rule.kind === 'when' ? rule.condition : undefined,
|
|
48
|
+
attrs,
|
|
49
|
+
attrs?.style,
|
|
50
|
+
];
|
|
51
|
+
return candidates.filter((candidate) => typeof candidate === 'function');
|
|
52
|
+
};
|
|
53
|
+
export class StylizedBuilder {
|
|
54
|
+
Base;
|
|
55
|
+
rules = [];
|
|
56
|
+
/** Cache por tema → (hash das props → resultado compilado). */
|
|
57
|
+
cacheByTheme = new WeakMap();
|
|
58
|
+
/**
|
|
59
|
+
* Props que as regras já leram. Só elas entram no hash: o resto (`testID`, `onPress`…) não muda o estilo.
|
|
60
|
+
* Cresce no primeiro cache miss que lê uma prop nova; nesse momento o cache é zerado (ver `learn`).
|
|
61
|
+
*/
|
|
62
|
+
readKeys = new Set();
|
|
63
|
+
/** Alguma regra enumerou as props (`{ ...props }`): não dá para saber quais contam, então todas contam. */
|
|
64
|
+
readAll = false;
|
|
65
|
+
id = ++builderCount;
|
|
66
|
+
/**
|
|
67
|
+
* `true` once a style rule read a real value from the theme (with `themeVariables` on, a value that is
|
|
68
|
+
* not a CSS variable). Until then the styles do not depend on the theme: the cache is shared by every
|
|
69
|
+
* theme and a theme switch does not re-render the component.
|
|
70
|
+
* Sticky: when it flips, the caches built under "any theme" are dropped (see `resolveDynamic`).
|
|
71
|
+
*/
|
|
72
|
+
themeDependent = false;
|
|
73
|
+
/** The variable keys `themeDependent` was learned under; a different `configure` starts over. */
|
|
74
|
+
variablesSignature = '';
|
|
75
|
+
constructor(Base, baseRules = []) {
|
|
76
|
+
this.Base = Base;
|
|
77
|
+
this.rules = [...baseRules];
|
|
78
|
+
}
|
|
79
|
+
/** Adiciona uma regra de estilo (objeto ou função de `{ theme, props, platform }`). */
|
|
80
|
+
style(styleOrFn) {
|
|
81
|
+
this.rules.push({ kind: 'style', style: styleOrFn });
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Adiciona uma regra condicional.
|
|
86
|
+
*
|
|
87
|
+
* @example when('platform:ios', { style: { shadowOpacity: 0.2 } })
|
|
88
|
+
* @example when('props:variant=primary', { style: { backgroundColor: 'blue' } })
|
|
89
|
+
* @example when(({ props }) => props.size > 40, { style: { opacity: 0.5 } })
|
|
90
|
+
*/
|
|
91
|
+
when(condition, attrs) {
|
|
92
|
+
this.rules.push({ kind: 'when', condition, attrs });
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
/** Adiciona props fixas (acessibilidade, testID, roles…). */
|
|
96
|
+
attrs(attrs) {
|
|
97
|
+
this.rules.push({ kind: 'attrs', attrs });
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
/** "Clona + adiciona": copia as regras atuais sem alterar o original. */
|
|
101
|
+
extend() {
|
|
102
|
+
return new StylizedBuilder(this.Base, [...this.rules]);
|
|
103
|
+
}
|
|
104
|
+
/** Roda as regras para um contexto, produzindo estilo mesclado + attrs. */
|
|
105
|
+
computeFromRules(adapter, theme, platform, props, reads) {
|
|
106
|
+
const styles = [];
|
|
107
|
+
const stateStyles = {};
|
|
108
|
+
const bpStyles = {};
|
|
109
|
+
const pseudoStyles = {};
|
|
110
|
+
const mergedAttrs = {};
|
|
111
|
+
// Contexto reaproveitado entre as regras: só é refeito quando uma regra anterior adicionou props
|
|
112
|
+
// (`attrsVersion`). As leituras de `props` ficam registradas em `reads` (ver `trackReads`).
|
|
113
|
+
let attrsVersion = 0;
|
|
114
|
+
let ctxVersion = -1;
|
|
115
|
+
let ctx;
|
|
116
|
+
for (let i = 0; i < this.rules.length; i++) {
|
|
117
|
+
const rule = this.rules[i];
|
|
118
|
+
if (ctxVersion !== attrsVersion) {
|
|
119
|
+
const view = { ...mergedAttrs, ...props };
|
|
120
|
+
ctx = { theme, platform, props: reads ? trackReads(view) : view };
|
|
121
|
+
ctxVersion = attrsVersion;
|
|
122
|
+
}
|
|
123
|
+
const state = rule.kind === 'when' ? stateOf(rule.condition) : null;
|
|
124
|
+
if (rule.kind === 'when' && state) {
|
|
125
|
+
// estados viram variantes compiladas pelo adapter (`:hover`, estado do Pressable…)
|
|
126
|
+
const ruleAttrs = typeof rule.attrs === 'function' ? rule.attrs(ctx) : rule.attrs;
|
|
127
|
+
if (ruleAttrs) {
|
|
128
|
+
const { style: ruleStyle, ...restAttrs } = ruleAttrs;
|
|
129
|
+
if (ruleStyle)
|
|
130
|
+
(stateStyles[state] ??= []).push(resolveStyle(ruleStyle, ctx));
|
|
131
|
+
if (Object.keys(restAttrs).length) {
|
|
132
|
+
warnOnce(`state-attrs:${state}`, `when('state:${state}') only accepts { style }; the other props were ignored.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (rule.kind === 'when' && isPseudoCondition(rule.condition)) {
|
|
138
|
+
// pseudo-elementos: `::before` etc. viram variantes compiladas pelo adapter
|
|
139
|
+
const name = rule.condition;
|
|
140
|
+
const ruleAttrs = typeof rule.attrs === 'function' ? rule.attrs(ctx) : rule.attrs;
|
|
141
|
+
if (ruleAttrs) {
|
|
142
|
+
const { style: ruleStyle, ...restAttrs } = ruleAttrs;
|
|
143
|
+
if (ruleStyle)
|
|
144
|
+
(pseudoStyles[name] ??= []).push(resolveStyle(ruleStyle, ctx));
|
|
145
|
+
if (Object.keys(restAttrs).length) {
|
|
146
|
+
warnOnce(`pseudo-attrs:${name}`, `when('${name}') only accepts { style }; the other props were ignored.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (rule.kind === 'when' && parseBreakpoint(rule.condition)) {
|
|
152
|
+
// breakpoints viram variantes por largura mínima (`@media` na web, largura da janela no mobile)
|
|
153
|
+
const name = rule.condition;
|
|
154
|
+
const ruleAttrs = typeof rule.attrs === 'function' ? rule.attrs(ctx) : rule.attrs;
|
|
155
|
+
if (ruleAttrs) {
|
|
156
|
+
const { style: ruleStyle, ...restAttrs } = ruleAttrs;
|
|
157
|
+
if (ruleStyle)
|
|
158
|
+
(bpStyles[name] ??= []).push(resolveStyle(ruleStyle, ctx));
|
|
159
|
+
if (Object.keys(restAttrs).length) {
|
|
160
|
+
warnOnce(`bp-attrs:${name}`, `when('${name}') only accepts { style }; the other props were ignored.`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (rule.kind === 'when') {
|
|
166
|
+
if (evaluateCondition(rule.condition, ctx)) {
|
|
167
|
+
const ruleAttrs = typeof rule.attrs === 'function' ? rule.attrs(ctx) : rule.attrs;
|
|
168
|
+
if (ruleAttrs) {
|
|
169
|
+
const { style: ruleStyle, ...restAttrs } = ruleAttrs;
|
|
170
|
+
Object.assign(mergedAttrs, restAttrs);
|
|
171
|
+
attrsVersion++;
|
|
172
|
+
if (ruleStyle)
|
|
173
|
+
styles.push(resolveStyle(ruleStyle, ctx));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (rule.kind === 'style') {
|
|
178
|
+
styles.push(resolveStyle(rule.style, ctx));
|
|
179
|
+
}
|
|
180
|
+
if (rule.kind === 'attrs') {
|
|
181
|
+
const { style: attrStyle, ...restAttrs } = (rule?.attrs || {});
|
|
182
|
+
Object.assign(mergedAttrs, restAttrs);
|
|
183
|
+
attrsVersion++;
|
|
184
|
+
if (attrStyle)
|
|
185
|
+
styles.push(resolveStyle(attrStyle, ctx));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
let states;
|
|
189
|
+
for (const key in stateStyles) {
|
|
190
|
+
const state = key;
|
|
191
|
+
(states ??= {})[state] = resolveInlineKeyframes(flattenStyle(stateStyles[state]));
|
|
192
|
+
}
|
|
193
|
+
let pseudos;
|
|
194
|
+
for (const key in pseudoStyles) {
|
|
195
|
+
const name = key;
|
|
196
|
+
(pseudos ??= {})[name] = resolveInlineKeyframes(flattenStyle(pseudoStyles[name]));
|
|
197
|
+
}
|
|
198
|
+
let breakpoints;
|
|
199
|
+
const names = Object.keys(bpStyles);
|
|
200
|
+
if (names.length) {
|
|
201
|
+
// ordem global das faixas: por largura mínima; dentro da mesma, as limitadas por `max` depois
|
|
202
|
+
const mins = [0, ...new Set(Object.values(getBreakpoints()))].sort((a, b) => a - b);
|
|
203
|
+
breakpoints = names
|
|
204
|
+
.map((name) => {
|
|
205
|
+
const { min, max } = parseBreakpoint(name);
|
|
206
|
+
return {
|
|
207
|
+
name,
|
|
208
|
+
min,
|
|
209
|
+
...(max !== undefined ? { max } : null),
|
|
210
|
+
order: mins.indexOf(min) * 2 + (max !== undefined ? 1 : 0),
|
|
211
|
+
style: resolveInlineKeyframes(flattenStyle(bpStyles[name])),
|
|
212
|
+
};
|
|
213
|
+
})
|
|
214
|
+
.sort((a, b) => a.min - b.min || (b.max ?? Infinity) - (a.max ?? Infinity) || a.name.localeCompare(b.name));
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
adapter,
|
|
218
|
+
compiled: adapter.compileStyle(resolveInlineKeyframes(flattenStyle(styles)), states, breakpoints, pseudos),
|
|
219
|
+
mergedAttrs,
|
|
220
|
+
hasAttrs: attrsVersion > 0,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* `true` quando nenhuma regra depende de props — o resultado só varia por
|
|
225
|
+
* tema e dispensa hash/lookup por render.
|
|
226
|
+
*/
|
|
227
|
+
isStatic() {
|
|
228
|
+
return this.rules.every((rule) => {
|
|
229
|
+
if (rule.kind === 'style')
|
|
230
|
+
return typeof rule.style !== 'function';
|
|
231
|
+
if (rule.kind === 'attrs')
|
|
232
|
+
return typeof rule.attrs?.style !== 'function';
|
|
233
|
+
return (isStaticCondition(rule.condition) &&
|
|
234
|
+
typeof rule.attrs !== 'function' &&
|
|
235
|
+
typeof rule.attrs?.style !== 'function');
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** `ref` estático vindo de `when(...).attrs({ ref })` (independe de props/tema). */
|
|
239
|
+
findStaticRef() {
|
|
240
|
+
for (const rule of this.rules) {
|
|
241
|
+
if (rule.kind === 'when' && rule.attrs?.ref)
|
|
242
|
+
return rule.attrs.ref;
|
|
243
|
+
}
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* `build()` roda uma vez, antes do encadeamento `.style().when().attrs()`
|
|
248
|
+
* (as regras são mutadas depois e lidas ao vivo pelo render — ver proxy.ts).
|
|
249
|
+
* Por isso `isStatic`/`findStaticRef` são memoizados aqui, invalidados só
|
|
250
|
+
* quando a lista de regras cresce.
|
|
251
|
+
*/
|
|
252
|
+
staticInfoCache = null;
|
|
253
|
+
getStaticInfo() {
|
|
254
|
+
if (!this.staticInfoCache || this.staticInfoCache.length !== this.rules.length) {
|
|
255
|
+
const isStatic = this.isStatic();
|
|
256
|
+
this.staticInfoCache = {
|
|
257
|
+
length: this.rules.length,
|
|
258
|
+
isStatic,
|
|
259
|
+
ref: this.findStaticRef(),
|
|
260
|
+
inlinable: isStatic || this.rules.every((rule) => functionsOf(rule).every(isThemeFree)),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return this.staticInfoCache;
|
|
264
|
+
}
|
|
265
|
+
/** Registra o que uma compilação leu. `true` quando passou a depender de props que o hash ainda não via. */
|
|
266
|
+
learn(reads) {
|
|
267
|
+
let grew = false;
|
|
268
|
+
if (reads.all && !this.readAll) {
|
|
269
|
+
this.readAll = true;
|
|
270
|
+
grew = true;
|
|
271
|
+
}
|
|
272
|
+
for (const key of reads.keys) {
|
|
273
|
+
if (!this.readKeys.has(key)) {
|
|
274
|
+
this.readKeys.add(key);
|
|
275
|
+
grew = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return grew;
|
|
279
|
+
}
|
|
280
|
+
hashOf(platform, props) {
|
|
281
|
+
return optimizedHash({ platform, props }, this.readAll ? null : this.readKeys);
|
|
282
|
+
}
|
|
283
|
+
/** Theme cache key: the theme itself, or `ANY_THEME` while the style never read a real theme value. */
|
|
284
|
+
cacheKey(theme) {
|
|
285
|
+
return this.themeDependent ? theme : ANY_THEME;
|
|
286
|
+
}
|
|
287
|
+
/** Estilo dinâmico: cache por tema, chaveado pelas props que as regras leem. */
|
|
288
|
+
resolveDynamic(adapter, theme, variableKeys, platform, props) {
|
|
289
|
+
const signature = variableKeys ? variableKeys.join(',') : '';
|
|
290
|
+
if (signature !== this.variablesSignature) {
|
|
291
|
+
this.variablesSignature = signature;
|
|
292
|
+
this.themeDependent = false;
|
|
293
|
+
this.cacheByTheme = new WeakMap();
|
|
294
|
+
}
|
|
295
|
+
let key = this.cacheKey(theme);
|
|
296
|
+
let cache = this.cacheByTheme.get(key);
|
|
297
|
+
if (!cache) {
|
|
298
|
+
cache = new LRUCache(CACHE_LIMIT);
|
|
299
|
+
this.cacheByTheme.set(key, cache);
|
|
300
|
+
}
|
|
301
|
+
let hash = this.hashOf(platform, props);
|
|
302
|
+
const hit = cache.get(hash);
|
|
303
|
+
if (hit && hit.adapter === adapter)
|
|
304
|
+
return hit;
|
|
305
|
+
const reads = createReads();
|
|
306
|
+
const probe = { dependent: false };
|
|
307
|
+
let computed;
|
|
308
|
+
// as regras rodam de forma síncrona: as leituras de props (e do tema) vão para os registros ativos
|
|
309
|
+
const previousReads = beginPropReads(reads);
|
|
310
|
+
const previousProbe = beginThemeReads(probe);
|
|
311
|
+
try {
|
|
312
|
+
// The rules see a view of the theme that reports what they read (`dependent`). With CSS variables
|
|
313
|
+
// the listed tokens are `var(--iso-…)` and do not count; without them every theme read counts.
|
|
314
|
+
const seen = themeView(theme, variableKeys ?? NO_VARIABLE_KEYS);
|
|
315
|
+
computed = this.computeFromRules(adapter, seen, platform, props, reads);
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
endThemeReads(previousProbe);
|
|
319
|
+
endPropReads(previousReads);
|
|
320
|
+
}
|
|
321
|
+
let stale = this.learn(reads);
|
|
322
|
+
if (probe.dependent && !this.themeDependent) {
|
|
323
|
+
// o estilo lê valores reais do tema: o que foi guardado como "vale para qualquer tema" não vale mais
|
|
324
|
+
this.themeDependent = true;
|
|
325
|
+
stale = true;
|
|
326
|
+
}
|
|
327
|
+
if (stale) {
|
|
328
|
+
// as entradas antigas foram chaveadas com menos props (ou com menos tema) do que o estilo realmente usa
|
|
329
|
+
this.cacheByTheme = new WeakMap();
|
|
330
|
+
key = this.cacheKey(theme);
|
|
331
|
+
cache = new LRUCache(CACHE_LIMIT);
|
|
332
|
+
this.cacheByTheme.set(key, cache);
|
|
333
|
+
hash = this.hashOf(platform, props); // agora com as props novas
|
|
334
|
+
}
|
|
335
|
+
cache.set(hash, computed);
|
|
336
|
+
if (cache.evictions > 0)
|
|
337
|
+
this.warnThrashing();
|
|
338
|
+
return computed;
|
|
339
|
+
}
|
|
340
|
+
/** A function marked theme-free read the theme: rendered inline, the component cannot follow theme switches. */
|
|
341
|
+
warnThemeFreeRead() {
|
|
342
|
+
warnOnce(`theme-free-read:${this.id}`, 'a style marked `themeFree` read the theme. Rendered without the wrapper component, it does not follow ' +
|
|
343
|
+
'theme changes. Remove `themeFree` from that function (or read the theme only in rules that are not marked).');
|
|
344
|
+
}
|
|
345
|
+
/** O aviso de thrash já foi decidido para este builder (a mensagem não é montada a cada miss). */
|
|
346
|
+
thrashWarned = false;
|
|
347
|
+
warnThrashing() {
|
|
348
|
+
if (this.thrashWarned)
|
|
349
|
+
return;
|
|
350
|
+
this.thrashWarned = true;
|
|
351
|
+
const name = typeof this.Base === 'string' ? this.Base : this.Base?.displayName || this.Base?.name;
|
|
352
|
+
warnOnce(`cache-thrash:${this.id}`, `the style of "${name ?? 'component'}" reads props with more than ${CACHE_LIMIT} value combinations and is recompiled on every render. ` +
|
|
353
|
+
'Props that change all the time (position, progress, time) belong in `style` or an animation, not in style rules.');
|
|
354
|
+
}
|
|
355
|
+
build() {
|
|
356
|
+
const primitive = typeof this.Base === 'string' ? this.Base : undefined;
|
|
357
|
+
// Sem função nas regras o resultado não depende do tema nem das props: um único resultado por adapter.
|
|
358
|
+
let staticResult;
|
|
359
|
+
/** What the component renders for `props`: no hooks, so the JSX runtime can call it too (see `inline`). */
|
|
360
|
+
const resolve = (props, ref) => {
|
|
361
|
+
const adapter = getProvider();
|
|
362
|
+
const platform = adapter.os();
|
|
363
|
+
const { isStatic, ref: staticRef } = this.getStaticInfo();
|
|
364
|
+
// tema como variáveis CSS (web, opt-in): só com um adapter que escreve as variáveis no `:root`
|
|
365
|
+
const variableKeys = adapter.applyThemeVariables ? getThemeVariableKeys() : null;
|
|
366
|
+
// leitura direta do store; a assinatura vem depois, quando já se sabe se o estilo depende do tema
|
|
367
|
+
const theme = getTheme();
|
|
368
|
+
let result;
|
|
369
|
+
if (isStatic) {
|
|
370
|
+
result = staticResult;
|
|
371
|
+
if (!result || result.adapter !== adapter) {
|
|
372
|
+
result = this.computeFromRules(adapter, theme, platform, props, null);
|
|
373
|
+
staticResult = result;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
result = this.resolveDynamic(adapter, theme, variableKeys, platform, props);
|
|
378
|
+
}
|
|
379
|
+
const { style: userStyle, ...restProps } = props;
|
|
380
|
+
const Component = primitive
|
|
381
|
+
? adapter.primitives[primitive]
|
|
382
|
+
: this.Base;
|
|
383
|
+
if (!Component) {
|
|
384
|
+
throw new Error(`[isoform] ISO007: the primitive "${primitive}" does not exist in the provider "${adapter.name}".`);
|
|
385
|
+
}
|
|
386
|
+
// `restProps` já é uma cópia só deste render: sem props das regras, dispensa copiar de novo
|
|
387
|
+
const input = result.hasAttrs ? { ...result.mergedAttrs, ...restProps } : restProps;
|
|
388
|
+
const finalProps = adapter.applyProps({ primitive, compiled: result.compiled, props: input, userStyle });
|
|
389
|
+
const Final = adapter.resolveComponent
|
|
390
|
+
? adapter.resolveComponent(Component, result.compiled)
|
|
391
|
+
: Component;
|
|
392
|
+
// Os adapters devolvem o objeto que receberam (uma cópia deste render): o `ref` vai nele, sem outra cópia.
|
|
393
|
+
// Um adapter que devolva outro objeto (talvez compartilhado) é copiado antes, por segurança.
|
|
394
|
+
const element = finalProps === input ? finalProps : { ...finalProps };
|
|
395
|
+
element.ref = staticRef !== undefined ? staticRef : ref;
|
|
396
|
+
return { type: Final, props: element };
|
|
397
|
+
};
|
|
398
|
+
const StylizedComponent = forwardRef((props, ref) => {
|
|
399
|
+
const { type, props: element } = resolve(props, ref);
|
|
400
|
+
// Only a style that read a real theme value re-renders on a theme switch; for the others the
|
|
401
|
+
// snapshot is constant. Always exactly one hook.
|
|
402
|
+
const followsTheme = !this.getStaticInfo().isStatic && this.themeDependent;
|
|
403
|
+
const snapshot = followsTheme ? getTheme : noTheme;
|
|
404
|
+
useSyncExternalStore(themeStore.subscribe, snapshot, snapshot);
|
|
405
|
+
return React.createElement(type, element);
|
|
406
|
+
});
|
|
407
|
+
/**
|
|
408
|
+
* Called by the isoform JSX runtime instead of creating a `<Stylized>` element: a style that never
|
|
409
|
+
* reads the theme needs no hook, so the element can be the component underneath, with no wrapper.
|
|
410
|
+
*/
|
|
411
|
+
const inline = (props) => {
|
|
412
|
+
if (!isInlineEnabled() || !this.getStaticInfo().inlinable)
|
|
413
|
+
return null;
|
|
414
|
+
const element = resolve(props, props.ref);
|
|
415
|
+
if (this.themeDependent)
|
|
416
|
+
this.warnThemeFreeRead();
|
|
417
|
+
return element;
|
|
418
|
+
};
|
|
419
|
+
StylizedComponent[INLINE] = inline;
|
|
420
|
+
const base = this.Base;
|
|
421
|
+
StylizedComponent.displayName = `Stylized(${typeof base === 'string' ? base : base?.displayName || base?.name || 'Component'})`;
|
|
422
|
+
// Sem `memo` de propósito. Medido numa lista de 500 linhas (cada linha repassa `children` novos),
|
|
423
|
+
// o `memo` não consegue pular nada, adiciona uma fibra por componente (~+1 µs na montagem) e deixa a
|
|
424
|
+
// atualização ~10% mais lenta. Quem tem props estáveis memoiza a própria linha, ou deixa o React Compiler fazer.
|
|
425
|
+
return StylizedComponent;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
export function stylized(component) {
|
|
429
|
+
return new StylizedBuilder(component);
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Camera`: the device camera's live preview, with photo capture, video recording
|
|
3
|
+
* and a code scanner. The app draws its own interface (shutter, switches…) and
|
|
4
|
+
* drives the camera through props and the `ref`.
|
|
5
|
+
* - Android: CameraX with the Jetpack Compose viewfinder (`CameraXViewfinder`).
|
|
6
|
+
* - iOS: AVFoundation (`AVCaptureSession`).
|
|
7
|
+
* - Web: `getUserMedia` in a `<video>`, `MediaRecorder` and `BarcodeDetector`.
|
|
8
|
+
*/
|
|
9
|
+
/** Which camera to use. */
|
|
10
|
+
export type CameraFacing = 'back' | 'front';
|
|
11
|
+
/** Flash for photos. */
|
|
12
|
+
export type CameraFlash = 'off' | 'on' | 'auto';
|
|
13
|
+
/**
|
|
14
|
+
* Access to a device (camera or microphone).
|
|
15
|
+
* - `'undetermined'`: not asked yet (the camera asks when it becomes active).
|
|
16
|
+
* - `'granted'`: allowed.
|
|
17
|
+
* - `'denied'`: refused, but the app may ask again.
|
|
18
|
+
* - `'blocked'`: refused for good; only the system settings can change it.
|
|
19
|
+
*/
|
|
20
|
+
export type CameraPermissionStatus = 'undetermined' | 'granted' | 'denied' | 'blocked';
|
|
21
|
+
/** Permission state reported by `onPermissionChange`. */
|
|
22
|
+
export interface CameraPermission {
|
|
23
|
+
/** Camera access. */
|
|
24
|
+
camera: CameraPermissionStatus;
|
|
25
|
+
/** Microphone access (only asked when `video` is on). */
|
|
26
|
+
microphone: CameraPermissionStatus;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Kind of code the scanner looks for.
|
|
30
|
+
* - 2D: `'qr'`, `'aztec'`, `'data-matrix'`, `'pdf417'`.
|
|
31
|
+
* - 1D: `'ean-13'`, `'ean-8'`, `'upc-a'`, `'upc-e'`, `'code-128'`, `'code-39'`, `'code-93'`, `'codabar'`, `'itf'`.
|
|
32
|
+
*/
|
|
33
|
+
export type CameraCodeType = 'qr' | 'aztec' | 'data-matrix' | 'pdf417' | 'ean-13' | 'ean-8' | 'upc-a' | 'upc-e' | 'code-128' | 'code-39' | 'code-93' | 'codabar' | 'itf';
|
|
34
|
+
/** Every code type, in the order the docs list them. */
|
|
35
|
+
export declare const CAMERA_CODE_TYPES: readonly CameraCodeType[];
|
|
36
|
+
/** One code seen by the scanner. */
|
|
37
|
+
export interface CameraCode {
|
|
38
|
+
/** What it encodes (text, URL…). */
|
|
39
|
+
value: string;
|
|
40
|
+
/** Its kind. */
|
|
41
|
+
type: CameraCodeType;
|
|
42
|
+
}
|
|
43
|
+
/** A photo taken with `takePhoto`. */
|
|
44
|
+
export interface CameraPhoto {
|
|
45
|
+
/** Where the JPEG was saved (`file://` on iOS/Android, a `blob:` URL on the web). */
|
|
46
|
+
uri: string;
|
|
47
|
+
/** Width in pixels, as the photo is meant to be seen (rotation applied). */
|
|
48
|
+
width: number;
|
|
49
|
+
/** Height in pixels, as the photo is meant to be seen (rotation applied). */
|
|
50
|
+
height: number;
|
|
51
|
+
}
|
|
52
|
+
/** A video recorded with `startRecording` / `stopRecording`. */
|
|
53
|
+
export interface CameraVideo {
|
|
54
|
+
/** Where the file was saved (`file://` MP4/MOV on iOS/Android, a `blob:` URL on the web). */
|
|
55
|
+
uri: string;
|
|
56
|
+
/** Length in seconds. */
|
|
57
|
+
duration: number;
|
|
58
|
+
}
|
|
59
|
+
/** Options of `takePhoto`. */
|
|
60
|
+
export interface TakePhotoOptions {
|
|
61
|
+
/** Flash for this photo. Default: the `flash` prop. */
|
|
62
|
+
flash?: CameraFlash;
|
|
63
|
+
}
|
|
64
|
+
/** Props of `Camera` besides the common ones (`style`, `testID`…). */
|
|
65
|
+
export interface CameraOwnProps {
|
|
66
|
+
/** Which camera. Default `'back'`. */
|
|
67
|
+
facing?: CameraFacing;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the camera runs. `false` stops it (and turns the light off) while the
|
|
70
|
+
* component stays on screen: use it for hidden tabs and screens. Default `true`.
|
|
71
|
+
*/
|
|
72
|
+
active?: boolean;
|
|
73
|
+
/** Flash for photos. Default `'off'`. */
|
|
74
|
+
flash?: CameraFlash;
|
|
75
|
+
/** Keeps the light on (back camera with a flash). Default `false`. */
|
|
76
|
+
torch?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Zoom factor: `1` is no zoom, `2` is twice as close. Clamped to what the device
|
|
79
|
+
* supports. With `zoomGesture` on, pinching changes it and reports `onZoomChange`.
|
|
80
|
+
* Default `1`.
|
|
81
|
+
*/
|
|
82
|
+
zoom?: number;
|
|
83
|
+
/** Called with the new factor when pinching changes the zoom. */
|
|
84
|
+
onZoomChange?: (zoom: number) => void;
|
|
85
|
+
/** Pinch to zoom on the preview. Default `true`. */
|
|
86
|
+
zoomGesture?: boolean;
|
|
87
|
+
/** Tap on the preview to focus and expose there. Default `true`. */
|
|
88
|
+
focusGesture?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Enables recording (`startRecording`): adds the video output and asks for the
|
|
91
|
+
* microphone. Requires `camera.video` in `isoform.config.json`. Default `false`.
|
|
92
|
+
*/
|
|
93
|
+
video?: boolean;
|
|
94
|
+
/** Records sound with the video. Default `true`. */
|
|
95
|
+
audio?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Called with the codes in sight whenever they change (not on every frame).
|
|
98
|
+
* Setting it turns the scanner on. Requires `camera.codeScanner` in `isoform.config.json`.
|
|
99
|
+
*/
|
|
100
|
+
onCodeScanned?: (codes: CameraCode[]) => void;
|
|
101
|
+
/** Code kinds to look for. Default `['qr']` (fewer kinds scan faster). */
|
|
102
|
+
codeTypes?: CameraCodeType[];
|
|
103
|
+
/** Called when the preview is showing frames. */
|
|
104
|
+
onReady?: () => void;
|
|
105
|
+
/** Called when the camera fails (no camera, in use by another app…). */
|
|
106
|
+
onError?: (message: string) => void;
|
|
107
|
+
/** Called when the camera or microphone permission changes. */
|
|
108
|
+
onPermissionChange?: (permission: CameraPermission) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Text shown over the preview while the camera is not allowed. The system dialog
|
|
111
|
+
* itself uses the platform's text (on iOS, `NSCameraUsageDescription` in Info.plist).
|
|
112
|
+
* Default `'Allow camera access to use the camera.'`.
|
|
113
|
+
*/
|
|
114
|
+
permissionMessage?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Label of the button under `permissionMessage`: it asks again, or opens the system
|
|
117
|
+
* settings once the permission is blocked. Default `'Allow camera'` / `'Open settings'`.
|
|
118
|
+
*/
|
|
119
|
+
permissionButtonLabel?: string;
|
|
120
|
+
}
|
|
121
|
+
/** `ref` of a `Camera`. */
|
|
122
|
+
export interface CameraHandle {
|
|
123
|
+
/** Takes a photo (JPEG). Rejects when the camera is not ready. */
|
|
124
|
+
takePhoto(options?: TakePhotoOptions): Promise<CameraPhoto>;
|
|
125
|
+
/** Starts recording (needs `video`). Resolves once recording has started. */
|
|
126
|
+
startRecording(): Promise<void>;
|
|
127
|
+
/** Stops recording and resolves with the file. */
|
|
128
|
+
stopRecording(): Promise<CameraVideo>;
|
|
129
|
+
}
|
|
130
|
+
/** Default code kinds. */
|
|
131
|
+
export declare const DEFAULT_CODE_TYPES: CameraCodeType[];
|
|
132
|
+
/** Default texts of the permission notice. */
|
|
133
|
+
export declare const CAMERA_TEXT: {
|
|
134
|
+
readonly message: "Allow camera access to use the camera.";
|
|
135
|
+
readonly ask: "Allow camera";
|
|
136
|
+
readonly settings: "Open settings";
|
|
137
|
+
};
|
|
138
|
+
/** Clamps a zoom factor to `[min, max]` (a non-finite value becomes `min`). */
|
|
139
|
+
export declare const clampZoom: (zoom: number, min: number, max: number) => number;
|
|
140
|
+
/** Whether two code lists hold the same codes (order ignored), so unchanged scans are not reported. */
|
|
141
|
+
export declare function sameCodes(a: CameraCode[], b: CameraCode[]): boolean;
|
|
142
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Camera`: the device camera's live preview, with photo capture, video recording
|
|
3
|
+
* and a code scanner. The app draws its own interface (shutter, switches…) and
|
|
4
|
+
* drives the camera through props and the `ref`.
|
|
5
|
+
* - Android: CameraX with the Jetpack Compose viewfinder (`CameraXViewfinder`).
|
|
6
|
+
* - iOS: AVFoundation (`AVCaptureSession`).
|
|
7
|
+
* - Web: `getUserMedia` in a `<video>`, `MediaRecorder` and `BarcodeDetector`.
|
|
8
|
+
*/
|
|
9
|
+
/** Every code type, in the order the docs list them. */
|
|
10
|
+
export const CAMERA_CODE_TYPES = [
|
|
11
|
+
'qr',
|
|
12
|
+
'aztec',
|
|
13
|
+
'data-matrix',
|
|
14
|
+
'pdf417',
|
|
15
|
+
'ean-13',
|
|
16
|
+
'ean-8',
|
|
17
|
+
'upc-a',
|
|
18
|
+
'upc-e',
|
|
19
|
+
'code-128',
|
|
20
|
+
'code-39',
|
|
21
|
+
'code-93',
|
|
22
|
+
'codabar',
|
|
23
|
+
'itf',
|
|
24
|
+
];
|
|
25
|
+
/** Default code kinds. */
|
|
26
|
+
export const DEFAULT_CODE_TYPES = ['qr'];
|
|
27
|
+
/** Default texts of the permission notice. */
|
|
28
|
+
export const CAMERA_TEXT = {
|
|
29
|
+
message: 'Allow camera access to use the camera.',
|
|
30
|
+
ask: 'Allow camera',
|
|
31
|
+
settings: 'Open settings',
|
|
32
|
+
};
|
|
33
|
+
/** Clamps a zoom factor to `[min, max]` (a non-finite value becomes `min`). */
|
|
34
|
+
export const clampZoom = (zoom, min, max) => Number.isFinite(zoom) ? Math.min(Math.max(zoom, min), max) : min;
|
|
35
|
+
/** Whether two code lists hold the same codes (order ignored), so unchanged scans are not reported. */
|
|
36
|
+
export function sameCodes(a, b) {
|
|
37
|
+
if (a.length !== b.length)
|
|
38
|
+
return false;
|
|
39
|
+
const key = (code) => `${code.type}:${code.value}`;
|
|
40
|
+
const seen = new Set(a.map(key));
|
|
41
|
+
return b.every((code) => seen.has(key(code)));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=camera.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns the camera's command/event pairs into promises: each command gets an id,
|
|
3
|
+
* and the native event that carries the same id settles it.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CameraRequests<T> {
|
|
6
|
+
private next;
|
|
7
|
+
private pending;
|
|
8
|
+
/** Starts a request: `send` receives the id to pass to the native command. */
|
|
9
|
+
start(send: (id: number) => void): Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Settles the request `id`: rejects with `error` when it is not empty, else resolves.
|
|
12
|
+
* @returns whether a request was waiting for that id.
|
|
13
|
+
*/
|
|
14
|
+
settle(id: number, error: string, value: T): boolean;
|
|
15
|
+
/** Rejects every waiting request (the camera went away). */
|
|
16
|
+
cancelAll(reason: string): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=cameraRequests.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns the camera's command/event pairs into promises: each command gets an id,
|
|
3
|
+
* and the native event that carries the same id settles it.
|
|
4
|
+
*/
|
|
5
|
+
export class CameraRequests {
|
|
6
|
+
next = 1;
|
|
7
|
+
pending = new Map();
|
|
8
|
+
/** Starts a request: `send` receives the id to pass to the native command. */
|
|
9
|
+
start(send) {
|
|
10
|
+
const id = this.next++;
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
this.pending.set(id, { resolve, reject });
|
|
13
|
+
try {
|
|
14
|
+
send(id);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
this.pending.delete(id);
|
|
18
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Settles the request `id`: rejects with `error` when it is not empty, else resolves.
|
|
24
|
+
* @returns whether a request was waiting for that id.
|
|
25
|
+
*/
|
|
26
|
+
settle(id, error, value) {
|
|
27
|
+
const request = this.pending.get(id);
|
|
28
|
+
if (!request)
|
|
29
|
+
return false;
|
|
30
|
+
this.pending.delete(id);
|
|
31
|
+
if (error)
|
|
32
|
+
request.reject(new Error(error));
|
|
33
|
+
else
|
|
34
|
+
request.resolve(value);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
/** Rejects every waiting request (the camera went away). */
|
|
38
|
+
cancelAll(reason) {
|
|
39
|
+
const waiting = [...this.pending.values()];
|
|
40
|
+
this.pending.clear();
|
|
41
|
+
waiting.forEach((request) => request.reject(new Error(reason)));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=cameraRequests.js.map
|