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,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme store object that implements the external store interface.
|
|
3
|
+
*
|
|
4
|
+
* This store is compatible with React's useSyncExternalStore hook,
|
|
5
|
+
* providing a standardized interface for subscribing to theme changes.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* // Direct subscription (advanced usage)
|
|
10
|
+
* const unsubscribe = themeStore.subscribe(() => {
|
|
11
|
+
* console.log('Theme changed:', themeStore.getSnapshot());
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* // Later unsubscribe
|
|
15
|
+
* unsubscribe();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const themeStore: {
|
|
19
|
+
/**
|
|
20
|
+
* Returns the current theme snapshot.
|
|
21
|
+
*
|
|
22
|
+
* This method provides access to the current theme state
|
|
23
|
+
* without triggering a subscription. It's used by useSyncExternalStore
|
|
24
|
+
* to get the initial value and for server-side rendering.
|
|
25
|
+
*
|
|
26
|
+
* @returns The current theme object
|
|
27
|
+
*/
|
|
28
|
+
getSnapshot: () => unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Subscribes to theme changes.
|
|
31
|
+
*
|
|
32
|
+
* Adds a listener function that will be called whenever the theme changes.
|
|
33
|
+
* Returns an unsubscribe function that can be called to remove the listener.
|
|
34
|
+
*
|
|
35
|
+
* @param listener - Function to call when theme changes
|
|
36
|
+
* @returns Unsubscribe function to remove the listener
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const unsubscribe = themeStore.subscribe(() => {
|
|
41
|
+
* console.log('Theme updated');
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Clean up on unmount
|
|
45
|
+
* useEffect(() => unsubscribe, []);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
subscribe: (listener: () => void) => () => boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Updates the global theme state with deep merging.
|
|
52
|
+
*
|
|
53
|
+
* This function is the primary way to modify the application theme.
|
|
54
|
+
* It accepts either a partial theme object or an updater function,
|
|
55
|
+
* and performs a deep merge to preserve existing theme values.
|
|
56
|
+
*
|
|
57
|
+
* The API mirrors React's setState semantics for familiarity:
|
|
58
|
+
* - Object form: Directly merges the provided partial theme
|
|
59
|
+
* - Function form: Receives the previous theme and returns updates
|
|
60
|
+
*
|
|
61
|
+
* Theme updates trigger re-renders in all components using useTheme().
|
|
62
|
+
*
|
|
63
|
+
* @template T - Type of the partial theme update
|
|
64
|
+
* @param input - Partial theme object or updater function
|
|
65
|
+
* @returns The fully resolved theme after the merge
|
|
66
|
+
*
|
|
67
|
+
* @example Basic Usage
|
|
68
|
+
* ```tsx
|
|
69
|
+
* import { updateTheme } from 'react-isoform';
|
|
70
|
+
*
|
|
71
|
+
* // Update theme colors
|
|
72
|
+
* updateTheme({
|
|
73
|
+
* colors: {
|
|
74
|
+
* primary: '#007AFF',
|
|
75
|
+
* secondary: '#5856D6',
|
|
76
|
+
* background: '#FFFFFF',
|
|
77
|
+
* }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Update spacing
|
|
81
|
+
* updateTheme({
|
|
82
|
+
* spacing: {
|
|
83
|
+
* sm: 8,
|
|
84
|
+
* md: 16,
|
|
85
|
+
* lg: 24,
|
|
86
|
+
* }
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example Functional Updates
|
|
91
|
+
* ```tsx
|
|
92
|
+
* // Toggle between light and dark themes
|
|
93
|
+
* updateTheme((prevTheme) => ({
|
|
94
|
+
* colors: {
|
|
95
|
+
* primary: prevTheme.colors.primary === '#007AFF' ? '#FF3B30' : '#007AFF',
|
|
96
|
+
* background: prevTheme.colors.background === '#FFFFFF' ? '#000000' : '#FFFFFF',
|
|
97
|
+
* }
|
|
98
|
+
* }));
|
|
99
|
+
*
|
|
100
|
+
* // Increment spacing values
|
|
101
|
+
* updateTheme((prevTheme) => ({
|
|
102
|
+
* spacing: {
|
|
103
|
+
* md: prevTheme.spacing.md + 2,
|
|
104
|
+
* }
|
|
105
|
+
* }));
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example Deep Merging
|
|
109
|
+
* ```tsx
|
|
110
|
+
* // Initial theme
|
|
111
|
+
* updateTheme({
|
|
112
|
+
* colors: { primary: 'blue', secondary: 'gray' },
|
|
113
|
+
* spacing: { sm: 4, md: 8 }
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // Later update - preserves existing values
|
|
117
|
+
* updateTheme({
|
|
118
|
+
* colors: { primary: 'red' }, // secondary: 'gray' is preserved
|
|
119
|
+
* spacing: { lg: 16 } // sm: 4, md: 8 are preserved
|
|
120
|
+
* });
|
|
121
|
+
*
|
|
122
|
+
* // Final theme:
|
|
123
|
+
* // {
|
|
124
|
+
* // colors: { primary: 'red', secondary: 'gray' },
|
|
125
|
+
* // spacing: { sm: 4, md: 8, lg: 16 }
|
|
126
|
+
* // }
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @performance
|
|
130
|
+
* - Only creates new objects when changes are detected
|
|
131
|
+
* - Preserves references to unchanged nested objects
|
|
132
|
+
* - Notifies all subscribers efficiently
|
|
133
|
+
* - Returns the final merged theme for convenience
|
|
134
|
+
*/
|
|
135
|
+
export declare const updateTheme: <T extends Partial<EngineTheme>>(input: T | ((prev: EngineTheme) => T)) => EngineTheme;
|
|
136
|
+
/**
|
|
137
|
+
* Retrieves the current global theme snapshot.
|
|
138
|
+
*
|
|
139
|
+
* This function provides direct access to the current theme state
|
|
140
|
+
* without subscribing to updates. It's useful for scenarios where
|
|
141
|
+
* you need the theme value reactively.
|
|
142
|
+
*
|
|
143
|
+
* Common use cases:
|
|
144
|
+
* - Non-React utilities and services
|
|
145
|
+
* - Server-side rendering where reactivity isn't needed
|
|
146
|
+
* - One-off theme reads in event handlers
|
|
147
|
+
* - Logging and debugging
|
|
148
|
+
* - Configuration setup
|
|
149
|
+
*
|
|
150
|
+
* @returns The current theme object
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* import { getTheme } from 'react-isoform';
|
|
155
|
+
*
|
|
156
|
+
* // Get current theme for logging
|
|
157
|
+
* const currentTheme = getTheme();
|
|
158
|
+
* console.log('Current primary color:', currentTheme.colors?.primary);
|
|
159
|
+
*
|
|
160
|
+
* // Use in utility functions
|
|
161
|
+
* const getPrimaryColor = () => getTheme().colors?.primary || '#007AFF';
|
|
162
|
+
*
|
|
163
|
+
* // Use in event handlers (non-reactive)
|
|
164
|
+
* const handlePress = () => {
|
|
165
|
+
* const theme = getTheme();
|
|
166
|
+
* Analytics.track('button_press', {
|
|
167
|
+
* color_scheme: theme.colors?.primary === '#007AFF' ? 'blue' : 'other'
|
|
168
|
+
* });
|
|
169
|
+
* };
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @example Server-Side Rendering
|
|
173
|
+
* ```tsx
|
|
174
|
+
* // In SSR context, you might want to set a theme and get it immediately
|
|
175
|
+
* import { updateTheme, getTheme } from 'react-isoform';
|
|
176
|
+
*
|
|
177
|
+
* // Set initial theme based on user preferences
|
|
178
|
+
* updateTheme({ colors: { primary: userPrefersDark ? '#fff' : '#000' } });
|
|
179
|
+
*
|
|
180
|
+
* // Get the theme for rendering
|
|
181
|
+
* const theme = getTheme();
|
|
182
|
+
* const initialHtml = renderToString(<App theme={theme} />);
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @note
|
|
186
|
+
* This function does NOT subscribe to theme changes. If you need
|
|
187
|
+
* reactive updates in React components, use the useTheme hook instead.
|
|
188
|
+
*
|
|
189
|
+
* @performance
|
|
190
|
+
* - Direct property access (no subscription overhead)
|
|
191
|
+
* - No re-renders triggered
|
|
192
|
+
* - Safe to call frequently
|
|
193
|
+
* - Memory efficient (no listener management)
|
|
194
|
+
*/
|
|
195
|
+
export declare const getTheme: () => EngineTheme;
|
|
196
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { noteThemeRead } from '../variables';
|
|
2
|
+
import { deepEqual, deepMerge } from './helpers';
|
|
3
|
+
/**
|
|
4
|
+
* Default theme object used as the base for all themes.
|
|
5
|
+
*
|
|
6
|
+
* This empty object serves as a starting point that can be extended
|
|
7
|
+
* with theme values via updateTheme(). The type system ensures that
|
|
8
|
+
* any theme values conform to the EngineTheme interface.
|
|
9
|
+
*/
|
|
10
|
+
const defaultTheme = {};
|
|
11
|
+
/**
|
|
12
|
+
* Internal reference to the current global theme state.
|
|
13
|
+
*
|
|
14
|
+
* This variable holds the active theme that is accessible throughout
|
|
15
|
+
* the application. It should only be modified through the updateTheme function
|
|
16
|
+
* to ensure proper reactivity and subscriber notifications.
|
|
17
|
+
*/
|
|
18
|
+
let _currentTheme = defaultTheme;
|
|
19
|
+
/**
|
|
20
|
+
* Set of subscribers that are notified when the theme changes.
|
|
21
|
+
*
|
|
22
|
+
* This Set contains all listener functions that have been subscribed
|
|
23
|
+
* to theme updates. When the theme changes, all listeners are called
|
|
24
|
+
* to trigger re-renders in components using useTheme().
|
|
25
|
+
*/
|
|
26
|
+
const listeners = new Set();
|
|
27
|
+
/**
|
|
28
|
+
* The last few distinct themes, so a theme the app returns to keeps its **identity**.
|
|
29
|
+
*
|
|
30
|
+
* Every style cache is keyed by the theme object. `updateTheme` always builds a new object when
|
|
31
|
+
* something changed, so without this a light↔dark toggle would recompile every dynamic style on
|
|
32
|
+
* every switch, even for themes already seen. Reusing the earlier (structurally equal) object makes
|
|
33
|
+
* the way back a cache hit.
|
|
34
|
+
*/
|
|
35
|
+
const RECENT_THEMES = 8;
|
|
36
|
+
const recentThemes = [];
|
|
37
|
+
const canonicalTheme = (theme) => {
|
|
38
|
+
const seen = recentThemes.find((candidate) => deepEqual(candidate, theme));
|
|
39
|
+
if (seen)
|
|
40
|
+
return seen;
|
|
41
|
+
recentThemes.push(theme);
|
|
42
|
+
if (recentThemes.length > RECENT_THEMES)
|
|
43
|
+
recentThemes.shift();
|
|
44
|
+
return theme;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Theme store object that implements the external store interface.
|
|
48
|
+
*
|
|
49
|
+
* This store is compatible with React's useSyncExternalStore hook,
|
|
50
|
+
* providing a standardized interface for subscribing to theme changes.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* // Direct subscription (advanced usage)
|
|
55
|
+
* const unsubscribe = themeStore.subscribe(() => {
|
|
56
|
+
* console.log('Theme changed:', themeStore.getSnapshot());
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Later unsubscribe
|
|
60
|
+
* unsubscribe();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export const themeStore = {
|
|
64
|
+
/**
|
|
65
|
+
* Returns the current theme snapshot.
|
|
66
|
+
*
|
|
67
|
+
* This method provides access to the current theme state
|
|
68
|
+
* without triggering a subscription. It's used by useSyncExternalStore
|
|
69
|
+
* to get the initial value and for server-side rendering.
|
|
70
|
+
*
|
|
71
|
+
* @returns The current theme object
|
|
72
|
+
*/
|
|
73
|
+
getSnapshot: () => _currentTheme,
|
|
74
|
+
/**
|
|
75
|
+
* Subscribes to theme changes.
|
|
76
|
+
*
|
|
77
|
+
* Adds a listener function that will be called whenever the theme changes.
|
|
78
|
+
* Returns an unsubscribe function that can be called to remove the listener.
|
|
79
|
+
*
|
|
80
|
+
* @param listener - Function to call when theme changes
|
|
81
|
+
* @returns Unsubscribe function to remove the listener
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const unsubscribe = themeStore.subscribe(() => {
|
|
86
|
+
* console.log('Theme updated');
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* // Clean up on unmount
|
|
90
|
+
* useEffect(() => unsubscribe, []);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
subscribe: (listener) => {
|
|
94
|
+
listeners.add(listener);
|
|
95
|
+
return () => listeners.delete(listener);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Updates the global theme state with deep merging.
|
|
100
|
+
*
|
|
101
|
+
* This function is the primary way to modify the application theme.
|
|
102
|
+
* It accepts either a partial theme object or an updater function,
|
|
103
|
+
* and performs a deep merge to preserve existing theme values.
|
|
104
|
+
*
|
|
105
|
+
* The API mirrors React's setState semantics for familiarity:
|
|
106
|
+
* - Object form: Directly merges the provided partial theme
|
|
107
|
+
* - Function form: Receives the previous theme and returns updates
|
|
108
|
+
*
|
|
109
|
+
* Theme updates trigger re-renders in all components using useTheme().
|
|
110
|
+
*
|
|
111
|
+
* @template T - Type of the partial theme update
|
|
112
|
+
* @param input - Partial theme object or updater function
|
|
113
|
+
* @returns The fully resolved theme after the merge
|
|
114
|
+
*
|
|
115
|
+
* @example Basic Usage
|
|
116
|
+
* ```tsx
|
|
117
|
+
* import { updateTheme } from 'react-isoform';
|
|
118
|
+
*
|
|
119
|
+
* // Update theme colors
|
|
120
|
+
* updateTheme({
|
|
121
|
+
* colors: {
|
|
122
|
+
* primary: '#007AFF',
|
|
123
|
+
* secondary: '#5856D6',
|
|
124
|
+
* background: '#FFFFFF',
|
|
125
|
+
* }
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // Update spacing
|
|
129
|
+
* updateTheme({
|
|
130
|
+
* spacing: {
|
|
131
|
+
* sm: 8,
|
|
132
|
+
* md: 16,
|
|
133
|
+
* lg: 24,
|
|
134
|
+
* }
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @example Functional Updates
|
|
139
|
+
* ```tsx
|
|
140
|
+
* // Toggle between light and dark themes
|
|
141
|
+
* updateTheme((prevTheme) => ({
|
|
142
|
+
* colors: {
|
|
143
|
+
* primary: prevTheme.colors.primary === '#007AFF' ? '#FF3B30' : '#007AFF',
|
|
144
|
+
* background: prevTheme.colors.background === '#FFFFFF' ? '#000000' : '#FFFFFF',
|
|
145
|
+
* }
|
|
146
|
+
* }));
|
|
147
|
+
*
|
|
148
|
+
* // Increment spacing values
|
|
149
|
+
* updateTheme((prevTheme) => ({
|
|
150
|
+
* spacing: {
|
|
151
|
+
* md: prevTheme.spacing.md + 2,
|
|
152
|
+
* }
|
|
153
|
+
* }));
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example Deep Merging
|
|
157
|
+
* ```tsx
|
|
158
|
+
* // Initial theme
|
|
159
|
+
* updateTheme({
|
|
160
|
+
* colors: { primary: 'blue', secondary: 'gray' },
|
|
161
|
+
* spacing: { sm: 4, md: 8 }
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* // Later update - preserves existing values
|
|
165
|
+
* updateTheme({
|
|
166
|
+
* colors: { primary: 'red' }, // secondary: 'gray' is preserved
|
|
167
|
+
* spacing: { lg: 16 } // sm: 4, md: 8 are preserved
|
|
168
|
+
* });
|
|
169
|
+
*
|
|
170
|
+
* // Final theme:
|
|
171
|
+
* // {
|
|
172
|
+
* // colors: { primary: 'red', secondary: 'gray' },
|
|
173
|
+
* // spacing: { sm: 4, md: 8, lg: 16 }
|
|
174
|
+
* // }
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @performance
|
|
178
|
+
* - Only creates new objects when changes are detected
|
|
179
|
+
* - Preserves references to unchanged nested objects
|
|
180
|
+
* - Notifies all subscribers efficiently
|
|
181
|
+
* - Returns the final merged theme for convenience
|
|
182
|
+
*/
|
|
183
|
+
export const updateTheme = (input) => {
|
|
184
|
+
// Store previous theme for functional updates
|
|
185
|
+
const prev = _currentTheme;
|
|
186
|
+
// Resolve the partial update from input
|
|
187
|
+
const nextPartial = typeof input === 'function' ? input(prev) : input;
|
|
188
|
+
// Deep merge the partial update into the current theme, reusing the object of an equal theme seen before
|
|
189
|
+
_currentTheme = canonicalTheme(deepMerge(prev, nextPartial));
|
|
190
|
+
// Notify all subscribers of the change
|
|
191
|
+
listeners.forEach(listener => listener());
|
|
192
|
+
// Return the fully resolved theme
|
|
193
|
+
return _currentTheme;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Retrieves the current global theme snapshot.
|
|
197
|
+
*
|
|
198
|
+
* This function provides direct access to the current theme state
|
|
199
|
+
* without subscribing to updates. It's useful for scenarios where
|
|
200
|
+
* you need the theme value reactively.
|
|
201
|
+
*
|
|
202
|
+
* Common use cases:
|
|
203
|
+
* - Non-React utilities and services
|
|
204
|
+
* - Server-side rendering where reactivity isn't needed
|
|
205
|
+
* - One-off theme reads in event handlers
|
|
206
|
+
* - Logging and debugging
|
|
207
|
+
* - Configuration setup
|
|
208
|
+
*
|
|
209
|
+
* @returns The current theme object
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* import { getTheme } from 'react-isoform';
|
|
214
|
+
*
|
|
215
|
+
* // Get current theme for logging
|
|
216
|
+
* const currentTheme = getTheme();
|
|
217
|
+
* console.log('Current primary color:', currentTheme.colors?.primary);
|
|
218
|
+
*
|
|
219
|
+
* // Use in utility functions
|
|
220
|
+
* const getPrimaryColor = () => getTheme().colors?.primary || '#007AFF';
|
|
221
|
+
*
|
|
222
|
+
* // Use in event handlers (non-reactive)
|
|
223
|
+
* const handlePress = () => {
|
|
224
|
+
* const theme = getTheme();
|
|
225
|
+
* Analytics.track('button_press', {
|
|
226
|
+
* color_scheme: theme.colors?.primary === '#007AFF' ? 'blue' : 'other'
|
|
227
|
+
* });
|
|
228
|
+
* };
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @example Server-Side Rendering
|
|
232
|
+
* ```tsx
|
|
233
|
+
* // In SSR context, you might want to set a theme and get it immediately
|
|
234
|
+
* import { updateTheme, getTheme } from 'react-isoform';
|
|
235
|
+
*
|
|
236
|
+
* // Set initial theme based on user preferences
|
|
237
|
+
* updateTheme({ colors: { primary: userPrefersDark ? '#fff' : '#000' } });
|
|
238
|
+
*
|
|
239
|
+
* // Get the theme for rendering
|
|
240
|
+
* const theme = getTheme();
|
|
241
|
+
* const initialHtml = renderToString(<App theme={theme} />);
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @note
|
|
245
|
+
* This function does NOT subscribe to theme changes. If you need
|
|
246
|
+
* reactive updates in React components, use the useTheme hook instead.
|
|
247
|
+
*
|
|
248
|
+
* @performance
|
|
249
|
+
* - Direct property access (no subscription overhead)
|
|
250
|
+
* - No re-renders triggered
|
|
251
|
+
* - Safe to call frequently
|
|
252
|
+
* - Memory efficient (no listener management)
|
|
253
|
+
*/
|
|
254
|
+
export const getTheme = () => {
|
|
255
|
+
// inside a style rule, reading the theme this way makes the style depend on it, like `ctx.theme` does
|
|
256
|
+
noteThemeRead();
|
|
257
|
+
return _currentTheme;
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--iso-…` name → value, for every string under the listed top-level keys.
|
|
3
|
+
* Arrays are not walked: a token list is not something a style references by name.
|
|
4
|
+
*/
|
|
5
|
+
export declare function variablesOf(theme: unknown, keys: readonly string[]): Record<string, string>;
|
|
6
|
+
/** The `:root` rule that carries the values. */
|
|
7
|
+
export declare const themeCss: (variables: Record<string, string>) => string;
|
|
8
|
+
/** What a style computation read from the theme that is NOT a variable. */
|
|
9
|
+
export interface ThemeProbe {
|
|
10
|
+
dependent: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Starts recording theme reads that are real values. Returns what to pass to `endThemeReads`. */
|
|
13
|
+
export declare const beginThemeReads: (probe: ThemeProbe) => ThemeProbe | null;
|
|
14
|
+
export declare const endThemeReads: (previous: ThemeProbe | null) => void;
|
|
15
|
+
/** A style computation reached the theme some other way (`getTheme()` inside a rule): it depends on it. */
|
|
16
|
+
export declare const noteThemeRead: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* The theme as style rules should see it. Same shape as `theme`; under the listed keys every safe
|
|
19
|
+
* string is `var(--iso-…)`, and every other value reports its read (see `ThemeProbe`).
|
|
20
|
+
* One view per theme object.
|
|
21
|
+
*/
|
|
22
|
+
export declare function themeView<T extends object>(theme: T, keys: readonly string[]): T;
|
|
23
|
+
//# sourceMappingURL=variables.d.ts.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* Theme as CSS variables (web, opt-in: `configure({ performance: { themeVariables: ['color'] } })`).
|
|
4
|
+
*
|
|
5
|
+
* The problem: a style rule that reads `theme.color.background` compiles to a class holding that
|
|
6
|
+
* *value*, so every theme switch recompiles the style and re-renders the component.
|
|
7
|
+
*
|
|
8
|
+
* The idea: for the theme branches the app lists (`'color'`…), the style rules are given
|
|
9
|
+
* `var(--iso-color-background)` instead of the value, and the real values live in one `:root` rule.
|
|
10
|
+
* A theme switch then rewrites that one rule. A component whose styles only read those tokens does
|
|
11
|
+
* not depend on the theme object any more: it does not subscribe to it, does not re-render and
|
|
12
|
+
* does not recompile.
|
|
13
|
+
*
|
|
14
|
+
* What it asks of the app: the listed branches must hold **CSS-ready string values** that the style
|
|
15
|
+
* only passes through (`backgroundColor: theme.color.bg`, or inside a template string). A rule that
|
|
16
|
+
* computes with them (`theme.color.bg + '80'`, parsing a color) would get a `var(...)` text instead of a
|
|
17
|
+
* value. Numbers, booleans and anything outside the listed branches stay real values, and a style
|
|
18
|
+
* that reads one of them keeps depending on the theme, exactly as before.
|
|
19
|
+
*/
|
|
20
|
+
/** Custom property prefix: `theme.color.bg` → `--iso-color-bg`. */
|
|
21
|
+
const PREFIX = '--iso-';
|
|
22
|
+
/** Values that could escape a CSS rule (also checked by the web sheet). Left as real values instead. */
|
|
23
|
+
const UNSAFE = /[{}]|<\/style/i;
|
|
24
|
+
const nameOf = (path) => PREFIX + path.map((part) => part.replace(/[^\w-]/g, '_')).join('-');
|
|
25
|
+
const isContainer = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
+
const isVariableValue = (value) => typeof value === 'string' && !UNSAFE.test(value);
|
|
27
|
+
/**
|
|
28
|
+
* `--iso-…` name → value, for every string under the listed top-level keys.
|
|
29
|
+
* Arrays are not walked: a token list is not something a style references by name.
|
|
30
|
+
*/
|
|
31
|
+
export function variablesOf(theme, keys) {
|
|
32
|
+
const out = {};
|
|
33
|
+
const walk = (node, path) => {
|
|
34
|
+
if (isContainer(node)) {
|
|
35
|
+
for (const key of Object.keys(node))
|
|
36
|
+
walk(node[key], [...path, key]);
|
|
37
|
+
}
|
|
38
|
+
else if (isVariableValue(node)) {
|
|
39
|
+
out[nameOf(path)] = node;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (isContainer(theme))
|
|
43
|
+
for (const key of keys)
|
|
44
|
+
if (key in theme)
|
|
45
|
+
walk(theme[key], [key]);
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** The `:root` rule that carries the values. */
|
|
49
|
+
export const themeCss = (variables) => {
|
|
50
|
+
const body = Object.keys(variables)
|
|
51
|
+
.map((name) => `${name}:${variables[name]}`)
|
|
52
|
+
.join(';');
|
|
53
|
+
return body ? `:root{${body}}` : '';
|
|
54
|
+
};
|
|
55
|
+
let activeProbe = null;
|
|
56
|
+
/** Starts recording theme reads that are real values. Returns what to pass to `endThemeReads`. */
|
|
57
|
+
export const beginThemeReads = (probe) => {
|
|
58
|
+
const previous = activeProbe;
|
|
59
|
+
activeProbe = probe;
|
|
60
|
+
return previous;
|
|
61
|
+
};
|
|
62
|
+
export const endThemeReads = (previous) => {
|
|
63
|
+
activeProbe = previous;
|
|
64
|
+
};
|
|
65
|
+
/** A style computation reached the theme some other way (`getTheme()` inside a rule): it depends on it. */
|
|
66
|
+
export const noteThemeRead = () => {
|
|
67
|
+
if (activeProbe)
|
|
68
|
+
activeProbe.dependent = true;
|
|
69
|
+
};
|
|
70
|
+
/** A property whose value is real: reading it marks the running computation as theme-dependent. */
|
|
71
|
+
const reportedValue = (target, key, value) => {
|
|
72
|
+
Object.defineProperty(target, key, {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
get() {
|
|
76
|
+
if (activeProbe)
|
|
77
|
+
activeProbe.dependent = true;
|
|
78
|
+
return value;
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
/** A branch of the listed keys: strings become `var(...)`, every other leaf is a reporting getter. */
|
|
83
|
+
function mirror(node, path) {
|
|
84
|
+
const out = {};
|
|
85
|
+
for (const key of Object.keys(node)) {
|
|
86
|
+
const value = node[key];
|
|
87
|
+
const here = [...path, key];
|
|
88
|
+
if (isContainer(value))
|
|
89
|
+
out[key] = mirror(value, here);
|
|
90
|
+
else if (isVariableValue(value))
|
|
91
|
+
out[key] = `var(${nameOf(here)})`;
|
|
92
|
+
else
|
|
93
|
+
reportedValue(out, key, value);
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
let cache = new WeakMap();
|
|
98
|
+
let cacheKeys = '';
|
|
99
|
+
/**
|
|
100
|
+
* The theme as style rules should see it. Same shape as `theme`; under the listed keys every safe
|
|
101
|
+
* string is `var(--iso-…)`, and every other value reports its read (see `ThemeProbe`).
|
|
102
|
+
* One view per theme object.
|
|
103
|
+
*/
|
|
104
|
+
export function themeView(theme, keys) {
|
|
105
|
+
const signature = keys.join('\u0000');
|
|
106
|
+
if (signature !== cacheKeys) {
|
|
107
|
+
cache = new WeakMap();
|
|
108
|
+
cacheKeys = signature;
|
|
109
|
+
}
|
|
110
|
+
let view = cache.get(theme);
|
|
111
|
+
if (view)
|
|
112
|
+
return view;
|
|
113
|
+
const built = {};
|
|
114
|
+
for (const key of Object.keys(theme)) {
|
|
115
|
+
const value = theme[key];
|
|
116
|
+
if (keys.includes(key) && isContainer(value))
|
|
117
|
+
built[key] = mirror(value, [key]);
|
|
118
|
+
else if (keys.includes(key) && isVariableValue(value))
|
|
119
|
+
built[key] = `var(${nameOf([key])})`;
|
|
120
|
+
else
|
|
121
|
+
reportedValue(built, key, value);
|
|
122
|
+
}
|
|
123
|
+
view = built;
|
|
124
|
+
cache.set(theme, view);
|
|
125
|
+
return view;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=variables.js.map
|