remix-utils
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "remix-utils", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"license": "MIT", | ||
@@ -8,4 +8,9 @@ "engines": { | ||
}, | ||
"browser": "./browser/index.js", | ||
"main": "./build/index.js", | ||
"sideEffects": false, | ||
"scripts": { | ||
"build": "tsc --project tsconfig.json", | ||
"build": "npm run build:browser && npm run build:main", | ||
"build:browser": "tsc --project tsconfig.json --module ESNext --outDir ./browser", | ||
"build:main": "tsc --project tsconfig.json --module CommonJS --outDir ./build", | ||
"typecheck": "tsc --project tsconfig.json --noEmit", | ||
@@ -12,0 +17,0 @@ "lint": "eslint --ext .ts,.tsx src/", |
@@ -20,3 +20,3 @@ # Remix Utils | ||
```tsx | ||
import { ClientOnly } from "remix-utils/react"; | ||
import { ClientOnly } from "remix-utils"; | ||
@@ -47,3 +47,3 @@ export default function View() { | ||
This part of Remix Utils needs packages from `remix-utils/server` and `remix-utils/react` to work. | ||
This part of Remix Utils needs packages from `remix-utils` and `remix-utils` to work. | ||
@@ -56,3 +56,3 @@ #### Generate the authenticity token | ||
import type { LoaderFunction } from "remix"; | ||
import { createAuthenticityToken, json } from "remix-utils/server"; | ||
import { createAuthenticityToken, json } from "remix-utils"; | ||
import { getSession, commitSession } from "~/services/session.server"; | ||
@@ -67,6 +67,9 @@ | ||
let token = createAuthenticityToken(session); | ||
return json<LoaderData>({ csrf: token }, { | ||
headers: await commitSession(session) | ||
}); | ||
} | ||
return json<LoaderData>( | ||
{ csrf: token }, | ||
{ | ||
headers: await commitSession(session), | ||
} | ||
); | ||
}; | ||
``` | ||
@@ -104,3 +107,3 @@ | ||
import { Form } from "remix"; | ||
import { AuthenticityTokenInput } from "remix-utils/react"; | ||
import { AuthenticityTokenInput } from "remix-utils"; | ||
@@ -133,3 +136,3 @@ export default function SomeRoute() { | ||
import { useFetcher } from "remix"; | ||
import { useAuthenticityToken } from "remix-utils/react"; | ||
import { useAuthenticityToken } from "remix-utils"; | ||
@@ -151,3 +154,3 @@ export function useMarkAsRead() { | ||
import type { ActionFunction } from "remix"; | ||
import { verifyAuthenticityToken, redirectBack } from "remix-utils/server"; | ||
import { verifyAuthenticityToken, redirectBack } from "remix-utils"; | ||
import { getSession, commitSession } from "~/services/session.server"; | ||
@@ -159,4 +162,4 @@ | ||
// do something here | ||
return redirectBack(request, { fallback: "/fallback"}) | ||
} | ||
return redirectBack(request, { fallback: "/fallback" }); | ||
}; | ||
``` | ||
@@ -174,3 +177,3 @@ | ||
// parent route | ||
import { Outlet } from "remix-utils/react"; | ||
import { Outlet } from "remix-utils"; | ||
@@ -184,3 +187,3 @@ export default function Parent() { | ||
// child route | ||
import { useParentData } from "remix-utils/react"; | ||
import { useParentData } from "remix-utils"; | ||
@@ -200,3 +203,3 @@ export default function Child() { | ||
```ts | ||
import { useHydrated } from "remix-utils/react"; | ||
import { useHydrated } from "remix-utils"; | ||
@@ -226,4 +229,4 @@ export function Component() { | ||
import type { ReactNode } from "react"; | ||
import { Links, LiveReload, Meta, Scripts, } from "remix"; | ||
import { useShouldHydrate } from "remix-utils/react"; | ||
import { Links, LiveReload, Meta, Scripts } from "remix"; | ||
import { useShouldHydrate } from "remix-utils"; | ||
@@ -235,3 +238,3 @@ interface DocumentProps { | ||
export function Document({ children, title, }: DocumentProps) { | ||
export function Document({ children, title }: DocumentProps) { | ||
let shouldHydrate = useShouldHydrate(); | ||
@@ -286,3 +289,3 @@ return ( | ||
```ts | ||
import { bodyParser, redirectBack } from "remix-utils/server"; | ||
import { bodyParser, redirectBack } from "remix-utils"; | ||
import type { ActionFunction } from "remix"; | ||
@@ -297,3 +300,3 @@ | ||
return redirectBack(request, { fallback: "/" }); | ||
} | ||
}; | ||
``` | ||
@@ -306,3 +309,3 @@ | ||
```ts | ||
import { bodyParser, redirectBack } from "remix-utils/server"; | ||
import { bodyParser, redirectBack } from "remix-utils"; | ||
import type { ActionFunction } from "remix"; | ||
@@ -316,3 +319,3 @@ | ||
return redirectBack(request, { fallback: "/" }); | ||
} | ||
}; | ||
``` | ||
@@ -334,3 +337,3 @@ | ||
```ts | ||
import { bodyParser, redirectBack } from "remix-utils/server"; | ||
import { bodyParser, redirectBack } from "remix-utils"; | ||
import type { ActionFunction } from "remix"; | ||
@@ -346,3 +349,3 @@ import { hasUsername } from "../validations/users"; | ||
return redirectBack(request, { fallback: "/" }); | ||
} | ||
}; | ||
``` | ||
@@ -372,3 +375,3 @@ | ||
import type { LoaderFunction } from "remix"; | ||
import { json } from "remix-utils/server"; | ||
import { json } from "remix-utils"; | ||
@@ -382,6 +385,6 @@ import { getUser } from "../services/users"; | ||
export let loader: LoaderFunction = async ({request}) => { | ||
export let loader: LoaderFunction = async ({ request }) => { | ||
const user = await getUser(request); | ||
return json<LoaderData>({ user }); | ||
} | ||
}; | ||
@@ -401,3 +404,3 @@ export default function View() { | ||
```ts | ||
import { redirectBack } from "remix-utils/server"; | ||
import { redirectBack } from "remix-utils"; | ||
import type { ActionFunction } from "remix"; | ||
@@ -407,3 +410,3 @@ | ||
await redirectBack(request, { fallback: "/" }); | ||
} | ||
}; | ||
``` | ||
@@ -418,3 +421,3 @@ | ||
```ts | ||
import { badRequest } from "remix-utils/server"; | ||
import { badRequest } from "remix-utils"; | ||
import type { ActionFunction } from "remix"; | ||
@@ -424,3 +427,3 @@ | ||
throw badRequest({ message: "You forgot something in the form." }); | ||
} | ||
}; | ||
``` | ||
@@ -433,3 +436,3 @@ | ||
```ts | ||
import { unauthorized } from "remix-utils/server"; | ||
import { unauthorized } from "remix-utils"; | ||
import type { LoaderFunction } from "remix"; | ||
@@ -440,3 +443,3 @@ | ||
throw unauthorized({ message: "You need to login." }); | ||
} | ||
}; | ||
``` | ||
@@ -449,3 +452,3 @@ | ||
```ts | ||
import { forbidden } from "remix-utils/server"; | ||
import { forbidden } from "remix-utils"; | ||
import type { LoaderFunction } from "remix"; | ||
@@ -455,3 +458,3 @@ | ||
throw forbidden({ message: "You don't have access for this." }); | ||
} | ||
}; | ||
``` | ||
@@ -464,3 +467,3 @@ | ||
```ts | ||
import { notFound } from "remix-utils/server"; | ||
import { notFound } from "remix-utils"; | ||
import type { LoaderFunction } from "remix"; | ||
@@ -470,3 +473,3 @@ | ||
throw notFound({ message: "This doesn't exists." }); | ||
} | ||
}; | ||
``` | ||
@@ -479,3 +482,3 @@ | ||
```ts | ||
import { unprocessableEntity } from "remix-utils/server"; | ||
import { unprocessableEntity } from "remix-utils"; | ||
import type { LoaderFunction } from "remix"; | ||
@@ -485,3 +488,3 @@ | ||
throw unprocessableEntity({ message: "This doesn't exists." }); | ||
} | ||
}; | ||
``` | ||
@@ -496,3 +499,3 @@ | ||
```ts | ||
import { serverError } from "remix-utils/server"; | ||
import { serverError } from "remix-utils"; | ||
import type { LoaderFunction } from "remix"; | ||
@@ -502,3 +505,3 @@ | ||
throw serverError({ message: "Something unexpected happened." }); | ||
} | ||
}; | ||
``` | ||
@@ -505,0 +508,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
73641
47
1478
481