Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.
TypeScript fintechinvoiceinvoice-generatorinvoice-pdfinvoice-templateinvoicesnextjsopen-sourcequotesreactreact-pdf-rendererself-hostedshadcn-uitailwindcsstypescript
fix: invoice preview and functionality in in-app browsers (#133)
Vlad Sazonau2b4a87badc5b
diff --git a/e2e/stripe-invoice-template/template.test.ts b/e2e/stripe-invoice-template/template.test.tsindex f07432a..db18da4 100644--- a/e2e/stripe-invoice-template/template.test.ts+++ b/e2e/stripe-invoice-template/template.test.ts@@ -485,7 +485,7 @@ test.describe("Stripe Invoice Template", () => {// Wait a moment for any debounced localStorage updates// eslint-disable-next-line playwright/no-wait-for-timeout- await page.waitForTimeout(600);+ await page.waitForTimeout(700);// Verify data is actually saved in localStorageconst storedData = (await page.evaluate((key) => {@@ -503,6 +503,8 @@ test.describe("Stripe Invoice Template", () => {// Reload pageawait page.reload();+ await expect(page).toHaveURL("/?template=stripe");+// Verify template is still Stripeawait expect(page.getByRole("combobox", { name: "Invoice Template" }),diff --git a/package.json b/package.jsonindex 55a5dfd..74107f0 100644--- a/package.json+++ b/package.json@@ -76,7 +76,7 @@"react-dom": "18.3.1","react-hook-form": "7.53.1","react-intersection-observer": "9.16.0",- "react-pdf": "9.2.1",+ "react-pdf": "10.1.0","remark-gfm": "4.0.1","resend": "4.2.0","sonner": "1.7.4",diff --git a/playwright.config.ts b/playwright.config.tsindex 61a9344..a7d7fd3 100644--- a/playwright.config.ts+++ b/playwright.config.ts@@ -33,7 +33,7 @@ export default defineConfig({workers: process.env.CI ? 2 : undefined,/* timeout for expect assertions */expect: {- timeout: 40_000,+ timeout: 35_000,},// /* timeout for test execution */diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 186bcb6..5b5dc2a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -149,8 +149,8 @@ importers:specifier: 9.16.0react-pdf:- specifier: 9.2.1+ specifier: 10.1.0+ version: 10.1.0(@types/[email protected])([email protected]([email protected]))([email protected])remark-gfm:specifier: 4.0.1version: 4.0.1@@ -1101,6 +1101,103 @@ packages:react: ">= 15"react-dom: ">= 15"+ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-jC8YX0rbAnu9YrLK1A52KM2HX9EDjrJSCLVuBf9Dsov4IC6GgwMLS2pwL9GFLJnSZBFgdwnA84efBehHT9eshA==,+ }+ engines: { node: ">= 10" }+ cpu: [arm64]+ os: [android]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-VFaCaCgAV0+hPwXajDIiHaaGx4fVCuUVYp/CxCGXmTGz699ngIEBx3Sa2oDp0uk3X+6RCRLueb7vD44BKBiPIg==,+ }+ engines: { node: ">= 10" }+ cpu: [arm64]+ os: [darwin]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-uD2NSkf6I4S3o0POJDwweK85FE4rfLNA2N714MgiEEMMw5AmupfSJGgpYzcyEXtPzdaca6rBfKcqNvzR1+EyLQ==,+ }+ engines: { node: ">= 10" }+ cpu: [x64]+ os: [darwin]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-03GxMMZGhHRQxiA4gyoKT6iQSz8xnA6T9PAfg/WNJnbkVMFZG782DwUJUb39QIZ1uE1euMCPnDgWAJ092MmgJQ==,+ }+ engines: { node: ">= 10" }+ cpu: [arm]+ os: [linux]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-ZO+d2gRU9JU1Bb7SgJcJ1k9wtRMCpSWjJAJ+2phhu0Lw5As8jYXXXmLKmMTGs1bOya2dBMYDLzwp7KS/S/+aCA==,+ }+ engines: { node: ">= 10" }+ cpu: [arm64]+ os: [linux]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-S1KtnP1+nWs2RApzNkdNf8X4trTLrHaY7FivV61ZRaL8NvuGOkSkKa+gWN2iedIGFEDz6gecpl/JAUSewwFXYg==,+ }+ engines: { node: ">= 10" }+ cpu: [arm64]+ os: [linux]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-A4YIKFYUwDtrSzCtdCAO5DYmRqlhCVKHdpq0+dBGPnIEhOQDFkPBTfoTAjO3pjlEnorlfKmNMOH21sKQg2esGA==,+ }+ engines: { node: ">= 10" }+ cpu: [riscv64]+ os: [linux]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-Lt6Sef5l0+5O1cSZ8ysO0JI+x+rSrqZyXs5f7+kVkCAOVq8X5WTcDVbvWvEs2aRhrWTp5y25Jf2Bn+3IcNHOuQ==,+ }+ engines: { node: ">= 10" }+ cpu: [x64]+ os: [linux]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-NiNFvC+D+omVeJ3IjYlIbyt/igONSABVe9z0ZZph29epHgZYu4eHwV9osfpRt1BGGOAM8LkFrHk4LBdn2EDymA==,+ }+ engines: { node: ">= 10" }+ cpu: [x64]+ os: [linux]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-fP6l0hZiWykyjvpZTS3sI46iib8QEflbPakNoUijtwyxRuOPTTBfzAWZUz5z2vKpJJ/8r305wnZeZ8lhsBHY5A==,+ }+ engines: { node: ">= 10" }+ cpu: [x64]+ os: [win32]++ "@napi-rs/[email protected]":+ resolution:+ {+ integrity: sha512-N9w2DkEKE1AXGp3q55GBOP6BEoFrqChDiFqJtKViTpQCWNOSVuMz7LkoGehbnpxtidppbsC36P0kCZNqJKs29w==,+ }+ engines: { node: ">= 10" }+"@napi-rs/[email protected]":resolution:{@@ -5238,13 +5335,6 @@ packages:integrity: sha512-e4QKw/O2Kavj2VQTKZWrwzkt3IxOmIlU6ajRb6LP64LHpBo1J67k2Hi4Vu/TgJWsNtynurfS0uK3MaUTCPfu5Q==,}- resolution:- {- integrity: sha512-tTj3CqqukVJ9NgSahykNwtGda7V33VLObwrHfzT0vqJXu7J4d4C/7kQQW3fOEGDfZZoILPut5H00gOjyttPGyg==,- }- engines: { node: ^18.12.0 || >= 20.9.0 }-resolution:{@@ -5324,12 +5414,6 @@ packages:}engines: { node: ">= 14.16.0" }- resolution:- {- integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==,- }-resolution:{@@ -5661,13 +5745,6 @@ packages:integrity: sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==,}- resolution:- {- integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==,- }- engines: { node: ">=10" }-resolution:{@@ -5675,13 +5752,6 @@ packages:}engines: { node: ">=6" }- resolution:- {- integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==,- }- engines: { node: ">=4.0.0" }-resolution:{@@ -5854,12 +5924,6 @@ packages:integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==,}- resolution:- {- integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==,- }-resolution:{@@ -6281,13 +6345,6 @@ packages:}engines: { node: ">=16.17" }- resolution:- {- integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==,- }- engines: { node: ">=6" }-resolution:{@@ -6455,12 +6512,6 @@ packages:integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==,}- resolution:- {- integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==,- }-resolution:{@@ -6571,12 +6622,6 @@ packages:integrity: sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==,}- resolution:- {- integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==,- }-resolution:{@@ -6885,12 +6930,6 @@ packages:integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==,}- resolution:- {- integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==,- }-resolution:{@@ -7578,16 +7617,16 @@ packages:}engines: { node: ">=12" }resolution:{- integrity: sha512-GCXh3bq/WuMbS+Ky4JBPW1hYTOU+znU+Q5m9Pu+pI8EoUqIHk9+tviOKC6/qhHh8C4/As3tzJ69IF32kdz85ww==,+ integrity: sha512-3SEQqTpV9oqVsIWqAcmDuaNeo7yBO3tqPtqGRcKkEo0lrzD3wqbKG9mkxO65KoOgXqj+zH2phJ2LiAsdzlogSw==,}resolution:{- integrity: sha512-iDwf7mA03WPiR8QxvcVHmVWEPfMY1RZXerDVNCRYW7dUr2ppH3J58Rwb39/WG39yTZdRSxr3x+2v22tvI0VEvA==,+ integrity: sha512-G/hncXrl4Qt7mauJEXSg3AcdYzmpkIITTNl5I+rH9sog5Yw0kK6vseJjCaPfOXqOqQuPUP89Rkhfz5kPS8ijtw==,}@@ -7728,10 +7767,10 @@ packages:integrity: sha512-aa5tG6sDoK+k70B9iEX1NeyfT8ObCKhNDs6lJVpwF6r8vhUfuKMslIcirq6HIUYuuUYLefcEQOn9bSBOvawtwg==,}resolution:{- integrity: sha512-nqXPXbso+1dcKDpPCXvwZyJILz+vSLqGGOnDrYHQYE+B8n9JTCekVLC65AfCpR4ggVyA/45Y0iR9LDyS2iI+zA==,+ integrity: sha512-3+B21mYK2IqUWnd2EivABLT7ueDhb0b8/dGK8LoFQPrU61YITeCMn14F7y7qZafWNZhUEKb24cJdiT5Wxs3prg==,}peerDependencies:"@types/react": ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0@@ -8004,13 +8043,6 @@ packages:}engines: { node: ">=18" }- resolution:- {- integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==,- }- engines: { node: ">=10" }-resolution:{@@ -8051,12 +8083,6 @@ packages:}engines: { node: ">=16 || 14 >=14.17" }- resolution:- {- integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==,- }-resolution:{@@ -8097,12 +8123,6 @@ packages:engines: { node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1 }hasBin: true- resolution:- {- integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==,- }-resolution:{@@ -8195,19 +8215,6 @@ packages:sass:optional: true- resolution:- {- integrity: sha512-OhYaY5sDsIka7H7AtijtI9jwGYLyl29eQn/W623DiN/MIv5sUqc4g7BIDThX+gb7di9f6xK02nkp8sdfFWZLTg==,- }- engines: { node: ">=10" }-- resolution:- {- integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==,- }-resolution:{@@ -8322,12 +8329,6 @@ packages:}engines: { node: ">= 0.4" }- resolution:- {- integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==,- }-resolution:{@@ -8461,13 +8462,6 @@ packages:}engines: { node: ">=16 || 14 >=14.18" }- resolution:- {- integrity: sha512-+vnG6S4dYcYxZd+CZxzXCNKdELYZSKfohrk98yajCo1PtRoDgCTrrwOvK1GT0UoAdVszagDVllQc0U1vaX4NUQ==,- }- engines: { node: ">=6" }-resolution:{@@ -8488,12 +8482,12 @@ packages:}engines: { node: ">=6.8.1" }resolution:{- integrity: sha512-IHZsA4T7YElCKNNXtiLgqScw4zPd3pG9do8UrznC757gMd7UPeHSL2qwNNMJo4r79fl8oj1Xx+1nh2YkzdMpLQ==,+ integrity: sha512-w3fQKVL1oGn8FRyx5JUG5tnbblggDqyx2XzA5brsJ5hSuS+I0NdnJANhmeWKLjotdbPQucLBug5t0MeWr0AAdg==,}- engines: { node: ">=18" }+ engines: { node: ">=20.16.0 || >=22.3.0" }resolution:@@ -8696,14 +8690,6 @@ packages:integrity: sha512-5SRRBinwpwkaD+OqlBDeITlRgvd8I8QlxHJw9AxSdMNV6O+LodN9nUyYGpSF7sadHjs6RzeFShMexC6DbtWr9g==,}- resolution:- {- integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==,- }- engines: { node: ">=10" }- hasBin: true-resolution:{@@ -8823,12 +8809,6 @@ packages:integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==,}- resolution:- {- integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==,- }-resolution:{@@ -8861,13 +8841,6 @@ packages:integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==,}- resolution:- {- integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==,- }- hasBin: true-resolution:{@@ -8941,10 +8914,10 @@ packages:integrity: sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==,}resolution:{- integrity: sha512-AJt0lAIkItWEZRA5d/mO+Om4nPCuTiQ0saA+qItO967DTjmGjnhmF+Bi2tL286mOTfBlF5CyLzJ35KTMaDoH+A==,+ integrity: sha512-iUI1YqWgwwZcsXjrehTp3Yi8nT/bvTaWULaRMMyJWvoqqSlopk4LQQ9GDqUnDtX3gzT2glrqrLbjIPl56a+Q3w==,}peerDependencies:"@types/react": ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0@@ -9469,18 +9442,6 @@ packages:}engines: { node: ">=14" }- resolution:- {- integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==,- }-- resolution:- {- integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==,- }-resolution:{@@ -9730,13 +9691,6 @@ packages:}engines: { node: ">=12" }- resolution:- {- integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==,- }- engines: { node: ">=0.10.0" }-resolution:{@@ -9865,19 +9819,6 @@ packages:}engines: { node: ">=6" }- resolution:- {- integrity: sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==,- }-- resolution:- {- integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==,- }- engines: { node: ">=6" }-resolution:{@@ -10030,12 +9971,6 @@ packages:engines: { node: ">=18.0.0" }hasBin: true- resolution:- {- integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==,- }-resolution:{@@ -10573,12 +10508,6 @@ packages:}engines: { node: ">=18" }- resolution:- {- integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==,- }-resolution:{@@ -11167,6 +11096,50 @@ snapshots:transitivePeerDependencies:- "@types/react"+ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optional: true++ "@napi-rs/[email protected]":+ optionalDependencies:+ "@napi-rs/canvas-android-arm64": 0.1.77+ "@napi-rs/canvas-darwin-arm64": 0.1.77+ "@napi-rs/canvas-darwin-x64": 0.1.77+ "@napi-rs/canvas-linux-arm-gnueabihf": 0.1.77+ "@napi-rs/canvas-linux-arm64-gnu": 0.1.77+ "@napi-rs/canvas-linux-arm64-musl": 0.1.77+ "@napi-rs/canvas-linux-riscv64-gnu": 0.1.77+ "@napi-rs/canvas-linux-x64-gnu": 0.1.77+ "@napi-rs/canvas-linux-x64-musl": 0.1.77+ "@napi-rs/canvas-win32-x64-msvc": 0.1.77+ optional: true+"@napi-rs/[email protected]":dependencies:"@emnapi/core": 1.4.5@@ -14387,12 +14360,6 @@ snapshots:- dependencies:- node-addon-api: 7.1.1- prebuild-install: 7.1.3- optional: true-@@ -14441,9 +14408,6 @@ snapshots:dependencies:readdirp: 4.1.2- optional: true-@@ -14600,16 +14564,8 @@ snapshots:dependencies:character-entities: 2.0.2- dependencies:- mimic-response: 3.1.0- optional: true-- optional: true-@@ -14695,11 +14651,6 @@ snapshots:- dependencies:- once: 1.4.0- optional: true-@@ -15150,9 +15101,6 @@ snapshots:signal-exit: 4.1.0strip-final-newline: 3.0.0- optional: true-@@ -15253,9 +15201,6 @@ snapshots:- optional: true-@@ -15333,9 +15278,6 @@ snapshots:dependencies:resolve-pkg-maps: 1.0.0- optional: true-dependencies:is-glob: 4.0.3@@ -15567,9 +15509,6 @@ snapshots:- optional: true-@@ -15966,9 +15905,9 @@ snapshots:dependencies:"@jridgewell/sourcemap-codec": 1.5.4- [email protected]: {}+ [email protected]: {}- [email protected]: {}+ [email protected]: {}@@ -16148,7 +16087,7 @@ snapshots:- [email protected](@types/[email protected]):+ [email protected](@types/[email protected]):optionalDependencies:"@types/react": 18.3.12@@ -16437,9 +16376,6 @@ snapshots:- optional: true-dependencies:brace-expansion: 1.1.11@@ -16458,9 +16394,6 @@ snapshots:- optional: true-@@ -16477,9 +16410,6 @@ snapshots:- optional: true-@@ -16554,14 +16484,6 @@ snapshots:- "@babel/core"- babel-plugin-macros- dependencies:- semver: 7.7.2- optional: true-- optional: true-@@ -16626,11 +16548,6 @@ snapshots:define-properties: 1.2.1es-object-atoms: 1.1.1- dependencies:- wrappy: 1.0.2- optional: true-dependencies:mimic-fn: 2.1.0@@ -16718,9 +16635,6 @@ snapshots:lru-cache: 10.4.3minipass: 7.1.2- optional: true-@@ -16732,10 +16646,9 @@ snapshots:transitivePeerDependencies:- supports-coloroptionalDependencies:- canvas: 3.1.0- path2d: 0.2.2+ "@napi-rs/canvas": 0.1.77@@ -16833,22 +16746,6 @@ snapshots:- dependencies:- detect-libc: 2.0.3- expand-template: 2.0.3- github-from-package: 0.0.0- minimist: 1.2.8- mkdirp-classic: 0.5.3- napi-build-utils: 2.0.0- node-abi: 3.75.0- pump: 3.0.2- rc: 1.2.8- simple-get: 4.0.1- tar-fs: 2.1.2- tunnel-agent: 0.6.0- optional: true-@@ -16875,12 +16772,6 @@ snapshots:- dependencies:- end-of-stream: 1.4.4- once: 1.4.0- optional: true-@@ -16897,14 +16788,6 @@ snapshots:dependencies:safe-buffer: 5.2.1- dependencies:- deep-extend: 0.6.0- ini: 1.3.8- minimist: 1.2.8- strip-json-comments: 2.0.1- optional: true-dependencies:"@internationalized/date": 3.8.0@@ -17044,14 +16927,14 @@ snapshots:- [email protected](@types/[email protected])([email protected]([email protected]))([email protected]):+ [email protected](@types/[email protected])([email protected]([email protected]))([email protected]):dependencies:clsx: 2.1.1dequal: 2.0.3- make-cancellable-promise: 1.3.2- make-event-props: 1.6.2- merge-refs: 1.3.0(@types/[email protected])- pdfjs-dist: 4.8.69+ make-cancellable-promise: 2.0.0+ make-event-props: 2.0.0+ merge-refs: 2.0.0(@types/[email protected])+ pdfjs-dist: 5.3.93react: 18.3.1react-dom: 18.3.1([email protected])tiny-invariant: 1.3.3@@ -17532,16 +17415,6 @@ snapshots:- optional: true-- dependencies:- decompress-response: 6.0.0- once: 1.4.0- simple-concat: 1.0.1- optional: true-dependencies:is-arrayish: 0.3.2@@ -17720,9 +17593,6 @@ snapshots:- optional: true-@@ -17810,23 +17680,6 @@ snapshots:- dependencies:- chownr: 1.1.4- mkdirp-classic: 0.5.3- pump: 3.0.2- tar-stream: 2.2.0- optional: true-- dependencies:- bl: 4.1.0- end-of-stream: 1.4.4- fs-constants: 1.0.0- inherits: 2.0.4- readable-stream: 3.6.2- optional: true-dependencies:"@jridgewell/trace-mapping": 0.3.29@@ -17902,11 +17755,6 @@ snapshots:optionalDependencies:fsevents: 2.3.3- dependencies:- safe-buffer: 5.2.1- optional: true-dependencies:prelude-ls: 1.2.1@@ -18357,9 +18205,6 @@ snapshots:string-width: 7.2.0strip-ansi: 7.1.0- optional: true-diff --git a/src/app/(app)/components/cta-toasts/index.tsx b/src/app/(app)/components/cta-toasts/index.tsxindex 2cffcb8..8ff3603 100644--- a/src/app/(app)/components/cta-toasts/index.tsx+++ b/src/app/(app)/components/cta-toasts/index.tsx@@ -34,7 +34,7 @@ function randomlyShowDonationButton() {/*** Renders a premium donation toast*/-export function customPremiumToast(toast: Omit<ToastProps, "id">) {+export function customPremiumToast(toast: ToastProps) {// dismiss any existing toastssonnerToast.dismiss();@@ -56,7 +56,7 @@ export function customPremiumToast(toast: Omit<ToastProps, "id">) {/*** Renders a default donation toast*/-export function customDefaultToast(toast: Omit<ToastProps, "id">) {+export function customDefaultToast(toast: ToastProps) {// dismiss any existing toastssonnerToast.dismiss();diff --git a/src/app/(app)/components/index.tsx b/src/app/(app)/components/index.tsxindex 953a8e9..dabd43c 100644--- a/src/app/(app)/components/index.tsx+++ b/src/app/(app)/components/index.tsx@@ -8,7 +8,6 @@ import { InvoiceForm } from "./invoice-form";import { InvoicePDFDownloadLink } from "./invoice-pdf-download-link";import { InvoicePdfTemplate } from "./invoice-pdf-template";import { StripeInvoicePdfTemplate } from "./invoice-pdf-stripe-template";-import { useDeviceContext } from "@/contexts/device-context";import { cn } from "@/lib/utils";const DesktopPDFViewerModuleLoading = () => (@@ -20,8 +19,8 @@ const DesktopPDFViewerModuleLoading = () => (</div>);-const AndroidPDFViewerModuleLoading = () => (- <div className="flex h-full w-full items-center justify-center border border-gray-200 bg-gray-200">+const MobileInvoicePDFViewerModuleLoading = () => (+ <div className="flex h-[480px] w-[650px] items-center justify-center border border-gray-200 bg-gray-200 lg:h-[620px] 2xl:h-[700px]"><div className="text-center"><div className="mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-4 border-blue-500 border-t-transparent" /><p className="text-gray-600">Loading PDF viewer...</p>@@ -29,8 +28,11 @@ const AndroidPDFViewerModuleLoading = () => (</div>);-const InvoicePDFViewer = dynamic(- () => import("./invoice-pdf-viewer").then((mod) => mod.InvoicePDFViewer),+const DesktopInvoicePDFViewer = dynamic(+ () =>+ import("./invoice-pdf-preview/desktop-pdf-viewer").then(+ (mod) => mod.DesktopInvoicePDFViewer,+ ),{ssr: false,@@ -38,23 +40,26 @@ const InvoicePDFViewer = dynamic(},);-const AndroidPDFViewer = dynamic(- () => import("./android-pdf-viewer").then((mod) => mod.AndroidPdfViewer),+const MobileInvoicePDFViewer = dynamic(+ () =>+ import("./invoice-pdf-preview/mobile-pdf-viewer").then(+ (mod) => mod.MobileInvoicePDFViewer,+ ),{ssr: false,- loading: () => <AndroidPDFViewerModuleLoading />,+ loading: () => <MobileInvoicePDFViewerModuleLoading />,},);const PdfViewer = ({invoiceData,errorWhileGeneratingPdfIsShown,+ isMobile,}: {invoiceData: InvoiceData;errorWhileGeneratingPdfIsShown: boolean;+ isMobile: boolean;}) => {- const { isAndroid } = useDeviceContext();-// Render the appropriate template based on the selected templateconst renderTemplate = () => {switch (invoiceData.template) {@@ -66,21 +71,24 @@ const PdfViewer = ({}};- // we only show the Android PDF viewer on Android devices due to the limitations of the PDF viewer+ // Use Mobile PDF viewer for:+ // 1. Mobile devices+ // 2. Any in-app browser/WebView environment (new logic for platforms like X.com, LinkedIn, etc.)+ // This is due to limitations of the standard PDF viewer in these environments// https://github.com/diegomura/react-pdf/issues/714- if (isAndroid) {- return <AndroidPDFViewer invoiceData={invoiceData} />;+ if (isMobile) {+ return <MobileInvoicePDFViewer invoiceData={invoiceData} />;}const template = renderTemplate();- // Normal version+ // Normal version for standard desktop browsersreturn (- <InvoicePDFViewer+ <DesktopInvoicePDFViewererrorWhileGeneratingPdfIsShown={errorWhileGeneratingPdfIsShown}>{template}- </InvoicePDFViewer>+ </DesktopInvoicePDFViewer>);};@@ -143,6 +151,7 @@ export function InvoiceClientPage({errorWhileGeneratingPdfIsShown={errorWhileGeneratingPdfIsShown}+ isMobile={isMobile}/></div></TabsContent>@@ -219,6 +228,7 @@ export function InvoiceClientPage({<PdfViewerinvoiceData={invoiceDataState}errorWhileGeneratingPdfIsShown={errorWhileGeneratingPdfIsShown}+ isMobile={false}/></div></>diff --git a/src/app/(app)/components/invoice-pdf-download-link.tsx b/src/app/(app)/components/invoice-pdf-download-link.tsxindex 77ff1e6..6deb8f8 100644--- a/src/app/(app)/components/invoice-pdf-download-link.tsx+++ b/src/app/(app)/components/invoice-pdf-download-link.tsx@@ -17,6 +17,8 @@ import { StripeInvoicePdfTemplate } from "./invoice-pdf-stripe-template";import { InvoicePdfTemplate } from "./invoice-pdf-template";import { customDefaultToast, customPremiumToast } from "./cta-toasts";+import { useDeviceContext } from "@/contexts/device-context";+import { isTelegramInAppBrowser } from "@/utils/is-telegram-in-app-browser";// Separate button states into a memoized componentconst ButtonContent = ({@@ -49,6 +51,92 @@ export function InvoicePDFDownloadLink({errorWhileGeneratingPdfIsShown: boolean;setErrorWhileGeneratingPdfIsShown: (error: boolean) => void;}) {+ const { inAppInfo } = useDeviceContext();++ const [{ loading: pdfLoading, url, error }, updatePdfInstance] = usePDF();+ const [isLoading, setIsLoading] = useState(false);++ const [inAppBrowserToastShown, setInAppBrowserToastShown] = useState(false);++ const isTelegramPreviewBrowser = isTelegramInAppBrowser();++ const trackDownload = useCallback(() => {+ umamiTrackEvent("download_invoice", {+ data: {+ invoice_template: invoiceData.template,+ },+ });+ }, [invoiceData.template]);++ const handleDownloadPDFClick = useCallback(+ (e: React.MouseEvent<HTMLAnchorElement>) => {+ if (!url) {+ e.preventDefault();++ toast.error(+ "File not available. Please try again in different browser.",+ );+ return;+ }++ if (inAppInfo?.isInApp) {+ e.preventDefault();++ toast(+ `Downloads are blocked inside ${inAppInfo?.name ?? "this app"}. Open in your browser to save.`,+ { icon: "📱" },+ );++ return;+ }++ if (isTelegramPreviewBrowser) {+ e.preventDefault();+ toast(+ `Downloads are blocked inside Telegram. Open in your browser to save.`,+ { icon: "📱" },+ );++ return;+ }++ if (!isLoading && !error) {+ trackDownload();++ // close all other toasts (if any)+ toast.dismiss();++ // Randomly show either default or premium donation toast after 3 seconds+ setTimeout(() => {+ if (Math.random() <= 0.5) {+ customPremiumToast({+ id: "premium-donation-toast",+ title: "Support My Work",+ description:+ "Your contribution helps me maintain and improve this project for everyone! 🚀",+ });+ } else {+ customDefaultToast({+ id: "default-donation-toast",+ title: "Love this project?",+ description:+ "Help me keep building amazing tools! Your support means the world to me. ✨",+ });+ }+ }, 3000);+ }+ },+ [+ url,+ inAppInfo?.isInApp,+ inAppInfo?.name,+ isLoading,+ error,+ trackDownload,+ isTelegramPreviewBrowser,+ ],+ );+// Memoize static valuesconst filename = useMemo(() => {const invoiceNumberValue = invoiceData?.invoiceNumberObject?.value;@@ -73,46 +161,6 @@ export function InvoicePDFDownloadLink({}}, [invoiceData]);- // Combine loading states- const [{ loading: pdfLoading, url, error }, updatePdfInstance] = usePDF();- const [isLoading, setIsLoading] = useState(false);- // const [errorShown, setErrorShown] = useState(false);-- // Memoize tracking functions- const trackDownload = useCallback(() => {- umamiTrackEvent("download_invoice", {- data: {- invoice_template: invoiceData.template,- },- });- }, [invoiceData.template]);-- const handleDownloadPDFClick = useCallback(() => {- if (!isLoading && url) {- trackDownload();-- // close all other toasts (if any)- toast.dismiss();-- // Randomly show either default or premium donation toast after 3 seconds- setTimeout(() => {- if (Math.random() <= 0.5) {- customPremiumToast({- title: "Support My Work",- description:- "Your contribution helps me maintain and improve this project for everyone! 🚀",- });- } else {- customDefaultToast({- title: "Love this project?",- description:- "Help me keep building amazing tools! Your support means the world to me. ✨",- });- }- }, 3000);- }- }, [isLoading, url, trackDownload]);-// Handle PDF updatesuseEffect(() => {updatePdfInstance(PdfDocument);@@ -134,7 +182,6 @@ export function InvoicePDFDownloadLink({useEffect(() => {if (error && !errorWhileGeneratingPdfIsShown) {ErrorGeneratingPdfToast();- // setErrorShown(true);setErrorWhileGeneratingPdfIsShown(true);umamiTrackEvent("error_generating_document_link", { data: { error } });@@ -146,12 +193,33 @@ export function InvoicePDFDownloadLink({setErrorWhileGeneratingPdfIsShown,]);+ // Show a toast if the user is in an in-app browser+ useEffect(() => {+ if (+ (inAppInfo?.isInApp || isTelegramPreviewBrowser) &&+ !inAppBrowserToastShown+ ) {+ toast.info("In-App Browser Detected", {+ description: (+ <p>+ For the best experience, please open this page in{" "}+ <span className="underline">Safari or Chrome browser.</span>+ </p>+ ),+ id: "in-app-browser-toast", // To prevent duplicate toasts+ duration: 8000,+ icon: "⚠️",+ });+ setInAppBrowserToastShown(true);+ }+ }, [inAppInfo?.isInApp, inAppBrowserToastShown, isTelegramPreviewBrowser]);+return (<><atranslate="no"href={url || "#"}- download={filename}+ download={url ? filename : undefined}onClick={handleDownloadPDFClick}className={cn("h-[36px] w-full rounded-lg bg-slate-900 px-4 py-2 text-center text-sm font-medium text-slate-50",diff --git a/src/app/(app)/components/invoice-pdf-viewer.tsx b/src/app/(app)/components/invoice-pdf-preview/desktop-pdf-viewer.tsxsimilarity index 95%rename from src/app/(app)/components/invoice-pdf-viewer.tsxrename to src/app/(app)/components/invoice-pdf-preview/desktop-pdf-viewer.tsxindex 3b34b67..b6e6778 100644--- a/src/app/(app)/components/invoice-pdf-viewer.tsx+++ b/src/app/(app)/components/invoice-pdf-preview/desktop-pdf-viewer.tsx@@ -2,7 +2,7 @@import { PDFViewer } from "@react-pdf/renderer/lib/react-pdf.browser";-export function InvoicePDFViewer({+export function DesktopInvoicePDFViewer({children,errorWhileGeneratingPdfIsShown,}: {diff --git a/src/app/(app)/components/android-pdf-viewer.tsx b/src/app/(app)/components/invoice-pdf-preview/mobile-pdf-viewer.tsxsimilarity index 79%rename from src/app/(app)/components/android-pdf-viewer.tsxrename to src/app/(app)/components/invoice-pdf-preview/mobile-pdf-viewer.tsxindex 1c39876..1f3c863 100644--- a/src/app/(app)/components/android-pdf-viewer.tsx+++ b/src/app/(app)/components/invoice-pdf-preview/mobile-pdf-viewer.tsx@@ -3,9 +3,8 @@import { BlobProvider } from "@react-pdf/renderer/lib/react-pdf.browser";import { Document, Page, pdfjs } from "react-pdf";import type { InvoiceData } from "@/app/schema";-import { InvoicePdfTemplate } from "./invoice-pdf-template";-import { StripeInvoicePdfTemplate } from "./invoice-pdf-stripe-template";-import { toast } from "sonner";+import { InvoicePdfTemplate } from "../invoice-pdf-template";+import { StripeInvoicePdfTemplate } from "../invoice-pdf-stripe-template";import * as Sentry from "@sentry/nextjs";import { useMemo } from "react";@@ -19,7 +18,7 @@ pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/b** https://github.com/wojtekmaj/react-pdf*/-export const AndroidPdfViewer = ({+export const MobileInvoicePDFViewer = ({invoiceData,}: {invoiceData: InvoiceData;@@ -34,7 +33,7 @@ export const AndroidPdfViewer = ({}}, [invoiceData]);- // On mobile, we need to use the BlobProvider to generate a PDF preview+ // On mobile, we need to use the 'react-pdf' (https://github.com/wojtekmaj/react-pdf) to generate a PDF preview// This is because the PDF viewer is not supported on Android Chrome devices// https://github.com/diegomura/react-pdf/issues/714return (@@ -42,7 +41,7 @@ export const AndroidPdfViewer = ({{({ url, loading, error }) => {if (error) {return (- <div className="flex h-[580px] w-full items-center justify-center border border-gray-200 bg-gray-200 lg:h-[620px] 2xl:h-[700px]">+ <div className="flex h-[480px] w-[650px] items-center justify-center border border-gray-200 bg-gray-200 lg:h-[620px] 2xl:h-[700px]"><div className="text-center"><p className="text-red-600">Error generating PDF preview</p><p className="mt-2 text-sm text-gray-600">@@ -53,9 +52,9 @@ export const AndroidPdfViewer = ({);}- if (loading) {+ if (loading || !url) {return (- <div className="flex h-full w-full items-center justify-center border border-gray-200 bg-gray-200">+ <div className="flex h-[480px] w-[650px] items-center justify-center border border-gray-200 bg-gray-200 lg:h-[620px] 2xl:h-[700px]"><div className="text-center"><div className="mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-4 border-blue-500 border-t-transparent" /><p className="text-gray-600">Loading PDF viewer...</p>@@ -64,19 +63,11 @@ export const AndroidPdfViewer = ({);}- if (!url) {- return (- <div className="flex h-full w-full items-center justify-center border border-gray-200 bg-gray-200">- <p className="text-gray-600">No PDF URL</p>- </div>- );- }-// https://github.com/wojtekmaj/react-pdfreturn (<Documentfile={url}- className="h-[480px] w-[650px] overflow-auto"+ className="h-[480px] w-[650px] overflow-auto lg:h-[620px] 2xl:h-[700px]"loading={<div className="flex h-[480px] w-full items-center justify-center border border-gray-200 bg-gray-200 lg:h-[620px] 2xl:h-[700px]"><div className="text-center">@@ -87,8 +78,6 @@ export const AndroidPdfViewer = ({}onLoadError={(error) => {Sentry.captureException(error);-- toast.error("Error loading PDF");}}><Pagediff --git a/src/app/(app)/page.client.tsx b/src/app/(app)/page.client.tsxindex a27a59b..85fad92 100644--- a/src/app/(app)/page.client.tsx+++ b/src/app/(app)/page.client.tsx@@ -298,6 +298,7 @@ export function AppPageClient() {// Randomly show either default or premium donation toastif (Math.random() <= 0.5) {customPremiumToast({+ id: "premium-donation-toast-client-page",title: "Support My Work",description:"Your contribution helps me maintain and improve this project for everyone! 🚀",@@ -305,6 +306,7 @@ export function AppPageClient() {});} else {customDefaultToast({+ id: "default-donation-toast-client-page",title: "Love this project?",description:"Help me keep building amazing tools! Your support means the world to me. ✨",diff --git a/src/app/[locale]/about/components/landing-cta-toast.tsx b/src/app/[locale]/about/components/landing-cta-toast.tsxindex d230e3b..e1c24ac 100644--- a/src/app/[locale]/about/components/landing-cta-toast.tsx+++ b/src/app/[locale]/about/components/landing-cta-toast.tsx@@ -28,6 +28,7 @@ export const LandingCtaToast = () => {// Randomly show either default or premium donation toastif (Math.random() <= 0.5) {customPremiumToast({+ id: "premium-donation-toast-landing-page",title: "Support My Work",description:"Your contribution helps me maintain and improve this project for everyone! 🚀",@@ -35,6 +36,7 @@ export const LandingCtaToast = () => {});} else {customDefaultToast({+ id: "default-donation-toast-landing-page",title: "Love this project?",description:"Help me keep building amazing tools! Your support means the world to me. ✨",diff --git a/src/app/layout.tsx b/src/app/layout.tsxindex 71e312a..55926a4 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -14,8 +14,8 @@ import { STATIC_ASSETS_URL } from "@/config";import "./globals.css";-import "react-pdf/dist/esm/Page/AnnotationLayer.css";-import "react-pdf/dist/esm/Page/TextLayer.css";+import "react-pdf/dist/Page/AnnotationLayer.css";+import "react-pdf/dist/Page/TextLayer.css";export const viewport: Viewport = {initialScale: 1, // Sets the default zoom level to 1 (100%)@@ -103,8 +103,12 @@ export default async function RootLayout({}: Readonly<{children: React.ReactNode;}>) {- const { isDesktop: isDesktopServer, isAndroid } =- await checkDeviceUserAgent();+ const {+ isDesktop: isDesktopServer,+ isAndroid,+ isMobile,+ inAppInfo,+ } = await checkDeviceUserAgent();return (<html lang="en">@@ -114,6 +118,8 @@ export default async function RootLayout({<DeviceContextProviderisDesktop={isDesktopServer}isAndroid={isAndroid}+ isMobile={isMobile}+ inAppInfo={inAppInfo}><NextIntlClientProvider>{children}diff --git a/src/contexts/device-context.tsx b/src/contexts/device-context.tsxindex 3f1af0f..7f32a64 100644--- a/src/contexts/device-context.tsx+++ b/src/contexts/device-context.tsx@@ -1,11 +1,14 @@"use client";import { useIsDesktop } from "@/hooks/use-media-query";+import type { InAppInfo } from "@/lib/check-device.server";import { createContext, useContext, useEffect, useState } from "react";interface DeviceContextType {isDesktop: boolean;isAndroid: boolean;+ isMobile: boolean;+ inAppInfo: InAppInfo;}const DeviceContext = createContext<DeviceContextType | null>(null);@@ -23,6 +26,8 @@ export function DeviceContextProvider({children,isDesktop,isAndroid,+ isMobile,+ inAppInfo,}: DeviceContextType & { children: React.ReactNode }) {const [isDesktopClient, setIsDesktopClient] = useState(isDesktop);@@ -40,7 +45,14 @@ export function DeviceContextProvider({}, [isMediaQueryDesktop]);return (- <DeviceContext.Provider value={{ isDesktop: isDesktopClient, isAndroid }}>+ <DeviceContext.Provider+ value={{+ isDesktop: isDesktopClient,+ isAndroid,+ isMobile,+ inAppInfo,+ }}+ >{children}</DeviceContext.Provider>);diff --git a/src/lib/check-device.server.ts b/src/lib/check-device.server.tsindex 8f678ad..e3821f5 100644--- a/src/lib/check-device.server.ts+++ b/src/lib/check-device.server.ts@@ -3,6 +3,183 @@import { headers } from "next/headers";import { UAParser } from "ua-parser-js";+export interface InAppInfo {+ isInApp: boolean;+ name: string | null;+}++type HeadersList = ReturnType<typeof headers>;++/**+ * Simplified in-app browser detection with detailed app identification+ */+function detectInAppBrowser(ua: string, headers: HeadersList) {+ const s = ua.toLowerCase();++ // Helper functions+ function has(token: string): boolean {+ return s.includes(token);+ }++ function ios(): boolean {+ return /iphone|ipad|ipod/.test(s);+ }++ // Check for app-specific headers first (most reliable)+ const xRequestedWith = headers.get("x-requested-with") || "";+ const headerDetectors = [+ {+ name: "Instagram",+ test: () => xRequestedWith.includes("com.instagram.android"),+ },+ {+ name: "Facebook",+ test: () => xRequestedWith.includes("com.facebook.katana"),+ },+ {+ name: "Facebook Messenger",+ test: () => xRequestedWith.includes("com.facebook.orca"),+ },+ {+ name: "Twitter/X",+ test: () => xRequestedWith.includes("com.twitter.android"),+ },+ {+ name: "TikTok",+ test: () =>+ xRequestedWith.includes("com.zhiliaoapp.musically") ||+ xRequestedWith.includes("com.ss.android.ugc.trill"),+ },+ { name: "WhatsApp", test: () => xRequestedWith.includes("com.whatsapp") },+ { name: "WeChat", test: () => xRequestedWith.includes("com.tencent.mm") },+ {+ name: "LINE",+ test: () => xRequestedWith.includes("jp.naver.line.android"),+ },+ {+ name: "Telegram",+ test: () =>+ xRequestedWith.includes("org.telegram.messenger") ||+ xRequestedWith.includes("org.telegram.plus") ||+ xRequestedWith.includes("org.telegram.btelegram") ||+ xRequestedWith.includes("org.thunderdog.challegram") ||+ xRequestedWith.includes("nekox.messenger") ||+ xRequestedWith.includes("org.telegram.mdgram") ||+ xRequestedWith.includes("it.owlgram.android"),+ },+ {+ name: "Gmail",+ test: () => xRequestedWith.includes("com.google.android.gm"),+ },+ {+ name: "Google App",+ test: () =>+ xRequestedWith.includes("com.google.android.googlequicksearchbox"),+ },+ {+ name: "Chrome Custom Tab",+ test: () =>+ xRequestedWith.includes("com.android.chrome") ||+ xRequestedWith.includes("com.chrome.beta") ||+ xRequestedWith.includes("com.chrome.canary") ||+ xRequestedWith.includes("com.chrome.dev") ||+ xRequestedWith.includes("org.chromium.chrome"),+ },+ {+ name: "LinkedIn",+ test: () => xRequestedWith.includes("com.linkedin.android"),+ },+ ];++ // Check headers first (most reliable)+ for (const detector of headerDetectors) {+ try {+ if (detector.test()) return { isInApp: true, name: detector.name };+ } catch {+ // ignore failing tests+ }+ }++ // User agent detectors (fallback)+ const uaDetectors = [+ {+ name: "Facebook",+ test: () => has("fbav") || has("fban") || has("fb_iab"),+ },+ { name: "Instagram", test: () => has("instagram") },+ {+ name: "Facebook Messenger",+ test: () =>+ // iOS Messenger: [FBAN/MessengerForiOS;+ has("fban/messengerforio") ||+ has("messengerforio") ||+ // Android Messenger: [FB_IAB/MESSENGER;+ has("fb_iab/messenger") ||+ // Fallback patterns+ (has("messenger") && (has("fban") || has("fb_iab"))),+ },+ { name: "WhatsApp", test: () => has("whatsapp") },+ {+ name: "Telegram",+ test: () =>+ has("telegram") ||+ has("tgwebview") ||+ has("telegrambot-like") ||+ has("tgbot") ||+ has("telegram-") ||+ // Bot user agents+ has("telegrambot") ||+ // Version-specific patterns+ has("telegram/") ||+ // iOS specific patterns+ (ios() && (has("telegram") || has("tg/"))) ||+ // Android specific patterns+ (has("android") && has("tg")),+ },+ { name: "Twitter/X", test: () => has("twitter") || has("x-client") },+ { name: "LinkedIn", test: () => has("linkedinapp") },+ { name: "Pinterest", test: () => has("pinterest") },+ { name: "Reddit", test: () => has("reddit") },+ { name: "Snapchat", test: () => has("snapchat") },+ { name: "TikTok", test: () => has("tiktok") || has("com.zhiliaoapp") },+ { name: "WeChat", test: () => has("micromessenger") },+ { name: "LINE", test: () => has("line/") },+ { name: "QQ", test: () => has("qq/") },+ { name: "Gmail", test: () => has("gmail") },+ { name: "Google App", test: () => has("gsa/") || has("googleapp") },+ { name: "Discord", test: () => has("discord") },+ { name: "YouTube", test: () => has("youtube") },+ { name: "Android WebView", test: () => has("wv") && has("android") },+ {+ name: "iOS WebView",+ test: () =>+ ios() &&+ has("applewebkit") &&+ !has("safari") &&+ !has("crios") &&+ !has("fxios") &&+ !has("edgios"),+ },+ {+ name: "Generic WebView",+ test: () =>+ (has("android") && has("webview")) ||+ (has("mobile safari") && !has("safari")),+ },+ ];++ // Test user agent patterns+ for (const detector of uaDetectors) {+ try {+ if (detector.test()) return { isInApp: true, name: detector.name };+ } catch {+ // ignore failing tests+ }+ }++ return { isInApp: false, name: null };+}+/*** Check the device type based on the user agent* @warning **Should only be used on server side**@@ -14,8 +191,8 @@ export const checkDeviceUserAgent = async () => {);}- const { get } = headers();- const ua = get("user-agent");+ const headersList = headers();+ const ua = headersList.get("user-agent");const parser = new UAParser(ua || "");@@ -34,8 +211,16 @@ export const checkDeviceUserAgent = async () => {// Detect Android specificallyconst isAndroid = os.name === "Android";+ // Detect in-app browsers/WebViews with detailed app identification+ const inAppInfo = detectInAppBrowser(ua || "", headersList);+// Desktop is when it's neither tablet nor mobileconst isDesktop = !isTablet && !isMobile;- return { isDesktop, isAndroid };+ return {+ isDesktop,+ isAndroid,+ isMobile,+ inAppInfo, // Include detailed in-app browser information+ };};diff --git a/src/utils/is-telegram-in-app-browser.ts b/src/utils/is-telegram-in-app-browser.tsnew file mode 100644index 0000000..6848eed--- /dev/null+++ b/src/utils/is-telegram-in-app-browser.ts@@ -0,0 +1,22 @@+"use client";++export function isTelegramInAppBrowser() {+ if (typeof window === "undefined") {+ return false;+ }++ // Android+ if ("TelegramWebview" in window) {+ return true;+ }++ // iOS+ if (+ "TelegramWebviewProxy" in window &&+ "TelegramWebviewProxyProto" in window+ ) {+ return true;+ }++ return false;+}diff --git a/tsconfig.json b/tsconfig.jsonindex 57e13b4..5aaaaa8 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -20,7 +20,8 @@],"paths": {"@/*": ["./src/*"]- }+ },+ "target": "es2022"},"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],"exclude": ["node_modules"]