From 6a692bc518b9c74bfcfb0c21f6045be7db742cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20=C5=BBuraw?= <9116238+krzysztofzuraw@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:00:09 +0200 Subject: [PATCH] Update app bridge --- .changeset/light-mugs-beam.md | 5 + package.json | 4 +- pnpm-lock.yaml | 195 ++++++++++------------- src/app-bridge/next/route-propagator.tsx | 31 ++-- 4 files changed, 108 insertions(+), 127 deletions(-) create mode 100644 .changeset/light-mugs-beam.md diff --git a/.changeset/light-mugs-beam.md b/.changeset/light-mugs-beam.md new file mode 100644 index 00000000..d68ebfda --- /dev/null +++ b/.changeset/light-mugs-beam.md @@ -0,0 +1,5 @@ +--- +"@saleor/app-sdk": patch +--- + +Update app bridge to support Next.js 14' diff --git a/package.json b/package.json index 5b2d17d2..6156850a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "peerDependencies": { "@vercel/kv": "^1.0.0", "graphql": ">=16.6.0", - "next": ">=12", + "next": ">=14", "react": ">=17", "react-dom": ">=17" }, @@ -65,7 +65,7 @@ "husky": "^8.0.1", "jsdom": "^20.0.3", "lint-staged": "^13.0.3", - "next": "^12.3.0", + "next": "^14.2.3", "node-mocks-http": "^1.11.0", "prettier": "2.7.1", "react": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 412d3491..2e70bdc2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: '@opentelemetry/api': specifier: ^1.7.0 @@ -109,8 +113,8 @@ devDependencies: specifier: ^13.0.3 version: 13.0.3 next: - specifier: ^12.3.0 - version: 12.3.0(@babel/core@7.20.12)(react-dom@18.2.0)(react@18.2.0) + specifier: ^14.2.3 + version: 14.2.5(@babel/core@7.20.12)(@opentelemetry/api@1.7.0)(react-dom@18.2.0)(react@18.2.0) node-mocks-http: specifier: ^1.11.0 version: 1.11.0 @@ -910,30 +914,12 @@ packages: read-yaml-file: 1.1.0 dev: true - /@next/env@12.3.0: - resolution: {integrity: sha512-PTJpjAFVbzBQ9xXpzMTroShvD5YDIIy46jQ7d4LrWpY+/5a8H90Tm8hE3Hvkc5RBRspVo7kvEOnqQms0A+2Q6w==} - dev: true - - /@next/swc-android-arm-eabi@12.3.0: - resolution: {integrity: sha512-/PuirPnAKsYBw93w/7Q9hqy+KGOU9mjYprZ/faxMUJh/dc6v3rYLxkZKNG9nFPIW4QKNTCnhP40xF9hLnxO+xg==} - engines: {node: '>= 10'} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@next/swc-android-arm64@12.3.0: - resolution: {integrity: sha512-OaI+FhAM6P9B6Ybwbn0Zl8YwWido0lLwhDBi9WiYCh4RQmIXAyVIoIJPHo4fP05+mXaJ/k1trvDvuURvHOq2qw==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [android] - requiresBuild: true + /@next/env@14.2.5: + resolution: {integrity: sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==} dev: true - optional: true - /@next/swc-darwin-arm64@12.3.0: - resolution: {integrity: sha512-9s4d3Mhii+WFce8o8Jok7WC3Bawkr9wEUU++SJRptjU1L5tsfYJMrSYCACHLhZujziNDLyExe4Hwwsccps1sfg==} + /@next/swc-darwin-arm64@14.2.5: + resolution: {integrity: sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -941,8 +927,8 @@ packages: dev: true optional: true - /@next/swc-darwin-x64@12.3.0: - resolution: {integrity: sha512-2scC4MqUTwGwok+wpVxP+zWp7WcCAVOtutki2E1n99rBOTnUOX6qXkgxSy083yBN6GqwuC/dzHeN7hIKjavfRA==} + /@next/swc-darwin-x64@14.2.5: + resolution: {integrity: sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -950,26 +936,8 @@ packages: dev: true optional: true - /@next/swc-freebsd-x64@12.3.0: - resolution: {integrity: sha512-xAlruUREij/bFa+qsE1tmsP28t7vz02N4ZDHt2lh3uJUniE0Ne9idyIDLc1Ed0IF2RjfgOp4ZVunuS3OM0sngw==} - engines: {node: '>= 10'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-arm-gnueabihf@12.3.0: - resolution: {integrity: sha512-jin2S4VT/cugc2dSZEUIabhYDJNgrUh7fufbdsaAezgcQzqfdfJqfxl4E9GuafzB4cbRPTaqA0V5uqbp0IyGkQ==} - engines: {node: '>= 10'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-arm64-gnu@12.3.0: - resolution: {integrity: sha512-RqJHDKe0WImeUrdR0kayTkRWgp4vD/MS7g0r6Xuf8+ellOFH7JAAJffDW3ayuVZeMYOa7RvgNFcOoWnrTUl9Nw==} + /@next/swc-linux-arm64-gnu@14.2.5: + resolution: {integrity: sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -977,8 +945,8 @@ packages: dev: true optional: true - /@next/swc-linux-arm64-musl@12.3.0: - resolution: {integrity: sha512-nvNWoUieMjvDjpYJ/4SQe9lQs2xMj6ZRs8N+bmTrVu9leY2Fg3WD6W9p/1uU9hGO8u+OdF13wc4iRShu/WYIHg==} + /@next/swc-linux-arm64-musl@14.2.5: + resolution: {integrity: sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -986,8 +954,8 @@ packages: dev: true optional: true - /@next/swc-linux-x64-gnu@12.3.0: - resolution: {integrity: sha512-4ajhIuVU9PeQCMMhdDgZTLrHmjbOUFuIyg6J19hZqwEwDTSqQyrSLkbJs2Nd7IRiM6Ul/XyrtEFCpk4k+xD2+w==} + /@next/swc-linux-x64-gnu@14.2.5: + resolution: {integrity: sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -995,8 +963,8 @@ packages: dev: true optional: true - /@next/swc-linux-x64-musl@12.3.0: - resolution: {integrity: sha512-U092RBYbaGxoMAwpauePJEu2PuZSEoUCGJBvsptQr2/2XIMwAJDYM4c/M5NfYEsBr+yjvsYNsOpYfeQ88D82Yg==} + /@next/swc-linux-x64-musl@14.2.5: + resolution: {integrity: sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1004,8 +972,8 @@ packages: dev: true optional: true - /@next/swc-win32-arm64-msvc@12.3.0: - resolution: {integrity: sha512-pzSzaxjDEJe67bUok9Nxf9rykbJfHXW0owICFsPBsqHyc+cr8vpF7g9e2APTCddtVhvjkga9ILoZJ9NxWS7Yiw==} + /@next/swc-win32-arm64-msvc@14.2.5: + resolution: {integrity: sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1013,8 +981,8 @@ packages: dev: true optional: true - /@next/swc-win32-ia32-msvc@12.3.0: - resolution: {integrity: sha512-MQGUpMbYhQmTZ06a9e0hPQJnxFMwETo2WtyAotY3GEzbNCQVbCGhsvqEKcl+ZEHgShlHXUWvSffq1ZscY6gK7A==} + /@next/swc-win32-ia32-msvc@14.2.5: + resolution: {integrity: sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -1022,8 +990,8 @@ packages: dev: true optional: true - /@next/swc-win32-x64-msvc@12.3.0: - resolution: {integrity: sha512-C/nw6OgQpEULWqs+wgMHXGvlJLguPRFFGqR2TAqWBerQ8J+Sg3z1ZTqwelkSi4FoqStGuZ2UdFHIDN1ySmR1xA==} + /@next/swc-win32-x64-msvc@14.2.5: + resolution: {integrity: sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1055,7 +1023,6 @@ packages: /@opentelemetry/api@1.7.0: resolution: {integrity: sha512-AdY5wvN0P2vXBi3b29hxZgSFvdhdxPB9+f0B6s//P9Q8nibRWeA3cHm8UmLpio9ABigkVHJ5NMPk+Mz8VCCyrw==} engines: {node: '>=8.0.0'} - dev: false /@opentelemetry/semantic-conventions@1.18.1: resolution: {integrity: sha512-+NLGHr6VZwcgE/2lw8zDIufOCGnzsA5CbQIMleXZTrgkBd0TanCX+MiDYJ1TOS4KL/Tqk0nFRxawnaYr6pkZkA==} @@ -1074,9 +1041,14 @@ packages: tslib: 2.4.0 dev: true - /@swc/helpers@0.4.11: - resolution: {integrity: sha512-rEUrBSGIoSFuYxwBYtlUFMlE2CwGhmW+w9355/5oduSw8e5h2+Tj4UrAGNNgP9915++wj5vkQo0UuOBqOAq4nw==} + /@swc/counter@0.1.3: + resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} + dev: true + + /@swc/helpers@0.5.5: + resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==} dependencies: + '@swc/counter': 0.1.3 tslib: 2.4.0 dev: true @@ -1680,7 +1652,6 @@ packages: engines: {node: '>=10.16.0'} dependencies: streamsearch: 1.1.0 - dev: false /bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} @@ -1741,6 +1712,10 @@ packages: resolution: {integrity: sha512-sS4CaUM+/+vqQUlCvCJ2WtDlV81aWtHhqeEVkLokVJJa3ViN4zDxAGfq9R8i1m90uGHxo99cy10Od+lvn3hf0g==} dev: true + /caniuse-lite@1.0.30001643: + resolution: {integrity: sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==} + dev: true + /chai@4.3.7: resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==} engines: {node: '>=4'} @@ -1838,6 +1813,10 @@ packages: string-width: 5.1.2 dev: true + /client-only@0.0.1: + resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} + dev: true + /cliui@6.0.0: resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==} dependencies: @@ -3376,6 +3355,10 @@ packages: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} dev: true + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: true + /grapheme-splitter@1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} dev: true @@ -4210,6 +4193,12 @@ packages: hasBin: true dev: true + /nanoid@3.3.7: + resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: true + /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true @@ -4219,46 +4208,44 @@ packages: engines: {node: '>= 0.6'} dev: true - /next@12.3.0(@babel/core@7.20.12)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-GpzI6me9V1+XYtfK0Ae9WD0mKqHyzQlGq1xH1rzNIYMASo4Tkl4rTe9jSqtBpXFhOS33KohXs9ZY38Akkhdciw==} - engines: {node: '>=12.22.0'} + /next@14.2.5(@babel/core@7.20.12)(@opentelemetry/api@1.7.0)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA==} + engines: {node: '>=18.17.0'} hasBin: true peerDependencies: - fibers: '>= 3.1.0' - node-sass: ^6.0.0 || ^7.0.0 - react: ^17.0.2 || ^18.0.0-0 - react-dom: ^17.0.2 || ^18.0.0-0 + '@opentelemetry/api': ^1.1.0 + '@playwright/test': ^1.41.2 + react: ^18.2.0 + react-dom: ^18.2.0 sass: ^1.3.0 peerDependenciesMeta: - fibers: + '@opentelemetry/api': optional: true - node-sass: + '@playwright/test': optional: true sass: optional: true dependencies: - '@next/env': 12.3.0 - '@swc/helpers': 0.4.11 - caniuse-lite: 1.0.30001390 - postcss: 8.4.14 + '@next/env': 14.2.5 + '@opentelemetry/api': 1.7.0 + '@swc/helpers': 0.5.5 + busboy: 1.6.0 + caniuse-lite: 1.0.30001643 + graceful-fs: 4.2.11 + postcss: 8.4.31 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - styled-jsx: 5.0.6(@babel/core@7.20.12)(react@18.2.0) - use-sync-external-store: 1.2.0(react@18.2.0) + styled-jsx: 5.1.1(@babel/core@7.20.12)(react@18.2.0) optionalDependencies: - '@next/swc-android-arm-eabi': 12.3.0 - '@next/swc-android-arm64': 12.3.0 - '@next/swc-darwin-arm64': 12.3.0 - '@next/swc-darwin-x64': 12.3.0 - '@next/swc-freebsd-x64': 12.3.0 - '@next/swc-linux-arm-gnueabihf': 12.3.0 - '@next/swc-linux-arm64-gnu': 12.3.0 - '@next/swc-linux-arm64-musl': 12.3.0 - '@next/swc-linux-x64-gnu': 12.3.0 - '@next/swc-linux-x64-musl': 12.3.0 - '@next/swc-win32-arm64-msvc': 12.3.0 - '@next/swc-win32-ia32-msvc': 12.3.0 - '@next/swc-win32-x64-msvc': 12.3.0 + '@next/swc-darwin-arm64': 14.2.5 + '@next/swc-darwin-x64': 14.2.5 + '@next/swc-linux-arm64-gnu': 14.2.5 + '@next/swc-linux-arm64-musl': 14.2.5 + '@next/swc-linux-x64-gnu': 14.2.5 + '@next/swc-linux-x64-musl': 14.2.5 + '@next/swc-win32-arm64-msvc': 14.2.5 + '@next/swc-win32-ia32-msvc': 14.2.5 + '@next/swc-win32-x64-msvc': 14.2.5 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -4624,8 +4611,8 @@ packages: yaml: 1.10.2 dev: true - /postcss@8.4.14: - resolution: {integrity: sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==} + /postcss@8.4.21: + resolution: {integrity: sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==} engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.4 @@ -4633,11 +4620,11 @@ packages: source-map-js: 1.0.2 dev: true - /postcss@8.4.21: - resolution: {integrity: sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==} + /postcss@8.4.31: + resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} dependencies: - nanoid: 3.3.4 + nanoid: 3.3.7 picocolors: 1.0.0 source-map-js: 1.0.2 dev: true @@ -5156,7 +5143,6 @@ packages: /streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} - dev: false /strict-uri-encode@2.0.0: resolution: {integrity: sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==} @@ -5262,8 +5248,8 @@ packages: acorn: 8.8.1 dev: true - /styled-jsx@5.0.6(@babel/core@7.20.12)(react@18.2.0): - resolution: {integrity: sha512-xOeROtkK5MGMDimBQ3J6iPId8q0t/BDoG5XN6oKkZClVz9ISF/hihN8OCn2LggMU6N32aXnrXBdn3auSqNS9fA==} + /styled-jsx@5.1.1(@babel/core@7.20.12)(react@18.2.0): + resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} engines: {node: '>= 12.0.0'} peerDependencies: '@babel/core': '*' @@ -5276,6 +5262,7 @@ packages: optional: true dependencies: '@babel/core': 7.20.12 + client-only: 0.0.1 react: 18.2.0 dev: true @@ -5640,14 +5627,6 @@ packages: requires-port: 1.0.0 dev: true - /use-sync-external-store@1.2.0(react@18.2.0): - resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==} - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - dependencies: - react: 18.2.0 - dev: true - /uuid@9.0.0: resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==} hasBin: true @@ -6114,7 +6093,3 @@ packages: dev: false publishDirectory: dist - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false diff --git a/src/app-bridge/next/route-propagator.tsx b/src/app-bridge/next/route-propagator.tsx index c9d715de..a2ca452e 100644 --- a/src/app-bridge/next/route-propagator.tsx +++ b/src/app-bridge/next/route-propagator.tsx @@ -1,38 +1,39 @@ /** * Use .js extension to avoid broken builds with ESM */ -import * as NextRouter from "next/router.js"; +import * as NextRouter from "next/navigation.js"; import { useEffect } from "react"; import { actions } from "../actions"; import { useAppBridge } from "../app-bridge-provider"; -const { useRouter } = NextRouter; +const { usePathname, useSearchParams } = NextRouter; /** * Synchronizes app inner state (inside iframe) with dashboard routing, so app's route can be restored after refresh */ export const useRoutePropagator = () => { const { appBridge, appBridgeState } = useAppBridge(); - const router = useRouter(); + const pathname = usePathname(); + const searchParams = useSearchParams(); useEffect(() => { if (!appBridgeState?.ready ?? !appBridge) { return; } - router.events.on("routeChangeComplete", (url) => { - appBridge - ?.dispatch( - actions.UpdateRouting({ - newRoute: url, - }) - ) - .catch(() => { - console.error("Error dispatching action"); - }); - }); - }, [appBridgeState, appBridge]); + const url = `${pathname}?${searchParams}`; + + appBridge + ?.dispatch( + actions.UpdateRouting({ + newRoute: url, + }) + ) + .catch(() => { + console.error("Error dispatching action"); + }); + }, [appBridgeState, appBridge, pathname, searchParams]); }; /**