Skip to content

Commit

Permalink
chore: Renaming to nuqs
Browse files Browse the repository at this point in the history
  • Loading branch information
franky47 committed Jan 1, 2024
1 parent 9ad3379 commit 2e4333e
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`):
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://next-usequerystate.vercel.app>
- A test bench for [end-to-end tests](./packages/e2e) driven by Cypress

Expand Down
8 changes: 4 additions & 4 deletions errors/NUQS-409.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion errors/NUQS-500.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
createSearchParamsCache,
parseAsInteger,
parseAsString
} from 'next-usequerystate/parsers'
} from 'nuqs/parsers'

const cache = createSearchParamsCache({
q: parseAsString,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "next-usequerystate-monorepo",
"name": "nuqs-monorepo",
"version": "0.0.0",
"private": true,
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next-usequerystate/parsers.d.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions packages/next-usequerystate/src/debug.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// todo: Remove check for `next-usequerystate` in v2
const enabled =
(typeof localStorage === 'object' &&
(localStorage.getItem('debug')?.includes('next-usequerystate') ??
Expand Down
2 changes: 1 addition & 1 deletion packages/next-usequerystate/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
16 changes: 8 additions & 8 deletions packages/next-usequerystate/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -23,7 +23,7 @@ export const emitter = Mitt<EventMap>()

declare global {
interface History {
__nextUseQueryState_patched?: string
__nuqs_patched?: string
}
}

Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions packages/playground/src/components/debug-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ 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(() => {
setChecked(c => {
const checked = !c
if (typeof localStorage !== 'undefined') {
if (checked) {
localStorage.setItem('debug', 'next-usequerystate')
localStorage.setItem('debug', 'nuqs')
} else {
localStorage.removeItem('debug')
}
Expand Down

0 comments on commit 2e4333e

Please sign in to comment.