diff --git a/web/app/entry.worker.ts b/web/app/entry.worker.ts deleted file mode 100644 index c3f6711..0000000 --- a/web/app/entry.worker.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// - -export {}; - -declare let self: ServiceWorkerGlobalScope; - -import { Logger } from "@remix-pwa/sw"; - -const logger = new Logger({ prefix: "[SW]" }); - -self.addEventListener("install", (event) => { - logger.log("Service worker installed"); - - event.waitUntil(self.skipWaiting()); -}); - -self.addEventListener("activate", (event) => { - logger.log("Service worker activated"); - - const cachesToKeep: string[] = []; - - const clearUpAllLegacyCaches = async () => { - return caches.keys().then((keyList) => - Promise.all( - keyList.map((key) => { - if (!cachesToKeep.includes(key)) { - return caches.delete(key); - } - }), - ), - ); - }; - - const handler = async () => { - await clearUpAllLegacyCaches(); - await self.clients.claim(); - }; - - event.waitUntil(handler()); -}); diff --git a/web/app/licenses.json b/web/app/licenses.json index 9f65f3b..e547b40 100644 --- a/web/app/licenses.json +++ b/web/app/licenses.json @@ -1 +1,730 @@ -[{"department":"kessler","relatedTo":"stuff","name":"@ai-sdk/google","licensePeriod":"perpetual","material":"material","licenseType":"Apache-2.0","link":"git+https://github.com/vercel/ai.git","remoteVersion":"0.0.55","installedVersion":"0.0.55","definedVersion":"^0.0.55","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@isaacs/ttlcache","licensePeriod":"perpetual","material":"material","licenseType":"ISC","link":"git+https://github.com/isaacs/ttlcache.git","remoteVersion":"1.4.1","installedVersion":"1.4.1","definedVersion":"^1.4.1","author":"Isaac Z. Schlueter (https://izs.me)"},{"department":"kessler","relatedTo":"stuff","name":"@radix-ui/react-slot","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/radix-ui/primitives.git","remoteVersion":"1.1.0","installedVersion":"1.1.0","definedVersion":"^1.1.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-pwa/client","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+ssh://git@github.com/remix-pwa/monorepo.git","remoteVersion":"3.0.7","installedVersion":"3.0.7","definedVersion":"^3.0.7","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-pwa/sw","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+ssh://git@github.com/remix-pwa/monorepo.git","remoteVersion":"3.0.10","installedVersion":"3.0.10","definedVersion":"^3.0.10","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-pwa/worker-runtime","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"https://remix-pwa.run","remoteVersion":"2.1.4","installedVersion":"2.1.4","definedVersion":"^2.1.4","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-run/node","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/remix-run/remix.git","remoteVersion":"2.13.1","installedVersion":"2.13.1","definedVersion":"^2.13.1","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-run/react","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/remix-run/remix.git","remoteVersion":"2.13.1","installedVersion":"2.13.1","definedVersion":"^2.13.1","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-run/serve","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/remix-run/remix.git","remoteVersion":"2.13.1","installedVersion":"2.13.1","definedVersion":"^2.13.1","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remixicon/react","licensePeriod":"perpetual","material":"material","licenseType":"Apache-2.0","link":"git+https://github.com/Remix-Design/remixicon.git","remoteVersion":"4.5.0","installedVersion":"4.5.0","definedVersion":"^4.5.0","author":"Wendy Gao "},{"department":"kessler","relatedTo":"stuff","name":"@resvg/resvg-js","licensePeriod":"perpetual","material":"material","licenseType":"MPL-2.0","link":"git+ssh://git@github.com/yisibl/resvg-js.git","remoteVersion":"2.6.2","installedVersion":"2.6.2","definedVersion":"^2.6.2","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@splinetool/react-spline","licensePeriod":"perpetual","material":"material","licenseType":"n/a","link":"https://registry.npmjs.org/@splinetool/react-spline/-/react-spline-4.0.0.tgz","remoteVersion":"4.0.0","installedVersion":"4.0.0","definedVersion":"^4.0.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@uidotdev/usehooks","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/uidotdev/usehooks.git","remoteVersion":"2.4.1","installedVersion":"2.4.1","definedVersion":"^2.4.1","author":"Tyler McGinnis, Ben Adam"},{"department":"kessler","relatedTo":"stuff","name":"ai","licensePeriod":"perpetual","material":"material","licenseType":"Apache-2.0","link":"git+https://github.com/vercel/ai.git","remoteVersion":"3.4.33","installedVersion":"3.4.33","definedVersion":"^3.4.33","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"clsx","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/lukeed/clsx.git","remoteVersion":"2.1.1","installedVersion":"2.1.1","definedVersion":"^2.1.1","author":"Luke Edwards luke.edwards05@gmail.com https://lukeed.com"},{"department":"kessler","relatedTo":"stuff","name":"cva","licensePeriod":"perpetual","material":"material","licenseType":"Apache-2.0","link":"git+https://github.com/joe-bell/cva.git","remoteVersion":"1.0.0-beta.1","installedVersion":"1.0.0-beta.1","definedVersion":"^1.0.0-beta.1","author":"Joe Bell (https://joebell.co.uk)"},{"department":"kessler","relatedTo":"stuff","name":"date-fns","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/date-fns/date-fns.git","remoteVersion":"4.1.0","installedVersion":"4.1.0","definedVersion":"^4.1.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"es-toolkit","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/toss/es-toolkit.git","remoteVersion":"1.26.1","installedVersion":"1.26.1","definedVersion":"^1.26.1","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"eslint-plugin-unused-imports","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/sweepline/eslint-plugin-unused-imports.git","remoteVersion":"4.1.4","installedVersion":"4.1.4","definedVersion":"^4.1.4","author":"Mikkel Holmer Pedersen"},{"department":"kessler","relatedTo":"stuff","name":"isbot","licensePeriod":"perpetual","material":"material","licenseType":"Unlicense","link":"git+https://github.com/omrilotan/isbot.git","remoteVersion":"5.1.17","installedVersion":"5.1.17","definedVersion":"^5.1.17","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"minisearch","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"https://github.com/lucaong/minisearch.git","remoteVersion":"7.1.0","installedVersion":"7.1.0","definedVersion":"^7.1.0","author":"Luca Ongaro"},{"department":"kessler","relatedTo":"stuff","name":"react","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/facebook/react.git","remoteVersion":"18.3.1","installedVersion":"18.3.1","definedVersion":"^18.2.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"react-dom","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/facebook/react.git","remoteVersion":"18.3.1","installedVersion":"18.3.1","definedVersion":"^18.2.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"remix-utils","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/sergiodxa/remix-utils.git","remoteVersion":"7.7.0","installedVersion":"7.7.0","definedVersion":"^7.7.0","author":"Sergio Xalambrí hello@sergiodxa.com https://sergiodxa.com"},{"department":"kessler","relatedTo":"stuff","name":"satori","licensePeriod":"perpetual","material":"material","licenseType":"MPL-2.0","link":"git+https://github.com/vercel/satori.git","remoteVersion":"0.11.3","installedVersion":"0.11.3","definedVersion":"^0.11.3","author":"Shu Ding "},{"department":"kessler","relatedTo":"stuff","name":"schema-dts","licensePeriod":"perpetual","material":"material","licenseType":"Apache-2.0","link":"git+https://github.com/google/schema-dts.git","remoteVersion":"1.1.2","installedVersion":"1.1.2","definedVersion":"^1.1.2","author":"Eyas Sharaiha (https://eyas.sh/)"},{"department":"kessler","relatedTo":"stuff","name":"sonner","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/emilkowalski/sonner.git","remoteVersion":"1.7.0","installedVersion":"1.7.0","definedVersion":"^1.7.0","author":"Emil Kowalski "},{"department":"kessler","relatedTo":"stuff","name":"tailwindcss-animated","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/new-data-services/tailwindcss-animated.git","remoteVersion":"1.1.2","installedVersion":"1.1.2","definedVersion":"^1.1.2","author":"new-data-services"},{"department":"kessler","relatedTo":"stuff","name":"xss","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git://github.com/leizongmin/js-xss.git","remoteVersion":"1.0.15","installedVersion":"1.0.15","definedVersion":"^1.0.15","author":"Zongmin Lei (http://ucdok.com)"},{"department":"kessler","relatedTo":"stuff","name":"zod","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/colinhacks/zod.git","remoteVersion":"3.23.8","installedVersion":"3.23.8","definedVersion":"^3.23.8","author":"Colin McDonnell "},{"department":"kessler","relatedTo":"stuff","name":"@remix-pwa/dev","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+ssh://git@github.com/remix-pwa/monorepo.git","remoteVersion":"3.1.0","installedVersion":"3.1.0","definedVersion":"^3.1.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@remix-run/dev","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/remix-run/remix.git","remoteVersion":"2.13.1","installedVersion":"2.13.1","definedVersion":"^2.13.1","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@types/react","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"https://github.com/DefinitelyTyped/DefinitelyTyped.git","remoteVersion":"18.3.12","installedVersion":"18.3.12","definedVersion":"^18.3.11","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@types/react-dom","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"https://github.com/DefinitelyTyped/DefinitelyTyped.git","remoteVersion":"18.3.1","installedVersion":"18.3.1","definedVersion":"^18.3.1","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@typescript-eslint/eslint-plugin","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/typescript-eslint/typescript-eslint.git","remoteVersion":"8.13.0","installedVersion":"8.13.0","definedVersion":"^8.13.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"@typescript-eslint/parser","licensePeriod":"perpetual","material":"material","licenseType":"BSD-2-Clause","link":"git+https://github.com/typescript-eslint/typescript-eslint.git","remoteVersion":"8.13.0","installedVersion":"8.13.0","definedVersion":"^8.13.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"autoprefixer","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/postcss/autoprefixer.git","remoteVersion":"10.4.20","installedVersion":"10.4.20","definedVersion":"^10.4.19","author":"Andrey Sitnik "},{"department":"kessler","relatedTo":"stuff","name":"dotenv-cli","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/entropitor/dotenv-cli.git","remoteVersion":"7.4.2","installedVersion":"7.4.2","definedVersion":"^7.4.2","author":"entropitor"},{"department":"kessler","relatedTo":"stuff","name":"eslint","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/eslint/eslint.git","remoteVersion":"8.57.1","installedVersion":"8.57.1","definedVersion":"^8.38.0","author":"Nicholas C. Zakas "},{"department":"kessler","relatedTo":"stuff","name":"eslint-import-resolver-typescript","licensePeriod":"perpetual","material":"material","licenseType":"ISC","link":"git+https://github.com/import-js/eslint-import-resolver-typescript.git","remoteVersion":"3.6.3","installedVersion":"3.6.3","definedVersion":"^3.6.1","author":"Alex Gorbatchev "},{"department":"kessler","relatedTo":"stuff","name":"eslint-plugin-import","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/import-js/eslint-plugin-import.git","remoteVersion":"2.31.0","installedVersion":"2.31.0","definedVersion":"^2.31.0","author":"Ben Mosher "},{"department":"kessler","relatedTo":"stuff","name":"eslint-plugin-jsx-a11y","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/jsx-eslint/eslint-plugin-jsx-a11y.git","remoteVersion":"6.10.2","installedVersion":"6.10.2","definedVersion":"^6.10.1","author":"Ethan Cohen"},{"department":"kessler","relatedTo":"stuff","name":"eslint-plugin-react","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/jsx-eslint/eslint-plugin-react.git","remoteVersion":"7.37.2","installedVersion":"7.37.2","definedVersion":"^7.37.1","author":"Yannick Croissant "},{"department":"kessler","relatedTo":"stuff","name":"eslint-plugin-react-hooks","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/facebook/react.git","remoteVersion":"5.0.0","installedVersion":"5.0.0","definedVersion":"^5.0.0","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"license-report","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/kessler/license-report.git","remoteVersion":"6.7.0","installedVersion":"6.7.0","definedVersion":"^6.7.0","author":"Yaniv Kessler"},{"department":"kessler","relatedTo":"stuff","name":"msw","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/mswjs/msw.git","remoteVersion":"2.6.1","installedVersion":"2.6.0","definedVersion":"^2.6.0","author":"Artem Zakharchenko https://github.com/kettanaito"},{"department":"kessler","relatedTo":"stuff","name":"npm-check","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/dylang/npm-check.git","remoteVersion":"6.0.1","installedVersion":"6.0.1","definedVersion":"^6.0.1","author":"Dylan Greene dylang@gmail.com"},{"department":"kessler","relatedTo":"stuff","name":"postcss","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/postcss/postcss.git","remoteVersion":"8.4.47","installedVersion":"8.4.47","definedVersion":"^8.4.38","author":"Andrey Sitnik "},{"department":"kessler","relatedTo":"stuff","name":"prettier","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/prettier/prettier.git","remoteVersion":"3.3.3","installedVersion":"3.3.3","definedVersion":"^3.3.3","author":"James Long"},{"department":"kessler","relatedTo":"stuff","name":"prettier-plugin-tailwindcss","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/tailwindlabs/prettier-plugin-tailwindcss.git","remoteVersion":"0.6.8","installedVersion":"0.6.8","definedVersion":"^0.6.8","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"tailwindcss","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/tailwindlabs/tailwindcss.git","remoteVersion":"3.4.14","installedVersion":"3.4.14","definedVersion":"^3.4.14","author":"n/a"},{"department":"kessler","relatedTo":"stuff","name":"tailwindcss-bg-patterns","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+ssh://git@github.com/thillmann/tailwind-patterns.git","remoteVersion":"0.3.0","installedVersion":"0.3.0","definedVersion":"^0.3.0","author":"Timo Hillmann "},{"department":"kessler","relatedTo":"stuff","name":"tailwindcss-radix-colors","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/mrcaidev/tailwindcss-radix-colors.git","remoteVersion":"1.4.1","installedVersion":"1.4.1","definedVersion":"^1.4.1","author":"Yuwang Cai mrcaidev@gmail.com https://mrcai.dev"},{"department":"kessler","relatedTo":"stuff","name":"typescript","licensePeriod":"perpetual","material":"material","licenseType":"Apache-2.0","link":"git+https://github.com/microsoft/TypeScript.git","remoteVersion":"5.6.3","installedVersion":"5.6.3","definedVersion":"^5.6.3","author":"Microsoft Corp."},{"department":"kessler","relatedTo":"stuff","name":"vite","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/vitejs/vite.git","remoteVersion":"5.4.10","installedVersion":"5.4.10","definedVersion":"^5.4.9","author":"Evan You"},{"department":"kessler","relatedTo":"stuff","name":"vite-tsconfig-paths","licensePeriod":"perpetual","material":"material","licenseType":"MIT","link":"git+https://github.com/aleclarson/vite-tsconfig-paths.git","remoteVersion":"5.1.0","installedVersion":"5.1.0","definedVersion":"^5.1.0","author":"aleclarson"}] +[ + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@ai-sdk/google", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Apache-2.0", + "link": "git+https://github.com/vercel/ai.git", + "remoteVersion": "0.0.55", + "installedVersion": "0.0.55", + "definedVersion": "^0.0.55", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@isaacs/ttlcache", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "ISC", + "link": "git+https://github.com/isaacs/ttlcache.git", + "remoteVersion": "1.4.1", + "installedVersion": "1.4.1", + "definedVersion": "^1.4.1", + "author": "Isaac Z. Schlueter (https://izs.me)" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@radix-ui/react-slot", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/radix-ui/primitives.git", + "remoteVersion": "1.1.0", + "installedVersion": "1.1.0", + "definedVersion": "^1.1.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-pwa/client", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+ssh://git@github.com/remix-pwa/monorepo.git", + "remoteVersion": "3.0.7", + "installedVersion": "3.0.7", + "definedVersion": "^3.0.7", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-pwa/sw", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+ssh://git@github.com/remix-pwa/monorepo.git", + "remoteVersion": "3.0.10", + "installedVersion": "3.0.10", + "definedVersion": "^3.0.10", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-pwa/worker-runtime", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "https://remix-pwa.run", + "remoteVersion": "2.1.4", + "installedVersion": "2.1.4", + "definedVersion": "^2.1.4", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-run/node", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/remix-run/remix.git", + "remoteVersion": "2.13.1", + "installedVersion": "2.13.1", + "definedVersion": "^2.13.1", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-run/react", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/remix-run/remix.git", + "remoteVersion": "2.13.1", + "installedVersion": "2.13.1", + "definedVersion": "^2.13.1", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-run/serve", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/remix-run/remix.git", + "remoteVersion": "2.13.1", + "installedVersion": "2.13.1", + "definedVersion": "^2.13.1", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remixicon/react", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Apache-2.0", + "link": "git+https://github.com/Remix-Design/remixicon.git", + "remoteVersion": "4.5.0", + "installedVersion": "4.5.0", + "definedVersion": "^4.5.0", + "author": "Wendy Gao " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@resvg/resvg-js", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MPL-2.0", + "link": "git+ssh://git@github.com/yisibl/resvg-js.git", + "remoteVersion": "2.6.2", + "installedVersion": "2.6.2", + "definedVersion": "^2.6.2", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@splinetool/react-spline", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "n/a", + "link": "https://registry.npmjs.org/@splinetool/react-spline/-/react-spline-4.0.0.tgz", + "remoteVersion": "4.0.0", + "installedVersion": "4.0.0", + "definedVersion": "^4.0.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@uidotdev/usehooks", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/uidotdev/usehooks.git", + "remoteVersion": "2.4.1", + "installedVersion": "2.4.1", + "definedVersion": "^2.4.1", + "author": "Tyler McGinnis, Ben Adam" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "ai", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Apache-2.0", + "link": "git+https://github.com/vercel/ai.git", + "remoteVersion": "3.4.33", + "installedVersion": "3.4.33", + "definedVersion": "^3.4.33", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "clsx", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/lukeed/clsx.git", + "remoteVersion": "2.1.1", + "installedVersion": "2.1.1", + "definedVersion": "^2.1.1", + "author": "Luke Edwards luke.edwards05@gmail.com https://lukeed.com" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "cva", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Apache-2.0", + "link": "git+https://github.com/joe-bell/cva.git", + "remoteVersion": "1.0.0-beta.1", + "installedVersion": "1.0.0-beta.1", + "definedVersion": "^1.0.0-beta.1", + "author": "Joe Bell (https://joebell.co.uk)" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "date-fns", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/date-fns/date-fns.git", + "remoteVersion": "4.1.0", + "installedVersion": "4.1.0", + "definedVersion": "^4.1.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "es-toolkit", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/toss/es-toolkit.git", + "remoteVersion": "1.26.1", + "installedVersion": "1.26.1", + "definedVersion": "^1.26.1", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint-plugin-unused-imports", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/sweepline/eslint-plugin-unused-imports.git", + "remoteVersion": "4.1.4", + "installedVersion": "4.1.4", + "definedVersion": "^4.1.4", + "author": "Mikkel Holmer Pedersen" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "isbot", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Unlicense", + "link": "git+https://github.com/omrilotan/isbot.git", + "remoteVersion": "5.1.17", + "installedVersion": "5.1.17", + "definedVersion": "^5.1.17", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "minisearch", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "https://github.com/lucaong/minisearch.git", + "remoteVersion": "7.1.0", + "installedVersion": "7.1.0", + "definedVersion": "^7.1.0", + "author": "Luca Ongaro" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "react", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/facebook/react.git", + "remoteVersion": "18.3.1", + "installedVersion": "18.3.1", + "definedVersion": "^18.2.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "react-dom", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/facebook/react.git", + "remoteVersion": "18.3.1", + "installedVersion": "18.3.1", + "definedVersion": "^18.2.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "remix-utils", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/sergiodxa/remix-utils.git", + "remoteVersion": "7.7.0", + "installedVersion": "7.7.0", + "definedVersion": "^7.7.0", + "author": "Sergio Xalambrí hello@sergiodxa.com https://sergiodxa.com" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "satori", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MPL-2.0", + "link": "git+https://github.com/vercel/satori.git", + "remoteVersion": "0.11.3", + "installedVersion": "0.11.3", + "definedVersion": "^0.11.3", + "author": "Shu Ding " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "schema-dts", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Apache-2.0", + "link": "git+https://github.com/google/schema-dts.git", + "remoteVersion": "1.1.2", + "installedVersion": "1.1.2", + "definedVersion": "^1.1.2", + "author": "Eyas Sharaiha (https://eyas.sh/)" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "sonner", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/emilkowalski/sonner.git", + "remoteVersion": "1.7.0", + "installedVersion": "1.7.0", + "definedVersion": "^1.7.0", + "author": "Emil Kowalski " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "tailwindcss-animated", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/new-data-services/tailwindcss-animated.git", + "remoteVersion": "1.1.2", + "installedVersion": "1.1.2", + "definedVersion": "^1.1.2", + "author": "new-data-services" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "xss", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git://github.com/leizongmin/js-xss.git", + "remoteVersion": "1.0.15", + "installedVersion": "1.0.15", + "definedVersion": "^1.0.15", + "author": "Zongmin Lei (http://ucdok.com)" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "zod", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/colinhacks/zod.git", + "remoteVersion": "3.23.8", + "installedVersion": "3.23.8", + "definedVersion": "^3.23.8", + "author": "Colin McDonnell " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-pwa/dev", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+ssh://git@github.com/remix-pwa/monorepo.git", + "remoteVersion": "3.1.0", + "installedVersion": "3.1.0", + "definedVersion": "^3.1.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@remix-run/dev", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/remix-run/remix.git", + "remoteVersion": "2.13.1", + "installedVersion": "2.13.1", + "definedVersion": "^2.13.1", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@types/react", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "remoteVersion": "18.3.12", + "installedVersion": "18.3.12", + "definedVersion": "^18.3.11", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@types/react-dom", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "remoteVersion": "18.3.1", + "installedVersion": "18.3.1", + "definedVersion": "^18.3.1", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@typescript-eslint/eslint-plugin", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/typescript-eslint/typescript-eslint.git", + "remoteVersion": "8.13.0", + "installedVersion": "8.13.0", + "definedVersion": "^8.13.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "@typescript-eslint/parser", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "BSD-2-Clause", + "link": "git+https://github.com/typescript-eslint/typescript-eslint.git", + "remoteVersion": "8.13.0", + "installedVersion": "8.13.0", + "definedVersion": "^8.13.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "autoprefixer", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/postcss/autoprefixer.git", + "remoteVersion": "10.4.20", + "installedVersion": "10.4.20", + "definedVersion": "^10.4.19", + "author": "Andrey Sitnik " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "dotenv-cli", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/entropitor/dotenv-cli.git", + "remoteVersion": "7.4.2", + "installedVersion": "7.4.2", + "definedVersion": "^7.4.2", + "author": "entropitor" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/eslint/eslint.git", + "remoteVersion": "8.57.1", + "installedVersion": "8.57.1", + "definedVersion": "^8.38.0", + "author": "Nicholas C. Zakas " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint-import-resolver-typescript", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "ISC", + "link": "git+https://github.com/import-js/eslint-import-resolver-typescript.git", + "remoteVersion": "3.6.3", + "installedVersion": "3.6.3", + "definedVersion": "^3.6.1", + "author": "Alex Gorbatchev " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint-plugin-import", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/import-js/eslint-plugin-import.git", + "remoteVersion": "2.31.0", + "installedVersion": "2.31.0", + "definedVersion": "^2.31.0", + "author": "Ben Mosher " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint-plugin-jsx-a11y", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/jsx-eslint/eslint-plugin-jsx-a11y.git", + "remoteVersion": "6.10.2", + "installedVersion": "6.10.2", + "definedVersion": "^6.10.1", + "author": "Ethan Cohen" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint-plugin-react", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/jsx-eslint/eslint-plugin-react.git", + "remoteVersion": "7.37.2", + "installedVersion": "7.37.2", + "definedVersion": "^7.37.1", + "author": "Yannick Croissant " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "eslint-plugin-react-hooks", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/facebook/react.git", + "remoteVersion": "5.0.0", + "installedVersion": "5.0.0", + "definedVersion": "^5.0.0", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "license-report", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/kessler/license-report.git", + "remoteVersion": "6.7.0", + "installedVersion": "6.7.0", + "definedVersion": "^6.7.0", + "author": "Yaniv Kessler" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "msw", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/mswjs/msw.git", + "remoteVersion": "2.6.2", + "installedVersion": "2.6.0", + "definedVersion": "^2.6.0", + "author": "Artem Zakharchenko https://github.com/kettanaito" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "npm-check", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/dylang/npm-check.git", + "remoteVersion": "6.0.1", + "installedVersion": "6.0.1", + "definedVersion": "^6.0.1", + "author": "Dylan Greene dylang@gmail.com" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "postcss", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/postcss/postcss.git", + "remoteVersion": "8.4.47", + "installedVersion": "8.4.47", + "definedVersion": "^8.4.38", + "author": "Andrey Sitnik " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "prettier", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/prettier/prettier.git", + "remoteVersion": "3.3.3", + "installedVersion": "3.3.3", + "definedVersion": "^3.3.3", + "author": "James Long" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "prettier-plugin-tailwindcss", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/tailwindlabs/prettier-plugin-tailwindcss.git", + "remoteVersion": "0.6.8", + "installedVersion": "0.6.8", + "definedVersion": "^0.6.8", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "tailwindcss", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/tailwindlabs/tailwindcss.git", + "remoteVersion": "3.4.14", + "installedVersion": "3.4.14", + "definedVersion": "^3.4.14", + "author": "n/a" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "tailwindcss-bg-patterns", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+ssh://git@github.com/thillmann/tailwind-patterns.git", + "remoteVersion": "0.3.0", + "installedVersion": "0.3.0", + "definedVersion": "^0.3.0", + "author": "Timo Hillmann " + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "tailwindcss-radix-colors", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/mrcaidev/tailwindcss-radix-colors.git", + "remoteVersion": "1.4.1", + "installedVersion": "1.4.1", + "definedVersion": "^1.4.1", + "author": "Yuwang Cai mrcaidev@gmail.com https://mrcai.dev" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "typescript", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "Apache-2.0", + "link": "git+https://github.com/microsoft/TypeScript.git", + "remoteVersion": "5.6.3", + "installedVersion": "5.6.3", + "definedVersion": "^5.6.3", + "author": "Microsoft Corp." + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "vite", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/vitejs/vite.git", + "remoteVersion": "5.4.10", + "installedVersion": "5.4.10", + "definedVersion": "^5.4.9", + "author": "Evan You" + }, + { + "department": "kessler", + "relatedTo": "stuff", + "name": "vite-tsconfig-paths", + "licensePeriod": "perpetual", + "material": "material", + "licenseType": "MIT", + "link": "git+https://github.com/aleclarson/vite-tsconfig-paths.git", + "remoteVersion": "5.1.0", + "installedVersion": "5.1.0", + "definedVersion": "^5.1.0", + "author": "aleclarson" + } +] diff --git a/web/app/root.tsx b/web/app/root.tsx index f0cd1f4..b07b559 100644 --- a/web/app/root.tsx +++ b/web/app/root.tsx @@ -3,254 +3,23 @@ import { Link, Links, Meta, - MetaFunction, Outlet, Scripts, ScrollRestoration, useMatches, - useRevalidator, useRouteLoaderData, } from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; import { Footer } from "./modules/footer"; import "./tailwind.css"; import { ENV } from "./data/env"; -import { BASE_URL } from "./modules/app"; import { useEffect } from "react"; +import { unregisterServiceWorker } from "@remix-pwa/sw"; +import { rootLinks, rootMeta } from "./route.meta"; +import { clog } from "./modules/observability"; -export const meta: MetaFunction = ({ location }) => { - // Pseudo-randomly select a cover image based on the length - // of the current path (= stable index per site) and add - // the current day of the week as a seed so that the cover - // changes daily. - const dayOfWeek = new Date().getDay(); - const coverIndex = ((location.pathname.length + dayOfWeek) & 9) + 1; +export const meta = rootMeta; - return [ - { title: "CRAN/E" }, - { name: "description", content: "The R package search engine, enhanced" }, - { property: "og:type", content: "website" }, - { property: "og:url", content: BASE_URL }, - { - property: "og:image", - content: BASE_URL + `/images/og/cover-${coverIndex}.jpg`, - }, - ]; -}; - -export const links: LinksFunction = () => { - return [ - { - rel: "manifest", - href: "/manifest.webmanifest", - }, - { - rel: "icon", - href: "/icons/favicon.ico", - }, - { - rel: "icon", - type: "image/png", - sizes: "32x32", - href: "/icons/favicon-32x32.png", - }, - { - rel: "icon", - type: "image/png", - sizes: "16x16", - href: "/icons/favicon-16x16.png", - }, - { - rel: "mask-icon", - href: "/icons/safari-pinned-tab.svg", - color: "#5bbad5", - }, - { - rel: "apple-touch-icon", - href: "/icons/apple-icon-180.png", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2048-2732.jpg", - media: - "(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2732-2048.jpg", - media: - "(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1668-2388.jpg", - media: - "(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2388-1668.jpg", - media: - "(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1536-2048.jpg", - media: - "(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2048-1536.jpg", - media: - "(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1668-2224.jpg", - media: - "(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2224-1668.jpg", - media: - "(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1620-2160.jpg", - media: - "(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2160-1620.jpg", - media: - "(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1290-2796.jpg", - media: - "(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2796-1290.jpg", - media: - "(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1179-2556.jpg", - media: - "(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2556-1179.jpg", - media: - "(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1284-2778.jpg", - media: - "(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2778-1284.jpg", - media: - "(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1170-2532.jpg", - media: - "(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2532-1170.jpg", - media: - "(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1125-2436.jpg", - media: - "(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2436-1125.jpg", - media: - "(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1242-2688.jpg", - media: - "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2688-1242.jpg", - media: - "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-828-1792.jpg", - media: - "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1792-828.jpg", - media: - "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1242-2208.jpg", - media: - "(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-2208-1242.jpg", - media: - "(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-750-1334.jpg", - media: - "(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1334-750.jpg", - media: - "(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-640-1136.jpg", - media: - "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", - }, - { - rel: "apple-touch-startup-image", - href: "/icons/apple-splash-1136-640.jpg", - media: - "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", - }, - ]; -}; +export const links = rootLinks; export const loader = async () => { return json({ @@ -271,10 +40,10 @@ export default function App() { return handle?.hasFooter; }); - const revalidator = useRevalidator(); useEffect(() => { - revalidator.revalidate(); - // eslint-disable-next-line react-hooks/exhaustive-deps + unregisterServiceWorker().catch(error => { + clog.error("Failed to unregister service worker", error); + }); }, []); return ( @@ -283,8 +52,16 @@ export default function App() { - - + + diff --git a/web/app/route.meta.tsx b/web/app/route.meta.tsx new file mode 100644 index 0000000..1d88e6c --- /dev/null +++ b/web/app/route.meta.tsx @@ -0,0 +1,244 @@ +import { MetaFunction } from "@remix-run/react"; +import type { LinksFunction } from "@remix-run/node"; +import "./tailwind.css"; +import { BASE_URL } from "./modules/app"; + +/* + * Only purpose of this module is to have a single place to define + * metadata and links for the root route and not clutter the + * root route module with this information, as it's quite a lot. + */ + +export const rootMeta: MetaFunction = ({ location }) => { + // Pseudo-randomly select a cover image based on the length + // of the current path (= stable index per site) and add + // the current day of the week as a seed so that the cover + // changes daily. + const dayOfWeek = new Date().getDay(); + const coverIndex = ((location.pathname.length + dayOfWeek) & 9) + 1; + + return [ + { title: "CRAN/E" }, + { name: "description", content: "The R package search engine, enhanced" }, + { property: "og:type", content: "website" }, + { property: "og:url", content: BASE_URL }, + { + property: "og:image", + content: BASE_URL + `/images/og/cover-${coverIndex}.jpg`, + }, + ]; +}; + +export const rootLinks: LinksFunction = () => { + return [ + { + rel: "manifest", + href: "/manifest.webmanifest", + }, + { + rel: "icon", + href: "/icons/favicon.ico", + }, + { + rel: "icon", + type: "image/png", + sizes: "32x32", + href: "/icons/favicon-32x32.png", + }, + { + rel: "icon", + type: "image/png", + sizes: "16x16", + href: "/icons/favicon-16x16.png", + }, + { + rel: "mask-icon", + href: "/icons/safari-pinned-tab.svg", + color: "#5bbad5", + }, + { + rel: "apple-touch-icon", + href: "/icons/apple-icon-180.png", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2048-2732.jpg", + media: + "(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2732-2048.jpg", + media: + "(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1668-2388.jpg", + media: + "(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2388-1668.jpg", + media: + "(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1536-2048.jpg", + media: + "(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2048-1536.jpg", + media: + "(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1668-2224.jpg", + media: + "(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2224-1668.jpg", + media: + "(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1620-2160.jpg", + media: + "(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2160-1620.jpg", + media: + "(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1290-2796.jpg", + media: + "(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2796-1290.jpg", + media: + "(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1179-2556.jpg", + media: + "(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2556-1179.jpg", + media: + "(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1284-2778.jpg", + media: + "(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2778-1284.jpg", + media: + "(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1170-2532.jpg", + media: + "(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2532-1170.jpg", + media: + "(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1125-2436.jpg", + media: + "(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2436-1125.jpg", + media: + "(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1242-2688.jpg", + media: + "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2688-1242.jpg", + media: + "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-828-1792.jpg", + media: + "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1792-828.jpg", + media: + "(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1242-2208.jpg", + media: + "(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-2208-1242.jpg", + media: + "(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-750-1334.jpg", + media: + "(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1334-750.jpg", + media: + "(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-640-1136.jpg", + media: + "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)", + }, + { + rel: "apple-touch-startup-image", + href: "/icons/apple-splash-1136-640.jpg", + media: + "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)", + }, + ]; +}; diff --git a/web/app/routes/_index.tsx b/web/app/routes/_index.tsx index e1559f8..dc6d752 100644 --- a/web/app/routes/_index.tsx +++ b/web/app/routes/_index.tsx @@ -5,7 +5,6 @@ import { randomInt } from "es-toolkit"; import clsx from "clsx"; import { Footer } from "../modules/footer"; import { ENV } from "../data/env"; -import { usePrevious } from "@uidotdev/usehooks"; import { secondsToMilliseconds } from "date-fns"; export const handle = { @@ -28,14 +27,9 @@ export const loader = async () => { export default function Index() { const { meshIndex, version } = useLoaderData(); - // TODO: Remove once "useRevalidator" has been removed as well. - // This is only for a few days for legacy support of the old SW, - // as Remix PWA can't init itself on initial page load. - const prevMeshIndex = usePrevious(meshIndex); - return ( <> - + { let dailyDownloads: CranDownloadsResponse = []; let yearlyDailyDownloads: CranDownloadsResponse = []; let trendingPackages: CranTrendingPackagesRes = []; - let topDownloads: CranTopDownloadedPackagesRes |undefined = undefined; + let topDownloads: CranTopDownloadedPackagesRes | undefined = undefined; try { const [ @@ -272,7 +272,7 @@ export default function PackagePage() { monthlyDayDownloadsComment, peakYearlyDayDownloads, indexOfTrendingItems, - indexOfTopDownloads + indexOfTopDownloads, } = useLoaderData(); return ( @@ -359,7 +359,8 @@ function AboveTheFoldSection(props: { indexOfTrendingItems: number; indexOfTopDownloads: number; }) { - const { item, lastRelease, indexOfTrendingItems, indexOfTopDownloads } = props; + const { item, lastRelease, indexOfTrendingItems, indexOfTopDownloads } = + props; const rVersion = item.depends?.find((d) => d.name === "R")?.version; const getTrendingLabel = () => { @@ -376,7 +377,7 @@ function AboveTheFoldSection(props: { if (indexOfTopDownloads < 20) return "Top 20 downloaded package"; if (indexOfTopDownloads < 50) return "Top 50 downloaded package"; return "Top downloaded package"; - } + }; return ( diff --git a/web/public/entry.worker.js b/web/public/entry.worker.js deleted file mode 100644 index 47448eb..0000000 --- a/web/public/entry.worker.js +++ /dev/null @@ -1,5333 +0,0 @@ -var __defProp = Object.defineProperty; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); -function _mergeNamespaces(n, m) { - for (var i = 0; i < m.length; i++) { - const e = m[i]; - if (typeof e !== "string" && !Array.isArray(e)) { - for (const k in e) { - if (k !== "default" && !(k in n)) { - const d = Object.getOwnPropertyDescriptor(e, k); - if (d) { - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: () => e[k] - }); - } - } - } - } - } - return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" })); -} -const _Logger = class _Logger { - constructor(o) { - __publicField(this, "options"); - __publicField(this, "inGroup", false); - this.options = { ..._Logger.defaultOptions, ...o }; - } - setLogLevel(o) { - this.options.logLevel = o; - } - setStyles(o) { - this.options.styles = { ...this.options.styles, ...o }; - } - print(o, r) { - const { isProductionEnv: i, styles: e } = this.options; - if (i) return; - const t = o; - if ("groupCollapsed" === t && /^((?!chrome|android).*safari)/i.test(navigator.userAgent)) return void console[t](...r); - const n = Object.entries(e[o]).map(([o2, r2]) => `${o2}: ${r2}`).join("; "), s = this.inGroup ? [] : [`%c${this.options.prefix}`, n]; - console[t](...s, ...r), "groupCollapsed" === t && (this.inGroup = true), "groupEnd" === t && (this.inGroup = false); - } - debug(...o) { - this.shouldLog("debug") && this.print("debug", o); - } - info(...o) { - this.shouldLog("info") && this.print("info", o); - } - log(...o) { - this.shouldLog("log") && this.print("log", o); - } - warn(...o) { - this.shouldLog("warn") && this.print("warn", o); - } - error(...o) { - this.shouldLog("error") && this.print("error", o); - } - groupCollapsed(...o) { - this.print("groupCollapsed", o); - } - groupEnd() { - this.print("groupEnd", []); - } - shouldLog(o) { - const { logLevel: r } = this.options, i = ["debug", "info", "log", "warn", "error"]; - return i.indexOf(o) >= i.indexOf(r); - } -}; -__publicField(_Logger, "defaultOptions", { prefix: "remix-pwa", styles: { debug: { background: "#7f8c8d", color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" }, info: { background: "#3498db", color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" }, log: { background: "#2ecc71", color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" }, warn: { background: "#f39c12", color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" }, error: { background: "#c0392b", color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" }, groupCollapsed: { background: "#3498db", color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" }, groupEnd: { background: null, color: "white", "border-radius": "0.5em", "font-weight": "bold", padding: "2px 0.5em" } }, logLevel: "debug", isProductionEnv: false }); -let Logger = _Logger; -new Logger(); -function getAugmentedNamespace(n) { - if (n.__esModule) return n; - var f = n.default; - if (typeof f == "function") { - var a = function a2() { - if (this instanceof a2) { - return Reflect.construct(f, arguments, this.constructor); - } - return f.apply(this, arguments); - }; - a.prototype = f.prototype; - } else a = {}; - Object.defineProperty(a, "__esModule", { value: true }); - Object.keys(n).forEach(function(k) { - var d = Object.getOwnPropertyDescriptor(n, k); - Object.defineProperty(a, k, d.get ? d : { - enumerable: true, - get: function() { - return n[k]; - } - }); - }); - return a; -} -const logger = new Logger({ prefix: "[SW]" }); -self.addEventListener("install", (event) => { - logger.log("Service worker installed"); - event.waitUntil(self.skipWaiting()); -}); -self.addEventListener("activate", (event) => { - logger.log("Service worker activated"); - const cachesToKeep = []; - const clearUpAllLegacyCaches = async () => { - return caches.keys().then( - (keyList) => Promise.all( - keyList.map((key) => { - if (!cachesToKeep.includes(key)) { - return caches.delete(key); - } - }) - ) - ); - }; - const handler = async () => { - await clearUpAllLegacyCaches(); - await self.clients.claim(); - }; - event.waitUntil(handler()); -}); -const entryWorker = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$m = Object.getOwnPropertyNames; -var __commonJS$m = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$m(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$m = __commonJS$m({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$m = require_worker_runtime$m(); -const route0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$m -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$l = Object.getOwnPropertyNames; -var __commonJS$l = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$l(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$l = __commonJS$l({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$l = require_worker_runtime$l(); -const route1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$l -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$k = Object.getOwnPropertyNames; -var __commonJS$k = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$k(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$k = __commonJS$k({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$k = require_worker_runtime$k(); -const route2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$k -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$j = Object.getOwnPropertyNames; -var __commonJS$j = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$j(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$j = __commonJS$j({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$j = require_worker_runtime$j(); -const route3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$j -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$i = Object.getOwnPropertyNames; -var __commonJS$i = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$i(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$i = __commonJS$i({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$i = require_worker_runtime$i(); -const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$i -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$h = Object.getOwnPropertyNames; -var __commonJS$h = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$h(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$h = __commonJS$h({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$h = require_worker_runtime$h(); -const route5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$h -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$g = Object.getOwnPropertyNames; -var __commonJS$g = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$g(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$g = __commonJS$g({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$g = require_worker_runtime$g(); -const route6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$g -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$f = Object.getOwnPropertyNames; -var __commonJS$f = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$f(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$f = __commonJS$f({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$f = require_worker_runtime$f(); -const route7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$f -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$e = Object.getOwnPropertyNames; -var __commonJS$e = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$e(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$e = __commonJS$e({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$e = require_worker_runtime$e(); -const route8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$e -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$d = Object.getOwnPropertyNames; -var __commonJS$d = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$d(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$d = __commonJS$d({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$d = require_worker_runtime$d(); -const route9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$d -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$c = Object.getOwnPropertyNames; -var __commonJS$c = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$c(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$c = __commonJS$c({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$c = require_worker_runtime$c(); -const route10 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$c -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$b = Object.getOwnPropertyNames; -var __commonJS$b = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$b(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$b = __commonJS$b({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$b = require_worker_runtime$b(); -const route11 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$b -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$a = Object.getOwnPropertyNames; -var __commonJS$a = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$a(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$a = __commonJS$a({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$a = require_worker_runtime$a(); -const route12 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$a -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$9 = Object.getOwnPropertyNames; -var __commonJS$9 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$9(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$9 = __commonJS$9({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$9 = require_worker_runtime$9(); -const route13 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$9 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$8 = Object.getOwnPropertyNames; -var __commonJS$8 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$8(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$8 = __commonJS$8({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$8 = require_worker_runtime$8(); -const route14 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$8 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$7 = Object.getOwnPropertyNames; -var __commonJS$7 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$7(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$7 = __commonJS$7({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$7 = require_worker_runtime$7(); -const route15 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$7 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$6 = Object.getOwnPropertyNames; -var __commonJS$6 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$6(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$6 = __commonJS$6({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$6 = require_worker_runtime$6(); -const route16 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$6 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$5 = Object.getOwnPropertyNames; -var __commonJS$5 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$5(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$5 = __commonJS$5({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$5 = require_worker_runtime$5(); -const route17 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$5 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$4 = Object.getOwnPropertyNames; -var __commonJS$4 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$4(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$4 = __commonJS$4({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$4 = require_worker_runtime$4(); -const route18 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$4 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$3 = Object.getOwnPropertyNames; -var __commonJS$3 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$3 = __commonJS$3({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$3 = require_worker_runtime$3(); -const route19 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$3 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$2 = Object.getOwnPropertyNames; -var __commonJS$2 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$2 = __commonJS$2({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$2 = require_worker_runtime$2(); -const route20 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$2 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames$1 = Object.getOwnPropertyNames; -var __commonJS$1 = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames$1(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime$1 = __commonJS$1({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default$1 = require_worker_runtime$1(); -const route21 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default$1 -}, Symbol.toStringTag, { value: "Module" })); -var __getOwnPropNames = Object.getOwnPropertyNames; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var require_worker_runtime = __commonJS({ - "@remix-pwa/worker-runtime"(exports, module) { - module.exports = {}; - } -}); -var worker_runtime_default = require_worker_runtime(); -const route22 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: worker_runtime_default -}, Symbol.toStringTag, { value: "Module" })); -const assets = [ - "/browserconfig.xml", - "/entry.worker.js", - "/manifest.webmanifest", - "/robots.txt", - "/images/logo.jpeg", - "/news/crane-v2-0-light.webp", - "/news/crane-v2-0.webp", - "/news/crane-v2-1.webp", - "/news/crane-v2-2.webp", - "/news/crane-v2-3.webp", - "/fonts/Inter-Regular.ttf", - "/icons/apple-icon-180.png", - "/icons/apple-splash-1125-2436.jpg", - "/icons/apple-splash-1136-640.jpg", - "/icons/apple-splash-1170-2532.jpg", - "/icons/apple-splash-1179-2556.jpg", - "/icons/apple-splash-1242-2208.jpg", - "/icons/apple-splash-1242-2688.jpg", - "/icons/apple-splash-1284-2778.jpg", - "/icons/apple-splash-1290-2796.jpg", - "/icons/apple-splash-1334-750.jpg", - "/icons/apple-splash-1536-2048.jpg", - "/icons/apple-splash-1620-2160.jpg", - "/icons/apple-splash-1668-2224.jpg", - "/icons/apple-splash-1668-2388.jpg", - "/icons/apple-splash-1792-828.jpg", - "/icons/apple-splash-2048-1536.jpg", - "/icons/apple-splash-2048-2732.jpg", - "/icons/apple-splash-2160-1620.jpg", - "/icons/apple-splash-2208-1242.jpg", - "/icons/apple-splash-2224-1668.jpg", - "/icons/apple-splash-2388-1668.jpg", - "/icons/apple-splash-2436-1125.jpg", - "/icons/apple-splash-2532-1170.jpg", - "/icons/apple-splash-2556-1179.jpg", - "/icons/apple-splash-2688-1242.jpg", - "/icons/apple-splash-2732-2048.jpg", - "/icons/apple-splash-2778-1284.jpg", - "/icons/apple-splash-2796-1290.jpg", - "/icons/apple-splash-640-1136.jpg", - "/icons/apple-splash-750-1334.jpg", - "/icons/apple-splash-828-1792.jpg", - "/icons/favicon-16x16.png", - "/icons/favicon-32x32.png", - "/icons/favicon.ico", - "/icons/manifest-icon-192.maskable.png", - "/icons/manifest-icon-512.maskable.png", - "/icons/safari-pinned-tab.svg", - "/images/og/cover-1.jpg", - "/images/og/cover-2.jpg", - "/images/og/cover-3.jpg", - "/images/og/cover-4.jpg", - "/images/og/cover-5.jpg", - "/images/og/cover-6.jpg", - "/images/og/cover-7.jpg", - "/images/og/cover-8.jpg", - "/images/og/cover-9.jpg", - "/images/we/lukas.webp", - "/images/we/tom.webp", - "/images/screenshots/screenshot-portrait-0.jpg", - "/images/screenshots/screenshot-portrait-1.jpg", - "/images/screenshots/screenshot-portrait-2.jpg", - "/images/screenshots/screenshot-wide-0.jpg", - "/images/screenshots/screenshot-wide-1.jpg", - "/images/screenshots/screenshot-wide-2.jpg", - "/images/screenshots/screenshot-wide-3.jpg" -]; -const routes = { - "root": { - id: "root", - parentId: void 0, - path: "", - index: void 0, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route0 - }, - "routes/_page.press.news._article.$articleSlug.og._index": { - id: "routes/_page.press.news._article.$articleSlug.og._index", - parentId: "routes/_page.press.news._article", - path: ":articleSlug/og", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route1 - }, - "routes/_page.package.$packageId.og._index": { - id: "routes/_page.package.$packageId.og._index", - parentId: "routes/_page.package.$packageId", - path: "og", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route2 - }, - "routes/_page.press.news._article.crane-v2": { - id: "routes/_page.press.news._article.crane-v2", - parentId: "routes/_page.press.news._article", - path: "crane-v2", - index: void 0, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route3 - }, - "routes/_page.statistic.packages.downloads": { - id: "routes/_page.statistic.packages.downloads", - parentId: "routes/_page", - path: "statistic/packages/downloads", - index: void 0, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route4 - }, - "routes/_page.statistic.crane.page-visits": { - id: "routes/_page.statistic.crane.page-visits", - parentId: "routes/_page", - path: "statistic/crane/page-visits", - index: void 0, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route5 - }, - "routes/_page.author.$authorId.og._index": { - id: "routes/_page.author.$authorId.og._index", - parentId: "routes/_page.author.$authorId", - path: "og", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route6 - }, - "routes/_page.statistic.packages.trends": { - id: "routes/_page.statistic.packages.trends", - parentId: "routes/_page", - path: "statistic/packages/trends", - index: void 0, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route7 - }, - "routes/_page.press.news.og._index": { - id: "routes/_page.press.news.og._index", - parentId: "routes/_page", - path: "press/news/og", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route8 - }, - "routes/_page.press.news._article": { - id: "routes/_page.press.news._article", - parentId: "routes/_page", - path: "press/news", - index: void 0, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route9 - }, - "routes/_page.package.$packageId": { - id: "routes/_page.package.$packageId", - parentId: "routes/_page", - path: "package/:packageId", - index: void 0, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route10 - }, - "routes/_page.press.news._index": { - id: "routes/_page.press.news._index", - parentId: "routes/_page", - path: "press/news", - index: true, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route11 - }, - "routes/_page.author.$authorId": { - id: "routes/_page.author.$authorId", - parentId: "routes/_page", - path: "author/:authorId", - index: void 0, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route12 - }, - "routes/_page.statistic._index": { - id: "routes/_page.statistic._index", - parentId: "routes/_page", - path: "statistic", - index: true, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route13 - }, - "routes/_page.package._index": { - id: "routes/_page.package._index", - parentId: "routes/_page", - path: "package", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route14 - }, - "routes/_page.privacy._index": { - id: "routes/_page.privacy._index", - parentId: "routes/_page", - path: "privacy", - index: true, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route15 - }, - "routes/sitemap[.xml]._index": { - id: "routes/sitemap[.xml]._index", - parentId: "root", - path: "sitemap.xml", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route16 - }, - "routes/_page.author._index": { - id: "routes/_page.author._index", - parentId: "routes/_page", - path: "author", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route17 - }, - "routes/$slug[.xml]._index": { - id: "routes/$slug[.xml]._index", - parentId: "root", - path: ":slug.xml", - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route18 - }, - "routes/_page.about._index": { - id: "routes/_page.about._index", - parentId: "routes/_page", - path: "about", - index: true, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route19 - }, - "routes/api.search._index": { - id: "routes/api.search._index", - parentId: "root", - path: "api/search", - index: true, - caseSensitive: void 0, - hasLoader: false, - hasAction: true, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route20 - }, - "routes/_index": { - id: "routes/_index", - parentId: "root", - path: void 0, - index: true, - caseSensitive: void 0, - hasLoader: true, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route21 - }, - "routes/_page": { - id: "routes/_page", - parentId: "root", - path: void 0, - index: void 0, - caseSensitive: void 0, - hasLoader: false, - hasAction: false, - hasWorkerLoader: false, - hasWorkerAction: false, - module: route22 - } -}; -const entry = { module: entryWorker }; -/** - * @remix-run/router v1.20.0 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */ -function _extends() { - _extends = Object.assign ? Object.assign.bind() : function(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - return target; - }; - return _extends.apply(this, arguments); -} -var Action; -(function(Action2) { - Action2["Pop"] = "POP"; - Action2["Push"] = "PUSH"; - Action2["Replace"] = "REPLACE"; -})(Action || (Action = {})); -const PopStateEventType = "popstate"; -function createMemoryHistory(options) { - if (options === void 0) { - options = {}; - } - let { - initialEntries = ["/"], - initialIndex, - v5Compat = false - } = options; - let entries; - entries = initialEntries.map((entry2, index2) => createMemoryLocation(entry2, typeof entry2 === "string" ? null : entry2.state, index2 === 0 ? "default" : void 0)); - let index = clampIndex(initialIndex == null ? entries.length - 1 : initialIndex); - let action = Action.Pop; - let listener = null; - function clampIndex(n) { - return Math.min(Math.max(n, 0), entries.length - 1); - } - function getCurrentLocation() { - return entries[index]; - } - function createMemoryLocation(to, state, key) { - if (state === void 0) { - state = null; - } - let location = createLocation(entries ? getCurrentLocation().pathname : "/", to, state, key); - warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in memory history: " + JSON.stringify(to)); - return location; - } - function createHref(to) { - return typeof to === "string" ? to : createPath(to); - } - let history = { - get index() { - return index; - }, - get action() { - return action; - }, - get location() { - return getCurrentLocation(); - }, - createHref, - createURL(to) { - return new URL(createHref(to), "http://localhost"); - }, - encodeLocation(to) { - let path = typeof to === "string" ? parsePath(to) : to; - return { - pathname: path.pathname || "", - search: path.search || "", - hash: path.hash || "" - }; - }, - push(to, state) { - action = Action.Push; - let nextLocation = createMemoryLocation(to, state); - index += 1; - entries.splice(index, entries.length, nextLocation); - if (v5Compat && listener) { - listener({ - action, - location: nextLocation, - delta: 1 - }); - } - }, - replace(to, state) { - action = Action.Replace; - let nextLocation = createMemoryLocation(to, state); - entries[index] = nextLocation; - if (v5Compat && listener) { - listener({ - action, - location: nextLocation, - delta: 0 - }); - } - }, - go(delta) { - action = Action.Pop; - let nextIndex = clampIndex(index + delta); - let nextLocation = entries[nextIndex]; - index = nextIndex; - if (listener) { - listener({ - action, - location: nextLocation, - delta - }); - } - }, - listen(fn) { - listener = fn; - return () => { - listener = null; - }; - } - }; - return history; -} -function createBrowserHistory(options) { - if (options === void 0) { - options = {}; - } - function createBrowserLocation(window2, globalHistory) { - let { - pathname, - search, - hash - } = window2.location; - return createLocation( - "", - { - pathname, - search, - hash - }, - // state defaults to `null` because `window.history.state` does - globalHistory.state && globalHistory.state.usr || null, - globalHistory.state && globalHistory.state.key || "default" - ); - } - function createBrowserHref(window2, to) { - return typeof to === "string" ? to : createPath(to); - } - return getUrlBasedHistory(createBrowserLocation, createBrowserHref, null, options); -} -function createHashHistory(options) { - if (options === void 0) { - options = {}; - } - function createHashLocation(window2, globalHistory) { - let { - pathname = "/", - search = "", - hash = "" - } = parsePath(window2.location.hash.substr(1)); - if (!pathname.startsWith("/") && !pathname.startsWith(".")) { - pathname = "/" + pathname; - } - return createLocation( - "", - { - pathname, - search, - hash - }, - // state defaults to `null` because `window.history.state` does - globalHistory.state && globalHistory.state.usr || null, - globalHistory.state && globalHistory.state.key || "default" - ); - } - function createHashHref(window2, to) { - let base = window2.document.querySelector("base"); - let href = ""; - if (base && base.getAttribute("href")) { - let url = window2.location.href; - let hashIndex = url.indexOf("#"); - href = hashIndex === -1 ? url : url.slice(0, hashIndex); - } - return href + "#" + (typeof to === "string" ? to : createPath(to)); - } - function validateHashLocation(location, to) { - warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")"); - } - return getUrlBasedHistory(createHashLocation, createHashHref, validateHashLocation, options); -} -function invariant(value, message) { - if (value === false || value === null || typeof value === "undefined") { - throw new Error(message); - } -} -function warning(cond, message) { - if (!cond) { - if (typeof console !== "undefined") console.warn(message); - try { - throw new Error(message); - } catch (e) { - } - } -} -function createKey() { - return Math.random().toString(36).substr(2, 8); -} -function getHistoryState(location, index) { - return { - usr: location.state, - key: location.key, - idx: index - }; -} -function createLocation(current, to, state, key) { - if (state === void 0) { - state = null; - } - let location = _extends({ - pathname: typeof current === "string" ? current : current.pathname, - search: "", - hash: "" - }, typeof to === "string" ? parsePath(to) : to, { - state, - // TODO: This could be cleaned up. push/replace should probably just take - // full Locations now and avoid the need to run through this flow at all - // But that's a pretty big refactor to the current test suite so going to - // keep as is for the time being and just let any incoming keys take precedence - key: to && to.key || key || createKey() - }); - return location; -} -function createPath(_ref) { - let { - pathname = "/", - search = "", - hash = "" - } = _ref; - if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search; - if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash; - return pathname; -} -function parsePath(path) { - let parsedPath = {}; - if (path) { - let hashIndex = path.indexOf("#"); - if (hashIndex >= 0) { - parsedPath.hash = path.substr(hashIndex); - path = path.substr(0, hashIndex); - } - let searchIndex = path.indexOf("?"); - if (searchIndex >= 0) { - parsedPath.search = path.substr(searchIndex); - path = path.substr(0, searchIndex); - } - if (path) { - parsedPath.pathname = path; - } - } - return parsedPath; -} -function getUrlBasedHistory(getLocation, createHref, validateLocation, options) { - if (options === void 0) { - options = {}; - } - let { - window: window2 = document.defaultView, - v5Compat = false - } = options; - let globalHistory = window2.history; - let action = Action.Pop; - let listener = null; - let index = getIndex(); - if (index == null) { - index = 0; - globalHistory.replaceState(_extends({}, globalHistory.state, { - idx: index - }), ""); - } - function getIndex() { - let state = globalHistory.state || { - idx: null - }; - return state.idx; - } - function handlePop() { - action = Action.Pop; - let nextIndex = getIndex(); - let delta = nextIndex == null ? null : nextIndex - index; - index = nextIndex; - if (listener) { - listener({ - action, - location: history.location, - delta - }); - } - } - function push(to, state) { - action = Action.Push; - let location = createLocation(history.location, to, state); - if (validateLocation) validateLocation(location, to); - index = getIndex() + 1; - let historyState = getHistoryState(location, index); - let url = history.createHref(location); - try { - globalHistory.pushState(historyState, "", url); - } catch (error) { - if (error instanceof DOMException && error.name === "DataCloneError") { - throw error; - } - window2.location.assign(url); - } - if (v5Compat && listener) { - listener({ - action, - location: history.location, - delta: 1 - }); - } - } - function replace2(to, state) { - action = Action.Replace; - let location = createLocation(history.location, to, state); - if (validateLocation) validateLocation(location, to); - index = getIndex(); - let historyState = getHistoryState(location, index); - let url = history.createHref(location); - globalHistory.replaceState(historyState, "", url); - if (v5Compat && listener) { - listener({ - action, - location: history.location, - delta: 0 - }); - } - } - function createURL(to) { - let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href; - let href = typeof to === "string" ? to : createPath(to); - href = href.replace(/ $/, "%20"); - invariant(base, "No window.location.(origin|href) available to create URL for href: " + href); - return new URL(href, base); - } - let history = { - get action() { - return action; - }, - get location() { - return getLocation(window2, globalHistory); - }, - listen(fn) { - if (listener) { - throw new Error("A history only accepts one active listener"); - } - window2.addEventListener(PopStateEventType, handlePop); - listener = fn; - return () => { - window2.removeEventListener(PopStateEventType, handlePop); - listener = null; - }; - }, - createHref(to) { - return createHref(window2, to); - }, - createURL, - encodeLocation(to) { - let url = createURL(to); - return { - pathname: url.pathname, - search: url.search, - hash: url.hash - }; - }, - push, - replace: replace2, - go(n) { - return globalHistory.go(n); - } - }; - return history; -} -var ResultType; -(function(ResultType2) { - ResultType2["data"] = "data"; - ResultType2["deferred"] = "deferred"; - ResultType2["redirect"] = "redirect"; - ResultType2["error"] = "error"; -})(ResultType || (ResultType = {})); -const immutableRouteKeys = /* @__PURE__ */ new Set(["lazy", "caseSensitive", "path", "id", "index", "children"]); -function isIndexRoute(route) { - return route.index === true; -} -function convertRoutesToDataRoutes(routes2, mapRouteProperties, parentPath, manifest) { - if (parentPath === void 0) { - parentPath = []; - } - if (manifest === void 0) { - manifest = {}; - } - return routes2.map((route, index) => { - let treePath = [...parentPath, String(index)]; - let id = typeof route.id === "string" ? route.id : treePath.join("-"); - invariant(route.index !== true || !route.children, "Cannot specify children on an index route"); - invariant(!manifest[id], 'Found a route id collision on id "' + id + `". Route id's must be globally unique within Data Router usages`); - if (isIndexRoute(route)) { - let indexRoute = _extends({}, route, mapRouteProperties(route), { - id - }); - manifest[id] = indexRoute; - return indexRoute; - } else { - let pathOrLayoutRoute = _extends({}, route, mapRouteProperties(route), { - id, - children: void 0 - }); - manifest[id] = pathOrLayoutRoute; - if (route.children) { - pathOrLayoutRoute.children = convertRoutesToDataRoutes(route.children, mapRouteProperties, treePath, manifest); - } - return pathOrLayoutRoute; - } - }); -} -function matchRoutes(routes2, locationArg, basename) { - if (basename === void 0) { - basename = "/"; - } - return matchRoutesImpl(routes2, locationArg, basename, false); -} -function matchRoutesImpl(routes2, locationArg, basename, allowPartial) { - let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg; - let pathname = stripBasename(location.pathname || "/", basename); - if (pathname == null) { - return null; - } - let branches = flattenRoutes(routes2); - rankRouteBranches(branches); - let matches = null; - for (let i = 0; matches == null && i < branches.length; ++i) { - let decoded = decodePath(pathname); - matches = matchRouteBranch(branches[i], decoded, allowPartial); - } - return matches; -} -function convertRouteMatchToUiMatch(match, loaderData) { - let { - route, - pathname, - params - } = match; - return { - id: route.id, - pathname, - params, - data: loaderData[route.id], - handle: route.handle - }; -} -function flattenRoutes(routes2, branches, parentsMeta, parentPath) { - if (branches === void 0) { - branches = []; - } - if (parentsMeta === void 0) { - parentsMeta = []; - } - if (parentPath === void 0) { - parentPath = ""; - } - let flattenRoute = (route, index, relativePath) => { - let meta = { - relativePath: relativePath === void 0 ? route.path || "" : relativePath, - caseSensitive: route.caseSensitive === true, - childrenIndex: index, - route - }; - if (meta.relativePath.startsWith("/")) { - invariant(meta.relativePath.startsWith(parentPath), 'Absolute route path "' + meta.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes."); - meta.relativePath = meta.relativePath.slice(parentPath.length); - } - let path = joinPaths([parentPath, meta.relativePath]); - let routesMeta = parentsMeta.concat(meta); - if (route.children && route.children.length > 0) { - invariant( - // Our types know better, but runtime JS may not! - // @ts-expect-error - route.index !== true, - "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".') - ); - flattenRoutes(route.children, branches, routesMeta, path); - } - if (route.path == null && !route.index) { - return; - } - branches.push({ - path, - score: computeScore(path, route.index), - routesMeta - }); - }; - routes2.forEach((route, index) => { - var _route$path; - if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) { - flattenRoute(route, index); - } else { - for (let exploded of explodeOptionalSegments(route.path)) { - flattenRoute(route, index, exploded); - } - } - }); - return branches; -} -function explodeOptionalSegments(path) { - let segments = path.split("/"); - if (segments.length === 0) return []; - let [first, ...rest] = segments; - let isOptional = first.endsWith("?"); - let required = first.replace(/\?$/, ""); - if (rest.length === 0) { - return isOptional ? [required, ""] : [required]; - } - let restExploded = explodeOptionalSegments(rest.join("/")); - let result = []; - result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/"))); - if (isOptional) { - result.push(...restExploded); - } - return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded); -} -function rankRouteBranches(branches) { - branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex))); -} -const paramRe = /^:[\w-]+$/; -const dynamicSegmentValue = 3; -const indexRouteValue = 2; -const emptySegmentValue = 1; -const staticSegmentValue = 10; -const splatPenalty = -2; -const isSplat = (s) => s === "*"; -function computeScore(path, index) { - let segments = path.split("/"); - let initialScore = segments.length; - if (segments.some(isSplat)) { - initialScore += splatPenalty; - } - if (index) { - initialScore += indexRouteValue; - } - return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore); -} -function compareIndexes(a, b) { - let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]); - return siblings ? ( - // If two routes are siblings, we should try to match the earlier sibling - // first. This allows people to have fine-grained control over the matching - // behavior by simply putting routes with identical paths in the order they - // want them tried. - a[a.length - 1] - b[b.length - 1] - ) : ( - // Otherwise, it doesn't really make sense to rank non-siblings by index, - // so they sort equally. - 0 - ); -} -function matchRouteBranch(branch, pathname, allowPartial) { - if (allowPartial === void 0) { - allowPartial = false; - } - let { - routesMeta - } = branch; - let matchedParams = {}; - let matchedPathname = "/"; - let matches = []; - for (let i = 0; i < routesMeta.length; ++i) { - let meta = routesMeta[i]; - let end = i === routesMeta.length - 1; - let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/"; - let match = matchPath({ - path: meta.relativePath, - caseSensitive: meta.caseSensitive, - end - }, remainingPathname); - let route = meta.route; - if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) { - match = matchPath({ - path: meta.relativePath, - caseSensitive: meta.caseSensitive, - end: false - }, remainingPathname); - } - if (!match) { - return null; - } - Object.assign(matchedParams, match.params); - matches.push({ - // TODO: Can this as be avoided? - params: matchedParams, - pathname: joinPaths([matchedPathname, match.pathname]), - pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])), - route - }); - if (match.pathnameBase !== "/") { - matchedPathname = joinPaths([matchedPathname, match.pathnameBase]); - } - } - return matches; -} -function generatePath(originalPath, params) { - if (params === void 0) { - params = {}; - } - let path = originalPath; - if (path.endsWith("*") && path !== "*" && !path.endsWith("/*")) { - warning(false, 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".')); - path = path.replace(/\*$/, "/*"); - } - const prefix = path.startsWith("/") ? "/" : ""; - const stringify = (p) => p == null ? "" : typeof p === "string" ? p : String(p); - const segments = path.split(/\/+/).map((segment, index, array) => { - const isLastSegment = index === array.length - 1; - if (isLastSegment && segment === "*") { - const star = "*"; - return stringify(params[star]); - } - const keyMatch = segment.match(/^:([\w-]+)(\??)$/); - if (keyMatch) { - const [, key, optional] = keyMatch; - let param = params[key]; - invariant(optional === "?" || param != null, 'Missing ":' + key + '" param'); - return stringify(param); - } - return segment.replace(/\?$/g, ""); - }).filter((segment) => !!segment); - return prefix + segments.join("/"); -} -function matchPath(pattern, pathname) { - if (typeof pattern === "string") { - pattern = { - path: pattern, - caseSensitive: false, - end: true - }; - } - let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end); - let match = pathname.match(matcher); - if (!match) return null; - let matchedPathname = match[0]; - let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1"); - let captureGroups = match.slice(1); - let params = compiledParams.reduce((memo, _ref, index) => { - let { - paramName, - isOptional - } = _ref; - if (paramName === "*") { - let splatValue = captureGroups[index] || ""; - pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1"); - } - const value = captureGroups[index]; - if (isOptional && !value) { - memo[paramName] = void 0; - } else { - memo[paramName] = (value || "").replace(/%2F/g, "/"); - } - return memo; - }, {}); - return { - params, - pathname: matchedPathname, - pathnameBase, - pattern - }; -} -function compilePath(path, caseSensitive, end) { - if (caseSensitive === void 0) { - caseSensitive = false; - } - if (end === void 0) { - end = true; - } - warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".')); - let params = []; - let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => { - params.push({ - paramName, - isOptional: isOptional != null - }); - return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)"; - }); - if (path.endsWith("*")) { - params.push({ - paramName: "*" - }); - regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$"; - } else if (end) { - regexpSource += "\\/*$"; - } else if (path !== "" && path !== "/") { - regexpSource += "(?:(?=\\/|$))"; - } else ; - let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i"); - return [matcher, params]; -} -function decodePath(value) { - try { - return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/"); - } catch (error) { - warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ").")); - return value; - } -} -function stripBasename(pathname, basename) { - if (basename === "/") return pathname; - if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) { - return null; - } - let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length; - let nextChar = pathname.charAt(startIndex); - if (nextChar && nextChar !== "/") { - return null; - } - return pathname.slice(startIndex) || "/"; -} -function resolvePath(to, fromPathname) { - if (fromPathname === void 0) { - fromPathname = "/"; - } - let { - pathname: toPathname, - search = "", - hash = "" - } = typeof to === "string" ? parsePath(to) : to; - let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname; - return { - pathname, - search: normalizeSearch(search), - hash: normalizeHash(hash) - }; -} -function resolvePathname(relativePath, fromPathname) { - let segments = fromPathname.replace(/\/+$/, "").split("/"); - let relativeSegments = relativePath.split("/"); - relativeSegments.forEach((segment) => { - if (segment === "..") { - if (segments.length > 1) segments.pop(); - } else if (segment !== ".") { - segments.push(segment); - } - }); - return segments.length > 1 ? segments.join("/") : "/"; -} -function getInvalidPathError(char, field, dest, path) { - return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in and the router will parse it for you.'; -} -function getPathContributingMatches(matches) { - return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0); -} -function getResolveToMatches(matches, v7_relativeSplatPath) { - let pathMatches = getPathContributingMatches(matches); - if (v7_relativeSplatPath) { - return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase); - } - return pathMatches.map((match) => match.pathnameBase); -} -function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) { - if (isPathRelative === void 0) { - isPathRelative = false; - } - let to; - if (typeof toArg === "string") { - to = parsePath(toArg); - } else { - to = _extends({}, toArg); - invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to)); - invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to)); - invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to)); - } - let isEmptyPath = toArg === "" || to.pathname === ""; - let toPathname = isEmptyPath ? "/" : to.pathname; - let from; - if (toPathname == null) { - from = locationPathname; - } else { - let routePathnameIndex = routePathnames.length - 1; - if (!isPathRelative && toPathname.startsWith("..")) { - let toSegments = toPathname.split("/"); - while (toSegments[0] === "..") { - toSegments.shift(); - routePathnameIndex -= 1; - } - to.pathname = toSegments.join("/"); - } - from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/"; - } - let path = resolvePath(to, from); - let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/"); - let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/"); - if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) { - path.pathname += "/"; - } - return path; -} -function getToPathname(to) { - return to === "" || to.pathname === "" ? "/" : typeof to === "string" ? parsePath(to).pathname : to.pathname; -} -const joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/"); -const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/"); -const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search; -const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash; -const json$1 = function json(data2, init) { - if (init === void 0) { - init = {}; - } - let responseInit = typeof init === "number" ? { - status: init - } : init; - let headers = new Headers(responseInit.headers); - if (!headers.has("Content-Type")) { - headers.set("Content-Type", "application/json; charset=utf-8"); - } - return new Response(JSON.stringify(data2), _extends({}, responseInit, { - headers - })); -}; -class DataWithResponseInit { - constructor(data2, init) { - this.type = "DataWithResponseInit"; - this.data = data2; - this.init = init || null; - } -} -function data(data2, init) { - return new DataWithResponseInit(data2, typeof init === "number" ? { - status: init - } : init); -} -class AbortedDeferredError extends Error { -} -class DeferredData { - constructor(data2, responseInit) { - this.pendingKeysSet = /* @__PURE__ */ new Set(); - this.subscribers = /* @__PURE__ */ new Set(); - this.deferredKeys = []; - invariant(data2 && typeof data2 === "object" && !Array.isArray(data2), "defer() only accepts plain objects"); - let reject; - this.abortPromise = new Promise((_, r) => reject = r); - this.controller = new AbortController(); - let onAbort = () => reject(new AbortedDeferredError("Deferred data aborted")); - this.unlistenAbortSignal = () => this.controller.signal.removeEventListener("abort", onAbort); - this.controller.signal.addEventListener("abort", onAbort); - this.data = Object.entries(data2).reduce((acc, _ref2) => { - let [key, value] = _ref2; - return Object.assign(acc, { - [key]: this.trackPromise(key, value) - }); - }, {}); - if (this.done) { - this.unlistenAbortSignal(); - } - this.init = responseInit; - } - trackPromise(key, value) { - if (!(value instanceof Promise)) { - return value; - } - this.deferredKeys.push(key); - this.pendingKeysSet.add(key); - let promise = Promise.race([value, this.abortPromise]).then((data2) => this.onSettle(promise, key, void 0, data2), (error) => this.onSettle(promise, key, error)); - promise.catch(() => { - }); - Object.defineProperty(promise, "_tracked", { - get: () => true - }); - return promise; - } - onSettle(promise, key, error, data2) { - if (this.controller.signal.aborted && error instanceof AbortedDeferredError) { - this.unlistenAbortSignal(); - Object.defineProperty(promise, "_error", { - get: () => error - }); - return Promise.reject(error); - } - this.pendingKeysSet.delete(key); - if (this.done) { - this.unlistenAbortSignal(); - } - if (error === void 0 && data2 === void 0) { - let undefinedError = new Error('Deferred data for key "' + key + '" resolved/rejected with `undefined`, you must resolve/reject with a value or `null`.'); - Object.defineProperty(promise, "_error", { - get: () => undefinedError - }); - this.emit(false, key); - return Promise.reject(undefinedError); - } - if (data2 === void 0) { - Object.defineProperty(promise, "_error", { - get: () => error - }); - this.emit(false, key); - return Promise.reject(error); - } - Object.defineProperty(promise, "_data", { - get: () => data2 - }); - this.emit(false, key); - return data2; - } - emit(aborted, settledKey) { - this.subscribers.forEach((subscriber) => subscriber(aborted, settledKey)); - } - subscribe(fn) { - this.subscribers.add(fn); - return () => this.subscribers.delete(fn); - } - cancel() { - this.controller.abort(); - this.pendingKeysSet.forEach((v, k) => this.pendingKeysSet.delete(k)); - this.emit(true); - } - async resolveData(signal) { - let aborted = false; - if (!this.done) { - let onAbort = () => this.cancel(); - signal.addEventListener("abort", onAbort); - aborted = await new Promise((resolve) => { - this.subscribe((aborted2) => { - signal.removeEventListener("abort", onAbort); - if (aborted2 || this.done) { - resolve(aborted2); - } - }); - }); - } - return aborted; - } - get done() { - return this.pendingKeysSet.size === 0; - } - get unwrappedData() { - invariant(this.data !== null && this.done, "Can only unwrap data on initialized and settled deferreds"); - return Object.entries(this.data).reduce((acc, _ref3) => { - let [key, value] = _ref3; - return Object.assign(acc, { - [key]: unwrapTrackedPromise(value) - }); - }, {}); - } - get pendingKeys() { - return Array.from(this.pendingKeysSet); - } -} -function isTrackedPromise$1(value) { - return value instanceof Promise && value._tracked === true; -} -function unwrapTrackedPromise(value) { - if (!isTrackedPromise$1(value)) { - return value; - } - if (value._error) { - throw value._error; - } - return value._data; -} -const defer$1 = function defer(data2, init) { - if (init === void 0) { - init = {}; - } - let responseInit = typeof init === "number" ? { - status: init - } : init; - return new DeferredData(data2, responseInit); -}; -const redirect$1 = function redirect(url, init) { - if (init === void 0) { - init = 302; - } - let responseInit = init; - if (typeof responseInit === "number") { - responseInit = { - status: responseInit - }; - } else if (typeof responseInit.status === "undefined") { - responseInit.status = 302; - } - let headers = new Headers(responseInit.headers); - headers.set("Location", url); - return new Response(null, _extends({}, responseInit, { - headers - })); -}; -const redirectDocument$1 = (url, init) => { - let response = redirect$1(url, init); - response.headers.set("X-Remix-Reload-Document", "true"); - return response; -}; -const replace$1 = (url, init) => { - let response = redirect$1(url, init); - response.headers.set("X-Remix-Replace", "true"); - return response; -}; -class ErrorResponseImpl { - constructor(status, statusText, data2, internal) { - if (internal === void 0) { - internal = false; - } - this.status = status; - this.statusText = statusText || ""; - this.internal = internal; - if (data2 instanceof Error) { - this.data = data2.toString(); - this.error = data2; - } else { - this.data = data2; - } - } -} -function isRouteErrorResponse(error) { - return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error; -} -const validMutationMethodsArr = ["post", "put", "patch", "delete"]; -const validMutationMethods = new Set(validMutationMethodsArr); -const validRequestMethodsArr = ["get", ...validMutationMethodsArr]; -const validRequestMethods = new Set(validRequestMethodsArr); -const redirectStatusCodes$1 = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]); -const redirectPreserveMethodStatusCodes = /* @__PURE__ */ new Set([307, 308]); -const IDLE_NAVIGATION = { - state: "idle", - location: void 0, - formMethod: void 0, - formAction: void 0, - formEncType: void 0, - formData: void 0, - json: void 0, - text: void 0 -}; -const IDLE_FETCHER = { - state: "idle", - data: void 0, - formMethod: void 0, - formAction: void 0, - formEncType: void 0, - formData: void 0, - json: void 0, - text: void 0 -}; -const IDLE_BLOCKER = { - state: "unblocked", - proceed: void 0, - reset: void 0, - location: void 0 -}; -const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; -const defaultMapRouteProperties = (route) => ({ - hasErrorBoundary: Boolean(route.hasErrorBoundary) -}); -const TRANSITIONS_STORAGE_KEY = "remix-router-transitions"; -function createRouter(init) { - const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0; - const isBrowser = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined"; - const isServer = !isBrowser; - invariant(init.routes.length > 0, "You must provide a non-empty routes array to createRouter"); - let mapRouteProperties; - if (init.mapRouteProperties) { - mapRouteProperties = init.mapRouteProperties; - } else if (init.detectErrorBoundary) { - let detectErrorBoundary = init.detectErrorBoundary; - mapRouteProperties = (route) => ({ - hasErrorBoundary: detectErrorBoundary(route) - }); - } else { - mapRouteProperties = defaultMapRouteProperties; - } - let manifest = {}; - let dataRoutes = convertRoutesToDataRoutes(init.routes, mapRouteProperties, void 0, manifest); - let inFlightDataRoutes; - let basename = init.basename || "/"; - let dataStrategyImpl = init.dataStrategy || defaultDataStrategy; - let patchRoutesOnNavigationImpl = init.patchRoutesOnNavigation; - let future = _extends({ - v7_fetcherPersist: false, - v7_normalizeFormMethod: false, - v7_partialHydration: false, - v7_prependBasename: false, - v7_relativeSplatPath: false, - v7_skipActionErrorRevalidation: false - }, init.future); - let unlistenHistory = null; - let subscribers = /* @__PURE__ */ new Set(); - let savedScrollPositions = null; - let getScrollRestorationKey = null; - let getScrollPosition = null; - let initialScrollRestored = init.hydrationData != null; - let initialMatches = matchRoutes(dataRoutes, init.history.location, basename); - let initialErrors = null; - if (initialMatches == null && !patchRoutesOnNavigationImpl) { - let error = getInternalRouterError(404, { - pathname: init.history.location.pathname - }); - let { - matches, - route - } = getShortCircuitMatches(dataRoutes); - initialMatches = matches; - initialErrors = { - [route.id]: error - }; - } - if (initialMatches && !init.hydrationData) { - let fogOfWar = checkFogOfWar(initialMatches, dataRoutes, init.history.location.pathname); - if (fogOfWar.active) { - initialMatches = null; - } - } - let initialized; - if (!initialMatches) { - initialized = false; - initialMatches = []; - if (future.v7_partialHydration) { - let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname); - if (fogOfWar.active && fogOfWar.matches) { - initialMatches = fogOfWar.matches; - } - } - } else if (initialMatches.some((m) => m.route.lazy)) { - initialized = false; - } else if (!initialMatches.some((m) => m.route.loader)) { - initialized = true; - } else if (future.v7_partialHydration) { - let loaderData = init.hydrationData ? init.hydrationData.loaderData : null; - let errors2 = init.hydrationData ? init.hydrationData.errors : null; - if (errors2) { - let idx = initialMatches.findIndex((m) => errors2[m.route.id] !== void 0); - initialized = initialMatches.slice(0, idx + 1).every((m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors2)); - } else { - initialized = initialMatches.every((m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors2)); - } - } else { - initialized = init.hydrationData != null; - } - let router2; - let state = { - historyAction: init.history.action, - location: init.history.location, - matches: initialMatches, - initialized, - navigation: IDLE_NAVIGATION, - // Don't restore on initial updateState() if we were SSR'd - restoreScrollPosition: init.hydrationData != null ? false : null, - preventScrollReset: false, - revalidation: "idle", - loaderData: init.hydrationData && init.hydrationData.loaderData || {}, - actionData: init.hydrationData && init.hydrationData.actionData || null, - errors: init.hydrationData && init.hydrationData.errors || initialErrors, - fetchers: /* @__PURE__ */ new Map(), - blockers: /* @__PURE__ */ new Map() - }; - let pendingAction = Action.Pop; - let pendingPreventScrollReset = false; - let pendingNavigationController; - let pendingViewTransitionEnabled = false; - let appliedViewTransitions = /* @__PURE__ */ new Map(); - let removePageHideEventListener = null; - let isUninterruptedRevalidation = false; - let isRevalidationRequired = false; - let cancelledDeferredRoutes = []; - let cancelledFetcherLoads = /* @__PURE__ */ new Set(); - let fetchControllers = /* @__PURE__ */ new Map(); - let incrementingLoadId = 0; - let pendingNavigationLoadId = -1; - let fetchReloadIds = /* @__PURE__ */ new Map(); - let fetchRedirectIds = /* @__PURE__ */ new Set(); - let fetchLoadMatches = /* @__PURE__ */ new Map(); - let activeFetchers = /* @__PURE__ */ new Map(); - let deletedFetchers = /* @__PURE__ */ new Set(); - let activeDeferreds = /* @__PURE__ */ new Map(); - let blockerFunctions = /* @__PURE__ */ new Map(); - let unblockBlockerHistoryUpdate = void 0; - function initialize() { - unlistenHistory = init.history.listen((_ref) => { - let { - action: historyAction, - location, - delta - } = _ref; - if (unblockBlockerHistoryUpdate) { - unblockBlockerHistoryUpdate(); - unblockBlockerHistoryUpdate = void 0; - return; - } - warning(blockerFunctions.size === 0 || delta != null, "You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL."); - let blockerKey = shouldBlockNavigation({ - currentLocation: state.location, - nextLocation: location, - historyAction - }); - if (blockerKey && delta != null) { - let nextHistoryUpdatePromise = new Promise((resolve) => { - unblockBlockerHistoryUpdate = resolve; - }); - init.history.go(delta * -1); - updateBlocker(blockerKey, { - state: "blocked", - location, - proceed() { - updateBlocker(blockerKey, { - state: "proceeding", - proceed: void 0, - reset: void 0, - location - }); - nextHistoryUpdatePromise.then(() => init.history.go(delta)); - }, - reset() { - let blockers = new Map(state.blockers); - blockers.set(blockerKey, IDLE_BLOCKER); - updateState({ - blockers - }); - } - }); - return; - } - return startNavigation(historyAction, location); - }); - if (isBrowser) { - restoreAppliedTransitions(routerWindow, appliedViewTransitions); - let _saveAppliedTransitions = () => persistAppliedTransitions(routerWindow, appliedViewTransitions); - routerWindow.addEventListener("pagehide", _saveAppliedTransitions); - removePageHideEventListener = () => routerWindow.removeEventListener("pagehide", _saveAppliedTransitions); - } - if (!state.initialized) { - startNavigation(Action.Pop, state.location, { - initialHydration: true - }); - } - return router2; - } - function dispose() { - if (unlistenHistory) { - unlistenHistory(); - } - if (removePageHideEventListener) { - removePageHideEventListener(); - } - subscribers.clear(); - pendingNavigationController && pendingNavigationController.abort(); - state.fetchers.forEach((_, key) => deleteFetcher(key)); - state.blockers.forEach((_, key) => deleteBlocker(key)); - } - function subscribe(fn) { - subscribers.add(fn); - return () => subscribers.delete(fn); - } - function updateState(newState, opts) { - if (opts === void 0) { - opts = {}; - } - state = _extends({}, state, newState); - let completedFetchers = []; - let deletedFetchersKeys = []; - if (future.v7_fetcherPersist) { - state.fetchers.forEach((fetcher, key) => { - if (fetcher.state === "idle") { - if (deletedFetchers.has(key)) { - deletedFetchersKeys.push(key); - } else { - completedFetchers.push(key); - } - } - }); - } - [...subscribers].forEach((subscriber) => subscriber(state, { - deletedFetchers: deletedFetchersKeys, - viewTransitionOpts: opts.viewTransitionOpts, - flushSync: opts.flushSync === true - })); - if (future.v7_fetcherPersist) { - completedFetchers.forEach((key) => state.fetchers.delete(key)); - deletedFetchersKeys.forEach((key) => deleteFetcher(key)); - } - } - function completeNavigation(location, newState, _temp) { - var _location$state, _location$state2; - let { - flushSync - } = _temp === void 0 ? {} : _temp; - let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && ((_location$state = location.state) == null ? void 0 : _location$state._isRedirect) !== true; - let actionData; - if (newState.actionData) { - if (Object.keys(newState.actionData).length > 0) { - actionData = newState.actionData; - } else { - actionData = null; - } - } else if (isActionReload) { - actionData = state.actionData; - } else { - actionData = null; - } - let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData; - let blockers = state.blockers; - if (blockers.size > 0) { - blockers = new Map(blockers); - blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER)); - } - let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true; - if (inFlightDataRoutes) { - dataRoutes = inFlightDataRoutes; - inFlightDataRoutes = void 0; - } - if (isUninterruptedRevalidation) ; - else if (pendingAction === Action.Pop) ; - else if (pendingAction === Action.Push) { - init.history.push(location, location.state); - } else if (pendingAction === Action.Replace) { - init.history.replace(location, location.state); - } - let viewTransitionOpts; - if (pendingAction === Action.Pop) { - let priorPaths = appliedViewTransitions.get(state.location.pathname); - if (priorPaths && priorPaths.has(location.pathname)) { - viewTransitionOpts = { - currentLocation: state.location, - nextLocation: location - }; - } else if (appliedViewTransitions.has(location.pathname)) { - viewTransitionOpts = { - currentLocation: location, - nextLocation: state.location - }; - } - } else if (pendingViewTransitionEnabled) { - let toPaths = appliedViewTransitions.get(state.location.pathname); - if (toPaths) { - toPaths.add(location.pathname); - } else { - toPaths = /* @__PURE__ */ new Set([location.pathname]); - appliedViewTransitions.set(state.location.pathname, toPaths); - } - viewTransitionOpts = { - currentLocation: state.location, - nextLocation: location - }; - } - updateState(_extends({}, newState, { - actionData, - loaderData, - historyAction: pendingAction, - location, - initialized: true, - navigation: IDLE_NAVIGATION, - revalidation: "idle", - restoreScrollPosition: getSavedScrollPosition(location, newState.matches || state.matches), - preventScrollReset, - blockers - }), { - viewTransitionOpts, - flushSync: flushSync === true - }); - pendingAction = Action.Pop; - pendingPreventScrollReset = false; - pendingViewTransitionEnabled = false; - isUninterruptedRevalidation = false; - isRevalidationRequired = false; - cancelledDeferredRoutes = []; - } - async function navigate(to, opts) { - if (typeof to === "number") { - init.history.go(to); - return; - } - let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, to, future.v7_relativeSplatPath, opts == null ? void 0 : opts.fromRouteId, opts == null ? void 0 : opts.relative); - let { - path, - submission, - error - } = normalizeNavigateOptions(future.v7_normalizeFormMethod, false, normalizedPath, opts); - let currentLocation = state.location; - let nextLocation = createLocation(state.location, path, opts && opts.state); - nextLocation = _extends({}, nextLocation, init.history.encodeLocation(nextLocation)); - let userReplace = opts && opts.replace != null ? opts.replace : void 0; - let historyAction = Action.Push; - if (userReplace === true) { - historyAction = Action.Replace; - } else if (userReplace === false) ; - else if (submission != null && isMutationMethod(submission.formMethod) && submission.formAction === state.location.pathname + state.location.search) { - historyAction = Action.Replace; - } - let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : void 0; - let flushSync = (opts && opts.flushSync) === true; - let blockerKey = shouldBlockNavigation({ - currentLocation, - nextLocation, - historyAction - }); - if (blockerKey) { - updateBlocker(blockerKey, { - state: "blocked", - location: nextLocation, - proceed() { - updateBlocker(blockerKey, { - state: "proceeding", - proceed: void 0, - reset: void 0, - location: nextLocation - }); - navigate(to, opts); - }, - reset() { - let blockers = new Map(state.blockers); - blockers.set(blockerKey, IDLE_BLOCKER); - updateState({ - blockers - }); - } - }); - return; - } - return await startNavigation(historyAction, nextLocation, { - submission, - // Send through the formData serialization error if we have one so we can - // render at the right error boundary after we match routes - pendingError: error, - preventScrollReset, - replace: opts && opts.replace, - enableViewTransition: opts && opts.viewTransition, - flushSync - }); - } - function revalidate() { - interruptActiveLoads(); - updateState({ - revalidation: "loading" - }); - if (state.navigation.state === "submitting") { - return; - } - if (state.navigation.state === "idle") { - startNavigation(state.historyAction, state.location, { - startUninterruptedRevalidation: true - }); - return; - } - startNavigation(pendingAction || state.historyAction, state.navigation.location, { - overrideNavigation: state.navigation, - // Proxy through any rending view transition - enableViewTransition: pendingViewTransitionEnabled === true - }); - } - async function startNavigation(historyAction, location, opts) { - pendingNavigationController && pendingNavigationController.abort(); - pendingNavigationController = null; - pendingAction = historyAction; - isUninterruptedRevalidation = (opts && opts.startUninterruptedRevalidation) === true; - saveScrollPosition(state.location, state.matches); - pendingPreventScrollReset = (opts && opts.preventScrollReset) === true; - pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true; - let routesToUse = inFlightDataRoutes || dataRoutes; - let loadingNavigation = opts && opts.overrideNavigation; - let matches = matchRoutes(routesToUse, location, basename); - let flushSync = (opts && opts.flushSync) === true; - let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname); - if (fogOfWar.active && fogOfWar.matches) { - matches = fogOfWar.matches; - } - if (!matches) { - let { - error, - notFoundMatches, - route - } = handleNavigational404(location.pathname); - completeNavigation(location, { - matches: notFoundMatches, - loaderData: {}, - errors: { - [route.id]: error - } - }, { - flushSync - }); - return; - } - if (state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) { - completeNavigation(location, { - matches - }, { - flushSync - }); - return; - } - pendingNavigationController = new AbortController(); - let request = createClientSideRequest(init.history, location, pendingNavigationController.signal, opts && opts.submission); - let pendingActionResult; - if (opts && opts.pendingError) { - pendingActionResult = [findNearestBoundary(matches).route.id, { - type: ResultType.error, - error: opts.pendingError - }]; - } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) { - let actionResult = await handleAction2(request, location, opts.submission, matches, fogOfWar.active, { - replace: opts.replace, - flushSync - }); - if (actionResult.shortCircuited) { - return; - } - if (actionResult.pendingActionResult) { - let [routeId, result] = actionResult.pendingActionResult; - if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) { - pendingNavigationController = null; - completeNavigation(location, { - matches: actionResult.matches, - loaderData: {}, - errors: { - [routeId]: result.error - } - }); - return; - } - } - matches = actionResult.matches || matches; - pendingActionResult = actionResult.pendingActionResult; - loadingNavigation = getLoadingNavigation(location, opts.submission); - flushSync = false; - fogOfWar.active = false; - request = createClientSideRequest(init.history, request.url, request.signal); - } - let { - shortCircuited, - matches: updatedMatches, - loaderData, - errors: errors2 - } = await handleLoaders(request, location, matches, fogOfWar.active, loadingNavigation, opts && opts.submission, opts && opts.fetcherSubmission, opts && opts.replace, opts && opts.initialHydration === true, flushSync, pendingActionResult); - if (shortCircuited) { - return; - } - pendingNavigationController = null; - completeNavigation(location, _extends({ - matches: updatedMatches || matches - }, getActionDataForCommit(pendingActionResult), { - loaderData, - errors: errors2 - })); - } - async function handleAction2(request, location, submission, matches, isFogOfWar, opts) { - if (opts === void 0) { - opts = {}; - } - interruptActiveLoads(); - let navigation = getSubmittingNavigation(location, submission); - updateState({ - navigation - }, { - flushSync: opts.flushSync === true - }); - if (isFogOfWar) { - let discoverResult = await discoverRoutes(matches, location.pathname, request.signal); - if (discoverResult.type === "aborted") { - return { - shortCircuited: true - }; - } else if (discoverResult.type === "error") { - let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id; - return { - matches: discoverResult.partialMatches, - pendingActionResult: [boundaryId, { - type: ResultType.error, - error: discoverResult.error - }] - }; - } else if (!discoverResult.matches) { - let { - notFoundMatches, - error, - route - } = handleNavigational404(location.pathname); - return { - matches: notFoundMatches, - pendingActionResult: [route.id, { - type: ResultType.error, - error - }] - }; - } else { - matches = discoverResult.matches; - } - } - let result; - let actionMatch = getTargetMatch(matches, location); - if (!actionMatch.route.action && !actionMatch.route.lazy) { - result = { - type: ResultType.error, - error: getInternalRouterError(405, { - method: request.method, - pathname: location.pathname, - routeId: actionMatch.route.id - }) - }; - } else { - let results = await callDataStrategy("action", state, request, [actionMatch], matches, null); - result = results[actionMatch.route.id]; - if (request.signal.aborted) { - return { - shortCircuited: true - }; - } - } - if (isRedirectResult(result)) { - let replace2; - if (opts && opts.replace != null) { - replace2 = opts.replace; - } else { - let location2 = normalizeRedirectLocation(result.response.headers.get("Location"), new URL(request.url), basename); - replace2 = location2 === state.location.pathname + state.location.search; - } - await startRedirectNavigation(request, result, true, { - submission, - replace: replace2 - }); - return { - shortCircuited: true - }; - } - if (isDeferredResult(result)) { - throw getInternalRouterError(400, { - type: "defer-action" - }); - } - if (isErrorResult(result)) { - let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id); - if ((opts && opts.replace) !== true) { - pendingAction = Action.Push; - } - return { - matches, - pendingActionResult: [boundaryMatch.route.id, result] - }; - } - return { - matches, - pendingActionResult: [actionMatch.route.id, result] - }; - } - async function handleLoaders(request, location, matches, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) { - let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission); - let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation); - let shouldUpdateNavigationState = !isUninterruptedRevalidation && (!future.v7_partialHydration || !initialHydration); - if (isFogOfWar) { - if (shouldUpdateNavigationState) { - let actionData = getUpdatedActionData(pendingActionResult); - updateState(_extends({ - navigation: loadingNavigation - }, actionData !== void 0 ? { - actionData - } : {}), { - flushSync - }); - } - let discoverResult = await discoverRoutes(matches, location.pathname, request.signal); - if (discoverResult.type === "aborted") { - return { - shortCircuited: true - }; - } else if (discoverResult.type === "error") { - let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id; - return { - matches: discoverResult.partialMatches, - loaderData: {}, - errors: { - [boundaryId]: discoverResult.error - } - }; - } else if (!discoverResult.matches) { - let { - error, - notFoundMatches, - route - } = handleNavigational404(location.pathname); - return { - matches: notFoundMatches, - loaderData: {}, - errors: { - [route.id]: error - } - }; - } else { - matches = discoverResult.matches; - } - } - let routesToUse = inFlightDataRoutes || dataRoutes; - let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult); - cancelActiveDeferreds((routeId) => !(matches && matches.some((m) => m.route.id === routeId)) || matchesToLoad && matchesToLoad.some((m) => m.route.id === routeId)); - pendingNavigationLoadId = ++incrementingLoadId; - if (matchesToLoad.length === 0 && revalidatingFetchers.length === 0) { - let updatedFetchers2 = markFetchRedirectsDone(); - completeNavigation(location, _extends({ - matches, - loaderData: {}, - // Commit pending error if we're short circuiting - errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? { - [pendingActionResult[0]]: pendingActionResult[1].error - } : null - }, getActionDataForCommit(pendingActionResult), updatedFetchers2 ? { - fetchers: new Map(state.fetchers) - } : {}), { - flushSync - }); - return { - shortCircuited: true - }; - } - if (shouldUpdateNavigationState) { - let updates = {}; - if (!isFogOfWar) { - updates.navigation = loadingNavigation; - let actionData = getUpdatedActionData(pendingActionResult); - if (actionData !== void 0) { - updates.actionData = actionData; - } - } - if (revalidatingFetchers.length > 0) { - updates.fetchers = getUpdatedRevalidatingFetchers(revalidatingFetchers); - } - updateState(updates, { - flushSync - }); - } - revalidatingFetchers.forEach((rf) => { - abortFetcher(rf.key); - if (rf.controller) { - fetchControllers.set(rf.key, rf.controller); - } - }); - let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((f) => abortFetcher(f.key)); - if (pendingNavigationController) { - pendingNavigationController.signal.addEventListener("abort", abortPendingFetchRevalidations); - } - let { - loaderResults, - fetcherResults - } = await callLoadersAndMaybeResolveData(state, matches, matchesToLoad, revalidatingFetchers, request); - if (request.signal.aborted) { - return { - shortCircuited: true - }; - } - if (pendingNavigationController) { - pendingNavigationController.signal.removeEventListener("abort", abortPendingFetchRevalidations); - } - revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key)); - let redirect3 = findRedirect(loaderResults); - if (redirect3) { - await startRedirectNavigation(request, redirect3.result, true, { - replace: replace2 - }); - return { - shortCircuited: true - }; - } - redirect3 = findRedirect(fetcherResults); - if (redirect3) { - fetchRedirectIds.add(redirect3.key); - await startRedirectNavigation(request, redirect3.result, true, { - replace: replace2 - }); - return { - shortCircuited: true - }; - } - let { - loaderData, - errors: errors2 - } = processLoaderData(state, matches, loaderResults, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds); - activeDeferreds.forEach((deferredData, routeId) => { - deferredData.subscribe((aborted) => { - if (aborted || deferredData.done) { - activeDeferreds.delete(routeId); - } - }); - }); - if (future.v7_partialHydration && initialHydration && state.errors) { - errors2 = _extends({}, state.errors, errors2); - } - let updatedFetchers = markFetchRedirectsDone(); - let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId); - let shouldUpdateFetchers = updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0; - return _extends({ - matches, - loaderData, - errors: errors2 - }, shouldUpdateFetchers ? { - fetchers: new Map(state.fetchers) - } : {}); - } - function getUpdatedActionData(pendingActionResult) { - if (pendingActionResult && !isErrorResult(pendingActionResult[1])) { - return { - [pendingActionResult[0]]: pendingActionResult[1].data - }; - } else if (state.actionData) { - if (Object.keys(state.actionData).length === 0) { - return null; - } else { - return state.actionData; - } - } - } - function getUpdatedRevalidatingFetchers(revalidatingFetchers) { - revalidatingFetchers.forEach((rf) => { - let fetcher = state.fetchers.get(rf.key); - let revalidatingFetcher = getLoadingFetcher(void 0, fetcher ? fetcher.data : void 0); - state.fetchers.set(rf.key, revalidatingFetcher); - }); - return new Map(state.fetchers); - } - function fetch2(key, routeId, href, opts) { - if (isServer) { - throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback."); - } - abortFetcher(key); - let flushSync = (opts && opts.flushSync) === true; - let routesToUse = inFlightDataRoutes || dataRoutes; - let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, future.v7_relativeSplatPath, routeId, opts == null ? void 0 : opts.relative); - let matches = matchRoutes(routesToUse, normalizedPath, basename); - let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath); - if (fogOfWar.active && fogOfWar.matches) { - matches = fogOfWar.matches; - } - if (!matches) { - setFetcherError(key, routeId, getInternalRouterError(404, { - pathname: normalizedPath - }), { - flushSync - }); - return; - } - let { - path, - submission, - error - } = normalizeNavigateOptions(future.v7_normalizeFormMethod, true, normalizedPath, opts); - if (error) { - setFetcherError(key, routeId, error, { - flushSync - }); - return; - } - let match = getTargetMatch(matches, path); - let preventScrollReset = (opts && opts.preventScrollReset) === true; - if (submission && isMutationMethod(submission.formMethod)) { - handleFetcherAction(key, routeId, path, match, matches, fogOfWar.active, flushSync, preventScrollReset, submission); - return; - } - fetchLoadMatches.set(key, { - routeId, - path - }); - handleFetcherLoader(key, routeId, path, match, matches, fogOfWar.active, flushSync, preventScrollReset, submission); - } - async function handleFetcherAction(key, routeId, path, match, requestMatches, isFogOfWar, flushSync, preventScrollReset, submission) { - interruptActiveLoads(); - fetchLoadMatches.delete(key); - function detectAndHandle405Error(m) { - if (!m.route.action && !m.route.lazy) { - let error = getInternalRouterError(405, { - method: submission.formMethod, - pathname: path, - routeId - }); - setFetcherError(key, routeId, error, { - flushSync - }); - return true; - } - return false; - } - if (!isFogOfWar && detectAndHandle405Error(match)) { - return; - } - let existingFetcher = state.fetchers.get(key); - updateFetcherState(key, getSubmittingFetcher(submission, existingFetcher), { - flushSync - }); - let abortController = new AbortController(); - let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission); - if (isFogOfWar) { - let discoverResult = await discoverRoutes(requestMatches, path, fetchRequest.signal); - if (discoverResult.type === "aborted") { - return; - } else if (discoverResult.type === "error") { - setFetcherError(key, routeId, discoverResult.error, { - flushSync - }); - return; - } else if (!discoverResult.matches) { - setFetcherError(key, routeId, getInternalRouterError(404, { - pathname: path - }), { - flushSync - }); - return; - } else { - requestMatches = discoverResult.matches; - match = getTargetMatch(requestMatches, path); - if (detectAndHandle405Error(match)) { - return; - } - } - } - fetchControllers.set(key, abortController); - let originatingLoadId = incrementingLoadId; - let actionResults = await callDataStrategy("action", state, fetchRequest, [match], requestMatches, key); - let actionResult = actionResults[match.route.id]; - if (fetchRequest.signal.aborted) { - if (fetchControllers.get(key) === abortController) { - fetchControllers.delete(key); - } - return; - } - if (future.v7_fetcherPersist && deletedFetchers.has(key)) { - if (isRedirectResult(actionResult) || isErrorResult(actionResult)) { - updateFetcherState(key, getDoneFetcher(void 0)); - return; - } - } else { - if (isRedirectResult(actionResult)) { - fetchControllers.delete(key); - if (pendingNavigationLoadId > originatingLoadId) { - updateFetcherState(key, getDoneFetcher(void 0)); - return; - } else { - fetchRedirectIds.add(key); - updateFetcherState(key, getLoadingFetcher(submission)); - return startRedirectNavigation(fetchRequest, actionResult, false, { - fetcherSubmission: submission, - preventScrollReset - }); - } - } - if (isErrorResult(actionResult)) { - setFetcherError(key, routeId, actionResult.error); - return; - } - } - if (isDeferredResult(actionResult)) { - throw getInternalRouterError(400, { - type: "defer-action" - }); - } - let nextLocation = state.navigation.location || state.location; - let revalidationRequest = createClientSideRequest(init.history, nextLocation, abortController.signal); - let routesToUse = inFlightDataRoutes || dataRoutes; - let matches = state.navigation.state !== "idle" ? matchRoutes(routesToUse, state.navigation.location, basename) : state.matches; - invariant(matches, "Didn't find any matches after fetcher action"); - let loadId = ++incrementingLoadId; - fetchReloadIds.set(key, loadId); - let loadFetcher = getLoadingFetcher(submission, actionResult.data); - state.fetchers.set(key, loadFetcher); - let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, false, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, [match.route.id, actionResult]); - revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => { - let staleKey = rf.key; - let existingFetcher2 = state.fetchers.get(staleKey); - let revalidatingFetcher = getLoadingFetcher(void 0, existingFetcher2 ? existingFetcher2.data : void 0); - state.fetchers.set(staleKey, revalidatingFetcher); - abortFetcher(staleKey); - if (rf.controller) { - fetchControllers.set(staleKey, rf.controller); - } - }); - updateState({ - fetchers: new Map(state.fetchers) - }); - let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => abortFetcher(rf.key)); - abortController.signal.addEventListener("abort", abortPendingFetchRevalidations); - let { - loaderResults, - fetcherResults - } = await callLoadersAndMaybeResolveData(state, matches, matchesToLoad, revalidatingFetchers, revalidationRequest); - if (abortController.signal.aborted) { - return; - } - abortController.signal.removeEventListener("abort", abortPendingFetchRevalidations); - fetchReloadIds.delete(key); - fetchControllers.delete(key); - revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key)); - let redirect3 = findRedirect(loaderResults); - if (redirect3) { - return startRedirectNavigation(revalidationRequest, redirect3.result, false, { - preventScrollReset - }); - } - redirect3 = findRedirect(fetcherResults); - if (redirect3) { - fetchRedirectIds.add(redirect3.key); - return startRedirectNavigation(revalidationRequest, redirect3.result, false, { - preventScrollReset - }); - } - let { - loaderData, - errors: errors2 - } = processLoaderData(state, matches, loaderResults, void 0, revalidatingFetchers, fetcherResults, activeDeferreds); - if (state.fetchers.has(key)) { - let doneFetcher = getDoneFetcher(actionResult.data); - state.fetchers.set(key, doneFetcher); - } - abortStaleFetchLoads(loadId); - if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) { - invariant(pendingAction, "Expected pending action"); - pendingNavigationController && pendingNavigationController.abort(); - completeNavigation(state.navigation.location, { - matches, - loaderData, - errors: errors2, - fetchers: new Map(state.fetchers) - }); - } else { - updateState({ - errors: errors2, - loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors2), - fetchers: new Map(state.fetchers) - }); - isRevalidationRequired = false; - } - } - async function handleFetcherLoader(key, routeId, path, match, matches, isFogOfWar, flushSync, preventScrollReset, submission) { - let existingFetcher = state.fetchers.get(key); - updateFetcherState(key, getLoadingFetcher(submission, existingFetcher ? existingFetcher.data : void 0), { - flushSync - }); - let abortController = new AbortController(); - let fetchRequest = createClientSideRequest(init.history, path, abortController.signal); - if (isFogOfWar) { - let discoverResult = await discoverRoutes(matches, path, fetchRequest.signal); - if (discoverResult.type === "aborted") { - return; - } else if (discoverResult.type === "error") { - setFetcherError(key, routeId, discoverResult.error, { - flushSync - }); - return; - } else if (!discoverResult.matches) { - setFetcherError(key, routeId, getInternalRouterError(404, { - pathname: path - }), { - flushSync - }); - return; - } else { - matches = discoverResult.matches; - match = getTargetMatch(matches, path); - } - } - fetchControllers.set(key, abortController); - let originatingLoadId = incrementingLoadId; - let results = await callDataStrategy("loader", state, fetchRequest, [match], matches, key); - let result = results[match.route.id]; - if (isDeferredResult(result)) { - result = await resolveDeferredData(result, fetchRequest.signal, true) || result; - } - if (fetchControllers.get(key) === abortController) { - fetchControllers.delete(key); - } - if (fetchRequest.signal.aborted) { - return; - } - if (deletedFetchers.has(key)) { - updateFetcherState(key, getDoneFetcher(void 0)); - return; - } - if (isRedirectResult(result)) { - if (pendingNavigationLoadId > originatingLoadId) { - updateFetcherState(key, getDoneFetcher(void 0)); - return; - } else { - fetchRedirectIds.add(key); - await startRedirectNavigation(fetchRequest, result, false, { - preventScrollReset - }); - return; - } - } - if (isErrorResult(result)) { - setFetcherError(key, routeId, result.error); - return; - } - invariant(!isDeferredResult(result), "Unhandled fetcher deferred data"); - updateFetcherState(key, getDoneFetcher(result.data)); - } - async function startRedirectNavigation(request, redirect3, isNavigation, _temp2) { - let { - submission, - fetcherSubmission, - preventScrollReset, - replace: replace2 - } = _temp2 === void 0 ? {} : _temp2; - if (redirect3.response.headers.has("X-Remix-Revalidate")) { - isRevalidationRequired = true; - } - let location = redirect3.response.headers.get("Location"); - invariant(location, "Expected a Location header on the redirect Response"); - location = normalizeRedirectLocation(location, new URL(request.url), basename); - let redirectLocation = createLocation(state.location, location, { - _isRedirect: true - }); - if (isBrowser) { - let isDocumentReload = false; - if (redirect3.response.headers.has("X-Remix-Reload-Document")) { - isDocumentReload = true; - } else if (ABSOLUTE_URL_REGEX.test(location)) { - const url = init.history.createURL(location); - isDocumentReload = // Hard reload if it's an absolute URL to a new origin - url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename - stripBasename(url.pathname, basename) == null; - } - if (isDocumentReload) { - if (replace2) { - routerWindow.location.replace(location); - } else { - routerWindow.location.assign(location); - } - return; - } - } - pendingNavigationController = null; - let redirectHistoryAction = replace2 === true || redirect3.response.headers.has("X-Remix-Replace") ? Action.Replace : Action.Push; - let { - formMethod, - formAction, - formEncType - } = state.navigation; - if (!submission && !fetcherSubmission && formMethod && formAction && formEncType) { - submission = getSubmissionFromNavigation(state.navigation); - } - let activeSubmission = submission || fetcherSubmission; - if (redirectPreserveMethodStatusCodes.has(redirect3.response.status) && activeSubmission && isMutationMethod(activeSubmission.formMethod)) { - await startNavigation(redirectHistoryAction, redirectLocation, { - submission: _extends({}, activeSubmission, { - formAction: location - }), - // Preserve these flags across redirects - preventScrollReset: preventScrollReset || pendingPreventScrollReset, - enableViewTransition: isNavigation ? pendingViewTransitionEnabled : void 0 - }); - } else { - let overrideNavigation = getLoadingNavigation(redirectLocation, submission); - await startNavigation(redirectHistoryAction, redirectLocation, { - overrideNavigation, - // Send fetcher submissions through for shouldRevalidate - fetcherSubmission, - // Preserve these flags across redirects - preventScrollReset: preventScrollReset || pendingPreventScrollReset, - enableViewTransition: isNavigation ? pendingViewTransitionEnabled : void 0 - }); - } - } - async function callDataStrategy(type, state2, request, matchesToLoad, matches, fetcherKey) { - let results; - let dataResults = {}; - try { - results = await callDataStrategyImpl(dataStrategyImpl, type, state2, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties); - } catch (e) { - matchesToLoad.forEach((m) => { - dataResults[m.route.id] = { - type: ResultType.error, - error: e - }; - }); - return dataResults; - } - for (let [routeId, result] of Object.entries(results)) { - if (isRedirectDataStrategyResultResult(result)) { - let response = result.result; - dataResults[routeId] = { - type: ResultType.redirect, - response: normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename, future.v7_relativeSplatPath) - }; - } else { - dataResults[routeId] = await convertDataStrategyResultToDataResult(result); - } - } - return dataResults; - } - async function callLoadersAndMaybeResolveData(state2, matches, matchesToLoad, fetchersToLoad, request) { - let currentMatches = state2.matches; - let loaderResultsPromise = callDataStrategy("loader", state2, request, matchesToLoad, matches, null); - let fetcherResultsPromise = Promise.all(fetchersToLoad.map(async (f) => { - if (f.matches && f.match && f.controller) { - let results = await callDataStrategy("loader", state2, createClientSideRequest(init.history, f.path, f.controller.signal), [f.match], f.matches, f.key); - let result = results[f.match.route.id]; - return { - [f.key]: result - }; - } else { - return Promise.resolve({ - [f.key]: { - type: ResultType.error, - error: getInternalRouterError(404, { - pathname: f.path - }) - } - }); - } - })); - let loaderResults = await loaderResultsPromise; - let fetcherResults = (await fetcherResultsPromise).reduce((acc, r) => Object.assign(acc, r), {}); - await Promise.all([resolveNavigationDeferredResults(matches, loaderResults, request.signal, currentMatches, state2.loaderData), resolveFetcherDeferredResults(matches, fetcherResults, fetchersToLoad)]); - return { - loaderResults, - fetcherResults - }; - } - function interruptActiveLoads() { - isRevalidationRequired = true; - cancelledDeferredRoutes.push(...cancelActiveDeferreds()); - fetchLoadMatches.forEach((_, key) => { - if (fetchControllers.has(key)) { - cancelledFetcherLoads.add(key); - } - abortFetcher(key); - }); - } - function updateFetcherState(key, fetcher, opts) { - if (opts === void 0) { - opts = {}; - } - state.fetchers.set(key, fetcher); - updateState({ - fetchers: new Map(state.fetchers) - }, { - flushSync: (opts && opts.flushSync) === true - }); - } - function setFetcherError(key, routeId, error, opts) { - if (opts === void 0) { - opts = {}; - } - let boundaryMatch = findNearestBoundary(state.matches, routeId); - deleteFetcher(key); - updateState({ - errors: { - [boundaryMatch.route.id]: error - }, - fetchers: new Map(state.fetchers) - }, { - flushSync: (opts && opts.flushSync) === true - }); - } - function getFetcher(key) { - if (future.v7_fetcherPersist) { - activeFetchers.set(key, (activeFetchers.get(key) || 0) + 1); - if (deletedFetchers.has(key)) { - deletedFetchers.delete(key); - } - } - return state.fetchers.get(key) || IDLE_FETCHER; - } - function deleteFetcher(key) { - let fetcher = state.fetchers.get(key); - if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) { - abortFetcher(key); - } - fetchLoadMatches.delete(key); - fetchReloadIds.delete(key); - fetchRedirectIds.delete(key); - deletedFetchers.delete(key); - cancelledFetcherLoads.delete(key); - state.fetchers.delete(key); - } - function deleteFetcherAndUpdateState(key) { - if (future.v7_fetcherPersist) { - let count = (activeFetchers.get(key) || 0) - 1; - if (count <= 0) { - activeFetchers.delete(key); - deletedFetchers.add(key); - } else { - activeFetchers.set(key, count); - } - } else { - deleteFetcher(key); - } - updateState({ - fetchers: new Map(state.fetchers) - }); - } - function abortFetcher(key) { - let controller = fetchControllers.get(key); - if (controller) { - controller.abort(); - fetchControllers.delete(key); - } - } - function markFetchersDone(keys) { - for (let key of keys) { - let fetcher = getFetcher(key); - let doneFetcher = getDoneFetcher(fetcher.data); - state.fetchers.set(key, doneFetcher); - } - } - function markFetchRedirectsDone() { - let doneKeys = []; - let updatedFetchers = false; - for (let key of fetchRedirectIds) { - let fetcher = state.fetchers.get(key); - invariant(fetcher, "Expected fetcher: " + key); - if (fetcher.state === "loading") { - fetchRedirectIds.delete(key); - doneKeys.push(key); - updatedFetchers = true; - } - } - markFetchersDone(doneKeys); - return updatedFetchers; - } - function abortStaleFetchLoads(landedId) { - let yeetedKeys = []; - for (let [key, id] of fetchReloadIds) { - if (id < landedId) { - let fetcher = state.fetchers.get(key); - invariant(fetcher, "Expected fetcher: " + key); - if (fetcher.state === "loading") { - abortFetcher(key); - fetchReloadIds.delete(key); - yeetedKeys.push(key); - } - } - } - markFetchersDone(yeetedKeys); - return yeetedKeys.length > 0; - } - function getBlocker(key, fn) { - let blocker = state.blockers.get(key) || IDLE_BLOCKER; - if (blockerFunctions.get(key) !== fn) { - blockerFunctions.set(key, fn); - } - return blocker; - } - function deleteBlocker(key) { - state.blockers.delete(key); - blockerFunctions.delete(key); - } - function updateBlocker(key, newBlocker) { - let blocker = state.blockers.get(key) || IDLE_BLOCKER; - invariant(blocker.state === "unblocked" && newBlocker.state === "blocked" || blocker.state === "blocked" && newBlocker.state === "blocked" || blocker.state === "blocked" && newBlocker.state === "proceeding" || blocker.state === "blocked" && newBlocker.state === "unblocked" || blocker.state === "proceeding" && newBlocker.state === "unblocked", "Invalid blocker state transition: " + blocker.state + " -> " + newBlocker.state); - let blockers = new Map(state.blockers); - blockers.set(key, newBlocker); - updateState({ - blockers - }); - } - function shouldBlockNavigation(_ref2) { - let { - currentLocation, - nextLocation, - historyAction - } = _ref2; - if (blockerFunctions.size === 0) { - return; - } - if (blockerFunctions.size > 1) { - warning(false, "A router only supports one blocker at a time"); - } - let entries = Array.from(blockerFunctions.entries()); - let [blockerKey, blockerFunction] = entries[entries.length - 1]; - let blocker = state.blockers.get(blockerKey); - if (blocker && blocker.state === "proceeding") { - return; - } - if (blockerFunction({ - currentLocation, - nextLocation, - historyAction - })) { - return blockerKey; - } - } - function handleNavigational404(pathname) { - let error = getInternalRouterError(404, { - pathname - }); - let routesToUse = inFlightDataRoutes || dataRoutes; - let { - matches, - route - } = getShortCircuitMatches(routesToUse); - cancelActiveDeferreds(); - return { - notFoundMatches: matches, - route, - error - }; - } - function cancelActiveDeferreds(predicate) { - let cancelledRouteIds = []; - activeDeferreds.forEach((dfd, routeId) => { - if (!predicate || predicate(routeId)) { - dfd.cancel(); - cancelledRouteIds.push(routeId); - activeDeferreds.delete(routeId); - } - }); - return cancelledRouteIds; - } - function enableScrollRestoration(positions, getPosition, getKey) { - savedScrollPositions = positions; - getScrollPosition = getPosition; - getScrollRestorationKey = getKey || null; - if (!initialScrollRestored && state.navigation === IDLE_NAVIGATION) { - initialScrollRestored = true; - let y = getSavedScrollPosition(state.location, state.matches); - if (y != null) { - updateState({ - restoreScrollPosition: y - }); - } - } - return () => { - savedScrollPositions = null; - getScrollPosition = null; - getScrollRestorationKey = null; - }; - } - function getScrollKey(location, matches) { - if (getScrollRestorationKey) { - let key = getScrollRestorationKey(location, matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))); - return key || location.key; - } - return location.key; - } - function saveScrollPosition(location, matches) { - if (savedScrollPositions && getScrollPosition) { - let key = getScrollKey(location, matches); - savedScrollPositions[key] = getScrollPosition(); - } - } - function getSavedScrollPosition(location, matches) { - if (savedScrollPositions) { - let key = getScrollKey(location, matches); - let y = savedScrollPositions[key]; - if (typeof y === "number") { - return y; - } - } - return null; - } - function checkFogOfWar(matches, routesToUse, pathname) { - if (patchRoutesOnNavigationImpl) { - if (!matches) { - let fogMatches = matchRoutesImpl(routesToUse, pathname, basename, true); - return { - active: true, - matches: fogMatches || [] - }; - } else { - if (Object.keys(matches[0].params).length > 0) { - let partialMatches = matchRoutesImpl(routesToUse, pathname, basename, true); - return { - active: true, - matches: partialMatches - }; - } - } - } - return { - active: false, - matches: null - }; - } - async function discoverRoutes(matches, pathname, signal) { - if (!patchRoutesOnNavigationImpl) { - return { - type: "success", - matches - }; - } - let partialMatches = matches; - while (true) { - let isNonHMR = inFlightDataRoutes == null; - let routesToUse = inFlightDataRoutes || dataRoutes; - let localManifest = manifest; - try { - await patchRoutesOnNavigationImpl({ - path: pathname, - matches: partialMatches, - patch: (routeId, children) => { - if (signal.aborted) return; - patchRoutesImpl(routeId, children, routesToUse, localManifest, mapRouteProperties); - } - }); - } catch (e) { - return { - type: "error", - error: e, - partialMatches - }; - } finally { - if (isNonHMR && !signal.aborted) { - dataRoutes = [...dataRoutes]; - } - } - if (signal.aborted) { - return { - type: "aborted" - }; - } - let newMatches = matchRoutes(routesToUse, pathname, basename); - if (newMatches) { - return { - type: "success", - matches: newMatches - }; - } - let newPartialMatches = matchRoutesImpl(routesToUse, pathname, basename, true); - if (!newPartialMatches || partialMatches.length === newPartialMatches.length && partialMatches.every((m, i) => m.route.id === newPartialMatches[i].route.id)) { - return { - type: "success", - matches: null - }; - } - partialMatches = newPartialMatches; - } - } - function _internalSetRoutes(newRoutes) { - manifest = {}; - inFlightDataRoutes = convertRoutesToDataRoutes(newRoutes, mapRouteProperties, void 0, manifest); - } - function patchRoutes(routeId, children) { - let isNonHMR = inFlightDataRoutes == null; - let routesToUse = inFlightDataRoutes || dataRoutes; - patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties); - if (isNonHMR) { - dataRoutes = [...dataRoutes]; - updateState({}); - } - } - router2 = { - get basename() { - return basename; - }, - get future() { - return future; - }, - get state() { - return state; - }, - get routes() { - return dataRoutes; - }, - get window() { - return routerWindow; - }, - initialize, - subscribe, - enableScrollRestoration, - navigate, - fetch: fetch2, - revalidate, - // Passthrough to history-aware createHref used by useHref so we get proper - // hash-aware URLs in DOM paths - createHref: (to) => init.history.createHref(to), - encodeLocation: (to) => init.history.encodeLocation(to), - getFetcher, - deleteFetcher: deleteFetcherAndUpdateState, - dispose, - getBlocker, - deleteBlocker, - patchRoutes, - _internalFetchControllers: fetchControllers, - _internalActiveDeferreds: activeDeferreds, - // TODO: Remove setRoutes, it's temporary to avoid dealing with - // updating the tree while validating the update algorithm. - _internalSetRoutes - }; - return router2; -} -const UNSAFE_DEFERRED_SYMBOL = Symbol("deferred"); -function createStaticHandler(routes2, opts) { - invariant(routes2.length > 0, "You must provide a non-empty routes array to createStaticHandler"); - let manifest = {}; - let basename = (opts ? opts.basename : null) || "/"; - let mapRouteProperties; - if (opts != null && opts.mapRouteProperties) { - mapRouteProperties = opts.mapRouteProperties; - } else if (opts != null && opts.detectErrorBoundary) { - let detectErrorBoundary = opts.detectErrorBoundary; - mapRouteProperties = (route) => ({ - hasErrorBoundary: detectErrorBoundary(route) - }); - } else { - mapRouteProperties = defaultMapRouteProperties; - } - let future = _extends({ - v7_relativeSplatPath: false, - v7_throwAbortReason: false - }, opts ? opts.future : null); - let dataRoutes = convertRoutesToDataRoutes(routes2, mapRouteProperties, void 0, manifest); - async function query(request, _temp3) { - let { - requestContext, - skipLoaderErrorBubbling, - dataStrategy - } = _temp3 === void 0 ? {} : _temp3; - let url = new URL(request.url); - let method = request.method; - let location = createLocation("", createPath(url), null, "default"); - let matches = matchRoutes(dataRoutes, location, basename); - if (!isValidMethod(method) && method !== "HEAD") { - let error = getInternalRouterError(405, { - method - }); - let { - matches: methodNotAllowedMatches, - route - } = getShortCircuitMatches(dataRoutes); - return { - basename, - location, - matches: methodNotAllowedMatches, - loaderData: {}, - actionData: null, - errors: { - [route.id]: error - }, - statusCode: error.status, - loaderHeaders: {}, - actionHeaders: {}, - activeDeferreds: null - }; - } else if (!matches) { - let error = getInternalRouterError(404, { - pathname: location.pathname - }); - let { - matches: notFoundMatches, - route - } = getShortCircuitMatches(dataRoutes); - return { - basename, - location, - matches: notFoundMatches, - loaderData: {}, - actionData: null, - errors: { - [route.id]: error - }, - statusCode: error.status, - loaderHeaders: {}, - actionHeaders: {}, - activeDeferreds: null - }; - } - let result = await queryImpl(request, location, matches, requestContext, dataStrategy || null, skipLoaderErrorBubbling === true, null); - if (isResponse$1(result)) { - return result; - } - return _extends({ - location, - basename - }, result); - } - async function queryRoute(request, _temp4) { - let { - routeId, - requestContext, - dataStrategy - } = _temp4 === void 0 ? {} : _temp4; - let url = new URL(request.url); - let method = request.method; - let location = createLocation("", createPath(url), null, "default"); - let matches = matchRoutes(dataRoutes, location, basename); - if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") { - throw getInternalRouterError(405, { - method - }); - } else if (!matches) { - throw getInternalRouterError(404, { - pathname: location.pathname - }); - } - let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location); - if (routeId && !match) { - throw getInternalRouterError(403, { - pathname: location.pathname, - routeId - }); - } else if (!match) { - throw getInternalRouterError(404, { - pathname: location.pathname - }); - } - let result = await queryImpl(request, location, matches, requestContext, dataStrategy || null, false, match); - if (isResponse$1(result)) { - return result; - } - let error = result.errors ? Object.values(result.errors)[0] : void 0; - if (error !== void 0) { - throw error; - } - if (result.actionData) { - return Object.values(result.actionData)[0]; - } - if (result.loaderData) { - var _result$activeDeferre; - let data2 = Object.values(result.loaderData)[0]; - if ((_result$activeDeferre = result.activeDeferreds) != null && _result$activeDeferre[match.route.id]) { - data2[UNSAFE_DEFERRED_SYMBOL] = result.activeDeferreds[match.route.id]; - } - return data2; - } - return void 0; - } - async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch) { - invariant(request.signal, "query()/queryRoute() requests must contain an AbortController signal"); - try { - if (isMutationMethod(request.method.toLowerCase())) { - let result2 = await submit(request, matches, routeMatch || getTargetMatch(matches, location), requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch != null); - return result2; - } - let result = await loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch); - return isResponse$1(result) ? result : _extends({}, result, { - actionData: null, - actionHeaders: {} - }); - } catch (e) { - if (isDataStrategyResult(e) && isResponse$1(e.result)) { - if (e.type === ResultType.error) { - throw e.result; - } - return e.result; - } - if (isRedirectResponse$1(e)) { - return e; - } - throw e; - } - } - async function submit(request, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest) { - let result; - if (!actionMatch.route.action && !actionMatch.route.lazy) { - let error = getInternalRouterError(405, { - method: request.method, - pathname: new URL(request.url).pathname, - routeId: actionMatch.route.id - }); - if (isRouteRequest) { - throw error; - } - result = { - type: ResultType.error, - error - }; - } else { - let results = await callDataStrategy("action", request, [actionMatch], matches, isRouteRequest, requestContext, dataStrategy); - result = results[actionMatch.route.id]; - if (request.signal.aborted) { - throwStaticHandlerAbortedError(request, isRouteRequest, future); - } - } - if (isRedirectResult(result)) { - throw new Response(null, { - status: result.response.status, - headers: { - Location: result.response.headers.get("Location") - } - }); - } - if (isDeferredResult(result)) { - let error = getInternalRouterError(400, { - type: "defer-action" - }); - if (isRouteRequest) { - throw error; - } - result = { - type: ResultType.error, - error - }; - } - if (isRouteRequest) { - if (isErrorResult(result)) { - throw result.error; - } - return { - matches: [actionMatch], - loaderData: {}, - actionData: { - [actionMatch.route.id]: result.data - }, - errors: null, - // Note: statusCode + headers are unused here since queryRoute will - // return the raw Response or value - statusCode: 200, - loaderHeaders: {}, - actionHeaders: {}, - activeDeferreds: null - }; - } - let loaderRequest = new Request(request.url, { - headers: request.headers, - redirect: request.redirect, - signal: request.signal - }); - if (isErrorResult(result)) { - let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id); - let context2 = await loadRouteData(loaderRequest, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, null, [boundaryMatch.route.id, result]); - return _extends({}, context2, { - statusCode: isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500, - actionData: null, - actionHeaders: _extends({}, result.headers ? { - [actionMatch.route.id]: result.headers - } : {}) - }); - } - let context = await loadRouteData(loaderRequest, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, null); - return _extends({}, context, { - actionData: { - [actionMatch.route.id]: result.data - } - }, result.statusCode ? { - statusCode: result.statusCode - } : {}, { - actionHeaders: result.headers ? { - [actionMatch.route.id]: result.headers - } : {} - }); - } - async function loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, pendingActionResult) { - let isRouteRequest = routeMatch != null; - if (isRouteRequest && !(routeMatch != null && routeMatch.route.loader) && !(routeMatch != null && routeMatch.route.lazy)) { - throw getInternalRouterError(400, { - method: request.method, - pathname: new URL(request.url).pathname, - routeId: routeMatch == null ? void 0 : routeMatch.route.id - }); - } - let requestMatches = routeMatch ? [routeMatch] : pendingActionResult && isErrorResult(pendingActionResult[1]) ? getLoaderMatchesUntilBoundary(matches, pendingActionResult[0]) : matches; - let matchesToLoad = requestMatches.filter((m) => m.route.loader || m.route.lazy); - if (matchesToLoad.length === 0) { - return { - matches, - // Add a null for all matched routes for proper revalidation on the client - loaderData: matches.reduce((acc, m) => Object.assign(acc, { - [m.route.id]: null - }), {}), - errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? { - [pendingActionResult[0]]: pendingActionResult[1].error - } : null, - statusCode: 200, - loaderHeaders: {}, - activeDeferreds: null - }; - } - let results = await callDataStrategy("loader", request, matchesToLoad, matches, isRouteRequest, requestContext, dataStrategy); - if (request.signal.aborted) { - throwStaticHandlerAbortedError(request, isRouteRequest, future); - } - let activeDeferreds = /* @__PURE__ */ new Map(); - let context = processRouteLoaderData(matches, results, pendingActionResult, activeDeferreds, skipLoaderErrorBubbling); - let executedLoaders = new Set(matchesToLoad.map((match) => match.route.id)); - matches.forEach((match) => { - if (!executedLoaders.has(match.route.id)) { - context.loaderData[match.route.id] = null; - } - }); - return _extends({}, context, { - matches, - activeDeferreds: activeDeferreds.size > 0 ? Object.fromEntries(activeDeferreds.entries()) : null - }); - } - async function callDataStrategy(type, request, matchesToLoad, matches, isRouteRequest, requestContext, dataStrategy) { - let results = await callDataStrategyImpl(dataStrategy || defaultDataStrategy, type, null, request, matchesToLoad, matches, null, manifest, mapRouteProperties, requestContext); - let dataResults = {}; - await Promise.all(matches.map(async (match) => { - if (!(match.route.id in results)) { - return; - } - let result = results[match.route.id]; - if (isRedirectDataStrategyResultResult(result)) { - let response = result.result; - throw normalizeRelativeRoutingRedirectResponse(response, request, match.route.id, matches, basename, future.v7_relativeSplatPath); - } - if (isResponse$1(result.result) && isRouteRequest) { - throw result; - } - dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result); - })); - return dataResults; - } - return { - dataRoutes, - query, - queryRoute - }; -} -function getStaticContextFromError(routes2, context, error) { - let newContext = _extends({}, context, { - statusCode: isRouteErrorResponse(error) ? error.status : 500, - errors: { - [context._deepestRenderedBoundaryId || routes2[0].id]: error - } - }); - return newContext; -} -function throwStaticHandlerAbortedError(request, isRouteRequest, future) { - if (future.v7_throwAbortReason && request.signal.reason !== void 0) { - throw request.signal.reason; - } - let method = isRouteRequest ? "queryRoute" : "query"; - throw new Error(method + "() call aborted: " + request.method + " " + request.url); -} -function isSubmissionNavigation(opts) { - return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0); -} -function normalizeTo(location, matches, basename, prependBasename, to, v7_relativeSplatPath, fromRouteId, relative) { - let contextualMatches; - let activeRouteMatch; - if (fromRouteId) { - contextualMatches = []; - for (let match of matches) { - contextualMatches.push(match); - if (match.route.id === fromRouteId) { - activeRouteMatch = match; - break; - } - } - } else { - contextualMatches = matches; - activeRouteMatch = matches[matches.length - 1]; - } - let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches, v7_relativeSplatPath), stripBasename(location.pathname, basename) || location.pathname, relative === "path"); - if (to == null) { - path.search = location.search; - path.hash = location.hash; - } - if ((to == null || to === "" || to === ".") && activeRouteMatch) { - let nakedIndex = hasNakedIndexQuery(path.search); - if (activeRouteMatch.route.index && !nakedIndex) { - path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index"; - } else if (!activeRouteMatch.route.index && nakedIndex) { - let params = new URLSearchParams(path.search); - let indexValues = params.getAll("index"); - params.delete("index"); - indexValues.filter((v) => v).forEach((v) => params.append("index", v)); - let qs = params.toString(); - path.search = qs ? "?" + qs : ""; - } - } - if (prependBasename && basename !== "/") { - path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]); - } - return createPath(path); -} -function normalizeNavigateOptions(normalizeFormMethod, isFetcher, path, opts) { - if (!opts || !isSubmissionNavigation(opts)) { - return { - path - }; - } - if (opts.formMethod && !isValidMethod(opts.formMethod)) { - return { - path, - error: getInternalRouterError(405, { - method: opts.formMethod - }) - }; - } - let getInvalidBodyError = () => ({ - path, - error: getInternalRouterError(400, { - type: "invalid-body" - }) - }); - let rawFormMethod = opts.formMethod || "get"; - let formMethod = normalizeFormMethod ? rawFormMethod.toUpperCase() : rawFormMethod.toLowerCase(); - let formAction = stripHashFromPath(path); - if (opts.body !== void 0) { - if (opts.formEncType === "text/plain") { - if (!isMutationMethod(formMethod)) { - return getInvalidBodyError(); - } - let text = typeof opts.body === "string" ? opts.body : opts.body instanceof FormData || opts.body instanceof URLSearchParams ? ( - // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data - Array.from(opts.body.entries()).reduce((acc, _ref3) => { - let [name, value] = _ref3; - return "" + acc + name + "=" + value + "\n"; - }, "") - ) : String(opts.body); - return { - path, - submission: { - formMethod, - formAction, - formEncType: opts.formEncType, - formData: void 0, - json: void 0, - text - } - }; - } else if (opts.formEncType === "application/json") { - if (!isMutationMethod(formMethod)) { - return getInvalidBodyError(); - } - try { - let json3 = typeof opts.body === "string" ? JSON.parse(opts.body) : opts.body; - return { - path, - submission: { - formMethod, - formAction, - formEncType: opts.formEncType, - formData: void 0, - json: json3, - text: void 0 - } - }; - } catch (e) { - return getInvalidBodyError(); - } - } - } - invariant(typeof FormData === "function", "FormData is not available in this environment"); - let searchParams; - let formData; - if (opts.formData) { - searchParams = convertFormDataToSearchParams(opts.formData); - formData = opts.formData; - } else if (opts.body instanceof FormData) { - searchParams = convertFormDataToSearchParams(opts.body); - formData = opts.body; - } else if (opts.body instanceof URLSearchParams) { - searchParams = opts.body; - formData = convertSearchParamsToFormData(searchParams); - } else if (opts.body == null) { - searchParams = new URLSearchParams(); - formData = new FormData(); - } else { - try { - searchParams = new URLSearchParams(opts.body); - formData = convertSearchParamsToFormData(searchParams); - } catch (e) { - return getInvalidBodyError(); - } - } - let submission = { - formMethod, - formAction, - formEncType: opts && opts.formEncType || "application/x-www-form-urlencoded", - formData, - json: void 0, - text: void 0 - }; - if (isMutationMethod(submission.formMethod)) { - return { - path, - submission - }; - } - let parsedPath = parsePath(path); - if (isFetcher && parsedPath.search && hasNakedIndexQuery(parsedPath.search)) { - searchParams.append("index", ""); - } - parsedPath.search = "?" + searchParams; - return { - path: createPath(parsedPath), - submission - }; -} -function getLoaderMatchesUntilBoundary(matches, boundaryId, includeBoundary) { - if (includeBoundary === void 0) { - includeBoundary = false; - } - let index = matches.findIndex((m) => m.route.id === boundaryId); - if (index >= 0) { - return matches.slice(0, includeBoundary ? index + 1 : index); - } - return matches; -} -function getMatchesToLoad(history, state, matches, submission, location, initialHydration, skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) { - let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0; - let currentUrl = history.createURL(state.location); - let nextUrl = history.createURL(location); - let boundaryMatches = matches; - if (initialHydration && state.errors) { - boundaryMatches = getLoaderMatchesUntilBoundary(matches, Object.keys(state.errors)[0], true); - } else if (pendingActionResult && isErrorResult(pendingActionResult[1])) { - boundaryMatches = getLoaderMatchesUntilBoundary(matches, pendingActionResult[0]); - } - let actionStatus = pendingActionResult ? pendingActionResult[1].statusCode : void 0; - let shouldSkipRevalidation = skipActionErrorRevalidation && actionStatus && actionStatus >= 400; - let navigationMatches = boundaryMatches.filter((match, index) => { - let { - route - } = match; - if (route.lazy) { - return true; - } - if (route.loader == null) { - return false; - } - if (initialHydration) { - return shouldLoadRouteOnHydration(route, state.loaderData, state.errors); - } - if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some((id) => id === match.route.id)) { - return true; - } - let currentRouteMatch = state.matches[index]; - let nextRouteMatch = match; - return shouldRevalidateLoader(match, _extends({ - currentUrl, - currentParams: currentRouteMatch.params, - nextUrl, - nextParams: nextRouteMatch.params - }, submission, { - actionResult, - actionStatus, - defaultShouldRevalidate: shouldSkipRevalidation ? false : ( - // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate - isRevalidationRequired || currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search || // Search params affect all loaders - currentUrl.search !== nextUrl.search || isNewRouteInstance(currentRouteMatch, nextRouteMatch) - ) - })); - }); - let revalidatingFetchers = []; - fetchLoadMatches.forEach((f, key) => { - if (initialHydration || !matches.some((m) => m.route.id === f.routeId) || deletedFetchers.has(key)) { - return; - } - let fetcherMatches = matchRoutes(routesToUse, f.path, basename); - if (!fetcherMatches) { - revalidatingFetchers.push({ - key, - routeId: f.routeId, - path: f.path, - matches: null, - match: null, - controller: null - }); - return; - } - let fetcher = state.fetchers.get(key); - let fetcherMatch = getTargetMatch(fetcherMatches, f.path); - let shouldRevalidate = false; - if (fetchRedirectIds.has(key)) { - shouldRevalidate = false; - } else if (cancelledFetcherLoads.has(key)) { - cancelledFetcherLoads.delete(key); - shouldRevalidate = true; - } else if (fetcher && fetcher.state !== "idle" && fetcher.data === void 0) { - shouldRevalidate = isRevalidationRequired; - } else { - shouldRevalidate = shouldRevalidateLoader(fetcherMatch, _extends({ - currentUrl, - currentParams: state.matches[state.matches.length - 1].params, - nextUrl, - nextParams: matches[matches.length - 1].params - }, submission, { - actionResult, - actionStatus, - defaultShouldRevalidate: shouldSkipRevalidation ? false : isRevalidationRequired - })); - } - if (shouldRevalidate) { - revalidatingFetchers.push({ - key, - routeId: f.routeId, - path: f.path, - matches: fetcherMatches, - match: fetcherMatch, - controller: new AbortController() - }); - } - }); - return [navigationMatches, revalidatingFetchers]; -} -function shouldLoadRouteOnHydration(route, loaderData, errors2) { - if (route.lazy) { - return true; - } - if (!route.loader) { - return false; - } - let hasData = loaderData != null && loaderData[route.id] !== void 0; - let hasError = errors2 != null && errors2[route.id] !== void 0; - if (!hasData && hasError) { - return false; - } - if (typeof route.loader === "function" && route.loader.hydrate === true) { - return true; - } - return !hasData && !hasError; -} -function isNewLoader(currentLoaderData, currentMatch, match) { - let isNew = ( - // [a] -> [a, b] - !currentMatch || // [a, b] -> [a, c] - match.route.id !== currentMatch.route.id - ); - let isMissingData = currentLoaderData[match.route.id] === void 0; - return isNew || isMissingData; -} -function isNewRouteInstance(currentMatch, match) { - let currentPath = currentMatch.route.path; - return ( - // param change for this match, /users/123 -> /users/456 - currentMatch.pathname !== match.pathname || // splat param changed, which is not present in match.path - // e.g. /files/images/avatar.jpg -> files/finances.xls - currentPath != null && currentPath.endsWith("*") && currentMatch.params["*"] !== match.params["*"] - ); -} -function shouldRevalidateLoader(loaderMatch, arg) { - if (loaderMatch.route.shouldRevalidate) { - let routeChoice = loaderMatch.route.shouldRevalidate(arg); - if (typeof routeChoice === "boolean") { - return routeChoice; - } - } - return arg.defaultShouldRevalidate; -} -function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties) { - var _childrenToPatch; - let childrenToPatch; - if (routeId) { - let route = manifest[routeId]; - invariant(route, "No route found to patch children into: routeId = " + routeId); - if (!route.children) { - route.children = []; - } - childrenToPatch = route.children; - } else { - childrenToPatch = routesToUse; - } - let uniqueChildren = children.filter((newRoute) => !childrenToPatch.some((existingRoute) => isSameRoute(newRoute, existingRoute))); - let newRoutes = convertRoutesToDataRoutes(uniqueChildren, mapRouteProperties, [routeId || "_", "patch", String(((_childrenToPatch = childrenToPatch) == null ? void 0 : _childrenToPatch.length) || "0")], manifest); - childrenToPatch.push(...newRoutes); -} -function isSameRoute(newRoute, existingRoute) { - if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) { - return true; - } - if (!(newRoute.index === existingRoute.index && newRoute.path === existingRoute.path && newRoute.caseSensitive === existingRoute.caseSensitive)) { - return false; - } - if ((!newRoute.children || newRoute.children.length === 0) && (!existingRoute.children || existingRoute.children.length === 0)) { - return true; - } - return newRoute.children.every((aChild, i) => { - var _existingRoute$childr; - return (_existingRoute$childr = existingRoute.children) == null ? void 0 : _existingRoute$childr.some((bChild) => isSameRoute(aChild, bChild)); - }); -} -async function loadLazyRouteModule(route, mapRouteProperties, manifest) { - if (!route.lazy) { - return; - } - let lazyRoute = await route.lazy(); - if (!route.lazy) { - return; - } - let routeToUpdate = manifest[route.id]; - invariant(routeToUpdate, "No route found in manifest"); - let routeUpdates = {}; - for (let lazyRouteProperty in lazyRoute) { - let staticRouteValue = routeToUpdate[lazyRouteProperty]; - let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based - // on the route updates - lazyRouteProperty !== "hasErrorBoundary"; - warning(!isPropertyStaticallyDefined, 'Route "' + routeToUpdate.id + '" has a static property "' + lazyRouteProperty + '" defined but its lazy function is also returning a value for this property. ' + ('The lazy route property "' + lazyRouteProperty + '" will be ignored.')); - if (!isPropertyStaticallyDefined && !immutableRouteKeys.has(lazyRouteProperty)) { - routeUpdates[lazyRouteProperty] = lazyRoute[lazyRouteProperty]; - } - } - Object.assign(routeToUpdate, routeUpdates); - Object.assign(routeToUpdate, _extends({}, mapRouteProperties(routeToUpdate), { - lazy: void 0 - })); -} -async function defaultDataStrategy(_ref4) { - let { - matches - } = _ref4; - let matchesToLoad = matches.filter((m) => m.shouldLoad); - let results = await Promise.all(matchesToLoad.map((m) => m.resolve())); - return results.reduce((acc, result, i) => Object.assign(acc, { - [matchesToLoad[i].route.id]: result - }), {}); -} -async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties, requestContext) { - let loadRouteDefinitionsPromises = matches.map((m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties, manifest) : void 0); - let dsMatches = matches.map((match, i) => { - let loadRoutePromise = loadRouteDefinitionsPromises[i]; - let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id); - let resolve = async (handlerOverride) => { - if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) { - shouldLoad = true; - } - return shouldLoad ? callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, requestContext) : Promise.resolve({ - type: ResultType.data, - result: void 0 - }); - }; - return _extends({}, match, { - shouldLoad, - resolve - }); - }); - let results = await dataStrategyImpl({ - matches: dsMatches, - request, - params: matches[0].params, - fetcherKey, - context: requestContext - }); - try { - await Promise.all(loadRouteDefinitionsPromises); - } catch (e) { - } - return results; -} -async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, staticContext) { - let result; - let onReject; - let runHandler = (handler) => { - let reject; - let abortPromise = new Promise((_, r) => reject = r); - onReject = () => reject(); - request.signal.addEventListener("abort", onReject); - let actualHandler = (ctx) => { - if (typeof handler !== "function") { - return Promise.reject(new Error("You cannot call the handler for a route which defines a boolean " + ('"' + type + '" [routeId: ' + match.route.id + "]"))); - } - return handler({ - request, - params: match.params, - context: staticContext - }, ...ctx !== void 0 ? [ctx] : []); - }; - let handlerPromise = (async () => { - try { - let val = await (handlerOverride ? handlerOverride((ctx) => actualHandler(ctx)) : actualHandler()); - return { - type: "data", - result: val - }; - } catch (e) { - return { - type: "error", - result: e - }; - } - })(); - return Promise.race([handlerPromise, abortPromise]); - }; - try { - let handler = match.route[type]; - if (loadRoutePromise) { - if (handler) { - let handlerError; - let [value] = await Promise.all([ - // If the handler throws, don't let it immediately bubble out, - // since we need to let the lazy() execution finish so we know if this - // route has a boundary that can handle the error - runHandler(handler).catch((e) => { - handlerError = e; - }), - loadRoutePromise - ]); - if (handlerError !== void 0) { - throw handlerError; - } - result = value; - } else { - await loadRoutePromise; - handler = match.route[type]; - if (handler) { - result = await runHandler(handler); - } else if (type === "action") { - let url = new URL(request.url); - let pathname = url.pathname + url.search; - throw getInternalRouterError(405, { - method: request.method, - pathname, - routeId: match.route.id - }); - } else { - return { - type: ResultType.data, - result: void 0 - }; - } - } - } else if (!handler) { - let url = new URL(request.url); - let pathname = url.pathname + url.search; - throw getInternalRouterError(404, { - pathname - }); - } else { - result = await runHandler(handler); - } - invariant(result.result !== void 0, "You defined " + (type === "action" ? "an action" : "a loader") + " for route " + ('"' + match.route.id + "\" but didn't return anything from your `" + type + "` ") + "function. Please return a value or `null`."); - } catch (e) { - return { - type: ResultType.error, - result: e - }; - } finally { - if (onReject) { - request.signal.removeEventListener("abort", onReject); - } - } - return result; -} -async function convertDataStrategyResultToDataResult(dataStrategyResult) { - let { - result, - type - } = dataStrategyResult; - if (isResponse$1(result)) { - let data2; - try { - let contentType = result.headers.get("Content-Type"); - if (contentType && /\bapplication\/json\b/.test(contentType)) { - if (result.body == null) { - data2 = null; - } else { - data2 = await result.json(); - } - } else { - data2 = await result.text(); - } - } catch (e) { - return { - type: ResultType.error, - error: e - }; - } - if (type === ResultType.error) { - return { - type: ResultType.error, - error: new ErrorResponseImpl(result.status, result.statusText, data2), - statusCode: result.status, - headers: result.headers - }; - } - return { - type: ResultType.data, - data: data2, - statusCode: result.status, - headers: result.headers - }; - } - if (type === ResultType.error) { - if (isDataWithResponseInit(result)) { - var _result$init2; - if (result.data instanceof Error) { - var _result$init; - return { - type: ResultType.error, - error: result.data, - statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status - }; - } - result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, void 0, result.data); - } - return { - type: ResultType.error, - error: result, - statusCode: isRouteErrorResponse(result) ? result.status : void 0 - }; - } - if (isDeferredData$1(result)) { - var _result$init3, _result$init4; - return { - type: ResultType.deferred, - deferredData: result, - statusCode: (_result$init3 = result.init) == null ? void 0 : _result$init3.status, - headers: ((_result$init4 = result.init) == null ? void 0 : _result$init4.headers) && new Headers(result.init.headers) - }; - } - if (isDataWithResponseInit(result)) { - var _result$init5, _result$init6; - return { - type: ResultType.data, - data: result.data, - statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status, - headers: (_result$init6 = result.init) != null && _result$init6.headers ? new Headers(result.init.headers) : void 0 - }; - } - return { - type: ResultType.data, - data: result - }; -} -function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename, v7_relativeSplatPath) { - let location = response.headers.get("Location"); - invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header"); - if (!ABSOLUTE_URL_REGEX.test(location)) { - let trimmedMatches = matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1); - location = normalizeTo(new URL(request.url), trimmedMatches, basename, true, location, v7_relativeSplatPath); - response.headers.set("Location", location); - } - return response; -} -function normalizeRedirectLocation(location, currentUrl, basename) { - if (ABSOLUTE_URL_REGEX.test(location)) { - let normalizedLocation = location; - let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation); - let isSameBasename = stripBasename(url.pathname, basename) != null; - if (url.origin === currentUrl.origin && isSameBasename) { - return url.pathname + url.search + url.hash; - } - } - return location; -} -function createClientSideRequest(history, location, signal, submission) { - let url = history.createURL(stripHashFromPath(location)).toString(); - let init = { - signal - }; - if (submission && isMutationMethod(submission.formMethod)) { - let { - formMethod, - formEncType - } = submission; - init.method = formMethod.toUpperCase(); - if (formEncType === "application/json") { - init.headers = new Headers({ - "Content-Type": formEncType - }); - init.body = JSON.stringify(submission.json); - } else if (formEncType === "text/plain") { - init.body = submission.text; - } else if (formEncType === "application/x-www-form-urlencoded" && submission.formData) { - init.body = convertFormDataToSearchParams(submission.formData); - } else { - init.body = submission.formData; - } - } - return new Request(url, init); -} -function convertFormDataToSearchParams(formData) { - let searchParams = new URLSearchParams(); - for (let [key, value] of formData.entries()) { - searchParams.append(key, typeof value === "string" ? value : value.name); - } - return searchParams; -} -function convertSearchParamsToFormData(searchParams) { - let formData = new FormData(); - for (let [key, value] of searchParams.entries()) { - formData.append(key, value); - } - return formData; -} -function processRouteLoaderData(matches, results, pendingActionResult, activeDeferreds, skipLoaderErrorBubbling) { - let loaderData = {}; - let errors2 = null; - let statusCode; - let foundError = false; - let loaderHeaders = {}; - let pendingError = pendingActionResult && isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : void 0; - matches.forEach((match) => { - if (!(match.route.id in results)) { - return; - } - let id = match.route.id; - let result = results[id]; - invariant(!isRedirectResult(result), "Cannot handle redirect results in processLoaderData"); - if (isErrorResult(result)) { - let error = result.error; - if (pendingError !== void 0) { - error = pendingError; - pendingError = void 0; - } - errors2 = errors2 || {}; - if (skipLoaderErrorBubbling) { - errors2[id] = error; - } else { - let boundaryMatch = findNearestBoundary(matches, id); - if (errors2[boundaryMatch.route.id] == null) { - errors2[boundaryMatch.route.id] = error; - } - } - loaderData[id] = void 0; - if (!foundError) { - foundError = true; - statusCode = isRouteErrorResponse(result.error) ? result.error.status : 500; - } - if (result.headers) { - loaderHeaders[id] = result.headers; - } - } else { - if (isDeferredResult(result)) { - activeDeferreds.set(id, result.deferredData); - loaderData[id] = result.deferredData.data; - if (result.statusCode != null && result.statusCode !== 200 && !foundError) { - statusCode = result.statusCode; - } - if (result.headers) { - loaderHeaders[id] = result.headers; - } - } else { - loaderData[id] = result.data; - if (result.statusCode && result.statusCode !== 200 && !foundError) { - statusCode = result.statusCode; - } - if (result.headers) { - loaderHeaders[id] = result.headers; - } - } - } - }); - if (pendingError !== void 0 && pendingActionResult) { - errors2 = { - [pendingActionResult[0]]: pendingError - }; - loaderData[pendingActionResult[0]] = void 0; - } - return { - loaderData, - errors: errors2, - statusCode: statusCode || 200, - loaderHeaders - }; -} -function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds) { - let { - loaderData, - errors: errors2 - } = processRouteLoaderData( - matches, - results, - pendingActionResult, - activeDeferreds, - false - // This method is only called client side so we always want to bubble - ); - revalidatingFetchers.forEach((rf) => { - let { - key, - match, - controller - } = rf; - let result = fetcherResults[key]; - invariant(result, "Did not find corresponding fetcher result"); - if (controller && controller.signal.aborted) { - return; - } else if (isErrorResult(result)) { - let boundaryMatch = findNearestBoundary(state.matches, match == null ? void 0 : match.route.id); - if (!(errors2 && errors2[boundaryMatch.route.id])) { - errors2 = _extends({}, errors2, { - [boundaryMatch.route.id]: result.error - }); - } - state.fetchers.delete(key); - } else if (isRedirectResult(result)) { - invariant(false, "Unhandled fetcher revalidation redirect"); - } else if (isDeferredResult(result)) { - invariant(false, "Unhandled fetcher deferred data"); - } else { - let doneFetcher = getDoneFetcher(result.data); - state.fetchers.set(key, doneFetcher); - } - }); - return { - loaderData, - errors: errors2 - }; -} -function mergeLoaderData(loaderData, newLoaderData, matches, errors2) { - let mergedLoaderData = _extends({}, newLoaderData); - for (let match of matches) { - let id = match.route.id; - if (newLoaderData.hasOwnProperty(id)) { - if (newLoaderData[id] !== void 0) { - mergedLoaderData[id] = newLoaderData[id]; - } - } else if (loaderData[id] !== void 0 && match.route.loader) { - mergedLoaderData[id] = loaderData[id]; - } - if (errors2 && errors2.hasOwnProperty(id)) { - break; - } - } - return mergedLoaderData; -} -function getActionDataForCommit(pendingActionResult) { - if (!pendingActionResult) { - return {}; - } - return isErrorResult(pendingActionResult[1]) ? { - // Clear out prior actionData on errors - actionData: {} - } : { - actionData: { - [pendingActionResult[0]]: pendingActionResult[1].data - } - }; -} -function findNearestBoundary(matches, routeId) { - let eligibleMatches = routeId ? matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1) : [...matches]; - return eligibleMatches.reverse().find((m) => m.route.hasErrorBoundary === true) || matches[0]; -} -function getShortCircuitMatches(routes2) { - let route = routes2.length === 1 ? routes2[0] : routes2.find((r) => r.index || !r.path || r.path === "/") || { - id: "__shim-error-route__" - }; - return { - matches: [{ - params: {}, - pathname: "", - pathnameBase: "", - route - }], - route - }; -} -function getInternalRouterError(status, _temp5) { - let { - pathname, - routeId, - method, - type, - message - } = _temp5 === void 0 ? {} : _temp5; - let statusText = "Unknown Server Error"; - let errorMessage = "Unknown @remix-run/router error"; - if (status === 400) { - statusText = "Bad Request"; - if (method && pathname && routeId) { - errorMessage = "You made a " + method + ' request to "' + pathname + '" but ' + ('did not provide a `loader` for route "' + routeId + '", ') + "so there is no way to handle the request."; - } else if (type === "defer-action") { - errorMessage = "defer() is not supported in actions"; - } else if (type === "invalid-body") { - errorMessage = "Unable to encode submission body"; - } - } else if (status === 403) { - statusText = "Forbidden"; - errorMessage = 'Route "' + routeId + '" does not match URL "' + pathname + '"'; - } else if (status === 404) { - statusText = "Not Found"; - errorMessage = 'No route matches URL "' + pathname + '"'; - } else if (status === 405) { - statusText = "Method Not Allowed"; - if (method && pathname && routeId) { - errorMessage = "You made a " + method.toUpperCase() + ' request to "' + pathname + '" but ' + ('did not provide an `action` for route "' + routeId + '", ') + "so there is no way to handle the request."; - } else if (method) { - errorMessage = 'Invalid request method "' + method.toUpperCase() + '"'; - } - } - return new ErrorResponseImpl(status || 500, statusText, new Error(errorMessage), true); -} -function findRedirect(results) { - let entries = Object.entries(results); - for (let i = entries.length - 1; i >= 0; i--) { - let [key, result] = entries[i]; - if (isRedirectResult(result)) { - return { - key, - result - }; - } - } -} -function stripHashFromPath(path) { - let parsedPath = typeof path === "string" ? parsePath(path) : path; - return createPath(_extends({}, parsedPath, { - hash: "" - })); -} -function isHashChangeOnly(a, b) { - if (a.pathname !== b.pathname || a.search !== b.search) { - return false; - } - if (a.hash === "") { - return b.hash !== ""; - } else if (a.hash === b.hash) { - return true; - } else if (b.hash !== "") { - return true; - } - return false; -} -function isDataStrategyResult(result) { - return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === ResultType.data || result.type === ResultType.error); -} -function isRedirectDataStrategyResultResult(result) { - return isResponse$1(result.result) && redirectStatusCodes$1.has(result.result.status); -} -function isDeferredResult(result) { - return result.type === ResultType.deferred; -} -function isErrorResult(result) { - return result.type === ResultType.error; -} -function isRedirectResult(result) { - return (result && result.type) === ResultType.redirect; -} -function isDataWithResponseInit(value) { - return typeof value === "object" && value != null && "type" in value && "data" in value && "init" in value && value.type === "DataWithResponseInit"; -} -function isDeferredData$1(value) { - let deferred = value; - return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function"; -} -function isResponse$1(value) { - return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined"; -} -function isRedirectResponse$1(result) { - if (!isResponse$1(result)) { - return false; - } - let status = result.status; - let location = result.headers.get("Location"); - return status >= 300 && status <= 399 && location != null; -} -function isValidMethod(method) { - return validRequestMethods.has(method.toLowerCase()); -} -function isMutationMethod(method) { - return validMutationMethods.has(method.toLowerCase()); -} -async function resolveNavigationDeferredResults(matches, results, signal, currentMatches, currentLoaderData) { - let entries = Object.entries(results); - for (let index = 0; index < entries.length; index++) { - let [routeId, result] = entries[index]; - let match = matches.find((m) => (m == null ? void 0 : m.route.id) === routeId); - if (!match) { - continue; - } - let currentMatch = currentMatches.find((m) => m.route.id === match.route.id); - let isRevalidatingLoader = currentMatch != null && !isNewRouteInstance(currentMatch, match) && (currentLoaderData && currentLoaderData[match.route.id]) !== void 0; - if (isDeferredResult(result) && isRevalidatingLoader) { - await resolveDeferredData(result, signal, false).then((result2) => { - if (result2) { - results[routeId] = result2; - } - }); - } - } -} -async function resolveFetcherDeferredResults(matches, results, revalidatingFetchers) { - for (let index = 0; index < revalidatingFetchers.length; index++) { - let { - key, - routeId, - controller - } = revalidatingFetchers[index]; - let result = results[key]; - let match = matches.find((m) => (m == null ? void 0 : m.route.id) === routeId); - if (!match) { - continue; - } - if (isDeferredResult(result)) { - invariant(controller, "Expected an AbortController for revalidating fetcher deferred result"); - await resolveDeferredData(result, controller.signal, true).then((result2) => { - if (result2) { - results[key] = result2; - } - }); - } - } -} -async function resolveDeferredData(result, signal, unwrap) { - if (unwrap === void 0) { - unwrap = false; - } - let aborted = await result.deferredData.resolveData(signal); - if (aborted) { - return; - } - if (unwrap) { - try { - return { - type: ResultType.data, - data: result.deferredData.unwrappedData - }; - } catch (e) { - return { - type: ResultType.error, - error: e - }; - } - } - return { - type: ResultType.data, - data: result.deferredData.data - }; -} -function hasNakedIndexQuery(search) { - return new URLSearchParams(search).getAll("index").some((v) => v === ""); -} -function getTargetMatch(matches, location) { - let search = typeof location === "string" ? parsePath(location).search : location.search; - if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) { - return matches[matches.length - 1]; - } - let pathMatches = getPathContributingMatches(matches); - return pathMatches[pathMatches.length - 1]; -} -function getSubmissionFromNavigation(navigation) { - let { - formMethod, - formAction, - formEncType, - text, - formData, - json: json3 - } = navigation; - if (!formMethod || !formAction || !formEncType) { - return; - } - if (text != null) { - return { - formMethod, - formAction, - formEncType, - formData: void 0, - json: void 0, - text - }; - } else if (formData != null) { - return { - formMethod, - formAction, - formEncType, - formData, - json: void 0, - text: void 0 - }; - } else if (json3 !== void 0) { - return { - formMethod, - formAction, - formEncType, - formData: void 0, - json: json3, - text: void 0 - }; - } -} -function getLoadingNavigation(location, submission) { - if (submission) { - let navigation = { - state: "loading", - location, - formMethod: submission.formMethod, - formAction: submission.formAction, - formEncType: submission.formEncType, - formData: submission.formData, - json: submission.json, - text: submission.text - }; - return navigation; - } else { - let navigation = { - state: "loading", - location, - formMethod: void 0, - formAction: void 0, - formEncType: void 0, - formData: void 0, - json: void 0, - text: void 0 - }; - return navigation; - } -} -function getSubmittingNavigation(location, submission) { - let navigation = { - state: "submitting", - location, - formMethod: submission.formMethod, - formAction: submission.formAction, - formEncType: submission.formEncType, - formData: submission.formData, - json: submission.json, - text: submission.text - }; - return navigation; -} -function getLoadingFetcher(submission, data2) { - if (submission) { - let fetcher = { - state: "loading", - formMethod: submission.formMethod, - formAction: submission.formAction, - formEncType: submission.formEncType, - formData: submission.formData, - json: submission.json, - text: submission.text, - data: data2 - }; - return fetcher; - } else { - let fetcher = { - state: "loading", - formMethod: void 0, - formAction: void 0, - formEncType: void 0, - formData: void 0, - json: void 0, - text: void 0, - data: data2 - }; - return fetcher; - } -} -function getSubmittingFetcher(submission, existingFetcher) { - let fetcher = { - state: "submitting", - formMethod: submission.formMethod, - formAction: submission.formAction, - formEncType: submission.formEncType, - formData: submission.formData, - json: submission.json, - text: submission.text, - data: existingFetcher ? existingFetcher.data : void 0 - }; - return fetcher; -} -function getDoneFetcher(data2) { - let fetcher = { - state: "idle", - formMethod: void 0, - formAction: void 0, - formEncType: void 0, - formData: void 0, - json: void 0, - text: void 0, - data: data2 - }; - return fetcher; -} -function restoreAppliedTransitions(_window, transitions) { - try { - let sessionPositions = _window.sessionStorage.getItem(TRANSITIONS_STORAGE_KEY); - if (sessionPositions) { - let json3 = JSON.parse(sessionPositions); - for (let [k, v] of Object.entries(json3 || {})) { - if (v && Array.isArray(v)) { - transitions.set(k, new Set(v || [])); - } - } - } - } catch (e) { - } -} -function persistAppliedTransitions(_window, transitions) { - if (transitions.size > 0) { - let json3 = {}; - for (let [k, v] of transitions) { - json3[k] = [...v]; - } - try { - _window.sessionStorage.setItem(TRANSITIONS_STORAGE_KEY, JSON.stringify(json3)); - } catch (error) { - warning(false, "Failed to save applied view transitions in sessionStorage (" + error + ")."); - } - } -} -const router$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - AbortedDeferredError, - get Action() { - return Action; - }, - IDLE_BLOCKER, - IDLE_FETCHER, - IDLE_NAVIGATION, - UNSAFE_DEFERRED_SYMBOL, - UNSAFE_DeferredData: DeferredData, - UNSAFE_ErrorResponseImpl: ErrorResponseImpl, - UNSAFE_convertRouteMatchToUiMatch: convertRouteMatchToUiMatch, - UNSAFE_convertRoutesToDataRoutes: convertRoutesToDataRoutes, - UNSAFE_decodePath: decodePath, - UNSAFE_getResolveToMatches: getResolveToMatches, - UNSAFE_invariant: invariant, - UNSAFE_warning: warning, - createBrowserHistory, - createHashHistory, - createMemoryHistory, - createPath, - createRouter, - createStaticHandler, - data, - defer: defer$1, - generatePath, - getStaticContextFromError, - getToPathname, - isDataWithResponseInit, - isDeferredData: isDeferredData$1, - isRouteErrorResponse, - joinPaths, - json: json$1, - matchPath, - matchRoutes, - normalizePathname, - parsePath, - redirect: redirect$1, - redirectDocument: redirectDocument$1, - replace: replace$1, - resolvePath, - resolveTo, - stripBasename -}, Symbol.toStringTag, { value: "Module" })); -var mode$2 = {}; -/** - * @remix-run/server-runtime v2.13.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */ -Object.defineProperty(mode$2, "__esModule", { value: true }); -let ServerMode = /* @__PURE__ */ function(ServerMode2) { - ServerMode2["Development"] = "development"; - ServerMode2["Production"] = "production"; - ServerMode2["Test"] = "test"; - return ServerMode2; -}({}); -function isServerMode(value) { - return value === ServerMode.Development || value === ServerMode.Production || value === ServerMode.Test; -} -var ServerMode_1 = mode$2.ServerMode = ServerMode; -var isServerMode_1 = mode$2.isServerMode = isServerMode; -const mode$1 = /* @__PURE__ */ _mergeNamespaces({ - __proto__: null, - ServerMode: ServerMode_1, - default: mode$2, - isServerMode: isServerMode_1 -}, [mode$2]); -var responses = {}; -const require$$0 = /* @__PURE__ */ getAugmentedNamespace(router$2); -var errors$2 = {}; -const require$$1$1 = /* @__PURE__ */ getAugmentedNamespace(mode$1); -/** - * @remix-run/server-runtime v2.13.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */ -Object.defineProperty(errors$2, "__esModule", { value: true }); -var router$1 = require$$0; -var mode = require$$1$1; -function sanitizeError(error, serverMode) { - if (error instanceof Error && serverMode !== mode.ServerMode.Development) { - let sanitized = new Error("Unexpected Server Error"); - sanitized.stack = void 0; - return sanitized; - } - return error; -} -function sanitizeErrors(errors2, serverMode) { - return Object.entries(errors2).reduce((acc, [routeId, error]) => { - return Object.assign(acc, { - [routeId]: sanitizeError(error, serverMode) - }); - }, {}); -} -function serializeError(error, serverMode) { - let sanitized = sanitizeError(error, serverMode); - return { - message: sanitized.message, - stack: sanitized.stack - }; -} -function serializeErrors(errors2, serverMode) { - if (!errors2) return null; - let entries = Object.entries(errors2); - let serialized = {}; - for (let [key, val] of entries) { - if (router$1.isRouteErrorResponse(val)) { - serialized[key] = { - ...val, - __type: "RouteErrorResponse" - }; - } else if (val instanceof Error) { - let sanitized = sanitizeError(val, serverMode); - serialized[key] = { - message: sanitized.message, - stack: sanitized.stack, - __type: "Error", - // If this is a subclass (i.e., ReferenceError), send up the type so we - // can re-create the same type during hydration. This will only apply - // in dev mode since all production errors are sanitized to normal - // Error instances - ...sanitized.name !== "Error" ? { - __subType: sanitized.name - } : {} - }; - } else { - serialized[key] = val; - } - } - return serialized; -} -var sanitizeError_1 = errors$2.sanitizeError = sanitizeError; -var sanitizeErrors_1 = errors$2.sanitizeErrors = sanitizeErrors; -var serializeError_1 = errors$2.serializeError = serializeError; -var serializeErrors_1 = errors$2.serializeErrors = serializeErrors; -const errors$1 = /* @__PURE__ */ _mergeNamespaces({ - __proto__: null, - default: errors$2, - sanitizeError: sanitizeError_1, - sanitizeErrors: sanitizeErrors_1, - serializeError: serializeError_1, - serializeErrors: serializeErrors_1 -}, [errors$2]); -const require$$1 = /* @__PURE__ */ getAugmentedNamespace(errors$1); -/** - * @remix-run/server-runtime v2.13.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */ -Object.defineProperty(responses, "__esModule", { value: true }); -var router = require$$0; -var errors = require$$1; -const json2 = (data2, init = {}) => { - return router.json(data2, init); -}; -const defer2 = (data2, init = {}) => { - return router.defer(data2, init); -}; -const redirect2 = (url, init = 302) => { - return router.redirect(url, init); -}; -const replace = (url, init = 302) => { - return router.replace(url, init); -}; -const redirectDocument = (url, init = 302) => { - return router.redirectDocument(url, init); -}; -function isDeferredData(value) { - let deferred = value; - return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function"; -} -function isResponse(value) { - return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined"; -} -const redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]); -function isRedirectStatusCode(statusCode) { - return redirectStatusCodes.has(statusCode); -} -function isRedirectResponse(response) { - return isRedirectStatusCode(response.status); -} -function isTrackedPromise(value) { - return value != null && typeof value.then === "function" && value._tracked === true; -} -const DEFERRED_VALUE_PLACEHOLDER_PREFIX = "__deferred_promise:"; -function createDeferredReadableStream(deferredData, signal, serverMode) { - let encoder = new TextEncoder(); - let stream = new ReadableStream({ - async start(controller) { - let criticalData = {}; - let preresolvedKeys = []; - for (let [key, value] of Object.entries(deferredData.data)) { - if (isTrackedPromise(value)) { - criticalData[key] = `${DEFERRED_VALUE_PLACEHOLDER_PREFIX}${key}`; - if (typeof value._data !== "undefined" || typeof value._error !== "undefined") { - preresolvedKeys.push(key); - } - } else { - criticalData[key] = value; - } - } - controller.enqueue(encoder.encode(JSON.stringify(criticalData) + "\n\n")); - for (let preresolvedKey of preresolvedKeys) { - enqueueTrackedPromise(controller, encoder, preresolvedKey, deferredData.data[preresolvedKey], serverMode); - } - let unsubscribe = deferredData.subscribe((aborted, settledKey) => { - if (settledKey) { - enqueueTrackedPromise(controller, encoder, settledKey, deferredData.data[settledKey], serverMode); - } - }); - await deferredData.resolveData(signal); - unsubscribe(); - controller.close(); - } - }); - return stream; -} -function enqueueTrackedPromise(controller, encoder, settledKey, promise, serverMode) { - if ("_error" in promise) { - controller.enqueue(encoder.encode("error:" + JSON.stringify({ - [settledKey]: promise._error instanceof Error ? errors.serializeError(promise._error, serverMode) : promise._error - }) + "\n\n")); - } else { - controller.enqueue(encoder.encode("data:" + JSON.stringify({ - [settledKey]: promise._data ?? null - }) + "\n\n")); - } -} -var createDeferredReadableStream_1 = responses.createDeferredReadableStream = createDeferredReadableStream; -responses.defer = defer2; -var isDeferredData_1 = responses.isDeferredData = isDeferredData; -var isRedirectResponse_1 = responses.isRedirectResponse = isRedirectResponse; -var isRedirectStatusCode_1 = responses.isRedirectStatusCode = isRedirectStatusCode; -var isResponse_1 = responses.isResponse = isResponse; -var json_1 = responses.json = json2; -var redirect_1 = responses.redirect = redirect2; -responses.redirectDocument = redirectDocument; -responses.replace = replace; -function clone(_object) { - const init = {}; - for (const property in _object) { - init[property] = _object[property]; - } - return init; -} -function getURLParameters(request, path = "") { - const url = new URL(request.url); - const match = matchPath(path, url.pathname); - return { - ...Object.fromEntries(new URL(request.url).searchParams.entries()), - ...match == null ? void 0 : match.params - }; -} -function stripIndexParameter(request) { - const url = new URL(request.url); - const indexValues = url.searchParams.getAll("index"); - const indexValuesToKeep = []; - url.searchParams.delete("index"); - for (const indexValue of indexValues) { - if (indexValue) { - indexValuesToKeep.push(indexValue); - } - } - for (const toKeep of indexValuesToKeep) { - url.searchParams.append("index", toKeep); - } - return new Request(url.href, { ...clone(request), duplex: "half" }); -} -function stripDataParameter(request) { - const url = new URL(request.url); - url.searchParams.delete("_data"); - return new Request(url.href, { ...clone(request), duplex: "half" }); -} -function createArgumentsFrom({ event, loadContext, path }) { - const request = stripDataParameter(stripIndexParameter(event.request.clone())); - const parameters = getURLParameters(request, path); - return { - request, - params: parameters, - context: loadContext - }; -} -function isMethod(request, methods) { - return methods.includes(request.method.toLowerCase()); -} -function isLoaderMethod(request) { - return isMethod(request, ["get"]); -} -function isActionMethod(request) { - return isMethod(request, ["post", "delete", "put", "patch", "head"]); -} -function isActionRequest(request, spaMode = false) { - const url = new URL(request.url); - const qualifies = spaMode ? true : url.searchParams.get("_data"); - return isActionMethod(request) && qualifies; -} -function isLoaderRequest(request, spaMode = false) { - const url = new URL(request.url); - const qualifies = spaMode ? true : url.searchParams.get("_data"); - return isLoaderMethod(request) && qualifies; -} -function errorResponseToJson(errorResponse) { - return json_1(errorResponse.error || { message: "Unexpected Server Error" }, { - status: errorResponse.status, - statusText: errorResponse.statusText, - headers: { - "X-Remix-Error": "yes" - } - }); -} -function isRemixResponse(response) { - return Array.from(response.headers.keys()).some((key) => key.toLowerCase().startsWith("x-remix-")); -} -async function handleRequest({ defaultHandler: defaultHandler2, errorHandler, event, loadContext, routes: routes2 }) { - var _a; - const isSPAMode = false; - const url = new URL(event.request.url); - const routeId = url.searchParams.get("_data"); - const route = routeId ? routes2[routeId] : void 0; - const _arguments = { - request: event.request, - params: getURLParameters(event.request, route == null ? void 0 : route.path), - context: loadContext - }; - try { - if (isLoaderRequest(event.request, isSPAMode) && (route == null ? void 0 : route.module.workerLoader)) { - return await handleLoader({ - event, - loader: route.module.workerLoader, - routeId: route.id, - routePath: route.path, - loadContext - }).then(responseHandler); - } - if (isActionRequest(event.request, isSPAMode) && ((_a = route == null ? void 0 : route.module) == null ? void 0 : _a.workerAction)) { - return await handleAction({ - event, - action: route.module.workerAction, - routeId: route.id, - routePath: route.path, - loadContext - }).then(responseHandler); - } - } catch (error) { - const handler = (error2) => errorHandler(error2, _arguments); - return _errorHandler({ error, handler }); - } - return defaultHandler2(_arguments); -} -async function handleLoader({ event, loadContext, loader, routeId, routePath }) { - const _arguments = createArgumentsFrom({ event, loadContext, path: routePath }); - const result = await loader(_arguments); - if (result === void 0) { - throw new Error(`You defined a loader for route "${routeId}" but didn't return anything from your \`worker loader\` function. Please return a value or \`null\`.`); - } - if (isDeferredData_1(result)) { - if (result.init && isRedirectStatusCode_1(result.init.status || 200)) { - return redirect_1(new Headers(result.init.headers).get("Location"), result.init); - } - const body = createDeferredReadableStream_1(result, event.request.signal, ServerMode_1.Production); - const init = result.init || {}; - const headers = new Headers(init.headers); - headers.set("Content-Type", "text/remix-deferred"); - init.headers = headers; - return new Response(body, init); - } - return isResponse_1(result) ? result : json_1(result); -} -async function handleAction({ action, event, loadContext, routeId, routePath }) { - const _arguments = createArgumentsFrom({ event, loadContext, path: routePath }); - const result = await action(_arguments); - if (result === void 0) { - throw new Error(`You defined an action for route "${routeId}" but didn't return anything from your \`worker action\` function. Please return a value or \`null\`.`); - } - return isResponse_1(result) ? result : json_1(result); -} -function _errorHandler({ error, handler: handleError }) { - if (isResponse_1(error)) { - error.headers.set("X-Remix-Catch", "yes"); - return error; - } - if (isRouteErrorResponse(error)) { - error.error && handleError(error.error); - return errorResponseToJson(error); - } - const errorInstance = error instanceof Error ? error : new Error("Unexpected Server Error"); - handleError(errorInstance); - return json_1({ message: errorInstance.message }, { - status: 500, - headers: { - "X-Remix-Error": "yes" - } - }); -} -function responseHandler(response) { - if (isRedirectResponse_1(response)) { - const headers2 = new Headers(response.headers); - headers2.set("X-Remix-Redirect", headers2.get("Location")); - headers2.set("X-Remix-Status", String(response.status)); - headers2.delete("Location"); - if (response.headers.get("Set-Cookie") !== null) { - headers2.set("X-Remix-Revalidate", "yes"); - } - return new Response(null, { - status: 204, - headers: headers2 - }); - } - const isNotRemixResponse = !isRemixResponse(response); - const headers = isNotRemixResponse ? new Headers(response.headers) : response.headers; - if (isNotRemixResponse) { - headers.set("X-Remix-Response", "yes"); - if (response.status < 200) { - return new Response(response.body, { headers }); - } - return new Response(response.body, { headers, status: response.status, statusText: response.statusText }); - } - return response; -} -const _self = self; -function createContext(event) { - var _a, _b; - const context = ((_b = (_a = entry.module).getLoadContext) == null ? void 0 : _b.call(_a, event)) || {}; - return { - event, - fetchFromServer: () => fetch(event.request.clone()), - // NOTE: we want the user to override the above properties if needed. - ...context - }; -} -const defaultHandler = entry.module.defaultFetchHandler || ((event) => fetch(event.request.clone())); -const defaultErrorHandler = entry.module.errorHandler || ((error, { request }) => { - if (!request.signal.aborted) { - console.error(error); - } -}); -_self.__workerManifest = { - // Re-publishing this. Somehow it's not available as `latest` - assets, - routes -}; -_self.addEventListener( - "fetch", - (event) => { - const response = handleRequest({ - event, - routes, - defaultHandler, - errorHandler: defaultErrorHandler, - loadContext: createContext(event) - }); - return event.respondWith(response); - } -); diff --git a/web/vite.config.ts b/web/vite.config.ts index 0eed22a..54066fb 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,7 +1,6 @@ import { vitePlugin as remix } from "@remix-run/dev"; import { defineConfig } from "vite"; import tsconfigPaths from "vite-tsconfig-paths"; -import { remixPWA } from "@remix-pwa/dev"; export default defineConfig({ plugins: [ @@ -13,8 +12,5 @@ export default defineConfig({ }, }), tsconfigPaths(), - remixPWA({ - registerSW: "script", - }), ], });