From 2ee914c3440994609b7dcd5987555ebf816bbc33 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Fri, 15 Nov 2024 15:04:24 -0800 Subject: [PATCH 01/10] Remove build.minify: true, add v3_lazyRouteDiscovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • build: { minify: true } causes variable names to be mangled in the SSR build of the app, which means that Models will have the wrong name and will wind up pointing at non-existent (or wrong) D1 tables • v3_lazyRouteDiscovery is a new default behavior for remix that doesn’t require any other changes to enable --- apps/site/vite.config.ts | 4 +--- examples/remix-cms/vite.config.ts | 4 +--- templates/remix/vite.config.ts | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/site/vite.config.ts b/apps/site/vite.config.ts index 5704fda7..eaa5f35a 100644 --- a/apps/site/vite.config.ts +++ b/apps/site/vite.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ remix({ future: { v3_fetcherPersist: true, + v3_lazyRouteDiscovery: true, v3_relativeSplatPath: true, v3_throwAbortReason: true, }, @@ -26,7 +27,4 @@ export default defineConfig({ resolve: { mainFields: ["browser", "module", "main"], }, - build: { - minify: true, - }, }); diff --git a/examples/remix-cms/vite.config.ts b/examples/remix-cms/vite.config.ts index bc76fb56..eee688b5 100644 --- a/examples/remix-cms/vite.config.ts +++ b/examples/remix-cms/vite.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ remix({ future: { v3_fetcherPersist: true, + v3_lazyRouteDiscovery: true, v3_relativeSplatPath: true, v3_throwAbortReason: true, }, @@ -34,7 +35,4 @@ export default defineConfig({ resolve: { mainFields: ["browser", "module", "main"], }, - build: { - minify: true, - }, }); diff --git a/templates/remix/vite.config.ts b/templates/remix/vite.config.ts index cb8df32d..9d2c63ec 100644 --- a/templates/remix/vite.config.ts +++ b/templates/remix/vite.config.ts @@ -9,6 +9,7 @@ export default defineConfig({ remix({ future: { v3_fetcherPersist: true, + v3_lazyRouteDiscovery: true, v3_relativeSplatPath: true, v3_throwAbortReason: true, }, @@ -23,7 +24,4 @@ export default defineConfig({ resolve: { mainFields: ["browser", "module", "main"], }, - build: { - minify: true, - }, }); From bbf40df2e22cd7ae4146c7acb141c08e651f5ded Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Fri, 15 Nov 2024 15:26:01 -0800 Subject: [PATCH 02/10] :memo: Update remix v1 link, add --remote, grammar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit you need to pass the --remote flag to the newest version of wrangler’s migrations apply command in order to get it to run on the production instance of the D1 DB --- packages/superflare/docs/database/relationships.md | 2 +- packages/superflare/docs/deploying.md | 2 +- packages/superflare/docs/events.md | 2 +- packages/superflare/docs/getting-started.md | 2 +- packages/superflare/docs/scheduled-tasks.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/superflare/docs/database/relationships.md b/packages/superflare/docs/database/relationships.md index ccb025ea..768ee497 100644 --- a/packages/superflare/docs/database/relationships.md +++ b/packages/superflare/docs/database/relationships.md @@ -272,7 +272,7 @@ await profile.save(); ## Migrations and Relationships -Superflare expects you to manually define [migrations](/database/migrations) which map to your relationships. For example, if your `Post` mdoel `belongsTo` your `User` model, you would need to include a column for `userId` in a migration: +Superflare expects you to manually define [migrations](/database/migrations) which map to your relationships. For example, if your `Post` model `belongsTo` your `User` model, you would need to include a column for `userId` in a migration: ```ts import { Schema } from "superflare"; diff --git a/packages/superflare/docs/deploying.md b/packages/superflare/docs/deploying.md index f0bd272c..0f1ceaf6 100644 --- a/packages/superflare/docs/deploying.md +++ b/packages/superflare/docs/deploying.md @@ -9,6 +9,6 @@ To deploy your Superflare app to production, you'll need to use `npx wrangler`. ## Checklist -- Make sure you've run D1 migrations against your production database before deploying with `npx wrangler d1 migrations apply `. +- Make sure you've run D1 migrations against your production database before deploying with `npx wrangler d1 migrations apply --remote`. - Make sure you've set an `APP_KEY` secret with `npx wrangler secret put APP_KEY`. - If you're using `wrangler.json` to store your config, be sure to pass the `-j` flag after each `wrangler` command. I'm sorry, but I'm also not sorry. diff --git a/packages/superflare/docs/events.md b/packages/superflare/docs/events.md index dd58ec5e..78ef27b6 100644 --- a/packages/superflare/docs/events.md +++ b/packages/superflare/docs/events.md @@ -9,7 +9,7 @@ Events are a powerful way to tell other parts of your application that something Superflare provides `Events` to emit changes to other parts of the application, and `Listeners` to subscribe to those events. -Imagine that you a file upload has finished processing. You might emit a `FileProcessed` event, and then a listener `SendFileProcessedNotification` could be used to alert the user via email or Slack that the file has been processed. +Imagine that you want to know when a file upload has finished processing. You might emit a `FileProcessed` event, and then a listener `SendFileProcessedNotification` could be used to alert the user via email or Slack that the file has been processed. ## Defining Events diff --git a/packages/superflare/docs/getting-started.md b/packages/superflare/docs/getting-started.md index 86d2defc..bf4a11fe 100644 --- a/packages/superflare/docs/getting-started.md +++ b/packages/superflare/docs/getting-started.md @@ -65,7 +65,7 @@ export default { } satisfies ExportedHandler }>; ``` -Behind the scenes, Superflare creates a [cookie-based session storage](https://remix.run/docs/en/1.14.1/utils/sessions#createcookiesessionstorage) for you and instantiates the Superflare request handler. +Behind the scenes, Superflare creates a [cookie-based session storage](https://remix.run/docs/en/main/utils/sessions#createcookiesessionstorage) for you and instantiates the Superflare request handler. It also injects `auth`, `session`, and `cloudflare` objects into your `AppContext`, which is provided to your loaders and actions. The `cloudflare` object matches the return value of [Wrangler’s `getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy). diff --git a/packages/superflare/docs/scheduled-tasks.md b/packages/superflare/docs/scheduled-tasks.md index db6b1c6f..3b54c1a8 100644 --- a/packages/superflare/docs/scheduled-tasks.md +++ b/packages/superflare/docs/scheduled-tasks.md @@ -96,4 +96,4 @@ You can also choose to import a Date library like [Luxon](https://moment.github. ## Testing Scheduled Tasks -To test your scheduled tasks, can open a browser visit `/__scheduled`. This will fire the `scheduled` function of your worker entrypoint. +To test your scheduled tasks, open a browser and visit `/__scheduled`. This will fire the `scheduled` function of your worker entrypoint. From d0e38b4c395b38cf930196d64b5de9400de3e562 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Sun, 17 Nov 2024 10:34:51 -0800 Subject: [PATCH 03/10] :memo: Document vite.config, update worker example --- packages/superflare/docs/getting-started.md | 60 ++++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/packages/superflare/docs/getting-started.md b/packages/superflare/docs/getting-started.md index bf4a11fe..2752ff8e 100644 --- a/packages/superflare/docs/getting-started.md +++ b/packages/superflare/docs/getting-started.md @@ -29,28 +29,29 @@ In an existing Remix app on the Cloudflare Workers adapter, run: npm install @superflare/remix ``` -Then, in your `worker.ts` file, import the `handleFetch` function from `@superflare/remix`, and import your local `superflare.config.ts` as `config`: +Then, in your `worker.ts` file, import the `handleFetch` function from `@superflare/remix`, and import your local `superflare.config.ts` as `config`. Superflare handles building and providing the load context, so you’ll be able to delete a lot of the code required with the [default Remix adapter](https://github.com/remix-run/remix/blob/main/templates/cloudflare-workers/server.ts): ```ts import { createRequestHandler, type ServerBuild } from "@remix-run/cloudflare"; import { handleFetch } from "@superflare/remix"; import config from "./superflare.config"; import * as build from "./build/server"; -import __STATIC_CONTENT_MANIFEST from "__STATIC_CONTENT_MANIFEST"; -const MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST); -const handleRemixRequest = createRequestHandler(build as any as ServerBuild); +const handleRequest = createRequestHandler(build as any as ServerBuild); export default { async fetch(request, env, ctx) { - // ... - - return await handleFetch(request, env, ctx, config, handleRemixRequest); + try { + return await handleFetch(request, env, ctx, config, handleRequest); + } catch (error) { + console.log(error); + return new Response("An unexpected error occurred", { status: 500 }); + } }, -} satisfies ExportedHandler }>; +} satisfies ExportedHandler; ``` -If you plan to use [Queues](/queues), you'll also need to import the `handleQueue` function from `superflare` and handle that in your `worker.ts` file: +If you plan to use [Queues](/queues), you’ll also need to import the `handleQueue` function from `superflare` and add that to your `worker.ts` file: ```ts import { handleQueue } from 'superflare'; @@ -62,12 +63,41 @@ export default { async queue(batch, env, ctx) { return handleQueue(batch, env, ctx, config); }, -} satisfies ExportedHandler }>; +} satisfies ExportedHandler; ``` -Behind the scenes, Superflare creates a [cookie-based session storage](https://remix.run/docs/en/main/utils/sessions#createcookiesessionstorage) for you and instantiates the Superflare request handler. +For local development, Remix uses Vite’s dev server with a [Cloudflare Proxy Vite plugin](https://remix.run/docs/en/main/guides/vite#cloudflare-proxy) that invokes [`getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy) to provide [bindings](https://developers.cloudflare.com/workers/wrangler/api/#supported-bindings) to your application from outside of the deployed `workersd` environment. Superflare has an additional entry point, `@superflare/remix/dev`, that exports `superflareDevProxyVitePlugin`, which adds Superflare support and can be used in place of Remix’s proxy plugin in your Vite config: -It also injects `auth`, `session`, and `cloudflare` objects into your `AppContext`, which is provided to your loaders and actions. The `cloudflare` object matches the return value of [Wrangler’s `getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy). +```ts +// vite.config.ts + +import { vitePlugin as remix } from "@remix-run/dev"; +import { superflareDevProxyVitePlugin } from "@superflare/remix/dev"; +import { defineConfig } from "vite"; +import tsconfigPaths from "vite-tsconfig-paths"; + +export default defineConfig({ + plugins: [ + superflareDevProxyVitePlugin(), + remix(), + tsconfigPaths(), + ], + ssr: { + resolve: { + conditions: ["workerd", "worker", "browser"], + }, + }, + resolve: { + mainFields: ["browser", "module", "main"], + }, +}); +``` + +{% callout title="Vite config" %} +**Do not** use `build: { minify: true }` in your Vite config. This will mangle the variable names of the `workerd` (SSR) build and change the names of your [models](/models), which will in turn break the mapping between those models and their corresponding DB tables. Vite’s [default minify behavior](https://vite.dev/config/build-options.html#build-minify) is to minify the client build and leave the SSR build untouched, which is what we want. +{% /callout %} + +The Superflare Remix integration creates a [cookie-based session storage](https://remix.run/docs/en/main/utils/sessions#createcookiesessionstorage) and injects `auth`, `session`, and `cloudflare` objects into your load context (the `AppContext` type), which is provided to your loaders and actions. The `cloudflare` object matches the return value of [Wrangler’s `getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy). {% callout title="Cookie Monster" %} Superflare automatically commits your session data to the outgoing response's `set-cookie` header, so you don't need to worry about that like you do in a standard Remix app. @@ -75,9 +105,11 @@ Superflare automatically commits your session data to the outgoing response's `s ## Workers vs Pages -I'd _love_ to use Cloudflare Pages for all the things. It's a nice abstraction on top of Workers and it already supports a ton of existing frameworks. +I’d _love_ to use Cloudflare Pages for all the things. It’s a nice abstraction on top of Workers and it already supports a ton of existing frameworks. + +Unfortunately, support for the latest and greatest things, like Queues and Cron Triggers (i.e. scheduled tasks), is delayed on Pages. Cloudflare maintains a [support table](https://developers.cloudflare.com/workers/static-assets/compatibility-matrix/) comparing the two platforms’ support for Cloudflare features. -Unfortunately, support for the latest and greatest things, like Queues, is delayed on Pages. For the time being, Superflare is designed for Workers. But I've definitely built it with Pages in mind and hope to switch to it as soon as I can! +For the time being, Superflare is designed for Workers. But I’ve definitely built it with Pages in mind and hope to support it as soon as possible. ## `AsyncLocalStorage` From 2283512cdee37c80bc0b6b934aaff77cb6b61cf2 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Sun, 17 Nov 2024 10:35:37 -0800 Subject: [PATCH 04/10] :memo: Update defunct sessions doc instructions --- packages/superflare/docs/sessions.md | 41 ++-------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/packages/superflare/docs/sessions.md b/packages/superflare/docs/sessions.md index ce6c28ab..0fa43068 100644 --- a/packages/superflare/docs/sessions.md +++ b/packages/superflare/docs/sessions.md @@ -7,46 +7,11 @@ Sessions provide a way to store information about users across requests. Superfl The `SuperflareSession` instance keeps track of any changes to the session, and Superflare automatically commits the changes to the session store on the outgoing response. -## Creating a `SuperflareSession` +## Creating sessions -_The following examples assume you are using Remix. They will be updated when Superflare supports other frameworks._ +_The following instructions assume you are using Remix. They will be updated when Superflare supports other frameworks._ -To create a `SuperflareSession` instance, pass a valid `Session` instance: - -```ts -// worker.ts - -import { SuperflareSession } from "superflare"; - -// Create a Remix `session`... -const session = "..."; - -const superflareSession = new SuperflareSession(session); -``` - -Then, you can inject the session into your Remix `loadContext`: - -```ts -// worker.ts - -const loadContext = { session, env }; - -try { - const config = getConfig({ request, env, ctx }); - - return handleFetch( - { - config, - session, - getSessionCookie: () => - sessionStorage.commitSession(session.getSession()), - }, - () => remixHandler(request, loadContext) - ); -} catch (error) { - return new Response("Internal Server Error", { status: 500 }); -} -``` +The `@superflare/remix` package exports `handleFetch`, which takes care of session creation and makes the session available on your Remix `AppContext` in deployed workers. There is an additional entry point, `@superflare/remix/dev`, that exports `superflareDevProxyVitePlugin` to provide the same automatic session handling in local dev when using the Vite dev server. See the [Getting Started](/getting-started) guide for details. ## Using sessions From e73d8936eda8409f55aa47fca44b83729bbb0532 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Sun, 17 Nov 2024 11:12:19 -0800 Subject: [PATCH 05/10] :memo: Add handleScheduled to Getting Started doc --- packages/superflare/docs/getting-started.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/superflare/docs/getting-started.md b/packages/superflare/docs/getting-started.md index 2752ff8e..9266c82a 100644 --- a/packages/superflare/docs/getting-started.md +++ b/packages/superflare/docs/getting-started.md @@ -66,6 +66,23 @@ export default { } satisfies ExportedHandler; ``` +Likewise for using [Cron Triggers](/scheduled-tasks): + +```ts +import { handleScheduled } from 'superflare'; +import config './superflare.config'; + +export default { + // ... + + async scheduled(event, env, ctx) { + return await handleScheduled(event, env, ctx, config, (schedule) => { + // Define a schedule + }); + }, +} satisfies ExportedHandler; +``` + For local development, Remix uses Vite’s dev server with a [Cloudflare Proxy Vite plugin](https://remix.run/docs/en/main/guides/vite#cloudflare-proxy) that invokes [`getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy) to provide [bindings](https://developers.cloudflare.com/workers/wrangler/api/#supported-bindings) to your application from outside of the deployed `workersd` environment. Superflare has an additional entry point, `@superflare/remix/dev`, that exports `superflareDevProxyVitePlugin`, which adds Superflare support and can be used in place of Remix’s proxy plugin in your Vite config: ```ts From 1076ca52bddee3797b8ffff9b1dc949728a479f0 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Sun, 17 Nov 2024 11:13:01 -0800 Subject: [PATCH 06/10] :memo: Mention Vite config gotcha in models doc --- packages/superflare/docs/models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/superflare/docs/models.md b/packages/superflare/docs/models.md index 4b1f0f21..bdb88444 100644 --- a/packages/superflare/docs/models.md +++ b/packages/superflare/docs/models.md @@ -47,7 +47,7 @@ export interface Post extends PostRow {} ``` {% callout title="Model class names" %} -Model class names are automatically converted to pluralized versions when referencing table names. For example, a `Post` model would have a corresponding `posts` table, and a `Person` model would have a corresponding `people` table. +Model class names are automatically converted to pluralized versions when referencing table names. For example, a `Post` model would have a corresponding `posts` table, and a `Person` model would have a corresponding `people` table. This means model class names must not be [mangled](https://github.com/terser/terser?tab=readme-ov-file#cli-mangle-options) when deployed, so do not use `build: { minify: true }` in your Vite config (Vite’s [default minify behavior](https://vite.dev/config/build-options.html#build-minify) is to minify the client build and leave the SSR build untouched). {% /callout %} Superflare provides utilities to help you keep your model's type definition in sync with your database. From 734b3b7a17bd1e67349ca2d320036c939d9902d3 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Sun, 17 Nov 2024 11:13:34 -0800 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=93=9D=20Update=20authentication=20?= =?UTF-8?q?doc=20for=20@superflare/remix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/superflare/docs/security/authentication.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/superflare/docs/security/authentication.md b/packages/superflare/docs/security/authentication.md index fb8ba2bf..5a9f72cd 100644 --- a/packages/superflare/docs/security/authentication.md +++ b/packages/superflare/docs/security/authentication.md @@ -16,8 +16,8 @@ However, Superflare takes the stance that **authentication should be built in**, To set up authentication, you need to do a few things: 1. Add a `User` model (and a `users` table) -2. Ensure you've created an instance of [`SuperflareSession`](/sessions) -3. Create an instance of `SuperflareAuth` (with a session) and pass it to a place your application code can access it during a request (like a Remix `AppContext`). +2. Ensure you’ve created an instance of [`SuperflareSession`](/sessions) (handled by `@superflare/remix` if you’re using that already) +3. Create an instance of `SuperflareAuth` (with a session) and pass it so your application code can access it during a request (handled by `@superflare/remix` if you’re using that already) 4. Add some sort of `/register` and `/login` routes to your application so users can log in. {% callout title="Batteries-included" %} @@ -26,11 +26,11 @@ If you've created a Superflare app with `npx superflare new`, you should already ## Register and Login pages -Superflare provides basic `/register` and `/login` routes and forms for you to use. You can use these as-is, or you can copy the code and modify it to your liking. +The [Superflare Remix template](https://github.com/jplhomer/superflare/tree/main/templates/remix) provides basic `/register` and `/login` routes and forms for you to use. You can use these as-is, or you can copy the code and modify it to your liking. ## Protecting routes -You can protect routes by using the `SuperflareAuth` instance you created in your app's entrypoint. For the purpose of this example, we'll pretend you're using Remix, and that you've injected the `SuperflareAuth` instance into the `AppContext` as `auth`: +You can protect routes by using the `SuperflareAuth` instance from your app’s entrypoint. For the purpose of this example, we’ll pretend you're using `@superflare/remix`, which injects the `SuperflareAuth` instance into the `AppContext` as `auth`: ```ts // routes/my-secret-route.tsx From a69eef69e09e6903f5bb93d98efee191c8ce394b Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Mon, 18 Nov 2024 10:59:44 -0800 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=93=9D=20Update=20CLI=20docs=20with?= =?UTF-8?q?=20changes=20to=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/superflare/docs/reference/cli.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/superflare/docs/reference/cli.md b/packages/superflare/docs/reference/cli.md index d134eea4..838f3ba2 100644 --- a/packages/superflare/docs/reference/cli.md +++ b/packages/superflare/docs/reference/cli.md @@ -35,14 +35,22 @@ By default, it: 4. (Optional with `-s`) [Seeds](/database/seeding) your local database 5. Parses the column types in your local database and syncs them to `superflare.env.d.ts` to be used by your [Models](/models) -## `superflare dev` +It takes the binding name of your D1 database as a positional argument, which is `DB` by default: + +```bash +npx superflare migrate DB +``` -The `dev` command starts a local development server for your Superflare app. It's effectively a wrapper around `wrangler dev --local`. It will be more useful in the context of Cloudflare Pages because all bindings are passed via CLI flags, which can be tedious to type out. +Superflare’s `migrate` command is intended for use in development, both for managing your local database (e.g. wiping it clean to start fresh, seeding it, running migrations) and for creating the TypeScript types to match your database schema. To run your migrations in production when you are ready to deploy your latest, use wrangler directly: ```bash -npx superflare dev +npx wrangler d1 migrations apply DB --remote ``` +## `superflare dev` + +The `dev` command starts a local development server for your Superflare app. It’s a wrapper around two commands: `remix vite:dev` (starts the main Vite dev server) and `wrangler dev -j` (enables working with [Durable Object bindings](https://developers.cloudflare.com/workers/wrangler/api/#supported-bindings)). You can use it directly or put it in your `package.json`’s scripts: `"dev": "superflare dev"`. + ## `superflare generate` Scaffold useful things in your Superflare app: From 6c4a22b5d935d60b7599bd61d1fddf92160e5447 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Mon, 18 Nov 2024 11:01:14 -0800 Subject: [PATCH 09/10] =?UTF-8?q?Replace=20local=20docsearch.css=20?= =?UTF-8?q?=E2=86=92=20@docsearch/css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also, upgrade from v3.6.1 → v3.8.0 (latest) --- apps/site/app/root.tsx | 1 + apps/site/app/styles/docsearch.css | 503 ----------------------------- apps/site/app/styles/tailwind.css | 11 +- apps/site/package.json | 3 +- pnpm-lock.yaml | 296 +++++++++-------- 5 files changed, 161 insertions(+), 653 deletions(-) delete mode 100644 apps/site/app/styles/docsearch.css diff --git a/apps/site/app/root.tsx b/apps/site/app/root.tsx index c7e734b4..31dfb615 100644 --- a/apps/site/app/root.tsx +++ b/apps/site/app/root.tsx @@ -12,6 +12,7 @@ import { ScrollRestoration, useLoaderData, } from "@remix-run/react"; +import "@docsearch/css"; import "focus-visible"; import "./styles/tailwind.css"; diff --git a/apps/site/app/styles/docsearch.css b/apps/site/app/styles/docsearch.css deleted file mode 100644 index 97efadd7..00000000 --- a/apps/site/app/styles/docsearch.css +++ /dev/null @@ -1,503 +0,0 @@ -/*! @docsearch/css 3.1.0 | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */ -:root { - --docsearch-primary-color: red; - --docsearch-highlight-color: var(--docsearch-primary-color); - --docsearch-muted-color: theme('colors.slate.500'); - --docsearch-emphasis-color: theme('colors.slate.900'); - --docsearch-logo-color: #5468ff; - --docsearch-modal-width: 35rem; - --docsearch-modal-height: 37.5rem; - --docsearch-modal-background: theme('colors.white'); - --docsearch-modal-shadow: theme('boxShadow.xl'); - --docsearch-searchbox-height: 3rem; - --docsearch-hit-color: theme('colors.slate.700'); - --docsearch-hit-active-color: theme('colors.sky.600'); - --docsearch-hit-active-background: theme('colors.slate.100'); - --docsearch-footer-height: 3rem; - --docsearch-border-color: theme('colors.slate.200'); - --docsearch-input-color: theme('colors.slate.900'); - --docsearch-heading-color: theme('colors.slate.900'); - --docsearch-key-background: theme('colors.slate.100'); - --docsearch-key-hover-background: theme('colors.slate.200'); - --docsearch-key-color: theme('colors.slate.500'); - --docsearch-action-color: theme('colors.slate.400'); - --docsearch-action-active-background: theme('colors.slate.200'); - --docsearch-loading-background: theme('colors.slate.400'); - --docsearch-loading-foreground: theme('colors.slate.900'); -} - -.dark { - --docsearch-highlight-color: var(--docsearch-primary-color); - --docsearch-muted-color: theme('colors.slate.400'); - --docsearch-emphasis-color: theme('colors.white'); - --docsearch-logo-color: theme('colors.slate.300'); - --docsearch-modal-background: theme('colors.slate.800'); - --docsearch-modal-shadow: 0 0 0 1px theme('colors.slate.700'), - theme('boxShadow.xl'); - --docsearch-hit-color: theme('colors.slate.300'); - --docsearch-hit-active-color: theme('colors.sky.400'); - --docsearch-hit-active-background: rgb(51 65 85 / 0.3); - --docsearch-border-color: rgb(148 163 184 / 0.1); - --docsearch-heading-color: theme('colors.white'); - --docsearch-key-background: rgb(51 65 85 / 0.4); - --docsearch-key-hover-background: rgb(51 65 85 / 0.8); - --docsearch-key-color: theme('colors.slate.400'); - --docsearch-input-color: theme('colors.white'); - --docsearch-action-color: theme('colors.slate.500'); - --docsearch-action-active-background: theme('colors.slate.700'); - --docsearch-loading-background: theme('colors.slate.500'); - --docsearch-loading-foreground: theme('colors.white'); -} - -.DocSearch--active { - overflow: hidden !important; -} - -.DocSearch-Container { - position: fixed; - z-index: 200; - top: 0; - left: 0; - width: 100vw; - height: 100vh; - height: -webkit-fill-available; - height: calc(var(--docsearch-vh, 1vh) * 100); - background-color: rgb(15 23 42 / 0.5); - backdrop-filter: blur(theme('backdropBlur.DEFAULT')); - cursor: auto; -} - -.DocSearch-Link { - appearance: none; - background: none; - border: 0; - color: var(--docsearch-highlight-color); - cursor: pointer; - font: inherit; -} - -.DocSearch-Modal { - position: relative; - overflow: hidden; - width: 100%; - max-width: 100%; - height: 100vh; - height: -webkit-fill-available; - height: calc(var(--docsearch-vh, 1vh) * 100); - background: var(--docsearch-modal-background); -} - -.DocSearch-SearchBar { - display: flex; - height: var(--docsearch-searchbox-height); - border-bottom: 1px solid var(--docsearch-border-color); -} - -.DocSearch-Form { - position: relative; - width: 100%; - display: flex; -} - -.DocSearch-Input { - appearance: none; - color: var(--docsearch-input-color); - flex: 1; - font-size: 1rem; - background: transparent; - padding: 0 1rem 0 3rem; - outline: none; -} - -.DocSearch-Input::placeholder { - color: theme('colors.slate.400'); - opacity: 1; -} - -.DocSearch-Input::-webkit-search-cancel-button, -.DocSearch-Input::-webkit-search-decoration, -.DocSearch-Input::-webkit-search-results-button, -.DocSearch-Input::-webkit-search-results-decoration { - display: none; -} - -.DocSearch-Reset { - display: none; -} - -.DocSearch-Container--Stalled .DocSearch-MagnifierLabel, -.DocSearch-LoadingIndicator { - display: none; -} - -.DocSearch-Container--Stalled .DocSearch-LoadingIndicator { - position: absolute; - top: 0.875rem; - left: 1rem; - display: flex; - align-items: center; - justify-content: center; - width: 1.25rem; - height: 1.25rem; - pointer-events: none; -} - -.DocSearch-LoadingIndicator svg { - height: 1rem; - width: 1rem; - overflow: visible; -} - -.DocSearch-LoadingIndicator path, -.DocSearch-LoadingIndicator circle { - vector-effect: non-scaling-stroke; -} - -.DocSearch-LoadingIndicator circle { - stroke: var(--docsearch-loading-background); - stroke-opacity: 1; -} - -.DocSearch-LoadingIndicator path { - stroke: var(--docsearch-loading-foreground); - stroke-opacity: 1; -} - -.DocSearch-MagnifierLabel { - position: absolute; - top: 0.875rem; - left: 1rem; - pointer-events: none; - width: 1.25rem; - height: 1.25rem; - background: url("data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.293 17.707a1 1 0 0 0 1.414-1.414l-1.414 1.414ZM9 14a5 5 0 0 1-5-5H2a7 7 0 0 0 7 7v-2ZM4 9a5 5 0 0 1 5-5V2a7 7 0 0 0-7 7h2Zm5-5a5 5 0 0 1 5 5h2a7 7 0 0 0-7-7v2Zm8.707 12.293-3.757-3.757-1.414 1.414 3.757 3.757 1.414-1.414ZM14 9a4.98 4.98 0 0 1-1.464 3.536l1.414 1.414A6.98 6.98 0 0 0 16 9h-2Zm-1.464 3.536A4.98 4.98 0 0 1 9 14v2a6.98 6.98 0 0 0 4.95-2.05l-1.414-1.414Z' fill='%2394A3B8'/%3E%3C/svg%3E"); -} - -.dark .DocSearch-MagnifierLabel { - background: url("data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.293 17.707a1 1 0 0 0 1.414-1.414l-1.414 1.414ZM9 14a5 5 0 0 1-5-5H2a7 7 0 0 0 7 7v-2ZM4 9a5 5 0 0 1 5-5V2a7 7 0 0 0-7 7h2Zm5-5a5 5 0 0 1 5 5h2a7 7 0 0 0-7-7v2Zm8.707 12.293-3.757-3.757-1.414 1.414 3.757 3.757 1.414-1.414ZM14 9a4.98 4.98 0 0 1-1.464 3.536l1.414 1.414A6.98 6.98 0 0 0 16 9h-2Zm-1.464 3.536A4.98 4.98 0 0 1 9 14v2a6.98 6.98 0 0 0 4.95-2.05l-1.414-1.414Z' fill='%2364748b'/%3E%3C/svg%3E"); -} - -.DocSearch-MagnifierLabel svg { - display: none; -} - -.DocSearch-Dropdown { - height: 100%; - max-height: calc( - var(--docsearch-vh, 1vh) * 100 - var(--docsearch-searchbox-height) - - var(--docsearch-footer-height) - ); - overflow-y: auto; - overflow-y: overlay; - padding: 1rem 0.5rem; - scrollbar-color: var(--docsearch-muted-color) - var(--docsearch-modal-background); - scrollbar-width: thin; -} - -.DocSearch-Dropdown::-webkit-scrollbar { - width: 12px; -} - -.DocSearch-Dropdown::-webkit-scrollbar-track { - background: transparent; -} - -.DocSearch-Dropdown::-webkit-scrollbar-thumb { - background-color: var(--docsearch-muted-color); - border: 3px solid var(--docsearch-modal-background); - border-radius: 20px; -} - -.DocSearch-StartScreen { - padding: 2rem 1rem; - text-align: center; -} - -.DocSearch-Label { - font-size: 0.75rem; - line-height: 1rem; -} - -.DocSearch-Help, -.DocSearch-Label { - color: var(--docsearch-muted-color); -} - -.DocSearch-Help { - font-size: 0.875rem; -} - -.DocSearch-Title { - font-size: 0.875rem; - color: var(--docsearch-muted-color); -} - -.DocSearch-Title strong { - color: var(--docsearch-emphasis-color); - font-weight: inherit; -} - -.DocSearch-Logo a { - display: flex; - align-items: center; -} - -.DocSearch-Logo svg { - color: var(--docsearch-logo-color); - margin-left: 0.5rem; -} - -.DocSearch-Hits + .DocSearch-Hits { - margin-top: 1.5rem; -} - -.DocSearch-Hits mark { - background: none; - color: var(--docsearch-hit-active-color); -} - -.DocSearch-HitsFooter { - display: none; -} - -.DocSearch-Hit { - display: flex; - position: relative; -} - -.DocSearch-Hit--deleting, -.DocSearch-Hit--favoriting { - transform: scale(1); - transition: all 0.0001s linear; -} - -.DocSearch-Hit a { - display: block; - width: 100%; - border-radius: theme('borderRadius.lg'); -} - -.DocSearch-Hit-source, -.DocSearch-NoResults .DocSearch-Help { - margin-left: 0.75rem; - margin-bottom: 0.5rem; - font-family: theme('fontFamily.display'); - color: var(--docsearch-heading-color); - font-size: 0.875rem; - font-weight: 500; - line-height: 1.5rem; -} - -.DocSearch-Hit-Tree { - width: 0.5rem; -} - -.DocSearch-Hit-Tree * { - display: none; -} - -.DocSearch-Hit[aria-selected='true'] a, -.DocSearch-Prefill:hover, -.DocSearch-Prefill:focus { - background-color: var(--docsearch-hit-active-background); - outline: none; -} - -.DocSearch-Hit[aria-selected='true'] mark { - text-decoration: underline; -} - -.DocSearch-Hit-Container, -.DocSearch-Prefill { - display: flex; - align-items: center; - padding: 0.5rem 0.75rem; - color: var(--docsearch-hit-color); -} - -.DocSearch-Hit-icon { - display: none; -} - -.DocSearch-Hit-action { - color: var(--docsearch-action-color); - stroke-width: 2; -} - -.DocSearch-Hit-action + .DocSearch-Hit-action { - margin-left: 0.375rem; -} - -.DocSearch-Hit-action-button { - border-radius: 50%; - color: inherit; - height: 1.5rem; - width: 1.5rem; - display: flex; - align-items: center; - justify-content: center; -} - -.DocSearch-Hit-action svg { - height: 1.125rem; - width: 1.125rem; -} - -svg.DocSearch-Hit-Select-Icon { - display: none; -} - -.DocSearch-Hit[aria-selected='true'] .DocSearch-Hit-Select-Icon { - display: block; -} - -.DocSearch-Hit-action-button:focus, -.DocSearch-Hit-action-button:hover { - background: var(--docsearch-action-active-background); -} - -.DocSearch-Hit-content-wrapper { - position: relative; - flex: 1 1 auto; - display: flex; - flex-direction: column; - justify-content: center; - overflow-x: hidden; - text-overflow: ellipsis; - white-space: nowrap; - width: 80%; -} - -.DocSearch-Hit-title, -.DocSearch-Prefill { - font-size: 0.875rem; - line-height: 1.5rem; -} - -.DocSearch-Hit-path { - color: var(--docsearch-muted-color); - font-size: 0.75rem; - line-height: 1rem; -} - -.DocSearch-Hit[aria-selected='true'] .DocSearch-Hit-path, -.DocSearch-Hit[aria-selected='true'] .DocSearch-Hit-text, -.DocSearch-Hit[aria-selected='true'] .DocSearch-Hit-title, -.DocSearch-Hit[aria-selected='true'] mark, -.DocSearch-Prefill:hover, -.DocSearch-Prefill:focus { - color: var(--docsearch-hit-active-color); -} - -.DocSearch-NoResults .DocSearch-Screen-Icon { - display: none; -} - -.DocSearch-NoResults .DocSearch-Title { - text-align: center; - padding: 2rem 1rem 3rem; -} - -.DocSearch-NoResults-Prefill-List { - margin: 0 -0.5rem; - padding: 1rem 0.5rem 0; - border-top: 1px solid var(--docsearch-border-color); -} - -.DocSearch-Prefill { - width: 100%; - border-radius: theme('borderRadius.lg'); -} - -.DocSearch-Footer { - position: absolute; - bottom: 0; - display: flex; - flex-direction: row-reverse; - align-items: center; - justify-content: space-between; - flex-shrink: 0; - width: 100%; - height: var(--docsearch-footer-height); - z-index: 300; - border-top: 1px solid var(--docsearch-border-color); - padding: 0 1rem; -} - -.DocSearch-Commands { - display: none; -} - -.DocSearch-Cancel { - background: var(--docsearch-key-background); - color: var(--docsearch-key-color); - align-self: center; - flex: none; - font-size: 0.75rem; - user-select: none; - border-radius: theme('borderRadius.md'); - padding: 0 0.375rem; - height: 1.5rem; - margin-right: 1rem; -} - -.DocSearch-Cancel:hover { - background: var(--docsearch-key-hover-background); -} - -@screen sm { - .DocSearch-Container { - height: 100vh; - } - - .DocSearch-Modal { - height: auto; - border-radius: theme('borderRadius.xl'); - box-shadow: var(--docsearch-modal-shadow); - margin: 4rem auto auto; - width: auto; - max-width: var(--docsearch-modal-width); - } - - .DocSearch-Input { - font-size: 0.875rem; - } - - .DocSearch-Footer { - position: static; - } - - .DocSearch-Commands { - display: flex; - } - - .DocSearch-Commands li { - align-items: center; - display: flex; - } - - .DocSearch-Commands li:not(:last-of-type) { - margin-right: 1rem; - } - - .DocSearch-Commands-Key { - background: var(--docsearch-key-background); - color: var(--docsearch-key-color); - width: 1.5rem; - height: 1.25rem; - display: flex; - align-items: center; - justify-content: center; - border-radius: theme('borderRadius.md'); - margin-right: 0.375rem; - } - - .DocSearch-Dropdown { - height: auto; - max-height: calc( - var(--docsearch-modal-height) - var(--docsearch-searchbox-height) - - var(--docsearch-footer-height) - ); - } -} diff --git a/apps/site/app/styles/tailwind.css b/apps/site/app/styles/tailwind.css index ed8306b7..a6aa99a5 100644 --- a/apps/site/app/styles/tailwind.css +++ b/apps/site/app/styles/tailwind.css @@ -1,6 +1,5 @@ -@import 'tailwindcss/base'; -@import './fonts.css'; -@import './docsearch.css'; -@import './prism.css'; -@import 'tailwindcss/components'; -@import 'tailwindcss/utilities'; +@import "tailwindcss/base"; +@import "./fonts.css"; +@import "./prism.css"; +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; diff --git a/apps/site/package.json b/apps/site/package.json index 7fb401ef..a41292c3 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -15,7 +15,8 @@ }, "browserslist": "defaults, not ie <= 11", "dependencies": { - "@docsearch/react": "^3.6.1", + "@docsearch/css": "^3.8.0", + "@docsearch/react": "^3.8.0", "@headlessui/react": "^2.1.2", "@markdoc/markdoc": "0.4.0", "@remix-run/cloudflare": "^2.12.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 34a1cc1b..fb388e5e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,9 +30,12 @@ importers: apps/site: dependencies: + '@docsearch/css': + specifier: ^3.8.0 + version: 3.8.0 '@docsearch/react': - specifier: ^3.6.1 - version: 3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.15.0) + specifier: ^3.8.0 + version: 3.8.0(@algolia/client-search@5.14.2)(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.15.0) '@headlessui/react': specifier: ^2.1.2 version: 2.1.2(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -250,7 +253,7 @@ importers: version: 8.10.0(eslint@7.32.0) eslint-config-turbo: specifier: latest - version: 2.2.3(eslint@7.32.0) + version: 2.3.0(eslint@7.32.0) eslint-plugin-react: specifier: 7.31.8 version: 7.31.8(eslint@7.32.0) @@ -440,70 +443,77 @@ importers: packages: - '@algolia/autocomplete-core@1.9.3': - resolution: {integrity: sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw==} + '@algolia/autocomplete-core@1.17.7': + resolution: {integrity: sha512-BjiPOW6ks90UKl7TwMv7oNQMnzU+t/wk9mgIDi6b1tXpUek7MW0lbNOUHpvam9pe3lVCf4xPFT+lK7s+e+fs7Q==} - '@algolia/autocomplete-plugin-algolia-insights@1.9.3': - resolution: {integrity: sha512-a/yTUkcO/Vyy+JffmAnTWbr4/90cLzw+CC3bRbhnULr/EM0fGNvM13oQQ14f2moLMcVDyAx/leczLlAOovhSZg==} + '@algolia/autocomplete-plugin-algolia-insights@1.17.7': + resolution: {integrity: sha512-Jca5Ude6yUOuyzjnz57og7Et3aXjbwCSDf/8onLHSQgw1qW3ALl9mrMWaXb5FmPVkV3EtkD2F/+NkT6VHyPu9A==} peerDependencies: search-insights: '>= 1 < 3' - '@algolia/autocomplete-preset-algolia@1.9.3': - resolution: {integrity: sha512-d4qlt6YmrLMYy95n5TB52wtNDr6EgAIPH81dvvvW8UmuWRgxEtY0NJiPwl/h95JtG2vmRM804M0DSwMCNZlzRA==} + '@algolia/autocomplete-preset-algolia@1.17.7': + resolution: {integrity: sha512-ggOQ950+nwbWROq2MOCIL71RE0DdQZsceqrg32UqnhDz8FlO9rL8ONHNsI2R1MH0tkgVIDKI/D0sMiUchsFdWA==} peerDependencies: '@algolia/client-search': '>= 4.9.1 < 6' algoliasearch: '>= 4.9.1 < 6' - '@algolia/autocomplete-shared@1.9.3': - resolution: {integrity: sha512-Wnm9E4Ye6Rl6sTTqjoymD+l8DjSTHsHboVRYrKgEt8Q7UHm9nYbqhN/i0fhUYA3OAEH7WA8x3jfpnmJm3rKvaQ==} + '@algolia/autocomplete-shared@1.17.7': + resolution: {integrity: sha512-o/1Vurr42U/qskRSuhBH+VKxMvkkUVTLU6WZQr+L5lGZZLYWyhdzWjW0iGXY7EkwRTjBqvN2EsR81yCTGV/kmg==} peerDependencies: '@algolia/client-search': '>= 4.9.1 < 6' algoliasearch: '>= 4.9.1 < 6' - '@algolia/cache-browser-local-storage@4.24.0': - resolution: {integrity: sha512-t63W9BnoXVrGy9iYHBgObNXqYXM3tYXCjDSHeNwnsc324r4o5UiVKUiAB4THQ5z9U5hTj6qUvwg/Ez43ZD85ww==} + '@algolia/client-abtesting@5.14.2': + resolution: {integrity: sha512-7fq1tWIy1aNJEaNHxWy3EwDkuo4k22+NBnxq9QlYVSLLXtr6HqmAm6bQgNNzGT3vm21iKqWO9efk+HIhEM1SzQ==} + engines: {node: '>= 14.0.0'} - '@algolia/cache-common@4.24.0': - resolution: {integrity: sha512-emi+v+DmVLpMGhp0V9q9h5CdkURsNmFC+cOS6uK9ndeJm9J4TiqSvPYVu+THUP8P/S08rxf5x2P+p3CfID0Y4g==} + '@algolia/client-analytics@5.14.2': + resolution: {integrity: sha512-5Nm5cOOyAGcY+hKNJVmR2jgoGn1nvoANS8W5EfB8yAaUqUxL3lFNUHSkFafAMTCOcVKNDkZQYjUDbOOfdYJLqw==} + engines: {node: '>= 14.0.0'} - '@algolia/cache-in-memory@4.24.0': - resolution: {integrity: sha512-gDrt2so19jW26jY3/MkFg5mEypFIPbPoXsQGQWAi6TrCPsNOSEYepBMPlucqWigsmEy/prp5ug2jy/N3PVG/8w==} + '@algolia/client-common@5.14.2': + resolution: {integrity: sha512-BW1Qzhh9tMKEsWSQQsiOEcHAd6g7zxq9RpPVmyxbDO/O4eA4vyN+Qz5Jzo686kuYdIQKqIPCEtob/JM89tk57g==} + engines: {node: '>= 14.0.0'} - '@algolia/client-account@4.24.0': - resolution: {integrity: sha512-adcvyJ3KjPZFDybxlqnf+5KgxJtBjwTPTeyG2aOyoJvx0Y8dUQAEOEVOJ/GBxX0WWNbmaSrhDURMhc+QeevDsA==} + '@algolia/client-insights@5.14.2': + resolution: {integrity: sha512-17zg6pqifKORvvrMIqW6HhwUry9RKRXLgADrgFjZ6PZvGB4oVs12dwRG2/HMrIlpxd9cjeQfdlEgHj6lbAf6QA==} + engines: {node: '>= 14.0.0'} - '@algolia/client-analytics@4.24.0': - resolution: {integrity: sha512-y8jOZt1OjwWU4N2qr8G4AxXAzaa8DBvyHTWlHzX/7Me1LX8OayfgHexqrsL4vSBcoMmVw2XnVW9MhL+Y2ZDJXg==} + '@algolia/client-personalization@5.14.2': + resolution: {integrity: sha512-5IYt8vbmTA52xyuaZKFwiRoDPeh7hiOC9aBZqqp9fVs6BU01djI/T8pGJXawvwczltCPYzNsdbllV3rqiDbxmQ==} + engines: {node: '>= 14.0.0'} - '@algolia/client-common@4.24.0': - resolution: {integrity: sha512-bc2ROsNL6w6rqpl5jj/UywlIYC21TwSSoFHKl01lYirGMW+9Eek6r02Tocg4gZ8HAw3iBvu6XQiM3BEbmEMoiA==} + '@algolia/client-query-suggestions@5.14.2': + resolution: {integrity: sha512-gvCX/cczU76Bu1sGcxxTdoIwxe+FnuC1IlW9SF/gzxd3ZzsgzBpzD2puIJqt9fHQsjLxVGkJqKev2FtExnJYZg==} + engines: {node: '>= 14.0.0'} - '@algolia/client-personalization@4.24.0': - resolution: {integrity: sha512-l5FRFm/yngztweU0HdUzz1rC4yoWCFo3IF+dVIVTfEPg906eZg5BOd1k0K6rZx5JzyyoP4LdmOikfkfGsKVE9w==} + '@algolia/client-search@5.14.2': + resolution: {integrity: sha512-0imdBZDjqxrshw0+eyJUgnkRAbS2W93UQ3BVj8VjN4xQylIMf0fWs72W7MZFdHlH78JJYydevgzqvGMcV0Z1CA==} + engines: {node: '>= 14.0.0'} - '@algolia/client-search@4.24.0': - resolution: {integrity: sha512-uRW6EpNapmLAD0mW47OXqTP8eiIx5F6qN9/x/7HHO6owL3N1IXqydGwW5nhDFBrV+ldouro2W1VX3XlcUXEFCA==} + '@algolia/ingestion@1.14.2': + resolution: {integrity: sha512-/p4rBNkW0fgCpCwrwre+jHfzlFQsLemgaAQqyui8NPxw95Wgf3p+DKxYzcmh8dygT7ub7FwztTW+uURLX1uqIQ==} + engines: {node: '>= 14.0.0'} - '@algolia/logger-common@4.24.0': - resolution: {integrity: sha512-LLUNjkahj9KtKYrQhFKCzMx0BY3RnNP4FEtO+sBybCjJ73E8jNdaKJ/Dd8A/VA4imVHP5tADZ8pn5B8Ga/wTMA==} + '@algolia/monitoring@1.14.2': + resolution: {integrity: sha512-81R57Y/mS0uNhWpu6cNEfkbkADLW4bP0BNjuPpxAypobv7WzYycUnbMvv1YkN6OsociB4+3M7HfsVzj4Nc09vA==} + engines: {node: '>= 14.0.0'} - '@algolia/logger-console@4.24.0': - resolution: {integrity: sha512-X4C8IoHgHfiUROfoRCV+lzSy+LHMgkoEEU1BbKcsfnV0i0S20zyy0NLww9dwVHUWNfPPxdMU+/wKmLGYf96yTg==} + '@algolia/recommend@5.14.2': + resolution: {integrity: sha512-OwELnAZxCUyfjYjqsrFmC7Vfa12kqwbDdLUV0oi4j+4pxDsfPgkiZ6iCH2uPw6X8VK88Hl3InPt+RPaZvcrCWg==} + engines: {node: '>= 14.0.0'} - '@algolia/recommend@4.24.0': - resolution: {integrity: sha512-P9kcgerfVBpfYHDfVZDvvdJv0lEoCvzNlOy2nykyt5bK8TyieYyiD0lguIJdRZZYGre03WIAFf14pgE+V+IBlw==} + '@algolia/requester-browser-xhr@5.14.2': + resolution: {integrity: sha512-irUvkK+TGBhyivtNCIIbVgNUgbUoHOSk8m/kFX4ddto/PUPmLFRRNNnMHtJ1+OzrJ/uD3Am4FUK2Yt+xgQr05w==} + engines: {node: '>= 14.0.0'} - '@algolia/requester-browser-xhr@4.24.0': - resolution: {integrity: sha512-Z2NxZMb6+nVXSjF13YpjYTdvV3032YTBSGm2vnYvYPA6mMxzM3v5rsCiSspndn9rzIW4Qp1lPHBvuoKJV6jnAA==} + '@algolia/requester-fetch@5.14.2': + resolution: {integrity: sha512-UNBg5mM4MIYdxPuVjyDL22BC6P87g7WuM91Z1Ky0J19aEGvCSF+oR+9autthROFXdRnAa1rACOjuqn95iBbKpw==} + engines: {node: '>= 14.0.0'} - '@algolia/requester-common@4.24.0': - resolution: {integrity: sha512-k3CXJ2OVnvgE3HMwcojpvY6d9kgKMPRxs/kVohrwF5WMr2fnqojnycZkxPoEg+bXm8fi5BBfFmOqgYztRtHsQA==} - - '@algolia/requester-node-http@4.24.0': - resolution: {integrity: sha512-JF18yTjNOVYvU/L3UosRcvbPMGT9B+/GQWNWnenIImglzNVGpyzChkXLnrSf6uxwVNO6ESGu6oN8MqcGQcjQJw==} - - '@algolia/transporter@4.24.0': - resolution: {integrity: sha512-86nI7w6NzWxd1Zp9q3413dRshDqAzSbsQjhcDhPIatEFiZrL1/TjnHL8S7jVKFePlIMzDsZWXAXwXzcok9c5oA==} + '@algolia/requester-node-http@5.14.2': + resolution: {integrity: sha512-CTFA03YiLcnpP+JoLRqjHt5pqDHuKWJpLsIBY/60Gmw8pjALZ3TwvbAquRX4Vy+yrin178NxMuU+ilZ54f2IrQ==} + engines: {node: '>= 14.0.0'} '@alloc/quick-lru@5.2.0': resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} @@ -833,11 +843,11 @@ packages: resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} - '@docsearch/css@3.6.1': - resolution: {integrity: sha512-VtVb5DS+0hRIprU2CO6ZQjK2Zg4QU5HrDM1+ix6rT0umsYvFvatMAnf97NHZlVWDaaLlx7GRfR/7FikANiM2Fg==} + '@docsearch/css@3.8.0': + resolution: {integrity: sha512-pieeipSOW4sQ0+bE5UFC51AOZp9NGxg89wAlZ1BAQFaiRAGK1IKUaPQ0UGZeNctJXyqZ1UvBtOQh2HH+U5GtmA==} - '@docsearch/react@3.6.1': - resolution: {integrity: sha512-qXZkEPvybVhSXj0K7U3bXc233tk5e8PfhoZ6MhPOiik/qUQxYC+Dn9DnoS7CxHQQhHfCvTiN0eY9M12oRghEXw==} + '@docsearch/react@3.8.0': + resolution: {integrity: sha512-WnFK720+iwTVt94CxY3u+FgX6exb3BfN5kE9xUY6uuAH/9W/UFboBZFLlrw/zxFRHoHZCOXRtOylsXF+6LHI+Q==} peerDependencies: '@types/react': '>= 16.8.0 < 19.0.0' react: '>= 16.8.0 < 19.0.0' @@ -2083,8 +2093,9 @@ packages: ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} - algoliasearch@4.24.0: - resolution: {integrity: sha512-bf0QV/9jVejssFBmz2HQLxUadxk574t4iwjCKp5E7NBzwKkrDEhKPISIIjAU/p6K5qDx3qoeh4+26zWN1jmw3g==} + algoliasearch@5.14.2: + resolution: {integrity: sha512-aYjI4WLamMxbhdJ2QAA99VbDCJOGzMOdT2agh57bi40n86ufkhZSIAf6mkocr7NmtBLtwCnSHvD5NJ+Ky5elWw==} + engines: {node: '>= 14.0.0'} ansi-colors@4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} @@ -2775,8 +2786,8 @@ packages: peerDependencies: eslint: '>=7.0.0' - eslint-config-turbo@2.2.3: - resolution: {integrity: sha512-/zwNU+G2w0HszXzWILdl6/Catt86ejUG7vsFSdpnFzFAAUbbT2TxgoCFvC1fKtm6+SkQsXwkRRe9tFz0aMftpg==} + eslint-config-turbo@2.3.0: + resolution: {integrity: sha512-Nm9WZgNoUIJw4bpYQugGCDjzYy1TlUD4sQ/nGblL+HdNqJWCj5NqXbJ1k+TBfYedhr65dlGoAFPYUOfjUOmKVg==} peerDependencies: eslint: '>6.6.0' @@ -2885,8 +2896,8 @@ packages: peerDependencies: eslint: ^7.5.0 || ^8.0.0 - eslint-plugin-turbo@2.2.3: - resolution: {integrity: sha512-LHt35VwxthdGVO6hQRfvmFb6ee8/exAzAYWCy4o87Bnp7urltP8qg7xMd4dPSLAhtfnI2xSo1WgeVaR3MeItxw==} + eslint-plugin-turbo@2.3.0: + resolution: {integrity: sha512-2iVUoIhrjp6kI8p0J4NewKPpXaKrHvL4K4eRnNXbqZvP/7xsm4Of+33B3b7m7OsS0UgX8HHOjlB9bEjigKMkMA==} peerDependencies: eslint: '>6.6.0' @@ -5609,109 +5620,110 @@ packages: snapshots: - '@algolia/autocomplete-core@1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)(search-insights@2.15.0)': + '@algolia/autocomplete-core@1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2)(search-insights@2.15.0)': dependencies: - '@algolia/autocomplete-plugin-algolia-insights': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)(search-insights@2.15.0) - '@algolia/autocomplete-shared': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0) + '@algolia/autocomplete-plugin-algolia-insights': 1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2)(search-insights@2.15.0) + '@algolia/autocomplete-shared': 1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2) transitivePeerDependencies: - '@algolia/client-search' - algoliasearch - search-insights - '@algolia/autocomplete-plugin-algolia-insights@1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)(search-insights@2.15.0)': + '@algolia/autocomplete-plugin-algolia-insights@1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2)(search-insights@2.15.0)': dependencies: - '@algolia/autocomplete-shared': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0) + '@algolia/autocomplete-shared': 1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2) search-insights: 2.15.0 transitivePeerDependencies: - '@algolia/client-search' - algoliasearch - '@algolia/autocomplete-preset-algolia@1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)': + '@algolia/autocomplete-preset-algolia@1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2)': dependencies: - '@algolia/autocomplete-shared': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0) - '@algolia/client-search': 4.24.0 - algoliasearch: 4.24.0 + '@algolia/autocomplete-shared': 1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2) + '@algolia/client-search': 5.14.2 + algoliasearch: 5.14.2 - '@algolia/autocomplete-shared@1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)': + '@algolia/autocomplete-shared@1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2)': dependencies: - '@algolia/client-search': 4.24.0 - algoliasearch: 4.24.0 + '@algolia/client-search': 5.14.2 + algoliasearch: 5.14.2 - '@algolia/cache-browser-local-storage@4.24.0': + '@algolia/client-abtesting@5.14.2': dependencies: - '@algolia/cache-common': 4.24.0 - - '@algolia/cache-common@4.24.0': {} + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/cache-in-memory@4.24.0': + '@algolia/client-analytics@5.14.2': dependencies: - '@algolia/cache-common': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/client-account@4.24.0': - dependencies: - '@algolia/client-common': 4.24.0 - '@algolia/client-search': 4.24.0 - '@algolia/transporter': 4.24.0 + '@algolia/client-common@5.14.2': {} - '@algolia/client-analytics@4.24.0': + '@algolia/client-insights@5.14.2': dependencies: - '@algolia/client-common': 4.24.0 - '@algolia/client-search': 4.24.0 - '@algolia/requester-common': 4.24.0 - '@algolia/transporter': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/client-common@4.24.0': + '@algolia/client-personalization@5.14.2': dependencies: - '@algolia/requester-common': 4.24.0 - '@algolia/transporter': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/client-personalization@4.24.0': + '@algolia/client-query-suggestions@5.14.2': dependencies: - '@algolia/client-common': 4.24.0 - '@algolia/requester-common': 4.24.0 - '@algolia/transporter': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/client-search@4.24.0': + '@algolia/client-search@5.14.2': dependencies: - '@algolia/client-common': 4.24.0 - '@algolia/requester-common': 4.24.0 - '@algolia/transporter': 4.24.0 - - '@algolia/logger-common@4.24.0': {} + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/logger-console@4.24.0': + '@algolia/ingestion@1.14.2': dependencies: - '@algolia/logger-common': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/recommend@4.24.0': + '@algolia/monitoring@1.14.2': dependencies: - '@algolia/cache-browser-local-storage': 4.24.0 - '@algolia/cache-common': 4.24.0 - '@algolia/cache-in-memory': 4.24.0 - '@algolia/client-common': 4.24.0 - '@algolia/client-search': 4.24.0 - '@algolia/logger-common': 4.24.0 - '@algolia/logger-console': 4.24.0 - '@algolia/requester-browser-xhr': 4.24.0 - '@algolia/requester-common': 4.24.0 - '@algolia/requester-node-http': 4.24.0 - '@algolia/transporter': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/requester-browser-xhr@4.24.0': + '@algolia/recommend@5.14.2': dependencies: - '@algolia/requester-common': 4.24.0 + '@algolia/client-common': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 - '@algolia/requester-common@4.24.0': {} + '@algolia/requester-browser-xhr@5.14.2': + dependencies: + '@algolia/client-common': 5.14.2 - '@algolia/requester-node-http@4.24.0': + '@algolia/requester-fetch@5.14.2': dependencies: - '@algolia/requester-common': 4.24.0 + '@algolia/client-common': 5.14.2 - '@algolia/transporter@4.24.0': + '@algolia/requester-node-http@5.14.2': dependencies: - '@algolia/cache-common': 4.24.0 - '@algolia/logger-common': 4.24.0 - '@algolia/requester-common': 4.24.0 + '@algolia/client-common': 5.14.2 '@alloc/quick-lru@5.2.0': {} @@ -6221,14 +6233,14 @@ snapshots: dependencies: '@jridgewell/trace-mapping': 0.3.9 - '@docsearch/css@3.6.1': {} + '@docsearch/css@3.8.0': {} - '@docsearch/react@3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.15.0)': + '@docsearch/react@3.8.0(@algolia/client-search@5.14.2)(@types/react@18.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.15.0)': dependencies: - '@algolia/autocomplete-core': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)(search-insights@2.15.0) - '@algolia/autocomplete-preset-algolia': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0) - '@docsearch/css': 3.6.1 - algoliasearch: 4.24.0 + '@algolia/autocomplete-core': 1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2)(search-insights@2.15.0) + '@algolia/autocomplete-preset-algolia': 1.17.7(@algolia/client-search@5.14.2)(algoliasearch@5.14.2) + '@docsearch/css': 3.8.0 + algoliasearch: 5.14.2 optionalDependencies: '@types/react': 18.3.3 react: 18.2.0 @@ -7529,23 +7541,21 @@ snapshots: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 - algoliasearch@4.24.0: - dependencies: - '@algolia/cache-browser-local-storage': 4.24.0 - '@algolia/cache-common': 4.24.0 - '@algolia/cache-in-memory': 4.24.0 - '@algolia/client-account': 4.24.0 - '@algolia/client-analytics': 4.24.0 - '@algolia/client-common': 4.24.0 - '@algolia/client-personalization': 4.24.0 - '@algolia/client-search': 4.24.0 - '@algolia/logger-common': 4.24.0 - '@algolia/logger-console': 4.24.0 - '@algolia/recommend': 4.24.0 - '@algolia/requester-browser-xhr': 4.24.0 - '@algolia/requester-common': 4.24.0 - '@algolia/requester-node-http': 4.24.0 - '@algolia/transporter': 4.24.0 + algoliasearch@5.14.2: + dependencies: + '@algolia/client-abtesting': 5.14.2 + '@algolia/client-analytics': 5.14.2 + '@algolia/client-common': 5.14.2 + '@algolia/client-insights': 5.14.2 + '@algolia/client-personalization': 5.14.2 + '@algolia/client-query-suggestions': 5.14.2 + '@algolia/client-search': 5.14.2 + '@algolia/ingestion': 1.14.2 + '@algolia/monitoring': 1.14.2 + '@algolia/recommend': 5.14.2 + '@algolia/requester-browser-xhr': 5.14.2 + '@algolia/requester-fetch': 5.14.2 + '@algolia/requester-node-http': 5.14.2 ansi-colors@4.1.3: {} @@ -8391,10 +8401,10 @@ snapshots: dependencies: eslint: 7.32.0 - eslint-config-turbo@2.2.3(eslint@7.32.0): + eslint-config-turbo@2.3.0(eslint@7.32.0): dependencies: eslint: 7.32.0 - eslint-plugin-turbo: 2.2.3(eslint@7.32.0) + eslint-plugin-turbo: 2.3.0(eslint@7.32.0) eslint-import-resolver-node@0.3.7: dependencies: @@ -8738,7 +8748,7 @@ snapshots: - supports-color - typescript - eslint-plugin-turbo@2.2.3(eslint@7.32.0): + eslint-plugin-turbo@2.3.0(eslint@7.32.0): dependencies: dotenv: 16.0.3 eslint: 7.32.0 From 1f267c7df9bd20dbb084487f7c8b810fe822e607 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Mon, 18 Nov 2024 18:05:33 -0800 Subject: [PATCH 10/10] Use global Request type for all request instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this resolves a type error that was being triggered when using handleFetch(request, …) from a worker.ts script (e.g. in examples/remix-cms). the full TS error: worker.ts:17:37 - error TS2345: Argument of type 'Request>' is not assignable to parameter of type 'import("/Users/andrew/Projects/superflare/node_modules/.pnpm/@cloudflare+workers-types@4.20241018.0/node_modules/@cloudflare/workers-types/index").Request(request, env, ctx, config, handleRequest); --- packages/superflare-remix/dev.ts | 8 +------- packages/superflare-remix/index.ts | 6 +----- packages/superflare-remix/load-context.ts | 1 - packages/superflare/src/config.ts | 1 - packages/superflare/src/fetch.ts | 6 +----- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/packages/superflare-remix/dev.ts b/packages/superflare-remix/dev.ts index b236eae9..299ed13a 100644 --- a/packages/superflare-remix/dev.ts +++ b/packages/superflare-remix/dev.ts @@ -1,7 +1,3 @@ -import { - type IncomingRequestCfProperties, - type Request, -} from "@cloudflare/workers-types"; import { cloudflareDevProxyVitePlugin } from "@remix-run/dev"; import { fromNodeRequest, @@ -15,8 +11,6 @@ import { type Plugin, type ViteDevServer } from "vite"; import { type GetPlatformProxyOptions } from "wrangler"; import { type Cloudflare, getLoadContext } from "./load-context"; -type WorkersRequest = Request>; - /** * This is copied from the workers-sdk repo (used for wrangler’s getPlatformProxy). * Using `waitUntil` means invoking the async function, so a no-op works in dev. @@ -76,7 +70,7 @@ export function superflareDevProxyVitePlugin( const request = fromNodeRequest(nodeReq, nodeRes); const loadContext = await getLoadContext({ context, - request: request as unknown as WorkersRequest, + request, SuperflareAuth: superflare.SuperflareAuth, SuperflareSession: superflare.SuperflareSession, }); diff --git a/packages/superflare-remix/index.ts b/packages/superflare-remix/index.ts index b84fdf32..63ac8f42 100644 --- a/packages/superflare-remix/index.ts +++ b/packages/superflare-remix/index.ts @@ -1,7 +1,3 @@ -import { - type IncomingRequestCfProperties, - type Request as WorkersRequest, -} from "@cloudflare/workers-types"; import { type AppLoadContext } from "@remix-run/cloudflare"; import { type DefineConfigReturn, @@ -27,7 +23,7 @@ declare module "@remix-run/cloudflare" { * It calls getLoadContext to inject `auth` and `session` into the Remix load context. */ export async function handleFetch( - request: WorkersRequest>, + request: Request, env: Env, ctx: ExecutionContext, config: DefineConfigReturn, diff --git a/packages/superflare-remix/load-context.ts b/packages/superflare-remix/load-context.ts index 9bdb1551..ffad56d8 100644 --- a/packages/superflare-remix/load-context.ts +++ b/packages/superflare-remix/load-context.ts @@ -1,4 +1,3 @@ -import { type Request } from "@cloudflare/workers-types"; import { type AppLoadContext, createCookieSessionStorage, diff --git a/packages/superflare/src/config.ts b/packages/superflare/src/config.ts index 71d00c1f..706791ac 100644 --- a/packages/superflare/src/config.ts +++ b/packages/superflare/src/config.ts @@ -1,4 +1,3 @@ -import { type Request } from "@cloudflare/workers-types"; import { sanitizeModuleName } from "./string"; export interface StorageDiskConfig { diff --git a/packages/superflare/src/fetch.ts b/packages/superflare/src/fetch.ts index 78bc7c22..5ab1a521 100644 --- a/packages/superflare/src/fetch.ts +++ b/packages/superflare/src/fetch.ts @@ -1,7 +1,3 @@ -import { - type IncomingRequestCfProperties, - type Request, -} from "@cloudflare/workers-types"; import { type DefineConfigReturn } from "./config"; import { type SuperflareSession } from "./session"; @@ -14,7 +10,7 @@ export async function handleFetch( session, getSessionCookie, }: { - request: Request>; + request: Request; env: Env; ctx: ExecutionContext; config: DefineConfigReturn;