mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
* chore(app): vendor react-native-enriched-markdown with the Paseo patch applied Copy react-native-enriched-markdown@1.2.0-nightly-20261014-766fc0e67 (upstream software-mansion/enriched-markdown 766fc0e67) into packages/react-native-enriched-markdown, with patches/react-native-enriched-markdown+1.2.0-nightly-20261014-766fc0e67.patch applied. Nothing else changes in this commit; the package is not a workspace yet. Reproduce: npm pack react-native-enriched-markdown@1.2.0-nightly-20261014-766fc0e67 tar xzf react-native-enriched-markdown-*.tgz mkdir -p t/node_modules && mv package t/node_modules/react-native-enriched-markdown (cd t && git init -q && git apply ../patches/react-native-enriched-markdown+*.patch) diff -r t/node_modules/react-native-enriched-markdown packages/react-native-enriched-markdown The diff is empty. * chore(app): consume react-native-enriched-markdown from its workspace Make packages/react-native-enriched-markdown a private workspace and point the app at it, then remove the patch-package patch it replaces. - package.json: private, version follows the root like every workspace, only the postinstall script that downloads tree-sitter grammars. Upstream's devDependencies would install a second react-native, so they are gone. - The package keeps its name, so autolinking, the Gradle project :react-native-enriched-markdown, the CocoaPods spec and imports are unchanged. - Lockfile: drop the nested registry copy under packages/app/node_modules; npm links node_modules/react-native-enriched-markdown to the workspace. - Formatting, lint and knip skip the vendored code. CI routes changes to it through the app and browser suites. - The codegen test checks the vendored package's generated props. - docs/markdown-renderer.md describes the fork and how to edit it. * fix(app): keep numbered sub-list markers off their text on Android From #9964, moved from the package patch into the vendored package. On Android, a numbered list nested in a bulleted item drew "1." over the first letters of each item. A nested item's text indent summed the root list's narrow bullet column with a fixed marginLeft, while its marker was right-aligned to its own wider "99." column, so the number landed on the text. iOS already indents from the item's own column. Backport the Android hunks of upstream enriched-markdown #1015 (size the number column to the widest marker) and #1023 (nested items start their text from their own marker column). test:android now also runs the backported ListRenderingTest and TaskListInteractionTest suites. docs/markdown-renderer.md lists the fork's backports, this one and #924, which the removed postinstall comment used to track. The vendored tree equals the #9964 patch applied to the pristine package. * fix(app): keep Android assistant replies inside their turns From #10380, moved from the package patch into the vendored package. On Android, an assistant reply with blockquotes nested inside a list could overlap its "Worked for ..." footer and the next user message: the displayed text and the layout measurement applied spans in different orders, and the list-wide line height inflated the blockquote spacers when it ran after them. Use the same span order for Android Markdown measurement and display. Apply list line height before blockquote spacers so nested quotes keep their configured padding and the reply fits above the turn footer. test:android now also runs ListBlockquoteMeasurementTest. Applied on top of #9964; the two changes share only ListRenderer.kt, where #10380's import and line-height call sit beside #9964's marker width code. Every other file equals the #10380 patch applied to the pristine package. * chore(app): match the vendored Markdown web block renderer source to its build The package patch changed lib/module/web/renderers/BlockRenderers.js (the renderers.codeBlock override and the zoom-in cursor on images) but not src/web/renderers/BlockRenderers.tsx. The app runs lib, so behavior does not change. Port both changes into src so src stays the source of lib.
169 lines
7.7 KiB
JavaScript
169 lines
7.7 KiB
JavaScript
import { copyFileSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
import { spawnSync } from "node:child_process";
|
|
import { join, relative } from "node:path";
|
|
|
|
// In CI we often install a single workspace (e.g. server/relay/website). Only apply patches
|
|
// when the patched dependency is actually present.
|
|
// `cwd` is where patch-package must run from. Packages that npm does not hoist to the
|
|
// workspace root live in their workspace's own node_modules, and patch-package resolves
|
|
// the patch's node_modules/... paths relative to its working directory.
|
|
const patchedPackages = [
|
|
// Backport for expo-modules-core 57.0.23: https://github.com/expo/expo/pull/49634.
|
|
// Remove when the installed Expo SDK includes the Activity recreation fix.
|
|
{
|
|
nodeModulesPath: "node_modules/expo-modules-core",
|
|
patchPrefix: "expo-modules-core+",
|
|
},
|
|
// Registry cleanup: remove after react-native-unistyles ships
|
|
// https://github.com/jpudysz/react-native-unistyles/pull/1203.
|
|
// Adaptive themes: keep until colorScheme reads no longer consume listener-owned media changes.
|
|
// withUnistyles: also keep the uniProps filter until upstream consumes its control prop.
|
|
// Android configuration: backport 3.5.3; remove the two NativePlatform hunks at >= 3.5.3.
|
|
// https://github.com/jpudysz/react-native-unistyles/compare/v3.5.2...v3.5.3
|
|
// Layout constraints: backport of https://github.com/jpudysz/react-native-unistyles/pull/1357
|
|
// (commit from the root the commit hands us, so a concurrent window-size commit is kept).
|
|
// Remove the ShadowTreeManager hunk when the installed release includes that PR.
|
|
{
|
|
nodeModulesPath: "node_modules/react-native-unistyles",
|
|
patchPrefix: "react-native-unistyles+",
|
|
},
|
|
// Backport of https://github.com/software-mansion/react-native-reanimated/pull/10435
|
|
// (Reanimated 4.7.1): skip synchronous Android prop updates for unmounted view tags
|
|
// instead of throwing and printing a full stack trace on the UI thread per tag per event.
|
|
// Remove when the installed Reanimated is >= 4.7.1.
|
|
{
|
|
nodeModulesPath: "node_modules/react-native-reanimated",
|
|
patchPrefix: "react-native-reanimated+",
|
|
},
|
|
// The native chat timeline. The patch's header lists its hunks and the upstream issue.
|
|
{
|
|
nodeModulesPath: "node_modules/@legendapp/list",
|
|
patchPrefix: "@legendapp+list+",
|
|
},
|
|
// Native sidebar lists. Besides gesture sessions and panel-gesture arbitration, the drop gives
|
|
// each moved cell a fresh transform host. Reanimated re-applies a view's last animated
|
|
// transform to every React commit, so a reused host painted one frame of new order plus old
|
|
// drag translate (upstream computerjazz/react-native-draggable-flatlist#621, open).
|
|
{
|
|
nodeModulesPath: "node_modules/react-native-draggable-flatlist",
|
|
patchPrefix: "react-native-draggable-flatlist+",
|
|
},
|
|
// Web pointer capture: capture only pointers the handler still tracks after pointer-down, so a
|
|
// touch-only pan that fails the mouse leaves browser text selection alone. Keep until upstream
|
|
// stops capturing pointers a handler has rejected.
|
|
{
|
|
nodeModulesPath: "node_modules/react-native-gesture-handler",
|
|
patchPrefix: "react-native-gesture-handler+",
|
|
},
|
|
// Exports BottomSheetModalInternalProvider so a subtree can host its own sheets on the shared
|
|
// modal stack (see packages/app/src/components/ui/isolated-bottom-sheet-modal/host-scope.tsx), and
|
|
// keeps a dismissing modal's status through its final onChange(-1), so a modal with
|
|
// enableDismissOnClose=false that unmounts while presented still leaves the portal, and removes
|
|
// the portal of a modal that unmounts before its opening animation starts.
|
|
// Dimensions subscription cleanup: https://github.com/gorhom/react-native-bottom-sheet/issues/2734
|
|
// and https://github.com/gorhom/react-native-bottom-sheet/pull/2751. Remove the useAnimatedLayout
|
|
// hunks once an installed release includes the cleanup; retain the other local hunks.
|
|
{
|
|
nodeModulesPath: "node_modules/@gorhom/bottom-sheet",
|
|
patchPrefix: "@gorhom+bottom-sheet+",
|
|
},
|
|
// Android resize: retain until upstream clears descendant geometry when the SVG canvas resizes.
|
|
// The native pixel regression is included in the patch; preserve the separate transform hunks.
|
|
{
|
|
nodeModulesPath: "packages/app/node_modules/react-native-svg",
|
|
patchPrefix: "react-native-svg+",
|
|
cwd: "packages/app",
|
|
},
|
|
// Reconcile ResponderEventPlugin trackedTouchCount and ResponderTouchHistoryStore touchBank with
|
|
// nativeEvent.touches.length so an unmatched touch start or single-pointer synthetic cancel
|
|
// (e.g. Modal dismiss while touching, RNGH pinch takeover, or double ACTION_DOWN in
|
|
// ReactRootView/ReactModalHostView) self-heals instead of leaving trackedTouchCount > 0 or stale
|
|
// active contacts in touchBank. Remove once upstream React/React Native reconciles both.
|
|
{
|
|
nodeModulesPath: "node_modules/react-native",
|
|
patchPrefix: "react-native+",
|
|
},
|
|
// Keep Android PasteTextInput aligned with RN AndroidTextInput (omit iOS-only
|
|
// onSelectionChangeShouldSetResponder), plus ref/eventCount/trailing-newline fixes.
|
|
{
|
|
nodeModulesPath: "node_modules/@mattermost/react-native-paste-input",
|
|
patchPrefix: "@mattermost+react-native-paste-input+",
|
|
},
|
|
// Backport of https://github.com/mermaid-js/mermaid/pull/8459 (lexer half): a flowchart label
|
|
// with an "@" parses. The patch header has the details. Remove when the app uses mermaid 12.
|
|
{
|
|
nodeModulesPath: "node_modules/mermaid",
|
|
patchPrefix: "mermaid+",
|
|
},
|
|
{
|
|
nodeModulesPath: "packages/server/node_modules/@opencode-ai/sdk",
|
|
patchPrefix: "@opencode-ai+sdk+",
|
|
cwd: "packages/server",
|
|
},
|
|
];
|
|
|
|
const installedPackages = patchedPackages.filter(({ nodeModulesPath }) =>
|
|
existsSync(nodeModulesPath),
|
|
);
|
|
|
|
if (!existsSync("patches") || installedPackages.length === 0) {
|
|
process.exit(0);
|
|
}
|
|
|
|
const patchFiles = readdirSync("patches").filter((file) => file.endsWith(".patch"));
|
|
|
|
const isWindows = process.platform === "win32";
|
|
const cmd = isWindows ? "patch-package.cmd" : "patch-package";
|
|
|
|
let failed = false;
|
|
for (const [index, { nodeModulesPath, patchPrefix, cwd = "." }] of installedPackages.entries()) {
|
|
const files = patchFiles.filter((file) => file.startsWith(patchPrefix));
|
|
if (files.length === 0) {
|
|
continue;
|
|
}
|
|
const outcome = applyPatches(cwd, files, index);
|
|
if (outcome === "applied") {
|
|
continue;
|
|
}
|
|
failed = true;
|
|
if (outcome === "unavailable") {
|
|
continue;
|
|
}
|
|
// patch-package cannot apply a patch that changed after an earlier version of it was
|
|
// applied. Without the package, the next install fetches it clean and applies the patch.
|
|
rmSync(nodeModulesPath, { recursive: true, force: true });
|
|
console.error(
|
|
`postinstall-patches: removed ${nodeModulesPath} because its patch did not apply. ` +
|
|
"Run npm install again to reinstall it with the current patch. " +
|
|
"If it fails again on the clean package, the patch is out of date and must be regenerated.",
|
|
);
|
|
}
|
|
|
|
process.exit(failed ? 1 : 0);
|
|
|
|
function applyPatches(cwd, files, index) {
|
|
const tempPatchDir = join(".tmp", `postinstall-patches-${process.pid}-${index}`);
|
|
mkdirSync(tempPatchDir, { recursive: true });
|
|
for (const patchFile of files) {
|
|
copyFileSync(join("patches", patchFile), join(tempPatchDir, patchFile));
|
|
}
|
|
|
|
let result;
|
|
try {
|
|
result = spawnSync(cmd, ["--patch-dir", relative(cwd, tempPatchDir), "--error-on-fail"], {
|
|
cwd,
|
|
shell: isWindows,
|
|
stdio: "inherit",
|
|
windowsHide: true,
|
|
});
|
|
} finally {
|
|
rmSync(tempPatchDir, { recursive: true, force: true });
|
|
}
|
|
|
|
if (result.error) {
|
|
console.error("postinstall-patches: patch-package failed to spawn:", result.error.message);
|
|
return "unavailable";
|
|
}
|
|
return result.status === 0 ? "applied" : "rejected";
|
|
}
|