Merge branch 'dev' into mobile-main
This commit is contained in:
@@ -2,6 +2,7 @@ pnpm-lock.yaml
|
||||
|
||||
CHANGELOG.md
|
||||
.context
|
||||
.waylog
|
||||
|
||||
apps/external/postcss.config.cjs
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# What's new in v1.6.1
|
||||
|
||||
## Shiny new things
|
||||
|
||||
- Added Spotlight settings with refined highlighting controls
|
||||
- Unified desktop updates with the OTA service for more consistent delivery
|
||||
|
||||
## Improvements
|
||||
|
||||
- Moved desktop text-to-speech playback to the Folo service
|
||||
- Improved update compatibility handling and release metadata generation
|
||||
|
||||
## No longer broken
|
||||
|
||||
- Fixed regressions in desktop update and release flows
|
||||
- Fixed PDF export layout and branding
|
||||
- Fixed future credit reset dates in AI chat
|
||||
- Fixed PlayerProgress switching to hour formatting too late
|
||||
|
||||
## Thanks
|
||||
|
||||
Special thanks to volunteer contributor @kuishou68 for their valuable contribution
|
||||
@@ -2,21 +2,10 @@
|
||||
|
||||
## Shiny new things
|
||||
|
||||
- Added Spotlight settings with refined highlighting controls
|
||||
- Unified desktop updates with the OTA service for more consistent delivery
|
||||
|
||||
## Improvements
|
||||
|
||||
- Moved desktop text-to-speech playback to the Folo service
|
||||
- Improved update compatibility handling and release metadata generation
|
||||
|
||||
## No longer broken
|
||||
|
||||
- Fixed regressions in desktop update and release flows
|
||||
- Fixed PDF export layout and branding
|
||||
- Fixed future credit reset dates in AI chat
|
||||
- Fixed PlayerProgress switching to hour formatting too late
|
||||
|
||||
## Thanks
|
||||
|
||||
Special thanks to volunteer contributor @kuishou68 for their valuable contribution
|
||||
Special thanks to volunteer contributors @ for their valuable contributions
|
||||
|
||||
@@ -85,6 +85,8 @@ export class BootstrapManager {
|
||||
currentApiURL: env.VITE_API_URL,
|
||||
})
|
||||
|
||||
await cleanupOldRender()
|
||||
|
||||
// Bypass CORS for PostHog analytics
|
||||
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
|
||||
const url = new URL(details.url)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest"
|
||||
|
||||
const { getCurrentRendererManifestMock } = vi.hoisted(() => ({
|
||||
getCurrentRendererManifestMock: vi.fn<() => null | { runtimeVersion: string; version: string }>(
|
||||
() => null,
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock("@follow/shared/env.desktop", () => ({
|
||||
env: {
|
||||
VITE_OTA_URL: "https://ota.folo.is",
|
||||
@@ -27,12 +33,30 @@ vi.mock("../env", () => ({
|
||||
}))
|
||||
|
||||
vi.mock("~/updater/hot-updater", () => ({
|
||||
getCurrentRendererManifest: () => null,
|
||||
getCurrentRendererManifest: getCurrentRendererManifestMock,
|
||||
isRendererManifestUsable: (
|
||||
manifest: { runtimeVersion?: string; version?: string } | null,
|
||||
input: { appVersion: string; runtimeVersion: string },
|
||||
) => {
|
||||
if (!manifest?.runtimeVersion || manifest.runtimeVersion !== input.runtimeVersion) {
|
||||
return false
|
||||
}
|
||||
|
||||
const manifestVersion = manifest.version?.split("-")[0]
|
||||
const appVersion = input.appVersion?.split("-")[0]
|
||||
|
||||
if (!manifestVersion || !appVersion) {
|
||||
return false
|
||||
}
|
||||
|
||||
return manifestVersion >= appVersion
|
||||
},
|
||||
}))
|
||||
|
||||
describe("desktop updater api", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal("fetch", vi.fn())
|
||||
getCurrentRendererManifestMock.mockReturnValue(null)
|
||||
})
|
||||
|
||||
it("returns null when desktop manifest responds 204", async () => {
|
||||
@@ -90,6 +114,27 @@ describe("desktop updater api", () => {
|
||||
expect(result?.app).toBeNull()
|
||||
})
|
||||
|
||||
it("falls back to the app version when the cached renderer manifest is stale", async () => {
|
||||
getCurrentRendererManifestMock.mockReturnValue({
|
||||
runtimeVersion: "1.6.0",
|
||||
version: "0.6.4",
|
||||
})
|
||||
|
||||
vi.mocked(fetch).mockResolvedValue(new Response(null, { status: 204 }))
|
||||
|
||||
const { fetchDesktopManifest } = await import("./api")
|
||||
await fetchDesktopManifest()
|
||||
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
new URL("/manifest", "https://ota.folo.is"),
|
||||
expect.objectContaining({
|
||||
headers: expect.objectContaining({
|
||||
"X-App-Renderer-Version": "1.5.0",
|
||||
}),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it("parses desktop policy responses", async () => {
|
||||
vi.mocked(fetch).mockResolvedValue(
|
||||
new Response(
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { env } from "@follow/shared/env.desktop"
|
||||
import { createDesktopAPIHeaders } from "@follow/utils/headers"
|
||||
import PKG, { runtimeVersion as configuredRuntimeVersion, version as appVersion } from "@pkg"
|
||||
import { gte } from "semver"
|
||||
|
||||
import { getCurrentRendererManifest } from "~/updater/hot-updater"
|
||||
import { getCurrentRendererManifest, isRendererManifestUsable } from "~/updater/hot-updater"
|
||||
|
||||
import { channel } from "../env"
|
||||
import type {
|
||||
@@ -18,8 +17,12 @@ export const getDesktopRuntimeVersion = () => configuredRuntimeVersion ?? appVer
|
||||
|
||||
export const getDesktopRendererVersion = () => {
|
||||
const rendererManifest = getCurrentRendererManifest()
|
||||
return gte(rendererManifest?.version ?? appVersion, appVersion)
|
||||
? (rendererManifest?.version ?? appVersion)
|
||||
|
||||
return isRendererManifestUsable(rendererManifest, {
|
||||
appVersion,
|
||||
runtimeVersion: getDesktopRuntimeVersion(),
|
||||
})
|
||||
? rendererManifest!.version
|
||||
: appVersion
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it, vi } from "vitest"
|
||||
|
||||
import { isRendererManifestUsable } from "./hot-updater"
|
||||
|
||||
vi.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: vi.fn(() => "/tmp"),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock("@follow/shared/bridge", () => ({
|
||||
callWindowExpose: vi.fn(() => ({
|
||||
readyToUpdate: vi.fn(),
|
||||
})),
|
||||
}))
|
||||
|
||||
vi.mock("@pkg", () => ({
|
||||
version: "1.6.0",
|
||||
runtimeVersion: "1.6.0",
|
||||
}))
|
||||
|
||||
vi.mock("electron-log", () => ({
|
||||
default: {
|
||||
scope: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
})),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock("~/manager/window", () => ({
|
||||
WindowManager: {
|
||||
getMainWindow: vi.fn(() => null),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock("./configs", () => ({
|
||||
appUpdaterConfig: {
|
||||
enableRenderHotUpdate: true,
|
||||
},
|
||||
}))
|
||||
|
||||
describe("renderer hot updater manifest compatibility", () => {
|
||||
it("rejects legacy cached manifests without a runtimeVersion", () => {
|
||||
expect(
|
||||
isRendererManifestUsable(
|
||||
{
|
||||
version: "0.6.3-12-gbfdc371ff",
|
||||
},
|
||||
{
|
||||
appVersion: "1.6.0",
|
||||
runtimeVersion: "1.6.0",
|
||||
},
|
||||
),
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it("rejects cached renderer manifests older than the current app version", () => {
|
||||
expect(
|
||||
isRendererManifestUsable(
|
||||
{
|
||||
runtimeVersion: "1.6.0",
|
||||
version: "0.6.4",
|
||||
},
|
||||
{
|
||||
appVersion: "1.6.0",
|
||||
runtimeVersion: "1.6.0",
|
||||
},
|
||||
),
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it("accepts cached renderer manifests that match the current runtime and app version", () => {
|
||||
expect(
|
||||
isRendererManifestUsable(
|
||||
{
|
||||
runtimeVersion: "1.6.0",
|
||||
version: "1.6.0",
|
||||
},
|
||||
{
|
||||
appVersion: "1.6.0",
|
||||
runtimeVersion: "1.6.0",
|
||||
},
|
||||
),
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -8,6 +8,7 @@ import { runtimeVersion as configuredRuntimeVersion, version as appVersion } fro
|
||||
import log from "electron-log"
|
||||
import { dump, load } from "js-yaml"
|
||||
import path from "pathe"
|
||||
import { compare } from "semver"
|
||||
import { x } from "tar"
|
||||
|
||||
import { HOTUPDATE_RENDER_ENTRY_DIR } from "~/constants/app"
|
||||
@@ -42,6 +43,47 @@ export interface RendererEligibilityResult {
|
||||
reason?: string
|
||||
}
|
||||
|
||||
const getCurrentRendererContext = () => ({
|
||||
appVersion,
|
||||
runtimeVersion: configuredRuntimeVersion ?? appVersion,
|
||||
})
|
||||
|
||||
const normalizeRendererVersion = (version?: null | string) => {
|
||||
const normalized = version?.split("-")[0]?.trim()
|
||||
if (!normalized) {
|
||||
return null
|
||||
}
|
||||
|
||||
return /^\d+\.\d+\.\d+$/.test(normalized) ? normalized : null
|
||||
}
|
||||
|
||||
const compareRendererVersions = (left?: null | string, right?: null | string) => {
|
||||
const normalizedLeft = normalizeRendererVersion(left)
|
||||
const normalizedRight = normalizeRendererVersion(right)
|
||||
|
||||
if (!normalizedLeft || !normalizedRight) {
|
||||
return null
|
||||
}
|
||||
|
||||
return compare(normalizedLeft, normalizedRight)
|
||||
}
|
||||
|
||||
export const isRendererManifestUsable = (
|
||||
manifest: null | Partial<Pick<RendererManifest, "runtimeVersion" | "version">>,
|
||||
input: { appVersion: string; runtimeVersion: string },
|
||||
) => {
|
||||
if (!manifest?.runtimeVersion || manifest.runtimeVersion !== input.runtimeVersion) {
|
||||
return false
|
||||
}
|
||||
|
||||
const versionComparison = compareRendererVersions(manifest.version, input.appVersion)
|
||||
if (versionComparison === null) {
|
||||
return false
|
||||
}
|
||||
|
||||
return versionComparison >= 0
|
||||
}
|
||||
|
||||
class RendererHotUpdater {
|
||||
private readonly logger = log.scope("updater:renderer")
|
||||
private readonly tempDir = path.resolve(os.tmpdir(), "follow-render-update")
|
||||
@@ -74,7 +116,24 @@ class RendererHotUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
if (manifest.version === appVersion) {
|
||||
const versionComparison = compareRendererVersions(manifest.version, appVersion)
|
||||
if (versionComparison === null) {
|
||||
return {
|
||||
status: RendererEligibilityStatus.NoManifest,
|
||||
manifest,
|
||||
reason: `Renderer payload version ${manifest.version} is invalid`,
|
||||
}
|
||||
}
|
||||
|
||||
if (versionComparison < 0) {
|
||||
return {
|
||||
status: RendererEligibilityStatus.AlreadyCurrent,
|
||||
manifest,
|
||||
reason: `Renderer version ${manifest.version} is older than current app version ${appVersion}`,
|
||||
}
|
||||
}
|
||||
|
||||
if (versionComparison === 0) {
|
||||
return {
|
||||
status: RendererEligibilityStatus.AlreadyCurrent,
|
||||
reason: "Renderer version matches current app version",
|
||||
@@ -203,7 +262,7 @@ class RendererHotUpdater {
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
const manifest = this.getCurrentManifest()
|
||||
if (!manifest) {
|
||||
if (!manifest || !isRendererManifestUsable(manifest, getCurrentRendererContext())) {
|
||||
await rm(HOTUPDATE_RENDER_ENTRY_DIR, { recursive: true, force: true })
|
||||
return
|
||||
}
|
||||
@@ -234,6 +293,9 @@ class RendererHotUpdater {
|
||||
|
||||
const manifest = this.getCurrentManifest()
|
||||
if (!manifest) return
|
||||
if (!isRendererManifestUsable(manifest, getCurrentRendererContext())) {
|
||||
return
|
||||
}
|
||||
|
||||
const dir = path.resolve(HOTUPDATE_RENDER_ENTRY_DIR, manifest.version)
|
||||
const entryFile = path.resolve(dir, "index.html")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Folo",
|
||||
"type": "module",
|
||||
"version": "1.6.0",
|
||||
"version": "1.6.1",
|
||||
"private": true,
|
||||
"description": "Follow everything in one place",
|
||||
"author": "Folo Team",
|
||||
@@ -96,7 +96,7 @@
|
||||
"vite-plugin-route-builder": "0.4.1",
|
||||
"vite-tsconfig-paths": "6.1.1"
|
||||
},
|
||||
"runtimeVersion": "1.6.0",
|
||||
"runtimeVersion": "1.6.1",
|
||||
"productName": "Folo",
|
||||
"mainHash": "a146c17f95d7c9383634b40eb933d796eae25c079bba41a0e4a3cdfc62f2dace"
|
||||
"mainHash": "6135b4a64577e6f5b0668b388e8defb987c4a52626594c7eb1b8684c49efe0e6"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.6.0",
|
||||
"version": "1.6.1",
|
||||
"mode": "build",
|
||||
"runtimeVersion": null,
|
||||
"channel": null
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
"@react-native-masked-view/masked-view": "0.3.2",
|
||||
"@react-native-menu/menu": "2.0.0",
|
||||
"@react-native-picker/picker": "2.11.4",
|
||||
"@shikijs/themes": "3.22.0",
|
||||
"@shopify/flash-list": "2.0.2",
|
||||
"@tanstack/query-sync-storage-persister": "5.90.22",
|
||||
"@tanstack/react-query": "5.90.21",
|
||||
@@ -60,16 +61,16 @@
|
||||
"dayjs": "1.11.19",
|
||||
"dnum": "2.17.0",
|
||||
"es-toolkit": "1.44.0",
|
||||
"expo": "55.0.13",
|
||||
"expo": "~55.0.15",
|
||||
"expo-apple-authentication": "55.0.13",
|
||||
"expo-application": "55.0.14",
|
||||
"expo-background-task": "55.0.14",
|
||||
"expo-background-task": "~55.0.16",
|
||||
"expo-blur": "55.0.14",
|
||||
"expo-build-properties": "55.0.13",
|
||||
"expo-clipboard": "55.0.13",
|
||||
"expo-constants": "55.0.13",
|
||||
"expo-dev-client": "55.0.24",
|
||||
"expo-device": "55.0.14",
|
||||
"expo-constants": "~55.0.14",
|
||||
"expo-dev-client": "~55.0.27",
|
||||
"expo-device": "~55.0.15",
|
||||
"expo-document-picker": "55.0.13",
|
||||
"expo-file-system": "55.0.16",
|
||||
"expo-glass-effect": "55.0.10",
|
||||
@@ -79,14 +80,14 @@
|
||||
"expo-image-manipulator": "55.0.15",
|
||||
"expo-image-picker": "~55.0.18",
|
||||
"expo-linear-gradient": "55.0.13",
|
||||
"expo-linking": "55.0.12",
|
||||
"expo-linking": "~55.0.13",
|
||||
"expo-localization": "55.0.13",
|
||||
"expo-media-library": "55.0.14",
|
||||
"expo-network": "55.0.13",
|
||||
"expo-notifications": "55.0.18",
|
||||
"expo-notifications": "~55.0.19",
|
||||
"expo-secure-store": "55.0.13",
|
||||
"expo-sharing": "55.0.18",
|
||||
"expo-splash-screen": "55.0.17",
|
||||
"expo-splash-screen": "~55.0.18",
|
||||
"expo-sqlite": "55.0.15",
|
||||
"expo-status-bar": "55.0.5",
|
||||
"expo-store-review": "~55.0.13",
|
||||
@@ -96,6 +97,7 @@
|
||||
"expo-updates": "55.0.20",
|
||||
"expo-video": "55.0.15",
|
||||
"expo-web-browser": "55.0.14",
|
||||
"foxact": "0.2.52",
|
||||
"franc-min": "6.2.0",
|
||||
"i18next": "25.8.6",
|
||||
"jotai": "2.17.1",
|
||||
@@ -108,12 +110,14 @@
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
"react-error-boundary": "6.1.0",
|
||||
"react-freeze": "1.0.4",
|
||||
"react-hook-form": "7.71.1",
|
||||
"react-i18next": "16.5.4",
|
||||
"react-native": "0.83.4",
|
||||
"react-native-awesome-slider": "2.9.0",
|
||||
"react-native-bouncy-checkbox": "4.1.4",
|
||||
"react-native-color-matrix-image-filters": "8.0.2",
|
||||
"react-native-css-interop": "0.2.1",
|
||||
"react-native-device-info": "15.0.1",
|
||||
"react-native-edge-to-edge": "1.7.0",
|
||||
"react-native-gesture-handler": "2.30.1",
|
||||
@@ -147,6 +151,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.29.0",
|
||||
"@follow/configs": "workspace:*",
|
||||
"@tailwindcss/typography": "0.5.19",
|
||||
"@types/react": "19.2.14",
|
||||
"babel-plugin-inline-import": "3.0.0",
|
||||
"eas-cli": "16.26.0",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { AndroidConfig, withAndroidManifest } = require("@expo/config-plugins")
|
||||
const { Paths } = require("@expo/config-plugins/build/android")
|
||||
const { AndroidConfig, withAndroidManifest } = require("expo/config-plugins")
|
||||
const path = require("pathe")
|
||||
const fs = require("node:fs")
|
||||
|
||||
@@ -17,7 +16,7 @@ const withTrustLocalCerts = (config) => {
|
||||
async function setCustomConfigAsync(config, androidManifest) {
|
||||
const src_file_pat = path.join(__dirname, "network_security_config.xml")
|
||||
const res_file_path = path.join(
|
||||
await Paths.getResourceFolderAsync(config.modRequest.projectRoot),
|
||||
await AndroidConfig.Paths.getResourceFolderAsync(config.modRequest.projectRoot),
|
||||
"xml",
|
||||
"network_security_config.xml",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
function buildMarkers(comment, tag) {
|
||||
return {
|
||||
start: `${comment} @generated begin ${tag}`,
|
||||
end: `${comment} @generated end ${tag}`,
|
||||
}
|
||||
}
|
||||
|
||||
function findAnchorIndex(lines, anchor) {
|
||||
if (typeof anchor === "string") {
|
||||
return lines.findIndex((line) => line.includes(anchor))
|
||||
}
|
||||
return lines.findIndex((line) => anchor.test(line))
|
||||
}
|
||||
|
||||
function mergeContents({ src, anchor, newSrc, offset = 0, tag, comment = "//" }) {
|
||||
const { start, end } = buildMarkers(comment, tag)
|
||||
const block = [start, newSrc.trimEnd(), end].join("\n")
|
||||
|
||||
const startIndex = src.indexOf(start)
|
||||
const endIndex = src.indexOf(end)
|
||||
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
|
||||
return {
|
||||
contents: `${src.slice(0, startIndex)}${block}${src.slice(endIndex + end.length)}`,
|
||||
}
|
||||
}
|
||||
|
||||
const lines = src.split("\n")
|
||||
const anchorIndex = findAnchorIndex(lines, anchor)
|
||||
if (anchorIndex === -1) {
|
||||
throw new Error(`Failed to find anchor for generated block: ${tag}`)
|
||||
}
|
||||
|
||||
const insertAt = Math.min(lines.length, anchorIndex + offset + 1)
|
||||
lines.splice(insertAt, 0, block)
|
||||
|
||||
return {
|
||||
contents: lines.join("\n"),
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
mergeContents,
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
const { withGradleProperties } = require("@expo/config-plugins")
|
||||
const { withGradleProperties } = require("expo/config-plugins")
|
||||
|
||||
function setGradleProperty(config, key, value) {
|
||||
return withGradleProperties(config, (config) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { withAppDelegate } = require("@expo/config-plugins")
|
||||
const { mergeContents } = require("@expo/config-plugins/build/utils/generateCode")
|
||||
const { withAppDelegate } = require("expo/config-plugins")
|
||||
|
||||
const { mergeContents } = require("./merge-contents")
|
||||
|
||||
const withFollowAppDelegate = (config) => {
|
||||
return withAppDelegate(config, async (config) => {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* - [spacedrive](https://github.com/spacedriveapp/spacedrive/blob/main/apps/mobile/scripts/withRiveAssets.js)
|
||||
*/
|
||||
|
||||
const { withDangerousMod, withXcodeProject, IOSConfig } = require("@expo/config-plugins")
|
||||
const { withDangerousMod, withXcodeProject, IOSConfig } = require("expo/config-plugins")
|
||||
const fs = require("node:fs")
|
||||
const path = require("pathe")
|
||||
const { execSync } = require("node:child_process")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { withDangerousMod, withXcodeProject, IOSConfig } = require("@expo/config-plugins")
|
||||
const { withDangerousMod, withXcodeProject, IOSConfig } = require("expo/config-plugins")
|
||||
const fs = require("node:fs")
|
||||
const path = require("pathe")
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { withPodfile, withPodfileProperties } = require("@expo/config-plugins")
|
||||
const { mergeContents } = require("@expo/config-plugins/build/utils/generateCode")
|
||||
const { withPodfile, withPodfileProperties } = require("expo/config-plugins")
|
||||
|
||||
const { mergeContents } = require("./merge-contents")
|
||||
|
||||
const STATIC_FRAMEWORK_TAG = "follow-rnfb-static-framework"
|
||||
const RNFB_IOS_COMPAT_TAG = "follow-rnfb-ios-compat"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EventBus } from "@follow/utils/event-bus"
|
||||
import type { NativeModule } from "expo"
|
||||
import { requireNativeModule } from "expo-modules-core"
|
||||
import { requireNativeModule } from "expo"
|
||||
|
||||
import { htmlUrl } from "./constants"
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// Original code copied and simplified from the link below as the codebase is currently not maintained:
|
||||
// https://github.com/jobtoday/react-native-image-viewing
|
||||
|
||||
// import * as ScreenOrientation from "expo-screen-orientation"
|
||||
import * as React from "react"
|
||||
import { useCallback, useMemo, useState } from "react"
|
||||
import { LayoutAnimation, PixelRatio, ScrollView, StyleSheet, View } from "react-native"
|
||||
@@ -47,7 +46,6 @@ type Rect = {
|
||||
height: number
|
||||
}
|
||||
|
||||
// const { PORTRAIT_UP } = ScreenOrientation.OrientationLock
|
||||
const PIXEL_RATIO = PixelRatio.get()
|
||||
const SLOW_SPRING: WithSpringConfig = {
|
||||
mass: isIOS ? 1.25 : 0.75,
|
||||
|
||||
@@ -12,12 +12,29 @@
|
||||
"@emotion/is-prop-valid": "1.3.1",
|
||||
"@follow/components": "workspace:*",
|
||||
"@follow/configs": "workspace:*",
|
||||
"@follow/hooks": "workspace:*",
|
||||
"@follow/shared": "workspace:*",
|
||||
"@follow/types": "workspace:*",
|
||||
"@follow/utils": "workspace:*",
|
||||
"@shikijs/transformers": "3.22.0",
|
||||
"clsx": "2.1.1",
|
||||
"foxact": "0.2.52",
|
||||
"jotai": "2.17.1",
|
||||
"katex": "0.16.28",
|
||||
"motion": "12.34.0",
|
||||
"react": "19.0.0",
|
||||
"react-blurhash": "0.3.0"
|
||||
"react-blurhash": "0.3.0",
|
||||
"react-dom": "19.0.0",
|
||||
"shiki": "3.22.0",
|
||||
"usehooks-ts": "3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/hast": "3.0.4",
|
||||
"@vitejs/plugin-react": "5.1.4",
|
||||
"hast-util-to-jsx-runtime": "2.3.6",
|
||||
"pathe": "2.0.3",
|
||||
"typescript": "catalog:",
|
||||
"vite": "7.3.1",
|
||||
"vitest": "3.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,14 +90,14 @@ export const parseHtml = (
|
||||
hr: ({ node, ...props }) =>
|
||||
createElement("hr", {
|
||||
...props,
|
||||
className: tw`scale-x-50`,
|
||||
className: "scale-x-50",
|
||||
}),
|
||||
input: ({ node, ...props }) => {
|
||||
if (props.type === "checkbox") {
|
||||
return createElement(Checkbox, {
|
||||
...props,
|
||||
disabled: false,
|
||||
className: tw`pointer-events-none mr-2`,
|
||||
className: "pointer-events-none mr-2",
|
||||
})
|
||||
}
|
||||
return createElement("input", props)
|
||||
@@ -170,7 +170,7 @@ export const parseHtml = (
|
||||
|
||||
createElement("table", {
|
||||
...props,
|
||||
className: tw`w-full my-0`,
|
||||
className: "w-full my-0",
|
||||
}),
|
||||
),
|
||||
video: ({ node, ...props }) =>
|
||||
|
||||
@@ -2,11 +2,7 @@ import react from "@vitejs/plugin-react"
|
||||
import path from "pathe"
|
||||
import { defineConfig } from "vite"
|
||||
|
||||
import { viteRenderBaseConfig } from "../../../desktop/configs/vite.render.config"
|
||||
import { astPlugin } from "../../../desktop/plugins/vite/ast"
|
||||
|
||||
export default defineConfig({
|
||||
...viteRenderBaseConfig,
|
||||
base: "",
|
||||
build: {
|
||||
outDir: path.resolve(import.meta.dirname, "../../../../out/rn-web/html-renderer"),
|
||||
@@ -19,6 +15,5 @@ export default defineConfig({
|
||||
define: {
|
||||
ELECTRON: "false",
|
||||
},
|
||||
|
||||
plugins: [react({}), astPlugin],
|
||||
plugins: [react({})],
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "cd html-renderer && vite build",
|
||||
"typecheck": "cd html-renderer && tsc --noEmit"
|
||||
"build": "pnpm --dir html-renderer build",
|
||||
"typecheck": "pnpm --dir html-renderer typecheck"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export default defineConfig(
|
||||
formatting: false,
|
||||
lessOpinionated: true,
|
||||
ignores: [
|
||||
".context/**",
|
||||
"resources/**",
|
||||
"apps/mobile/android/**",
|
||||
"apps/mobile/ios/**",
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
"@babel/parser": "7.29.0",
|
||||
"@babel/traverse": "7.29.0",
|
||||
"@babel/types": "7.29.0",
|
||||
"@electron-toolkit/tsconfig": "2.0.0",
|
||||
"@eslint/compat": "1.4.1",
|
||||
"@tsslint/cli": "2.0.7",
|
||||
"@tsslint/config": "2.0.7",
|
||||
|
||||
@@ -64,7 +64,9 @@
|
||||
"@types/hast": "3.0.4",
|
||||
"@types/unist": "3.0.3",
|
||||
"class-variance-authority": "0.7.1",
|
||||
"clsx": "2.1.1",
|
||||
"dayjs": "1.11.19",
|
||||
"es-toolkit": "1.44.0",
|
||||
"foxact": "0.2.52",
|
||||
"hast-util-to-jsx-runtime": "2.3.6",
|
||||
"hast-util-to-text": "4.0.2",
|
||||
@@ -77,7 +79,9 @@
|
||||
"react-blurhash": "0.3.0",
|
||||
"react-fast-marquee": "1.6.5",
|
||||
"react-hook-form": "7.71.1",
|
||||
"react-hotkeys-hook": "5.2.4",
|
||||
"react-i18next": "16.5.4",
|
||||
"react-router": "7.13.0",
|
||||
"rehype-infer-description-meta": "2.0.0",
|
||||
"rehype-parse": "9.0.1",
|
||||
"rehype-sanitize": "6.0.0",
|
||||
@@ -85,6 +89,7 @@
|
||||
"remark-directive": "4.0.0",
|
||||
"remark-gfm": "4.0.1",
|
||||
"remark-gh-alerts": "0.0.3",
|
||||
"remark-parse": "11.0.0",
|
||||
"remark-rehype": "11.1.2",
|
||||
"sonner": "2.0.7",
|
||||
"tailwindcss-uikit-colors": "catalog:",
|
||||
@@ -94,7 +99,8 @@
|
||||
"use-context-selector": "2.0.0",
|
||||
"usehooks-ts": "3.1.1",
|
||||
"vaul": "1.1.2",
|
||||
"vfile": "5.3.7"
|
||||
"vfile": "5.3.7",
|
||||
"zustand": "5.0.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@follow/configs": "workspace:*",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { viewportAtom } from "@follow/components/atoms/viewport.js"
|
||||
import { throttle } from "es-toolkit/compat"
|
||||
import { useIsomorphicLayoutEffect } from "foxact/use-isomorphic-layout-effect"
|
||||
import { useStore } from "jotai"
|
||||
import type { FC } from "react"
|
||||
|
||||
import { mouseAtom } from "../atoms/mouse"
|
||||
import { viewportAtom } from "../atoms/viewport"
|
||||
|
||||
export const EventProvider: FC = () => {
|
||||
const store = useStore()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { setNavigate, setRoute } from "@follow/components/atoms/route.js"
|
||||
import { useLayoutEffect } from "react"
|
||||
import type { NavigateFunction } from "react-router"
|
||||
import { useLocation, useNavigate, useParams, useSearchParams } from "react-router"
|
||||
|
||||
import { setNavigate, setRoute } from "../atoms/route"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
export interface CustomRoute {}
|
||||
export interface GlobalRoute extends CustomRoute {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import {
|
||||
useFocusable,
|
||||
useGlobalFocusableScopeSelector,
|
||||
} from "@follow/components/common/Focusable/index.js"
|
||||
import type { EnhanceSet } from "@follow/utils"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { cn, getOS } from "@follow/utils/utils"
|
||||
@@ -10,6 +6,7 @@ import { useCallback, useState } from "react"
|
||||
import type { Options } from "react-hotkeys-hook"
|
||||
import { useHotkeys } from "react-hotkeys-hook"
|
||||
|
||||
import { useFocusable, useGlobalFocusableScopeSelector } from "../../common/Focusable"
|
||||
import { KbdCombined } from "../kbd/Kbd"
|
||||
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "../tooltip"
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { VariantProps } from "class-variance-authority"
|
||||
import type { HTMLMotionProps } from "motion/react"
|
||||
import { m } from "motion/react"
|
||||
import * as React from "react"
|
||||
|
||||
import { useMobile } from "../../hooks/useMobile"
|
||||
import { LoadingCircle } from "../loading"
|
||||
import { styledButtonVariant } from "./variants"
|
||||
|
||||
export interface BaseButtonProps {
|
||||
|
||||
@@ -219,4 +219,4 @@ export {
|
||||
ContextMenuTrigger,
|
||||
}
|
||||
|
||||
export { RootPortal as ContextMenuPortal } from "@follow/components/ui/portal/index.jsx"
|
||||
export { RootPortal as ContextMenuPortal } from "../portal"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { Input } from "@follow/components/ui/input/index.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
|
||||
import { Button } from "../button"
|
||||
import { Input } from "../input"
|
||||
|
||||
export interface KeyValuePair {
|
||||
key: string
|
||||
value: string
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
||||
import { m } from "motion/react"
|
||||
import * as React from "react"
|
||||
|
||||
import { Spring } from "../../constants/spring"
|
||||
import { tooltipStyle, tooltipStyles } from "./styles"
|
||||
|
||||
const TooltipProvider = TooltipPrimitive.Provider
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { useViewport } from "@follow/components/hooks/useViewport.js"
|
||||
import type { ComponentType, ReactNode, RefAttributes } from "react"
|
||||
import { lazy, Suspense } from "react"
|
||||
|
||||
import { useMobile } from "../hooks/useMobile"
|
||||
import { useViewport } from "../hooks/useViewport"
|
||||
|
||||
export function withResponsiveComponent<P extends object>(
|
||||
desktopImport: () => Promise<{ default: ComponentType<P> }>,
|
||||
mobileImport: () => Promise<{ default: ComponentType<P> }>,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./src/index.ts",
|
||||
"require": "./src/index.js"
|
||||
"require": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@@ -15,8 +15,11 @@
|
||||
"@follow/shared": "workspace:*",
|
||||
"@follow/types": "workspace:*",
|
||||
"@follow/utils": "workspace:*",
|
||||
"@tanstack/react-query": "5.90.21",
|
||||
"es-toolkit": "1.44.0",
|
||||
"foxact": "0.2.52",
|
||||
"jotai": "2.17.1",
|
||||
"sonner": "2.0.7",
|
||||
"usehooks-ts": "3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -113,8 +113,12 @@
|
||||
"@follow/tracker": "workspace:*",
|
||||
"@follow/utils": "workspace:*",
|
||||
"@tanstack/react-query": "5.90.21",
|
||||
"@yornaath/batshit": "0.14.0",
|
||||
"es-toolkit": "1.44.0",
|
||||
"i18next": "25.8.6",
|
||||
"immer": "11.1.4",
|
||||
"jotai": "2.17.1",
|
||||
"sf-symbols-typescript": "2.2.0",
|
||||
"zustand": "5.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,15 +33,32 @@
|
||||
"@follow/shared": "workspace:*",
|
||||
"@follow/types": "workspace:*",
|
||||
"@mozilla/readability": "0.6.0",
|
||||
"@types/hast": "3.0.4",
|
||||
"@types/unist": "3.0.3",
|
||||
"chardet": "2.1.1",
|
||||
"clsx": "2.1.1",
|
||||
"dayjs": "1.11.19",
|
||||
"dompurify": "3.3.1",
|
||||
"es-toolkit": "1.44.0",
|
||||
"franc-min": "6.2.0",
|
||||
"hast-util-sanitize": "5.0.2",
|
||||
"hast-util-to-jsx-runtime": "2.3.6",
|
||||
"hast-util-to-text": "4.0.2",
|
||||
"jotai": "2.17.1",
|
||||
"motion": "12.34.0",
|
||||
"nanoid": "5.1.6",
|
||||
"path-to-regexp": "8.3.0",
|
||||
"rehype-infer-description-meta": "2.0.0",
|
||||
"rehype-parse": "9.0.1",
|
||||
"rehype-sanitize": "6.0.0",
|
||||
"rehype-stringify": "10.0.1",
|
||||
"tailwind-merge": "3.4.0",
|
||||
"tldts": "7.0.23",
|
||||
"uniqolor": "1.1.1"
|
||||
"unified": "11.0.5",
|
||||
"uniqolor": "1.1.1",
|
||||
"unist-util-visit": "5.1.0",
|
||||
"unist-util-visit-parents": "5.1.3",
|
||||
"zustand": "5.0.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@follow/configs": "workspace:*",
|
||||
|
||||
@@ -11,7 +11,6 @@ import rehypeParse from "rehype-parse"
|
||||
import rehypeSanitize, { defaultSchema } from "rehype-sanitize"
|
||||
import rehypeStringify from "rehype-stringify"
|
||||
import { unified } from "unified"
|
||||
import type { Node } from "unist"
|
||||
import { visit } from "unist-util-visit"
|
||||
import { visitParents } from "unist-util-visit-parents"
|
||||
|
||||
@@ -25,6 +24,10 @@ type ParseHtmlOptions = {
|
||||
hastTransform?: (tree: Root) => void
|
||||
}
|
||||
|
||||
type CompatibleVisitTree = Parameters<typeof visit>[0]
|
||||
type CompatibleVisitParentsTree = Parameters<typeof visitParents>[0]
|
||||
type CompatibleAncestor = Element | Parent | Root | Text
|
||||
|
||||
const spotlightExcludedTagNames = new Set([
|
||||
"code",
|
||||
"pre",
|
||||
@@ -237,18 +240,20 @@ export const parseHtml = (content: string, options?: ParseHtmlOptions) => {
|
||||
|
||||
const tree = pipeline.parse(content)
|
||||
|
||||
rehypeUrlToAnchor(tree)
|
||||
rehypeUrlToAnchor(tree as CompatibleVisitParentsTree)
|
||||
|
||||
// console.log("tree", tree)
|
||||
|
||||
const hastTree = pipeline.runSync(tree, content)
|
||||
const hastTree = pipeline.runSync(tree, content) as Root
|
||||
hastTransform?.(hastTree as Root)
|
||||
|
||||
const images = [] as string[]
|
||||
|
||||
visit(tree, "element", (node) => {
|
||||
if (node.tagName === "img" && node.properties.src) {
|
||||
images.push(node.properties.src as string)
|
||||
visit(hastTree as CompatibleVisitTree, "element", (node) => {
|
||||
const element = node as Element
|
||||
|
||||
if (element.tagName === "img" && typeof element.properties.src === "string") {
|
||||
images.push(element.properties.src)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -268,12 +273,15 @@ export const parseHtml = (content: string, options?: ParseHtmlOptions) => {
|
||||
}
|
||||
}
|
||||
|
||||
function rehypeUrlToAnchor(tree: Node) {
|
||||
function rehypeUrlToAnchor(tree: CompatibleVisitParentsTree) {
|
||||
const tagsShouldNotBeWrapped = new Set(["a", "pre", "code"])
|
||||
// https://chatgpt.com/share/37e0ceec-5c9e-4086-b9d6-5afc1af13bb0
|
||||
visitParents(tree as any, "text", (node: Text, ancestors: Node[]) => {
|
||||
visitParents(tree, "text", (node, ancestors) => {
|
||||
const textNode = node as Text
|
||||
const typedAncestors = ancestors as CompatibleAncestor[]
|
||||
|
||||
if (
|
||||
ancestors.some(
|
||||
typedAncestors.some(
|
||||
(ancestor) =>
|
||||
"tagName" in ancestor && tagsShouldNotBeWrapped.has((ancestor as Element).tagName),
|
||||
)
|
||||
@@ -281,10 +289,10 @@ function rehypeUrlToAnchor(tree: Node) {
|
||||
return
|
||||
}
|
||||
|
||||
const parent = ancestors.at(-1)
|
||||
const parent = typedAncestors.at(-1)
|
||||
|
||||
const urlRegex = /https?:\/\/\S+/g
|
||||
const text = node.value
|
||||
const text = textNode.value
|
||||
const matches = [...text.matchAll(urlRegex)]
|
||||
|
||||
if (matches.length === 0 || !parent || !("children" in parent)) return
|
||||
@@ -324,7 +332,7 @@ function rehypeUrlToAnchor(tree: Node) {
|
||||
})
|
||||
}
|
||||
|
||||
const index = (parent.children as (Text | Element)[]).indexOf(node)
|
||||
const index = (parent.children as (Text | Element)[]).indexOf(textNode)
|
||||
;(parent.children as (Text | Element)[]).splice(index, 1, ...newNodes)
|
||||
})
|
||||
}
|
||||
|
||||
Generated
+580
-359
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ packages:
|
||||
- apps/desktop/layer/*
|
||||
- "!apps/mobile/native/example"
|
||||
- apps/mobile/web-app
|
||||
- apps/mobile/web-app/html-renderer
|
||||
- "!**/example"
|
||||
- "!**/example/**"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user