vibefast-cli 1.1.5 → 1.3.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/CHANGELOG.md +32 -0
- package/README.md +63 -169
- package/dist/__tests__/recipes.test.js +89 -85
- package/dist/__tests__/recipes.test.js.map +1 -1
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +576 -588
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/checklist.d.ts +1 -1
- package/dist/commands/checklist.d.ts.map +1 -1
- package/dist/commands/checklist.js +40 -39
- package/dist/commands/checklist.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +22 -22
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.d.ts +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +58 -53
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/health.d.ts +1 -1
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +101 -93
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +416 -296
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/remove.d.ts +1 -1
- package/dist/commands/remove.d.ts.map +1 -1
- package/dist/commands/remove.js +77 -64
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +15 -14
- package/dist/commands/status.js.map +1 -1
- package/dist/core/__tests__/detect.test.js +68 -34
- package/dist/core/__tests__/detect.test.js.map +1 -1
- package/dist/core/ast.d.ts +14 -0
- package/dist/core/ast.d.ts.map +1 -0
- package/dist/core/ast.js +239 -0
- package/dist/core/ast.js.map +1 -0
- package/dist/core/codemod.d.ts.map +1 -1
- package/dist/core/codemod.js +62 -44
- package/dist/core/codemod.js.map +1 -1
- package/dist/core/config.d.ts +10 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +51 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/detect.d.ts +8 -2
- package/dist/core/detect.d.ts.map +1 -1
- package/dist/core/detect.js +52 -21
- package/dist/core/detect.js.map +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +9 -8
- package/dist/core/errors.js.map +1 -1
- package/dist/core/exec.d.ts +16 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +48 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/manualSteps.d.ts +7 -0
- package/dist/core/manualSteps.d.ts.map +1 -0
- package/dist/core/manualSteps.js +59 -0
- package/dist/core/manualSteps.js.map +1 -0
- package/dist/core/paths.d.ts +3 -1
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/paths.js +14 -10
- package/dist/core/paths.js.map +1 -1
- package/dist/core/spinner.d.ts +1 -1
- package/dist/core/spinner.d.ts.map +1 -1
- package/dist/core/spinner.js +38 -8
- package/dist/core/spinner.js.map +1 -1
- package/dist/core/vosk.d.ts.map +1 -1
- package/dist/core/vosk.js +50 -39
- package/dist/core/vosk.js.map +1 -1
- package/docs/manual-testing.md +91 -0
- package/package.json +6 -3
- package/recipes/audio-recorder/apps/native/src/app/audio-recorder/index.tsx +5 -0
- package/recipes/audio-recorder/recipe.json +3 -3
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/components/audio-player.tsx +301 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/components/audio-recorder.tsx +373 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/components/audio-waveform.tsx +270 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/components/index.ts +4 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/components/recording-list.tsx +89 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/demo/audio-player-demo.tsx +66 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/demo/audio-recorder-cloud.tsx +68 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/demo/audio-recorder-interview.tsx +102 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/demo/basic.tsx +27 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/demo/index.ts +5 -0
- package/recipes/audio-recorder-supabase/apps/native/src/features/audio-recorder/demo/with-recording-list-demo.tsx +82 -0
- package/recipes/audio-recorder-supabase/packages/backend/src/services/recordings.ts +369 -0
- package/recipes/audio-recorder-supabase/packages/backend/supabase/migrations/recordings.sql +70 -0
- package/recipes/audio-recorder-supabase/recipe.json +52 -0
- package/recipes/audio-recorder-supabase@latest.zip +0 -0
- package/recipes/audio-recorder@latest.zip +0 -0
- package/recipes/charts/apps/native/src/features/charts/components/bar-chart.tsx +3 -3
- package/recipes/charts/apps/native/src/features/charts/components/candlestick-chart.tsx +2 -2
- package/recipes/charts/apps/native/src/features/charts/components/chart-card.tsx +5 -5
- package/recipes/charts/apps/native/src/features/charts/components/column-chart.tsx +3 -3
- package/recipes/charts/apps/native/src/features/charts/components/doughnut-chart.tsx +20 -4
- package/recipes/charts/apps/native/src/features/charts/components/line-chart.tsx +7 -6
- package/recipes/charts/apps/native/src/features/charts/components/radar-chart.tsx +6 -4
- package/recipes/charts/apps/native/src/features/charts/components/radial-bar-chart.tsx +1 -1
- package/recipes/charts/apps/native/src/features/charts/components/stacked-bar-chart.tsx +5 -4
- package/recipes/charts/recipe.json +4 -13
- package/recipes/charts@latest.zip +0 -0
- package/recipes/chatbot/apps/native/src/app/chatbot/index.tsx +1 -0
- package/recipes/chatbot/apps/native/src/features/chatbot/components/chat-markdown.tsx +86 -86
- package/recipes/chatbot/apps/native/src/features/chatbot/components/markdown/code-block.tsx +86 -53
- package/recipes/chatbot/recipe.json +26 -92
- package/recipes/chatbot-supabase/apps/native/src/api-client/supabase/chatbot.ts +515 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/app/index.tsx +257 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/chat-header-buttons.tsx +59 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/chat-input-bar.tsx +485 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/chat-markdown.tsx +575 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/chat-message-bubble.tsx +223 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/chat-settings-modal.tsx +161 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/image-preview-list.tsx +116 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/markdown/code-block.tsx +165 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/markdown/index.ts +10 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/markdown/table-renderer.tsx +129 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/message-error-boundary.tsx +78 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/message-list.tsx +170 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/model-selector.tsx +283 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/report-content-modal.tsx +188 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/suggested-messages.tsx +67 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/constants/models.ts +20 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/constants/report-reasons.ts +9 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-attachment-cache.ts +142 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-chat-config.ts +458 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-chat-handlers.ts +429 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-chatbot-settings.ts +89 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-conversation.ts +90 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-image-picker.ts +122 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-keyboard-coordinator.ts +161 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/hooks/use-smart-scroll-manager.ts +213 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/models/index.ts +86 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/models/models.ts +162 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/models/providers.ts +62 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/models/types.ts +40 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/services/file-uploader.ts +287 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/services/message-handler-service.ts +189 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/types/index.ts +70 -0
- package/recipes/chatbot-supabase/apps/native/src/features/chatbot/utils/chat-telemetry.ts +91 -0
- package/recipes/chatbot-supabase/packages/backend/src/services/conversations.ts +243 -0
- package/recipes/chatbot-supabase/packages/backend/src/services/messages.ts +327 -0
- package/recipes/chatbot-supabase/packages/backend/supabase/functions/chat-stream/index.ts +347 -0
- package/recipes/chatbot-supabase/packages/backend/supabase/migrations/chatbot.sql +104 -0
- package/recipes/chatbot-supabase/recipe.json +106 -0
- package/recipes/chatbot-supabase@latest.zip +0 -0
- package/recipes/chatbot.zip +0 -0
- package/recipes/chatbot@latest.zip +0 -0
- package/recipes/image-analysis/packages/backend/convex/imageAnalysis/index.ts +2 -2
- package/recipes/image-analysis/packages/backend/convex/imageAnalysis.ts +0 -1
- package/recipes/image-analysis/recipe.json +15 -55
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/analysis-options-screen.tsx +304 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/camera.tsx +221 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/image-capture-screen.tsx +333 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/loading-screen.tsx +214 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/loading.tsx +191 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/results.tsx +137 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/trait-details.tsx +172 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/use-analysis-data.ts +160 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/app/use-results-screen.ts +151 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/achievement-badge.tsx +77 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/achievement-card.tsx +75 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/achievement-unlocked-modal.tsx +162 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/achievements-section.tsx +44 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/advice-list.tsx +42 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/circular-progress.tsx +233 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/content-card.tsx +38 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/error-state.tsx +42 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/index.ts +9 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/loading-state.tsx +26 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/profile-image.tsx +60 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/results-header.tsx +62 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/score-display.tsx +54 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/share-options-modal.tsx +110 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/components/results/traits-grid.tsx +74 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/config/analysis-config.ts +80 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/config/master-analysis-config.ts +157 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/hooks/index.ts +1 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/hooks/use-analysis.ts +38 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/hooks/use-image-analysis.ts +208 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/services/analysis-service.ts +262 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/services/share-service.ts +176 -0
- package/recipes/image-analysis-supabase/apps/native/src/features/image-analyzer/services/trait-details-service.ts +289 -0
- package/recipes/image-analysis-supabase/packages/backend/src/services/image-analyses.ts +132 -0
- package/recipes/image-analysis-supabase/packages/backend/supabase/functions/analyze-image/index.ts +312 -0
- package/recipes/image-analysis-supabase/packages/backend/supabase/migrations/image_analysis.sql +42 -0
- package/recipes/image-analysis-supabase/recipe.json +90 -0
- package/recipes/image-analysis-supabase@latest.zip +0 -0
- package/recipes/image-analysis@latest.zip +0 -0
- package/recipes/image-generator/apps/native/src/features/image-generator/app/index.tsx +16 -2
- package/recipes/image-generator/apps/native/src/features/image-generator/components/image-model-selector.tsx +11 -5
- package/recipes/image-generator/apps/native/src/features/image-generator/hooks/use-image-generator.ts +11 -5
- package/recipes/image-generator/packages/backend/convex/imageGeneration/index.ts +2 -2
- package/recipes/image-generator/recipe.json +16 -39
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/app/_layout.tsx +26 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/app/gallery.tsx +217 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/app/index.tsx +251 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/components/gallery-image.tsx +25 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/components/image-detail-modal.tsx +215 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/components/image-model-selector.tsx +216 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/components/image-placeholder.tsx +26 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/hooks/use-image-gallery.ts +71 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/hooks/use-image-generator-settings.ts +152 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/hooks/use-image-generator.ts +103 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/models/models.ts +66 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/services/image-gallery-service.ts +96 -0
- package/recipes/image-generator-supabase/apps/native/src/features/image-generator/services/image-save-service.ts +120 -0
- package/recipes/image-generator-supabase/packages/backend/supabase/functions/generate-image/index.ts +291 -0
- package/recipes/image-generator-supabase/packages/backend/supabase/migrations/image_generator.sql +71 -0
- package/recipes/image-generator-supabase/recipe.json +86 -0
- package/recipes/image-generator-supabase@latest.zip +0 -0
- package/recipes/image-generator@latest.zip +0 -0
- package/recipes/ios-widget/recipe.json +15 -24
- package/recipes/ios-widget@latest.zip +0 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/analytics/index.ts +9 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/components/onboarding-with-analytics.tsx +141 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/components/onboarding.tsx +173 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/config/onboarding-flow-config.ts +189 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/demo-one/app/index.tsx +42 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/demo-one/data.ts +32 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/app/index.tsx +43 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/interactive-onboarding.tsx +222 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/ai-tone-step.tsx +133 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/currency-step.tsx +165 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/feature-ai-step.tsx +199 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/feature-chatbot-step.tsx +154 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/feature-manual-step.tsx +156 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/feature-scan-step.tsx +158 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/main-reason-step.tsx +139 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/notification-step.tsx +129 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/overspend-step.tsx +138 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/personalizing-step.tsx +190 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/rating-step.tsx +98 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/reminder-step.tsx +181 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/safety-step.tsx +110 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/struggle-step.tsx +139 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/steps/welcome-step.tsx +217 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/components/ui/onboarding-header.tsx +58 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/expense-tracker/constants.ts +179 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/hooks/use-onboarding-analytics.ts +323 -0
- package/recipes/onboarding/apps/native/src/features/onboarding/services/onboarding-analytics.ts +432 -0
- package/recipes/onboarding/recipe.json +15 -0
- package/recipes/onboarding@latest.zip +0 -0
- package/recipes/payments/recipe.json +28 -61
- package/recipes/payments-supabase/apps/native/src/features/payments/README.md +200 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/app/local-paywall.tsx +194 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/app/remote-paywall.tsx +79 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/components/payment-initializer.tsx +95 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/components/paywall-error-state.tsx +60 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/components/paywall-local-mode.tsx +116 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/components/paywall-product-card.tsx +133 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/components/paywall-remote-mode.tsx +146 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/hooks/use-entitlement.ts +63 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/index.ts +8 -0
- package/recipes/payments-supabase/apps/native/src/features/payments/services/revenuecat-adapter.ts +407 -0
- package/recipes/payments-supabase/packages/backend/src/services/payments.ts +201 -0
- package/recipes/payments-supabase/packages/backend/supabase/migrations/payments.sql +35 -0
- package/recipes/payments-supabase/recipe.json +72 -0
- package/recipes/payments-supabase@latest.zip +0 -0
- package/recipes/payments@latest.zip +0 -0
- package/recipes/quiz/apps/native/src/features/quiz/index.tsx +1 -2
- package/recipes/quiz/recipe.json +6 -9
- package/recipes/quiz@latest.zip +0 -0
- package/recipes/tracker-app/apps/native/src/features/tracker-app/app/index.tsx +1 -2
- package/recipes/tracker-app/recipe.json +7 -10
- package/recipes/tracker-app@latest.zip +0 -0
- package/recipes/voice-bot/recipe.json +8 -68
- package/recipes/voice-bot.zip +0 -0
- package/recipes/voice-bot@latest.zip +0 -0
- package/recipes/wake-word/recipe.json +10 -9
- package/recipes/wake-word.zip +0 -0
- package/recipes/wake-word@latest.zip +0 -0
- package/recipes/charts/apps/native/src/app/(root)/(protected)/charts/index.tsx +0 -3
- package/recipes/chatbot/packages/backend/convex/lib/rateLimit.ts +0 -100
- package/recipes/chatbot/packages/backend/convex/lib/telemetry.ts +0 -29
- package/recipes/chatbot/packages/backend/convex/ragKnowledge.ts +0 -0
- package/recipes/image-analysis/apps/native/assets/features/image-analyzer/front.jpg +0 -0
- package/recipes/image-analysis/apps/native/assets/features/image-analyzer/side.jpg +0 -0
- package/recipes/image-analysis/apps/native/assets/features/image-analyzer/threeQuarter.jpg +0 -0
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/_layout.tsx +0 -5
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/analysis-options.tsx +0 -50
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/camera.tsx +0 -2
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/index.tsx +0 -50
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/loading.tsx +0 -50
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/results.tsx +0 -2
- package/recipes/image-analysis/apps/native/src/app/(root)/(protected)/analysis/[type]/trait-details.tsx +0 -3
- package/recipes/image-analysis/packages/backend/convex/imageAnalysisFunctions.ts +0 -325
- package/recipes/image-analysis/packages/backend/convex/lib/ai/imageAnalysisAdapter.ts +0 -200
- package/recipes/payments/apps/native/src/app/(root)/(protected)/paywall/index.tsx +0 -74
- package/recipes/payments/apps/native/src/app/(root)/(protected)/paywall/local.tsx +0 -25
- package/recipes/payments/apps/native/src/app/(root)/(protected)/paywall/remote.tsx +0 -23
- package/recipes/quiz/apps/native/src/app/(root)/(protected)/quiz/index.tsx +0 -47
- package/recipes/tracker-app/apps/native/src/app/(root)/(protected)/tracker-app/index.tsx +0 -1
- package/recipes/voice-bot/apps/native/src/app/(root)/(protected)/voice-bot/index.tsx +0 -27
- package/recipes/voice-bot/packages/backend/convex/router.ts +0 -81
- /package/recipes/{chatbot/apps/native/src/app/(root)/(protected) → chatbot-supabase/apps/native/src/app}/chatbot/index.tsx +0 -0
- /package/recipes/{image-generator/apps/native/src/app/(root)/(protected) → image-generator-supabase/apps/native/src/app}/image-generator/gallery.tsx +0 -0
- /package/recipes/{image-generator/apps/native/src/app/(root)/(protected) → image-generator-supabase/apps/native/src/app}/image-generator/index.tsx +0 -0
package/recipes/chatbot-supabase/apps/native/src/features/chatbot/components/chat-markdown.tsx
ADDED
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatMarkdown component for rendering markdown content in chat messages.
|
|
3
|
+
*
|
|
4
|
+
* This component has been refactored to improve modularity:
|
|
5
|
+
* - CodeBlock component extracted to ./markdown/code-block.tsx
|
|
6
|
+
* - TableRenderer component extracted to ./markdown/table-renderer.tsx
|
|
7
|
+
*
|
|
8
|
+
* The remaining code consists primarily of:
|
|
9
|
+
* - Style definitions (markdownStyles object)
|
|
10
|
+
* - Render rules configuration
|
|
11
|
+
* - Theme integration
|
|
12
|
+
*
|
|
13
|
+
* Requirements addressed:
|
|
14
|
+
* - 5.1: Extract CodeBlock component into separate file
|
|
15
|
+
* - 5.2: Extract table rendering logic into dedicated file
|
|
16
|
+
* - 5.3: Add JSDoc comments to exported functions
|
|
17
|
+
*
|
|
18
|
+
* Note: This file still exceeds 300 lines due to extensive style definitions
|
|
19
|
+
* and render rules, but the complex logic has been extracted into separate modules.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import * as Clipboard from 'expo-clipboard';
|
|
23
|
+
import MarkdownIt from 'markdown-it';
|
|
24
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
25
|
+
import {
|
|
26
|
+
Image,
|
|
27
|
+
type ImageStyle,
|
|
28
|
+
Linking,
|
|
29
|
+
Platform,
|
|
30
|
+
StyleSheet,
|
|
31
|
+
Text,
|
|
32
|
+
type TextStyle,
|
|
33
|
+
UIManager,
|
|
34
|
+
View,
|
|
35
|
+
type ViewStyle,
|
|
36
|
+
} from 'react-native';
|
|
37
|
+
import Markdown, { type RenderRules } from 'react-native-markdown-display';
|
|
38
|
+
import { atomOneDark, github } from 'react-syntax-highlighter/styles/hljs';
|
|
39
|
+
|
|
40
|
+
import { useToast } from '@/components/ui/utils';
|
|
41
|
+
import { translate } from '@/lib';
|
|
42
|
+
import { useThemeConfig } from '@/lib/use-theme-config';
|
|
43
|
+
|
|
44
|
+
import { CodeBlock, TableRenderer } from './markdown';
|
|
45
|
+
|
|
46
|
+
const md = new MarkdownIt({
|
|
47
|
+
linkify: true,
|
|
48
|
+
breaks: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
type ChatMarkdownProps = {
|
|
52
|
+
content: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Renders markdown content with syntax highlighting, tables, and rich formatting.
|
|
57
|
+
*
|
|
58
|
+
* @param content - Markdown string to render
|
|
59
|
+
* @param onPrepareLayoutAnimation - Optional callback to prepare FlashList for layout changes
|
|
60
|
+
* @returns Rendered markdown content
|
|
61
|
+
*/
|
|
62
|
+
export const ChatMarkdown = React.memo(function ChatMarkdown({
|
|
63
|
+
content,
|
|
64
|
+
}: ChatMarkdownProps) {
|
|
65
|
+
const theme = useThemeConfig();
|
|
66
|
+
const toast = useToast();
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (
|
|
70
|
+
Platform.OS === 'android' &&
|
|
71
|
+
typeof UIManager.setLayoutAnimationEnabledExperimental === 'function'
|
|
72
|
+
) {
|
|
73
|
+
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
74
|
+
}
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
const textColor = theme.colors.text as string;
|
|
78
|
+
const linkColor = theme.colors.primary as string;
|
|
79
|
+
const codeBg = theme.colors.muted as string;
|
|
80
|
+
const codeFg = theme.colors.foreground as string;
|
|
81
|
+
const subtleText = theme.colors.mutedForeground as string;
|
|
82
|
+
const borderColor = theme.colors.border as string;
|
|
83
|
+
const isDarkMode = theme.dark ?? false;
|
|
84
|
+
|
|
85
|
+
const monospaceFontFamily = useMemo(
|
|
86
|
+
() =>
|
|
87
|
+
Platform.select({
|
|
88
|
+
ios: 'Menlo-Regular',
|
|
89
|
+
android: 'monospace',
|
|
90
|
+
default: 'Menlo',
|
|
91
|
+
}) ?? 'Menlo',
|
|
92
|
+
[],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const columnDividerWidth = StyleSheet.hairlineWidth || 0.5;
|
|
96
|
+
|
|
97
|
+
const markdownStyles = useMemo(() => {
|
|
98
|
+
const codeBlockStyle = {
|
|
99
|
+
backgroundColor: codeBg,
|
|
100
|
+
borderBlockColor: borderColor,
|
|
101
|
+
paddingTop: 24,
|
|
102
|
+
paddingHorizontal: 14,
|
|
103
|
+
paddingBottom: 20,
|
|
104
|
+
borderRadius: 10,
|
|
105
|
+
marginVertical: 12,
|
|
106
|
+
} satisfies ViewStyle;
|
|
107
|
+
|
|
108
|
+
const styles = {
|
|
109
|
+
body: { fontSize: 17, lineHeight: 24, color: textColor },
|
|
110
|
+
text: { fontSize: 17, lineHeight: 24, color: textColor },
|
|
111
|
+
paragraph: { marginBottom: 10, color: textColor },
|
|
112
|
+
link: {
|
|
113
|
+
color: linkColor,
|
|
114
|
+
textDecorationLine: 'underline' as TextStyle['textDecorationLine'],
|
|
115
|
+
fontWeight: '500' as TextStyle['fontWeight'],
|
|
116
|
+
},
|
|
117
|
+
strong: {
|
|
118
|
+
fontWeight: '600' as TextStyle['fontWeight'],
|
|
119
|
+
color: textColor,
|
|
120
|
+
},
|
|
121
|
+
em: {
|
|
122
|
+
fontStyle: 'italic' as TextStyle['fontStyle'],
|
|
123
|
+
color: textColor,
|
|
124
|
+
},
|
|
125
|
+
code_inline: {
|
|
126
|
+
fontFamily: monospaceFontFamily,
|
|
127
|
+
fontSize: 15,
|
|
128
|
+
backgroundColor: codeBg,
|
|
129
|
+
borderColor: borderColor,
|
|
130
|
+
color: codeFg,
|
|
131
|
+
paddingHorizontal: 6,
|
|
132
|
+
paddingVertical: 3,
|
|
133
|
+
borderRadius: 6,
|
|
134
|
+
},
|
|
135
|
+
code_block: codeBlockStyle,
|
|
136
|
+
fence: codeBlockStyle,
|
|
137
|
+
blockquote: {
|
|
138
|
+
color: textColor,
|
|
139
|
+
backgroundColor: codeBg,
|
|
140
|
+
borderLeftColor: linkColor,
|
|
141
|
+
borderLeftWidth: 3,
|
|
142
|
+
paddingLeft: 12,
|
|
143
|
+
marginVertical: 12,
|
|
144
|
+
},
|
|
145
|
+
bullet_list: {
|
|
146
|
+
marginVertical: 8,
|
|
147
|
+
paddingLeft: 0,
|
|
148
|
+
},
|
|
149
|
+
ordered_list: {
|
|
150
|
+
marginVertical: 8,
|
|
151
|
+
paddingLeft: 0,
|
|
152
|
+
},
|
|
153
|
+
list_item: { marginBottom: 6, color: textColor },
|
|
154
|
+
table: {
|
|
155
|
+
minWidth: '100%',
|
|
156
|
+
backgroundColor: theme.colors.background,
|
|
157
|
+
},
|
|
158
|
+
thead: {
|
|
159
|
+
backgroundColor: codeBg,
|
|
160
|
+
},
|
|
161
|
+
tbody: {},
|
|
162
|
+
tr: {
|
|
163
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
164
|
+
borderColor,
|
|
165
|
+
flexDirection: 'row',
|
|
166
|
+
},
|
|
167
|
+
th: {
|
|
168
|
+
flexGrow: 0,
|
|
169
|
+
flexShrink: 0,
|
|
170
|
+
minWidth: 140,
|
|
171
|
+
paddingVertical: 10,
|
|
172
|
+
paddingHorizontal: 16,
|
|
173
|
+
backgroundColor: codeBg,
|
|
174
|
+
borderLeftWidth: columnDividerWidth,
|
|
175
|
+
borderColor,
|
|
176
|
+
},
|
|
177
|
+
td: {
|
|
178
|
+
flexGrow: 0,
|
|
179
|
+
flexShrink: 0,
|
|
180
|
+
minWidth: 140,
|
|
181
|
+
paddingVertical: 10,
|
|
182
|
+
paddingHorizontal: 16,
|
|
183
|
+
borderLeftWidth: columnDividerWidth,
|
|
184
|
+
borderColor,
|
|
185
|
+
},
|
|
186
|
+
heading1: {
|
|
187
|
+
fontSize: 28,
|
|
188
|
+
fontWeight: '700',
|
|
189
|
+
color: textColor,
|
|
190
|
+
marginTop: 18,
|
|
191
|
+
marginBottom: 12,
|
|
192
|
+
},
|
|
193
|
+
heading2: {
|
|
194
|
+
fontSize: 22,
|
|
195
|
+
fontWeight: '700',
|
|
196
|
+
color: textColor,
|
|
197
|
+
marginTop: 16,
|
|
198
|
+
marginBottom: 10,
|
|
199
|
+
},
|
|
200
|
+
heading3: {
|
|
201
|
+
fontSize: 19,
|
|
202
|
+
fontWeight: '600',
|
|
203
|
+
color: textColor,
|
|
204
|
+
marginTop: 14,
|
|
205
|
+
marginBottom: 8,
|
|
206
|
+
},
|
|
207
|
+
heading4: {
|
|
208
|
+
fontSize: 17,
|
|
209
|
+
fontWeight: '600',
|
|
210
|
+
color: textColor,
|
|
211
|
+
marginTop: 12,
|
|
212
|
+
marginBottom: 8,
|
|
213
|
+
},
|
|
214
|
+
heading5: {
|
|
215
|
+
fontSize: 16,
|
|
216
|
+
fontWeight: '600',
|
|
217
|
+
color: textColor,
|
|
218
|
+
marginTop: 10,
|
|
219
|
+
marginBottom: 6,
|
|
220
|
+
},
|
|
221
|
+
heading6: {
|
|
222
|
+
fontSize: 15,
|
|
223
|
+
fontWeight: '600' as TextStyle['fontWeight'],
|
|
224
|
+
color: textColor,
|
|
225
|
+
marginTop: 8,
|
|
226
|
+
marginBottom: 6,
|
|
227
|
+
},
|
|
228
|
+
hr: {
|
|
229
|
+
backgroundColor: codeBg,
|
|
230
|
+
height: 1,
|
|
231
|
+
marginVertical: 14,
|
|
232
|
+
},
|
|
233
|
+
imageWrapper: {
|
|
234
|
+
marginVertical: 8,
|
|
235
|
+
borderRadius: 14,
|
|
236
|
+
overflow: 'hidden',
|
|
237
|
+
},
|
|
238
|
+
image: {
|
|
239
|
+
width: '100%',
|
|
240
|
+
aspectRatio: 16 / 9,
|
|
241
|
+
backgroundColor: codeBg,
|
|
242
|
+
},
|
|
243
|
+
image_caption: {
|
|
244
|
+
marginTop: 6,
|
|
245
|
+
fontSize: 13,
|
|
246
|
+
color: subtleText,
|
|
247
|
+
textAlign: 'center',
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return styles as Record<string, TextStyle | ViewStyle | ImageStyle>;
|
|
252
|
+
}, [
|
|
253
|
+
borderColor,
|
|
254
|
+
codeBg,
|
|
255
|
+
codeFg,
|
|
256
|
+
linkColor,
|
|
257
|
+
subtleText,
|
|
258
|
+
textColor,
|
|
259
|
+
monospaceFontFamily,
|
|
260
|
+
theme.colors.background,
|
|
261
|
+
columnDividerWidth,
|
|
262
|
+
]);
|
|
263
|
+
|
|
264
|
+
const codeSyntaxTheme = useMemo(() => {
|
|
265
|
+
const baseTheme = isDarkMode ? atomOneDark : github;
|
|
266
|
+
return {
|
|
267
|
+
...baseTheme,
|
|
268
|
+
hljs: {
|
|
269
|
+
...baseTheme.hljs,
|
|
270
|
+
background: 'transparent',
|
|
271
|
+
color: codeFg,
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}, [codeFg, isDarkMode]);
|
|
275
|
+
|
|
276
|
+
const codeContentStyle = useMemo(
|
|
277
|
+
() =>
|
|
278
|
+
({
|
|
279
|
+
backgroundColor: 'transparent',
|
|
280
|
+
padding: 0,
|
|
281
|
+
margin: 0,
|
|
282
|
+
}) satisfies ViewStyle,
|
|
283
|
+
[],
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
const tableScrollViewStyle = useMemo(
|
|
287
|
+
() =>
|
|
288
|
+
({
|
|
289
|
+
marginVertical: 0,
|
|
290
|
+
}) satisfies ViewStyle,
|
|
291
|
+
[],
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const tableScrollContentStyle = useMemo(
|
|
295
|
+
() =>
|
|
296
|
+
({
|
|
297
|
+
flexGrow: 1,
|
|
298
|
+
}) satisfies ViewStyle,
|
|
299
|
+
[],
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const tableOuterStyle = useMemo(
|
|
303
|
+
() =>
|
|
304
|
+
({
|
|
305
|
+
borderWidth: 1,
|
|
306
|
+
borderColor,
|
|
307
|
+
borderRadius: 10,
|
|
308
|
+
overflow: 'hidden',
|
|
309
|
+
marginVertical: 12,
|
|
310
|
+
backgroundColor: theme.colors.background,
|
|
311
|
+
}) satisfies ViewStyle,
|
|
312
|
+
[borderColor, theme.colors.background],
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
const codeActionsContainerStyle = useMemo(
|
|
316
|
+
() =>
|
|
317
|
+
({
|
|
318
|
+
position: 'absolute',
|
|
319
|
+
top: 12,
|
|
320
|
+
right: 12,
|
|
321
|
+
flexDirection: 'row',
|
|
322
|
+
alignItems: 'center',
|
|
323
|
+
justifyContent: 'flex-end',
|
|
324
|
+
}) satisfies ViewStyle,
|
|
325
|
+
[],
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const codeActionButtonBaseStyle = useMemo(
|
|
329
|
+
() =>
|
|
330
|
+
({
|
|
331
|
+
alignItems: 'center',
|
|
332
|
+
justifyContent: 'center',
|
|
333
|
+
borderRadius: 999,
|
|
334
|
+
borderWidth: 1,
|
|
335
|
+
borderColor,
|
|
336
|
+
paddingHorizontal: 12,
|
|
337
|
+
paddingVertical: 8,
|
|
338
|
+
backgroundColor: isDarkMode
|
|
339
|
+
? 'rgba(15, 15, 15, 0.9)'
|
|
340
|
+
: 'rgba(255, 255, 255, 0.92)',
|
|
341
|
+
}) satisfies ViewStyle,
|
|
342
|
+
[borderColor, isDarkMode],
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
const codeToggleButtonSpacingStyle = useMemo(
|
|
346
|
+
() =>
|
|
347
|
+
({
|
|
348
|
+
marginLeft: 16,
|
|
349
|
+
}) satisfies ViewStyle,
|
|
350
|
+
[],
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
const codeContentContainerStyle = useMemo(
|
|
354
|
+
() =>
|
|
355
|
+
({
|
|
356
|
+
overflow: 'hidden',
|
|
357
|
+
marginTop: 24,
|
|
358
|
+
}) satisfies ViewStyle,
|
|
359
|
+
[],
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const copyCodeToClipboard = useCallback(
|
|
363
|
+
async (code: string) => {
|
|
364
|
+
try {
|
|
365
|
+
if (!code.trim()) {
|
|
366
|
+
toast.warning(translate('chatbot.empty_message'), {
|
|
367
|
+
duration: 2000,
|
|
368
|
+
});
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
await Clipboard.setStringAsync(code);
|
|
373
|
+
toast.success(translate('chatbot.copy_code_success'), {
|
|
374
|
+
duration: 2000,
|
|
375
|
+
});
|
|
376
|
+
} catch (error) {
|
|
377
|
+
console.error('[CHATBOT_FRONTEND] Copy code failed:', {
|
|
378
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
379
|
+
});
|
|
380
|
+
toast.error(translate('chatbot.copy_code_failed'), {
|
|
381
|
+
duration: 3000,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
[toast],
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
// Memoize CodeBlock wrapper to pass all required props
|
|
389
|
+
const renderCodeBlockComponent = useCallback(
|
|
390
|
+
(
|
|
391
|
+
containerStyle: ViewStyle | TextStyle | ImageStyle,
|
|
392
|
+
content: string,
|
|
393
|
+
language: string,
|
|
394
|
+
) => {
|
|
395
|
+
return (
|
|
396
|
+
<CodeBlock
|
|
397
|
+
containerStyle={containerStyle}
|
|
398
|
+
content={content}
|
|
399
|
+
language={language}
|
|
400
|
+
codeSyntaxTheme={codeSyntaxTheme}
|
|
401
|
+
monospaceFontFamily={monospaceFontFamily}
|
|
402
|
+
subtleText={subtleText}
|
|
403
|
+
codeContentStyle={codeContentStyle}
|
|
404
|
+
codeActionsContainerStyle={codeActionsContainerStyle}
|
|
405
|
+
codeActionButtonBaseStyle={codeActionButtonBaseStyle}
|
|
406
|
+
codeToggleButtonSpacingStyle={codeToggleButtonSpacingStyle}
|
|
407
|
+
codeContentContainerStyle={codeContentContainerStyle}
|
|
408
|
+
onCopyCode={copyCodeToClipboard}
|
|
409
|
+
/>
|
|
410
|
+
);
|
|
411
|
+
},
|
|
412
|
+
[
|
|
413
|
+
codeSyntaxTheme,
|
|
414
|
+
monospaceFontFamily,
|
|
415
|
+
subtleText,
|
|
416
|
+
codeContentStyle,
|
|
417
|
+
codeActionsContainerStyle,
|
|
418
|
+
codeActionButtonBaseStyle,
|
|
419
|
+
codeToggleButtonSpacingStyle,
|
|
420
|
+
codeContentContainerStyle,
|
|
421
|
+
copyCodeToClipboard,
|
|
422
|
+
],
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
const handleLinkPress = useCallback((url: string) => {
|
|
426
|
+
if (!url) {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
Linking.openURL(url).catch(() => {
|
|
431
|
+
// Swallow errors so the renderer keeps flowing even if the link fails.
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
return true;
|
|
435
|
+
}, []);
|
|
436
|
+
|
|
437
|
+
const rules = useMemo<RenderRules>(() => {
|
|
438
|
+
const renderCodeBlock = (
|
|
439
|
+
node: any,
|
|
440
|
+
_children: React.ReactNode[],
|
|
441
|
+
_parent: any[],
|
|
442
|
+
styles: Record<string, any>,
|
|
443
|
+
_inheritedStyles: Record<string, any> = {},
|
|
444
|
+
) => {
|
|
445
|
+
const rawContent = typeof node.content === 'string' ? node.content : '';
|
|
446
|
+
const trimmed = rawContent.replace(/\n+$/u, '');
|
|
447
|
+
const content = trimmed.length > 0 ? trimmed : rawContent;
|
|
448
|
+
|
|
449
|
+
const info = node.attributes?.info;
|
|
450
|
+
const className = node.attributes?.class;
|
|
451
|
+
const languageFromInfo =
|
|
452
|
+
typeof info === 'string' && info.trim().length > 0
|
|
453
|
+
? info.trim().split(/\s+/u)[0]
|
|
454
|
+
: undefined;
|
|
455
|
+
const languageFromClass =
|
|
456
|
+
typeof className === 'string'
|
|
457
|
+
? (className.match(/language-([\w-]+)/u)?.[1] ??
|
|
458
|
+
className.match(/lang-([\w-]+)/u)?.[1])
|
|
459
|
+
: undefined;
|
|
460
|
+
const language = (languageFromInfo ?? languageFromClass ?? '')
|
|
461
|
+
.replace(/^language-/u, '')
|
|
462
|
+
.toLowerCase();
|
|
463
|
+
|
|
464
|
+
const containerStyle =
|
|
465
|
+
styles.code_block ?? styles.fence ?? styles.code_inline;
|
|
466
|
+
|
|
467
|
+
return (
|
|
468
|
+
<React.Fragment key={node.key}>
|
|
469
|
+
{renderCodeBlockComponent(containerStyle, content, language)}
|
|
470
|
+
</React.Fragment>
|
|
471
|
+
);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
return {
|
|
475
|
+
code: (node, _children, _parent, styles) => {
|
|
476
|
+
const content = node.content || '';
|
|
477
|
+
return (
|
|
478
|
+
<Text key={node.key} style={styles.code_inline}>
|
|
479
|
+
{content}
|
|
480
|
+
</Text>
|
|
481
|
+
);
|
|
482
|
+
},
|
|
483
|
+
code_block: renderCodeBlock,
|
|
484
|
+
fence: renderCodeBlock,
|
|
485
|
+
table: (node, children, _parent, styles) => {
|
|
486
|
+
return (
|
|
487
|
+
<TableRenderer
|
|
488
|
+
node={node}
|
|
489
|
+
styles={styles}
|
|
490
|
+
tableOuterStyle={tableOuterStyle}
|
|
491
|
+
tableScrollContentStyle={tableScrollContentStyle}
|
|
492
|
+
tableScrollViewStyle={tableScrollViewStyle}
|
|
493
|
+
columnDividerWidth={columnDividerWidth}
|
|
494
|
+
>
|
|
495
|
+
{children}
|
|
496
|
+
</TableRenderer>
|
|
497
|
+
);
|
|
498
|
+
},
|
|
499
|
+
link: (node, children, _parent, styles) => {
|
|
500
|
+
const href =
|
|
501
|
+
typeof node.attributes?.href === 'string' ? node.attributes.href : '';
|
|
502
|
+
const titleAttr =
|
|
503
|
+
typeof node.attributes?.title === 'string'
|
|
504
|
+
? node.attributes.title.trim()
|
|
505
|
+
: '';
|
|
506
|
+
const fallbackLabel =
|
|
507
|
+
typeof node.content === 'string' && node.content.trim().length > 0
|
|
508
|
+
? node.content.trim()
|
|
509
|
+
: href;
|
|
510
|
+
const linkLabel =
|
|
511
|
+
titleAttr.length > 0
|
|
512
|
+
? titleAttr
|
|
513
|
+
: children && children.length > 0
|
|
514
|
+
? children
|
|
515
|
+
: fallbackLabel;
|
|
516
|
+
|
|
517
|
+
return (
|
|
518
|
+
<Text
|
|
519
|
+
key={node.key}
|
|
520
|
+
style={styles.link}
|
|
521
|
+
onPress={() => {
|
|
522
|
+
if (href) {
|
|
523
|
+
handleLinkPress(href);
|
|
524
|
+
}
|
|
525
|
+
}}
|
|
526
|
+
>
|
|
527
|
+
{linkLabel}
|
|
528
|
+
</Text>
|
|
529
|
+
);
|
|
530
|
+
},
|
|
531
|
+
image: (node, _children, _parent, styles) => {
|
|
532
|
+
const sourceUri = node.attributes?.src;
|
|
533
|
+
if (!sourceUri) {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const alt = node.attributes?.alt ?? '';
|
|
538
|
+
const caption = alt.trim().length > 0 ? alt : undefined;
|
|
539
|
+
|
|
540
|
+
return (
|
|
541
|
+
<View key={node.key} style={styles.imageWrapper}>
|
|
542
|
+
<Image
|
|
543
|
+
source={{ uri: sourceUri }}
|
|
544
|
+
style={styles.image}
|
|
545
|
+
resizeMode="cover"
|
|
546
|
+
accessible
|
|
547
|
+
accessibilityLabel={caption ?? 'Markdown image'}
|
|
548
|
+
/>
|
|
549
|
+
{caption ? (
|
|
550
|
+
<Text style={styles.image_caption}>{caption}</Text>
|
|
551
|
+
) : null}
|
|
552
|
+
</View>
|
|
553
|
+
);
|
|
554
|
+
},
|
|
555
|
+
};
|
|
556
|
+
}, [
|
|
557
|
+
renderCodeBlockComponent,
|
|
558
|
+
tableOuterStyle,
|
|
559
|
+
tableScrollContentStyle,
|
|
560
|
+
tableScrollViewStyle,
|
|
561
|
+
columnDividerWidth,
|
|
562
|
+
handleLinkPress,
|
|
563
|
+
]);
|
|
564
|
+
|
|
565
|
+
return (
|
|
566
|
+
<Markdown
|
|
567
|
+
markdownit={md}
|
|
568
|
+
style={markdownStyles}
|
|
569
|
+
onLinkPress={handleLinkPress}
|
|
570
|
+
rules={rules}
|
|
571
|
+
>
|
|
572
|
+
{content}
|
|
573
|
+
</Markdown>
|
|
574
|
+
);
|
|
575
|
+
});
|