@akinon/next 2.0.0-beta.24 → 2.0.0-beta.26

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 2.0.0-beta.26
4
+
5
+ ### Patch Changes
6
+
7
+ - 09ccd457: ZERO-4371: Restore `URLSearchParams` type for `PageProps.searchParams` (v1 brand backward compat)
8
+
9
+ 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).
10
+
11
+ 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.
12
+
13
+ A new `RawSearchParams` type is exported for code at the middleware/HOC boundary that needs to handle the unnormalized Next 16 shape directly.
14
+
15
+ ## 2.0.0-beta.25
16
+
17
+ ### Patch Changes
18
+
19
+ - 05c19ad0: ZERO-4365: Remove brand `@theme/*` alias imports from library packages
20
+
3
21
  ## 2.0.0-beta.24
4
22
 
5
23
  ## 2.0.0-beta.23
@@ -1,5 +1,5 @@
1
1
  import { forwardRef } from 'react';
2
- import { SelectProps } from '@theme/components/types';
2
+ import type { SelectProps } from '@theme/components/types';
3
3
  import clsx from 'clsx';
4
4
  import { Icon } from './icon';
5
5
  import { twMerge } from 'tailwind-merge';
@@ -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: resolvedSearchParams,
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.24",
4
+ "version": "2.0.0-beta.26",
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.24",
40
+ "@akinon/eslint-plugin-projectzero": "2.0.0-beta.26",
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
- // Page/Layout props sync params for backward compatibility with v1 brands
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: 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: SearchParams;
326
+ searchParams: URLSearchParams;
322
327
  }
323
328
 
324
329
  export interface ResolvedLayoutProps<T = any> extends ResolvedPageProps<T> {