π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat: add Lottie arrow parsing utility functions
Aswin Asokd868d7260f1b
diff --git a/web/apps/paste/public/images/metaimage.png b/web/apps/paste/public/images/metaimage.pngnew file mode 100644index 0000000000..0acb933c7bBinary files /dev/null and b/web/apps/paste/public/images/metaimage.png differdiff --git a/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx b/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsxindex cd4834497f..b4b85e9af7 100644--- a/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx+++ b/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx@@ -1,6 +1,6 @@import { Navigation06Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import { Box, IconButton, TextField, Typography } from "@mui/material";+import { Box, CircularProgress, IconButton, TextField, Typography } from "@mui/material";import { MAX_PASTE_CHARS } from "../constants";import { PasteLinkCard } from "./PasteLinkCard";import { pasteTextFieldSx } from "./textFieldSx";@@ -32,6 +32,7 @@ export const PasteCreatePanel = ({const inputGlassBorder = "rgba(213, 225, 255, 0.14)";const nearLimitThreshold = Math.floor(MAX_PASTE_CHARS * 0.9);const isNearCharLimit = inputText.length >= nearLimitThreshold;+ const isCreateDisabled = isInputEmpty;const mutedCounterColor = "rgba(234, 238, 255, 0.6)";const softBlueCounterColor = "rgba(204, 224, 255, 0.96)";const privacyPills = [@@ -75,8 +76,11 @@ export const PasteCreatePanel = ({),{"& .MuiFilledInput-root": {- paddingBottom: { xs: "76px", sm: "84px" },- padding: { xs: "12px", sm: "14px" },+ paddingTop: { xs: "12px", sm: "14px" },+ paddingRight: { xs: "12px", sm: "14px" },+ paddingLeft: { xs: "12px", sm: "14px" },+ // Keep only the minimum reserve needed for the footer row.+ paddingBottom: { xs: "50px", sm: "56px" },backdropFilter: "blur(9px) saturate(112%)",WebkitBackdropFilter: "blur(9px) saturate(112%)",background:@@ -112,11 +116,11 @@ export const PasteCreatePanel = ({position: "absolute",left: { xs: 12, sm: 18 },right: { xs: 12, sm: 18 },- bottom: { xs: 12, sm: 18 },- height: { xs: 44, sm: 48 },+ bottom: { xs: 8, sm: 10 },+ height: { xs: 36, sm: 40 },display: "flex",justifyContent: "space-between",- alignItems: "flex-end",+ alignItems: "center",gap: { xs: 1, sm: 2 },pointerEvents: "none",}}@@ -126,11 +130,7 @@ export const PasteCreatePanel = ({sx={{display: "flex",alignItems: "center",- height: { xs: 40, sm: 44 },- transform: {- xs: "translateY(8px)",- md: "translateY(12px)",- },+ height: { xs: 32, sm: 36 },color: mutedCounterColor,fontWeight: 600,lineHeight: 1,@@ -153,14 +153,16 @@ export const PasteCreatePanel = ({</Typography><IconButtonaria-label="Create secure link"+ aria-busy={creating}onClick={() => {+ if (creating || isCreateDisabled) return;void onCreate();}}- disabled={creating || isInputEmpty}+ disabled={isCreateDisabled}sx={{pointerEvents: "auto",- width: { xs: 40, sm: 44 },- height: { xs: 40, sm: 44 },+ width: { xs: 34, sm: 38 },+ height: { xs: 34, sm: 38 },borderRadius: { xs: "12px", sm: "14px" },bgcolor: frameBlue,color: "#f4f7ff",@@ -170,27 +172,35 @@ export const PasteCreatePanel = ({boxShadow: "none",},"&.Mui-disabled": {- bgcolor: isInputEmpty+ bgcolor: isCreateDisabled? "rgba(255, 255, 255, 0.18)": "rgba(47, 109, 247, 0.45)",- color: isInputEmpty+ color: isCreateDisabled? "rgba(230, 236, 255, 0.44)": "rgba(244, 247, 255, 0.72)",},}}>- <Box- sx={{- transform: "rotate(90deg)",- display: "flex",- }}- >- <HugeiconsIcon- icon={Navigation06Icon}- size={18}- strokeWidth={2}+ {creating ? (+ <CircularProgress+ size={17}+ thickness={5.2}+ sx={{ color: "rgba(244, 247, 255, 0.95)" }}/>- </Box>+ ) : (+ <Box+ sx={{+ transform: "rotate(90deg)",+ display: "flex",+ }}+ >+ <HugeiconsIcon+ icon={Navigation06Icon}+ size={18}+ strokeWidth={2}+ />+ </Box>+ )}</IconButton></Box></Box>diff --git a/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx b/web/apps/paste/src/features/paste/components/PasteLinkCard.tsxindex f980a9e8fa..b6c6291f97 100644--- a/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx+++ b/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx@@ -4,6 +4,11 @@ import QrCode2RoundedIcon from "@mui/icons-material/QrCode2Rounded";import { Box, Dialog, IconButton, Stack, Typography } from "@mui/material";import useMediaQuery from "@mui/material/useMediaQuery";import { useEffect, useMemo, useRef, useState } from "react";+import {+ parseArrowLottie,+ type ParsedArrow,+ type ParsedArrowPath,+} from "../utils/lottie";import { createQrSvgData } from "../utils/qrCode";interface PasteLinkCardProps {@@ -12,147 +17,12 @@ interface PasteLinkCardProps {onShare: (url: string) => Promise<void>;}-type LottiePoint = [number, number];--interface LottieShapePath {- c: boolean;- i: LottiePoint[];- o: LottiePoint[];- v: LottiePoint[];-}--interface ParsedArrowPath {- color: string;- d: string;- lineCap: "butt" | "round" | "square";- lineJoin: "miter" | "round" | "bevel";- name: string;- strokeScale: number;- width: number;-}--interface ParsedArrow {- height: number;- paths: ParsedArrowPath[];- transform: string;- width: number;-}-interface MeasuredPath {len: number;parsed: ParsedArrowPath;path: SVGPathElement;}-const safePoint = (point?: LottiePoint): [number, number] => [- point?.[0] ?? 0,- point?.[1] ?? 0,-];--const toPathD = (shape: LottieShapePath) => {- if (!shape?.v?.length) return "";-- const { c, i, o, v } = shape;- const [startX, startY] = safePoint(v[0]);- let d = `M ${startX} ${startY}`;-- for (let idx = 1; idx < v.length; idx++) {- const [prevX, prevY] = safePoint(v[idx - 1]);- const [currX, currY] = safePoint(v[idx]);- const [prevOutX, prevOutY] = safePoint(o[idx - 1]);- const [currInX, currInY] = safePoint(i[idx]);- const hasCurve =- prevOutX !== 0 || prevOutY !== 0 || currInX !== 0 || currInY !== 0;-- if (hasCurve) {- d += ` C ${prevX + prevOutX} ${prevY + prevOutY} ${- currX + currInX- } ${currY + currInY} ${currX} ${currY}`;- } else {- d += ` L ${currX} ${currY}`;- }- }-- if (c) {- const lastIdx = v.length - 1;- const [prevX, prevY] = safePoint(v[lastIdx]);- const [currX, currY] = safePoint(v[0]);- const [prevOutX, prevOutY] = safePoint(o[lastIdx]);- const [currInX, currInY] = safePoint(i[0]);- const hasCurve =- prevOutX !== 0 || prevOutY !== 0 || currInX !== 0 || currInY !== 0;-- if (hasCurve) {- d += ` C ${prevX + prevOutX} ${prevY + prevOutY} ${- currX + currInX- } ${currY + currInY} ${currX} ${currY}`;- } else {- d += ` L ${currX} ${currY}`;- }- d += " Z";- }-- return d;-};--const toLineCap = (value: number): ParsedArrowPath["lineCap"] =>- value === 2 ? "round" : value === 3 ? "square" : "butt";--const toLineJoin = (value: number): ParsedArrowPath["lineJoin"] =>- value === 2 ? "round" : value === 3 ? "bevel" : "miter";--const toRGB = (rgb: number[]) => {- const r = Number(rgb?.[0] ?? 1);- const g = Number(rgb?.[1] ?? 1);- const b = Number(rgb?.[2] ?? 1);- return `rgb(${Math.round(r * 255)} ${Math.round(g * 255)} ${Math.round(b * 255)})`;-};--const parseArrowLottie = (lottie: any): ParsedArrow | null => {- const layer = lottie?.layers?.[0];- if (!layer?.shapes?.length) return null;-- const sx = (Number(layer?.ks?.s?.k?.[0] ?? 100) || 100) / 100;- const sy =- (Number(layer?.ks?.s?.k?.[1] ?? layer?.ks?.s?.k?.[0] ?? 100) || 100) /- 100;- const px = Number(layer?.ks?.p?.k?.[0] ?? 0) || 0;- const py = Number(layer?.ks?.p?.k?.[1] ?? 0) || 0;-- const paths: ParsedArrowPath[] = [];- for (const group of layer.shapes) {- if (group?.ty !== "gr" || !Array.isArray(group?.it)) continue;-- const shape = group.it.find((item: any) => item?.ty === "sh")?.ks?.k as- | LottieShapePath- | undefined;- const stroke = group.it.find((item: any) => item?.ty === "st");- if (!shape || !stroke) continue;- const groupName = String(group?.nm ?? "");- const d = toPathD(shape);- if (!d) continue;-- paths.push({- color: toRGB(stroke?.c?.k),- d,- lineCap: toLineCap(Number(stroke?.lc ?? 1)),- lineJoin: toLineJoin(Number(stroke?.lj ?? 1)),- name: groupName,- strokeScale: 0.58,- width: Number(stroke?.w?.k ?? 2),- });- }-- if (!paths.length) return null;-- return {- height: Number(lottie?.h ?? 84) || 84,- paths,- transform: `translate(${px} ${py}) scale(${sx} ${sy})`,- width: Number(lottie?.w ?? 150) || 150,- };-};-export const PasteLinkCard = ({link,onCopy,diff --git a/web/apps/paste/src/features/paste/utils/lottie.ts b/web/apps/paste/src/features/paste/utils/lottie.tsnew file mode 100644index 0000000000..4c720279f9--- /dev/null+++ b/web/apps/paste/src/features/paste/utils/lottie.ts@@ -0,0 +1,134 @@+type LottiePoint = [number, number];++interface LottieShapePath {+ c: boolean;+ i: LottiePoint[];+ o: LottiePoint[];+ v: LottiePoint[];+}++export interface ParsedArrowPath {+ color: string;+ d: string;+ lineCap: "butt" | "round" | "square";+ lineJoin: "miter" | "round" | "bevel";+ name: string;+ strokeScale: number;+ width: number;+}++export interface ParsedArrow {+ height: number;+ paths: ParsedArrowPath[];+ transform: string;+ width: number;+}++const safePoint = (point?: LottiePoint): [number, number] => [+ point?.[0] ?? 0,+ point?.[1] ?? 0,+];++const toPathD = (shape: LottieShapePath) => {+ if (!shape?.v?.length) return "";++ const { c, i, o, v } = shape;+ const [startX, startY] = safePoint(v[0]);+ let d = `M ${startX} ${startY}`;++ for (let idx = 1; idx < v.length; idx++) {+ const [prevX, prevY] = safePoint(v[idx - 1]);+ const [currX, currY] = safePoint(v[idx]);+ const [prevOutX, prevOutY] = safePoint(o[idx - 1]);+ const [currInX, currInY] = safePoint(i[idx]);+ const hasCurve =+ prevOutX !== 0 || prevOutY !== 0 || currInX !== 0 || currInY !== 0;++ if (hasCurve) {+ d += ` C ${prevX + prevOutX} ${prevY + prevOutY} ${+ currX + currInX+ } ${currY + currInY} ${currX} ${currY}`;+ } else {+ d += ` L ${currX} ${currY}`;+ }+ }++ if (c) {+ const lastIdx = v.length - 1;+ const [prevX, prevY] = safePoint(v[lastIdx]);+ const [currX, currY] = safePoint(v[0]);+ const [prevOutX, prevOutY] = safePoint(o[lastIdx]);+ const [currInX, currInY] = safePoint(i[0]);+ const hasCurve =+ prevOutX !== 0 || prevOutY !== 0 || currInX !== 0 || currInY !== 0;++ if (hasCurve) {+ d += ` C ${prevX + prevOutX} ${prevY + prevOutY} ${+ currX + currInX+ } ${currY + currInY} ${currX} ${currY}`;+ } else {+ d += ` L ${currX} ${currY}`;+ }+ d += " Z";+ }++ return d;+};++const toLineCap = (value: number): ParsedArrowPath["lineCap"] =>+ value === 2 ? "round" : value === 3 ? "square" : "butt";++const toLineJoin = (value: number): ParsedArrowPath["lineJoin"] =>+ value === 2 ? "round" : value === 3 ? "bevel" : "miter";++const toRGB = (rgb: number[]) => {+ const r = Number(rgb?.[0] ?? 1);+ const g = Number(rgb?.[1] ?? 1);+ const b = Number(rgb?.[2] ?? 1);+ return `rgb(${Math.round(r * 255)} ${Math.round(g * 255)} ${Math.round(b * 255)})`;+};++export const parseArrowLottie = (lottie: any): ParsedArrow | null => {+ const layer = lottie?.layers?.[0];+ if (!layer?.shapes?.length) return null;++ const sx = (Number(layer?.ks?.s?.k?.[0] ?? 100) || 100) / 100;+ const sy =+ (Number(layer?.ks?.s?.k?.[1] ?? layer?.ks?.s?.k?.[0] ?? 100) || 100) /+ 100;+ const px = Number(layer?.ks?.p?.k?.[0] ?? 0) || 0;+ const py = Number(layer?.ks?.p?.k?.[1] ?? 0) || 0;++ const paths: ParsedArrowPath[] = [];+ for (const group of layer.shapes) {+ if (group?.ty !== "gr" || !Array.isArray(group?.it)) continue;++ const shape = group.it.find((item: any) => item?.ty === "sh")?.ks?.k as+ | LottieShapePath+ | undefined;+ const stroke = group.it.find((item: any) => item?.ty === "st");+ if (!shape || !stroke) continue;+ const groupName = String(group?.nm ?? "");+ const d = toPathD(shape);+ if (!d) continue;++ paths.push({+ color: toRGB(stroke?.c?.k),+ d,+ lineCap: toLineCap(Number(stroke?.lc ?? 1)),+ lineJoin: toLineJoin(Number(stroke?.lj ?? 1)),+ name: groupName,+ strokeScale: 0.58,+ width: Number(stroke?.w?.k ?? 2),+ });+ }++ if (!paths.length) return null;++ return {+ height: Number(lottie?.h ?? 84) || 84,+ paths,+ transform: `translate(${px} ${py}) scale(${sx} ${sy})`,+ width: Number(lottie?.w ?? 150) || 150,+ };+};diff --git a/web/apps/paste/src/pages/_app.tsx b/web/apps/paste/src/pages/_app.tsxindex 06a102a762..6483e818c5 100644--- a/web/apps/paste/src/pages/_app.tsx+++ b/web/apps/paste/src/pages/_app.tsx@@ -18,15 +18,6 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {><CustomHead title="Ente Paste" /><CssBaseline enableColorScheme />- <style jsx global>{`- html,- body,- #__next {- width: 100%;- max-width: 100%;- overflow-x: hidden;- }- `}</style><Component {...pageProps} /></ThemeProvider>);diff --git a/web/apps/paste/src/pages/index.tsx b/web/apps/paste/src/pages/index.tsxindex a231892b78..6e30b1c1d7 100644--- a/web/apps/paste/src/pages/index.tsx+++ b/web/apps/paste/src/pages/index.tsx@@ -1,5 +1,4 @@import { Stack } from "@mui/material";-import Head from "next/head";import { PasteCreatePanel } from "features/paste/components/PasteCreatePanel";import { PasteFooter } from "features/paste/components/PasteFooter";import { PasteFrame } from "features/paste/components/PasteFrame";@@ -11,6 +10,7 @@ import {copyTextToClipboard,shareUrlOrCopy,} from "features/paste/utils/browser";+import Head from "next/head";const Page = () => {const { mode, accessToken } = usePasteRoute();@@ -36,6 +36,14 @@ const Page = () => {name="description"content="Share sensitive text with one-time, end-to-end encrypted links that auto-expire after 24 hours."/>+ <meta+ property="og:image"+ content="https://paste.ente.io/images/metaimage.png"+ />+ <meta+ name="twitter:image"+ content="https://paste.ente.io/images/metaimage.png"+ /><link rel="preconnect" href="https://fonts.googleapis.com" /><linkrel="preconnect"