Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 419eaa9c83 | |||
| a9179fa296 | |||
| 36785ffce0 | |||
| 50fd127373 | |||
| 1e8eccffd2 |
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
@@ -23,31 +23,6 @@ on:
|
||||
version-code:
|
||||
description: Android version code
|
||||
value: ${{ jobs.build.outputs.version-code }}
|
||||
secrets:
|
||||
EXPO_TOKEN:
|
||||
required: true
|
||||
ENV_TOKEN:
|
||||
required: true
|
||||
SENTRY_DSN:
|
||||
required: true
|
||||
BITDRIFT_API_KEY:
|
||||
required: true
|
||||
EXPO_PUBLIC_GCP_PROJECT_ID:
|
||||
required: true
|
||||
GOOGLE_SERVICES_TOKEN:
|
||||
required: true
|
||||
SENTRY_AUTH_TOKEN:
|
||||
required: true
|
||||
SLACK_CLIENT_ALERT_WEBHOOK:
|
||||
required: true
|
||||
ANDROID_KEYSTORE_BASE64:
|
||||
required: true
|
||||
ANDROID_KEYSTORE_PASSWORD:
|
||||
required: true
|
||||
ANDROID_KEY_ALIAS:
|
||||
required: true
|
||||
ANDROID_KEY_PASSWORD:
|
||||
required: true
|
||||
|
||||
# Deploys happen via EAS using EXPO_TOKEN; the GITHUB_TOKEN only checks out code
|
||||
permissions:
|
||||
@@ -74,7 +49,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 5
|
||||
|
||||
@@ -87,7 +62,7 @@ jobs:
|
||||
cache: pnpm
|
||||
|
||||
- name: 🪛 Setup jq
|
||||
uses: dcarbone/install-jq-action@4fcb5062d7ce9bc4382d1a352d19ba3ba2c317c1 # v4.0.1
|
||||
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
|
||||
|
||||
- name: ⚙️ Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
@@ -99,7 +74,7 @@ jobs:
|
||||
packager: 'pnpm --allow-build=dtrace-provider'
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
- uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
@@ -161,7 +136,7 @@ jobs:
|
||||
- name: 🔧 Setup bundletool
|
||||
uses: amyu/setup-bundletool@cc2e1857284660bd625e43f2c8a45626f034302f # v1.1
|
||||
with:
|
||||
version: "1.18.3"
|
||||
bundletool-version: "1.17.2"
|
||||
|
||||
- name: 🔑 Decode keystore
|
||||
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode >
|
||||
@@ -208,7 +183,7 @@ jobs:
|
||||
|
||||
- name: ⬇️ Restore Cache
|
||||
id: get-base-commit
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
if: ${{ inputs.profile == 'testflight-android' }}
|
||||
with:
|
||||
path: most-recent-testflight-commit.txt
|
||||
@@ -252,7 +227,7 @@ jobs:
|
||||
|
||||
- name: ⬇️ Download APK artifact
|
||||
if: ${{ steps.release-check.outputs.exists == 'true' }}
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
||||
with:
|
||||
name: ${{ needs.build.outputs.apk-artifact-name }}
|
||||
|
||||
@@ -263,14 +238,11 @@ jobs:
|
||||
- name: 📎 Attach APK to GitHub Release
|
||||
id: attach
|
||||
if: ${{ steps.release-check.outputs.exists == 'true' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
APK: Bluesky-${{ needs.build.outputs.package-version }}.apk
|
||||
run: |
|
||||
gh release upload "$TAG" "$APK" --clobber
|
||||
url=$(gh release view "$TAG" --json url --jq .url)
|
||||
echo "url=$url" >> "$GITHUB_OUTPUT"
|
||||
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
files: Bluesky-${{ needs.build.outputs.package-version }}.apk
|
||||
fail_on_unmatched_files: true
|
||||
|
||||
- name: 🔔 Notify Slack of Release Attachment
|
||||
if: ${{ steps.release-check.outputs.exists == 'true' }}
|
||||
|
||||
@@ -10,24 +10,20 @@ on:
|
||||
options:
|
||||
- testflight
|
||||
- production
|
||||
testFlightGroup:
|
||||
type: choice
|
||||
description: TestFlight group to assign the build to after submitting
|
||||
options:
|
||||
- none
|
||||
- QA Team
|
||||
- Software Mansion
|
||||
default: none
|
||||
assignTestFlightGroup:
|
||||
type: boolean
|
||||
description: Assign the build to the "QA Team" TestFlight group after submitting
|
||||
default: false
|
||||
workflow_call:
|
||||
inputs:
|
||||
profile:
|
||||
type: string
|
||||
description: Build profile to use
|
||||
required: true
|
||||
testFlightGroup:
|
||||
type: string
|
||||
description: TestFlight group to assign the build to after submitting ("none" to skip)
|
||||
default: none
|
||||
assignTestFlightGroup:
|
||||
type: boolean
|
||||
description: Assign the build to the "QA Team" TestFlight group after submitting
|
||||
default: false
|
||||
outputs:
|
||||
package-version:
|
||||
description: Version from package.json
|
||||
@@ -35,29 +31,6 @@ on:
|
||||
build-number:
|
||||
description: iOS build number
|
||||
value: ${{ jobs.build.outputs.build-number }}
|
||||
secrets:
|
||||
EXPO_TOKEN:
|
||||
required: true
|
||||
ENV_TOKEN:
|
||||
required: true
|
||||
SENTRY_DSN:
|
||||
required: true
|
||||
BITDRIFT_API_KEY:
|
||||
required: true
|
||||
EXPO_PUBLIC_GCP_PROJECT_ID:
|
||||
required: true
|
||||
GOOGLE_SERVICES_TOKEN:
|
||||
required: true
|
||||
SENTRY_AUTH_TOKEN:
|
||||
required: true
|
||||
ASC_KEY_ID:
|
||||
required: true
|
||||
ASC_ISSUER_ID:
|
||||
required: true
|
||||
ASC_KEY_P8_BASE64:
|
||||
required: true
|
||||
SLACK_CLIENT_ALERT_WEBHOOK:
|
||||
required: true
|
||||
|
||||
# Deploys happen via EAS using EXPO_TOKEN; the GITHUB_TOKEN only checks out code
|
||||
permissions:
|
||||
@@ -83,7 +56,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 5
|
||||
|
||||
@@ -96,7 +69,7 @@ jobs:
|
||||
cache: pnpm
|
||||
|
||||
- name: 🪛 Setup jq
|
||||
uses: dcarbone/install-jq-action@4fcb5062d7ce9bc4382d1a352d19ba3ba2c317c1 # v4.0.1
|
||||
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
|
||||
|
||||
- name: ⚙️ Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
@@ -124,7 +97,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: 💾 Cache Pods
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
id: pods-cache
|
||||
with:
|
||||
path: ./ios/Pods
|
||||
@@ -239,9 +212,8 @@ jobs:
|
||||
# TestFlight group. fastlane's distribute_only mode skips the upload and assigns the
|
||||
# already-submitted build to the group, polling until Apple finishes processing it.
|
||||
- name: 🧪 Assign build to TestFlight group
|
||||
if: ${{ inputs.testFlightGroup != 'none' }}
|
||||
if: ${{ inputs.assignTestFlightGroup }}
|
||||
env:
|
||||
TESTFLIGHT_GROUP: ${{ inputs.testFlightGroup }}
|
||||
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
|
||||
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
|
||||
ASC_KEY_P8_BASE64: ${{ secrets.ASC_KEY_P8_BASE64 }}
|
||||
@@ -269,7 +241,7 @@ jobs:
|
||||
app_identifier:"xyz.blueskyweb.app" \
|
||||
app_version:"$APP_VERSION" \
|
||||
build_number:"$BUILD_NUMBER" \
|
||||
groups:"$TESTFLIGHT_GROUP" \
|
||||
groups:"QA Team" \
|
||||
notify_external_testers:true
|
||||
|
||||
- name: 🔔 Notify Slack of Production Build
|
||||
@@ -284,7 +256,7 @@ jobs:
|
||||
|
||||
- name: ⬇️ Restore Cache
|
||||
id: get-base-commit
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
if: ${{ inputs.profile == 'testflight' }}
|
||||
with:
|
||||
path: most-recent-testflight-commit.txt
|
||||
|
||||
@@ -31,9 +31,7 @@ jobs:
|
||||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-deploy
|
||||
cancel-in-progress: true
|
||||
outputs:
|
||||
# A version bump forces a native build even if the fingerprint is unchanged
|
||||
changes-detected: ${{ steps.fingerprint.outputs.includes-changes ||
|
||||
steps.version.outputs.version-changed }}
|
||||
changes-detected: ${{ steps.fingerprint.outputs.includes-changes }}
|
||||
|
||||
steps:
|
||||
- name: Check for EXPO_TOKEN
|
||||
@@ -54,7 +52,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -62,27 +60,6 @@ jobs:
|
||||
if: ${{ github.ref != 'refs/heads/main' }}
|
||||
run: git fetch origin main:main --depth 100
|
||||
|
||||
# A change to the version in package.json means a new native release, so
|
||||
# an OTA update must not be deployed and full native builds are required
|
||||
# regardless of what the fingerprint says
|
||||
- name: 🔢 Check for version change
|
||||
id: version
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
env:
|
||||
EVENT_BEFORE: ${{ github.event.before }}
|
||||
run: |
|
||||
CURRENT_VERSION=$(jq -r '.version' package.json)
|
||||
if [ -n "$EVENT_BEFORE" ] && [[ ! "$EVENT_BEFORE" =~ ^0+$ ]] && git cat-file -e "$EVENT_BEFORE:package.json" 2>/dev/null; then
|
||||
PREVIOUS_VERSION=$(git show "$EVENT_BEFORE:package.json" | jq -r '.version')
|
||||
else
|
||||
PREVIOUS_VERSION=$(git show HEAD~1:package.json | jq -r '.version')
|
||||
fi
|
||||
echo "Previous version: $PREVIOUS_VERSION, current version: $CURRENT_VERSION"
|
||||
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
|
||||
echo "Version changed, full native builds are required"
|
||||
echo "version-changed=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
|
||||
|
||||
- name: 🔧 Setup Node
|
||||
@@ -93,7 +70,7 @@ jobs:
|
||||
|
||||
- name: 📷 Check fingerprint and install dependencies
|
||||
id: fingerprint
|
||||
uses: bluesky-social/github-actions/fingerprint-native@b5556913e4aef3964cfd5936d0add3fc0d809bdb # v0.2.0
|
||||
uses: bluesky-social/github-actions/fingerprint-native@ebc6aa6d7466dc1e78b1e832041b7b81f6f95030 # v0.1.0
|
||||
with:
|
||||
profile: ${{ inputs.channel || 'testflight' }}
|
||||
previous-commit-tag: ${{ inputs.runtimeVersion }}
|
||||
@@ -116,17 +93,15 @@ jobs:
|
||||
|
||||
- name: 🔨 Setup EAS
|
||||
uses: expo/expo-github-action@eab7a230208c952974db8c3245cfd78402c7b385 # 9.0.0
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
with:
|
||||
eas-version: '19.0.5'
|
||||
packager: 'pnpm --allow-build=dtrace-provider'
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- name: 🪛 Setup jq
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
uses: dcarbone/install-jq-action@4fcb5062d7ce9bc4382d1a352d19ba3ba2c317c1 # v4.0.1
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
|
||||
|
||||
# eas.json not used here, set EXPO_PUBLIC_ENV
|
||||
- name: Env
|
||||
@@ -134,8 +109,7 @@ jobs:
|
||||
CHANNEL: ${{ inputs.channel || 'testflight' }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
id: env
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
run: |
|
||||
export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
|
||||
echo "${{ secrets.ENV_TOKEN }}" > .env
|
||||
@@ -151,8 +125,7 @@ jobs:
|
||||
echo "$json" > google-services.json
|
||||
|
||||
- name: 🏗️ Create Bundle
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
run: >
|
||||
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
SENTRY_RELEASE=${{ steps.env.outputs.EXPO_PUBLIC_RELEASE_VERSION }}
|
||||
@@ -160,8 +133,7 @@ jobs:
|
||||
pnpm export
|
||||
|
||||
- name: 📦 Package Bundle and 🚀 Deploy
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
run: pnpm use-build-number bash scripts/bundleUpdate.sh
|
||||
env:
|
||||
DENIS_API_KEY: ${{ secrets.DENIS_API_KEY }}
|
||||
@@ -170,16 +142,14 @@ jobs:
|
||||
|
||||
- name: ⬇️ Restore Cache
|
||||
id: get-base-commit
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
with:
|
||||
path: most-recent-testflight-commit.txt
|
||||
key: most-recent-testflight-commit
|
||||
|
||||
- name: ✏️ Write commit hash to cache
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes &&
|
||||
!steps.version.outputs.version-changed }}
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
run: echo $GITHUB_SHA > most-recent-testflight-commit.txt
|
||||
|
||||
# GitHub actions are horrible so let's just copy paste this in
|
||||
@@ -204,7 +174,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 5
|
||||
|
||||
@@ -242,7 +212,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: 💾 Cache Pods
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
id: pods-cache
|
||||
with:
|
||||
path: ./ios/Pods
|
||||
@@ -325,7 +295,7 @@ jobs:
|
||||
|
||||
- name: ⬇️ Restore Cache
|
||||
id: get-base-commit
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
if: ${{ inputs.channel == 'testflight' }}
|
||||
with:
|
||||
path: most-recent-testflight-commit.txt
|
||||
@@ -359,7 +329,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 5
|
||||
|
||||
@@ -378,7 +348,7 @@ jobs:
|
||||
packager: 'pnpm --allow-build=dtrace-provider'
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
- uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
@@ -426,7 +396,7 @@ jobs:
|
||||
- name: 🔧 Setup bundletool
|
||||
uses: amyu/setup-bundletool@cc2e1857284660bd625e43f2c8a45626f034302f # v1.1
|
||||
with:
|
||||
version: "1.18.3"
|
||||
bundletool-version: "1.17.2"
|
||||
|
||||
- name: 🔑 Decode keystore
|
||||
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode >
|
||||
@@ -473,7 +443,7 @@ jobs:
|
||||
|
||||
- name: ⬇️ Restore Cache
|
||||
id: get-base-commit
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
if: ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
|
||||
with:
|
||||
path: most-recent-testflight-commit.txt
|
||||
|
||||
@@ -54,18 +54,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Configure AWS credentials (OIDC)
|
||||
uses: aws-actions/configure-aws-credentials@254c19bd240aabef8777f48595e9d2d7b972184b # v6.2.1
|
||||
uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6.2.0
|
||||
with:
|
||||
role-to-assume: ${{ secrets.AWS_BEDROCK_REVIEW_ROLE_ARN }}
|
||||
aws-region: us-east-2
|
||||
|
||||
- name: Claude
|
||||
uses: anthropics/claude-code-action@4633baf5267540f3f8cb58b684f79901d564c280 # v1.0.160
|
||||
uses: anthropics/claude-code-action@9dd8b95a392eb34b6f5fb56cf5a64cb735912d4b # v1.0.150
|
||||
with:
|
||||
use_bedrock: 'true'
|
||||
additional_permissions: |
|
||||
|
||||
@@ -40,18 +40,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Configure AWS credentials (OIDC)
|
||||
uses: aws-actions/configure-aws-credentials@254c19bd240aabef8777f48595e9d2d7b972184b # v6.2.1
|
||||
uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6.2.0
|
||||
with:
|
||||
role-to-assume: ${{ secrets.AWS_BEDROCK_REVIEW_ROLE_ARN }}
|
||||
aws-region: us-east-2
|
||||
|
||||
- name: Claude review
|
||||
uses: anthropics/claude-code-action@4633baf5267540f3f8cb58b684f79901d564c280 # v1.0.160
|
||||
uses: anthropics/claude-code-action@9dd8b95a392eb34b6f5fb56cf5a64cb735912d4b # v1.0.150
|
||||
with:
|
||||
use_bedrock: 'true'
|
||||
additional_permissions: |
|
||||
|
||||
@@ -18,9 +18,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Git Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
- name: Set up Go tooling
|
||||
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
|
||||
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
||||
with:
|
||||
go-version-file: bskyweb/go.mod
|
||||
cache-dependency-path: bskyweb/go.sum
|
||||
@@ -36,9 +36,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Git Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
- name: Set up Go tooling
|
||||
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
|
||||
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
||||
with:
|
||||
go-version-file: bskyweb/go.mod
|
||||
cache-dependency-path: bskyweb/go.sum
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
job: [lint, prettier, typecheck]
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
- name: Verify Node version pins match package.json
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
shard: [1, 2, 3, 4]
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
|
||||
- name: Install node
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
notes: ${{ steps.notes.outputs.notes }}
|
||||
steps:
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -77,21 +77,8 @@ jobs:
|
||||
uses: ./.github/workflows/build-submit-ios.yml
|
||||
with:
|
||||
profile: testflight
|
||||
testFlightGroup: "QA Team"
|
||||
# Pass only the secrets the reusable workflow declares, rather than `secrets: inherit`,
|
||||
# so the nightly build never hands the reusable workflow the entire repo secret store.
|
||||
secrets:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
ENV_TOKEN: ${{ secrets.ENV_TOKEN }}
|
||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||
BITDRIFT_API_KEY: ${{ secrets.BITDRIFT_API_KEY }}
|
||||
EXPO_PUBLIC_GCP_PROJECT_ID: ${{ secrets.EXPO_PUBLIC_GCP_PROJECT_ID }}
|
||||
GOOGLE_SERVICES_TOKEN: ${{ secrets.GOOGLE_SERVICES_TOKEN }}
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
|
||||
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
|
||||
ASC_KEY_P8_BASE64: ${{ secrets.ASC_KEY_P8_BASE64 }}
|
||||
SLACK_CLIENT_ALERT_WEBHOOK: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
|
||||
assignTestFlightGroup: true
|
||||
secrets: inherit
|
||||
|
||||
android:
|
||||
name: Nightly Android Build
|
||||
@@ -104,21 +91,7 @@ jobs:
|
||||
uses: ./.github/workflows/build-submit-android.yml
|
||||
with:
|
||||
profile: testflight-android
|
||||
# Pass only the secrets the reusable workflow declares, rather than `secrets: inherit`,
|
||||
# so the nightly build never hands the reusable workflow the entire repo secret store.
|
||||
secrets:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
ENV_TOKEN: ${{ secrets.ENV_TOKEN }}
|
||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||
BITDRIFT_API_KEY: ${{ secrets.BITDRIFT_API_KEY }}
|
||||
EXPO_PUBLIC_GCP_PROJECT_ID: ${{ secrets.EXPO_PUBLIC_GCP_PROJECT_ID }}
|
||||
GOOGLE_SERVICES_TOKEN: ${{ secrets.GOOGLE_SERVICES_TOKEN }}
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
SLACK_CLIENT_ALERT_WEBHOOK: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
|
||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
|
||||
secrets: inherit
|
||||
|
||||
notify-ios:
|
||||
name: Notify Slack of iOS nightly
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
ssh-key: ${{secrets.GH_ACTION_DEPLOY_KEY}}
|
||||
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
- name: Extract language strings
|
||||
run: pnpm intl:extract
|
||||
- name: Create commit
|
||||
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
|
||||
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
|
||||
with:
|
||||
commit_message: Nightly source-language update
|
||||
file_pattern: ./src/locale/locales/en/messages.po
|
||||
|
||||
@@ -125,7 +125,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
ref: ${{ steps.pr-info.outputs.head-sha }}
|
||||
|
||||
@@ -160,7 +160,7 @@ jobs:
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
|
||||
- name: 🪛 Setup jq
|
||||
uses: dcarbone/install-jq-action@4fcb5062d7ce9bc4382d1a352d19ba3ba2c317c1 # v4.0.1
|
||||
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
|
||||
|
||||
- name: Env
|
||||
id: env
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
|
||||
- name: ⬇️ Get base stats from cache
|
||||
id: get-base-stats
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: stats-base.json
|
||||
key: stats-base-${{ steps.base-commit.outputs.base-commit }}
|
||||
@@ -116,7 +116,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: ⬇️ Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 100
|
||||
|
||||
@@ -134,8 +134,7 @@ jobs:
|
||||
|
||||
- name: 📷 Check fingerprint and install dependencies
|
||||
id: fingerprint
|
||||
timeout-minutes: 5
|
||||
uses: bluesky-social/github-actions/fingerprint-native@b5556913e4aef3964cfd5936d0add3fc0d809bdb # v0.2.0
|
||||
uses: bluesky-social/github-actions/fingerprint-native@ebc6aa6d7466dc1e78b1e832041b7b81f6f95030 # v0.1.0
|
||||
with:
|
||||
profile: pull-request
|
||||
|
||||
@@ -163,19 +162,3 @@ jobs:
|
||||
with:
|
||||
header: fingerprint-diff
|
||||
delete: true
|
||||
|
||||
- name: 🏷️ Label as fingerprint changed
|
||||
if: ${{ steps.fingerprint.outputs.includes-changes }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
gh pr edit "$PR_NUMBER" --add-label "bot: fingerprint changed" || true
|
||||
|
||||
- name: 🏷️ Remove fingerprint changed label
|
||||
if: ${{ !steps.fingerprint.outputs.includes-changes }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
gh pr edit "$PR_NUMBER" --remove-label "bot: fingerprint changed" || true
|
||||
|
||||
@@ -14,12 +14,9 @@ jobs:
|
||||
if: github.repository == 'bluesky-social/social-app'
|
||||
steps:
|
||||
- name: Checkout public repo
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# Don't persist the checkout auth header; the push below authenticates
|
||||
# with the app token embedded in the remote URL instead
|
||||
persist-credentials: false
|
||||
- name: Generate GitHub App Token
|
||||
id: app-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
@@ -28,16 +25,14 @@ jobs:
|
||||
private-key: ${{ secrets.SYNC_INTERNAL_PK }}
|
||||
repositories: social-app-internal
|
||||
# Scope the token down from the app's full installation permissions;
|
||||
# pushing is the only thing this token is used for. The workflows
|
||||
# permission is required because the sync includes files under
|
||||
# .github/workflows/, which GitHub refuses to push without it.
|
||||
# pushing is the only thing this token is used for
|
||||
permission-contents: write
|
||||
permission-workflows: write
|
||||
- name: Push to internal repo
|
||||
env:
|
||||
TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
run: |
|
||||
git config user.name "github-actions"
|
||||
git config user.email "test@users.noreply.github.com"
|
||||
git config --unset-all http.https://github.com/.extraheader
|
||||
git remote add internal https://x-access-token:${TOKEN}@github.com/bluesky-social/social-app-internal.git
|
||||
git push internal main --force
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out PR HEAD
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run zizmor
|
||||
uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7
|
||||
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
|
||||
with:
|
||||
# Annotate the PR directly instead of uploading SARIF to the
|
||||
# security tab, and fail the check on any finding
|
||||
|
||||
@@ -10,7 +10,7 @@ Bluesky Social is a cross-platform social media application built with React Nat
|
||||
|
||||
- React 19.1
|
||||
- React Native 0.81 with Expo 54
|
||||
- TypeScript 7
|
||||
- TypeScript 6
|
||||
- React Navigation 7 for routing
|
||||
- TanStack Query (React Query) for data fetching
|
||||
- Lingui 5 for internationalization
|
||||
@@ -32,7 +32,6 @@ pnpm ios # Run on iOS
|
||||
pnpm test # Run Jest tests
|
||||
pnpm lint # Run ESLint
|
||||
pnpm typecheck # Run TypeScript type checking
|
||||
pnpm prettier # Run Prettier for code formatting
|
||||
|
||||
# Internationalization
|
||||
# DO NOT run these commands - extraction and compilation are handled by CI
|
||||
@@ -165,45 +164,12 @@ related code together and gives us a better visual cue that there are probably
|
||||
other files contained within this "macro" feature, whereas `Component.tsx` on
|
||||
its own looks more like a single component file.
|
||||
|
||||
### Comments
|
||||
### Documentation and Tests Within Features
|
||||
|
||||
Comment code when necessary to explain the “why” behind something; avoid
|
||||
comments that simply describe the code. Avoid Unicode characters in comments,
|
||||
e.g., use `-` not `—`.
|
||||
|
||||
Always use docblock (`/** */`) syntax for comments that document a type, type
|
||||
member, method, function, or variable. These are the comments a reader expects
|
||||
to find attached to a named declaration, and the docblock form makes that intent
|
||||
clear and surfaces nicely in editor tooltips.
|
||||
|
||||
```tsx
|
||||
type DateFieldProps = {
|
||||
/**
|
||||
* An empty string renders the placeholder and opens the picker at today (or
|
||||
* maximumDate, if earlier).
|
||||
*/
|
||||
value: string | Date
|
||||
}
|
||||
|
||||
/**
|
||||
* Date-only input. Accepts a string in the format YYYY-MM-DD, or a Date object.
|
||||
*/
|
||||
export function DateField() {}
|
||||
```
|
||||
|
||||
More generally, any multiline comment should use the `/* */` block syntax rather
|
||||
than stacked `//` lines. Reserve `//` for short, single-line comments.
|
||||
|
||||
```tsx
|
||||
/*
|
||||
* The picker requires a valid date, so when value is empty we fall back to
|
||||
* maximumDate (if set) or today.
|
||||
*/
|
||||
const fallbackDate = maximumDate ? toSimpleDateString(maximumDate) : today
|
||||
```
|
||||
|
||||
### Documentation and Tests Within Features
|
||||
|
||||
For larger features or components, it's helpful to include a README.md file
|
||||
within the directory that explains the purpose of the feature, how it works, and
|
||||
any important implementation details. The `/Component/index.tsx` pattern lends
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
FROM node:24.18.0-alpine3.23 AS build
|
||||
FROM node:24.15.0-alpine3.22 AS build
|
||||
|
||||
# Move files into the image and install
|
||||
WORKDIR /app
|
||||
@@ -14,7 +14,7 @@ RUN yarn build
|
||||
RUN yarn install --production --ignore-scripts --prefer-offline
|
||||
|
||||
# Uses assets from build stage to reduce build size
|
||||
FROM node:24.18.0-alpine3.23
|
||||
FROM node:24.15.0-alpine3.22
|
||||
|
||||
RUN apk add --update dumb-init
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:24.18.0-alpine3.23 AS build
|
||||
FROM node:24.15.0-alpine3.22 AS build
|
||||
|
||||
# Tells pnpm to run non-interactively (needed for install/script steps)
|
||||
ENV CI=true
|
||||
@@ -9,7 +9,7 @@ WORKDIR /app
|
||||
COPY ./bskyogcard/package.json ./
|
||||
COPY ./bskyogcard/pnpm-lock.yaml ./
|
||||
COPY ./bskyogcard/pnpm-workspace.yaml ./
|
||||
RUN npm install --global pnpm@11.10.0
|
||||
RUN npm install --global pnpm@11.5.2
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
COPY ./bskyogcard ./
|
||||
@@ -19,7 +19,7 @@ RUN pnpm install-fonts && pnpm build
|
||||
RUN pnpm install --prod --ignore-scripts --prefer-offline
|
||||
|
||||
# Uses assets from build stage to reduce build size
|
||||
FROM node:24.18.0-alpine3.23
|
||||
FROM node:24.15.0-alpine3.22
|
||||
|
||||
RUN apk add --update dumb-init
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ WORKDIR /usr/src/social-app
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Node
|
||||
ENV NODE_VERSION=24.18.0
|
||||
ENV NODE_VERSION=24.15.0
|
||||
ENV NVM_DIR=/usr/share/nvm
|
||||
|
||||
# Go
|
||||
@@ -33,7 +33,7 @@ RUN mkdir --parents $NVM_DIR && \
|
||||
RUN \. "$NVM_DIR/nvm.sh" && \
|
||||
nvm install $NODE_VERSION && \
|
||||
nvm use $NODE_VERSION && \
|
||||
npm install --global pnpm@11.10.0 && \
|
||||
npm install --global pnpm@11.7.0 && \
|
||||
pnpm install --frozen-lockfile && \
|
||||
cd bskyembed && pnpm install --frozen-lockfile && cd .. && \
|
||||
pnpm intl:build && \
|
||||
|
||||
@@ -135,8 +135,7 @@ appId: xyz.blueskyweb.app
|
||||
|
||||
- tapOn:
|
||||
id: "bottomBarSearchBtn"
|
||||
- tapOn:
|
||||
id: "searchScreenInput"
|
||||
- tapOn: "Search for posts, users[,]? or feeds"
|
||||
- inputText: "bob"
|
||||
- tapOn:
|
||||
id: "searchAutoCompleteResult-bob.test"
|
||||
|
||||
@@ -11,8 +11,7 @@ appId: xyz.blueskyweb.app
|
||||
- tapOn: "Sign in"
|
||||
- tapOn:
|
||||
id: "selectServiceButton"
|
||||
- tapOn:
|
||||
id: "manualSelectBtn"
|
||||
- tapOn: "Custom"
|
||||
- tapOn:
|
||||
id: "customServerTextInput"
|
||||
- inputText: "http://localhost:3000"
|
||||
@@ -21,8 +20,7 @@ appId: xyz.blueskyweb.app
|
||||
platform: Android
|
||||
commands:
|
||||
- hideKeyboard
|
||||
- tapOn:
|
||||
id: "doneBtn"
|
||||
- tapOn: "Done"
|
||||
- tapOn:
|
||||
id: "loginUsernameInput"
|
||||
- inputText: "Alice"
|
||||
|
||||
@@ -15,8 +15,7 @@ appId: xyz.blueskyweb.app
|
||||
id: "bottomBarSearchBtn"
|
||||
- tapOn:
|
||||
id: "bottomBarSearchBtn"
|
||||
- tapOn:
|
||||
id: "searchScreenInput"
|
||||
- tapOn: "Search for posts, users[,]? or feeds"
|
||||
- inputText: "b"
|
||||
- tapOn:
|
||||
id: "searchAutoCompleteResult-bob.test"
|
||||
|
||||
@@ -15,10 +15,8 @@ appId: xyz.blueskyweb.app
|
||||
id: "bottomBarSearchBtn"
|
||||
- tapOn:
|
||||
id: "bottomBarSearchBtn"
|
||||
- assertVisible:
|
||||
id: "searchScreenInput"
|
||||
- tapOn:
|
||||
id: "searchScreenInput"
|
||||
- assertVisible: "Search for posts, users[,]? or feeds"
|
||||
- tapOn: "Search for posts, users[,]? or feeds"
|
||||
- inputText: "b"
|
||||
- tapOn:
|
||||
id: "searchAutoCompleteResult-bob.test"
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
import {
|
||||
buildStateObject,
|
||||
getCurrentRoute,
|
||||
isStateAtTabRoot,
|
||||
} from '#/lib/routes/helpers'
|
||||
import {type State} from '#/lib/routes/types'
|
||||
|
||||
describe('getCurrentRoute', () => {
|
||||
it('returns Home when there is no state', () => {
|
||||
expect(getCurrentRoute(undefined).name).toBe('Home')
|
||||
})
|
||||
|
||||
it('descends into nested state using the index', () => {
|
||||
const state = {
|
||||
index: 0,
|
||||
routes: [
|
||||
{
|
||||
name: 'HomeTab',
|
||||
state: {
|
||||
index: 1,
|
||||
routes: [{name: 'Home'}, {name: 'PostThread'}],
|
||||
},
|
||||
},
|
||||
],
|
||||
} as unknown as State
|
||||
|
||||
expect(getCurrentRoute(state).name).toBe('PostThread')
|
||||
})
|
||||
|
||||
/*
|
||||
* Right after a cold start from a deep link, nested navigator states are
|
||||
* still partial and have no `index`. React Navigation focuses the last
|
||||
* route when rehydrating such a state, so getCurrentRoute must do the
|
||||
* same (previously it stopped at the tab route, which re-enabled the
|
||||
* drawer swipe gesture on top of the deep-linked screen).
|
||||
*/
|
||||
it('descends into partial nested state without an index', () => {
|
||||
const state = {
|
||||
routes: [
|
||||
{
|
||||
name: 'HomeTab',
|
||||
state: {
|
||||
routes: [{name: 'Home'}, {name: 'PostThread'}],
|
||||
},
|
||||
},
|
||||
],
|
||||
} as unknown as State
|
||||
|
||||
expect(getCurrentRoute(state).name).toBe('PostThread')
|
||||
})
|
||||
})
|
||||
|
||||
describe('isStateAtTabRoot', () => {
|
||||
it('returns true for the initial deep link state of a tab root', () => {
|
||||
const state = buildStateObject('HomeTab', 'Home', {}) as unknown as State
|
||||
expect(isStateAtTabRoot(state)).toBe(true)
|
||||
})
|
||||
|
||||
it('returns false for the initial deep link state of a nested screen', () => {
|
||||
const state = buildStateObject(
|
||||
'HomeTab',
|
||||
'PostThread',
|
||||
{name: 'alice.test', rkey: '123'},
|
||||
[{name: 'Home', params: {}}],
|
||||
) as unknown as State
|
||||
expect(isStateAtTabRoot(state)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildStateObject', () => {
|
||||
it('focuses the deep-linked route in the nested state', () => {
|
||||
const state = buildStateObject(
|
||||
'HomeTab',
|
||||
'PostThread',
|
||||
{name: 'alice.test', rkey: '123'},
|
||||
[{name: 'Home', params: {}}],
|
||||
)
|
||||
|
||||
expect(state).toEqual({
|
||||
index: 0,
|
||||
routes: [
|
||||
{
|
||||
name: 'HomeTab',
|
||||
state: {
|
||||
index: 1,
|
||||
routes: [
|
||||
{name: 'Home', params: {}},
|
||||
{name: 'PostThread', params: {name: 'alice.test', rkey: '123'}},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it('builds a single-route state for the Flat navigator', () => {
|
||||
const state = buildStateObject('Flat', 'PostThread', {
|
||||
name: 'alice.test',
|
||||
rkey: '123',
|
||||
})
|
||||
|
||||
expect(state).toEqual({
|
||||
index: 0,
|
||||
routes: [{name: 'PostThread', params: {name: 'alice.test', rkey: '123'}}],
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -59,7 +59,6 @@ module.exports = function (_config) {
|
||||
ios: {
|
||||
supportsTablet: false,
|
||||
bundleIdentifier: 'xyz.blueskyweb.app',
|
||||
appleTeamId: process.env.EXPO_APPLE_TEAM_ID,
|
||||
config: {
|
||||
usesNonExemptEncryption: false,
|
||||
},
|
||||
@@ -82,7 +81,6 @@ module.exports = function (_config) {
|
||||
'an',
|
||||
'ast',
|
||||
'ca',
|
||||
'cs',
|
||||
'cy',
|
||||
'da',
|
||||
'de',
|
||||
@@ -128,7 +126,6 @@ module.exports = function (_config) {
|
||||
'com.apple.security.application-groups': 'group.app.bsky',
|
||||
'com.apple.developer.usernotifications.communication': true,
|
||||
// 'com.apple.developer.device-information.user-assigned-device-name': true,
|
||||
'com.apple.developer.declared-age-range': true,
|
||||
},
|
||||
privacyManifests: {
|
||||
NSPrivacyCollectedDataTypes: [
|
||||
|
||||
+13
-1
@@ -18,7 +18,19 @@ module.exports = function (api) {
|
||||
plugins: [
|
||||
'@lingui/babel-plugin-lingui-macro',
|
||||
['babel-plugin-react-compiler', {target: '19'}],
|
||||
'module:react-native-dotenv', // used by web build! can remove when we drop webpack
|
||||
[
|
||||
'module:react-native-dotenv',
|
||||
{
|
||||
envName: 'APP_ENV',
|
||||
moduleName: '@env',
|
||||
path: '.env',
|
||||
blocklist: null,
|
||||
allowlist: null,
|
||||
safe: false,
|
||||
allowUndefined: true,
|
||||
verbose: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
'module-resolver',
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"devEngines": {
|
||||
"packageManager": {
|
||||
"name": "pnpm",
|
||||
"version": "11.10.0",
|
||||
"version": "11.5.2",
|
||||
"onFail": "warn"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -65,7 +65,6 @@ type discussionForumPosting struct {
|
||||
CommentCount *int64 `json:"commentCount,omitempty"`
|
||||
Comment []comment `json:"comment,omitempty"`
|
||||
IsBasedOn string `json:"isBasedOn,omitempty"`
|
||||
IsPartOf string `json:"isPartOf,omitempty"`
|
||||
SharedContent *sharedContent `json:"sharedContent,omitempty"`
|
||||
}
|
||||
|
||||
@@ -345,43 +344,6 @@ func extractSharedContentURL(pv *appbsky.FeedDefs_PostView) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// threadRootURI returns the AT-URI of the root post of the thread a reply
|
||||
// belongs to, or "" if the post is not a reply or the record is malformed.
|
||||
func threadRootURI(pv *appbsky.FeedDefs_PostView) string {
|
||||
if pv == nil || pv.Record == nil {
|
||||
return ""
|
||||
}
|
||||
rec, ok := pv.Record.Val.(*appbsky.FeedPost)
|
||||
if !ok || rec.Reply == nil || rec.Reply.Root == nil {
|
||||
return ""
|
||||
}
|
||||
return rec.Reply.Root.Uri
|
||||
}
|
||||
|
||||
// findRootPostInParents walks tv's parent chain upward and returns the
|
||||
// PostView whose URI matches rootURI, or nil if the root is not present.
|
||||
// The root is absent when the chain is truncated by parentHeight (reply
|
||||
// deeper than the fetched height) or broken by a blocked/not-found parent.
|
||||
// Avoids a separate FeedGetPosts call when the thread response already
|
||||
// contains the root.
|
||||
func findRootPostInParents(tv *appbsky.FeedDefs_ThreadViewPost, rootURI string) *appbsky.FeedDefs_PostView {
|
||||
if rootURI == "" {
|
||||
return nil
|
||||
}
|
||||
for node := tv; node != nil; {
|
||||
if node.Post != nil && node.Post.Uri == rootURI {
|
||||
return node.Post
|
||||
}
|
||||
if node.Parent == nil {
|
||||
return nil
|
||||
}
|
||||
// Only threadViewPost parents continue the chain; a blocked or
|
||||
// not-found parent breaks it before reaching the root.
|
||||
node = node.Parent.FeedDefs_ThreadViewPost
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// buildAuthor constructs a Person. Organization classification for
|
||||
// custom-domain accounts is a future enhancement.
|
||||
func buildAuthor(author *appbsky.ActorDefs_ProfileViewBasic) *personOrOrg {
|
||||
@@ -622,21 +584,13 @@ func buildReplyNode(pv *appbsky.FeedDefs_PostView, hideLabels map[string]bool) c
|
||||
|
||||
// buildPostJSONLD marshals the WebPage envelope wrapping a
|
||||
// DiscussionForumPosting. canonicalURL is used for both envelope.url and
|
||||
// (as a fallback) mainEntity.url so they always agree. isPartOfURL, when
|
||||
// non-empty, is the handle-form canonical URL of the thread root the handler
|
||||
// resolved for a reply; pass "" to omit isPartOf (non-reply, or the root could
|
||||
// not be resolved). We never emit a DID-form isPartOf because it would not
|
||||
// match the root page's handle-form canonical.
|
||||
func buildPostJSONLD(pv *appbsky.FeedDefs_PostView, replies []*appbsky.FeedDefs_ThreadViewPost_Replies_Elem, canonicalURL string, isPartOfURL string, hideLabels, hideReplyLabels map[string]bool) (string, error) {
|
||||
// (as a fallback) mainEntity.url so they always agree.
|
||||
func buildPostJSONLD(pv *appbsky.FeedDefs_PostView, replies []*appbsky.FeedDefs_ThreadViewPost_Replies_Elem, canonicalURL string, hideLabels, hideReplyLabels map[string]bool) (string, error) {
|
||||
if pv == nil || pv.Author == nil {
|
||||
return "", fmt.Errorf("nil post view or author")
|
||||
}
|
||||
node := buildPostNode(pv, replies, hideLabels, hideReplyLabels)
|
||||
|
||||
if isPartOfURL != "" {
|
||||
node.IsPartOf = isPartOfURL
|
||||
}
|
||||
|
||||
// mainEntity.url is empty when the author handle is unusable; fall back
|
||||
// to canonicalURL so it agrees with envelope.url.
|
||||
if node.URL == "" {
|
||||
|
||||
@@ -183,19 +183,6 @@ func withQuotePostBlocked() func(*appbsky.FeedDefs_PostView) {
|
||||
}
|
||||
}
|
||||
|
||||
// withReplyRoot marks the post as a reply by setting its record's Reply.Root
|
||||
// strong-ref to the given thread-root post.
|
||||
func withReplyRoot(rootDid, rootRkey string) func(*appbsky.FeedDefs_PostView) {
|
||||
return func(pv *appbsky.FeedDefs_PostView) {
|
||||
rec, _ := pv.Record.Val.(*appbsky.FeedPost)
|
||||
uri := "at://" + rootDid + "/app.bsky.feed.post/" + rootRkey
|
||||
rec.Reply = &appbsky.FeedPost_ReplyRef{
|
||||
Root: &comatprototypes.RepoStrongRef{Uri: uri, Cid: "bafy-root"},
|
||||
Parent: &comatprototypes.RepoStrongRef{Uri: uri, Cid: "bafy-root"},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// withSelfLabel adds a self-label that should hide embeds.
|
||||
func withSelfLabel(val string) func(*appbsky.FeedDefs_PostView) {
|
||||
return func(pv *appbsky.FeedDefs_PostView) {
|
||||
@@ -276,7 +263,7 @@ func unmarshalLD(t *testing.T, s string) map[string]any {
|
||||
func TestBuildPostJSONLD_Bare(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hello")
|
||||
canonical := "https://bsky.app/profile/alice.bsky.social/post/abc123"
|
||||
out, err := buildPostJSONLD(pv, nil, canonical, "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, canonical, hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -346,7 +333,7 @@ func TestBuildPostJSONLD_WithImages(t *testing.T) {
|
||||
thumb1 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/abc@jpeg"
|
||||
thumb2 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/def@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "look", withImages(thumb1, thumb2))
|
||||
out, err := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -371,7 +358,7 @@ func TestBuildPostJSONLD_WithGallery(t *testing.T) {
|
||||
thumb2 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/g2@jpeg"
|
||||
thumb3 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/g3@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "gallery", withGallery(thumb1, thumb2, thumb3))
|
||||
out, err := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -398,7 +385,7 @@ func TestBuildPostJSONLD_GalleryInRecordWithMedia(t *testing.T) {
|
||||
thumb := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/g@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "quote+gallery",
|
||||
withRecordWithMediaGallery("bob.example.com", "did:plc:bob", "xyz", thumb))
|
||||
out, err := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -451,7 +438,7 @@ func TestExtractPostMedia_GallerySkipsUnknownItems(t *testing.T) {
|
||||
func TestBuildPostJSONLD_WithVideo(t *testing.T) {
|
||||
thumb := "https://cdn.bsky.app/img/video_thumbnail/plain/did:plc:alice/v@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "watch", withVideo(thumb))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if main["thumbnailUrl"] != thumb {
|
||||
t.Errorf("video thumbnailUrl wrong: %v", main["thumbnailUrl"])
|
||||
@@ -464,7 +451,7 @@ func TestBuildPostJSONLD_WithVideo(t *testing.T) {
|
||||
|
||||
func TestBuildPostJSONLD_QuotePost(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "quoting!", withQuotePost("bob.example.com", "did:plc:bob", "xyz"))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if main["isBasedOn"] != "https://bsky.app/profile/bob.example.com/post/xyz" {
|
||||
t.Errorf("isBasedOn wrong: %v", main["isBasedOn"])
|
||||
@@ -473,122 +460,16 @@ func TestBuildPostJSONLD_QuotePost(t *testing.T) {
|
||||
|
||||
func TestBuildPostJSONLD_QuoteBlocked(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "quoting blocked", withQuotePostBlocked())
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["isBasedOn"]; present {
|
||||
t.Errorf("blocked quote should not produce isBasedOn")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPostJSONLD_IsPartOf(t *testing.T) {
|
||||
// isPartOf is sourced solely from the handler-resolved URL. When supplied,
|
||||
// it is emitted on the main post; when empty, no isPartOf is present.
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "a reply")
|
||||
isPartOf := "https://bsky.app/profile/root.bsky.social/post/rootrkey"
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", isPartOf, hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if main["isPartOf"] != isPartOf {
|
||||
t.Errorf("isPartOf = %v, want %v", main["isPartOf"], isPartOf)
|
||||
}
|
||||
|
||||
out, _ = buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
main = unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["isPartOf"]; present {
|
||||
t.Errorf("empty isPartOfURL should omit isPartOf, got %v", main["isPartOf"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreadRootURI(t *testing.T) {
|
||||
// A reply returns its root AT-URI; a non-reply returns "".
|
||||
reply := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "a reply",
|
||||
withReplyRoot("did:plc:root", "rootrkey"))
|
||||
want := "at://did:plc:root/app.bsky.feed.post/rootrkey"
|
||||
if got := threadRootURI(reply); got != want {
|
||||
t.Errorf("threadRootURI = %q, want %q", got, want)
|
||||
}
|
||||
|
||||
post := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "not a reply")
|
||||
if got := threadRootURI(post); got != "" {
|
||||
t.Errorf("threadRootURI on non-reply = %q, want empty", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindRootPostInParents(t *testing.T) {
|
||||
rootPost := makePostView("root.bsky.social", "did:plc:root", "rootrkey", "root")
|
||||
rootURI := rootPost.Uri
|
||||
|
||||
// tvp wraps a PostView, optionally chaining to a parent thread node.
|
||||
tvp := func(pv *appbsky.FeedDefs_PostView, parent *appbsky.FeedDefs_ThreadViewPost) *appbsky.FeedDefs_ThreadViewPost {
|
||||
node := &appbsky.FeedDefs_ThreadViewPost{Post: pv}
|
||||
if parent != nil {
|
||||
node.Parent = &appbsky.FeedDefs_ThreadViewPost_Parent{FeedDefs_ThreadViewPost: parent}
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
t.Run("direct reply, parent is root", func(t *testing.T) {
|
||||
leaf := tvp(makePostView("alice.bsky.social", "did:plc:alice", "leaf", "reply"), tvp(rootPost, nil))
|
||||
if got := findRootPostInParents(leaf, rootURI); got != rootPost {
|
||||
t.Errorf("expected root post, got %v", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("multi-level chain", func(t *testing.T) {
|
||||
mid := tvp(makePostView("bob.bsky.social", "did:plc:bob", "mid", "mid"), tvp(rootPost, nil))
|
||||
leaf := tvp(makePostView("alice.bsky.social", "did:plc:alice", "leaf", "reply"), mid)
|
||||
if got := findRootPostInParents(leaf, rootURI); got != rootPost {
|
||||
t.Errorf("expected root post in chain, got %v", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("root absent, chain truncated", func(t *testing.T) {
|
||||
// Topmost parent is not the root (e.g. parentHeight cut off the chain).
|
||||
topmost := makePostView("bob.bsky.social", "did:plc:bob", "mid", "mid")
|
||||
leaf := tvp(makePostView("alice.bsky.social", "did:plc:alice", "leaf", "reply"), tvp(topmost, nil))
|
||||
if got := findRootPostInParents(leaf, rootURI); got != nil {
|
||||
t.Errorf("expected nil when root absent, got %v", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("chain broken by blocked parent", func(t *testing.T) {
|
||||
// A blocked/not-found parent yields a nil FeedDefs_ThreadViewPost,
|
||||
// breaking the walk before the root.
|
||||
leaf := &appbsky.FeedDefs_ThreadViewPost{
|
||||
Post: makePostView("alice.bsky.social", "did:plc:alice", "leaf", "reply"),
|
||||
Parent: &appbsky.FeedDefs_ThreadViewPost_Parent{
|
||||
FeedDefs_BlockedPost: &appbsky.FeedDefs_BlockedPost{Uri: rootURI},
|
||||
},
|
||||
}
|
||||
if got := findRootPostInParents(leaf, rootURI); got != nil {
|
||||
t.Errorf("expected nil when chain broken by blocked parent, got %v", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("empty rootURI", func(t *testing.T) {
|
||||
leaf := tvp(makePostView("alice.bsky.social", "did:plc:alice", "leaf", "reply"), tvp(rootPost, nil))
|
||||
if got := findRootPostInParents(leaf, ""); got != nil {
|
||||
t.Errorf("expected nil for empty rootURI, got %v", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestBuildPostJSONLD_ReplyCommentsNoIsPartOf(t *testing.T) {
|
||||
// Replies surfaced under the main post as comment[] are Comment nodes and
|
||||
// never carry isPartOf, even when the main post has one.
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "main")
|
||||
reply := makePostView("bob.bsky.social", "did:plc:bob", "rep1", "a reply")
|
||||
isPartOf := "https://bsky.app/profile/root.bsky.social/post/rootrkey"
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", isPartOf, hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
c := main["comment"].([]any)[0].(map[string]any)
|
||||
if _, present := c["isPartOf"]; present {
|
||||
t.Errorf("comment entries should not carry isPartOf, got %v", c["isPartOf"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPostJSONLD_ExternalEmbed(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "check this out", withExternalEmbed("https://www.spiegel.de/article", "Title"))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
sc, ok := main["sharedContent"].(map[string]any)
|
||||
if !ok {
|
||||
@@ -606,7 +487,7 @@ func TestBuildPostJSONLD_HiddenEmbed(t *testing.T) {
|
||||
thumb := "https://cdn.bsky.app/img/x@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "nsfw",
|
||||
withImages(thumb), withSelfLabel("porn"))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["image"]; present {
|
||||
t.Errorf("hidden-embed post should not emit image")
|
||||
@@ -625,7 +506,7 @@ func TestBuildPostJSONLD_HiddenEmbed_Gallery(t *testing.T) {
|
||||
thumb := "https://cdn.bsky.app/img/g@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "nsfw",
|
||||
withGallery(thumb), withSelfLabel("porn"))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["image"]; present {
|
||||
t.Errorf("hidden-embed gallery post should not emit image")
|
||||
@@ -639,7 +520,7 @@ func TestBuildPostJSONLD_TextEscaping(t *testing.T) {
|
||||
// Includes ", \, newline, </script>, and a unicode char.
|
||||
tricky := "hello \"world\" \\ <\\>\n</script> 🎉"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", tricky)
|
||||
out, err := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -675,7 +556,7 @@ func TestBuildPostJSONLD_Comments(t *testing.T) {
|
||||
FeedDefs_BlockedPost: &appbsky.FeedDefs_BlockedPost{Uri: "at://x/y/z"},
|
||||
})
|
||||
|
||||
out, _ := buildPostJSONLD(pv, replies, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, replies, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
|
||||
if cc := main["commentCount"].(float64); int64(cc) != 14 {
|
||||
@@ -717,7 +598,7 @@ func TestBuildPostJSONLD_Comments(t *testing.T) {
|
||||
func TestBuildPostJSONLD_HandleInvalidAuthor(t *testing.T) {
|
||||
pv := makePostView("handle.invalid", "did:plc:alice", "abc123", "hello")
|
||||
fallback := "https://bsky.app/profile/did:plc:alice/post/abc123"
|
||||
out, _ := buildPostJSONLD(pv, nil, fallback, "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, fallback, hideEmbedLabels, hideReplyLabels)
|
||||
envelope := unmarshalLD(t, out)
|
||||
main := envelope["mainEntity"].(map[string]any)
|
||||
// mainEntity.url falls back to the caller's canonical URL so envelope
|
||||
@@ -766,7 +647,7 @@ func TestBuildPostJSONLD_EnvelopeURLMatchesMainEntity(t *testing.T) {
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
pv := makePostView(tc.handle, tc.did, tc.rkey, "hi")
|
||||
out, _ := buildPostJSONLD(pv, nil, tc.canonical, "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, tc.canonical, hideEmbedLabels, hideReplyLabels)
|
||||
env := unmarshalLD(t, out)
|
||||
main := env["mainEntity"].(map[string]any)
|
||||
if env["url"] != tc.canonical {
|
||||
@@ -783,7 +664,7 @@ func TestBuildPostJSONLD_NilAuthor(t *testing.T) {
|
||||
// Defensive: don't panic if Author is nil.
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hi")
|
||||
pv.Author = nil
|
||||
if _, err := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels); err == nil {
|
||||
if _, err := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels); err == nil {
|
||||
t.Errorf("expected error for nil-author post, got nil")
|
||||
}
|
||||
}
|
||||
@@ -801,7 +682,7 @@ func TestBuildPostJSONLD_NilAuthorReply(t *testing.T) {
|
||||
{FeedDefs_ThreadViewPost: &appbsky.FeedDefs_ThreadViewPost{Post: goodReply}},
|
||||
{FeedDefs_ThreadViewPost: &appbsky.FeedDefs_ThreadViewPost{Post: badReply}},
|
||||
}
|
||||
out, err := buildPostJSONLD(pv, replies, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, replies, "u", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -822,7 +703,7 @@ func TestBuildPostJSONLD_CommentMedia(t *testing.T) {
|
||||
replies := []*appbsky.FeedDefs_ThreadViewPost_Replies_Elem{
|
||||
{FeedDefs_ThreadViewPost: &appbsky.FeedDefs_ThreadViewPost{Post: reply}},
|
||||
}
|
||||
out, _ := buildPostJSONLD(pv, replies, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, replies, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
c := main["comment"].([]any)[0].(map[string]any)
|
||||
imgs, ok := c["image"].([]any)
|
||||
@@ -1029,7 +910,7 @@ func TestBuildPostJSONLD_HiddenReplyDropped_PostViewLabel(t *testing.T) {
|
||||
good := makePostView("bob.bsky.social", "did:plc:bob", "rep1", "good reply")
|
||||
bad := makePostView("eve.bsky.social", "did:plc:eve", "rep2", "spam reply",
|
||||
withPostLabel("!hide", false))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(good, bad), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(good, bad), "u", hideEmbedLabels, hideReplyLabels)
|
||||
ids := commentIdentifiers(t, out)
|
||||
if len(ids) != 1 || ids[0] != good.Uri {
|
||||
t.Errorf("expected only the unlabeled reply to remain, got %v", ids)
|
||||
@@ -1042,7 +923,7 @@ func TestBuildPostJSONLD_HiddenReplyDropped_SelfLabel(t *testing.T) {
|
||||
good := makePostView("bob.bsky.social", "did:plc:bob", "rep1", "good reply")
|
||||
bad := makePostView("eve.bsky.social", "did:plc:eve", "rep2", "spam reply",
|
||||
withSelfLabel("spam"))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(good, bad), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(good, bad), "u", hideEmbedLabels, hideReplyLabels)
|
||||
ids := commentIdentifiers(t, out)
|
||||
if len(ids) != 1 || ids[0] != good.Uri {
|
||||
t.Errorf("expected self-labeled reply dropped, got %v", ids)
|
||||
@@ -1058,7 +939,7 @@ func TestBuildPostJSONLD_HiddenReplyDropped_EmbedLabel(t *testing.T) {
|
||||
// union behavior.
|
||||
bad := makePostView("eve.bsky.social", "did:plc:eve", "rep2", "concerning reply",
|
||||
withPostLabel("self-harm", false))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(good, bad), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(good, bad), "u", hideEmbedLabels, hideReplyLabels)
|
||||
ids := commentIdentifiers(t, out)
|
||||
if len(ids) != 1 || ids[0] != good.Uri {
|
||||
t.Errorf("expected embed-labeled reply dropped, got %v", ids)
|
||||
@@ -1070,7 +951,7 @@ func TestBuildPostJSONLD_NegatedHideLabelKept(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "main")
|
||||
reply := makePostView("bob.bsky.social", "did:plc:bob", "rep1", "fine reply",
|
||||
withPostLabel("!hide", true))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", hideEmbedLabels, hideReplyLabels)
|
||||
ids := commentIdentifiers(t, out)
|
||||
if len(ids) != 1 || ids[0] != reply.Uri {
|
||||
t.Errorf("expected negated-label reply to be kept, got %v", ids)
|
||||
@@ -1081,7 +962,7 @@ func TestBuildPostJSONLD_ReplyAuthorHasIdentifier(t *testing.T) {
|
||||
// Reply author should also carry a DID identifier.
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "main")
|
||||
reply := makePostView("bob.bsky.social", "did:plc:bob", "rep1", "hi")
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
c := main["comment"].([]any)[0].(map[string]any)
|
||||
auth, ok := c["author"].(map[string]any)
|
||||
@@ -1222,7 +1103,7 @@ func TestBuildPostJSONLD_AuthorReviewedBy(t *testing.T) {
|
||||
})
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hi",
|
||||
withVerifications(state))
|
||||
out, err := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1262,7 +1143,7 @@ func TestBuildPostJSONLD_ReplyAuthorNoReviewedBy(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "main")
|
||||
reply := makePostView("bob.bsky.social", "did:plc:bob", "rep1", "hi",
|
||||
withVerifications(state))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
c := main["comment"].([]any)[0].(map[string]any)
|
||||
auth := c["author"].(map[string]any)
|
||||
@@ -1386,7 +1267,7 @@ func TestBuildPostJSONLD_WithVideoObject(t *testing.T) {
|
||||
hasAspect: true, width: 16, height: 9,
|
||||
}))
|
||||
canonical := "https://bsky.app/profile/alice.bsky.social/post/abc123"
|
||||
out, err := buildPostJSONLD(pv, nil, canonical, "", hideEmbedLabels, hideReplyLabels)
|
||||
out, err := buildPostJSONLD(pv, nil, canonical, hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1434,7 +1315,7 @@ func TestBuildPostJSONLD_VideoNameFallback(t *testing.T) {
|
||||
withVideoFull(videoEmbedOpts{
|
||||
playlist: "https://video.bsky.app/p.m3u8",
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
video, ok := main["video"].(map[string]any)
|
||||
if !ok {
|
||||
@@ -1451,7 +1332,7 @@ func TestBuildPostJSONLD_VideoNameFallbackHandleInvalid(t *testing.T) {
|
||||
withVideoFull(videoEmbedOpts{
|
||||
playlist: "https://video.bsky.app/p.m3u8",
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
video := main["video"].(map[string]any)
|
||||
if video["name"] != "Video on Bluesky" {
|
||||
@@ -1466,7 +1347,7 @@ func TestBuildPostJSONLD_VideoDescriptionFallback(t *testing.T) {
|
||||
withVideoFull(videoEmbedOpts{
|
||||
playlist: "https://video.bsky.app/p.m3u8", alt: "scenic clip",
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
video := main["video"].(map[string]any)
|
||||
if video["description"] != "scenic clip" {
|
||||
@@ -1479,7 +1360,7 @@ func TestBuildPostJSONLD_VideoNoAspectRatio(t *testing.T) {
|
||||
withVideoFull(videoEmbedOpts{
|
||||
playlist: "https://video.bsky.app/p.m3u8", alt: "alt",
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
video := main["video"].(map[string]any)
|
||||
if _, present := video["width"]; present {
|
||||
@@ -1496,7 +1377,7 @@ func TestBuildPostJSONLD_VideoMissingPlaylist(t *testing.T) {
|
||||
thumb := "https://cdn.bsky.app/img/video_thumbnail/plain/did:plc:alice/v@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "x",
|
||||
withVideo(thumb))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["video"]; present {
|
||||
t.Errorf("video without playlist should not produce VideoObject")
|
||||
@@ -1515,7 +1396,7 @@ func TestBuildPostJSONLD_VideoHiddenEmbed(t *testing.T) {
|
||||
alt: "should be dropped",
|
||||
}),
|
||||
withSelfLabel("porn"))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["video"]; present {
|
||||
t.Errorf("hidden-embed post should not emit video")
|
||||
@@ -1530,7 +1411,7 @@ func TestBuildPostJSONLD_VideoInRecordWithMedia(t *testing.T) {
|
||||
thumbnail: thumb, playlist: playlist, alt: "alt", recordMedia: true,
|
||||
hasAspect: true, width: 4, height: 3,
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
video, ok := main["video"].(map[string]any)
|
||||
if !ok {
|
||||
@@ -1557,7 +1438,7 @@ func TestBuildPostJSONLD_VideoOnReply(t *testing.T) {
|
||||
withVideoFull(videoEmbedOpts{
|
||||
thumbnail: thumb, playlist: playlist, alt: "bob's clip",
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
c := main["comment"].([]any)[0].(map[string]any)
|
||||
video, ok := c["video"].(map[string]any)
|
||||
@@ -1580,7 +1461,7 @@ func TestBuildPostJSONLD_VideoOnReply(t *testing.T) {
|
||||
|
||||
func TestBuildPostJSONLD_NoVideoNoField(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "no embed")
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
if _, present := main["video"]; present {
|
||||
t.Errorf("post without video should not include video field")
|
||||
@@ -1624,7 +1505,7 @@ func TestBuildPostJSONLD_VideoHandleInvalidEmbedURL(t *testing.T) {
|
||||
playlist: playlist, alt: "scenic clip",
|
||||
}))
|
||||
canonical := "https://bsky.app/profile/did:plc:alice/post/abc123"
|
||||
out, _ := buildPostJSONLD(pv, nil, canonical, "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, nil, canonical, hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
video, ok := main["video"].(map[string]any)
|
||||
if !ok {
|
||||
@@ -1647,7 +1528,7 @@ func TestBuildPostJSONLD_VideoHandleInvalidEmbedURL_Reply(t *testing.T) {
|
||||
withVideoFull(videoEmbedOpts{
|
||||
playlist: playlist, alt: "bob's clip",
|
||||
}))
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
out, _ := buildPostJSONLD(pv, buildReplies(reply), "u", hideEmbedLabels, hideReplyLabels)
|
||||
main := unmarshalLD(t, out)["mainEntity"].(map[string]any)
|
||||
c := main["comment"].([]any)[0].(map[string]any)
|
||||
video, ok := c["video"].(map[string]any)
|
||||
|
||||
@@ -20,20 +20,3 @@ func profileRequiresAuth(pv *appbsky.ActorDefs_ProfileViewDetailed) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// postAuthorRequiresAuth reports whether the post author self-applied the
|
||||
// !no-unauthenticated label, read from the author view embedded in a
|
||||
// getPostThread response. The appview surfaces the account's profile-record
|
||||
// self-labels on the post author (src == author DID), so this mirrors
|
||||
// profileRequiresAuth without a separate ActorGetProfile call.
|
||||
func postAuthorRequiresAuth(pv *appbsky.FeedDefs_PostView) bool {
|
||||
if pv == nil || pv.Author == nil {
|
||||
return false
|
||||
}
|
||||
for _, label := range pv.Author.Labels {
|
||||
if label.Src == pv.Author.Did && label.Val == "!no-unauthenticated" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -77,76 +77,3 @@ func TestProfileRequiresAuth(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostAuthorRequiresAuth(t *testing.T) {
|
||||
negTrue := true
|
||||
|
||||
authorPV := func(labels []*comatprototypes.LabelDefs_Label) *appbsky.FeedDefs_PostView {
|
||||
return &appbsky.FeedDefs_PostView{
|
||||
Author: &appbsky.ActorDefs_ProfileViewBasic{
|
||||
Did: "did:plc:alice",
|
||||
Handle: "alice.bsky.social",
|
||||
Labels: labels,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
pv *appbsky.FeedDefs_PostView
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "nil post view",
|
||||
pv: nil,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "nil author",
|
||||
pv: &appbsky.FeedDefs_PostView{},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "no labels",
|
||||
pv: authorPV(nil),
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "self-applied !no-unauthenticated",
|
||||
pv: authorPV([]*comatprototypes.LabelDefs_Label{
|
||||
{Src: "did:plc:alice", Val: "!no-unauthenticated"},
|
||||
}),
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "label from a different src does not gate",
|
||||
pv: authorPV([]*comatprototypes.LabelDefs_Label{
|
||||
{Src: "did:plc:labeler", Val: "!no-unauthenticated"},
|
||||
}),
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "different label value does not gate",
|
||||
pv: authorPV([]*comatprototypes.LabelDefs_Label{
|
||||
{Src: "did:plc:alice", Val: "spam"},
|
||||
}),
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
// Negation isn't honored - matches profileRequiresAuth behavior.
|
||||
name: "negated label still triggers (matches profile behavior)",
|
||||
pv: authorPV([]*comatprototypes.LabelDefs_Label{
|
||||
{Src: "did:plc:alice", Val: "!no-unauthenticated", Neg: &negTrue},
|
||||
}),
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := postAuthorRequiresAuth(tt.pv); got != tt.want {
|
||||
t.Errorf("got %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestRenderBase_NoindexMeta(t *testing.T) {
|
||||
|
||||
func TestRenderPost_EmitsJSONLD(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hello")
|
||||
ld, err := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, err := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", hideEmbedLabels, hideReplyLabels)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func TestRenderPost_OGImageMatchesJSONLD(t *testing.T) {
|
||||
thumb1 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/abc@jpeg"
|
||||
thumb2 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/def@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "look", withImages(thumb1, thumb2))
|
||||
ld, _ := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", hideEmbedLabels, hideReplyLabels)
|
||||
html := renderTemplate(t, "post.html", pongo2.Context{
|
||||
"postView": pv,
|
||||
"requestURI": "https://bsky.app/profile/alice.bsky.social/post/abc123",
|
||||
@@ -113,7 +113,7 @@ func TestRenderPost_OGImageMatchesJSONLD_Gallery(t *testing.T) {
|
||||
thumb2 := "https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:alice/g2@jpeg"
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "gallery", withGallery(thumb1, thumb2))
|
||||
thumbs := extractPostMedia(pv, false)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", hideEmbedLabels, hideReplyLabels)
|
||||
html := renderTemplate(t, "post.html", pongo2.Context{
|
||||
"postView": pv,
|
||||
"requestURI": "https://bsky.app/profile/alice.bsky.social/post/abc123",
|
||||
@@ -142,7 +142,7 @@ func TestRenderPost_OGImageMatchesJSONLD_Gallery(t *testing.T) {
|
||||
func TestRenderPost_FallsBackToCanonicalizeFilter(t *testing.T) {
|
||||
// Without canonicalURL, the template falls back to requestURI|canonicalize_url.
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hi")
|
||||
ld, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
html := renderTemplate(t, "post.html", pongo2.Context{
|
||||
"postView": pv,
|
||||
"requestURI": "https://bsky.app/profile/alice.bsky.social/post/abc123?utm=foo",
|
||||
@@ -208,7 +208,7 @@ func TestRenderProfile_AuthRequiredEmitsJSONLD(t *testing.T) {
|
||||
// og:url and <link rel="canonical"> must emit the same URL.
|
||||
func TestRenderPost_OGUrlMatchesCanonical(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hi")
|
||||
ld, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
canonical := "https://bsky.app/profile/alice.bsky.social/post/abc123"
|
||||
html := renderTemplate(t, "post.html", pongo2.Context{
|
||||
"postView": pv,
|
||||
@@ -233,7 +233,7 @@ func TestRenderPost_OGUrlMatchesCanonical(t *testing.T) {
|
||||
// video without a thumbnail dropped og:video entirely.
|
||||
func TestRenderPost_VideoWithoutThumbnailEmitsOGVideo(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "watch")
|
||||
ld, _ := buildPostJSONLD(pv, nil, "u", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "u", hideEmbedLabels, hideReplyLabels)
|
||||
videoURL := "https://video.bsky.app/v.m3u8"
|
||||
html := renderTemplate(t, "post.html", pongo2.Context{
|
||||
"postView": pv,
|
||||
@@ -286,7 +286,7 @@ func TestRenderProfile_AuthRequiredNoindex(t *testing.T) {
|
||||
// flip of the noindex flag for indexable pages.
|
||||
func TestRenderPost_PublicNoNoindex(t *testing.T) {
|
||||
pv := makePostView("alice.bsky.social", "did:plc:alice", "abc123", "hello")
|
||||
ld, _ := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", "", hideEmbedLabels, hideReplyLabels)
|
||||
ld, _ := buildPostJSONLD(pv, nil, "https://bsky.app/profile/alice.bsky.social/post/abc123", hideEmbedLabels, hideReplyLabels)
|
||||
html := renderTemplate(t, "post.html", pongo2.Context{
|
||||
"postView": pv,
|
||||
"requestURI": "https://bsky.app/profile/alice.bsky.social/post/abc123",
|
||||
|
||||
@@ -620,39 +620,23 @@ func (srv *Server) WebPost(c echo.Context) error {
|
||||
|
||||
identifier := handleOrDID.Normalize().String()
|
||||
|
||||
// requires two fetches: first fetch profile (!)
|
||||
pv, err := appbsky.ActorGetProfile(ctx, srv.xrpcc, identifier)
|
||||
if err != nil {
|
||||
log.Warnf("failed to fetch profile for: %s\t%v", identifier, err)
|
||||
return c.Render(http.StatusOK, "post.html", data)
|
||||
}
|
||||
unauthedViewingOkay := !profileRequiresAuth(pv)
|
||||
|
||||
req := c.Request()
|
||||
requestURI := fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
|
||||
|
||||
// Fetch the post thread directly. The AT-URI authority accepts either a
|
||||
// handle or a DID (the appview resolves it), so we skip the separate
|
||||
// ActorGetProfile call and source identity, the canonical URL, and the
|
||||
// auth gate from the thread response's author view instead.
|
||||
// parentHeight=80 (the lexicon default) pulls the reply's ancestor chain
|
||||
// up to the root in nearly all threads, letting isPartOf resolve from this
|
||||
// response without a separate FeedGetPosts call.
|
||||
uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", identifier, rkey)
|
||||
tpv, err := appbsky.FeedGetPostThread(ctx, srv.xrpcc, 1, 80, uri)
|
||||
if err != nil {
|
||||
log.Warnf("failed to fetch post: %s\t%v", uri, err)
|
||||
return c.Render(http.StatusOK, "post.html", data)
|
||||
}
|
||||
|
||||
threadView := tpv.Thread.FeedDefs_ThreadViewPost
|
||||
if threadView == nil || threadView.Post == nil || threadView.Post.Author == nil {
|
||||
return c.Render(http.StatusOK, "post.html", data)
|
||||
}
|
||||
postView := threadView.Post
|
||||
|
||||
// Always prefer the handle-form URL so JSON-LD `url` and
|
||||
// <link rel="canonical"> match. Falls back to requestURI when the
|
||||
// handle is unusable (template strips query/fragment).
|
||||
canonicalURL := bskyPostURL(postView.Author.Handle, rkey.String())
|
||||
canonicalURL := bskyPostURL(pv.Handle, rkey.String())
|
||||
|
||||
// Gate before populating any post content into the template so that
|
||||
// !no-unauthenticated posts never leak text/media. The appview returns the
|
||||
// post (with the author self-label) to unauthed callers, so we detect the
|
||||
// label here rather than via a profile fetch.
|
||||
if postAuthorRequiresAuth(postView) {
|
||||
if !unauthedViewingOkay {
|
||||
// Provide minimal OpenGraph data for auth-required posts
|
||||
data["requestURI"] = requestURI
|
||||
if canonicalURL != "" {
|
||||
@@ -661,13 +645,26 @@ func (srv *Server) WebPost(c echo.Context) error {
|
||||
data["requiresAuth"] = true
|
||||
data["noindex"] = true
|
||||
data["nofollow"] = true
|
||||
data["profileHandle"] = postView.Author.Handle
|
||||
if postView.Author.DisplayName != nil {
|
||||
data["profileDisplayName"] = *postView.Author.DisplayName
|
||||
data["profileHandle"] = pv.Handle
|
||||
if pv.DisplayName != nil {
|
||||
data["profileDisplayName"] = *pv.DisplayName
|
||||
}
|
||||
return c.Render(http.StatusOK, "post.html", data)
|
||||
}
|
||||
|
||||
// then fetch the post thread (with extra context)
|
||||
uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", pv.Did, rkey)
|
||||
tpv, err := appbsky.FeedGetPostThread(ctx, srv.xrpcc, 1, 0, uri)
|
||||
if err != nil {
|
||||
log.Warnf("failed to fetch post: %s\t%v", uri, err)
|
||||
return c.Render(http.StatusOK, "post.html", data)
|
||||
}
|
||||
|
||||
threadView := tpv.Thread.FeedDefs_ThreadViewPost
|
||||
if threadView == nil || threadView.Post == nil {
|
||||
return c.Render(http.StatusOK, "post.html", data)
|
||||
}
|
||||
postView := threadView.Post
|
||||
data["postView"] = postView
|
||||
data["requestURI"] = requestURI
|
||||
if canonicalURL != "" {
|
||||
@@ -697,32 +694,7 @@ func (srv *Server) WebPost(c echo.Context) error {
|
||||
if jsonldURL == "" {
|
||||
jsonldURL = requestURI
|
||||
}
|
||||
|
||||
// Best-effort: resolve a reply's thread root to its handle-form canonical
|
||||
// URL for isPartOf. Prefer the root already present in the thread response
|
||||
// (parentHeight=80); fall back to a bounded FeedGetPosts only when the
|
||||
// chain is truncated (very deep thread) or broken by a blocked/not-found
|
||||
// ancestor. On timeout, error, or an unresolvable root we omit isPartOf
|
||||
// rather than point at a non-indexable page.
|
||||
isPartOfURL := ""
|
||||
if rootURI := threadRootURI(postView); rootURI != "" {
|
||||
if rootPost := findRootPostInParents(threadView, rootURI); rootPost != nil && rootPost.Author != nil {
|
||||
isPartOfURL = bskyPostURLFromATURI(rootPost.Author.Handle, rootURI)
|
||||
} else {
|
||||
pctx, cancel := context.WithTimeout(ctx, 1*time.Second)
|
||||
if posts, perr := appbsky.FeedGetPosts(pctx, srv.xrpcc, []string{rootURI}); perr != nil {
|
||||
log.Warnf("failed to resolve thread root post for isPartOf: %s\t%v", rootURI, perr)
|
||||
} else if len(posts.Posts) > 0 && posts.Posts[0].Author != nil {
|
||||
// Handle-form only (no DID fallback): isPartOf must match the
|
||||
// root page's handle-form canonical, so an unusable handle omits
|
||||
// isPartOf rather than point at a non-canonical DID-form URL.
|
||||
isPartOfURL = bskyPostURLFromATURI(posts.Posts[0].Author.Handle, rootURI)
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
if jsonld, err := buildPostJSONLD(postView, threadView.Replies, jsonldURL, isPartOfURL, hideEmbedLabels, hideReplyLabels); err == nil {
|
||||
if jsonld, err := buildPostJSONLD(postView, threadView.Replies, jsonldURL, hideEmbedLabels, hideReplyLabels); err == nil {
|
||||
data["postJSONLD"] = jsonld
|
||||
} else {
|
||||
log.Warnf("failed to build post JSON-LD for %s: %v", uri, err)
|
||||
|
||||
+8
-8
@@ -44,9 +44,9 @@ require (
|
||||
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/pgx/v5 v5.9.2 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.0 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
@@ -90,11 +90,11 @@ require (
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.26.0 // indirect
|
||||
golang.org/x/crypto v0.52.0 // indirect
|
||||
golang.org/x/net v0.55.0 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/sys v0.45.0 // indirect
|
||||
golang.org/x/text v0.37.0 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/net v0.47.0 // indirect
|
||||
golang.org/x/sync v0.18.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
|
||||
+18
-18
@@ -77,12 +77,12 @@ github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fG
|
||||
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.9.2 h1:3ZhOzMWnR4yJ+RW1XImIPsD1aNSz4T4fyP7zlQb56hw=
|
||||
github.com/jackc/pgx/v5 v5.9.2/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw=
|
||||
github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
|
||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
|
||||
github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o=
|
||||
github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4=
|
||||
@@ -194,8 +194,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
@@ -247,8 +247,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
|
||||
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
@@ -266,16 +266,16 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
|
||||
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -291,8 +291,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
|
||||
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
@@ -304,8 +304,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
|
||||
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
"start": "NODE_ENV=development ./dev-infra/with-test-redis-and-db.sh node ./mock-server.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@atproto/api": "^0.20.22",
|
||||
"@atproto/dev-env": "^0.5.3",
|
||||
"@atproto/api": "^0.20.0",
|
||||
"@atproto/dev-env": "^0.5.0",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Generated
+13
-73
@@ -208,10 +208,10 @@ importers:
|
||||
.:
|
||||
dependencies:
|
||||
'@atproto/api':
|
||||
specifier: ^0.20.22
|
||||
version: 0.20.22
|
||||
specifier: ^0.20.0
|
||||
version: 0.20.5
|
||||
'@atproto/dev-env':
|
||||
specifier: ^0.5.3
|
||||
specifier: ^0.5.0
|
||||
version: 0.5.3
|
||||
typescript:
|
||||
specifier: ^6.0.3
|
||||
@@ -257,8 +257,8 @@ packages:
|
||||
resolution: {integrity: sha512-nmjM83KucbRnz/CDSXQX6FLH/GP93XjcI1u5WFlomPscmeOAP1+9AOVsMQlKmh27I3hgaSOdCr03GJjAIpuPZQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/api@0.20.22':
|
||||
resolution: {integrity: sha512-TdT9ktYc0FMmMZ8HjkMz13QcSCcYiesCGN81mFZd5owQASHVM9GBtAAmzpkrPyZhUkiIjgh/nUHk8xWVu+4dVA==}
|
||||
'@atproto/api@0.20.5':
|
||||
resolution: {integrity: sha512-VqkRYKR9vRRk36NhtytJz5TPhNtR1hczCcfM+bWoOK6MBvWUT8HwelufrycFAIbFIH7n4ws+5UbnLYpTIBQZ6Q==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/aws@0.3.0':
|
||||
@@ -277,10 +277,6 @@ packages:
|
||||
resolution: {integrity: sha512-ReWnkuZdDU/74/I47gaI26uxQjHmpq4edp41NnZZQ5vIIKGb7Ei6pZHzDTUD9JURo109SKrPx9RMP2IQm0fOKA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/common-web@0.5.2':
|
||||
resolution: {integrity: sha512-oO0JEvM7MM7iXMngq6V51IJlzBZFhFJoDjnGnQT75EO94/8Q5hnM/LP+a8KyWjcBcpcSZwQ0bukNv9phZONdGA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/common@0.1.0':
|
||||
resolution: {integrity: sha512-OB5tWE2R19jwiMIs2IjQieH5KTUuMb98XGCn9h3xuu6NanwjlmbCYMv08fMYwIp3UQ6jcq//84cDT3Bu6fJD+A==}
|
||||
|
||||
@@ -335,10 +331,6 @@ packages:
|
||||
resolution: {integrity: sha512-/xza8nU/YhtzhETnHL3QKKofaJ28/0NCzhT7LaYoUkm8EgypWp5ykEtmW52yLhQM2JF6fVa25g1soQmNTGqtSg==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lex-data@0.1.3':
|
||||
resolution: {integrity: sha512-ysqMYW6cIKce52/+EIbTa+I4pLqZQSBP9aGImN88vAQtd1oZBKPmut6dQk00xSQ8PW9REJRuIHNSFAF4HD+fsw==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lex-document@0.1.0':
|
||||
resolution: {integrity: sha512-I2q2iwK8RnSHkBeAj5xdJNYdHiUQqlkbbleBSJKJXlYOYy5y86dWRo9IfE0l9E3qZ3/zvy1ydlEZmZupEt0FGg==}
|
||||
engines: {node: '>=22'}
|
||||
@@ -351,10 +343,6 @@ packages:
|
||||
resolution: {integrity: sha512-oWUrRMwFyWpmi/5k1Se3xBTbP06XdxBS5iFuUz9LmqItaPXwrWRD87a9ldPvINQ/A2/mn7J6/qug8sDVlhD+vQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lex-json@0.1.2':
|
||||
resolution: {integrity: sha512-58nIjoWX0c8T5fcoPPmIaShxKZgfPMhNmrprtR7GuN4PzyMwm59A3CLlKAzzR+vjI3IidEMU+enpLuwUT8L+Nw==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lex-resolver@0.1.0':
|
||||
resolution: {integrity: sha512-zliMiRW4ttSNFreKxyvSpaYQjeWrKpV/lutnXI9BNE8Ysgnw8Rltm0bR7kG/y0OlyClxhhU/vAG+OR8NpjhU1Q==}
|
||||
engines: {node: '>=22'}
|
||||
@@ -372,10 +360,6 @@ packages:
|
||||
resolution: {integrity: sha512-voNfNED5KUxn3vpo7N5DMRblBDfWf7kSfdKhJFC1RrLCxg38YbBzzURNVQJ32bp13Oot8kYfyXBWxTgtKLvw8w==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lexicon@0.7.3':
|
||||
resolution: {integrity: sha512-WP6ct2rjNCKSJN/VFc+8x6JQ7PvRMlfHUlmQM5hzvE3a6nOjm6kwSicjSIV/QldurdRGJ4FCQZ3uZu9Wqt4SxQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/oauth-provider-api@0.6.0':
|
||||
resolution: {integrity: sha512-wFioPBgI71v4PuEwYmIYPp4GNOyaRw1UX8FJq0AiNuUGMbqCjdd7ImSsG4b43hsHr5wOsMirsWyccjUEdhb+yQ==}
|
||||
engines: {node: '>=22'}
|
||||
@@ -416,10 +400,6 @@ packages:
|
||||
resolution: {integrity: sha512-kA4dQDoMPpWCH8N0Q4KoSq024u5MkVfDVa8DdhyLjGA72z/khbOf1jXKPv7NIL2oEc9aj7geKELdvqyf4ogopA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/syntax@0.6.3':
|
||||
resolution: {integrity: sha512-io7Ck4o+40iFXhetHYoEtok2gZ8cWcJ1yRftEHe5AmAF0dSGcYmclbx5GatVew59taw+eSG7Ty5D3llop/0BhA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/ws-client@0.1.0':
|
||||
resolution: {integrity: sha512-8qG+A+htxEHpDJRgtYNUExUOejDwU4nE2SEJCFLiTc1G+s0GbFaeg7Fk5drQA9tLMHQWoU9uqIr1YQpJyvJs8w==}
|
||||
engines: {node: '>=22'}
|
||||
@@ -432,10 +412,6 @@ packages:
|
||||
resolution: {integrity: sha512-NJy02bIKrWlE2NQkRV1kT0Cj0ixbuxlF/MejBdo4cPWAa9v3oZexvAcjjb0zaOYeABkaU14iyIhvn2G4e/oLpw==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/xrpc@0.8.2':
|
||||
resolution: {integrity: sha512-geLqJwazZuCGnae68KZppciS8DujhGvYtpc/aAj16XpHkUCf5Ds64H1IPrV0uv7SFvd/IAuMZAXZS4GIpfp1iw==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@aws-crypto/crc32@5.2.0':
|
||||
resolution: {integrity: sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
@@ -2134,12 +2110,12 @@ snapshots:
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
|
||||
'@atproto/api@0.20.22':
|
||||
'@atproto/api@0.20.5':
|
||||
dependencies:
|
||||
'@atproto/common-web': 0.5.2
|
||||
'@atproto/lexicon': 0.7.3
|
||||
'@atproto/syntax': 0.6.3
|
||||
'@atproto/xrpc': 0.8.2
|
||||
'@atproto/common-web': 0.5.0
|
||||
'@atproto/lexicon': 0.7.1
|
||||
'@atproto/syntax': 0.6.1
|
||||
'@atproto/xrpc': 0.8.0
|
||||
await-lock: 3.0.0
|
||||
multiformats: 13.4.2
|
||||
tlds: 1.261.0
|
||||
@@ -2164,7 +2140,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@atproto-labs/fetch-node': 0.3.0
|
||||
'@atproto-labs/xrpc-utils': 0.1.0
|
||||
'@atproto/api': 0.20.22
|
||||
'@atproto/api': 0.20.5
|
||||
'@atproto/common': 0.6.1
|
||||
'@atproto/crypto': 0.5.0
|
||||
'@atproto/did': 0.4.0
|
||||
@@ -2234,13 +2210,6 @@ snapshots:
|
||||
'@atproto/syntax': 0.6.1
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/common-web@0.5.2':
|
||||
dependencies:
|
||||
'@atproto/lex-data': 0.1.3
|
||||
'@atproto/lex-json': 0.1.2
|
||||
'@atproto/syntax': 0.6.3
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/common@0.1.0':
|
||||
dependencies:
|
||||
'@ipld/dag-cbor': 7.0.3
|
||||
@@ -2279,7 +2248,7 @@ snapshots:
|
||||
|
||||
'@atproto/dev-env@0.5.3':
|
||||
dependencies:
|
||||
'@atproto/api': 0.20.22
|
||||
'@atproto/api': 0.20.5
|
||||
'@atproto/bsky': 0.0.234
|
||||
'@atproto/bsync': 0.0.27
|
||||
'@atproto/common-web': 0.5.0
|
||||
@@ -2354,13 +2323,6 @@ snapshots:
|
||||
uint8arrays: 5.1.1
|
||||
unicode-segmenter: 0.14.5
|
||||
|
||||
'@atproto/lex-data@0.1.3':
|
||||
dependencies:
|
||||
multiformats: 13.4.2
|
||||
tslib: 2.8.1
|
||||
uint8arrays: 5.1.1
|
||||
unicode-segmenter: 0.14.5
|
||||
|
||||
'@atproto/lex-document@0.1.0':
|
||||
dependencies:
|
||||
'@atproto/lex-schema': 0.1.1
|
||||
@@ -2383,11 +2345,6 @@ snapshots:
|
||||
'@atproto/lex-data': 0.1.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@atproto/lex-json@0.1.2':
|
||||
dependencies:
|
||||
'@atproto/lex-data': 0.1.3
|
||||
tslib: 2.8.1
|
||||
|
||||
'@atproto/lex-resolver@0.1.0':
|
||||
dependencies:
|
||||
'@atproto-labs/did-resolver': 0.3.0
|
||||
@@ -2425,13 +2382,6 @@ snapshots:
|
||||
multiformats: 13.4.2
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/lexicon@0.7.3':
|
||||
dependencies:
|
||||
'@atproto/common-web': 0.5.2
|
||||
'@atproto/syntax': 0.6.3
|
||||
multiformats: 13.4.2
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/oauth-provider-api@0.6.0':
|
||||
dependencies:
|
||||
'@atproto/jwk': 0.7.0
|
||||
@@ -2486,7 +2436,7 @@ snapshots:
|
||||
|
||||
'@atproto/ozone@0.1.176':
|
||||
dependencies:
|
||||
'@atproto/api': 0.20.22
|
||||
'@atproto/api': 0.20.5
|
||||
'@atproto/common': 0.6.1
|
||||
'@atproto/crypto': 0.5.0
|
||||
'@atproto/identity': 0.5.0
|
||||
@@ -2601,11 +2551,6 @@ snapshots:
|
||||
iso-datestring-validator: 2.2.2
|
||||
tslib: 2.8.1
|
||||
|
||||
'@atproto/syntax@0.6.3':
|
||||
dependencies:
|
||||
iso-datestring-validator: 2.2.2
|
||||
tslib: 2.8.1
|
||||
|
||||
'@atproto/ws-client@0.1.0':
|
||||
dependencies:
|
||||
'@atproto/common': 0.6.1
|
||||
@@ -2641,11 +2586,6 @@ snapshots:
|
||||
'@atproto/lexicon': 0.7.1
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/xrpc@0.8.2':
|
||||
dependencies:
|
||||
'@atproto/lexicon': 0.7.3
|
||||
zod: 3.25.76
|
||||
|
||||
'@aws-crypto/crc32@5.2.0':
|
||||
dependencies:
|
||||
'@aws-crypto/util': 5.2.0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"build": {
|
||||
"base": {
|
||||
"node": "24.18.0"
|
||||
"node": "24.15.0"
|
||||
},
|
||||
"development": {
|
||||
"extends": "base",
|
||||
|
||||
@@ -10,9 +10,22 @@
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"modules/bottom-sheet/src/BottomSheetPortal.tsx": {
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/bottom-sheet/src/lib/Portal.tsx": {
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider.tsx": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/expo-background-notification-handler/src/ExpoBackgroundNotificationHandlerModule.web.ts": {
|
||||
@@ -20,6 +33,28 @@
|
||||
"count": 4
|
||||
}
|
||||
},
|
||||
"modules/expo-bluesky-gif-view/src/GifView.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-call": {
|
||||
"count": 4
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 4
|
||||
},
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/expo-bluesky-gif-view/src/GifView.web.tsx": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 2
|
||||
},
|
||||
"@typescript-eslint/require-await": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"modules/expo-bluesky-swiss-army/src/PlatformInfo/index.native.ts": {
|
||||
"@typescript-eslint/no-unsafe-call": {
|
||||
"count": 3
|
||||
@@ -53,6 +88,9 @@
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 1
|
||||
},
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/expo-bluesky-swiss-army/src/VisibilityView/index.tsx": {
|
||||
@@ -60,6 +98,16 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/expo-bluesky-swiss-army/src/VisibilityView/types.ts": {
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"modules/expo-emoji-picker/src/EmojiPickerView.tsx": {
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/Navigation.tsx": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 1
|
||||
@@ -162,6 +210,11 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/components/Autocomplete/Autocomplete.tsx": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/components/Autocomplete/useAutocomplete/index.ts": {
|
||||
"react-hooks/immutability": {
|
||||
"count": 1
|
||||
@@ -671,6 +724,9 @@
|
||||
}
|
||||
},
|
||||
"src/components/forms/TextField.tsx": {
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 3
|
||||
},
|
||||
"react-hooks/refs": {
|
||||
"count": 1
|
||||
}
|
||||
@@ -890,6 +946,14 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/lib/hooks/useNotificationHandler.ts": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 16
|
||||
},
|
||||
"@typescript-eslint/require-await": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/lib/hooks/useOTAUpdates.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
@@ -924,6 +988,11 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/lib/hooks/useTabFocusEffect.ts": {
|
||||
"react-hooks/set-state-in-effect": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/lib/hooks/useToggleMutationQueue.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
@@ -984,6 +1053,11 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/lib/merge-refs.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/lib/notifications/notifications.ts": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 5
|
||||
@@ -1050,11 +1124,27 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/logger/transports/sentry.ts": {
|
||||
"@typescript-eslint/no-unsafe-enum-comparison": {
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"src/logger/types.ts": {
|
||||
"@typescript-eslint/no-redundant-type-constituents": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Bookmarks/index.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 3
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/screens/Deactivated.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
@@ -1113,7 +1203,69 @@
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/screens/Login/ChooseAccountForm.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Login/ForgotPasswordForm.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-call": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Login/LoginForm.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 3
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-call": {
|
||||
"count": 4
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 4
|
||||
},
|
||||
"react-hooks/refs": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Login/SetNewPasswordForm.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 2
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-call": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Login/index.tsx": {
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"react-hooks/purity": {
|
||||
"count": 1
|
||||
},
|
||||
"react-hooks/refs": {
|
||||
"count": 1
|
||||
},
|
||||
@@ -1422,6 +1574,11 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Signup/StepHandle/index.tsx": {
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/screens/Signup/StepInfo/Policies.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
@@ -1765,6 +1922,14 @@
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/state/queries/search-posts.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/state/queries/starter-packs.ts": {
|
||||
"@typescript-eslint/require-await": {
|
||||
"count": 1
|
||||
@@ -1860,6 +2025,18 @@
|
||||
}
|
||||
},
|
||||
"src/view/com/composer/Composer.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
},
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 4
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 2
|
||||
},
|
||||
"react-hooks/immutability": {
|
||||
"count": 2
|
||||
},
|
||||
@@ -1949,6 +2126,11 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/com/composer/videos/pickVideo.web.ts": {
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/com/feeds/ComposerPrompt.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
@@ -2001,6 +2183,14 @@
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"src/view/com/modals/Modal.tsx": {
|
||||
"@typescript-eslint/no-misused-promises": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/require-await": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/com/notifications/NotificationFeed.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 2
|
||||
@@ -2186,6 +2376,14 @@
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"src/view/com/util/ViewSelector.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 6
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/com/util/Views.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
@@ -2201,6 +2399,14 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"src/view/screens/Debug.tsx": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 1
|
||||
},
|
||||
"@typescript-eslint/no-unsafe-member-access": {
|
||||
"count": 4
|
||||
}
|
||||
},
|
||||
"src/view/screens/Feeds.tsx": {
|
||||
"@typescript-eslint/no-floating-promises": {
|
||||
"count": 3
|
||||
|
||||
@@ -38,8 +38,6 @@ export default defineConfig(
|
||||
'*.e2e.ts',
|
||||
'*.e2e.tsx',
|
||||
'eslint.config.mjs',
|
||||
'babel.config.js',
|
||||
'metro.config.js',
|
||||
'.jscodeshift/**',
|
||||
],
|
||||
},
|
||||
|
||||
@@ -7,7 +7,6 @@ export default defineConfig({
|
||||
'an',
|
||||
'ast',
|
||||
'ca',
|
||||
'cs',
|
||||
'cy',
|
||||
'da',
|
||||
'de',
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import {createContext, useContext, useMemo} from 'react'
|
||||
import React from 'react'
|
||||
|
||||
import {createPortalGroup_INTERNAL} from './lib/Portal'
|
||||
|
||||
type PortalContext = React.ElementType<{children: React.ReactNode}>
|
||||
|
||||
export const Context = createContext({} as PortalContext)
|
||||
export const Context = React.createContext({} as PortalContext)
|
||||
Context.displayName = 'BottomSheetPortalContext'
|
||||
|
||||
export const useBottomSheetPortal_INTERNAL = () => useContext(Context)
|
||||
export const useBottomSheetPortal_INTERNAL = () => React.useContext(Context)
|
||||
|
||||
export function BottomSheetPortalProvider({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const portal = useMemo(() => {
|
||||
const portal = React.useMemo(() => {
|
||||
return createPortalGroup_INTERNAL()
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
createContext,
|
||||
Fragment,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useId,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react'
|
||||
import React from 'react'
|
||||
|
||||
type Component = React.ReactElement
|
||||
|
||||
@@ -23,7 +13,7 @@ type ComponentMap = {
|
||||
}
|
||||
|
||||
export function createPortalGroup_INTERNAL() {
|
||||
const Context = createContext<ContextType>({
|
||||
const Context = React.createContext<ContextType>({
|
||||
outlet: null,
|
||||
append: () => {},
|
||||
remove: () => {},
|
||||
@@ -31,21 +21,21 @@ export function createPortalGroup_INTERNAL() {
|
||||
Context.displayName = 'BottomSheetPortalContext'
|
||||
|
||||
function Provider(props: React.PropsWithChildren<{}>) {
|
||||
const map = useRef<ComponentMap>({})
|
||||
const [outlet, setOutlet] = useState<ContextType['outlet']>(null)
|
||||
const map = React.useRef<ComponentMap>({})
|
||||
const [outlet, setOutlet] = React.useState<ContextType['outlet']>(null)
|
||||
|
||||
const append = useCallback<ContextType['append']>((id, component) => {
|
||||
const append = React.useCallback<ContextType['append']>((id, component) => {
|
||||
if (map.current[id]) return
|
||||
map.current[id] = <Fragment key={id}>{component}</Fragment>
|
||||
map.current[id] = <React.Fragment key={id}>{component}</React.Fragment>
|
||||
setOutlet(<>{Object.values(map.current)}</>)
|
||||
}, [])
|
||||
|
||||
const remove = useCallback<ContextType['remove']>(id => {
|
||||
const remove = React.useCallback<ContextType['remove']>(id => {
|
||||
delete map.current[id]
|
||||
setOutlet(<>{Object.values(map.current)}</>)
|
||||
}, [])
|
||||
|
||||
const contextValue = useMemo(
|
||||
const contextValue = React.useMemo(
|
||||
() => ({
|
||||
outlet,
|
||||
append,
|
||||
@@ -60,14 +50,14 @@ export function createPortalGroup_INTERNAL() {
|
||||
}
|
||||
|
||||
function Outlet() {
|
||||
const ctx = useContext(Context)
|
||||
const ctx = React.useContext(Context)
|
||||
return ctx.outlet
|
||||
}
|
||||
|
||||
function Portal({children}: React.PropsWithChildren<{}>) {
|
||||
const {append, remove} = useContext(Context)
|
||||
const id = useId()
|
||||
useEffect(() => {
|
||||
const {append, remove} = React.useContext(Context)
|
||||
const id = React.useId()
|
||||
React.useEffect(() => {
|
||||
append(id, children as Component)
|
||||
return () => remove(id)
|
||||
}, [id, children, append, remove])
|
||||
|
||||
+7
-6
@@ -1,4 +1,4 @@
|
||||
import {createContext, useContext, useEffect, useMemo, useState} from 'react'
|
||||
import React from 'react'
|
||||
|
||||
import {type BackgroundNotificationHandlerPreferences} from './ExpoBackgroundNotificationHandler.types'
|
||||
import {BackgroundNotificationHandler} from './ExpoBackgroundNotificationHandlerModule'
|
||||
@@ -11,10 +11,11 @@ interface BackgroundNotificationPreferencesContext {
|
||||
) => void
|
||||
}
|
||||
|
||||
const Context = createContext<BackgroundNotificationPreferencesContext>(
|
||||
const Context = React.createContext<BackgroundNotificationPreferencesContext>(
|
||||
{} as BackgroundNotificationPreferencesContext,
|
||||
)
|
||||
export const useBackgroundNotificationPreferences = () => useContext(Context)
|
||||
export const useBackgroundNotificationPreferences = () =>
|
||||
React.useContext(Context)
|
||||
|
||||
export function BackgroundNotificationPreferencesProvider({
|
||||
children,
|
||||
@@ -22,18 +23,18 @@ export function BackgroundNotificationPreferencesProvider({
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const [preferences, setPreferences] =
|
||||
useState<BackgroundNotificationHandlerPreferences>({
|
||||
React.useState<BackgroundNotificationHandlerPreferences>({
|
||||
playSoundChat: true,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
React.useEffect(() => {
|
||||
;(async () => {
|
||||
const prefs = await BackgroundNotificationHandler.getAllPrefsAsync()
|
||||
setPreferences(prefs)
|
||||
})()
|
||||
}, [])
|
||||
|
||||
const value = useMemo(
|
||||
const value = React.useMemo(
|
||||
() => ({
|
||||
preferences,
|
||||
setPref: async <
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import {createRef, PureComponent} from 'react'
|
||||
import React from 'react'
|
||||
import {requireNativeModule} from 'expo'
|
||||
import {requireNativeViewManager} from 'expo-modules-core'
|
||||
|
||||
import {type GifViewProps} from './GifView.types'
|
||||
|
||||
interface GifViewNativeRef {
|
||||
playAsync: () => Promise<void>
|
||||
pauseAsync: () => Promise<void>
|
||||
toggleAsync: () => Promise<void>
|
||||
}
|
||||
|
||||
const NativeModule: {
|
||||
prefetchAsync: (sources: string[]) => Promise<void>
|
||||
} = requireNativeModule('ExpoBlueskyGifView')
|
||||
const NativeModule = requireNativeModule('ExpoBlueskyGifView')
|
||||
const NativeView: React.ComponentType<
|
||||
GifViewProps & {ref: React.RefObject<GifViewNativeRef | null>}
|
||||
GifViewProps & {ref: React.RefObject<any>}
|
||||
> = requireNativeViewManager('ExpoBlueskyGifView')
|
||||
|
||||
export class GifView extends PureComponent<GifViewProps> {
|
||||
private nativeRef: React.RefObject<GifViewNativeRef | null> = createRef()
|
||||
export class GifView extends React.PureComponent<GifViewProps> {
|
||||
// TODO native types, should all be the same as those in this class
|
||||
private nativeRef: React.RefObject<any> = React.createRef()
|
||||
|
||||
constructor(props: GifViewProps | Readonly<GifViewProps>) {
|
||||
super(props)
|
||||
@@ -29,15 +22,15 @@ export class GifView extends PureComponent<GifViewProps> {
|
||||
}
|
||||
|
||||
async playAsync(): Promise<void> {
|
||||
await this.nativeRef.current?.playAsync()
|
||||
await this.nativeRef.current.playAsync()
|
||||
}
|
||||
|
||||
async pauseAsync(): Promise<void> {
|
||||
await this.nativeRef.current?.pauseAsync()
|
||||
await this.nativeRef.current.pauseAsync()
|
||||
}
|
||||
|
||||
async toggleAsync(): Promise<void> {
|
||||
await this.nativeRef.current?.toggleAsync()
|
||||
await this.nativeRef.current.toggleAsync()
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import {createRef, PureComponent} from 'react'
|
||||
import {createRef, PureComponent, type RefObject} from 'react'
|
||||
import {StyleSheet} from 'react-native'
|
||||
|
||||
import {type GifViewProps} from './GifView.types'
|
||||
|
||||
export class GifView extends PureComponent<GifViewProps> {
|
||||
private readonly videoPlayerRef: React.RefObject<HTMLVideoElement | null> =
|
||||
createRef()
|
||||
private readonly videoPlayerRef: RefObject<HTMLMediaElement> = createRef()
|
||||
private isLoaded = false
|
||||
|
||||
constructor(props: GifViewProps | Readonly<GifViewProps>) {
|
||||
@@ -19,9 +18,9 @@ export class GifView extends PureComponent<GifViewProps> {
|
||||
componentDidUpdate(prevProps: Readonly<GifViewProps>) {
|
||||
if (prevProps.autoplay !== this.props.autoplay) {
|
||||
if (this.props.autoplay) {
|
||||
void this.playAsync()
|
||||
this.playAsync()
|
||||
} else {
|
||||
void this.pauseAsync()
|
||||
this.pauseAsync()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +29,6 @@ export class GifView extends PureComponent<GifViewProps> {
|
||||
document.removeEventListener('visibilitychange', this.onVisibilityChange)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
static async prefetchAsync(_: string[]): Promise<void> {
|
||||
console.warn('prefetchAsync is not supported on web')
|
||||
}
|
||||
@@ -83,7 +81,6 @@ export class GifView extends PureComponent<GifViewProps> {
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
async pauseAsync(): Promise<void> {
|
||||
this.videoPlayerRef.current?.pause()
|
||||
}
|
||||
@@ -105,12 +102,12 @@ export class GifView extends PureComponent<GifViewProps> {
|
||||
// When `<source>` children are present, omit `src` so the browser
|
||||
// walks the source list and picks via canPlayType.
|
||||
src={useSources ? undefined : source}
|
||||
autoPlay={autoplay ? true : undefined}
|
||||
autoPlay={autoplay ? 'autoplay' : undefined}
|
||||
preload={autoplay ? 'auto' : undefined}
|
||||
playsInline={true}
|
||||
loop={true}
|
||||
muted={true}
|
||||
style={StyleSheet.flatten(style) as React.CSSProperties}
|
||||
loop="loop"
|
||||
muted="muted"
|
||||
style={StyleSheet.flatten(style)}
|
||||
onCanPlay={this.onLoad}
|
||||
onPlay={this.firePlayerStateChangeEvent}
|
||||
onPause={this.firePlayerStateChangeEvent}
|
||||
|
||||
@@ -10,7 +10,6 @@ This module consolidates several native features into a single Expo module:
|
||||
- **Referrer**: Tracking how users arrive at the app (web referrers, app referrers, Google Play install referrer)
|
||||
- **SharedPrefs**: Shared preferences storage using native platform APIs (UserDefaults on iOS, SharedPreferences on Android)
|
||||
- **VisibilityView**: A native view component that tracks which view is currently visible on screen
|
||||
- **NotificationSettings**: iOS handler that routes the system "notification settings" intent into the app
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -124,24 +123,9 @@ This is useful for features like video autoplay, where you want to know which vi
|
||||
- Android: Full support using View position tracking
|
||||
- Web: Passthrough component (renders children without tracking)
|
||||
|
||||
### NotificationSettings
|
||||
## Architecture
|
||||
|
||||
iOS only. Has no JavaScript surface - it is a pure native side effect registered
|
||||
at app launch.
|
||||
|
||||
When push permissions are requested with `provideAppNotificationSettings: true`,
|
||||
iOS adds an in-app notification settings button to the system Settings screen for
|
||||
Bluesky. Tapping it launches the app and triggers
|
||||
`userNotificationCenter(_:openSettingsFor:)`. expo-notifications owns the
|
||||
`UNUserNotificationCenter` delegate and fans this callback out to registered
|
||||
`NotificationDelegate`s. This module registers one and converts the callback into
|
||||
a `bluesky://settings/notifications` deep link, which the app's existing linking
|
||||
config routes to the notification settings screen.
|
||||
|
||||
**Platform Support:**
|
||||
- iOS: Full support
|
||||
- Android: Not applicable (Android opens the system notification settings directly)
|
||||
- Web: Not applicable
|
||||
### TypeScript Layer
|
||||
|
||||
The module uses platform-specific file extensions to provide appropriate implementations:
|
||||
|
||||
@@ -186,9 +170,7 @@ The module uses platform-specific file extensions to provide appropriate impleme
|
||||
|
||||
### Expo Module Config
|
||||
|
||||
The module is registered in `expo-module.config.json`. The PlatformInfo,
|
||||
Referrer, SharedPrefs, and VisibilityView sub-modules are registered for both iOS
|
||||
and Android; NotificationSettings is iOS only.
|
||||
The module is registered in `expo-module.config.json` with all four sub-modules for both iOS and Android.
|
||||
|
||||
### iOS
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
"ExpoBlueskySharedPrefsModule",
|
||||
"ExpoBlueskyReferrerModule",
|
||||
"ExpoBlueskyVisibilityViewModule",
|
||||
"ExpoPlatformInfoModule",
|
||||
"ExpoBlueskyNotificationSettingsModule"
|
||||
"ExpoPlatformInfoModule"
|
||||
]
|
||||
},
|
||||
"android": {
|
||||
|
||||
@@ -10,7 +10,6 @@ Pod::Spec.new do |s|
|
||||
s.static_framework = true
|
||||
|
||||
s.dependency 'ExpoModulesCore'
|
||||
s.dependency 'EXNotifications'
|
||||
|
||||
# Swift/Objective-C compatibility
|
||||
s.pod_target_xcconfig = {
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
import EXNotifications
|
||||
import ExpoModulesCore
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
|
||||
/*
|
||||
* When we request push notification permissions with
|
||||
* `provideAppNotificationSettings: true`, iOS adds an in-app notification
|
||||
* settings button to the system Settings screen for Bluesky (and may surface
|
||||
* it elsewhere, e.g. from a delivered notification). Tapping it launches the
|
||||
* app and calls `userNotificationCenter(_:openSettingsFor:)`.
|
||||
*
|
||||
* expo-notifications owns the `UNUserNotificationCenter` delegate via its
|
||||
* `NotificationCenterManager`, which fans that callback out to any registered
|
||||
* `NotificationDelegate` through `openSettings(_:)`. We register here and turn
|
||||
* the callback into a `bluesky://settings/notifications` deep link so the app's
|
||||
* existing linking config routes the user to the notification settings screen.
|
||||
*/
|
||||
public class ExpoBlueskyNotificationSettingsModule: Module, NotificationDelegate {
|
||||
public func definition() -> ModuleDefinition {
|
||||
Name("ExpoBlueskyNotificationSettings")
|
||||
|
||||
OnCreate {
|
||||
NotificationCenterManager.shared.addDelegate(self)
|
||||
}
|
||||
|
||||
OnDestroy {
|
||||
NotificationCenterManager.shared.removeDelegate(self)
|
||||
}
|
||||
}
|
||||
|
||||
public func openSettings(_ notification: UNNotification?) {
|
||||
guard let url = URL(string: "bluesky://settings/notifications") else {
|
||||
return
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useCallback} from 'react'
|
||||
import React from 'react'
|
||||
import {type StyleProp, type ViewStyle} from 'react-native'
|
||||
import {requireNativeModule, requireNativeViewManager} from 'expo-modules-core'
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function VisibilityView({
|
||||
onChangeStatus: onChangeStatusOuter,
|
||||
enabled,
|
||||
}: VisibilityViewProps) {
|
||||
const onChangeStatus = useCallback(
|
||||
const onChangeStatus = React.useCallback(
|
||||
(e: {nativeEvent: {isActive: boolean}}) => {
|
||||
onChangeStatusOuter(e.nativeEvent.isActive)
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type React from 'react'
|
||||
export interface VisibilityViewProps {
|
||||
children: React.ReactNode
|
||||
onChangeStatus: (isActive: boolean) => void
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
group = 'expo.modules.blueskyvideocompress'
|
||||
version = '1.0.0'
|
||||
|
||||
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
||||
apply from: expoModulesCorePlugin
|
||||
applyKotlinExpoModulesCorePlugin()
|
||||
useCoreDependencies()
|
||||
useExpoPublishing()
|
||||
|
||||
buildscript {
|
||||
ext.safeExtGet = { prop, fallback ->
|
||||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
||||
|
||||
namespace "expo.modules.blueskyvideocompress"
|
||||
defaultConfig {
|
||||
minSdkVersion safeExtGet("minSdkVersion", 21)
|
||||
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
||||
versionCode 1
|
||||
versionName "1.0.0"
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import android.media.MediaCodecInfo
|
||||
import android.media.MediaCodecList
|
||||
import android.media.MediaFormat
|
||||
import android.os.Build
|
||||
|
||||
object CodecSelector {
|
||||
// Source: https://github.com/numandev1/react-native-compressor/blob/f949b0868055178e7c8753e05202f784b1bcd589/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/compressor/Compressor.kt#L500
|
||||
private val AVC_DENYLIST = setOf(
|
||||
"c2.qti.avc.encoder"
|
||||
)
|
||||
|
||||
private val SOFTWARE_PREFIXES = listOf(
|
||||
"OMX.google.",
|
||||
"c2.android.",
|
||||
"c2.google."
|
||||
)
|
||||
|
||||
data class EncoderInfo(
|
||||
val name: String,
|
||||
val mime: String,
|
||||
val isHardware: Boolean
|
||||
)
|
||||
|
||||
fun findEncoder(mime: String, requireHardware: Boolean): EncoderInfo? {
|
||||
val codecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
|
||||
val candidates = codecList.codecInfos
|
||||
.filter { it.isEncoder }
|
||||
.filter { it.supportedTypes.any { t -> t.equals(mime, ignoreCase = true) } }
|
||||
.filter { !it.name.contains("secure", ignoreCase = true) }
|
||||
.filter { !(mime == MediaFormat.MIMETYPE_VIDEO_AVC && AVC_DENYLIST.contains(it.name)) }
|
||||
|
||||
val hardware = candidates.filter { isHardware(it) }
|
||||
val selected = if (requireHardware) {
|
||||
hardware.firstOrNull()
|
||||
} else {
|
||||
hardware.firstOrNull() ?: candidates.firstOrNull()
|
||||
}
|
||||
selected ?: return null
|
||||
return EncoderInfo(
|
||||
name = selected.name,
|
||||
mime = mime,
|
||||
isHardware = isHardware(selected)
|
||||
)
|
||||
}
|
||||
|
||||
private fun isHardware(info: MediaCodecInfo): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
info.isHardwareAccelerated
|
||||
} else {
|
||||
SOFTWARE_PREFIXES.none { info.name.startsWith(it, ignoreCase = true) }
|
||||
}
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import expo.modules.kotlin.modules.Module
|
||||
import expo.modules.kotlin.modules.ModuleDefinition
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class ExpoBlueskyVideoCompressModule : Module() {
|
||||
private val activeCompressors = ConcurrentHashMap<Int, VideoCompressor>()
|
||||
|
||||
override fun definition() = ModuleDefinition {
|
||||
Name("ExpoBlueskyVideoCompress")
|
||||
|
||||
Events("onProgress")
|
||||
|
||||
AsyncFunction("probe") { uri: String ->
|
||||
val context = appContext.reactContext
|
||||
?: throw Error("React context is null")
|
||||
return@AsyncFunction VideoProber.probe(context, uri)
|
||||
}
|
||||
|
||||
AsyncFunction("compress") { uri: String, options: Map<String, Any?> ->
|
||||
val context = appContext.reactContext
|
||||
?: throw Error("React context is null")
|
||||
val targetBitrate = (options["targetBitrate"] as? Number)?.toInt() ?: 0
|
||||
val maxSize = (options["maxSize"] as? Number)?.toInt() ?: 1920
|
||||
val codecPref = (options["codec"] as? String) ?: "auto"
|
||||
val frameRateCap = ((options["frameRateCap"] as? Number)?.toInt() ?: 30).coerceAtLeast(1)
|
||||
val jobId = (options["jobId"] as? Number)?.toInt() ?: 0
|
||||
|
||||
val compressor = VideoCompressor(
|
||||
context = context,
|
||||
uriString = uri,
|
||||
targetBitrate = targetBitrate,
|
||||
maxSize = maxSize,
|
||||
codecPref = codecPref,
|
||||
frameRateCap = frameRateCap,
|
||||
jobId = jobId,
|
||||
onProgress = { id, progress ->
|
||||
sendEvent("onProgress", mapOf(
|
||||
"id" to id,
|
||||
"progress" to progress
|
||||
))
|
||||
}
|
||||
)
|
||||
|
||||
activeCompressors[jobId] = compressor
|
||||
|
||||
try {
|
||||
val result = compressor.compress()
|
||||
activeCompressors.remove(jobId)
|
||||
return@AsyncFunction result
|
||||
} catch (e: Exception) {
|
||||
activeCompressors.remove(jobId)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
Function("cancel") { jobId: Int ->
|
||||
activeCompressors.remove(jobId)?.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import android.opengl.EGL14
|
||||
import android.opengl.EGLConfig
|
||||
import android.opengl.EGLContext
|
||||
import android.opengl.EGLDisplay
|
||||
import android.opengl.EGLExt
|
||||
import android.opengl.EGLSurface
|
||||
import android.view.Surface
|
||||
|
||||
class InputSurface(private val surface: Surface) {
|
||||
private var eglDisplay: EGLDisplay = EGL14.EGL_NO_DISPLAY
|
||||
private var eglContext: EGLContext = EGL14.EGL_NO_CONTEXT
|
||||
private var eglSurface: EGLSurface = EGL14.EGL_NO_SURFACE
|
||||
|
||||
init {
|
||||
eglSetup()
|
||||
}
|
||||
|
||||
private fun eglSetup() {
|
||||
eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY)
|
||||
if (eglDisplay === EGL14.EGL_NO_DISPLAY) {
|
||||
throw RuntimeException("unable to get EGL14 display")
|
||||
}
|
||||
|
||||
val version = IntArray(2)
|
||||
if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) {
|
||||
throw RuntimeException("unable to initialize EGL14")
|
||||
}
|
||||
|
||||
val attribList = intArrayOf(
|
||||
EGL14.EGL_RED_SIZE, 8,
|
||||
EGL14.EGL_GREEN_SIZE, 8,
|
||||
EGL14.EGL_BLUE_SIZE, 8,
|
||||
EGL14.EGL_ALPHA_SIZE, 8,
|
||||
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
|
||||
EGL14.EGL_SURFACE_TYPE, EGL14.EGL_WINDOW_BIT,
|
||||
EGL14.EGL_NONE
|
||||
)
|
||||
val configs = arrayOfNulls<EGLConfig>(1)
|
||||
val numConfigs = IntArray(1)
|
||||
EGL14.eglChooseConfig(eglDisplay, attribList, 0, configs, 0, 1, numConfigs, 0)
|
||||
checkEglError("eglChooseConfig")
|
||||
|
||||
val contextAttribs = intArrayOf(
|
||||
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL14.EGL_NONE
|
||||
)
|
||||
eglContext = EGL14.eglCreateContext(
|
||||
eglDisplay, configs[0], EGL14.EGL_NO_CONTEXT, contextAttribs, 0
|
||||
)
|
||||
checkEglError("eglCreateContext")
|
||||
|
||||
val surfaceAttribs = intArrayOf(EGL14.EGL_NONE)
|
||||
eglSurface = EGL14.eglCreateWindowSurface(
|
||||
eglDisplay, configs[0], surface, surfaceAttribs, 0
|
||||
)
|
||||
checkEglError("eglCreateWindowSurface")
|
||||
}
|
||||
|
||||
fun makeCurrent() {
|
||||
EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)
|
||||
checkEglError("eglMakeCurrent")
|
||||
}
|
||||
|
||||
fun swapBuffers(): Boolean {
|
||||
return EGL14.eglSwapBuffers(eglDisplay, eglSurface)
|
||||
}
|
||||
|
||||
fun setPresentationTime(nsecs: Long) {
|
||||
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, nsecs)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
if (eglDisplay !== EGL14.EGL_NO_DISPLAY) {
|
||||
EGL14.eglMakeCurrent(
|
||||
eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT
|
||||
)
|
||||
EGL14.eglDestroySurface(eglDisplay, eglSurface)
|
||||
EGL14.eglDestroyContext(eglDisplay, eglContext)
|
||||
EGL14.eglReleaseThread()
|
||||
EGL14.eglTerminate(eglDisplay)
|
||||
}
|
||||
surface.release()
|
||||
eglDisplay = EGL14.EGL_NO_DISPLAY
|
||||
eglContext = EGL14.EGL_NO_CONTEXT
|
||||
eglSurface = EGL14.EGL_NO_SURFACE
|
||||
}
|
||||
|
||||
private fun checkEglError(msg: String) {
|
||||
val error = EGL14.eglGetError()
|
||||
if (error != EGL14.EGL_SUCCESS) {
|
||||
throw RuntimeException("$msg: EGL error: 0x${Integer.toHexString(error)}")
|
||||
}
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import android.graphics.SurfaceTexture
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.view.Surface
|
||||
|
||||
class OutputSurface : SurfaceTexture.OnFrameAvailableListener {
|
||||
private val renderer = TextureRenderer()
|
||||
private var surfaceTexture: SurfaceTexture? = null
|
||||
private val stMatrix = FloatArray(16)
|
||||
private val callbackThread = HandlerThread("OutputSurfaceCallbacks")
|
||||
val surface: Surface
|
||||
|
||||
@Volatile
|
||||
private var frameAvailable = false
|
||||
private val frameSyncObject = Object()
|
||||
|
||||
init {
|
||||
renderer.surfaceCreated()
|
||||
callbackThread.start()
|
||||
val handler = Handler(callbackThread.looper)
|
||||
surfaceTexture = SurfaceTexture(renderer.getTextureId()).also {
|
||||
it.setOnFrameAvailableListener(this, handler)
|
||||
}
|
||||
surface = Surface(surfaceTexture)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
surface.release()
|
||||
surfaceTexture?.release()
|
||||
surfaceTexture = null
|
||||
callbackThread.quitSafely()
|
||||
}
|
||||
|
||||
fun awaitNewImage() {
|
||||
val timeoutMs = 2500L
|
||||
synchronized(frameSyncObject) {
|
||||
while (!frameAvailable) {
|
||||
frameSyncObject.wait(timeoutMs)
|
||||
if (!frameAvailable) {
|
||||
throw RuntimeException("Surface frame wait timed out")
|
||||
}
|
||||
}
|
||||
frameAvailable = false
|
||||
}
|
||||
surfaceTexture!!.updateTexImage()
|
||||
}
|
||||
|
||||
fun drawImage() {
|
||||
surfaceTexture!!.getTransformMatrix(stMatrix)
|
||||
renderer.drawFrame(stMatrix)
|
||||
}
|
||||
|
||||
override fun onFrameAvailable(st: SurfaceTexture) {
|
||||
synchronized(frameSyncObject) {
|
||||
frameAvailable = true
|
||||
frameSyncObject.notifyAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
-156
@@ -1,156 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import android.opengl.GLES11Ext
|
||||
import android.opengl.GLES20
|
||||
import android.opengl.Matrix
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.FloatBuffer
|
||||
|
||||
class TextureRenderer {
|
||||
companion object {
|
||||
private const val FLOAT_SIZE_BYTES = 4
|
||||
private const val STRIDE_BYTES = 5 * FLOAT_SIZE_BYTES
|
||||
private const val POS_OFFSET = 0
|
||||
private const val UV_OFFSET = 3
|
||||
|
||||
private val VERTICES = floatArrayOf(
|
||||
-1.0f, -1.0f, 0f, 0f, 0f,
|
||||
1.0f, -1.0f, 0f, 1f, 0f,
|
||||
-1.0f, 1.0f, 0f, 0f, 1f,
|
||||
1.0f, 1.0f, 0f, 1f, 1f,
|
||||
)
|
||||
|
||||
private const val VERTEX_SHADER = """
|
||||
uniform mat4 uMVPMatrix;
|
||||
uniform mat4 uSTMatrix;
|
||||
attribute vec4 aPosition;
|
||||
attribute vec4 aTextureCoord;
|
||||
varying vec2 vTextureCoord;
|
||||
void main() {
|
||||
gl_Position = uMVPMatrix * aPosition;
|
||||
vTextureCoord = (uSTMatrix * aTextureCoord).xy;
|
||||
}
|
||||
"""
|
||||
|
||||
private const val FRAGMENT_SHADER = """
|
||||
#extension GL_OES_EGL_image_external : require
|
||||
precision mediump float;
|
||||
varying vec2 vTextureCoord;
|
||||
uniform samplerExternalOES sTexture;
|
||||
void main() {
|
||||
gl_FragColor = texture2D(sTexture, vTextureCoord);
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
private val vertices: FloatBuffer =
|
||||
ByteBuffer.allocateDirect(VERTICES.size * FLOAT_SIZE_BYTES)
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.asFloatBuffer()
|
||||
.apply { put(VERTICES); position(0) }
|
||||
|
||||
private val mvpMatrix = FloatArray(16)
|
||||
private var program = 0
|
||||
private var textureId = -1
|
||||
private var uMVPMatrixHandle = 0
|
||||
private var uSTMatrixHandle = 0
|
||||
private var aPositionHandle = 0
|
||||
private var aTextureCoordHandle = 0
|
||||
|
||||
init {
|
||||
Matrix.setIdentityM(mvpMatrix, 0)
|
||||
}
|
||||
|
||||
fun getTextureId(): Int = textureId
|
||||
|
||||
fun surfaceCreated() {
|
||||
program = createProgram(VERTEX_SHADER, FRAGMENT_SHADER)
|
||||
|
||||
aPositionHandle = GLES20.glGetAttribLocation(program, "aPosition")
|
||||
aTextureCoordHandle = GLES20.glGetAttribLocation(program, "aTextureCoord")
|
||||
uMVPMatrixHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix")
|
||||
uSTMatrixHandle = GLES20.glGetUniformLocation(program, "uSTMatrix")
|
||||
|
||||
val textures = IntArray(1)
|
||||
GLES20.glGenTextures(1, textures, 0)
|
||||
textureId = textures[0]
|
||||
|
||||
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId)
|
||||
GLES20.glTexParameterf(
|
||||
GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
|
||||
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR.toFloat()
|
||||
)
|
||||
GLES20.glTexParameterf(
|
||||
GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
|
||||
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR.toFloat()
|
||||
)
|
||||
GLES20.glTexParameteri(
|
||||
GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
|
||||
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE
|
||||
)
|
||||
GLES20.glTexParameteri(
|
||||
GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
|
||||
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE
|
||||
)
|
||||
}
|
||||
|
||||
fun drawFrame(stMatrix: FloatArray) {
|
||||
GLES20.glClearColor(0f, 0f, 0f, 1f)
|
||||
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT or GLES20.GL_COLOR_BUFFER_BIT)
|
||||
|
||||
GLES20.glUseProgram(program)
|
||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0)
|
||||
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId)
|
||||
|
||||
vertices.position(POS_OFFSET)
|
||||
GLES20.glVertexAttribPointer(
|
||||
aPositionHandle, 3, GLES20.GL_FLOAT, false, STRIDE_BYTES, vertices
|
||||
)
|
||||
GLES20.glEnableVertexAttribArray(aPositionHandle)
|
||||
|
||||
vertices.position(UV_OFFSET)
|
||||
GLES20.glVertexAttribPointer(
|
||||
aTextureCoordHandle, 2, GLES20.GL_FLOAT, false, STRIDE_BYTES, vertices
|
||||
)
|
||||
GLES20.glEnableVertexAttribArray(aTextureCoordHandle)
|
||||
|
||||
GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, mvpMatrix, 0)
|
||||
GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, stMatrix, 0)
|
||||
|
||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4)
|
||||
GLES20.glDisableVertexAttribArray(aPositionHandle)
|
||||
GLES20.glDisableVertexAttribArray(aTextureCoordHandle)
|
||||
}
|
||||
|
||||
private fun createProgram(vertexSource: String, fragmentSource: String): Int {
|
||||
val vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource)
|
||||
val fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource)
|
||||
val program = GLES20.glCreateProgram()
|
||||
GLES20.glAttachShader(program, vertexShader)
|
||||
GLES20.glAttachShader(program, fragmentShader)
|
||||
GLES20.glLinkProgram(program)
|
||||
val linkStatus = IntArray(1)
|
||||
GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0)
|
||||
if (linkStatus[0] != GLES20.GL_TRUE) {
|
||||
val log = GLES20.glGetProgramInfoLog(program)
|
||||
GLES20.glDeleteProgram(program)
|
||||
throw RuntimeException("Could not link program: $log")
|
||||
}
|
||||
return program
|
||||
}
|
||||
|
||||
private fun loadShader(type: Int, source: String): Int {
|
||||
val shader = GLES20.glCreateShader(type)
|
||||
GLES20.glShaderSource(shader, source)
|
||||
GLES20.glCompileShader(shader)
|
||||
val compiled = IntArray(1)
|
||||
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0)
|
||||
if (compiled[0] == 0) {
|
||||
val log = GLES20.glGetShaderInfoLog(shader)
|
||||
GLES20.glDeleteShader(shader)
|
||||
throw RuntimeException("Could not compile shader $type: $log")
|
||||
}
|
||||
return shader
|
||||
}
|
||||
}
|
||||
-582
@@ -1,582 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaCodec
|
||||
import android.media.MediaCodecInfo
|
||||
import android.media.MediaExtractor
|
||||
import android.media.MediaFormat
|
||||
import android.media.MediaMuxer
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.UUID
|
||||
|
||||
class VideoCompressor(
|
||||
private val context: Context,
|
||||
private val uriString: String,
|
||||
private val targetBitrate: Int,
|
||||
private val maxSize: Int,
|
||||
private val codecPref: String,
|
||||
private val frameRateCap: Int,
|
||||
private val jobId: Int,
|
||||
private val onProgress: (Int, Double) -> Unit
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "BskyVideoCompress"
|
||||
private const val TIMEOUT_DEQUEUE = 100L
|
||||
private const val I_FRAME_INTERVAL = 3
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var isCancelled = false
|
||||
|
||||
fun cancel() {
|
||||
isCancelled = true
|
||||
}
|
||||
|
||||
fun compress(): Map<String, Any> {
|
||||
// 'auto' targets h264 — server pipeline is HLS, which favors h264 (HEVC needs
|
||||
// fMP4 segments + commercial licensing). HEVC remains opt-in via codec: 'hevc'.
|
||||
val tryHevc = codecPref == "hevc"
|
||||
|
||||
if (tryHevc) {
|
||||
try {
|
||||
return doCompress(useHevc = true, allowSoftwareFallback = false)
|
||||
} catch (e: Exception) {
|
||||
if (codecPref == "hevc" || isCancelled) throw e
|
||||
Log.w(TAG, "HEVC encode failed, falling back to h264", e)
|
||||
}
|
||||
}
|
||||
return doCompress(useHevc = false, allowSoftwareFallback = true)
|
||||
}
|
||||
|
||||
private fun doCompress(useHevc: Boolean, allowSoftwareFallback: Boolean): Map<String, Any> {
|
||||
val mime = if (useHevc) MediaFormat.MIMETYPE_VIDEO_HEVC else MediaFormat.MIMETYPE_VIDEO_AVC
|
||||
val encoderInfo = CodecSelector.findEncoder(mime, requireHardware = !allowSoftwareFallback)
|
||||
?: throw RuntimeException("No encoder for $mime")
|
||||
|
||||
try {
|
||||
return runPipeline(encoderInfo, useHevc)
|
||||
} catch (e: Exception) {
|
||||
if (!allowSoftwareFallback || isCancelled || !encoderInfo.isHardware) throw e
|
||||
Log.w(TAG, "Hardware encoder ${encoderInfo.name} failed, trying software", e)
|
||||
val sw = CodecSelector.findEncoder(mime, requireHardware = false)
|
||||
?.takeIf { !it.isHardware }
|
||||
?: throw e
|
||||
return runPipeline(sw, useHevc)
|
||||
}
|
||||
}
|
||||
|
||||
private fun runPipeline(
|
||||
encoderInfo: CodecSelector.EncoderInfo,
|
||||
useHevc: Boolean
|
||||
): Map<String, Any> {
|
||||
val outputFile = File(context.cacheDir, "${UUID.randomUUID()}.mp4")
|
||||
|
||||
var extractor: MediaExtractor? = null
|
||||
var muxer: MediaMuxer? = null
|
||||
var encoder: MediaCodec? = null
|
||||
var decoder: MediaCodec? = null
|
||||
var inputSurface: InputSurface? = null
|
||||
var outputSurface: OutputSurface? = null
|
||||
var muxerStarted = false
|
||||
var outputDims = Pair(0, 0)
|
||||
var durationUs = 0L
|
||||
|
||||
try {
|
||||
val uri = Uri.parse(uriString)
|
||||
extractor = MediaExtractor()
|
||||
if (uriString.startsWith("content://") || uriString.startsWith("file://")) {
|
||||
extractor.setDataSource(context, uri, null)
|
||||
} else {
|
||||
extractor.setDataSource(uriString)
|
||||
}
|
||||
|
||||
var videoTrackIndex = -1
|
||||
var audioTrackIndex = -1
|
||||
var videoFormat: MediaFormat? = null
|
||||
var audioFormat: MediaFormat? = null
|
||||
|
||||
for (i in 0 until extractor.trackCount) {
|
||||
val format = extractor.getTrackFormat(i)
|
||||
val trackMime = format.getString(MediaFormat.KEY_MIME) ?: continue
|
||||
if (trackMime.startsWith("video/") && videoTrackIndex == -1) {
|
||||
videoTrackIndex = i
|
||||
videoFormat = format
|
||||
} else if (trackMime.startsWith("audio/") && audioTrackIndex == -1) {
|
||||
audioTrackIndex = i
|
||||
audioFormat = format
|
||||
}
|
||||
}
|
||||
|
||||
if (videoTrackIndex == -1 || videoFormat == null) {
|
||||
throw RuntimeException("No video track found")
|
||||
}
|
||||
|
||||
val sourceWidth = videoFormat.getInteger(MediaFormat.KEY_WIDTH)
|
||||
val sourceHeight = videoFormat.getInteger(MediaFormat.KEY_HEIGHT)
|
||||
val rotation = if (videoFormat.containsKey(MediaFormat.KEY_ROTATION)) {
|
||||
videoFormat.getInteger(MediaFormat.KEY_ROTATION)
|
||||
} else 0
|
||||
durationUs = if (videoFormat.containsKey(MediaFormat.KEY_DURATION)) {
|
||||
videoFormat.getLong(MediaFormat.KEY_DURATION)
|
||||
} else 0L
|
||||
val sourceFps = if (videoFormat.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
||||
videoFormat.getInteger(MediaFormat.KEY_FRAME_RATE)
|
||||
} else 30
|
||||
|
||||
outputDims = calculateOutputDims(sourceWidth, sourceHeight, rotation, maxSize)
|
||||
val shouldPassthroughAudio = audioFormat != null && canPassthroughAudio(audioFormat)
|
||||
val transcodedAudio: TranscodedAudio? = if (
|
||||
audioTrackIndex >= 0 && audioFormat != null && !shouldPassthroughAudio
|
||||
) {
|
||||
transcodeAudioToAAC(audioTrackIndex, audioFormat)
|
||||
} else null
|
||||
muxer = MediaMuxer(outputFile.absolutePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4)
|
||||
|
||||
val effectiveBitrate = if (targetBitrate > 0) {
|
||||
targetBitrate
|
||||
} else if (useHevc) 2_500_000 else 3_000_000
|
||||
|
||||
val encoderFormat = MediaFormat.createVideoFormat(
|
||||
encoderInfo.mime, outputDims.first, outputDims.second
|
||||
).apply {
|
||||
setInteger(
|
||||
MediaFormat.KEY_COLOR_FORMAT,
|
||||
MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface
|
||||
)
|
||||
setInteger(MediaFormat.KEY_BIT_RATE, effectiveBitrate)
|
||||
setInteger(
|
||||
MediaFormat.KEY_BITRATE_MODE,
|
||||
MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR
|
||||
)
|
||||
setInteger(MediaFormat.KEY_FRAME_RATE, frameRateCap)
|
||||
setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
setInteger(MediaFormat.KEY_COLOR_STANDARD, MediaFormat.COLOR_STANDARD_BT709)
|
||||
setInteger(MediaFormat.KEY_COLOR_TRANSFER, MediaFormat.COLOR_TRANSFER_SDR_VIDEO)
|
||||
setInteger(MediaFormat.KEY_COLOR_RANGE, MediaFormat.COLOR_RANGE_LIMITED)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
setInteger(MediaFormat.KEY_PRIORITY, 0)
|
||||
setInteger(MediaFormat.KEY_OPERATING_RATE, frameRateCap)
|
||||
if (useHevc) {
|
||||
setInteger(
|
||||
MediaFormat.KEY_PROFILE,
|
||||
MediaCodecInfo.CodecProfileLevel.HEVCProfileMain
|
||||
)
|
||||
} else {
|
||||
setInteger(
|
||||
MediaFormat.KEY_PROFILE,
|
||||
MediaCodecInfo.CodecProfileLevel.AVCProfileHigh
|
||||
)
|
||||
setInteger(
|
||||
MediaFormat.KEY_LEVEL,
|
||||
MediaCodecInfo.CodecProfileLevel.AVCLevel41
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
encoder = MediaCodec.createByCodecName(encoderInfo.name)
|
||||
encoder.configure(encoderFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE)
|
||||
val encoderInputSurface = encoder.createInputSurface()
|
||||
inputSurface = InputSurface(encoderInputSurface)
|
||||
inputSurface.makeCurrent()
|
||||
outputSurface = OutputSurface()
|
||||
encoder.start()
|
||||
|
||||
decoder = MediaCodec.createDecoderByType(
|
||||
videoFormat.getString(MediaFormat.KEY_MIME) ?: "video/avc"
|
||||
)
|
||||
// Ask the decoder to tone-map HDR (HLG/PQ) sources to SDR. Vendors may
|
||||
// ignore the hint, but where supported it produces correct BT.709 pixels
|
||||
// for the encoder rather than HDR pixels mislabeled as SDR.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
videoFormat.setInteger(
|
||||
MediaFormat.KEY_COLOR_TRANSFER_REQUEST,
|
||||
MediaFormat.COLOR_TRANSFER_SDR_VIDEO
|
||||
)
|
||||
}
|
||||
decoder.configure(videoFormat, outputSurface.surface, null, 0)
|
||||
decoder.start()
|
||||
extractor.selectTrack(videoTrackIndex)
|
||||
|
||||
val frameDropEnabled = sourceFps > frameRateCap
|
||||
val targetFrameIntervalUs = if (frameDropEnabled) 1_000_000L / frameRateCap else 0L
|
||||
var nextTargetPtsUs = 0L
|
||||
|
||||
var muxerVideoTrack = -1
|
||||
var muxerAudioTrack = -1
|
||||
|
||||
val bufferInfo = MediaCodec.BufferInfo()
|
||||
var inputDone = false
|
||||
var decoderDone = false
|
||||
var outputDone = false
|
||||
var lastProgressMs = 0L
|
||||
|
||||
while (!outputDone && !isCancelled) {
|
||||
if (!inputDone) {
|
||||
val idx = decoder.dequeueInputBuffer(TIMEOUT_DEQUEUE)
|
||||
if (idx >= 0) {
|
||||
val buf = decoder.getInputBuffer(idx)
|
||||
if (buf != null) {
|
||||
val sz = extractor.readSampleData(buf, 0)
|
||||
if (sz < 0) {
|
||||
decoder.queueInputBuffer(
|
||||
idx, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM
|
||||
)
|
||||
inputDone = true
|
||||
} else {
|
||||
decoder.queueInputBuffer(idx, 0, sz, extractor.sampleTime, 0)
|
||||
extractor.advance()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!decoderDone) {
|
||||
val status = decoder.dequeueOutputBuffer(bufferInfo, TIMEOUT_DEQUEUE)
|
||||
if (status >= 0) {
|
||||
val isEos = bufferInfo.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0
|
||||
val shouldRender = if (isEos) {
|
||||
false
|
||||
} else if (frameDropEnabled) {
|
||||
if (bufferInfo.presentationTimeUs >= nextTargetPtsUs) {
|
||||
nextTargetPtsUs = bufferInfo.presentationTimeUs + targetFrameIntervalUs
|
||||
true
|
||||
} else false
|
||||
} else true
|
||||
decoder.releaseOutputBuffer(status, shouldRender)
|
||||
if (shouldRender) {
|
||||
outputSurface.awaitNewImage()
|
||||
outputSurface.drawImage()
|
||||
inputSurface.setPresentationTime(bufferInfo.presentationTimeUs * 1000)
|
||||
inputSurface.swapBuffers()
|
||||
}
|
||||
if (isEos) {
|
||||
encoder.signalEndOfInputStream()
|
||||
decoderDone = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var encoderDrained = false
|
||||
while (!outputDone && !isCancelled && !encoderDrained) {
|
||||
val encIdx = encoder.dequeueOutputBuffer(bufferInfo, 0)
|
||||
when {
|
||||
encIdx == MediaCodec.INFO_TRY_AGAIN_LATER -> encoderDrained = true
|
||||
encIdx == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED -> {
|
||||
if (!muxerStarted) {
|
||||
muxerVideoTrack = muxer.addTrack(encoder.outputFormat)
|
||||
if (audioTrackIndex >= 0 && audioFormat != null) {
|
||||
if (shouldPassthroughAudio) {
|
||||
muxerAudioTrack = muxer.addTrack(audioFormat)
|
||||
} else if (transcodedAudio != null) {
|
||||
muxerAudioTrack = muxer.addTrack(transcodedAudio.outputFormat)
|
||||
}
|
||||
}
|
||||
muxer.start()
|
||||
muxerStarted = true
|
||||
}
|
||||
}
|
||||
encIdx >= 0 -> {
|
||||
val data = encoder.getOutputBuffer(encIdx)
|
||||
if (bufferInfo.flags and MediaCodec.BUFFER_FLAG_CODEC_CONFIG != 0) {
|
||||
bufferInfo.size = 0
|
||||
}
|
||||
if (data != null && bufferInfo.size > 0 && muxerStarted) {
|
||||
muxer.writeSampleData(muxerVideoTrack, data, bufferInfo)
|
||||
}
|
||||
val isEos = bufferInfo.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0
|
||||
encoder.releaseOutputBuffer(encIdx, false)
|
||||
if (isEos) {
|
||||
outputDone = true
|
||||
} else if (durationUs > 0) {
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastProgressMs >= 100) {
|
||||
lastProgressMs = now
|
||||
val p = (bufferInfo.presentationTimeUs.toDouble() / durationUs)
|
||||
.coerceIn(0.0, 1.0)
|
||||
onProgress(jobId, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (audioTrackIndex >= 0 && muxerAudioTrack >= 0 && muxerStarted && !isCancelled) {
|
||||
if (shouldPassthroughAudio) {
|
||||
passthroughAudio(audioTrackIndex, muxer, muxerAudioTrack)
|
||||
} else if (transcodedAudio != null) {
|
||||
writeTranscodedAudio(transcodedAudio.samples, muxer, muxerAudioTrack)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
try { decoder?.stop() } catch (_: Exception) {}
|
||||
try { decoder?.release() } catch (_: Exception) {}
|
||||
try { encoder?.stop() } catch (_: Exception) {}
|
||||
try { encoder?.release() } catch (_: Exception) {}
|
||||
try { outputSurface?.release() } catch (_: Exception) {}
|
||||
try { inputSurface?.release() } catch (_: Exception) {}
|
||||
try { extractor?.release() } catch (_: Exception) {}
|
||||
try {
|
||||
if (muxerStarted) muxer?.stop()
|
||||
muxer?.release()
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
|
||||
if (isCancelled) {
|
||||
outputFile.delete()
|
||||
throw RuntimeException("Compression cancelled")
|
||||
}
|
||||
|
||||
onProgress(jobId, 1.0)
|
||||
val durationSeconds = durationUs / 1_000_000.0
|
||||
|
||||
return mapOf(
|
||||
"uri" to "file://${outputFile.absolutePath}",
|
||||
"size" to outputFile.length(),
|
||||
"mimeType" to "video/mp4",
|
||||
"width" to outputDims.first,
|
||||
"height" to outputDims.second,
|
||||
"duration" to durationSeconds,
|
||||
"codec" to if (useHevc) "hevc" else "h264"
|
||||
)
|
||||
}
|
||||
|
||||
private fun passthroughAudio(audioTrackIndex: Int, muxer: MediaMuxer, muxerAudioTrack: Int) {
|
||||
val audioExtractor = MediaExtractor()
|
||||
if (uriString.startsWith("content://") || uriString.startsWith("file://")) {
|
||||
audioExtractor.setDataSource(context, Uri.parse(uriString), null)
|
||||
} else {
|
||||
audioExtractor.setDataSource(uriString)
|
||||
}
|
||||
audioExtractor.selectTrack(audioTrackIndex)
|
||||
audioExtractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC)
|
||||
|
||||
val buffer = ByteBuffer.allocate(256 * 1024)
|
||||
val info = MediaCodec.BufferInfo()
|
||||
try {
|
||||
while (!isCancelled) {
|
||||
val sz = audioExtractor.readSampleData(buffer, 0)
|
||||
if (sz < 0) break
|
||||
info.offset = 0
|
||||
info.size = sz
|
||||
info.presentationTimeUs = audioExtractor.sampleTime
|
||||
info.flags = audioExtractor.sampleFlags
|
||||
muxer.writeSampleData(muxerAudioTrack, buffer, info)
|
||||
audioExtractor.advance()
|
||||
}
|
||||
} finally {
|
||||
audioExtractor.release()
|
||||
}
|
||||
}
|
||||
|
||||
private fun canPassthroughAudio(format: MediaFormat): Boolean {
|
||||
val mime = format.getString(MediaFormat.KEY_MIME) ?: return false
|
||||
return mime == MediaFormat.MIMETYPE_AUDIO_AAC
|
||||
}
|
||||
|
||||
private data class TranscodedAudio(
|
||||
val outputFormat: MediaFormat,
|
||||
val samples: List<Sample>
|
||||
) {
|
||||
data class Sample(
|
||||
val bytes: ByteArray,
|
||||
val presentationTimeUs: Long,
|
||||
val flags: Int
|
||||
)
|
||||
}
|
||||
|
||||
// Re-encode non-AAC source audio (Opus, Vorbis, etc.) to AAC so the mp4 muxer
|
||||
// can take it. iOS always re-encodes to AAC; without this Android would drop
|
||||
// the audio track entirely.
|
||||
private fun transcodeAudioToAAC(
|
||||
audioTrackIndex: Int,
|
||||
sourceFormat: MediaFormat
|
||||
): TranscodedAudio? {
|
||||
val sourceMime = sourceFormat.getString(MediaFormat.KEY_MIME) ?: return null
|
||||
val sampleRate = if (sourceFormat.containsKey(MediaFormat.KEY_SAMPLE_RATE))
|
||||
sourceFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE) else 44100
|
||||
val channelCount = if (sourceFormat.containsKey(MediaFormat.KEY_CHANNEL_COUNT))
|
||||
sourceFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT).coerceIn(1, 2) else 2
|
||||
|
||||
val audioExtractor = MediaExtractor()
|
||||
if (uriString.startsWith("content://") || uriString.startsWith("file://")) {
|
||||
audioExtractor.setDataSource(context, Uri.parse(uriString), null)
|
||||
} else {
|
||||
audioExtractor.setDataSource(uriString)
|
||||
}
|
||||
audioExtractor.selectTrack(audioTrackIndex)
|
||||
|
||||
var decoder: MediaCodec? = null
|
||||
var encoder: MediaCodec? = null
|
||||
try {
|
||||
decoder = MediaCodec.createDecoderByType(sourceMime)
|
||||
decoder.configure(sourceFormat, null, null, 0)
|
||||
decoder.start()
|
||||
|
||||
val encoderFormat = MediaFormat.createAudioFormat(
|
||||
MediaFormat.MIMETYPE_AUDIO_AAC, sampleRate, channelCount
|
||||
).apply {
|
||||
setInteger(
|
||||
MediaFormat.KEY_AAC_PROFILE,
|
||||
MediaCodecInfo.CodecProfileLevel.AACObjectLC
|
||||
)
|
||||
setInteger(MediaFormat.KEY_BIT_RATE, 128_000)
|
||||
setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 256 * 1024)
|
||||
}
|
||||
encoder = MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_AUDIO_AAC)
|
||||
encoder.configure(encoderFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE)
|
||||
encoder.start()
|
||||
|
||||
val samples = mutableListOf<TranscodedAudio.Sample>()
|
||||
var outputFormat: MediaFormat? = null
|
||||
var inputDone = false
|
||||
var decoderDone = false
|
||||
var encoderInputSignalled = false
|
||||
var encoderDone = false
|
||||
val info = MediaCodec.BufferInfo()
|
||||
|
||||
while (!encoderDone && !isCancelled) {
|
||||
if (!inputDone) {
|
||||
val idx = decoder.dequeueInputBuffer(TIMEOUT_DEQUEUE)
|
||||
if (idx >= 0) {
|
||||
val buf = decoder.getInputBuffer(idx)
|
||||
if (buf != null) {
|
||||
val sz = audioExtractor.readSampleData(buf, 0)
|
||||
if (sz < 0) {
|
||||
decoder.queueInputBuffer(
|
||||
idx, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM
|
||||
)
|
||||
inputDone = true
|
||||
} else {
|
||||
decoder.queueInputBuffer(
|
||||
idx, 0, sz, audioExtractor.sampleTime, audioExtractor.sampleFlags
|
||||
)
|
||||
audioExtractor.advance()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!decoderDone) {
|
||||
val status = decoder.dequeueOutputBuffer(info, TIMEOUT_DEQUEUE)
|
||||
when {
|
||||
status == MediaCodec.INFO_TRY_AGAIN_LATER -> {}
|
||||
status == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED -> {}
|
||||
status >= 0 -> {
|
||||
val isEos = info.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0
|
||||
val data = decoder.getOutputBuffer(status)
|
||||
if (data != null && info.size > 0) {
|
||||
val encInIdx = encoder.dequeueInputBuffer(TIMEOUT_DEQUEUE)
|
||||
if (encInIdx >= 0) {
|
||||
val encInBuf = encoder.getInputBuffer(encInIdx)
|
||||
if (encInBuf != null) {
|
||||
encInBuf.clear()
|
||||
data.position(info.offset)
|
||||
data.limit(info.offset + info.size)
|
||||
encInBuf.put(data)
|
||||
encoder.queueInputBuffer(
|
||||
encInIdx, 0, info.size, info.presentationTimeUs, 0
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
decoder.releaseOutputBuffer(status, false)
|
||||
if (isEos) {
|
||||
if (!encoderInputSignalled) {
|
||||
val encInIdx = encoder.dequeueInputBuffer(TIMEOUT_DEQUEUE * 10)
|
||||
if (encInIdx >= 0) {
|
||||
encoder.queueInputBuffer(
|
||||
encInIdx, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM
|
||||
)
|
||||
encoderInputSignalled = true
|
||||
}
|
||||
}
|
||||
decoderDone = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val encOutIdx = encoder.dequeueOutputBuffer(info, TIMEOUT_DEQUEUE)
|
||||
when {
|
||||
encOutIdx == MediaCodec.INFO_TRY_AGAIN_LATER -> {}
|
||||
encOutIdx == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED -> {
|
||||
outputFormat = encoder.outputFormat
|
||||
}
|
||||
encOutIdx >= 0 -> {
|
||||
val data = encoder.getOutputBuffer(encOutIdx)
|
||||
val isEos = info.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0
|
||||
val isConfig = info.flags and MediaCodec.BUFFER_FLAG_CODEC_CONFIG != 0
|
||||
if (data != null && info.size > 0 && !isConfig) {
|
||||
val bytes = ByteArray(info.size)
|
||||
data.position(info.offset)
|
||||
data.get(bytes, 0, info.size)
|
||||
samples.add(
|
||||
TranscodedAudio.Sample(
|
||||
bytes = bytes,
|
||||
presentationTimeUs = info.presentationTimeUs,
|
||||
flags = info.flags and MediaCodec.BUFFER_FLAG_CODEC_CONFIG.inv()
|
||||
)
|
||||
)
|
||||
}
|
||||
encoder.releaseOutputBuffer(encOutIdx, false)
|
||||
if (isEos) encoderDone = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val fmt = outputFormat ?: return null
|
||||
return TranscodedAudio(fmt, samples)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Audio transcode failed; dropping audio", e)
|
||||
return null
|
||||
} finally {
|
||||
try { decoder?.stop() } catch (_: Exception) {}
|
||||
try { decoder?.release() } catch (_: Exception) {}
|
||||
try { encoder?.stop() } catch (_: Exception) {}
|
||||
try { encoder?.release() } catch (_: Exception) {}
|
||||
audioExtractor.release()
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeTranscodedAudio(
|
||||
samples: List<TranscodedAudio.Sample>,
|
||||
muxer: MediaMuxer,
|
||||
muxerAudioTrack: Int
|
||||
) {
|
||||
val info = MediaCodec.BufferInfo()
|
||||
for (sample in samples) {
|
||||
if (isCancelled) break
|
||||
val buffer = ByteBuffer.wrap(sample.bytes)
|
||||
info.offset = 0
|
||||
info.size = sample.bytes.size
|
||||
info.presentationTimeUs = sample.presentationTimeUs
|
||||
info.flags = sample.flags
|
||||
muxer.writeSampleData(muxerAudioTrack, buffer, info)
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateOutputDims(srcW: Int, srcH: Int, rotation: Int, maxSize: Int): Pair<Int, Int> {
|
||||
val isRotated = rotation == 90 || rotation == 270
|
||||
val displayW = if (isRotated) srcH else srcW
|
||||
val displayH = if (isRotated) srcW else srcH
|
||||
val scale: Float = when {
|
||||
displayW <= maxSize && displayH <= maxSize -> 1.0f
|
||||
displayW > displayH -> maxSize.toFloat() / displayW
|
||||
else -> maxSize.toFloat() / displayH
|
||||
}
|
||||
return Pair(
|
||||
roundToEven((displayW * scale).toInt()),
|
||||
roundToEven((displayH * scale).toInt())
|
||||
)
|
||||
}
|
||||
|
||||
private fun roundToEven(v: Int): Int = if (v % 2 == 0) v else v - 1
|
||||
}
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
package expo.modules.blueskyvideocompress
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaExtractor
|
||||
import android.media.MediaFormat
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
|
||||
object VideoProber {
|
||||
fun probe(context: Context, uriString: String): Map<String, Any> {
|
||||
val uri = Uri.parse(uriString)
|
||||
val retriever = MediaMetadataRetriever()
|
||||
|
||||
try {
|
||||
if (uriString.startsWith("content://") || uriString.startsWith("file://")) {
|
||||
retriever.setDataSource(context, uri)
|
||||
} else {
|
||||
retriever.setDataSource(uriString)
|
||||
}
|
||||
|
||||
val width = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)
|
||||
?.toIntOrNull() ?: 0
|
||||
val height = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)
|
||||
?.toIntOrNull() ?: 0
|
||||
val durationMs = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)
|
||||
?.toLongOrNull() ?: 0L
|
||||
val rotation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION)
|
||||
?.toIntOrNull() ?: 0
|
||||
val bitrate = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE)
|
||||
?.toIntOrNull() ?: 0
|
||||
val hasAudio = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_AUDIO)
|
||||
?.equals("yes") ?: false
|
||||
val frameRate = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CAPTURE_FRAMERATE)
|
||||
?.toFloatOrNull() ?: 0f
|
||||
|
||||
val fileSize = getFileSize(context, uriString)
|
||||
|
||||
val extractor = MediaExtractor()
|
||||
var codec = "unknown"
|
||||
var mimeType = "video/mp4"
|
||||
var extractedFrameRate = frameRate
|
||||
var isHDR = false
|
||||
|
||||
try {
|
||||
if (uriString.startsWith("content://") || uriString.startsWith("file://")) {
|
||||
extractor.setDataSource(context, uri, null)
|
||||
} else {
|
||||
extractor.setDataSource(uriString)
|
||||
}
|
||||
|
||||
for (i in 0 until extractor.trackCount) {
|
||||
val format = extractor.getTrackFormat(i)
|
||||
val mime = format.getString(MediaFormat.KEY_MIME)
|
||||
if (mime?.startsWith("video/") == true) {
|
||||
mimeType = mime
|
||||
codec = mime.removePrefix("video/")
|
||||
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
||||
extractedFrameRate = format.getInteger(MediaFormat.KEY_FRAME_RATE).toFloat()
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
|
||||
format.containsKey(MediaFormat.KEY_COLOR_TRANSFER)
|
||||
) {
|
||||
val transfer = format.getInteger(MediaFormat.KEY_COLOR_TRANSFER)
|
||||
isHDR = transfer == MediaFormat.COLOR_TRANSFER_HLG ||
|
||||
transfer == MediaFormat.COLOR_TRANSFER_ST2084
|
||||
}
|
||||
// Dolby Vision tracks use codec-specific mimes that aren't covered by
|
||||
// KEY_COLOR_TRANSFER on every device.
|
||||
if (mime.contains("dolby-vision", ignoreCase = true)) {
|
||||
isHDR = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
extractor.release()
|
||||
}
|
||||
|
||||
val durationSeconds = durationMs / 1000.0
|
||||
val effectiveBitrate = if (bitrate > 0) {
|
||||
bitrate
|
||||
} else if (durationSeconds > 0 && fileSize > 0) {
|
||||
(fileSize * 8 / durationSeconds).toInt()
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
return mapOf(
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
"duration" to durationSeconds,
|
||||
"bitrate" to effectiveBitrate,
|
||||
"fileSize" to fileSize,
|
||||
"mimeType" to mimeType,
|
||||
"codec" to codec,
|
||||
"hasAudio" to hasAudio,
|
||||
"frameRate" to extractedFrameRate.toDouble(),
|
||||
"rotation" to rotation,
|
||||
"isHDR" to isHDR
|
||||
)
|
||||
} finally {
|
||||
retriever.release()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFileSize(context: Context, uriString: String): Long {
|
||||
return try {
|
||||
if (uriString.startsWith("content://")) {
|
||||
context.contentResolver.openFileDescriptor(Uri.parse(uriString), "r")?.use {
|
||||
it.statSize
|
||||
} ?: 0L
|
||||
} else {
|
||||
val path = if (uriString.startsWith("file://")) {
|
||||
uriString.removePrefix("file://")
|
||||
} else {
|
||||
uriString
|
||||
}
|
||||
java.io.File(path).length()
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"platforms": ["ios", "android"],
|
||||
"ios": {
|
||||
"modules": ["ExpoBlueskyVideoCompressModule"]
|
||||
},
|
||||
"android": {
|
||||
"modules": ["expo.modules.blueskyvideocompress.ExpoBlueskyVideoCompressModule"]
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
import {type EventSubscription} from 'expo-modules-core'
|
||||
|
||||
import NativeModule from './src/ExpoBlueskyVideoCompressModule'
|
||||
import {
|
||||
type CodecPreference,
|
||||
type CompressCallbacks,
|
||||
type CompressOptions,
|
||||
type CompressResult,
|
||||
type VideoMetadata,
|
||||
} from './src/types'
|
||||
|
||||
export type {
|
||||
CodecPreference,
|
||||
CompressCallbacks,
|
||||
CompressOptions,
|
||||
CompressResult,
|
||||
VideoMetadata,
|
||||
}
|
||||
|
||||
class AbortError extends Error {
|
||||
name = 'AbortError'
|
||||
constructor() {
|
||||
super('Aborted')
|
||||
}
|
||||
}
|
||||
|
||||
let jobIdCounter = 0
|
||||
|
||||
export function probe(uri: string): Promise<VideoMetadata> {
|
||||
return NativeModule.probe(uri)
|
||||
}
|
||||
|
||||
export function compress(
|
||||
uri: string,
|
||||
options: CompressOptions = {},
|
||||
callbacks?: CompressCallbacks,
|
||||
): Promise<CompressResult> {
|
||||
const jobId = ++jobIdCounter
|
||||
let subscription: EventSubscription | undefined
|
||||
|
||||
if (callbacks?.signal?.aborted) {
|
||||
return Promise.reject(new AbortError())
|
||||
}
|
||||
|
||||
const nativeOptions = {
|
||||
targetBitrate: options.targetBitrate ?? 0,
|
||||
maxSize: options.maxSize ?? 1920,
|
||||
codec: options.codec ?? 'auto',
|
||||
frameRateCap: options.frameRateCap ?? 30,
|
||||
jobId,
|
||||
}
|
||||
|
||||
return new Promise<CompressResult>((resolve, reject) => {
|
||||
if (callbacks?.onProgress) {
|
||||
subscription = NativeModule.addListener(
|
||||
'onProgress',
|
||||
(event: {id: number; progress: number}) => {
|
||||
if (event.id === jobId) {
|
||||
callbacks.onProgress!(event.progress)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
const abortHandler = () => {
|
||||
NativeModule.cancel(jobId)
|
||||
subscription?.remove()
|
||||
reject(new AbortError())
|
||||
}
|
||||
|
||||
if (callbacks?.signal) {
|
||||
callbacks.signal.addEventListener('abort', abortHandler, {once: true})
|
||||
}
|
||||
|
||||
NativeModule.compress(uri, nativeOptions)
|
||||
.then(result => {
|
||||
callbacks?.signal?.removeEventListener('abort', abortHandler)
|
||||
subscription?.remove()
|
||||
resolve(result)
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
callbacks?.signal?.removeEventListener('abort', abortHandler)
|
||||
subscription?.remove()
|
||||
reject(error instanceof Error ? error : new Error(String(error)))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import VideoToolbox
|
||||
|
||||
enum CodecCapability {
|
||||
static let isHardwareHEVCEncodeAvailable: Bool = {
|
||||
var encoderListCF: CFArray?
|
||||
let status = VTCopyVideoEncoderList(nil, &encoderListCF)
|
||||
guard status == noErr, let encoderList = encoderListCF as? [[String: Any]] else {
|
||||
return false
|
||||
}
|
||||
return encoderList.contains { encoder in
|
||||
guard let codecTypeValue = encoder[kVTVideoEncoderList_CodecType as String] as? Int,
|
||||
codecTypeValue == Int(kCMVideoCodecType_HEVC) else {
|
||||
return false
|
||||
}
|
||||
if let isHardware = encoder[kVTVideoEncoderList_IsHardwareAccelerated as String] as? Bool {
|
||||
return isHardware
|
||||
}
|
||||
return true
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'ExpoBlueskyVideoCompress'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'Hardware-accelerated video compression for Bluesky'
|
||||
s.description = 'Hardware-accelerated h264/HEVC video compression using AVAssetReader/Writer and VideoToolbox on iOS'
|
||||
s.author = ''
|
||||
s.homepage = 'https://github.com/bluesky-social/social-app'
|
||||
s.platforms = { :ios => '15.1' }
|
||||
s.source = { git: '' }
|
||||
s.static_framework = true
|
||||
|
||||
s.dependency 'ExpoModulesCore'
|
||||
|
||||
s.pod_target_xcconfig = {
|
||||
'DEFINES_MODULE' => 'YES',
|
||||
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
||||
}
|
||||
|
||||
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
|
||||
end
|
||||
@@ -1,74 +0,0 @@
|
||||
import AVFoundation
|
||||
import ExpoModulesCore
|
||||
|
||||
public class ExpoBlueskyVideoCompressModule: Module {
|
||||
private var activeCompressors: [Int: VideoCompressor] = [:]
|
||||
private let activeCompressorsLock = NSLock()
|
||||
|
||||
public func definition() -> ModuleDefinition {
|
||||
Name("ExpoBlueskyVideoCompress")
|
||||
|
||||
Events("onProgress")
|
||||
|
||||
AsyncFunction("probe") { (uri: String) -> [String: Any] in
|
||||
let url = URL(string: uri) ?? URL(fileURLWithPath: uri)
|
||||
return try await VideoProber.probe(url: url)
|
||||
}
|
||||
|
||||
AsyncFunction("compress") { (uri: String, options: [String: Any]) -> [String: Any] in
|
||||
let url = URL(string: uri) ?? URL(fileURLWithPath: uri)
|
||||
let targetBitrate = options["targetBitrate"] as? Int ?? 0
|
||||
let maxSize = options["maxSize"] as? Int ?? 1920
|
||||
let codecPref = options["codec"] as? String ?? "auto"
|
||||
let frameRateCap = max(1, options["frameRateCap"] as? Int ?? 30)
|
||||
let jobId = options["jobId"] as? Int ?? 0
|
||||
|
||||
let compressor = VideoCompressor(
|
||||
url: url,
|
||||
targetBitrate: targetBitrate,
|
||||
maxSize: maxSize,
|
||||
codecPref: codecPref,
|
||||
frameRateCap: frameRateCap,
|
||||
jobId: jobId,
|
||||
onProgress: { [weak self] id, progress in
|
||||
self?.sendEvent("onProgress", [
|
||||
"id": id,
|
||||
"progress": progress,
|
||||
])
|
||||
}
|
||||
)
|
||||
|
||||
self.setCompressor(jobId, compressor)
|
||||
|
||||
do {
|
||||
let result = try await compressor.compress()
|
||||
self.setCompressor(jobId, nil)
|
||||
return result
|
||||
} catch {
|
||||
self.setCompressor(jobId, nil)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
Function("cancel") { (jobId: Int) in
|
||||
self.cancelCompressor(jobId)
|
||||
}
|
||||
}
|
||||
|
||||
private func setCompressor(_ jobId: Int, _ compressor: VideoCompressor?) {
|
||||
activeCompressorsLock.lock()
|
||||
defer { activeCompressorsLock.unlock() }
|
||||
if let compressor = compressor {
|
||||
activeCompressors[jobId] = compressor
|
||||
} else {
|
||||
activeCompressors.removeValue(forKey: jobId)
|
||||
}
|
||||
}
|
||||
|
||||
private func cancelCompressor(_ jobId: Int) {
|
||||
activeCompressorsLock.lock()
|
||||
let compressor = activeCompressors.removeValue(forKey: jobId)
|
||||
activeCompressorsLock.unlock()
|
||||
compressor?.cancel()
|
||||
}
|
||||
}
|
||||
@@ -1,410 +0,0 @@
|
||||
import AVFoundation
|
||||
import VideoToolbox
|
||||
|
||||
class VideoCompressor {
|
||||
private let url: URL
|
||||
private let targetBitrate: Int
|
||||
private let maxSize: Int
|
||||
private let codecPref: String
|
||||
private let frameRateCap: Int
|
||||
private let jobId: Int
|
||||
private let onProgress: (Int, Double) -> Void
|
||||
private var isCancelled = false
|
||||
|
||||
init(
|
||||
url: URL,
|
||||
targetBitrate: Int,
|
||||
maxSize: Int,
|
||||
codecPref: String,
|
||||
frameRateCap: Int,
|
||||
jobId: Int,
|
||||
onProgress: @escaping (Int, Double) -> Void
|
||||
) {
|
||||
self.url = url
|
||||
self.targetBitrate = targetBitrate
|
||||
self.maxSize = maxSize
|
||||
self.codecPref = codecPref
|
||||
self.frameRateCap = frameRateCap
|
||||
self.jobId = jobId
|
||||
self.onProgress = onProgress
|
||||
}
|
||||
|
||||
func cancel() {
|
||||
isCancelled = true
|
||||
}
|
||||
|
||||
func compress() async throws -> [String: Any] {
|
||||
let asset = AVURLAsset(
|
||||
url: url,
|
||||
options: [AVURLAssetPreferPreciseDurationAndTimingKey: true]
|
||||
)
|
||||
let duration = try await asset.load(.duration)
|
||||
let totalSeconds = CMTimeGetSeconds(duration)
|
||||
guard totalSeconds > 0 else { throw err("Invalid video duration", code: 2) }
|
||||
|
||||
let videoTracks = try await asset.loadTracks(withMediaType: .video)
|
||||
guard let videoTrack = videoTracks.first else {
|
||||
throw err("No video track found", code: 1)
|
||||
}
|
||||
|
||||
let naturalSize = try await videoTrack.load(.naturalSize)
|
||||
let preferredTransform = try await videoTrack.load(.preferredTransform)
|
||||
|
||||
let rotatedRect = CGRect(origin: .zero, size: naturalSize).applying(preferredTransform)
|
||||
let displaySize = CGSize(
|
||||
width: abs(rotatedRect.width),
|
||||
height: abs(rotatedRect.height)
|
||||
)
|
||||
let outputSize = scaleEvenly(displaySize: displaySize, maxSize: maxSize)
|
||||
|
||||
let audioTracks = try await asset.loadTracks(withMediaType: .audio)
|
||||
|
||||
// 'auto' targets h264 — server pipeline is HLS, which favors h264 (HEVC needs
|
||||
// fMP4 segments + commercial licensing). HEVC remains opt-in via codec: 'hevc'.
|
||||
let useHEVC: Bool
|
||||
switch codecPref {
|
||||
case "hevc": useHEVC = true
|
||||
default: useHEVC = false
|
||||
}
|
||||
let codecType: AVVideoCodecType = useHEVC ? .hevc : .h264
|
||||
let profileLevel: String = useHEVC
|
||||
? kVTProfileLevel_HEVC_Main_AutoLevel as String
|
||||
: kVTProfileLevel_H264_High_AutoLevel as String
|
||||
|
||||
let effectiveBitrate = targetBitrate > 0
|
||||
? targetBitrate
|
||||
: (useHEVC ? 2_500_000 : 3_000_000)
|
||||
|
||||
let outputURL = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent(UUID().uuidString)
|
||||
.appendingPathExtension("mp4")
|
||||
|
||||
let videoComposition = makeRotatingComposition(
|
||||
videoTrack: videoTrack,
|
||||
preferredTransform: preferredTransform,
|
||||
naturalSize: naturalSize,
|
||||
outputSize: outputSize,
|
||||
duration: duration
|
||||
)
|
||||
|
||||
let reader = try AVAssetReader(asset: asset)
|
||||
|
||||
let videoReaderSettings: [String: Any] = [
|
||||
kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA
|
||||
]
|
||||
let videoReaderOutput = AVAssetReaderVideoCompositionOutput(
|
||||
videoTracks: [videoTrack],
|
||||
videoSettings: videoReaderSettings
|
||||
)
|
||||
videoReaderOutput.videoComposition = videoComposition
|
||||
videoReaderOutput.alwaysCopiesSampleData = false
|
||||
guard reader.canAdd(videoReaderOutput) else {
|
||||
throw err("Cannot read video track", code: 3)
|
||||
}
|
||||
reader.add(videoReaderOutput)
|
||||
|
||||
var compressionProps: [String: Any] = [
|
||||
AVVideoAverageBitRateKey: effectiveBitrate,
|
||||
AVVideoProfileLevelKey: profileLevel,
|
||||
AVVideoMaxKeyFrameIntervalKey: max(frameRateCap * 3, 30),
|
||||
AVVideoExpectedSourceFrameRateKey: frameRateCap,
|
||||
AVVideoAllowFrameReorderingKey: false,
|
||||
kVTCompressionPropertyKey_RealTime as String: true,
|
||||
]
|
||||
let peakBytesPerSecond = Int(Double(effectiveBitrate) / 8.0 * 1.5)
|
||||
compressionProps[kVTCompressionPropertyKey_DataRateLimits as String] = [
|
||||
peakBytesPerSecond, 1.0
|
||||
] as CFArray
|
||||
|
||||
let videoColorProps: [String: Any] = [
|
||||
AVVideoColorPrimariesKey: AVVideoColorPrimaries_ITU_R_709_2,
|
||||
AVVideoTransferFunctionKey: AVVideoTransferFunction_ITU_R_709_2,
|
||||
AVVideoYCbCrMatrixKey: AVVideoYCbCrMatrix_ITU_R_709_2,
|
||||
]
|
||||
|
||||
let videoWriterSettings: [String: Any] = [
|
||||
AVVideoCodecKey: codecType,
|
||||
AVVideoWidthKey: outputSize.width,
|
||||
AVVideoHeightKey: outputSize.height,
|
||||
AVVideoColorPropertiesKey: videoColorProps,
|
||||
AVVideoCompressionPropertiesKey: compressionProps,
|
||||
]
|
||||
let videoWriterInput = AVAssetWriterInput(
|
||||
mediaType: .video,
|
||||
outputSettings: videoWriterSettings
|
||||
)
|
||||
videoWriterInput.expectsMediaDataInRealTime = false
|
||||
|
||||
let writer = try AVAssetWriter(outputURL: outputURL, fileType: .mp4)
|
||||
writer.shouldOptimizeForNetworkUse = true
|
||||
writer.metadata = []
|
||||
guard writer.canAdd(videoWriterInput) else {
|
||||
throw err("Cannot write video track", code: 4)
|
||||
}
|
||||
writer.add(videoWriterInput)
|
||||
|
||||
var audioReaderOutput: AVAssetReaderTrackOutput?
|
||||
var audioWriterInput: AVAssetWriterInput?
|
||||
if let audioTrack = audioTracks.first {
|
||||
let audioDecoderSettings: [String: Any] = [
|
||||
AVFormatIDKey: kAudioFormatLinearPCM,
|
||||
AVLinearPCMBitDepthKey: 16,
|
||||
AVLinearPCMIsFloatKey: false,
|
||||
AVLinearPCMIsBigEndianKey: false,
|
||||
AVLinearPCMIsNonInterleaved: false,
|
||||
]
|
||||
let audioOutput = AVAssetReaderTrackOutput(
|
||||
track: audioTrack,
|
||||
outputSettings: audioDecoderSettings
|
||||
)
|
||||
audioOutput.alwaysCopiesSampleData = false
|
||||
if reader.canAdd(audioOutput) {
|
||||
reader.add(audioOutput)
|
||||
audioReaderOutput = audioOutput
|
||||
|
||||
let audioEncoderSettings: [String: Any] = [
|
||||
AVFormatIDKey: kAudioFormatMPEG4AAC,
|
||||
AVSampleRateKey: 44100,
|
||||
AVNumberOfChannelsKey: 2,
|
||||
AVEncoderBitRateKey: 128_000,
|
||||
]
|
||||
let audioInput = AVAssetWriterInput(
|
||||
mediaType: .audio,
|
||||
outputSettings: audioEncoderSettings
|
||||
)
|
||||
audioInput.expectsMediaDataInRealTime = false
|
||||
if writer.canAdd(audioInput) {
|
||||
writer.add(audioInput)
|
||||
audioWriterInput = audioInput
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard reader.startReading() else {
|
||||
throw reader.error ?? err("Reader failed to start", code: 8)
|
||||
}
|
||||
guard writer.startWriting() else {
|
||||
throw writer.error ?? err("Writer failed to start", code: 9)
|
||||
}
|
||||
writer.startSession(atSourceTime: .zero)
|
||||
|
||||
let minFrameIntervalSeconds = 1.0 / Double(frameRateCap)
|
||||
let minFrameInterval = CMTime(
|
||||
seconds: minFrameIntervalSeconds,
|
||||
preferredTimescale: 600
|
||||
)
|
||||
|
||||
await withTaskGroup(of: Void.self) { group in
|
||||
group.addTask { [self] in
|
||||
await processVideoTrack(
|
||||
readerOutput: videoReaderOutput,
|
||||
writerInput: videoWriterInput,
|
||||
totalDuration: totalSeconds,
|
||||
minFrameInterval: minFrameInterval
|
||||
)
|
||||
}
|
||||
if let audioOutput = audioReaderOutput, let audioInput = audioWriterInput {
|
||||
group.addTask { [self] in
|
||||
await processAudioTrack(
|
||||
readerOutput: audioOutput,
|
||||
writerInput: audioInput
|
||||
)
|
||||
}
|
||||
}
|
||||
await group.waitForAll()
|
||||
}
|
||||
|
||||
if isCancelled {
|
||||
writer.cancelWriting()
|
||||
try? FileManager.default.removeItem(at: outputURL)
|
||||
throw err("Compression cancelled", code: 5)
|
||||
}
|
||||
|
||||
if reader.status == .failed {
|
||||
let error = reader.error ?? err("Reader failed", code: 6)
|
||||
writer.cancelWriting()
|
||||
try? FileManager.default.removeItem(at: outputURL)
|
||||
throw error
|
||||
}
|
||||
|
||||
await writer.finishWriting()
|
||||
|
||||
if writer.status == .failed {
|
||||
let error = writer.error ?? err("Writer failed", code: 7)
|
||||
try? FileManager.default.removeItem(at: outputURL)
|
||||
throw error
|
||||
}
|
||||
|
||||
onProgress(jobId, 1.0)
|
||||
|
||||
let attributes = try FileManager.default.attributesOfItem(atPath: outputURL.path)
|
||||
let fileSize = attributes[.size] as? Int ?? 0
|
||||
|
||||
return [
|
||||
"uri": outputURL.absoluteString,
|
||||
"size": fileSize,
|
||||
"mimeType": "video/mp4",
|
||||
"width": outputSize.width,
|
||||
"height": outputSize.height,
|
||||
"duration": totalSeconds,
|
||||
"codec": useHEVC ? "hevc" : "h264",
|
||||
]
|
||||
}
|
||||
|
||||
private func processVideoTrack(
|
||||
readerOutput: AVAssetReaderOutput,
|
||||
writerInput: AVAssetWriterInput,
|
||||
totalDuration: Double,
|
||||
minFrameInterval: CMTime
|
||||
) async {
|
||||
var lastProgressTime: CFAbsoluteTime = 0
|
||||
var lastAppendedPTS: CMTime?
|
||||
var finished = false
|
||||
|
||||
await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in
|
||||
writerInput.requestMediaDataWhenReady(
|
||||
on: DispatchQueue(label: "com.bsky.videocompress.video")
|
||||
) {
|
||||
let finish = {
|
||||
if !finished {
|
||||
finished = true
|
||||
writerInput.markAsFinished()
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
while writerInput.isReadyForMoreMediaData {
|
||||
if finished { return }
|
||||
if self.isCancelled {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
guard let sampleBuffer = readerOutput.copyNextSampleBuffer() else {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
let pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
|
||||
if let last = lastAppendedPTS {
|
||||
let delta = CMTimeSubtract(pts, last)
|
||||
if CMTimeCompare(delta, minFrameInterval) < 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
lastAppendedPTS = pts
|
||||
|
||||
if !writerInput.append(sampleBuffer) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
let now = CFAbsoluteTimeGetCurrent()
|
||||
if now - lastProgressTime >= 0.1 {
|
||||
lastProgressTime = now
|
||||
let progress = min(CMTimeGetSeconds(pts) / totalDuration, 1.0)
|
||||
self.onProgress(self.jobId, progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func processAudioTrack(
|
||||
readerOutput: AVAssetReaderOutput,
|
||||
writerInput: AVAssetWriterInput
|
||||
) async {
|
||||
var finished = false
|
||||
|
||||
await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in
|
||||
writerInput.requestMediaDataWhenReady(
|
||||
on: DispatchQueue(label: "com.bsky.videocompress.audio")
|
||||
) {
|
||||
let finish = {
|
||||
if !finished {
|
||||
finished = true
|
||||
writerInput.markAsFinished()
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
while writerInput.isReadyForMoreMediaData {
|
||||
if finished { return }
|
||||
if self.isCancelled {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
guard let sampleBuffer = readerOutput.copyNextSampleBuffer() else {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
if !writerInput.append(sampleBuffer) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func makeRotatingComposition(
|
||||
videoTrack: AVAssetTrack,
|
||||
preferredTransform: CGAffineTransform,
|
||||
naturalSize: CGSize,
|
||||
outputSize: (width: Int, height: Int),
|
||||
duration: CMTime
|
||||
) -> AVMutableVideoComposition {
|
||||
let composition = AVMutableVideoComposition()
|
||||
composition.renderSize = CGSize(width: outputSize.width, height: outputSize.height)
|
||||
composition.frameDuration = CMTime(value: 1, timescale: Int32(frameRateCap))
|
||||
|
||||
let rotatedRect = CGRect(origin: .zero, size: naturalSize).applying(preferredTransform)
|
||||
let translate = CGAffineTransform(
|
||||
translationX: -rotatedRect.minX,
|
||||
y: -rotatedRect.minY
|
||||
)
|
||||
let displaySize = CGSize(
|
||||
width: abs(rotatedRect.width),
|
||||
height: abs(rotatedRect.height)
|
||||
)
|
||||
let scaleX = CGFloat(outputSize.width) / displaySize.width
|
||||
let scaleY = CGFloat(outputSize.height) / displaySize.height
|
||||
let scale = CGAffineTransform(scaleX: scaleX, y: scaleY)
|
||||
let combined = preferredTransform.concatenating(translate).concatenating(scale)
|
||||
|
||||
let layerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: videoTrack)
|
||||
layerInstruction.setTransform(combined, at: .zero)
|
||||
|
||||
let instruction = AVMutableVideoCompositionInstruction()
|
||||
instruction.timeRange = CMTimeRange(start: .zero, duration: duration)
|
||||
instruction.layerInstructions = [layerInstruction]
|
||||
|
||||
composition.instructions = [instruction]
|
||||
return composition
|
||||
}
|
||||
|
||||
private func scaleEvenly(displaySize: CGSize, maxSize: Int) -> (width: Int, height: Int) {
|
||||
let cap = CGFloat(maxSize)
|
||||
let scale: CGFloat
|
||||
if displaySize.width <= cap && displaySize.height <= cap {
|
||||
scale = 1.0
|
||||
} else if displaySize.width > displaySize.height {
|
||||
scale = cap / displaySize.width
|
||||
} else {
|
||||
scale = cap / displaySize.height
|
||||
}
|
||||
return (
|
||||
roundToEven(Int(displaySize.width * scale)),
|
||||
roundToEven(Int(displaySize.height * scale))
|
||||
)
|
||||
}
|
||||
|
||||
private func roundToEven(_ value: Int) -> Int {
|
||||
return value % 2 == 0 ? value : value - 1
|
||||
}
|
||||
|
||||
private func err(_ message: String, code: Int) -> NSError {
|
||||
return NSError(
|
||||
domain: "ExpoBlueskyVideoCompress",
|
||||
code: code,
|
||||
userInfo: [NSLocalizedDescriptionKey: message]
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
import AVFoundation
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct VideoProber {
|
||||
static func probe(url: URL) async throws -> [String: Any] {
|
||||
let asset = AVURLAsset(url: url)
|
||||
|
||||
let duration = try await asset.load(.duration)
|
||||
let tracks = try await asset.loadTracks(withMediaType: .video)
|
||||
|
||||
guard let videoTrack = tracks.first else {
|
||||
throw NSError(
|
||||
domain: "ExpoBlueskyVideoCompress",
|
||||
code: 1,
|
||||
userInfo: [NSLocalizedDescriptionKey: "No video track found"]
|
||||
)
|
||||
}
|
||||
|
||||
let naturalSize = try await videoTrack.load(.naturalSize)
|
||||
let preferredTransform = try await videoTrack.load(.preferredTransform)
|
||||
let estimatedDataRate = try await videoTrack.load(.estimatedDataRate)
|
||||
let nominalFrameRate = try await videoTrack.load(.nominalFrameRate)
|
||||
let formatDescriptions = try await videoTrack.load(.formatDescriptions)
|
||||
|
||||
var codec = "unknown"
|
||||
var isHDR = false
|
||||
if let formatDescription = formatDescriptions.first {
|
||||
let subType = CMFormatDescriptionGetMediaSubType(formatDescription)
|
||||
codec = fourCCToString(subType)
|
||||
// Dolby Vision codecs are HDR by definition.
|
||||
let dolbyVisionSubtypes: Set<String> = ["dvhe", "dvh1", "dvav", "dva1"]
|
||||
if dolbyVisionSubtypes.contains(codec) {
|
||||
isHDR = true
|
||||
} else if let extensions = CMFormatDescriptionGetExtensions(formatDescription)
|
||||
as? [String: Any]
|
||||
{
|
||||
let transferKey = kCMFormatDescriptionExtension_TransferFunction as String
|
||||
if let transfer = extensions[transferKey] as? String {
|
||||
let hlg = kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG as String
|
||||
let pq = kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ as String
|
||||
isHDR = transfer == hlg || transfer == pq
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let rotation = rotationFromTransform(preferredTransform)
|
||||
let isRotated = rotation == 90 || rotation == 270
|
||||
let width = isRotated ? Int(naturalSize.height) : Int(naturalSize.width)
|
||||
let height = isRotated ? Int(naturalSize.width) : Int(naturalSize.height)
|
||||
|
||||
let audioTracks = try await asset.loadTracks(withMediaType: .audio)
|
||||
let hasAudio = !audioTracks.isEmpty
|
||||
|
||||
let fileSize: Int
|
||||
if let attributes = try? FileManager.default.attributesOfItem(atPath: url.path),
|
||||
let size = attributes[.size] as? Int {
|
||||
fileSize = size
|
||||
} else {
|
||||
fileSize = 0
|
||||
}
|
||||
|
||||
let mimeType: String
|
||||
if let utType = UTType(filenameExtension: url.pathExtension) {
|
||||
mimeType = utType.preferredMIMEType ?? "video/mp4"
|
||||
} else {
|
||||
mimeType = "video/mp4"
|
||||
}
|
||||
|
||||
let durationSeconds = CMTimeGetSeconds(duration)
|
||||
var bitrate = Int(estimatedDataRate)
|
||||
if bitrate == 0 && durationSeconds > 0 {
|
||||
bitrate = Int(Double(fileSize * 8) / durationSeconds)
|
||||
}
|
||||
|
||||
return [
|
||||
"width": width,
|
||||
"height": height,
|
||||
"duration": durationSeconds,
|
||||
"bitrate": bitrate,
|
||||
"fileSize": fileSize,
|
||||
"mimeType": mimeType,
|
||||
"codec": codec,
|
||||
"hasAudio": hasAudio,
|
||||
"frameRate": nominalFrameRate,
|
||||
"rotation": rotation,
|
||||
"isHDR": isHDR
|
||||
]
|
||||
}
|
||||
|
||||
private static func rotationFromTransform(_ transform: CGAffineTransform) -> Int {
|
||||
let angle = atan2(transform.b, transform.a)
|
||||
let degrees = Int(round(angle * 180.0 / .pi))
|
||||
return ((degrees % 360) + 360) % 360
|
||||
}
|
||||
|
||||
private static func fourCCToString(_ code: FourCharCode) -> String {
|
||||
let chars: [Character] = [
|
||||
Character(UnicodeScalar((code >> 24) & 0xFF)!),
|
||||
Character(UnicodeScalar((code >> 16) & 0xFF)!),
|
||||
Character(UnicodeScalar((code >> 8) & 0xFF)!),
|
||||
Character(UnicodeScalar(code & 0xFF)!)
|
||||
]
|
||||
return String(chars).trimmingCharacters(in: .whitespaces)
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import {type EventSubscription, requireNativeModule} from 'expo-modules-core'
|
||||
|
||||
import {
|
||||
type CompressResult,
|
||||
type NativeCompressOptions,
|
||||
type VideoMetadata,
|
||||
} from './types'
|
||||
|
||||
type ProgressEvent = {id: number; progress: number}
|
||||
|
||||
interface ExpoBlueskyVideoCompressModule {
|
||||
probe(uri: string): Promise<VideoMetadata>
|
||||
compress(uri: string, options: NativeCompressOptions): Promise<CompressResult>
|
||||
cancel(jobId: number): void
|
||||
addListener(
|
||||
eventName: 'onProgress',
|
||||
listener: (event: ProgressEvent) => void,
|
||||
): EventSubscription
|
||||
}
|
||||
|
||||
export default requireNativeModule<ExpoBlueskyVideoCompressModule>(
|
||||
'ExpoBlueskyVideoCompress',
|
||||
)
|
||||
@@ -1,45 +0,0 @@
|
||||
export type CodecPreference = 'auto' | 'hevc' | 'h264'
|
||||
|
||||
export type VideoMetadata = {
|
||||
width: number
|
||||
height: number
|
||||
duration: number
|
||||
bitrate: number
|
||||
fileSize: number
|
||||
mimeType: string
|
||||
codec: string
|
||||
hasAudio: boolean
|
||||
frameRate: number
|
||||
rotation: number
|
||||
isHDR: boolean
|
||||
}
|
||||
|
||||
export type CompressOptions = {
|
||||
targetBitrate?: number
|
||||
maxSize?: number
|
||||
codec?: CodecPreference
|
||||
frameRateCap?: number
|
||||
}
|
||||
|
||||
export type CompressCallbacks = {
|
||||
onProgress?: (progress: number) => void
|
||||
signal?: AbortSignal
|
||||
}
|
||||
|
||||
export type CompressResult = {
|
||||
uri: string
|
||||
size: number
|
||||
mimeType: string
|
||||
width: number
|
||||
height: number
|
||||
duration: number
|
||||
codec: 'h264' | 'hevc'
|
||||
}
|
||||
|
||||
export type NativeCompressOptions = {
|
||||
targetBitrate: number
|
||||
maxSize: number
|
||||
codec: CodecPreference
|
||||
frameRateCap: number
|
||||
jobId: number
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import {requireNativeView} from 'expo'
|
||||
import type * as React from 'react'
|
||||
|
||||
import {
|
||||
type EmojiPickerNativeViewProps,
|
||||
|
||||
+8
-9
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"name": "bsky.app",
|
||||
"version": "1.128.0",
|
||||
"version": "1.126.0",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=24.18.0"
|
||||
"node": ">=24.15.0"
|
||||
},
|
||||
"devEngines": {
|
||||
"packageManager": {
|
||||
"name": "pnpm",
|
||||
"version": "11.10.0",
|
||||
"version": "11.7.0",
|
||||
"onFail": "warn"
|
||||
},
|
||||
"runtime": {
|
||||
"name": "node",
|
||||
"version": "^24.18.0",
|
||||
"version": "^24.15.0",
|
||||
"onFail": "download"
|
||||
}
|
||||
},
|
||||
@@ -90,12 +90,12 @@
|
||||
"generate-webpack-stats-file": "EXPO_PUBLIC_GENERATE_STATS=1 pnpm build-web",
|
||||
"open-analyzer": "EXPO_PUBLIC_OPEN_ANALYZER=1 pnpm build-web",
|
||||
"icons:optimize": "svgo -f ./assets/icons",
|
||||
"prettier": "prettier --check ."
|
||||
"prettier": "prettier --check .",
|
||||
"update-actions": "pnpm dlx actions-up --min-age 7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@atproto/api": "0.20.25",
|
||||
"@atproto/common-web": "0.5.3",
|
||||
"@atproto/syntax": "0.6.4",
|
||||
"@atproto/api": "0.20.15",
|
||||
"@atproto/syntax": "0.6.1",
|
||||
"@bitdrift/react-native": "^0.6.8",
|
||||
"@braintree/sanitize-url": "^6.0.2",
|
||||
"@bsky.app/alf": "^0.1.14",
|
||||
@@ -157,7 +157,6 @@
|
||||
"emoji-regex": "^10.4.0",
|
||||
"eventemitter3": "^5.0.1",
|
||||
"expo": "54.0.34",
|
||||
"expo-age-range": "0.2.18",
|
||||
"expo-application": "~7.0.8",
|
||||
"expo-blur": "~15.0.8",
|
||||
"expo-build-properties": "~1.0.10",
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
diff --git a/ios/AgeRangeModule.swift b/ios/AgeRangeModule.swift
|
||||
index faf1089f4ddfb290105e959bb1f96a7250586f54..dafd2addb0c8d39a4a453bdeecbe27f7278e20f7 100644
|
||||
--- a/ios/AgeRangeModule.swift
|
||||
+++ b/ios/AgeRangeModule.swift
|
||||
@@ -11,8 +11,9 @@ public class AgeRangeModule: Module {
|
||||
return AgeRangeResponse()
|
||||
}
|
||||
|
||||
- let currentVc: UIViewController? = await MainActor.run { [appContext] in
|
||||
- appContext?.utilities?.currentViewController()
|
||||
+ nonisolated(unsafe) let utilities = appContext?.utilities
|
||||
+ let currentVc: UIViewController? = await MainActor.run {
|
||||
+ utilities?.currentViewController()
|
||||
}
|
||||
|
||||
guard let currentVc else {
|
||||
@@ -1,26 +1,3 @@
|
||||
diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts
|
||||
index 48178d9246ab94d701983ac20473983eb746d1a6..451d38e6e20646c32795db3be28fbea57de1d12f 100644
|
||||
--- a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts
|
||||
+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts
|
||||
@@ -172,6 +172,18 @@ function useChatKeyboard(
|
||||
|
||||
currentHeight.value = e.height;
|
||||
|
||||
+ if (scrollViewRef() == null) {
|
||||
+ // The scroll view can be detached or not yet attached while a
|
||||
+ // keyboard animation is running (e.g. the chat list re-creating its
|
||||
+ // scroll component mid-animation). Every branch below eventually
|
||||
+ // calls scrollTo (directly or via clampScrollIfNeeded); on Paper
|
||||
+ // reanimated's scrollTo would hand the null ref to the native
|
||||
+ // _scrollToPaper HostFunction, which throws "Value is null, expected
|
||||
+ // a number" and crashes in release builds. currentHeight is kept up
|
||||
+ // to date above so the animated style keeps committing.
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (inverted) {
|
||||
// Skip post-interactive snap-back (duration === -1)
|
||||
if (e.duration === -1) {
|
||||
diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
|
||||
index 0f6d7c67a307885310ab184fdf9e7a5c7b296825..1a01093e7909973cef5268f999158df389e77634 100644
|
||||
--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
|
||||
|
||||
Generated
+106
-124
@@ -7,52 +7,52 @@ importers:
|
||||
configDependencies: {}
|
||||
packageManagerDependencies:
|
||||
'@pnpm/exe':
|
||||
specifier: 11.10.0
|
||||
version: 11.10.0
|
||||
specifier: 11.7.0
|
||||
version: 11.7.0
|
||||
pnpm:
|
||||
specifier: 11.10.0
|
||||
version: 11.10.0
|
||||
specifier: 11.7.0
|
||||
version: 11.7.0
|
||||
|
||||
packages:
|
||||
|
||||
'@pnpm/exe@11.10.0':
|
||||
resolution: {integrity: sha512-mrmfi2C7LpZkyq0voKKye6MzrK8/K7tYQRiSB/jqOiwnFtQxxcA3xGTY9cEsrGpNl2ClPecQofLuj+BO8AIsxw==}
|
||||
'@pnpm/exe@11.7.0':
|
||||
resolution: {integrity: sha512-3CujpSSp2PIDE0pwu7mWSdjhdDqaZa7OppVooECWWaNEoA/z66s9FZts1MhDO+2yq1XER4gBHh84DVbFN/r1rA==}
|
||||
hasBin: true
|
||||
|
||||
'@pnpm/linux-arm64@11.10.0':
|
||||
resolution: {integrity: sha512-NbvDeUfs0SJuli9OPvgVvmnlbo2DvJ861XGXKrzgLu5AuTnLDLXgbZEEUd8mJ5I0YNrqOVXSWVfWEqiAazWzPA==}
|
||||
'@pnpm/linux-arm64@11.7.0':
|
||||
resolution: {integrity: sha512-ANTX2SlMO+d2y/4bYQhHCwHPX7gSSADJ5+pMUIiDFzIsybnFFaJdZboaFfq9NOxCbETcnDxqZ95Rz3+NHx1JIw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@pnpm/linux-x64@11.10.0':
|
||||
resolution: {integrity: sha512-kdgb8BXZ/3XQ0x2cOmgLmsij7+SUIqd1bcV6OZhdGzQiDrOY6FAPrR+Y2Bp+NjrrhjzMHVm5pZrrmdeC67ymSQ==}
|
||||
'@pnpm/linux-x64@11.7.0':
|
||||
resolution: {integrity: sha512-fr75tqixXoS8cnA81HQIomjOGEPnsOsd3xCDL5pMNY5raOXbKurtgRV+RjATvjxlJxSLIVFKegABlxAiB7q72A==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@pnpm/linuxstatic-arm64@11.10.0':
|
||||
resolution: {integrity: sha512-JE1WrSyKGvqGQgWzqrMXn//ehedpiRax3hi1oP+v6mhvcnlJD1lpfXsjSfIFl9weTWC5KVtFbxSNKbKWfP+v6g==}
|
||||
'@pnpm/linuxstatic-arm64@11.7.0':
|
||||
resolution: {integrity: sha512-Q++pgzvXkGeqnVRl26/uqmpMGdttQus0rGyL3XIfYGLCi8ZfajYUaCKdZID2MH7+CNOuugWDdFDup3r7BR7Rfg==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/linuxstatic-x64@11.10.0':
|
||||
resolution: {integrity: sha512-1TBZVRkWb78GnsusIfVgwz20MOOW0fyehW+qLL3MxE9vT0IedNWsAhe3KWXgEvtC4M7NtMt55uQQJm+1egwBkA==}
|
||||
'@pnpm/linuxstatic-x64@11.7.0':
|
||||
resolution: {integrity: sha512-z1+exW6ocU/rmOvJnmU3FUBJYaryCUqFoaXN6KZW5BqTj7BPJb7HJcAyXRlirNZMJlEiUY5rXbfStGPQJhGsVA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/macos-arm64@11.10.0':
|
||||
resolution: {integrity: sha512-94AVpPixBqyNT6SHYvIKFb1bfaHR5vxBzZsiFJahNSlGkgyPrgzmcqDiloZ/Jl+zxJd8L5PU1ddP0Q9PZnRqlA==}
|
||||
'@pnpm/macos-arm64@11.7.0':
|
||||
resolution: {integrity: sha512-gD34/k3JT5oab4BYaqrUor3e4VdwXvkfLNlEI+lvDtX1MHT+2Nauc9p9NsQnpn1zE8blQEflzbF8wAUQ6Dmvkw==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/win-arm64@11.10.0':
|
||||
resolution: {integrity: sha512-g2Ymnq+LgVyZaWsGBQSlpIcBCOOxyLky2UX+kTwGiIXnj6k/xXqZR0ZJLuxeiGNh/CVmhftOqokpyJNzyj8kng==}
|
||||
'@pnpm/win-arm64@11.7.0':
|
||||
resolution: {integrity: sha512-hRTcDmm2j7KoRwbqNo0rUAu9A1kVJN98Eob7H09U0uPJbEMax85JGOmERkT3Lf6HjVJuFNBvfaJ3OTI3HmlVGg==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@pnpm/win-x64@11.10.0':
|
||||
resolution: {integrity: sha512-kCHYZudUEBjrEchgnJUnNHCdvLXpUZun2z0rMAeP5DymsaXwEVvVzGj220iR/NyhgDocJUmgtTKtwL/ejL785Q==}
|
||||
'@pnpm/win-x64@11.7.0':
|
||||
resolution: {integrity: sha512-r/1NuKY7Z+6ZXVIzVrUEMj6TTEBdR63geV4Rlm8HKEhgQTdxyIsJoqV3FJGqoyzbRaScObqAwRfMaK9dskPddQ==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
@@ -116,45 +116,45 @@ packages:
|
||||
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
pnpm@11.10.0:
|
||||
resolution: {integrity: sha512-C3+LmAYAMZBMAX46QesYehbUDuuCm5XE+MsDaBdh/Eq1PdIZEVubRH9NzhoFohR2RGHn03AzkqnzL5URzoyGyA==}
|
||||
pnpm@11.7.0:
|
||||
resolution: {integrity: sha512-GcyFLBIMcSV2DyRD7mvgyltA+fUFmN4aCaHxd1A+AQ5Xwjx3ZG4B52HeWb+HT7IqM5jDOrlpH8E+uUa28PTWIA==}
|
||||
engines: {node: '>=22.13'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@pnpm/exe@11.10.0':
|
||||
'@pnpm/exe@11.7.0':
|
||||
dependencies:
|
||||
'@reflink/reflink': 0.1.19
|
||||
detect-libc: 2.1.2
|
||||
optionalDependencies:
|
||||
'@pnpm/linux-arm64': 11.10.0
|
||||
'@pnpm/linux-x64': 11.10.0
|
||||
'@pnpm/linuxstatic-arm64': 11.10.0
|
||||
'@pnpm/linuxstatic-x64': 11.10.0
|
||||
'@pnpm/macos-arm64': 11.10.0
|
||||
'@pnpm/win-arm64': 11.10.0
|
||||
'@pnpm/win-x64': 11.10.0
|
||||
'@pnpm/linux-arm64': 11.7.0
|
||||
'@pnpm/linux-x64': 11.7.0
|
||||
'@pnpm/linuxstatic-arm64': 11.7.0
|
||||
'@pnpm/linuxstatic-x64': 11.7.0
|
||||
'@pnpm/macos-arm64': 11.7.0
|
||||
'@pnpm/win-arm64': 11.7.0
|
||||
'@pnpm/win-x64': 11.7.0
|
||||
|
||||
'@pnpm/linux-arm64@11.10.0':
|
||||
'@pnpm/linux-arm64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/linux-x64@11.10.0':
|
||||
'@pnpm/linux-x64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/linuxstatic-arm64@11.10.0':
|
||||
'@pnpm/linuxstatic-arm64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/linuxstatic-x64@11.10.0':
|
||||
'@pnpm/linuxstatic-x64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/macos-arm64@11.10.0':
|
||||
'@pnpm/macos-arm64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/win-arm64@11.10.0':
|
||||
'@pnpm/win-arm64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/win-x64@11.10.0':
|
||||
'@pnpm/win-x64@11.7.0':
|
||||
optional: true
|
||||
|
||||
'@reflink/reflink-darwin-arm64@0.1.19':
|
||||
@@ -194,7 +194,7 @@ snapshots:
|
||||
|
||||
detect-libc@2.1.2: {}
|
||||
|
||||
pnpm@11.10.0: {}
|
||||
pnpm@11.7.0: {}
|
||||
|
||||
---
|
||||
lockfileVersion: '9.0'
|
||||
@@ -216,7 +216,6 @@ overrides:
|
||||
|
||||
patchedDependencies:
|
||||
'@sentry/react-native@6.20.0': 1d48e4d5178f5684eb33262299e7eed283bf9601f79b9ae1af63a7f607d3483a
|
||||
expo-age-range@0.2.18: c325225749993424461eeece1d97a99b19c00da2ebc958a73c12e4eca0c39306
|
||||
expo-glass-effect@55.0.8: 6c9fa5b104e53b87df4e17b320acb3b94d12ac90c0101190045dd620681efff0
|
||||
expo-haptics@15.0.8: b33910ba2753c4eccdc885b449e6e33aa90b9cefa75ca8639762a26013141410
|
||||
expo-image-picker@17.0.11: 47b28f6ddb8bcaa6483f8714c82daaa0001122f2b0dac6c05d19e98a61a6ceab
|
||||
@@ -228,7 +227,7 @@ patchedDependencies:
|
||||
react-native-compressor@1.13.0: 58379dfaace6ced8590cb341c77f2ca8099dfa8f7df6297032ec51de767a9925
|
||||
react-native-date-picker@5.0.13: f2a6697da7a7ca79b4f39efda142eee1b82db6de3aa5010ad4bd59df41fe2ce1
|
||||
react-native-drawer-layout@4.2.3: 74f2c043cc22ab87054f219e7c7373a509b779b18bfa79d27e7d051d73355130
|
||||
react-native-keyboard-controller@1.21.8: ac52bf7502ff3ad34a8594b5e1a916b96bf87a2523b6abc87c31f03607d52271
|
||||
react-native-keyboard-controller@1.21.8: 2f6791837622fb391c3e41fc044b91ddedbe503da14da86165ee0a73924b05f1
|
||||
react-native-pager-view@6.8.0: 0979d6fe1e2fa43b2784cc0b5e0ff0117d53b53423e85ee5855eefdc41a00108
|
||||
react-native-reanimated@3.19.1: 97a1967f37a4213fbab59e1fd59a1bf859b5efc79af5e1b528a47fe488e6c5d6
|
||||
react-native-svg@15.12.1: 31401fa6ff01498773afb51a7b066821c471eb3e71b0764a10017938beed49e9
|
||||
@@ -242,14 +241,11 @@ importers:
|
||||
.:
|
||||
dependencies:
|
||||
'@atproto/api':
|
||||
specifier: 0.20.25
|
||||
version: 0.20.25
|
||||
'@atproto/common-web':
|
||||
specifier: 0.5.3
|
||||
version: 0.5.3
|
||||
specifier: 0.20.15
|
||||
version: 0.20.15
|
||||
'@atproto/syntax':
|
||||
specifier: 0.6.4
|
||||
version: 0.6.4
|
||||
specifier: 0.6.1
|
||||
version: 0.6.1
|
||||
'@bitdrift/react-native':
|
||||
specifier: ^0.6.8
|
||||
version: 0.6.14(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
@@ -433,9 +429,6 @@ importers:
|
||||
expo:
|
||||
specifier: 54.0.34
|
||||
version: 54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
expo-age-range:
|
||||
specifier: 0.2.18
|
||||
version: 0.2.18(patch_hash=c325225749993424461eeece1d97a99b19c00da2ebc958a73c12e4eca0c39306)(expo@54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))
|
||||
expo-application:
|
||||
specifier: ~7.0.8
|
||||
version: 7.0.8(expo@54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))
|
||||
@@ -639,7 +632,7 @@ importers:
|
||||
version: 2.28.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
react-native-keyboard-controller:
|
||||
specifier: ^1.21.8
|
||||
version: 1.21.8(patch_hash=ac52bf7502ff3ad34a8594b5e1a916b96bf87a2523b6abc87c31f03607d52271)(react-native-reanimated@3.19.1(patch_hash=97a1967f37a4213fbab59e1fd59a1bf859b5efc79af5e1b528a47fe488e6c5d6)(@babel/core@7.29.0)(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
version: 1.21.8(patch_hash=2f6791837622fb391c3e41fc044b91ddedbe503da14da86165ee0a73924b05f1)(react-native-reanimated@3.19.1(patch_hash=97a1967f37a4213fbab59e1fd59a1bf859b5efc79af5e1b528a47fe488e6c5d6)(@babel/core@7.29.0)(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
react-native-pager-view:
|
||||
specifier: 6.8.0
|
||||
version: 6.8.0(patch_hash=0979d6fe1e2fa43b2784cc0b5e0ff0117d53b53423e85ee5855eefdc41a00108)(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
@@ -846,8 +839,8 @@ importers:
|
||||
specifier: ^13.2.3
|
||||
version: 13.3.0
|
||||
node:
|
||||
specifier: runtime:^24.18.0
|
||||
version: runtime:24.18.0
|
||||
specifier: runtime:^24.15.0
|
||||
version: runtime:24.15.0
|
||||
prettier:
|
||||
specifier: ^3.8.3
|
||||
version: 3.8.3
|
||||
@@ -883,32 +876,32 @@ packages:
|
||||
graphql:
|
||||
optional: true
|
||||
|
||||
'@atproto/api@0.20.25':
|
||||
resolution: {integrity: sha512-PTwt6X0U45C9vikr8NRi0Qzcep9VqJet52HtfcxgG9R7ofRHxqLVPzfVuN/f2xOaYM6H5IG/Nk1E9kXZcI0mSQ==}
|
||||
'@atproto/api@0.20.15':
|
||||
resolution: {integrity: sha512-b9TuVNY9iWIaRXAeKegNCqRsK9tSpB68DE/j/ytVTxEMK+/m43B0DycJND9tnhRiNIY+i7MhwLqNHPak9YaDJg==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/common-web@0.5.3':
|
||||
resolution: {integrity: sha512-FkMhOcNv1y7r5984+zXB+uMN4zJ4QFLEbZrYyQo6bNCf/Kfav/pEHXXENlaZEOweq2NYXf+tr2giMssBuM9u5A==}
|
||||
'@atproto/common-web@0.5.0':
|
||||
resolution: {integrity: sha512-ReWnkuZdDU/74/I47gaI26uxQjHmpq4edp41NnZZQ5vIIKGb7Ei6pZHzDTUD9JURo109SKrPx9RMP2IQm0fOKA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lex-data@0.1.4':
|
||||
resolution: {integrity: sha512-f9U95sk0zUtxHktvK59peU+Shd0cIUYV68p//GS7sfdkAxUIeaspvX6CY+Quv9Oa4aozmsXI52SjaNn1wuU8RQ==}
|
||||
'@atproto/lex-data@0.1.1':
|
||||
resolution: {integrity: sha512-/xza8nU/YhtzhETnHL3QKKofaJ28/0NCzhT7LaYoUkm8EgypWp5ykEtmW52yLhQM2JF6fVa25g1soQmNTGqtSg==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lex-json@0.1.3':
|
||||
resolution: {integrity: sha512-Ch2w9bCLFOwWINFFxpZo6DBW7+ZxkehciU3P8N94gSyENLe3/5WWXHdHvkiH7EXZrpI7fKY8nVWn4GIL0ttqxw==}
|
||||
'@atproto/lex-json@0.1.0':
|
||||
resolution: {integrity: sha512-oWUrRMwFyWpmi/5k1Se3xBTbP06XdxBS5iFuUz9LmqItaPXwrWRD87a9ldPvINQ/A2/mn7J6/qug8sDVlhD+vQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/lexicon@0.7.4':
|
||||
resolution: {integrity: sha512-ulk4RGwMBp4vbkTOZcIwZJeTEPlj3PImOnx9TqxSxMDnBdySxarpd0Aprg7+iAvGyKTsMcrYHpeoLukZaquk0A==}
|
||||
'@atproto/lexicon@0.7.1':
|
||||
resolution: {integrity: sha512-voNfNED5KUxn3vpo7N5DMRblBDfWf7kSfdKhJFC1RrLCxg38YbBzzURNVQJ32bp13Oot8kYfyXBWxTgtKLvw8w==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/syntax@0.6.4':
|
||||
resolution: {integrity: sha512-ELgpShRGMF65cvLXcoMCZFL0HBzy67yz/Nlhox3yOtTh120B09KjjvZYXhMysVog3nUJqv2EW5rf1VRYCeM/hw==}
|
||||
'@atproto/syntax@0.6.1':
|
||||
resolution: {integrity: sha512-kA4dQDoMPpWCH8N0Q4KoSq024u5MkVfDVa8DdhyLjGA72z/khbOf1jXKPv7NIL2oEc9aj7geKELdvqyf4ogopA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@atproto/xrpc@0.8.3':
|
||||
resolution: {integrity: sha512-0gUGN71+bSqV3PI5U4cQ4fdnw4nI0eD6czHDQ6jB7hMYBwNcJpwAyfA9W+C1G1wayIvP0SIap/M0H/pSKDWFIQ==}
|
||||
'@atproto/xrpc@0.8.0':
|
||||
resolution: {integrity: sha512-NJy02bIKrWlE2NQkRV1kT0Cj0ixbuxlF/MejBdo4cPWAa9v3oZexvAcjjb0zaOYeABkaU14iyIhvn2G4e/oLpw==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@babel/code-frame@7.10.4':
|
||||
@@ -5288,12 +5281,6 @@ packages:
|
||||
resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
|
||||
expo-age-range@0.2.18:
|
||||
resolution: {integrity: sha512-WThjp0/islDlysxRkamXmS9D2zU/T7P5fIizIBPaajfG4C+tjL7psFZp6R6l0eDkYJkYO+VPJRMr5NrQQAu6nQ==}
|
||||
peerDependencies:
|
||||
expo: '*'
|
||||
react-native: '*'
|
||||
|
||||
expo-application@7.0.8:
|
||||
resolution: {integrity: sha512-qFGyxk7VJbrNOQWBbE09XUuGuvkOgFS9QfToaK2FdagM2aQ+x3CvGV2DuVgl/l4ZxPgIf3b/MNh9xHpwSwn74Q==}
|
||||
peerDependencies:
|
||||
@@ -7132,7 +7119,7 @@ packages:
|
||||
node-releases@2.0.44:
|
||||
resolution: {integrity: sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ==}
|
||||
|
||||
node@runtime:24.18.0:
|
||||
node@runtime:24.15.0:
|
||||
resolution:
|
||||
type: variations
|
||||
variants:
|
||||
@@ -7140,9 +7127,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-ZGOiNzn2sjAOvsXM1gJ14TjjhY/Br8bo+bxOT2pLdvo=
|
||||
integrity: sha256-3UvHfctfTJoslkNzm7WTUAzLCUE+xCyqD47w5e8RYJU=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-aix-ppc64.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-aix-ppc64.tar.gz
|
||||
targets:
|
||||
- cpu: ppc64
|
||||
os: aix
|
||||
@@ -7150,9 +7137,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-4al+FMmcgD6WxzOUAyguoFpJnDL42D3v6e9exm+XntE=
|
||||
integrity: sha256-NyMxuWl3mrXRW5SYhPxur4jVr+h73ouogdZAC5EA/8Q=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-darwin-arm64.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-darwin-arm64.tar.gz
|
||||
targets:
|
||||
- cpu: arm64
|
||||
os: darwin
|
||||
@@ -7160,9 +7147,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-39Db0+chUDQ033tyBecZ9hs6OjGyvPlym4uR/qJA8IA=
|
||||
integrity: sha256-/9XuKTRnkn8+5zGlU+uI/R9Iz3TuvC10prq+SvIoZzs=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-darwin-x64.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-darwin-x64.tar.gz
|
||||
targets:
|
||||
- cpu: x64
|
||||
os: darwin
|
||||
@@ -7170,9 +7157,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-a0SEwhkCdBdd+aqPKOLXWKgZyxwf5qtIHi+VtGOrhQg=
|
||||
integrity: sha256-c6/CNNVYwkkZh19RwtHqACoq2k6m+DYBo4OGn++mTu0=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-linux-arm64.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-linux-arm64.tar.gz
|
||||
targets:
|
||||
- cpu: arm64
|
||||
os: linux
|
||||
@@ -7180,9 +7167,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-/hM4ly95KDxrwh5h2/RXa76MBa3tKZnUHIZDrTAmUUI=
|
||||
integrity: sha256-sfiJAKSxY2XqulYmkwT8Edp1gdvwNVLUSV+azh/AX20=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-linux-ppc64le.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-linux-ppc64le.tar.gz
|
||||
targets:
|
||||
- cpu: ppc64le
|
||||
os: linux
|
||||
@@ -7190,9 +7177,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-Nx68E5RfwWlJPnUvLdr6+rbs2My0Ubz/RuCfacXdjHo=
|
||||
integrity: sha256-+YVFVDnVL+m43mqPbQe/7MxzbepSfofqyv5ajXUWo4A=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-linux-s390x.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-linux-s390x.tar.gz
|
||||
targets:
|
||||
- cpu: s390x
|
||||
os: linux
|
||||
@@ -7200,9 +7187,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-eDEwmElj23upy9AQierywu+wVcfBaTyUMXS5Z7MFDLg=
|
||||
integrity: sha256-RINoctmuxJ8ea1KpqSKHLbmisC0jWmFqVoG2qF/sjYk=
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-linux-x64.tar.gz
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-linux-x64.tar.gz
|
||||
targets:
|
||||
- cpu: x64
|
||||
os: linux
|
||||
@@ -7210,10 +7197,10 @@ packages:
|
||||
archive: zip
|
||||
bin:
|
||||
node: node.exe
|
||||
integrity: sha256-8nRmmtuTsf0Pv48h/QeGCencyEMz1PJxjS3eP5oWGgE=
|
||||
prefix: node-v24.18.0-win-arm64
|
||||
integrity: sha256-yet0Au2ibiun5EtnJ/yFqN5WxQlbH3Hr0wYokiEaoRY=
|
||||
prefix: node-v24.15.0-win-arm64
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-win-arm64.zip
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-win-arm64.zip
|
||||
targets:
|
||||
- cpu: arm64
|
||||
os: win32
|
||||
@@ -7221,10 +7208,10 @@ packages:
|
||||
archive: zip
|
||||
bin:
|
||||
node: node.exe
|
||||
integrity: sha256-CuaEBrQtdyVmHal5sUA+yZJtogXGdwgn8zqsnY8m6CE=
|
||||
prefix: node-v24.18.0-win-x64
|
||||
integrity: sha256-zFFJ6r1Td5zh573FQBZDYi0MfmgAreGJKKdn6UC7DmI=
|
||||
prefix: node-v24.15.0-win-x64
|
||||
type: binary
|
||||
url: https://nodejs.org/download/release/v24.18.0/node-v24.18.0-win-x64.zip
|
||||
url: https://nodejs.org/download/release/v24.15.0/node-v24.15.0-win-x64.zip
|
||||
targets:
|
||||
- cpu: x64
|
||||
os: win32
|
||||
@@ -7232,9 +7219,9 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-scbC3DG0bdj7IyL0/nWwfndcUSC8NyUd7uoo9SnUVns=
|
||||
integrity: sha256-MemKqWCgZ9qR7f/V2TvEZle10qgClhLDWfXyrABgFSo=
|
||||
type: binary
|
||||
url: https://unofficial-builds.nodejs.org/download/release/v24.18.0/node-v24.18.0-linux-arm64-musl.tar.gz
|
||||
url: https://unofficial-builds.nodejs.org/download/release/v24.15.0/node-v24.15.0-linux-arm64-musl.tar.gz
|
||||
targets:
|
||||
- cpu: arm64
|
||||
os: linux
|
||||
@@ -7243,14 +7230,14 @@ packages:
|
||||
archive: tarball
|
||||
bin:
|
||||
node: bin/node
|
||||
integrity: sha256-6lhAmRHhQexrGdkXjvotkYWhMpUAWxy/VSGzFX7tHZU=
|
||||
integrity: sha256-9Vr1vUicU0exE8pllMrgClSzC6V6xYdTJDEb/G9HYuM=
|
||||
type: binary
|
||||
url: https://unofficial-builds.nodejs.org/download/release/v24.18.0/node-v24.18.0-linux-x64-musl.tar.gz
|
||||
url: https://unofficial-builds.nodejs.org/download/release/v24.15.0/node-v24.15.0-linux-x64-musl.tar.gz
|
||||
targets:
|
||||
- cpu: x64
|
||||
os: linux
|
||||
libc: musl
|
||||
version: 24.18.0
|
||||
version: 24.15.0
|
||||
hasBin: true
|
||||
|
||||
normalize-path@3.0.0:
|
||||
@@ -9485,51 +9472,51 @@ snapshots:
|
||||
|
||||
'@0no-co/graphql.web@1.2.0': {}
|
||||
|
||||
'@atproto/api@0.20.25':
|
||||
'@atproto/api@0.20.15':
|
||||
dependencies:
|
||||
'@atproto/common-web': 0.5.3
|
||||
'@atproto/lexicon': 0.7.4
|
||||
'@atproto/syntax': 0.6.4
|
||||
'@atproto/xrpc': 0.8.3
|
||||
'@atproto/common-web': 0.5.0
|
||||
'@atproto/lexicon': 0.7.1
|
||||
'@atproto/syntax': 0.6.1
|
||||
'@atproto/xrpc': 0.8.0
|
||||
await-lock: 3.0.0
|
||||
multiformats: 13.4.2
|
||||
tlds: 1.261.0
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/common-web@0.5.3':
|
||||
'@atproto/common-web@0.5.0':
|
||||
dependencies:
|
||||
'@atproto/lex-data': 0.1.4
|
||||
'@atproto/lex-json': 0.1.3
|
||||
'@atproto/syntax': 0.6.4
|
||||
'@atproto/lex-data': 0.1.1
|
||||
'@atproto/lex-json': 0.1.0
|
||||
'@atproto/syntax': 0.6.1
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/lex-data@0.1.4':
|
||||
'@atproto/lex-data@0.1.1':
|
||||
dependencies:
|
||||
multiformats: 13.4.2
|
||||
tslib: 2.8.1
|
||||
uint8arrays: 5.1.1
|
||||
unicode-segmenter: 0.14.5
|
||||
|
||||
'@atproto/lex-json@0.1.3':
|
||||
'@atproto/lex-json@0.1.0':
|
||||
dependencies:
|
||||
'@atproto/lex-data': 0.1.4
|
||||
'@atproto/lex-data': 0.1.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@atproto/lexicon@0.7.4':
|
||||
'@atproto/lexicon@0.7.1':
|
||||
dependencies:
|
||||
'@atproto/common-web': 0.5.3
|
||||
'@atproto/syntax': 0.6.4
|
||||
'@atproto/common-web': 0.5.0
|
||||
'@atproto/syntax': 0.6.1
|
||||
multiformats: 13.4.2
|
||||
zod: 3.25.76
|
||||
|
||||
'@atproto/syntax@0.6.4':
|
||||
'@atproto/syntax@0.6.1':
|
||||
dependencies:
|
||||
iso-datestring-validator: 2.2.2
|
||||
tslib: 2.8.1
|
||||
|
||||
'@atproto/xrpc@0.8.3':
|
||||
'@atproto/xrpc@0.8.0':
|
||||
dependencies:
|
||||
'@atproto/lexicon': 0.7.4
|
||||
'@atproto/lexicon': 0.7.1
|
||||
zod: 3.25.76
|
||||
|
||||
'@babel/code-frame@7.10.4':
|
||||
@@ -14794,11 +14781,6 @@ snapshots:
|
||||
jest-message-util: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
|
||||
expo-age-range@0.2.18(patch_hash=c325225749993424461eeece1d97a99b19c00da2ebc958a73c12e4eca0c39306)(expo@54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)):
|
||||
dependencies:
|
||||
expo: 54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
react-native: 0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
||||
|
||||
expo-application@7.0.8(expo@54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)):
|
||||
dependencies:
|
||||
expo: 54.0.34(@babel/core@7.29.0)(react-native-webview@13.15.0(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||
@@ -17030,7 +17012,7 @@ snapshots:
|
||||
|
||||
node-releases@2.0.44: {}
|
||||
|
||||
node@runtime:24.18.0: {}
|
||||
node@runtime:24.15.0: {}
|
||||
|
||||
normalize-path@3.0.0: {}
|
||||
|
||||
@@ -17891,7 +17873,7 @@ snapshots:
|
||||
react: 19.1.0
|
||||
react-native: 0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
||||
|
||||
react-native-keyboard-controller@1.21.8(patch_hash=ac52bf7502ff3ad34a8594b5e1a916b96bf87a2523b6abc87c31f03607d52271)(react-native-reanimated@3.19.1(patch_hash=97a1967f37a4213fbab59e1fd59a1bf859b5efc79af5e1b528a47fe488e6c5d6)(@babel/core@7.29.0)(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0):
|
||||
react-native-keyboard-controller@1.21.8(patch_hash=2f6791837622fb391c3e41fc044b91ddedbe503da14da86165ee0a73924b05f1)(react-native-reanimated@3.19.1(patch_hash=97a1967f37a4213fbab59e1fd59a1bf859b5efc79af5e1b528a47fe488e6c5d6)(@babel/core@7.29.0)(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0))(react-native@0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0):
|
||||
dependencies:
|
||||
react: 19.1.0
|
||||
react-native: 0.81.5(patch_hash=2656ac6deb71b92a4df4af4593d13ace6a5740936432e5e7e8ef32bc3cd05194)(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
||||
|
||||
@@ -20,7 +20,6 @@ allowBuilds:
|
||||
'unrs-resolver': true
|
||||
patchedDependencies:
|
||||
'@sentry/react-native@6.20.0': patches/@sentry__react-native@6.20.0.patch
|
||||
expo-age-range@0.2.18: patches/expo-age-range@0.2.18.patch
|
||||
'expo-glass-effect@55.0.8': patches/expo-glass-effect@55.0.8.patch
|
||||
'expo-haptics@15.0.8': patches/expo-haptics@15.0.8.patch
|
||||
'expo-image-picker@17.0.11': patches/expo-image-picker@17.0.11.patch
|
||||
|
||||
@@ -124,7 +124,7 @@ function InnerApp() {
|
||||
await features.init
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn(`session: resume failed`, {message: e})
|
||||
logger.error(`session: resume failed`, {message: e})
|
||||
} finally {
|
||||
setIsReady(true)
|
||||
}
|
||||
+1
-1
@@ -103,7 +103,7 @@ function InnerApp() {
|
||||
await features.init
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn('session: resumeSession failed', {message: e})
|
||||
logger.error('session: resumeSession failed', {message: e})
|
||||
} finally {
|
||||
setIsReady(true)
|
||||
}
|
||||
|
||||
+5
-2
@@ -30,7 +30,7 @@ import {
|
||||
} from '#/lib/hooks/useNotificationHandler'
|
||||
import {useWebScrollRestoration} from '#/lib/hooks/useWebScrollRestoration'
|
||||
import {useCallOnce} from '#/lib/once'
|
||||
import {buildStateObject, getCurrentRoute} from '#/lib/routes/helpers'
|
||||
import {buildStateObject} from '#/lib/routes/helpers'
|
||||
import {
|
||||
type AllNavigatorParams,
|
||||
type BottomTabNavigatorParams,
|
||||
@@ -783,7 +783,10 @@ const LINKING = {
|
||||
|
||||
getPathFromState(state: State) {
|
||||
// find the current node in the navigation tree
|
||||
const node = getCurrentRoute(state)
|
||||
let node = state.routes[state.index || 0]
|
||||
while (node.state?.routes && typeof node.state?.index === 'number') {
|
||||
node = node.state?.routes[node.state?.index]
|
||||
}
|
||||
|
||||
// build the path
|
||||
const route = router.matchName(node.name)
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {createStaticClick, SimpleInlineLinkText} from '#/components/Link'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_IOS} from '#/env'
|
||||
|
||||
/**
|
||||
* Explains what sharing on-device age signals reveals, shown alongside the
|
||||
* "Share age range" button on the age assurance surfaces (the no-access screen
|
||||
* and the account settings card).
|
||||
*
|
||||
* Platform-split so the copy can name the OS account the age range comes from
|
||||
* (Apple Account vs Google Account) and reassure users that only a range is
|
||||
* shared. Device signals are only supported on iOS and Android, so these are
|
||||
* the only two cases.
|
||||
*/
|
||||
export function DeviceSignalsNotice({onPressKws}: {onPressKws: () => void}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
|
||||
return (
|
||||
<Text style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
||||
{IS_IOS ? (
|
||||
<Trans comment="Shown next to the 'Share age range' button when on-device age verification is available. KWS is the name of a third-party verification partner.">
|
||||
Sharing your age range reveals only the range associated with your
|
||||
Apple Account – for example, that you’re at least 18.{' '}
|
||||
<Text style={[a.text_sm, a.font_bold]}>
|
||||
Your exact age and birthday are never shared,
|
||||
</Text>{' '}
|
||||
and this data never leaves this device. Therefore, it only enables
|
||||
access on this device. Alternatively,{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Verify now using KWS`}
|
||||
{...createStaticClick(() => {
|
||||
onPressKws()
|
||||
})}>
|
||||
you can use our trusted partner, KWS
|
||||
</SimpleInlineLinkText>
|
||||
, to complete your verification and enable access on all platforms.
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans comment="Shown next to the 'Share age range' button when on-device age verification is available. KWS is the name of a third-party verification partner.">
|
||||
Sharing your age range reveals only the range associated with your
|
||||
Google Account – for example, that you’re at least 18.{' '}
|
||||
<Text style={[a.text_sm, a.font_bold]}>
|
||||
Your exact age and birthday are never shared,
|
||||
</Text>{' '}
|
||||
and this data never leaves this device. Therefore, it only enables
|
||||
access on this device. Alternatively,{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Verify now using KWS`}
|
||||
{...createStaticClick(() => {
|
||||
onPressKws()
|
||||
})}>
|
||||
you can use our trusted partner, KWS
|
||||
</SimpleInlineLinkText>
|
||||
, to complete your verification and enable access on all platforms.
|
||||
</Trans>
|
||||
)}
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
import {useCallback, useEffect} from 'react'
|
||||
import {ScrollView, View} from 'react-native'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
import {
|
||||
SupportCode,
|
||||
useCreateSupportLink,
|
||||
} from '#/lib/hooks/useCreateSupportLink'
|
||||
import {dateDiff, useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
|
||||
import {useIsBirthdateUpdateAllowed} from '#/state/birthdate'
|
||||
import {useSessionApi} from '#/state/session'
|
||||
@@ -21,60 +27,44 @@ import {DeviceLocationRequestDialog} from '#/components/dialogs/DeviceLocationRe
|
||||
import {Full as Logo} from '#/components/icons/Logo'
|
||||
import {ShieldCheck_Stroke2_Corner0_Rounded as ShieldIcon} from '#/components/icons/Shield'
|
||||
import {createStaticClick, SimpleInlineLinkText} from '#/components/Link'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {Outlet as PortalOutlet} from '#/components/Portal'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {BottomSheetOutlet} from '#/../modules/bottom-sheet'
|
||||
import {useAgeAssurance} from '#/ageAssurance'
|
||||
import {DeviceSignalsNotice} from '#/ageAssurance/components/DeviceSignalsNotice'
|
||||
import {useAgeAssuranceServerDataContext} from '#/ageAssurance/data'
|
||||
import {useComputeAgeAssuranceRegionAccess} from '#/ageAssurance/useComputeAgeAssuranceRegionAccess'
|
||||
import {useAgeAssuranceVerificationFlow} from '#/ageAssurance/useVerificationFlow'
|
||||
import {
|
||||
canBirthdateUpdateIncreaseAccess,
|
||||
createGeolocationString,
|
||||
isLegacyBirthdateBug,
|
||||
useAgeAssuranceRegionConfig,
|
||||
} from '#/ageAssurance/util'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||
import {useDeviceGeolocationApi, useGeolocation} from '#/geolocation'
|
||||
import {useDeviceGeolocationApi} from '#/geolocation'
|
||||
|
||||
const textStyles = [a.text_md, a.leading_snug]
|
||||
|
||||
export function NoAccessScreen() {
|
||||
const t = useTheme()
|
||||
const {t: l, i18n} = useLingui()
|
||||
const {_} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const {gtPhone} = useBreakpoints()
|
||||
const insets = useSafeAreaInsets()
|
||||
const birthdateControl = useDialogControl()
|
||||
const deactivateAccountControl = useDialogControl()
|
||||
const deleteAccountControl = useDialogControl()
|
||||
const {metadata, deviceSignals} = useAgeAssuranceServerDataContext()
|
||||
const {metadata} = useAgeAssuranceServerDataContext()
|
||||
const region = useAgeAssuranceRegionConfig()
|
||||
const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
|
||||
const {logoutCurrentAccount} = useSessionApi()
|
||||
const geolocation = useGeolocation()
|
||||
const {setDeviceGeolocation} = useDeviceGeolocationApi()
|
||||
const locationControl = Dialog.useDialogControl()
|
||||
const computeAgeAssuranceRegionAccess = useComputeAgeAssuranceRegionAccess()
|
||||
const createSupportLink = useCreateSupportLink()
|
||||
|
||||
const aa = useAgeAssurance()
|
||||
const isBlocked = aa.state.status === aa.Status.Blocked
|
||||
const isAARegion = !!region
|
||||
const hasDeclaredAge = aa.flags.hasDeclaredAge
|
||||
const birthdateMightIncreaseAccess = Boolean(
|
||||
region &&
|
||||
canBirthdateUpdateIncreaseAccess({region, metadata, deviceSignals}),
|
||||
)
|
||||
const hasDeclaredAge = metadata?.declaredAge !== undefined
|
||||
const canUpdateBirthday =
|
||||
(isBirthdateUpdateAllowed ||
|
||||
isLegacyBirthdateBug(metadata?.birthdate || '')) &&
|
||||
birthdateMightIncreaseAccess
|
||||
const geolocationString = createGeolocationString(geolocation, i18n.locale)
|
||||
const isUsingGPS = !!geolocation.deviceGeolocation?.countryCode && IS_NATIVE
|
||||
isBirthdateUpdateAllowed || isLegacyBirthdateBug(metadata?.birthdate || '')
|
||||
|
||||
useEffect(() => {
|
||||
// just counting overall hits here
|
||||
@@ -116,7 +106,7 @@ export function NoAccessScreen() {
|
||||
<Trans>
|
||||
If you believe your birthdate is incorrect, you can update it by{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Click here to update your birthdate`}
|
||||
label={_(msg`Click here to update your birthdate`)}
|
||||
style={[textStyles]}
|
||||
{...createStaticClick(() => {
|
||||
ax.metric('ageAssurance:noAccessScreen:openBirthdateDialog', {})
|
||||
@@ -130,7 +120,20 @@ export function NoAccessScreen() {
|
||||
|
||||
{orgAdmonition}
|
||||
</>
|
||||
) : null
|
||||
) : (
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
If you believe your birthdate is incorrect, please{' '}
|
||||
<SimpleInlineLinkText
|
||||
to={createSupportLink({code: SupportCode.AA_BIRTHDATE})}
|
||||
label={_(msg`Click here to contact our support team`)}
|
||||
style={[textStyles]}>
|
||||
contact our support team
|
||||
</SimpleInlineLinkText>
|
||||
.
|
||||
</Trans>
|
||||
</Text>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -161,147 +164,80 @@ export function NoAccessScreen() {
|
||||
<AgeAssuranceBadge />
|
||||
</View>
|
||||
|
||||
<View style={[a.gap_lg]}>
|
||||
{hasDeclaredAge ? (
|
||||
<>
|
||||
{isAARegion ? (
|
||||
<>
|
||||
<View style={[a.gap_lg]}>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>Hey there!</Trans>
|
||||
</Text>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
You are accessing Bluesky from a region that legally
|
||||
requires us to verify your age before allowing you
|
||||
to access the app.
|
||||
</Trans>
|
||||
</Text>
|
||||
|
||||
{region && geolocationString && (
|
||||
<Text style={[textStyles]}>
|
||||
{isUsingGPS ? (
|
||||
<Trans>
|
||||
Based on your device's location, we think you're
|
||||
in{' '}
|
||||
<Text style={[textStyles, a.font_bold]}>
|
||||
{geolocationString}
|
||||
</Text>
|
||||
.
|
||||
</Trans>
|
||||
) : (
|
||||
<>
|
||||
<Trans>
|
||||
Based on your network, we think you're in{' '}
|
||||
<Text style={[textStyles, a.font_bold]}>
|
||||
{geolocationString}
|
||||
</Text>
|
||||
. This estimate may be inaccurate if you're
|
||||
using a VPN.
|
||||
</Trans>
|
||||
</>
|
||||
)}
|
||||
{IS_NATIVE && (
|
||||
<>
|
||||
{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Update your location`}
|
||||
{...createStaticClick(() => {
|
||||
locationControl.open()
|
||||
})}
|
||||
style={[textStyles]}>
|
||||
<Trans>
|
||||
Tap here to update your location with GPS.
|
||||
</Trans>
|
||||
</SimpleInlineLinkText>
|
||||
<DeviceLocationRequestDialog
|
||||
control={locationControl}
|
||||
onLocationAcquired={props => {
|
||||
const access =
|
||||
computeAgeAssuranceRegionAccess(
|
||||
props.geolocation,
|
||||
)
|
||||
if (access !== aa.Access.Full) {
|
||||
props.disableDialogAction()
|
||||
props.setDialogError(
|
||||
l`We're sorry, but based on your device's location, you are currently located in a region that requires age assurance.`,
|
||||
)
|
||||
} else {
|
||||
props.closeDialog(() => {
|
||||
// set this after close!
|
||||
setDeviceGeolocation(props.geolocation)
|
||||
Toast.show(l`Thanks! You're all set.`, {
|
||||
type: 'success',
|
||||
})
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{!aa.flags.isOverRegionMinAccessAge && (
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
Unfortunately, your declared age indicates that
|
||||
you are not old enough to access Bluesky in your
|
||||
region.
|
||||
</Trans>
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{!isBlocked && birthdateUpdateText}
|
||||
</View>
|
||||
|
||||
{aa.flags.isOverRegionMinAccessAge && <AccessSection />}
|
||||
</>
|
||||
) : (
|
||||
{hasDeclaredAge ? (
|
||||
<>
|
||||
{isAARegion ? (
|
||||
<>
|
||||
<View style={[a.gap_lg]}>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>Hey there!</Trans>
|
||||
</Text>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
Unfortunately, the birthdate you have saved to your
|
||||
profile makes you too young to access Bluesky.
|
||||
You are accessing Bluesky from a region that legally
|
||||
requires us to verify your age before allowing you to
|
||||
access the app.
|
||||
</Trans>
|
||||
</Text>
|
||||
|
||||
{birthdateUpdateText}
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<View style={[a.gap_lg]}>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>Hi there!</Trans>
|
||||
</Text>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
In order to provide an age-appropriate experience, we need
|
||||
to know your birthdate. This is a one-time thing, and your
|
||||
data will be kept private.
|
||||
</Trans>
|
||||
</Text>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
Set your birthdate below and we'll get you back to posting
|
||||
and exploring in no time!
|
||||
</Trans>
|
||||
</Text>
|
||||
<Button
|
||||
color="primary"
|
||||
size="large"
|
||||
label={l`Click here to update your birthdate`}
|
||||
onPress={() => birthdateControl.open()}>
|
||||
<ButtonText>
|
||||
<Trans>Add your birthdate</Trans>
|
||||
</ButtonText>
|
||||
</Button>
|
||||
{!aa.flags.isOverRegionMinAccessAge && (
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
Unfortunately, your declared age indicates that you
|
||||
are not old enough to access Bluesky in your region.
|
||||
</Trans>
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{orgAdmonition}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
{!isBlocked && birthdateUpdateText}
|
||||
</View>
|
||||
|
||||
{aa.flags.isOverRegionMinAccessAge && <AccessSection />}
|
||||
</>
|
||||
) : (
|
||||
<View style={[a.gap_lg]}>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
Unfortunately, the birthdate you have saved to your
|
||||
profile makes you too young to access Bluesky.
|
||||
</Trans>
|
||||
</Text>
|
||||
|
||||
{birthdateUpdateText}
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<View style={[a.gap_lg]}>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>Hi there!</Trans>
|
||||
</Text>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
In order to provide an age-appropriate experience, we need
|
||||
to know your birthdate. This is a one-time thing, and your
|
||||
data will be kept private.
|
||||
</Trans>
|
||||
</Text>
|
||||
<Text style={[textStyles]}>
|
||||
<Trans>
|
||||
Set your birthdate below and we'll get you back to posting
|
||||
and exploring in no time!
|
||||
</Trans>
|
||||
</Text>
|
||||
<Button
|
||||
color="primary"
|
||||
size="large"
|
||||
label={_(msg`Click here to update your birthdate`)}
|
||||
onPress={() => birthdateControl.open()}>
|
||||
<ButtonText>
|
||||
<Trans>Add your birthdate</Trans>
|
||||
</ButtonText>
|
||||
</Button>
|
||||
|
||||
{orgAdmonition}
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View style={[a.pt_lg, a.gap_xl, {maxWidth: 280}]}>
|
||||
<Logo width={120} textFill={t.atoms.text.color} />
|
||||
@@ -315,7 +251,7 @@ export function NoAccessScreen() {
|
||||
<Trans>
|
||||
To log out,{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Click here to log out`}
|
||||
label={_(msg`Click here to log out`)}
|
||||
{...createStaticClick(() => {
|
||||
onPressLogout()
|
||||
})}
|
||||
@@ -324,7 +260,7 @@ export function NoAccessScreen() {
|
||||
</SimpleInlineLinkText>
|
||||
. Or if you’d prefer, you can{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Click here to delete your account`}
|
||||
label={_(msg`Click here to delete your account`)}
|
||||
{...createStaticClick(() => {
|
||||
ax.metric(
|
||||
'ageAssurance:noAccessScreen:openDeleteAccountDialog',
|
||||
@@ -363,11 +299,14 @@ export function NoAccessScreen() {
|
||||
|
||||
function AccessSection() {
|
||||
const t = useTheme()
|
||||
const {t: l, i18n} = useLingui()
|
||||
const {_, i18n} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const control = useDialogControl()
|
||||
const appealControl = Dialog.useDialogControl()
|
||||
const locationControl = Dialog.useDialogControl()
|
||||
const getTimeAgo = useGetTimeAgo()
|
||||
const {setDeviceGeolocation} = useDeviceGeolocationApi()
|
||||
const computeAgeAssuranceRegionAccess = useComputeAgeAssuranceRegionAccess()
|
||||
|
||||
const aa = useAgeAssurance()
|
||||
const {status, lastInitiatedAt} = aa.state
|
||||
@@ -379,15 +318,6 @@ function AccessSection() {
|
||||
const diff = lastInitiatedAt
|
||||
? dateDiff(lastInitiatedAt, new Date(), 'down')
|
||||
: null
|
||||
const {
|
||||
onPressVerify,
|
||||
openInitDialog,
|
||||
isVerifying,
|
||||
verifyCta,
|
||||
deviceSignalsFailed,
|
||||
} = useAgeAssuranceVerificationFlow({initDialogControl: control})
|
||||
const useDeviceSignals =
|
||||
aa.flags.allowsDeviceVerification && !deviceSignalsFailed
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -401,7 +331,7 @@ function AccessSection() {
|
||||
You are currently unable to access Bluesky's Age Assurance flow.
|
||||
Please{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={l`Contact our moderation team`}
|
||||
label={_(msg`Contact our moderation team`)}
|
||||
{...createStaticClick(() => {
|
||||
appealControl.open()
|
||||
ax.metric('ageAssurance:appealDialogOpen', {})
|
||||
@@ -415,22 +345,26 @@ function AccessSection() {
|
||||
<>
|
||||
<View style={[a.gap_md]}>
|
||||
<Button
|
||||
label={verifyCta}
|
||||
label={_(msg`Verify now`)}
|
||||
size="large"
|
||||
color={
|
||||
hasInitiated || aa.flags.hasSharedDeviceSignals
|
||||
? 'secondary'
|
||||
: 'primary'
|
||||
}
|
||||
disabled={isVerifying}
|
||||
onPress={() => void onPressVerify()}>
|
||||
<ButtonIcon icon={isVerifying ? Loader : ShieldIcon} />
|
||||
<ButtonText>{verifyCta}</ButtonText>
|
||||
color={hasInitiated ? 'secondary' : 'primary'}
|
||||
onPress={() => {
|
||||
control.open()
|
||||
ax.metric('ageAssurance:initDialogOpen', {
|
||||
hasInitiatedPreviously: hasInitiated,
|
||||
})
|
||||
}}>
|
||||
<ButtonIcon icon={ShieldIcon} />
|
||||
<ButtonText>
|
||||
{hasInitiated ? (
|
||||
<Trans>Verify again</Trans>
|
||||
) : (
|
||||
<Trans>Verify now</Trans>
|
||||
)}
|
||||
</ButtonText>
|
||||
</Button>
|
||||
|
||||
{useDeviceSignals ? (
|
||||
<DeviceSignalsNotice onPressKws={openInitDialog} />
|
||||
) : lastInitiatedAt && timeAgo && diff ? (
|
||||
{lastInitiatedAt && timeAgo && diff ? (
|
||||
<Text
|
||||
style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}
|
||||
title={i18n.date(lastInitiatedAt, {
|
||||
@@ -446,12 +380,56 @@ function AccessSection() {
|
||||
) : (
|
||||
<Text
|
||||
style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
||||
<Trans>Age assurance only takes a few minutes.</Trans>
|
||||
<Trans>Age assurance only takes a few minutes</Trans>
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
<View style={[a.gap_xs]}>
|
||||
{IS_NATIVE && (
|
||||
<>
|
||||
<Admonition>
|
||||
<Trans>
|
||||
Is your location not accurate?{' '}
|
||||
<SimpleInlineLinkText
|
||||
label={_(msg`Update your location`)}
|
||||
{...createStaticClick(() => {
|
||||
locationControl.open()
|
||||
})}>
|
||||
Tap here to update your location with GPS.
|
||||
</SimpleInlineLinkText>{' '}
|
||||
</Trans>
|
||||
</Admonition>
|
||||
|
||||
<DeviceLocationRequestDialog
|
||||
control={locationControl}
|
||||
onLocationAcquired={props => {
|
||||
const access = computeAgeAssuranceRegionAccess(
|
||||
props.geolocation,
|
||||
)
|
||||
if (access !== aa.Access.Full) {
|
||||
props.disableDialogAction()
|
||||
props.setDialogError(
|
||||
_(
|
||||
msg`We're sorry, but based on your device's location, you are currently located in a region that requires age assurance.`,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
props.closeDialog(() => {
|
||||
// set this after close!
|
||||
setDeviceGeolocation(props.geolocation)
|
||||
Toast.show(_(msg`Thanks! You're all set.`), {
|
||||
type: 'success',
|
||||
})
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -4,29 +4,12 @@ import {
|
||||
} from '@atproto/api'
|
||||
|
||||
import {AgeAssuranceAccess} from '#/ageAssurance/types'
|
||||
import {ANDROID_API_LEVEL, IOS_MAJOR_VERSION, IS_ANDROID, IS_IOS} from '#/env'
|
||||
|
||||
/**
|
||||
* Minimum age required to access the app at all.
|
||||
*/
|
||||
export const MIN_ACCESS_AGE = 13
|
||||
|
||||
/**
|
||||
* Whether the current device can provide the native on-device age signals we
|
||||
* use for age assurance (via `expo-age-range`). We gate on OS version because
|
||||
* the underlying platform APIs are only available on:
|
||||
*
|
||||
* - iOS 26.0+ (Declared Age Range API)
|
||||
* https://developer.apple.com/documentation/declaredagerange/
|
||||
* - Android 6.0 / API level 23+ (Play Age Signals API)
|
||||
* https://developer.android.com/google/play/age-signals/use-age-signals-api
|
||||
*
|
||||
* On unsupported platforms/versions (including web) this is `false`, so we skip
|
||||
* the device flow and fall back to KWS.
|
||||
*/
|
||||
export const DEVICE_SIGNALS_SUPPORTED: boolean =
|
||||
(IS_IOS && IOS_MAJOR_VERSION >= 26) || (IS_ANDROID && ANDROID_API_LEVEL >= 23)
|
||||
|
||||
export const FALLBACK_REGION_CONFIG: AppBskyAgeassuranceDefs.ConfigRegion = {
|
||||
countryCode: '*',
|
||||
regionCode: undefined,
|
||||
|
||||
+7
-191
@@ -1,11 +1,11 @@
|
||||
import {createContext, useCallback, useContext, useEffect, useMemo} from 'react'
|
||||
import * as AgeRange from 'expo-age-range'
|
||||
import {
|
||||
type AppBskyAgeassuranceDefs,
|
||||
type AppBskyAgeassuranceGetConfig,
|
||||
type AppBskyAgeassuranceGetState,
|
||||
AtpAgent,
|
||||
type ChatBskyActorDeclaration,
|
||||
getAgeAssuranceRegionConfig,
|
||||
} from '@atproto/api'
|
||||
import {createAsyncStoragePersister} from '@tanstack/query-async-storage-persister'
|
||||
import {focusManager, QueryClient, useQuery} from '@tanstack/react-query'
|
||||
@@ -22,21 +22,14 @@ import {
|
||||
} from '#/state/birthdate'
|
||||
import {fetchActorDeclarationRecord} from '#/state/queries/messages/actor-declaration'
|
||||
import {useAgent, useSession} from '#/state/session'
|
||||
import {DEVICE_SIGNALS_SUPPORTED} from '#/ageAssurance/const'
|
||||
import * as debug from '#/ageAssurance/debug'
|
||||
import {logger} from '#/ageAssurance/logger'
|
||||
import {type AgeAssuranceMetadata} from '#/ageAssurance/types'
|
||||
import {
|
||||
type AgeAssuranceDeviceSignals,
|
||||
type AgeAssuranceMetadata,
|
||||
} from '#/ageAssurance/types'
|
||||
import {
|
||||
createRegionKey,
|
||||
getAgeAssuranceRegionConfigForGeolocation,
|
||||
getBirthdateStringFromAge,
|
||||
isLegacyBirthdateBug,
|
||||
} from '#/ageAssurance/util'
|
||||
import {IS_DEV} from '#/env'
|
||||
import {useGeolocation} from '#/geolocation'
|
||||
import {device} from '#/storage'
|
||||
|
||||
/**
|
||||
@@ -317,7 +310,10 @@ export function useServerStateQuery() {
|
||||
const isAArequired = Boolean(
|
||||
config &&
|
||||
geolocation &&
|
||||
getAgeAssuranceRegionConfigForGeolocation(config, geolocation),
|
||||
!!getAgeAssuranceRegionConfig(config, {
|
||||
countryCode: geolocation?.countryCode ?? '',
|
||||
regionCode: geolocation?.regionCode,
|
||||
}),
|
||||
)
|
||||
|
||||
// only refetch when needed
|
||||
@@ -489,173 +485,6 @@ export function useOtherRequiredDataQuery() {
|
||||
)
|
||||
}
|
||||
|
||||
export function createDeviceSignalsQueryKey({did}: {did: string}) {
|
||||
return ['device-signals', did]
|
||||
}
|
||||
/**
|
||||
* Prompts the native OS age API. Returns the raw response, or undefined if the
|
||||
* platform can't provide one.
|
||||
*
|
||||
* Native-only: on web `expo-age-range` returns a misleading default (e.g.
|
||||
* `{lowerBound: 18}`), so we never call it there — web users fall back to KWS.
|
||||
*
|
||||
* If this method throws for whatever reason, we catch and log the error and
|
||||
* return undefined. The caller should treat undefined as "no device signals
|
||||
* available" and fall back to KWS.
|
||||
*/
|
||||
export async function getDeviceSignals(): Promise<
|
||||
AgeRange.AgeRangeResponse | undefined
|
||||
> {
|
||||
if (debug.enabled && debug.useMockDeviceSignalsAPIResponse)
|
||||
return debug.resolve(debug.deviceSignals)
|
||||
if (!DEVICE_SIGNALS_SUPPORTED) return undefined
|
||||
try {
|
||||
return await AgeRange.requestAgeRangeAsync({
|
||||
threshold1: 13,
|
||||
threshold2: 16,
|
||||
threshold3: 18,
|
||||
})
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
logger.error(`getDeviceSignals: failed to get device signals`, {
|
||||
safeMessage: e.message,
|
||||
})
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The raw region-keyed map of device signals (all regions). Used internally by
|
||||
* the query + writer, which operate on the full map. Most consumers want
|
||||
* {@link getDeviceSignalsFromCacheForRegion}, which resolves to the
|
||||
* current region.
|
||||
*/
|
||||
export function getDeviceSignalsMapFromCache({
|
||||
did,
|
||||
}: {
|
||||
did: string
|
||||
}): AgeAssuranceDeviceSignals | undefined {
|
||||
return qc.getQueryData<AgeAssuranceDeviceSignals>(
|
||||
createDeviceSignalsQueryKey({did}),
|
||||
)
|
||||
}
|
||||
/**
|
||||
* Returns the device signals for the region the user is currently in, or
|
||||
* undefined.
|
||||
*/
|
||||
export function getDeviceSignalsFromCacheForRegion({
|
||||
did,
|
||||
region,
|
||||
}: {
|
||||
did: string
|
||||
region: AppBskyAgeassuranceDefs.ConfigRegion
|
||||
}): AgeRange.AgeRangeResponse | undefined {
|
||||
const regionKey = createRegionKey(region)
|
||||
return getDeviceSignalsMapFromCache({did})?.[regionKey]
|
||||
}
|
||||
/**
|
||||
* Stores freshly granted device signals into the (persisted) cache under the
|
||||
* region they were captured in, merging with any signals already stored for
|
||||
* other regions. Notifies the disabled `useDeviceSignalsQuery` observer so the
|
||||
* AA state recomputes.
|
||||
*
|
||||
* Device assurance is client-side only (it can't be verified server-side) and
|
||||
* region-bound — keying by region is what binds it. See
|
||||
* {@link AgeAssuranceDeviceSignals}.
|
||||
*/
|
||||
export function setDeviceSignalsForRegion({
|
||||
did,
|
||||
region,
|
||||
signals,
|
||||
}: {
|
||||
did: string
|
||||
region: {countryCode: string; regionCode?: string}
|
||||
signals: AgeRange.AgeRangeResponse
|
||||
}) {
|
||||
const regionKey = createRegionKey(region)
|
||||
qc.setQueryData<AgeAssuranceDeviceSignals | undefined>(
|
||||
createDeviceSignalsQueryKey({did}),
|
||||
prev => ({...prev, [regionKey]: signals}),
|
||||
)
|
||||
}
|
||||
export async function prefetchDeviceSignals({agent}: {agent: AtpAgent}) {
|
||||
const did = getDidFromAgentSession(agent)
|
||||
if (!did) return
|
||||
|
||||
/**
|
||||
* Device signals are restored from the persisted cache only — we never call
|
||||
* the native age API during prefetch, since that would prompt the OS for
|
||||
* users who haven't opted in. Awaiting cache hydration ensures any previously
|
||||
* granted signals are available before the AA state is first computed. The
|
||||
* user can (re)grant access later via the NoAccessScreen verify flow.
|
||||
*/
|
||||
await cacheHydrationPromise
|
||||
const cached = getDeviceSignalsMapFromCache({did})
|
||||
logger.debug(
|
||||
`prefetchDeviceSignals: ${cached ? 'restored from cache' : 'no cache'}`,
|
||||
cached,
|
||||
)
|
||||
|
||||
/*
|
||||
* Future silent-refresh path (intentionally left commented out). The OS
|
||||
* returns a previously granted age range without re-prompting, so once a
|
||||
* region is already cached we could refresh it on load instead of waiting for
|
||||
* the user to re-verify. We don't do this yet because the native call can
|
||||
* still surface a prompt for users who never opted in, so it must stay gated
|
||||
* behind an explicit grant for now.
|
||||
*
|
||||
* const geolocation = device.get(['mergedGeolocation'])
|
||||
* if (cached && geolocation?.countryCode) {
|
||||
* const signals = await getDeviceSignals()
|
||||
* if (signals) {
|
||||
* setDeviceSignalsForRegion({did, region: geolocation, signals})
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
}
|
||||
export function useDeviceSignalsQuery() {
|
||||
const agent = useAgent()
|
||||
const did = getDidFromAgentSession(agent)
|
||||
const {data: config} = useConfigQuery()
|
||||
const geolocation = useGeolocation()
|
||||
/*
|
||||
* Resolve the matched config region (no fallback) and key off it, so the read
|
||||
* stays symmetric with the write (see `setDeviceSignalsForRegion`). When
|
||||
* geolocation matches no AA region there's no device grant to surface.
|
||||
*/
|
||||
const regionConfig = config
|
||||
? getAgeAssuranceRegionConfigForGeolocation(config, geolocation)
|
||||
: undefined
|
||||
const regionKey = regionConfig ? createRegionKey(regionConfig) : undefined
|
||||
|
||||
return useQuery(
|
||||
{
|
||||
/**
|
||||
* Disabled so we never auto-call the native age API on load — that would
|
||||
* prompt the OS for every logged-in user. We restore from the persisted
|
||||
* cache (via `initialData`) and otherwise only update reactively when the
|
||||
* user explicitly verifies (see `getDeviceSignals` +
|
||||
* `setDeviceSignalsForRegion` in the NoAccessScreen verify flow).
|
||||
*
|
||||
* A future enhancement could silently refresh here when already cached,
|
||||
* since the OS returns the granted result without re-prompting.
|
||||
*/
|
||||
enabled: false,
|
||||
initialData: getDeviceSignalsMapFromCache({did: did!}),
|
||||
queryKey: createDeviceSignalsQueryKey({did: did!}),
|
||||
queryFn() {
|
||||
// Never auto-fetches (see `enabled: false`); the verify flow writes the
|
||||
// region-keyed signals directly via `setDeviceSignalsForRegion`.
|
||||
return getDeviceSignalsMapFromCache({did: did!})
|
||||
},
|
||||
// The cache holds the full region-keyed map (the writer merges into it);
|
||||
// `select` resolves it to the current region for consumers without
|
||||
// mutating the cached value.
|
||||
select: map => (map && regionKey ? map[regionKey] : undefined),
|
||||
},
|
||||
qc,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to prefetch all age assurance data from the server.
|
||||
*/
|
||||
@@ -665,7 +494,6 @@ export function prefetchAgeAssuranceServerData({agent}: {agent: AtpAgent}) {
|
||||
configPrefetchPromise,
|
||||
prefetchServerState({agent}),
|
||||
prefetchOtherRequiredData({agent}),
|
||||
prefetchDeviceSignals({agent}),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -697,14 +525,6 @@ export type AgeAssuranceServerData = {
|
||||
*/
|
||||
state: AppBskyAgeassuranceDefs.State | undefined
|
||||
metadata: AgeAssuranceMetadata | undefined
|
||||
/**
|
||||
* The native on-device age signals for the region the user is currently in,
|
||||
* if they've granted access there. Already resolved from the region-keyed
|
||||
* cache (see `getDeviceSignalsFromCacheForRegion`), so a grant from
|
||||
* another region won't appear here. Only consumed for regions that permit
|
||||
* device verification.
|
||||
*/
|
||||
deviceSignals: AgeRange.AgeRangeResponse | undefined
|
||||
}
|
||||
const AgeAssuranceServerDataContext = createContext<AgeAssuranceServerData>({
|
||||
config: undefined,
|
||||
@@ -714,7 +534,6 @@ const AgeAssuranceServerDataContext = createContext<AgeAssuranceServerData>({
|
||||
declaredAge: undefined,
|
||||
birthdate: undefined,
|
||||
},
|
||||
deviceSignals: undefined,
|
||||
})
|
||||
export function useAgeAssuranceServerDataContext() {
|
||||
return useContext(AgeAssuranceServerDataContext)
|
||||
@@ -728,8 +547,6 @@ export function AgeAssuranceServerDataProvider({
|
||||
const serverState = useServerStateQuery()
|
||||
const {state, metadata} = serverState.data || {}
|
||||
const {data} = useOtherRequiredDataQuery()
|
||||
// `select` resolves the cached region-keyed map to the current region.
|
||||
const {data: deviceSignals} = useDeviceSignalsQuery()
|
||||
const ctx = useMemo(
|
||||
() => ({
|
||||
config,
|
||||
@@ -742,9 +559,8 @@ export function AgeAssuranceServerDataProvider({
|
||||
: undefined,
|
||||
birthdate: data?.birthdate,
|
||||
},
|
||||
deviceSignals,
|
||||
}),
|
||||
[config, state, data, metadata, deviceSignals],
|
||||
[config, state, data, metadata],
|
||||
)
|
||||
return (
|
||||
<AgeAssuranceServerDataContext.Provider value={ctx}>
|
||||
|
||||
+12
-49
@@ -1,4 +1,3 @@
|
||||
import type * as AgeRange from 'expo-age-range'
|
||||
import {
|
||||
ageAssuranceRuleIDs as ids,
|
||||
type AppBskyAgeassuranceDefs,
|
||||
@@ -18,16 +17,17 @@ export const geolocation: Geolocation | undefined = enabled
|
||||
}
|
||||
: undefined
|
||||
|
||||
export const deviceGeolocation: Geolocation | undefined = enabled
|
||||
? {
|
||||
countryCode: 'AA',
|
||||
regionCode: undefined,
|
||||
...geolocation,
|
||||
}
|
||||
: undefined
|
||||
const deviceGeolocationEnabled = false || IS_E2E
|
||||
export const deviceGeolocation: Geolocation | undefined =
|
||||
enabled && deviceGeolocationEnabled
|
||||
? {
|
||||
countryCode: 'AA',
|
||||
regionCode: undefined,
|
||||
}
|
||||
: undefined
|
||||
|
||||
export const otherRequiredData: OtherRequiredData = {
|
||||
birthdate: new Date(2000, 12, 1).toISOString(),
|
||||
birthdate: new Date(2010, 12, 1).toISOString(),
|
||||
}
|
||||
|
||||
const serverStateEnabled = false || IS_E2E
|
||||
@@ -35,9 +35,9 @@ export const serverState: AppBskyAgeassuranceGetState.OutputSchema | undefined =
|
||||
serverStateEnabled
|
||||
? {
|
||||
state: {
|
||||
lastInitiatedAt: undefined, // new Date(2025, 1, 1).toISOString(),
|
||||
status: 'unknown',
|
||||
access: 'unknown',
|
||||
lastInitiatedAt: new Date(2025, 1, 1).toISOString(),
|
||||
status: 'assured',
|
||||
access: 'full',
|
||||
},
|
||||
metadata: {
|
||||
accountCreatedAt: new Date(2023, 1, 1).toISOString(),
|
||||
@@ -58,26 +58,6 @@ export const config: AppBskyAgeassuranceDefs.Config = {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// On-device verification region. KWS is included as a fallback for
|
||||
// platforms without the native age API (e.g. web) or when the device
|
||||
// result is insufficient.
|
||||
countryCode: 'US',
|
||||
regionCode: 'TX',
|
||||
minAccessAge: 18,
|
||||
additionalVerificationMethods: ['device'],
|
||||
rules: [
|
||||
{
|
||||
age: 18,
|
||||
access: 'full',
|
||||
$type: ids.IfAssuredOverAge,
|
||||
},
|
||||
{
|
||||
access: 'none',
|
||||
$type: ids.Default,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
countryCode: 'GB',
|
||||
minAccessAge: 13,
|
||||
@@ -277,23 +257,6 @@ export const config: AppBskyAgeassuranceDefs.Config = {
|
||||
],
|
||||
}
|
||||
|
||||
/**
|
||||
* When debug is enabled we mock the `deviceSignals` response by default. Set
|
||||
* this to `false` to hit the real native age API (`expo-age-range`) so the OS
|
||||
* age prompt actually shows — useful for testing the device flow on a physical
|
||||
* device.
|
||||
*/
|
||||
export const useMockDeviceSignalsAPIResponse = true
|
||||
export const deviceSignals: AgeRange.AgeRangeResponse | undefined =
|
||||
useMockDeviceSignalsAPIResponse
|
||||
? {
|
||||
// Simulates the OS reporting the user is at least 18. Lower this below
|
||||
// a region's IfAssuredOverAge threshold to exercise the KWS fallback.
|
||||
lowerBound: 16,
|
||||
upperBound: null,
|
||||
}
|
||||
: undefined
|
||||
|
||||
export async function resolve<T>(data: T) {
|
||||
await new Promise(y => setTimeout(y, 500)) // simulate network
|
||||
return data
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {createContext, useCallback, useContext, useMemo} from 'react'
|
||||
|
||||
import {useGetAndRegisterPushToken} from '#/lib/notifications/notifications'
|
||||
import {restrictChatSettings} from '#/state/queries/messages/restrictChatSettings'
|
||||
import {useAgent} from '#/state/session'
|
||||
import {Provider as RedirectOverlayProvider} from '#/ageAssurance/components/RedirectOverlay'
|
||||
import {
|
||||
AgeAssuranceServerDataProvider,
|
||||
@@ -49,12 +51,9 @@ const AgeAssuranceStateContext = createContext<{
|
||||
adultContentDisabled: false,
|
||||
chatDisabled: false,
|
||||
groupChatDisabled: false,
|
||||
hasDeclaredAge: false,
|
||||
isDeclaredUnderAdultAge: false,
|
||||
isOverRegionMinAccessAge: false,
|
||||
isOverAppMinAccessAge: false,
|
||||
allowsDeviceVerification: false,
|
||||
hasSharedDeviceSignals: false,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -78,8 +77,9 @@ export function Provider({children}: {children: React.ReactNode}) {
|
||||
}
|
||||
|
||||
function InnerProvider({children}: {children: React.ReactNode}) {
|
||||
const agent = useAgent()
|
||||
const state = useAgeAssuranceState()
|
||||
const {metadata, deviceSignals} = useAgeAssuranceServerDataContext()
|
||||
const {metadata} = useAgeAssuranceServerDataContext()
|
||||
const regionConfig = useAgeAssuranceRegionConfigWithFallback()
|
||||
const getAndRegisterPushToken = useGetAndRegisterPushToken()
|
||||
|
||||
@@ -89,15 +89,21 @@ function InnerProvider({children}: {children: React.ReactNode}) {
|
||||
state: s,
|
||||
regionConfig,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
})
|
||||
if (flags.isAgeRestricted) {
|
||||
void getAndRegisterPushToken({
|
||||
isAgeRestricted: true,
|
||||
})
|
||||
}
|
||||
if (flags.chatDisabled || flags.groupChatDisabled) {
|
||||
void restrictChatSettings({
|
||||
agent,
|
||||
restrictIncoming: flags.chatDisabled,
|
||||
restrictGroupInvites: flags.groupChatDisabled,
|
||||
})
|
||||
}
|
||||
},
|
||||
[getAndRegisterPushToken, regionConfig, metadata, deviceSignals],
|
||||
[agent, getAndRegisterPushToken, regionConfig, metadata],
|
||||
)
|
||||
useOnAgeAssuranceAccessUpdate(handleAccessUpdate)
|
||||
|
||||
@@ -112,12 +118,11 @@ function InnerProvider({children}: {children: React.ReactNode}) {
|
||||
state,
|
||||
regionConfig,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
}),
|
||||
}
|
||||
logger.debug(`useAgeAssurance`, res)
|
||||
return res
|
||||
}, [state, metadata, regionConfig, deviceSignals])}>
|
||||
}, [state, metadata, regionConfig])}>
|
||||
{children}
|
||||
</AgeAssuranceStateContext.Provider>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {useEffect, useMemo, useState} from 'react'
|
||||
import type * as AgeRange from 'expo-age-range'
|
||||
import {
|
||||
type AppBskyAgeassuranceDefs,
|
||||
computeAgeAssuranceRegionAccess,
|
||||
@@ -9,7 +8,6 @@ import {getAge} from '#/lib/strings/time'
|
||||
import {useSession} from '#/state/session'
|
||||
import {
|
||||
getConfigFromCache,
|
||||
getDeviceSignalsFromCacheForRegion,
|
||||
getOtherRequiredDataFromCache,
|
||||
getServerStateFromCache,
|
||||
useAgeAssuranceServerDataContext,
|
||||
@@ -25,8 +23,6 @@ import {
|
||||
} from '#/ageAssurance/types'
|
||||
import {
|
||||
computeAgeAssuranceFlags,
|
||||
getAgeAssuranceDataFromDeviceSignals,
|
||||
getAgeAssuranceRegionConfigForGeolocation,
|
||||
getAgeAssuranceRegionConfigWithFallback,
|
||||
} from '#/ageAssurance/util'
|
||||
import {type Geolocation, useGeolocation} from '#/geolocation'
|
||||
@@ -43,14 +39,12 @@ function computeAgeAssuranceState({
|
||||
config,
|
||||
state,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
}: {
|
||||
hasSession: boolean
|
||||
geolocation: Geolocation
|
||||
config?: AppBskyAgeassuranceDefs.Config
|
||||
state?: AppBskyAgeassuranceDefs.State
|
||||
metadata?: AgeAssuranceMetadata
|
||||
deviceSignals?: AgeRange.AgeRangeResponse
|
||||
}) {
|
||||
/**
|
||||
* This is where we control logged-out moderation prefs. It's all
|
||||
@@ -99,19 +93,10 @@ function computeAgeAssuranceState({
|
||||
* Otherwise, we need to compute the access based on the latest data. For
|
||||
* accounts with an accurate birthdate, our default fallback rules should
|
||||
* ensure correct access.
|
||||
*
|
||||
* In regions that permit on-device verification, the OS-provided age range
|
||||
* is treated as an assured age and fed into the rule engine, where it
|
||||
* matches `IfAssuredOverAge`/`IfAssuredUnderAge` rules.
|
||||
*/
|
||||
const {assuredAge} = getAgeAssuranceDataFromDeviceSignals(
|
||||
region,
|
||||
deviceSignals,
|
||||
)
|
||||
const result = computeAgeAssuranceRegionAccess(region, {
|
||||
accountCreatedAt: metadata?.accountCreatedAt,
|
||||
declaredAge: metadata?.declaredAge,
|
||||
assuredAge,
|
||||
})
|
||||
const computed = {
|
||||
lastInitiatedAt: state?.lastInitiatedAt,
|
||||
@@ -153,19 +138,6 @@ export function unsafeGetAndComputeAgeAssurance({did}: {did: string}) {
|
||||
}
|
||||
|
||||
const region = getAgeAssuranceRegionConfigWithFallback(config, geolocation)
|
||||
/*
|
||||
* Device signals are keyed off the matched config region (no fallback): if
|
||||
* geolocation matches no AA region there's no device grant to read, so we
|
||||
* skip the lookup rather than keying off FALLBACK_REGION_CONFIG. This keeps
|
||||
* the read key symmetric with the write (see `setDeviceSignalsForRegion`).
|
||||
*/
|
||||
const deviceRegion = getAgeAssuranceRegionConfigForGeolocation(
|
||||
config,
|
||||
geolocation,
|
||||
)
|
||||
const deviceSignals = deviceRegion
|
||||
? getDeviceSignalsFromCacheForRegion({did, region: deviceRegion})
|
||||
: undefined
|
||||
const metadata: AgeAssuranceMetadata = {
|
||||
accountCreatedAt: state.metadata?.accountCreatedAt,
|
||||
declaredAge: requiredData?.birthdate
|
||||
@@ -179,7 +151,6 @@ export function unsafeGetAndComputeAgeAssurance({did}: {did: string}) {
|
||||
geolocation,
|
||||
state: state.state,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -188,7 +159,6 @@ export function unsafeGetAndComputeAgeAssurance({did}: {did: string}) {
|
||||
state: computed,
|
||||
regionConfig: region,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -196,8 +166,7 @@ export function unsafeGetAndComputeAgeAssurance({did}: {did: string}) {
|
||||
export function useAgeAssuranceState(): AgeAssuranceState {
|
||||
const {hasSession} = useSession()
|
||||
const geolocation = useGeolocation()
|
||||
const {config, state, metadata, deviceSignals} =
|
||||
useAgeAssuranceServerDataContext()
|
||||
const {config, state, metadata} = useAgeAssuranceServerDataContext()
|
||||
|
||||
return useMemo(
|
||||
() =>
|
||||
@@ -207,9 +176,8 @@ export function useAgeAssuranceState(): AgeAssuranceState {
|
||||
geolocation,
|
||||
state,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
}),
|
||||
[hasSession, geolocation, config, state, metadata, deviceSignals],
|
||||
[hasSession, geolocation, config, state, metadata],
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
import type * as AgeRange from 'expo-age-range'
|
||||
import {type computeAgeAssuranceRegionAccess} from '@atproto/api'
|
||||
|
||||
import {logger} from '#/ageAssurance/logger'
|
||||
|
||||
/**
|
||||
* Native on-device age signals, keyed by the region (a `country[-region]`
|
||||
* string, see `createRegionKey`) they were captured in. We keep one entry per
|
||||
* region so multiple regions with differing criteria can each retain their own
|
||||
* grant.
|
||||
*
|
||||
* Device assurance can't be verified server-side (the OS gives us no signed
|
||||
* attestation, only age bounds), so we persist it client-side only and bind it
|
||||
* to its capture region via the key. A grant captured in TX is only ever read
|
||||
* back for TX — it can't silently unlock another region. See
|
||||
* `getAgeAssuranceDataFromDeviceSignals`.
|
||||
*/
|
||||
export type AgeAssuranceDeviceSignals = {
|
||||
[regionKey: string]: AgeRange.AgeRangeResponse
|
||||
}
|
||||
|
||||
export enum AgeAssuranceAccess {
|
||||
Unknown = 'unknown',
|
||||
None = 'none',
|
||||
@@ -51,12 +34,9 @@ export type AgeAssuranceFlags = {
|
||||
adultContentDisabled: boolean
|
||||
chatDisabled: boolean
|
||||
groupChatDisabled: boolean
|
||||
hasDeclaredAge: boolean
|
||||
isDeclaredUnderAdultAge: boolean
|
||||
isOverRegionMinAccessAge: boolean
|
||||
isOverAppMinAccessAge: boolean
|
||||
allowsDeviceVerification: boolean
|
||||
hasSharedDeviceSignals: boolean
|
||||
}
|
||||
|
||||
export function parseStatusFromString(raw: string) {
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
import {useCallback, useState} from 'react'
|
||||
import type * as AgeRange from 'expo-age-range'
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {useSession} from '#/state/session'
|
||||
import {type DialogControlProps} from '#/components/Dialog'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {useAgeAssurance} from '#/ageAssurance'
|
||||
import {getDeviceSignals, setDeviceSignalsForRegion} from '#/ageAssurance/data'
|
||||
import {logger} from '#/ageAssurance/logger'
|
||||
import {unsafeGetAndComputeAgeAssurance} from '#/ageAssurance/state'
|
||||
import {
|
||||
getAgeAssuranceDataFromDeviceSignals,
|
||||
useAgeAssuranceRegionConfig,
|
||||
} from '#/ageAssurance/util'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
|
||||
/**
|
||||
* Shared "Verify now" flow for the age assurance surfaces (the no-access screen
|
||||
* and the account settings card). Handles the device-first verification path
|
||||
* with a KWS fallback, keeping the two entry points in sync.
|
||||
*
|
||||
* The caller owns the KWS dialog (`AgeAssuranceInitDialog`) and passes its
|
||||
* `initDialogControl` here so we can open it for the fallback / opt-in cases.
|
||||
*
|
||||
* Returns:
|
||||
* - `onPressVerify`: the button handler. In device-verification regions it
|
||||
* prompts the OS age API, persists a sufficient result (region-bound), and
|
||||
* toasts the outcome; otherwise (or on any missing/failed device response) it
|
||||
* opens the KWS dialog.
|
||||
* - `openInitDialog`: opens the KWS dialog directly (for the inline "use KWS"
|
||||
* link), emitting the same metric as the fallback path.
|
||||
* - `isVerifying`: true while the OS age prompt is up, for a button
|
||||
* loading state.
|
||||
* - `verifyCta`: the localized button label for the current mode.
|
||||
*/
|
||||
export function useAgeAssuranceVerificationFlow({
|
||||
initDialogControl,
|
||||
}: {
|
||||
initDialogControl: DialogControlProps
|
||||
}) {
|
||||
const {t: l} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const {currentAccount} = useSession()
|
||||
const region = useAgeAssuranceRegionConfig()
|
||||
const aa = useAgeAssurance()
|
||||
const hasInitiated = !!aa.state.lastInitiatedAt
|
||||
const allowsDeviceVerification = region && aa.flags.allowsDeviceVerification
|
||||
|
||||
const [isVerifying, setIsVerifying] = useState(false)
|
||||
/*
|
||||
* In-memory only, and scoped to this hook instance: each surface using this
|
||||
* hook tracks its own failure, and a remount (or another surface) starts
|
||||
* fresh and will offer the device flow again. That's intentional for now -
|
||||
* it's a soft "don't immediately re-offer" signal, not a persisted judgment
|
||||
* that the device can't provide signals.
|
||||
*/
|
||||
const [deviceSignalsFailed, setDeviceSignalsFailed] = useState(false)
|
||||
|
||||
const verifyCta =
|
||||
allowsDeviceVerification && !deviceSignalsFailed
|
||||
? l`Share age range`
|
||||
: hasInitiated
|
||||
? l`Verify again`
|
||||
: l`Verify now`
|
||||
|
||||
const openInitDialog = useCallback(() => {
|
||||
initDialogControl.open()
|
||||
ax.metric('ageAssurance:initDialogOpen', {
|
||||
hasInitiatedPreviously: hasInitiated,
|
||||
})
|
||||
}, [initDialogControl, ax, hasInitiated])
|
||||
|
||||
const onPressVerify = useCallback(async () => {
|
||||
const did = currentAccount?.did
|
||||
|
||||
// Just for typescript, these surfaces aren't shown without a logged in user
|
||||
if (!did) return
|
||||
|
||||
/*
|
||||
* In regions that permit on-device verification, try the native age API
|
||||
* first. We tag the result with the current region (device assurance is
|
||||
* region-bound — a TX grant only counts in TX) and, if it's sufficient,
|
||||
* persist it client-side so the AA state recompute lifts the gate.
|
||||
*
|
||||
* Once the OS returns a response we stay on the device path and report the
|
||||
* outcome via a toast (sufficient, under-age, or no usable data) rather than
|
||||
* silently falling back — users can still opt into KWS via the inline link.
|
||||
* We only fall through to the KWS dialog below when the device can't give us
|
||||
* a response at all: `getDeviceSignals` handles its own errors and returns
|
||||
* undefined (e.g. on web or failure).
|
||||
*/
|
||||
if (allowsDeviceVerification && !deviceSignalsFailed) {
|
||||
// Show a loading state while the OS age prompt is up.
|
||||
setIsVerifying(true)
|
||||
let signals: AgeRange.AgeRangeResponse | undefined
|
||||
try {
|
||||
signals = await getDeviceSignals()
|
||||
} finally {
|
||||
setIsVerifying(false)
|
||||
}
|
||||
if (signals) {
|
||||
const {assuredAge} = getAgeAssuranceDataFromDeviceSignals(
|
||||
region,
|
||||
signals,
|
||||
)
|
||||
if (assuredAge !== undefined) {
|
||||
// Persist (keyed by this region) so the AA state recomputes from the
|
||||
// cache write. Recompute here too so we can react to the outcome: a
|
||||
// sufficient age lifts the gate (nothing more to do), but the device
|
||||
// may report an age below the region's threshold, in which case
|
||||
// access stays `none` and we tell the user.
|
||||
setDeviceSignalsForRegion({did, region, signals})
|
||||
const {state} = unsafeGetAndComputeAgeAssurance({did})
|
||||
if (state.access === aa.Access.None) {
|
||||
Toast.show(
|
||||
l`We're sorry, but based on the data shared by your device, you are not old enough to access Bluesky.`,
|
||||
{type: 'info'},
|
||||
)
|
||||
} else if (state.access === aa.Access.Unknown) {
|
||||
Toast.show(
|
||||
l`Hmm, it seems we weren't able to compute your level of access. Please try again.`,
|
||||
{type: 'warning'},
|
||||
)
|
||||
} else if (state.access === aa.Access.Safe) {
|
||||
Toast.show(
|
||||
l`You're all set! However, certain features may still be restricted until you're able to verify you're an adult.`,
|
||||
{
|
||||
type: 'success',
|
||||
},
|
||||
)
|
||||
} else {
|
||||
Toast.show(l`You're all set!`, {
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
// We got a device response but it carried no usable age information.
|
||||
Toast.show(
|
||||
l`Hmm, it seems your device was unable to share age information with us.`,
|
||||
{type: 'warning'},
|
||||
)
|
||||
setDeviceSignalsFailed(true)
|
||||
return
|
||||
}
|
||||
logger.debug(
|
||||
`onPressVerify: no device signals available (web/error), falling back to KWS`,
|
||||
)
|
||||
}
|
||||
|
||||
openInitDialog()
|
||||
}, [
|
||||
region,
|
||||
currentAccount?.did,
|
||||
openInitDialog,
|
||||
allowsDeviceVerification,
|
||||
aa,
|
||||
l,
|
||||
deviceSignalsFailed,
|
||||
setDeviceSignalsFailed,
|
||||
])
|
||||
|
||||
return {
|
||||
onPressVerify,
|
||||
openInitDialog,
|
||||
isVerifying,
|
||||
verifyCta,
|
||||
deviceSignalsFailed,
|
||||
}
|
||||
}
|
||||
+12
-237
@@ -1,20 +1,13 @@
|
||||
import {useMemo} from 'react'
|
||||
import type * as AgeRange from 'expo-age-range'
|
||||
import {
|
||||
AppBskyAgeassuranceDefs,
|
||||
computeAgeAssuranceRegionAccess,
|
||||
type AppBskyAgeassuranceDefs,
|
||||
getAgeAssuranceRegionConfig,
|
||||
type ModerationPrefs,
|
||||
} from '@atproto/api'
|
||||
|
||||
import {getAge} from '#/lib/strings/time'
|
||||
import {regionName} from '#/locale/helpers'
|
||||
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/const'
|
||||
import {
|
||||
DEVICE_SIGNALS_SUPPORTED,
|
||||
FALLBACK_REGION_CONFIG,
|
||||
MIN_ACCESS_AGE,
|
||||
} from '#/ageAssurance/const'
|
||||
import {FALLBACK_REGION_CONFIG, MIN_ACCESS_AGE} from '#/ageAssurance/const'
|
||||
import {useAgeAssuranceServerDataContext} from '#/ageAssurance/data'
|
||||
import {
|
||||
AgeAssuranceAccess,
|
||||
@@ -23,213 +16,24 @@ import {
|
||||
type AgeAssuranceState,
|
||||
} from '#/ageAssurance/types'
|
||||
import {type Geolocation, useGeolocation} from '#/geolocation'
|
||||
import {USRegionNameToRegionCode} from '#/geolocation/util'
|
||||
|
||||
/**
|
||||
* Resolves a geolocation to its matched age assurance region config, or
|
||||
* undefined when the geolocation matches no AA region.
|
||||
*
|
||||
* This is the single source of truth for geolocation -> region resolution.
|
||||
* Device signals are written and read back under a key derived from the
|
||||
* matched region (see `createRegionKey`), so every site that resolves a region
|
||||
* for that purpose MUST go through this helper - independent re-implementations
|
||||
* risk desyncing the write and read keys and silently losing grants.
|
||||
*/
|
||||
export function getAgeAssuranceRegionConfigForGeolocation(
|
||||
config: AppBskyAgeassuranceDefs.Config,
|
||||
geolocation: Geolocation,
|
||||
): AppBskyAgeassuranceDefs.ConfigRegion | undefined {
|
||||
return getAgeAssuranceRegionConfig(config, {
|
||||
countryCode: geolocation.countryCode ?? '',
|
||||
regionCode: geolocation.regionCode,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get age assurance region config based on geolocation, with fallback to
|
||||
* app defaults if no region config is found.
|
||||
*
|
||||
* See {@link getAgeAssuranceRegionConfigForGeolocation} for the generic option,
|
||||
* which can return undefined if the geolocation does not match any AA region.
|
||||
* See {@link getAgeAssuranceRegionConfig} for the generic option, which can
|
||||
* return undefined if the geolocation does not match any AA region.
|
||||
*/
|
||||
export function getAgeAssuranceRegionConfigWithFallback(
|
||||
config: AppBskyAgeassuranceDefs.Config,
|
||||
geolocation: Geolocation,
|
||||
): AppBskyAgeassuranceDefs.ConfigRegion {
|
||||
return (
|
||||
getAgeAssuranceRegionConfigForGeolocation(config, geolocation) ||
|
||||
FALLBACK_REGION_CONFIG
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the verification methods permitted for a region *in addition to* the
|
||||
* always-supported KWS flow. Empty when the region doesn't specify any (the
|
||||
* historical KWS-only behavior).
|
||||
*/
|
||||
export function getRegionAdditionalVerificationMethods(
|
||||
region: AppBskyAgeassuranceDefs.ConfigRegion,
|
||||
): NonNullable<
|
||||
AppBskyAgeassuranceDefs.ConfigRegion['additionalVerificationMethods']
|
||||
> {
|
||||
return region.additionalVerificationMethods ?? []
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a region permits satisfying age assurance via the native on-device
|
||||
* age APIs (Apple Declared Age Range / Google Play Age Signals).
|
||||
*/
|
||||
export function regionAllowsDeviceVerification(
|
||||
region: AppBskyAgeassuranceDefs.ConfigRegion,
|
||||
): boolean {
|
||||
return getRegionAdditionalVerificationMethods(region).includes('device')
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the cache key for a region's device signals — a `country[-region]`
|
||||
* string (e.g. `US-TX` or `GB`). This is the key under which on-device
|
||||
* assurance is stored and read back, which is what binds a grant to its capture
|
||||
* region.
|
||||
*/
|
||||
export function createRegionKey(region: {
|
||||
countryCode: string
|
||||
regionCode?: string
|
||||
}): string {
|
||||
return region.regionCode
|
||||
? `${region.countryCode}-${region.regionCode}`
|
||||
: region.countryCode
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives age assurance data from native device signals for the given region,
|
||||
* but only when the region permits device verification. The signals are
|
||||
* expected to already be resolved to the user's current region (see
|
||||
* `getDeviceSignalsFromCacheForRegion`), so a grant captured in another region
|
||||
* won't reach here.
|
||||
*
|
||||
* The OS-provided `lowerBound` is the minimum age the platform will attest to,
|
||||
* which maps onto the `assuredAge` input of the rule engine (i.e.
|
||||
* `IfAssuredOverAge`/`IfAssuredUnderAge` rules).
|
||||
*
|
||||
* Always returns an object (so callers can spread it unconditionally); fields
|
||||
* are populated only when device verification applies and the OS provided
|
||||
* usable data.
|
||||
*/
|
||||
export function getAgeAssuranceDataFromDeviceSignals(
|
||||
region: AppBskyAgeassuranceDefs.ConfigRegion,
|
||||
deviceSignals: AgeRange.AgeRangeResponse | undefined,
|
||||
): {
|
||||
assuredAge?: number
|
||||
} {
|
||||
if (!regionAllowsDeviceVerification(region)) return {}
|
||||
const lowerBound = deviceSignals?.lowerBound
|
||||
return {
|
||||
assuredAge: typeof lowerBound === 'number' ? lowerBound : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ranks access levels from most to least restrictive so we can compare two
|
||||
* outcomes. Higher number = more access.
|
||||
*/
|
||||
const ACCESS_RANK: Record<string, number> = {
|
||||
[AgeAssuranceAccess.None]: 0,
|
||||
[AgeAssuranceAccess.Safe]: 1,
|
||||
[AgeAssuranceAccess.Full]: 2,
|
||||
// `unknown` isn't a real granted level; treat it as the floor.
|
||||
[AgeAssuranceAccess.Unknown]: -1,
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether correcting the user's declared age (i.e. updating their birthdate)
|
||||
* could meaningfully improve their standing in the current region.
|
||||
*
|
||||
* There are two ways a birthdate update can help:
|
||||
*
|
||||
* 1. Raising the rule-engine access level. Some regions grant `safe`/`full` off
|
||||
* a sufficient *declared* age, so a user whose birthdate is wrong (too young)
|
||||
* can unlock more by correcting it. Other regions gate higher access purely
|
||||
* on an *assured* age (or account date), where a declared age changes
|
||||
* nothing.
|
||||
* 2. Crossing the region's `minAccessAge`. Below it the user is hard-blocked
|
||||
* with no verify path (see `isOverRegionMinAccessAge` gating in the
|
||||
* NoAccessScreen); crossing it unlocks the verify flow, which is itself a
|
||||
* path to more access even when the rule-engine level would still be `none`.
|
||||
*
|
||||
* We answer by simulating the real rule engine: hold `accountCreatedAt` and
|
||||
* the device-derived `assuredAge` fixed and re-run access for a set of
|
||||
* candidate declared ages drawn from the region's declared-age rule thresholds
|
||||
* and its `minAccessAge`. If any candidate yields strictly more access, or
|
||||
* crosses `minAccessAge` when the current declared age doesn't, a birthdate
|
||||
* update could help. Simulating rather than statically inspecting rules means
|
||||
* first-match precedence (e.g. an assured/account rule pre-empting a declared
|
||||
* rule) is handled correctly for free.
|
||||
*
|
||||
* `deviceSignals` must be passed so the baseline matches the user's *real*
|
||||
* computed access (see `computeAgeAssuranceState`, which derives `assuredAge`
|
||||
* the same way). Without it, a device-assured user's baseline would compute
|
||||
* lower than their actual access and we'd claim a birthdate update helps when
|
||||
* it can't - and account-date rules would flip on when they're really skipped
|
||||
* (the engine bypasses them whenever `assuredAge` is set).
|
||||
*/
|
||||
export function canBirthdateUpdateIncreaseAccess({
|
||||
region,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
}: {
|
||||
region: AppBskyAgeassuranceDefs.ConfigRegion
|
||||
metadata?: AgeAssuranceMetadata
|
||||
deviceSignals?: AgeRange.AgeRangeResponse
|
||||
}): boolean {
|
||||
const {assuredAge} = getAgeAssuranceDataFromDeviceSignals(
|
||||
region,
|
||||
deviceSignals,
|
||||
)
|
||||
const baseline = computeAgeAssuranceRegionAccess(region, {
|
||||
accountCreatedAt: metadata?.accountCreatedAt,
|
||||
declaredAge: metadata?.declaredAge,
|
||||
assuredAge,
|
||||
const region = getAgeAssuranceRegionConfig(config, {
|
||||
countryCode: geolocation.countryCode ?? '',
|
||||
regionCode: geolocation.regionCode,
|
||||
})
|
||||
const baselineRank =
|
||||
ACCESS_RANK[baseline?.access ?? AgeAssuranceAccess.Unknown]
|
||||
const baselineOverMin =
|
||||
metadata?.declaredAge !== undefined &&
|
||||
metadata.declaredAge >= region.minAccessAge
|
||||
|
||||
/*
|
||||
* Candidate declared ages to probe: each declared-age rule's threshold and
|
||||
* the region's `minAccessAge`, plus one below each (to cover
|
||||
* `IfDeclaredUnderAge` and the min-age boundary). Anything a birthdate edit
|
||||
* could achieve is captured by crossing one of these thresholds, so we don't
|
||||
* need to sweep every integer.
|
||||
*/
|
||||
const thresholds = new Set<number>([region.minAccessAge])
|
||||
for (const rule of region.rules) {
|
||||
if (
|
||||
AppBskyAgeassuranceDefs.isConfigRegionRuleIfDeclaredOverAge(rule) ||
|
||||
AppBskyAgeassuranceDefs.isConfigRegionRuleIfDeclaredUnderAge(rule)
|
||||
) {
|
||||
thresholds.add(rule.age)
|
||||
}
|
||||
}
|
||||
const candidates = new Set<number>()
|
||||
for (const threshold of thresholds) {
|
||||
candidates.add(threshold)
|
||||
candidates.add(Math.max(0, threshold - 1))
|
||||
}
|
||||
|
||||
for (const declaredAge of candidates) {
|
||||
const result = computeAgeAssuranceRegionAccess(region, {
|
||||
accountCreatedAt: metadata?.accountCreatedAt,
|
||||
declaredAge,
|
||||
assuredAge,
|
||||
})
|
||||
const rank = ACCESS_RANK[result?.access ?? AgeAssuranceAccess.Unknown]
|
||||
const overMin = declaredAge >= region.minAccessAge
|
||||
if (rank > baselineRank || (overMin && !baselineOverMin)) return true
|
||||
}
|
||||
|
||||
return false
|
||||
return region || FALLBACK_REGION_CONFIG
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +47,10 @@ export function useAgeAssuranceRegionConfig() {
|
||||
return useMemo(() => {
|
||||
if (!config) return
|
||||
// use generic helper, we want to potentially return undefined
|
||||
return getAgeAssuranceRegionConfigForGeolocation(config, geolocation)
|
||||
return getAgeAssuranceRegionConfig(config, {
|
||||
countryCode: geolocation.countryCode ?? '',
|
||||
regionCode: geolocation.regionCode,
|
||||
})
|
||||
}, [config, geolocation])
|
||||
}
|
||||
|
||||
@@ -294,12 +101,10 @@ export function computeAgeAssuranceFlags({
|
||||
state,
|
||||
regionConfig,
|
||||
metadata,
|
||||
deviceSignals,
|
||||
}: {
|
||||
state: AgeAssuranceState
|
||||
regionConfig: AppBskyAgeassuranceDefs.ConfigRegion
|
||||
metadata?: AgeAssuranceMetadata
|
||||
deviceSignals?: AgeRange.AgeRangeResponse
|
||||
}): AgeAssuranceFlags {
|
||||
const isAgeRestricted = state.access !== AgeAssuranceAccess.Full
|
||||
const chatDisabled = isAgeRestricted
|
||||
@@ -315,44 +120,14 @@ export function computeAgeAssuranceFlags({
|
||||
: false
|
||||
const adultContentDisabled =
|
||||
state.access !== AgeAssuranceAccess.Full || isDeclaredUnderAdultAge
|
||||
const allowsDeviceVerification =
|
||||
DEVICE_SIGNALS_SUPPORTED && regionAllowsDeviceVerification(regionConfig)
|
||||
const hasSharedDeviceSignals = deviceSignals?.lowerBound !== undefined
|
||||
|
||||
return {
|
||||
isAgeRestricted,
|
||||
adultContentDisabled,
|
||||
chatDisabled,
|
||||
groupChatDisabled,
|
||||
hasDeclaredAge: metadata?.declaredAge !== undefined,
|
||||
isDeclaredUnderAdultAge,
|
||||
isOverRegionMinAccessAge,
|
||||
isOverAppMinAccessAge,
|
||||
allowsDeviceVerification,
|
||||
hasSharedDeviceSignals,
|
||||
}
|
||||
}
|
||||
|
||||
const USRegionCodeToRegionName: {[regionCode: string]: string} =
|
||||
Object.fromEntries(
|
||||
Object.entries(USRegionNameToRegionCode).map(([name, code]) => [
|
||||
code,
|
||||
name,
|
||||
]),
|
||||
)
|
||||
export function createGeolocationString(
|
||||
geolocation: Geolocation,
|
||||
appLang: string,
|
||||
): string | undefined {
|
||||
const {countryCode, regionCode} = geolocation
|
||||
if (!countryCode) return undefined
|
||||
const country = regionName(countryCode, appLang)
|
||||
// If `regionName` couldn't resolve a real name and fell through to the raw
|
||||
// code, we'd rather show nothing than a bare ISO code in the prose.
|
||||
if (country === countryCode) return undefined
|
||||
if (regionCode && countryCode === 'US') {
|
||||
const state = USRegionCodeToRegionName[regionCode]
|
||||
if (state) return `${state}, ${country}`
|
||||
}
|
||||
return country
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ export enum Features {
|
||||
ImportContactsSettingsDisable = 'import_contacts:settings:disable',
|
||||
LiveNowBetaDisable = 'live_now_beta:disable',
|
||||
GroupChatsDisable = 'group_chats:disable',
|
||||
DmsNewMessageComposerEnable = 'dms:new_message_composer:enable',
|
||||
ComposerLanguageDetectionEnable = 'composer:language_detection:enable',
|
||||
PostGalleryEmbedEnable = 'post_gallery_embed:enable',
|
||||
SearchV2Enable = 'search_v2:enable',
|
||||
AdvancedSearchV2Enable = 'advanced_search_v2:enable',
|
||||
NotificationsExpandedProfileCardEnable = 'notifications:expanded_profile_card:enable',
|
||||
|
||||
AATest = 'aa-test',
|
||||
}
|
||||
|
||||
+11
-69
@@ -1,6 +1,5 @@
|
||||
import {createContext, useContext, useMemo} from 'react'
|
||||
import {Platform} from 'react-native'
|
||||
import {type Result} from '@growthbook/growthbook-react'
|
||||
|
||||
import {Logger} from '#/logger'
|
||||
import {
|
||||
@@ -170,39 +169,6 @@ export function AnalyticsContext({
|
||||
return <Context.Provider value={childContext}>{children}</Context.Provider>
|
||||
}
|
||||
|
||||
/**
|
||||
* GrowthBook attribute name for the did. Must match the key used in
|
||||
* `setAttributes` (`#/analytics/features`) and the assignment unit configured
|
||||
* in the GrowthBook dashboard.
|
||||
*/
|
||||
const DID_HASH_ATTRIBUTE = 'did'
|
||||
|
||||
/**
|
||||
* Builds the session metadata override for an exposure event so the event's
|
||||
* `did` is sourced from the unit GrowthBook actually bucketed on
|
||||
* (`result.hashValue`) rather than from ambient React session metadata. This
|
||||
* keeps the `did` and the variation in sync, since both then come from the
|
||||
* same evaluation. See APP-2461.
|
||||
*
|
||||
* Only did-bucketed experiments are overridden. Experiments bucketed on
|
||||
* another attribute (e.g. `deviceId`) have a `hashValue` that is not a did, so
|
||||
* we leave their session metadata untouched and let the ambient did stand.
|
||||
*/
|
||||
function sessionMetadataForResult(
|
||||
parentContext: AnalyticsBaseContextType,
|
||||
result: Result<unknown>,
|
||||
): MergeableMetadata | undefined {
|
||||
if (result.hashAttribute !== DID_HASH_ATTRIBUTE) return undefined
|
||||
const {session} = parentContext.metadata
|
||||
if (!session) return undefined
|
||||
return {
|
||||
session: {
|
||||
...session,
|
||||
did: result.hashValue,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature gates provider. Decorates the parent analytics context with
|
||||
* feature gate capabilities. Should be mounted within `AnalyticsContext`,
|
||||
@@ -219,46 +185,22 @@ export function AnalyticsFeaturesContext({
|
||||
* Side-effects: we need to synchronously set these during the same render
|
||||
* cycle. These calls do not trigger re-renders, they just set properties on
|
||||
* the singleton GrowthBook instance.
|
||||
*
|
||||
* Order matters here. We register the tracking callbacks _before_ calling
|
||||
* `setAttributes`, because `setAttributes` triggers a synchronous
|
||||
* re-evaluation that can fire exposure events. Registering first guarantees
|
||||
* those events run through this render's callback (with this render's
|
||||
* metadata) rather than a stale callback left over from a previous render,
|
||||
* e.g. after an account switch remounts this provider via the
|
||||
* `<Fragment key={did} />` breaker in `App.<platform>.tsx`. See APP-2461.
|
||||
*
|
||||
* We deliberately keep these synchronous rather than moving them into a
|
||||
* `useEffect`: `setAttributes` must run before children evaluate gates (or
|
||||
* they bucket on the previous account's attributes), and the feature usage
|
||||
* callback has no deferred-replay, so a feature evaluated before it is
|
||||
* registered would lose its `feature:viewed` event entirely.
|
||||
*/
|
||||
setAttributes(parentContext.metadata)
|
||||
feats.setTrackingCallback((experiment, result) => {
|
||||
parentContext.metric(
|
||||
'experiment:viewed',
|
||||
{
|
||||
experimentId: experiment.key,
|
||||
variationId: result.key,
|
||||
},
|
||||
sessionMetadataForResult(parentContext, result),
|
||||
)
|
||||
parentContext.metric('experiment:viewed', {
|
||||
experimentId: experiment.key,
|
||||
variationId: result.key,
|
||||
})
|
||||
})
|
||||
feats.setFeatureUsageCallback((feature, result) => {
|
||||
parentContext.metric(
|
||||
'feature:viewed',
|
||||
{
|
||||
featureId: feature,
|
||||
featureResultValue: result.value,
|
||||
experimentId: result.experiment?.key,
|
||||
variationId: result.experimentResult?.key,
|
||||
},
|
||||
result.experimentResult
|
||||
? sessionMetadataForResult(parentContext, result.experimentResult)
|
||||
: undefined,
|
||||
)
|
||||
parentContext.metric('feature:viewed', {
|
||||
featureId: feature,
|
||||
featureResultValue: result.value,
|
||||
experimentId: result.experiment?.key,
|
||||
variationId: result.experimentResult?.key,
|
||||
})
|
||||
})
|
||||
setAttributes(parentContext.metadata)
|
||||
|
||||
const childContext = useMemo<AnalyticsContextType>(() => {
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import {type Platform} from 'react-native'
|
||||
|
||||
import {type NotificationReason} from '#/lib/hooks/useNotificationHandler'
|
||||
import {type VideoCompressSkipReason} from '#/lib/media/video/types'
|
||||
import {type NotificationType} from '#/state/queries/notifications/types'
|
||||
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
||||
import {type LiveEventFeedMetricContext} from '#/features/liveEvents/types'
|
||||
@@ -775,7 +774,6 @@ export type Events = {
|
||||
|
||||
'search:query': {
|
||||
source: 'typed' | 'history' | 'autocomplete'
|
||||
filterCount: number
|
||||
}
|
||||
|
||||
'search:results:loaded': {
|
||||
@@ -800,18 +798,6 @@ export type Events = {
|
||||
position: number
|
||||
}
|
||||
|
||||
'search:advanced:press': {
|
||||
filterCount: number
|
||||
}
|
||||
|
||||
'search:shareLink:press': {
|
||||
filterCount: number
|
||||
}
|
||||
|
||||
'search:addFilter:press': {
|
||||
filterCount: number
|
||||
}
|
||||
|
||||
'progressGuide:hide': {}
|
||||
'progressGuide:followDialog:open': {}
|
||||
|
||||
@@ -1333,7 +1319,7 @@ export type Events = {
|
||||
'invite:action:scan': {}
|
||||
// user changed the QR card color theme
|
||||
'invite:theme:change': {
|
||||
themeKey: 'dawn' | 'sunlight' | 'day' | 'dusk' | 'twilight' | 'night'
|
||||
themeKey: 'dawn' | 'day' | 'dusk' | 'night'
|
||||
}
|
||||
// QR scanner decoded a code; result indicates whether it resolved to a profile
|
||||
'invite:scanner:scanned': {
|
||||
@@ -1345,120 +1331,4 @@ export type Events = {
|
||||
'invite:followersPromo:press': {}
|
||||
// user dismissed the empty-followers promo banner
|
||||
'invite:followersPromo:dismiss': {}
|
||||
|
||||
// === Video upload funnel (Frontend Spec section D) ===
|
||||
// Every event carries uploadId (client-generated UUID, ties one upload
|
||||
// session end-to-end) + engine (compression engine id, e.g.
|
||||
// native:react-native-compressor@1.13.0). jobId is added once the server
|
||||
// returns it. Sizes / codecs / dimensions / timings only - never content.
|
||||
'video:upload:picked': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
sourceMimeType?: string
|
||||
sourceBytes?: number
|
||||
sourceDurationMs?: number
|
||||
sourceWidth?: number
|
||||
sourceHeight?: number
|
||||
}
|
||||
'video:upload:compressStarted': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
sourceBytes?: number
|
||||
}
|
||||
// Native-only. Raw container metadata returned by the new module's probe()
|
||||
// (bitrate, codec, HDR, frame rate, rotation, etc.). Fires once per upload
|
||||
// between compressStarted and the compressSkipped/compressCompleted decision.
|
||||
// The web (mediabunny) and legacy rn-compressor engines do not surface this.
|
||||
'video:upload:probed': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
mimeType: string
|
||||
codec: string
|
||||
width: number
|
||||
height: number
|
||||
duration: number
|
||||
bitrate: number
|
||||
fileSize: number
|
||||
hasAudio: boolean
|
||||
frameRate: number
|
||||
rotation: number
|
||||
isHDR: boolean
|
||||
}
|
||||
'video:upload:compressCompleted': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
bytesIn?: number
|
||||
bytesOut: number
|
||||
outputMimeType: string
|
||||
elapsedMs: number
|
||||
}
|
||||
'video:upload:compressSkipped': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
skipReason: VideoCompressSkipReason
|
||||
bytes: number
|
||||
mimeType: string
|
||||
elapsedMs: number
|
||||
}
|
||||
'video:upload:compressFailed': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
errorClass: string
|
||||
/** Truncated to 256 chars */
|
||||
errorMessage: string
|
||||
elapsedMs: number
|
||||
}
|
||||
'video:upload:uploadStarted': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
bytes: number
|
||||
}
|
||||
'video:upload:uploadCompleted': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
jobId: string
|
||||
bytes: number
|
||||
elapsedMs: number
|
||||
throughputBytesPerSec: number
|
||||
}
|
||||
'video:upload:uploadFailed': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
bytes: number
|
||||
errorClass: string
|
||||
elapsedMs: number
|
||||
}
|
||||
'video:upload:processingStarted': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
jobId: string
|
||||
}
|
||||
'video:upload:processingCompleted': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
jobId: string
|
||||
elapsedMs: number
|
||||
}
|
||||
'video:upload:processingFailed': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
jobId: string
|
||||
errorClass: string
|
||||
elapsedMs: number
|
||||
}
|
||||
'video:upload:published': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
jobId: string
|
||||
// wall-clock from picked to published
|
||||
totalElapsedMs: number
|
||||
}
|
||||
// The event that measures the actual problem: users giving up mid-wait.
|
||||
'video:upload:abandoned': {
|
||||
uploadId: string
|
||||
engine: string
|
||||
phase: 'compress' | 'upload' | 'processing'
|
||||
jobId?: string
|
||||
elapsedInPhaseMs: number
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
import {Pressable} from 'react-native'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {HITSLOP_20} from '#/lib/constants'
|
||||
import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import * as Prompt from '#/components/Prompt'
|
||||
import {Text} from '#/components/Typography'
|
||||
|
||||
const positionStyles = {
|
||||
'top-left': {
|
||||
top: a.p_xs.padding,
|
||||
left: a.p_xs.padding,
|
||||
},
|
||||
'top-right': {
|
||||
top: a.p_xs.padding,
|
||||
right: a.p_xs.padding,
|
||||
},
|
||||
'bottom-left': {
|
||||
bottom: a.p_xs.padding,
|
||||
left: a.p_xs.padding,
|
||||
},
|
||||
'bottom-right': {
|
||||
bottom: a.p_xs.padding,
|
||||
right: a.p_xs.padding,
|
||||
},
|
||||
}
|
||||
|
||||
export function AltBadgeWithDialog({
|
||||
text,
|
||||
position,
|
||||
}: {
|
||||
text: string
|
||||
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const large = useLargeAltBadgeEnabled()
|
||||
const control = Prompt.usePromptControl()
|
||||
|
||||
const pos = position ? [a.absolute, positionStyles[position]] : {}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Pressable
|
||||
testID="altBadgeWithDialogButton"
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={l`Show alt text`}
|
||||
accessibilityHint=""
|
||||
hitSlop={HITSLOP_20}
|
||||
onPress={control.open}
|
||||
style={s => [
|
||||
a.justify_center,
|
||||
a.rounded_sm,
|
||||
a.p_xs,
|
||||
a.z_10,
|
||||
t.atoms.bg_contrast_25,
|
||||
large && {
|
||||
padding: 6,
|
||||
},
|
||||
{
|
||||
opacity: 0.8,
|
||||
},
|
||||
pos,
|
||||
s.hovered || s.pressed
|
||||
? [
|
||||
{
|
||||
opacity: 1,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
]}>
|
||||
<Text
|
||||
accessible={false}
|
||||
style={[a.font_bold, large ? a.text_xs : {fontSize: 8}]}>
|
||||
<Trans>ALT</Trans>
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
<Prompt.Outer control={control}>
|
||||
<Prompt.Content>
|
||||
<Prompt.TitleText>
|
||||
<Trans>Alt Text</Trans>
|
||||
</Prompt.TitleText>
|
||||
<Prompt.DescriptionText selectable>{text}</Prompt.DescriptionText>
|
||||
</Prompt.Content>
|
||||
<Prompt.Actions>
|
||||
<Prompt.Cancel cta={l`Close`} />
|
||||
</Prompt.Actions>
|
||||
</Prompt.Outer>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -7,10 +7,9 @@ import {sanitizeAppLanguageSetting} from '#/locale/helpers'
|
||||
import {APP_LANGUAGES} from '#/locale/languages'
|
||||
import {useLanguagePrefs, useLanguagePrefsApi} from '#/state/preferences'
|
||||
import {resetPostsFeedQueries} from '#/state/queries/post-feed'
|
||||
import {atoms as a, platform, useTheme, web} from '#/alf'
|
||||
import {atoms as a, platform, useTheme} from '#/alf'
|
||||
import * as Select from '#/components/Select'
|
||||
import {Button, ButtonIcon} from './Button'
|
||||
import {Earth_Stroke2_Corner2_Rounded as EarthIcon} from './icons/Globe'
|
||||
import {Button} from './Button'
|
||||
|
||||
export function AppLanguageDropdown() {
|
||||
const t = useTheme()
|
||||
@@ -58,7 +57,6 @@ export function AppLanguageDropdown() {
|
||||
native: [a.gap_xs],
|
||||
}),
|
||||
]}>
|
||||
<ButtonIcon icon={EarthIcon} size="md" />
|
||||
<Select.ValueText
|
||||
placeholder={_(msg`Select an app language`)}
|
||||
style={[t.atoms.text_contrast_medium]}
|
||||
@@ -70,7 +68,7 @@ export function AppLanguageDropdown() {
|
||||
<Select.Content
|
||||
label={_(msg`Select language`)}
|
||||
renderItem={({label, value}) => (
|
||||
<Select.Item value={value} label={label} style={web([a.pointer])}>
|
||||
<Select.Item value={value} label={label}>
|
||||
<Select.ItemIndicator />
|
||||
<Select.ItemText>{label}</Select.ItemText>
|
||||
</Select.Item>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user