diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 18c45eb9..fcf491a3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,10 +10,10 @@ assignees: '' ## Context -What's your version of `next-usequerystate`? +What's your version of `nuqs`? ``` --> Paste result from `cat package.json | grep next-usequerystate` here +-> Paste result from `cat package.json | grep -e nuqs -e next-usequerystate` here ``` Next.js information (obtained by running `next info`): diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43e44049..8a33d59e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ First off, thanks for your help! This monorepo contains: -- The source code for the `next-usequerystate` NPM package, in [`packages/next-usequerystate`](./packages/next-usequerystate). +- The source code for the `nuqs` NPM package, in [`packages/next-usequerystate`](./packages/next-usequerystate). - A Next.js app under [`packages/playground`](./packages/playground) that serves as a playground deployed at - A test bench for [end-to-end tests](./packages/e2e) driven by Cypress diff --git a/errors/NUQS-409.md b/errors/NUQS-409.md index a44bc5b5..7c76ecd8 100644 --- a/errors/NUQS-409.md +++ b/errors/NUQS-409.md @@ -1,13 +1,13 @@ # Multiple versions of the library are loaded -This error occurs if two different versions of `next-usequerystate` are +This error occurs if two different versions of `nuqs` are loaded in the same application. -This may happen if you are using a package that embeds next-usequerystate and -you are also using next-usequerystate directly. +This may happen if you are using a package that embeds `nuqs` and +you are also using `nuqs` directly. ## Possible Solutions -Inspect your dependencies for duplicate versions of `next-usequerystate` and +Inspect your dependencies for duplicate versions of `nuqs` and use the `resolutions` field in `package.json` to force all dependencies to use the same version. diff --git a/errors/NUQS-500.md b/errors/NUQS-500.md index 682f254c..5210cd0e 100644 --- a/errors/NUQS-500.md +++ b/errors/NUQS-500.md @@ -26,7 +26,7 @@ import { createSearchParamsCache, parseAsInteger, parseAsString -} from 'next-usequerystate/parsers' +} from 'nuqs/parsers' const cache = createSearchParamsCache({ q: parseAsString, diff --git a/package.json b/package.json index edc87b1e..88e9cef6 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "next-usequerystate-monorepo", + "name": "nuqs-monorepo", "version": "0.0.0", "private": true, "license": "MIT", diff --git a/packages/e2e/package.json b/packages/e2e/package.json index fc87a6dd..8bded3e8 100644 --- a/packages/e2e/package.json +++ b/packages/e2e/package.json @@ -1,7 +1,7 @@ { "name": "e2e", "version": "0.0.0-internal", - "description": "End-to-end test bench for next-usequerystate", + "description": "End-to-end test bench for nuqs", "license": "MIT", "private": true, "author": { diff --git a/packages/e2e/src/app/layout.tsx b/packages/e2e/src/app/layout.tsx index d943ffd5..43a18ed9 100644 --- a/packages/e2e/src/app/layout.tsx +++ b/packages/e2e/src/app/layout.tsx @@ -2,7 +2,7 @@ import React, { Suspense } from 'react' import { HydrationMarker } from '../components/hydration-marker' export const metadata = { - title: 'next-usequerystate playground', + title: 'nuqs playground', description: 'useQueryState hook for Next.js - Like React.useState, but stored in the URL query string' } diff --git a/packages/next-usequerystate/parsers.d.ts b/packages/next-usequerystate/parsers.d.ts index 03cff907..6e0e1b44 100644 --- a/packages/next-usequerystate/parsers.d.ts +++ b/packages/next-usequerystate/parsers.d.ts @@ -1,5 +1,5 @@ // This file is needed for projects that have `moduleResolution` set to `node` -// in their tsconfig.json to be able to `import {} from 'next-usequerystate/parsers'`. +// in their tsconfig.json to be able to `import {} from 'nuqs/parsers'`. // Other module resolutions strategies will look for the `exports` in `package.json`, // but with `node`, TypeScript will look for a .d.ts file with that name at the // root of the package. diff --git a/packages/next-usequerystate/src/debug.ts b/packages/next-usequerystate/src/debug.ts index 3962184b..52925640 100644 --- a/packages/next-usequerystate/src/debug.ts +++ b/packages/next-usequerystate/src/debug.ts @@ -1,3 +1,4 @@ +// todo: Remove check for `next-usequerystate` in v2 const enabled = (typeof localStorage === 'object' && (localStorage.getItem('debug')?.includes('next-usequerystate') ?? diff --git a/packages/next-usequerystate/src/errors.ts b/packages/next-usequerystate/src/errors.ts index 4dc31dea..287a4f47 100644 --- a/packages/next-usequerystate/src/errors.ts +++ b/packages/next-usequerystate/src/errors.ts @@ -6,6 +6,6 @@ export const errors = { } as const export function error(code: keyof typeof errors) { - return `[next-usequerystate] ${errors[code]} + return `[nuqs] ${errors[code]} See https://err.47ng.com/NUQS-${code}` } diff --git a/packages/next-usequerystate/src/sync.ts b/packages/next-usequerystate/src/sync.ts index 0159250f..685706c4 100644 --- a/packages/next-usequerystate/src/sync.ts +++ b/packages/next-usequerystate/src/sync.ts @@ -3,9 +3,9 @@ import { debug } from './debug' import { error } from './errors' import { getQueuedValue } from './update-queue' -export const SYNC_EVENT_KEY = Symbol('__nextUseQueryState__SYNC__') -export const NOSYNC_MARKER = '__nextUseQueryState__NO_SYNC__' -const NOTIFY_EVENT_KEY = Symbol('__nextUseQueryState__NOTIFY__') +export const SYNC_EVENT_KEY = Symbol('__nuqs__SYNC__') +export const NOSYNC_MARKER = '__nuqs__NO_SYNC__' +const NOTIFY_EVENT_KEY = Symbol('__nuqs__NOTIFY__') export type QueryUpdateSource = 'internal' | 'external' export type QueryUpdateNotificationArgs = { @@ -23,7 +23,7 @@ export const emitter = Mitt() declare global { interface History { - __nextUseQueryState_patched?: string + __nuqs_patched?: string } } @@ -32,7 +32,7 @@ declare global { * method is no longer needed as you can use `useSearchParams`, which will * react to changes in the URL when the `windowHistorySupport` experimental flag * is set. - * This method will be removed in `next-usequerystate@2.0.0`, when Next.js + * This method will be removed in `nuqs@2.0.0`, when Next.js * decides to land the `windowHistorySupport` flag in GA. */ export function subscribeToQueryUpdates( @@ -50,7 +50,7 @@ function patchHistory() { // This is replaced with the package.json version by scripts/prepack.sh // after semantic-release has done updating the version number. const version = '0.0.0-inject-version-here' - const patched = history.__nextUseQueryState_patched + const patched = history.__nuqs_patched if (patched) { if (patched !== version) { console.error(error(409), patched, version) @@ -60,7 +60,7 @@ function patchHistory() { debug('[nuqs] Patching history with %s', version) for (const method of ['pushState', 'replaceState'] as const) { const original = history[method].bind(history) - history[method] = function nextUseQueryState_patchedHistory( + history[method] = function nuqs_patchedHistory( state: any, title: string, url?: string | URL | null @@ -116,7 +116,7 @@ function patchHistory() { return original(state, title === NOSYNC_MARKER ? '' : title, url) } } - Object.defineProperty(history, '__nextUseQueryState_patched', { + Object.defineProperty(history, '__nuqs_patched', { value: version, writable: false, enumerable: false, diff --git a/packages/playground/src/components/debug-control.tsx b/packages/playground/src/components/debug-control.tsx index d5641866..07a2b34e 100644 --- a/packages/playground/src/components/debug-control.tsx +++ b/packages/playground/src/components/debug-control.tsx @@ -8,7 +8,9 @@ export default function DebugControl() { return false } return ( - localStorage.getItem('debug')?.includes('next-usequerystate') ?? false + localStorage.getItem('debug')?.includes('next-usequerystate') ?? + localStorage.getItem('debug')?.includes('nuqs') ?? + false ) }) const update = React.useCallback(() => { @@ -16,7 +18,7 @@ export default function DebugControl() { const checked = !c if (typeof localStorage !== 'undefined') { if (checked) { - localStorage.setItem('debug', 'next-usequerystate') + localStorage.setItem('debug', 'nuqs') } else { localStorage.removeItem('debug') }