@timber-js/app 0.2.0-alpha.231 → 0.2.0-alpha.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{use-query-states-pkDV-jSg.js → use-query-states-D3MMl-KM.js} +12 -12
- package/dist/_chunks/use-query-states-D3MMl-KM.js.map +1 -0
- package/dist/client/index.js +1 -1
- package/dist/client/internal.js +1 -1
- package/dist/client/nuqs-adapter.d.ts.map +1 -1
- package/dist/client/use-query-states.d.ts +1 -1
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/node-flight-builds.d.ts +38 -0
- package/dist/plugins/node-flight-builds.d.ts.map +1 -0
- package/dist/search-params/define.d.ts +37 -17
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.d.ts +1 -0
- package/dist/search-params/index.d.ts.map +1 -1
- package/dist/search-params/index.js +3 -2
- package/dist/search-params/index.js.map +1 -1
- package/docs/learn/06-typed-params.mdx +33 -0
- package/package.json +2 -2
- package/src/client/nuqs-adapter.tsx +45 -2
- package/src/client/use-query-states.ts +27 -23
- package/src/index.ts +2 -0
- package/src/plugins/node-flight-builds.ts +94 -0
- package/src/search-params/define.ts +37 -17
- package/src/search-params/index.ts +10 -0
- package/dist/_chunks/use-query-states-pkDV-jSg.js.map +0 -1
|
@@ -126,6 +126,11 @@ function deriveUrlKeys(codecs) {
|
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Bridge an entire codec map to nuqs-compatible parsers.
|
|
129
|
+
*
|
|
130
|
+
* Keyed by `string`, not `keyof T`: the per-key types are erased across the
|
|
131
|
+
* nuqs boundary anyway (the hook re-types its values as `T` on the way out),
|
|
132
|
+
* and a string-keyed map is what lets the timber-owned `urlKeys` — a
|
|
133
|
+
* `Record<string, string>` — type-check against nuqs's `UrlKeys<KeyMap>`.
|
|
129
134
|
*/
|
|
130
135
|
function bridgeCodecs(codecs) {
|
|
131
136
|
const result = {};
|
|
@@ -155,17 +160,16 @@ function bridgeCodecs(codecs) {
|
|
|
155
160
|
* "not registered yet" failure mode. See design/23-search-params.md
|
|
156
161
|
* §"Client Access".
|
|
157
162
|
*/
|
|
158
|
-
function useQueryStates$1(codecs,
|
|
163
|
+
function useQueryStates$1(codecs, options, urlKeys) {
|
|
159
164
|
const bridged = bridgeCodecs(codecs);
|
|
160
|
-
const nuqsOptions = {};
|
|
161
|
-
if (_options?.shallow !== void 0) nuqsOptions.shallow = _options.shallow;
|
|
162
|
-
if (_options?.scroll !== void 0) nuqsOptions.scroll = _options.scroll;
|
|
163
|
-
if (_options?.history !== void 0) nuqsOptions.history = _options.history;
|
|
164
165
|
const resolvedUrlKeys = {
|
|
165
166
|
...deriveUrlKeys(codecs),
|
|
166
167
|
...urlKeys
|
|
167
168
|
};
|
|
168
|
-
|
|
169
|
+
const nuqsOptions = {
|
|
170
|
+
...options,
|
|
171
|
+
urlKeys: resolvedUrlKeys
|
|
172
|
+
};
|
|
169
173
|
let values;
|
|
170
174
|
let setValues;
|
|
171
175
|
try {
|
|
@@ -183,10 +187,6 @@ function useQueryStates$1(codecs, _options, urlKeys) {
|
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
189
|
const setParams = (partial, setOptions) => {
|
|
186
|
-
const nuqsSetOptions = {};
|
|
187
|
-
if (setOptions?.shallow !== void 0) nuqsSetOptions.shallow = setOptions.shallow;
|
|
188
|
-
if (setOptions?.scroll !== void 0) nuqsSetOptions.scroll = setOptions.scroll;
|
|
189
|
-
if (setOptions?.history !== void 0) nuqsSetOptions.history = setOptions.history;
|
|
190
190
|
let forwarded = partial;
|
|
191
191
|
for (const key of Object.keys(partial)) {
|
|
192
192
|
const value = partial[key];
|
|
@@ -205,7 +205,7 @@ function useQueryStates$1(codecs, _options, urlKeys) {
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
setValues(forwarded,
|
|
208
|
+
setValues(forwarded, setOptions);
|
|
209
209
|
};
|
|
210
210
|
return [normalized, setParams];
|
|
211
211
|
}
|
|
@@ -220,4 +220,4 @@ function bindUseQueryStates(definition) {
|
|
|
220
220
|
}
|
|
221
221
|
export { parseTotal as i, useQueryStates$1 as n, serializedEqual as r, bindUseQueryStates as t };
|
|
222
222
|
|
|
223
|
-
//# sourceMappingURL=use-query-states-
|
|
223
|
+
//# sourceMappingURL=use-query-states-D3MMl-KM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-query-states-D3MMl-KM.js","names":["useQueryStates","nuqsUseQueryStates"],"sources":["../../src/search-params/parse-total.ts","../../src/search-params/serialize-equal.ts","../../src/client/use-query-states.ts"],"sourcesContent":["/**\n * parseTotal — invoke a codec over the FULL raw domain.\n *\n * `SearchParamCodec.parse` is documented to be total over\n * `string | string[] | undefined`, because that is exactly what a URL\n * hands it: a param can be absent (`undefined`) or repeated (`string[]`).\n * Timber's own codecs and the Standard Schema bridges honour that.\n *\n * nuqs parsers do not. Their `parse` expects a **present scalar string** —\n * nuqs checks presence itself before ever calling it — so `parseAsBoolean`\n * and `parseAsIsoDate` threw a render-phase 500 on an absent param and\n * `parseAsString` returned an array on a repeated one (TIM-1350).\n *\n * nuqs ships the missing adapter: every parser builder exposes\n * `parseServerSide(value: string | string[] | undefined)`, which maps\n * absent → `null` (or the parser's `withDefault` value), takes the FIRST\n * entry of a repeated param (matching `URLSearchParams.get()`), and wraps\n * the inner `parse` so a throw becomes `null`. That is precisely timber's\n * domain, so we call it in preference to `parse` rather than hand-rolling\n * a second normalization that could disagree with the client hook.\n *\n * Feature detection, not an instanceof check: any codec MAY publish\n * `parseServerSide` to declare \"this is my total entry point\" — it is an\n * optional member of `SearchParamCodec` — and a codec that does not is\n * assumed already total and called through `parse`. Timber codecs and\n * schema bridges take the second branch untouched; several of them rely on\n * `parse(undefined)` to produce their default.\n *\n * **Search params only.** Segment params (`server/param-coercion.ts`) call\n * `codec.parse` directly and must keep doing so: their domain is a value\n * the router matched, never absent, and a codec that REJECTS one is how a\n * route produces a 404. Routing a rejection through nuqs's `safeParse`\n * would turn that 404 into a silent `null` param. The two domains differ\n * in what \"no value\" means, not just in plumbing. Cookies are a third\n * domain (`cookies/define-cookie.ts`) and are likewise untouched.\n *\n * `parseServerSide` carries a `@deprecated` tag in nuqs (it steers users to\n * loaders, which timber does not use). It remains public, typed and\n * exercised; `tests/nuqs-codec-boundary.test.ts` asserts totality for every\n * parser through timber's own API, so a nuqs release that drops it fails\n * loudly rather than silently reinstating the 500s.\n *\n * Design doc: design/23-search-params.md §\"nuqs parsers, made total\"\n */\n\n/**\n * Minimal interface for anything `parseTotal` can dispatch. Only `parse` is\n * required; `parseServerSide` is the optional total entry point. `serialize`\n * is deliberately absent — `parseTotal` never calls it, and requiring it\n * would prevent `SearchParamCodec<T>` (whose serialize returns `string |\n * string[] | null`) from being passed where `Codec<T>` (whose serialize\n * returns `string | null`) is expected.\n */\nexport interface ParseableCodec<T> {\n parse(value: string | string[] | undefined): T;\n parseServerSide?(value: string | string[] | undefined): T;\n}\n\n/**\n * A codec that publishes a total entry point over the raw URL domain.\n *\n * The return is `T`, not `T | null`. This is the entry point timber calls,\n * so whatever it answers IS the field's type. A `null` for an absent param\n * belongs in `T` — a bare nuqs parser is a codec of `string | null`, and\n * `parseAsInteger.withDefault(1)` is a codec of `number`, because nuqs\n * narrows its own `parseServerSide` return to `NonNullable<T>`. Declaring\n * `T | null` here would let a codec annotated `SearchParamCodec<string>`\n * hand back `null` under a non-nullable type (TIM-1350 review).\n */\nexport interface TotalCodec<T> {\n parseServerSide(value: string | string[] | undefined): T;\n}\n\nfunction hasParseServerSide<T>(\n codec: ParseableCodec<T>\n): codec is ParseableCodec<T> & TotalCodec<T> {\n return typeof (codec as Partial<TotalCodec<T>>).parseServerSide === 'function';\n}\n\n/**\n * Parse a raw URL value through a codec, using the codec's total entry\n * point when it publishes one.\n *\n * Returns `T`, from both branches. A `null` for an absent param is part of\n * the codec's own `T` — see TotalCodec above — so this signature does not\n * widen it, and a caller that must handle \"no value\" (`withDefault`) sees\n * it because `T` carries it.\n */\nexport function parseTotal<T>(codec: ParseableCodec<T>, raw: string | string[] | undefined): T {\n return hasParseServerSide(codec) ? codec.parseServerSide(raw) : codec.parse(raw);\n}\n","/**\n * Compare two serialize results for equality. Needed because `string[]`\n * from repeated-key codecs does not compare by reference.\n *\n * Shared between define.ts (buildSearchParams default-omission) and\n * use-query-states.ts (bridgeCodec eq). One source of truth.\n */\nexport function serializedEqual(a: string | string[] | null, b: string | string[] | null): boolean {\n if (a === b) return true;\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n return false;\n}\n","/**\n * useQueryStates — client-side hook for URL-synced search params.\n *\n * Delegates to nuqs for URL synchronization, batching, React 19 transitions,\n * and throttled URL writes. Bridges timber's SearchParamCodec protocol to\n * nuqs-compatible parsers.\n *\n * Design doc: design/23-search-params.md §\"Codec Bridge\"\n */\n\n'use client';\n\nimport { useQueryStates as nuqsUseQueryStates } from 'nuqs';\nimport type { MultiParser, SetValues, UseQueryStatesOptions } from 'nuqs';\nimport type {\n SearchParamCodec,\n SearchParamsDefinition,\n SetParams,\n QueryStatesOptions,\n} from '../search-params/define.ts';\nimport { parseTotal } from '../search-params/parse-total.ts';\nimport { serializedEqual } from '../search-params/serialize-equal.ts';\n\n// ─── Codec Bridge ─────────────────────────────────────────────────\n\n// nuqs's parser contract conflates values timber codecs distinguish:\n// parse() returning null means \"unparseable, substitute defaultValue\",\n// and undefined entries are skipped entirely. Timber codecs can\n// legitimately produce both — bare z.string() yields undefined for absent\n// params (implicit optionality), and a codec may map a present value to\n// null. Wrap those two values in sentinels across the nuqs boundary and\n// unwrap them before handing values back to the caller, so the client\n// hook returns exactly what server-side parse() returns.\n// Unique object references compared by identity — a codec can never\n// produce these from URL input, so user-controlled strings cannot collide\n// with them (unlike string sentinels), and unlike Symbols they survive\n// nuqs's internal string coercion without throwing.\nconst NULL_SENTINEL: object = { timberSentinel: 'null' };\nconst UNDEFINED_SENTINEL: object = { timberSentinel: 'undefined' };\n\nfunction wrapNuqsValue(value: unknown): unknown {\n if (value === null) return NULL_SENTINEL;\n if (value === undefined) return UNDEFINED_SENTINEL;\n return value;\n}\n\nfunction unwrapNuqsValue(value: unknown): unknown {\n if (value === NULL_SENTINEL) return null;\n if (value === UNDEFINED_SENTINEL) return undefined;\n return value;\n}\n\n/**\n * Bridge a timber SearchParamCodec to a nuqs-compatible MultiParser.\n *\n * nuqs parsers: { parse(string) → T|null, serialize?(T) → string, eq?, defaultValue? }\n * timber codecs: { parse(string|string[]|undefined) → T, serialize(T) → string|null }\n *\n * The defaultValue is computed eagerly, through `parseTotal` — the same\n * entry point server-side `parse()` uses, so the hook and the server agree\n * on what an absent param means (a bare nuqs parser answers `null`, not\n * `undefined`; TIM-1350). Codecs are documented to return a default rather\n * than throw, but a throwing codec must not crash every component that\n * mounts the hook — treat its default as undefined and let its error\n * surface from server-side parse() instead.\n *\n * A `null` absent-value is NOT registered as the nuqs default. nuqs\n * already represents an absent key as `null`, so the hook reads the same\n * value either way — but registering it makes `clearOnDefault` fire on\n * `setParams({ q: null })` and delete the key before the bridged\n * `serialize` runs. For a codec that encodes `null` as a real query value\n * (`serialize(null) === 'none'`), that silently disagrees with\n * `buildSearchParams({ q: null })`, which writes it. Same reasoning as\n * `getDefaultSerialized` on the server: a codec with no value for an\n * absent param has no default to register.\n */\nfunction bridgeCodec<T>(codec: SearchParamCodec<T>): MultiParser<T> & { defaultValue: T } {\n let absent: unknown;\n try {\n absent = parseTotal(codec, undefined);\n } catch {\n absent = undefined;\n }\n\n const parser = {\n // `multi`, so nuqs reads the key with `searchParams.getAll()` and hands\n // us EVERY value. A single parser reads `.get()` — the first value only\n // — which is not the domain a timber codec is defined over. The server\n // parses `?tags=a&tags=b` as `['a','b']`; a single parser made the hook\n // answer `['a']` for the same URL, under a declared `string[]` that\n // admitted no such disagreement (TIM-1352). Scalar codecs are unaffected:\n // they receive the array and take `value[0]`, exactly as they do on the\n // server, so first-value-wins is preserved through the same code path\n // rather than through nuqs's reader.\n //\n // nuqs never calls this with an empty array — `isAbsentFromUrl` treats\n // `[]` as absent and answers `defaultValue` directly — which is what\n // keeps the absent case agreeing with the server's `undefined`.\n //\n // Reading every value is only half of it: the values must arrive in the\n // SAME SHAPE the server would have produced, or the divergence just\n // moves. `normalizeRaw` (search-params/define.ts) collapses a\n // single-valued key to a bare string and keeps an array only for a\n // repeated one, so this mirrors that rule exactly. Handing a codec\n // `['3']` where the server hands it `'3'` breaks every codec whose\n // `parse` is written for the scalar case — which is most hand-written\n // ones, contract or no contract.\n type: 'multi' as const,\n // Through parseTotal, not codec.parse. nuqs's own `.withDefault(d)`\n // overrides ONLY `parseServerSide`, so `parseAsInteger.withDefault(1)`\n // on `?page=abc` returned 1 from the server and null from the hook —\n // a divergence the declared non-nullable `number` did not admit.\n parse: (v: readonly string[]) =>\n wrapNuqsValue(parseTotal(codec, v.length === 1 ? v[0] : [...v])),\n serialize: (v: unknown) => {\n const value = unwrapNuqsValue(v);\n if (value === undefined) return [''];\n // TIM-1354: catch TypeError from codecs whose serialize is not total\n // over null (e.g. parseAsIsoDate.serialize(null) → null.toISOString()).\n // Only TypeError — deliberate signals must not be swallowed.\n let result: string | string[] | null;\n try {\n result = codec.serialize(value as T);\n } catch (error) {\n if (error instanceof TypeError) return [''];\n throw error;\n }\n // TIM-1353: pass through string[] from codecs that emit repeated\n // keys. nuqs multi parsers append one key=value per array element.\n if (Array.isArray(result)) return result;\n return [result ?? ''];\n },\n eq: (a: unknown, b: unknown) => {\n if (a === b) return true;\n try {\n return serializedEqual(\n codec.serialize(unwrapNuqsValue(a) as T),\n codec.serialize(unwrapNuqsValue(b) as T)\n );\n } catch {\n return false;\n }\n },\n } as MultiParser<T> & { defaultValue: T };\n\n if (absent !== null) parser.defaultValue = wrapNuqsValue(absent) as T;\n return parser;\n}\n\n/**\n * Collect `withUrlKey` aliases off a codec map.\n *\n * `withUrlKey(codec, 'q')` returns a codec carrying `urlKey: 'q'`, so the map\n * alone is enough to reconstruct the aliases — `defineSearchParams` builds its\n * own `urlKeys` from exactly this property.\n */\nfunction deriveUrlKeys(codecs: Record<string, SearchParamCodec<unknown>>): Record<string, string> {\n const result: Record<string, string> = {};\n for (const key of Object.keys(codecs)) {\n const alias = codecs[key]?.urlKey;\n if (alias) result[key] = alias;\n }\n return result;\n}\n\ntype BridgedParsers = Record<string, MultiParser<unknown> & { defaultValue: unknown }>;\n\n/**\n * Bridge an entire codec map to nuqs-compatible parsers.\n *\n * Keyed by `string`, not `keyof T`: the per-key types are erased across the\n * nuqs boundary anyway (the hook re-types its values as `T` on the way out),\n * and a string-keyed map is what lets the timber-owned `urlKeys` — a\n * `Record<string, string>` — type-check against nuqs's `UrlKeys<KeyMap>`.\n */\nfunction bridgeCodecs<T extends Record<string, unknown>>(codecs: {\n [K in keyof T]: SearchParamCodec<T[K]>;\n}): BridgedParsers {\n const result: BridgedParsers = {};\n for (const key of Object.keys(codecs)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = bridgeCodec(codecs[key as keyof T]) as any;\n }\n return result;\n}\n\n// ─── Hook ─────────────────────────────────────────────────────────\n\n/**\n * Read and write typed search params from/to the URL.\n *\n * Delegates to nuqs internally. The timber nuqs adapter (auto-injected in\n * browser-entry.ts) handles RSC navigation on non-shallow updates.\n *\n * Usage:\n * ```ts\n * // Via a SearchParamsDefinition imported from the route's params.ts\n * const [params, setParams] = definition.useQueryStates()\n *\n * // Standalone with inline codecs\n * const [params, setParams] = useQueryStates({\n * page: fromSchema(z.coerce.number().int().min(1).default(1)),\n * })\n * ```\n *\n * There is deliberately no route-string form (`useQueryStates('/products')`).\n * Importing the definition from `params.ts` is the documented way to reach\n * another route's codecs — it needs no runtime registry lookup and so has no\n * \"not registered yet\" failure mode. See design/23-search-params.md\n * §\"Client Access\".\n */\nexport function useQueryStates<T extends Record<string, unknown>>(\n codecs: { [K in keyof T]: SearchParamCodec<T[K]> },\n options?: QueryStatesOptions,\n urlKeys?: Readonly<Record<string, string>>\n): [T, SetParams<T>] {\n const bridged = bridgeCodecs(codecs);\n\n // `withUrlKey` attaches the alias to the codec itself — that is the design's\n // \"URL keys travel with codecs\" principle — so the aliases are derivable\n // here and must be, for the inline codec-map form: nobody passes `urlKeys`\n // on that path, and without this an aliased bundle silently read and wrote\n // the property name instead of the alias. `bindUseQueryStates` still passes\n // the definition's precomputed map, which wins on conflict; it is built from\n // these same codecs, so the two agree by construction rather than by luck.\n const resolvedUrlKeys = { ...deriveUrlKeys(codecs), ...urlKeys };\n\n // Every hook option goes to nuqs whole, so an option nuqs adds later works\n // with no change here (TIM-1623: a field-by-field copy silently dropped\n // `limitUrlUpdates`). These are the defaults for every setter call from\n // this hook; nuqs resolves each write as per-call ?? hook ?? adapter\n // default. `urlKeys` is spread last: timber owns it, and nuqs's `Options`\n // does not declare it, so only an untyped caller could have supplied one.\n const nuqsOptions: Partial<UseQueryStatesOptions<BridgedParsers>> = {\n ...options,\n urlKeys: resolvedUrlKeys,\n };\n\n let values: Record<string, unknown>;\n let setValues: SetValues<BridgedParsers>;\n try {\n [values, setValues] = nuqsUseQueryStates(bridged, nuqsOptions);\n } catch (err) {\n if (\n err instanceof Error &&\n /Invalid hook call|cannot be called|Cannot read properties of null/i.test(err.message)\n ) {\n throw new Error(\n 'useQueryStates is a client component hook and cannot be called outside a React component. ' +\n 'Use definition.parse(searchParams) in server components instead.'\n );\n }\n throw err;\n }\n\n // Unwrap the null/undefined sentinels the bridge injected (see Codec\n // Bridge above) so callers see exactly what server-side parse() returns.\n // Copy-on-write preserves the identity of nuqs's memoized values object\n // when nothing needs unwrapping.\n let normalized = values;\n for (const key of Object.keys(bridged)) {\n const value = normalized[key];\n if (value === NULL_SENTINEL || value === UNDEFINED_SENTINEL) {\n if (normalized === values) normalized = { ...values };\n normalized[key] = unwrapNuqsValue(value);\n }\n }\n\n // Wrap the nuqs setter to match timber's SetParams<T> signature.\n // nuqs's setter accepts Partial<Nullable<Values>> | UpdaterFn | null.\n // timber's setter accepts Partial<T> with optional SetParamsOptions.\n // `setOptions` is nuqs's own `Options` and is forwarded untouched — see\n // the hook options above.\n const setParams: SetParams<T> = (partial, setOptions?) => {\n // nuqs's update loop skips undefined entries and treats null as a\n // key deletion before serialize runs. Timber semantics:\n // - setParams({ q: undefined }) must clear ?q= (absent = undefined),\n // so explicit undefined maps to a null deletion.\n // - setParams({ q: null }) clears the key only when the codec encodes\n // null as \"omit\" (serialize(null) === null). If the codec encodes\n // null as a real query value, forward the sentinel so the bridged\n // serialize writes it — matching definition.serialize({ q: null }).\n let forwarded: Record<string, unknown> = partial;\n for (const key of Object.keys(partial)) {\n const value = partial[key as keyof T];\n if (value === undefined) {\n if (forwarded === partial) forwarded = { ...partial };\n forwarded[key] = null;\n } else if (value === null) {\n let encoded: string | string[] | null = null;\n try {\n const raw = codecs[key as keyof T]?.serialize(null as T[keyof T]);\n // string[] is non-null, but an empty array carries no value\n encoded = raw === null ? null : Array.isArray(raw) ? (raw.length > 0 ? raw : null) : raw;\n } catch {\n // Codec can't serialize null — treat as a deletion.\n }\n if (encoded !== null) {\n if (forwarded === partial) forwarded = { ...partial };\n forwarded[key] = NULL_SENTINEL;\n }\n }\n }\n void setValues(forwarded, setOptions);\n };\n\n return [normalized as T, setParams];\n}\n\n// ─── Definition binding ───────────────────────────────────────────\n\n/**\n * Create a useQueryStates binding for a SearchParamsDefinition.\n * This is used internally by SearchParamsDefinition.useQueryStates().\n */\nexport function bindUseQueryStates<T extends Record<string, unknown>>(\n definition: SearchParamsDefinition<T>\n): (options?: QueryStatesOptions) => [T, SetParams<T>] {\n return (options?: QueryStatesOptions) => {\n return useQueryStates<T>(definition.codecs, options, definition.urlKeys);\n };\n}\n"],"mappings":";;AAyEA,SAAS,mBACP,OAC4C;CAC5C,OAAO,OAAQ,MAAiC,oBAAoB;AACtE;;;;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AO;GACpD,WAAW,OAAO,gBAAgB,KAAK;EACzC;CACF;CAOA,MAAM,aAA2B,SAAS,eAAgB;EASxD,IAAI,YAAqC;EACzC,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,GAAG;GACtC,MAAM,QAAQ,QAAQ;GACtB,IAAI,UAAU,KAAA,GAAW;IACvB,IAAI,cAAc,SAAS,YAAY,EAAE,GAAG,QAAQ;IACpD,UAAU,OAAO;GACnB,OAAO,IAAI,UAAU,MAAM;IACzB,IAAI,UAAoC;IACxC,IAAI;KACF,MAAM,MAAM,OAAO,IAAe,EAAE,UAAU,IAAkB;KAEhE,UAAU,QAAQ,OAAO,OAAO,MAAM,QAAQ,GAAG,IAAK,IAAI,SAAS,IAAI,MAAM,OAAQ;IACvF,QAAQ,CAER;IACA,IAAI,YAAY,MAAM;KACpB,IAAI,cAAc,SAAS,YAAY,EAAE,GAAG,QAAQ;KACpD,UAAU,OAAO;IACnB;GACF;EACF;EACA,UAAe,WAAW,UAAU;CACtC;CAEA,OAAO,CAAC,YAAiB,SAAS;AACpC;;;;;AAQA,SAAgB,mBACd,YACqD;CACrD,QAAQ,YAAiC;EACvC,OAAOD,iBAAkB,WAAW,QAAQ,SAAS,WAAW,OAAO;CACzE;AACF"}
|
package/dist/client/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { n as interpolateParams, r as resolveHref } from "../_chunks/href-BtspoN
|
|
|
8
8
|
import { i as useNavigationContext, n as usePendingNavigation, o as getRouterOrNull } from "../_chunks/navigation-root-CoGHIMiE.js";
|
|
9
9
|
import { t as getSsrData } from "../_chunks/ssr-data-9hPtcNOr.js";
|
|
10
10
|
import { n as useSegmentContext } from "../_chunks/segment-context-GAyTjjtS.js";
|
|
11
|
-
import { n as useQueryStates } from "../_chunks/use-query-states-
|
|
11
|
+
import { n as useQueryStates } from "../_chunks/use-query-states-D3MMl-KM.js";
|
|
12
12
|
import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
13
13
|
import { flushSync } from "react-dom";
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
package/dist/client/internal.js
CHANGED
|
@@ -6,7 +6,7 @@ import { a as getRouter, i as useNavigationContext, o as getRouterOrNull, r as N
|
|
|
6
6
|
import { n as registerSsrDataProvider, t as getSsrData } from "../_chunks/ssr-data-9hPtcNOr.js";
|
|
7
7
|
import { n as useSegmentContext, t as SegmentProvider } from "../_chunks/segment-context-GAyTjjtS.js";
|
|
8
8
|
import { a as createSpaExits, c as createRenderOwner, d as fetchRscPayload, f as readPayloadTree, i as createScrollEffects, l as isClientStale, n as TimberErrorBoundary, o as runAsHandle, p as readPublishedParams, r as createNavigationRecovery, s as recordSkew, u as NonRscResponse } from "../_chunks/error-boundary-OHK1mI99.js";
|
|
9
|
-
import { t as bindUseQueryStates } from "../_chunks/use-query-states-
|
|
9
|
+
import { t as bindUseQueryStates } from "../_chunks/use-query-states-D3MMl-KM.js";
|
|
10
10
|
// src/client/history.ts
|
|
11
11
|
/**
|
|
12
12
|
* Session-lived history stack keyed by URL. Enables instant back/forward
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuqs-adapter.d.ts","sourceRoot":"","sources":["../../src/client/nuqs-adapter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nuqs-adapter.d.ts","sourceRoot":"","sources":["../../src/client/nuqs-adapter.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAwJhD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAatE"}
|
|
@@ -33,7 +33,7 @@ import type { SearchParamCodec, SearchParamsDefinition, SetParams, QueryStatesOp
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function useQueryStates<T extends Record<string, unknown>>(codecs: {
|
|
35
35
|
[K in keyof T]: SearchParamCodec<T[K]>;
|
|
36
|
-
},
|
|
36
|
+
}, options?: QueryStatesOptions, urlKeys?: Readonly<Record<string, string>>): [T, SetParams<T>];
|
|
37
37
|
/**
|
|
38
38
|
* Create a useQueryStates binding for a SearchParamsDefinition.
|
|
39
39
|
* This is used internally by SearchParamsDefinition.useQueryStates().
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-query-states.d.ts","sourceRoot":"","sources":["../../src/client/use-query-states.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-query-states.d.ts","sourceRoot":"","sources":["../../src/client/use-query-states.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAyKpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,MAAM,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,EAClD,OAAO,CAAC,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACzC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CA4FnB;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACpC,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAIrD"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;AA+CjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAa1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1D,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,MAAM;CAAG;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAEvE;AAyGD,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,YAAY,EAAE,CA2XhE;eAEc,MAAM"}
|
package/dist/index.js
CHANGED
|
@@ -8134,6 +8134,58 @@ function timberClientInServerPackageDeps(rscEnvironmentName = "rsc") {
|
|
|
8134
8134
|
}
|
|
8135
8135
|
};
|
|
8136
8136
|
}
|
|
8137
|
+
// src/plugins/node-flight-builds.ts
|
|
8138
|
+
var SERVER_ENVIRONMENTS = /* @__PURE__ */ new Set(["rsc", "ssr"]);
|
|
8139
|
+
var VENDOR = "@vitejs/plugin-rsc/vendor/react-server-dom";
|
|
8140
|
+
var VENDOR_EDGE_RE = /^@vitejs\/plugin-rsc\/vendor\/react-server-dom\/(server|client|static)\.edge$/;
|
|
8141
|
+
var REACT_DOM_SERVER_RE = /^react-dom\/(server|static)(?:\.edge)?$/;
|
|
8142
|
+
/**
|
|
8143
|
+
* A server renderer specifier → its Node build; null for anything else.
|
|
8144
|
+
*
|
|
8145
|
+
* react-dom's bare `react-dom/server` already resolves to the Node build on
|
|
8146
|
+
* Node, but as a raw file: once `react-dom/server.node` is pre-bundled it
|
|
8147
|
+
* would be a second instance, so it is redirected too. SSR only: in RSC,
|
|
8148
|
+
* plugin-rsc rejects `react-dom/server`, and that error must stay.
|
|
8149
|
+
*/
|
|
8150
|
+
function nodeBuildOf(specifier, environmentName) {
|
|
8151
|
+
const vendor = VENDOR_EDGE_RE.exec(specifier);
|
|
8152
|
+
if (vendor) return `${VENDOR}/${vendor[1]}.node`;
|
|
8153
|
+
if (environmentName !== "ssr") return null;
|
|
8154
|
+
const reactDom = REACT_DOM_SERVER_RE.exec(specifier);
|
|
8155
|
+
if (reactDom) return `react-dom/${reactDom[1]}.node`;
|
|
8156
|
+
return null;
|
|
8157
|
+
}
|
|
8158
|
+
/**
|
|
8159
|
+
* The pre-bundle list with each edge build replaced by its Node build. A Node
|
|
8160
|
+
* build already listed is not listed twice.
|
|
8161
|
+
*/
|
|
8162
|
+
function withNodeFlightBuilds(include, environmentName) {
|
|
8163
|
+
return [...new Set(include.map((entry) => nodeBuildOf(entry, environmentName) ?? entry))];
|
|
8164
|
+
}
|
|
8165
|
+
function timberNodeFlightBuilds() {
|
|
8166
|
+
return {
|
|
8167
|
+
name: "timber-node-flight-builds",
|
|
8168
|
+
apply: "serve",
|
|
8169
|
+
enforce: "pre",
|
|
8170
|
+
configEnvironment: {
|
|
8171
|
+
order: "post",
|
|
8172
|
+
handler(name, config) {
|
|
8173
|
+
if (!SERVER_ENVIRONMENTS.has(name)) return;
|
|
8174
|
+
const deps = config.optimizeDeps;
|
|
8175
|
+
if (deps?.include) deps.include = withNodeFlightBuilds(deps.include, name);
|
|
8176
|
+
}
|
|
8177
|
+
},
|
|
8178
|
+
resolveId(source, importer, options) {
|
|
8179
|
+
if (!SERVER_ENVIRONMENTS.has(this.environment.name)) return;
|
|
8180
|
+
const nodeBuild = nodeBuildOf(source, this.environment.name);
|
|
8181
|
+
if (!nodeBuild) return;
|
|
8182
|
+
return this.resolve(nodeBuild, importer, {
|
|
8183
|
+
...options,
|
|
8184
|
+
skipSelf: true
|
|
8185
|
+
});
|
|
8186
|
+
}
|
|
8187
|
+
};
|
|
8188
|
+
}
|
|
8137
8189
|
// src/plugins/callsite-jsx.ts
|
|
8138
8190
|
/**
|
|
8139
8191
|
* Try to extract a static JSON-safe value from an AST expression node.
|
|
@@ -10727,6 +10779,7 @@ function timber(config) {
|
|
|
10727
10779
|
return [
|
|
10728
10780
|
rootSync,
|
|
10729
10781
|
timberReactResolve(),
|
|
10782
|
+
timberNodeFlightBuilds(),
|
|
10730
10783
|
timberReactProd(),
|
|
10731
10784
|
...patchReactCompilerForProdJsx(react({ compiler: effectiveReactCompiler || false })),
|
|
10732
10785
|
vitePluginRsc(createRscOptions(ctx, encryptionKeyExpr)),
|