@akinon/next 2.0.0-beta.25 → 2.0.0-beta.27
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/CHANGELOG.md +14 -0
- package/hocs/server/with-segment-defaults.tsx +17 -1
- package/package.json +2 -2
- package/types/index.ts +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.27
|
|
4
|
+
|
|
5
|
+
## 2.0.0-beta.26
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- 09ccd457: ZERO-4371: Restore `URLSearchParams` type for `PageProps.searchParams` (v1 brand backward compat)
|
|
10
|
+
|
|
11
|
+
In v1 (`@akinon/next` 1.x) `PageProps.searchParams` was typed as `URLSearchParams`. Beta v2 widened this to a `Record<string, string | string[]> | URLSearchParams` union, which broke v1 brand pages calling `new URLSearchParams(searchParams)` (TS rejects the `Record<string, string[]>` arm of the union).
|
|
12
|
+
|
|
13
|
+
This restores the v1 contract — `PageProps.searchParams: URLSearchParams` — and adds a defensive runtime normalizer in the server `withSegmentDefaults` HOC so Next 16's raw `Record<string, string | string[]>` is converted to a real `URLSearchParams` instance before brand components see it. v1 brands can keep using `.get()`/`.has()`/etc safely without code changes.
|
|
14
|
+
|
|
15
|
+
A new `RawSearchParams` type is exported for code at the middleware/HOC boundary that needs to handle the unnormalized Next 16 shape directly.
|
|
16
|
+
|
|
3
17
|
## 2.0.0-beta.25
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -35,10 +35,26 @@ export const withSegmentDefaults =
|
|
|
35
35
|
? await props.searchParams
|
|
36
36
|
: undefined;
|
|
37
37
|
|
|
38
|
+
// Normalize Next 16's raw Record<string, string | string[]> shape into a
|
|
39
|
+
// URLSearchParams instance so v1 brands (which expect URLSearchParams) can
|
|
40
|
+
// call .get/.has/etc without runtime breakage.
|
|
41
|
+
const normalizedSearchParams =
|
|
42
|
+
resolvedSearchParams instanceof URLSearchParams
|
|
43
|
+
? resolvedSearchParams
|
|
44
|
+
: new URLSearchParams(
|
|
45
|
+
Object.entries(resolvedSearchParams ?? {}).flatMap(([k, v]) =>
|
|
46
|
+
Array.isArray(v)
|
|
47
|
+
? v.map((item): [string, string] => [k, String(item)])
|
|
48
|
+
: v != null
|
|
49
|
+
? ([[k, String(v)]] as [string, string][])
|
|
50
|
+
: []
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
|
|
38
54
|
let componentProps = {
|
|
39
55
|
...props,
|
|
40
56
|
params: resolvedParams,
|
|
41
|
-
searchParams:
|
|
57
|
+
searchParams: normalizedSearchParams,
|
|
42
58
|
...('children' in props ? { children: (props as any).children } : {})
|
|
43
59
|
} as T;
|
|
44
60
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.27",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"set-cookie-parser": "2.6.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@akinon/eslint-plugin-projectzero": "2.0.0-beta.
|
|
40
|
+
"@akinon/eslint-plugin-projectzero": "2.0.0-beta.27",
|
|
41
41
|
"@babel/core": "7.26.10",
|
|
42
42
|
"@babel/preset-env": "7.26.9",
|
|
43
43
|
"@babel/preset-typescript": "7.27.0",
|
package/types/index.ts
CHANGED
|
@@ -278,7 +278,12 @@ export interface PzSegmentsConfig {
|
|
|
278
278
|
// Search params type compatible with both Next.js resolved searchParams and URLSearchParams
|
|
279
279
|
export type SearchParams = Record<string, string | string[] | undefined> | URLSearchParams;
|
|
280
280
|
|
|
281
|
-
//
|
|
281
|
+
// Raw Next 16 server prop shape, used at the middleware/HOC boundary before normalization
|
|
282
|
+
export type RawSearchParams = Record<string, string | string[] | undefined>;
|
|
283
|
+
|
|
284
|
+
// Page/Layout props — sync params for backward compatibility with v1 brands.
|
|
285
|
+
// `searchParams` is always exposed as `URLSearchParams` (matching v1 behavior).
|
|
286
|
+
// The server HOC normalizes Next 16's raw Record into a URLSearchParams instance.
|
|
282
287
|
export interface PageProps<T = any> {
|
|
283
288
|
params: T & {
|
|
284
289
|
pz?: string;
|
|
@@ -288,7 +293,7 @@ export interface PageProps<T = any> {
|
|
|
288
293
|
url?: string;
|
|
289
294
|
[key: string]: any;
|
|
290
295
|
};
|
|
291
|
-
searchParams:
|
|
296
|
+
searchParams: URLSearchParams;
|
|
292
297
|
}
|
|
293
298
|
|
|
294
299
|
export interface LayoutProps<T = any> extends PageProps<T> {
|
|
@@ -318,7 +323,7 @@ export interface AsyncPageProps<T = any> {
|
|
|
318
323
|
// Resolved (sync) versions for inner components after withSegmentDefaults resolves props
|
|
319
324
|
export interface ResolvedPageProps<T = any> {
|
|
320
325
|
params: T & { locale: string; currency: string };
|
|
321
|
-
searchParams:
|
|
326
|
+
searchParams: URLSearchParams;
|
|
322
327
|
}
|
|
323
328
|
|
|
324
329
|
export interface ResolvedLayoutProps<T = any> extends ResolvedPageProps<T> {
|