uikit-v1.2.4-next-pages-batching-default
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 52s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s

This commit is contained in:
Mohamadzadeh 2026-10-26 14:43:12 +03:30
parent 0f98a51070
commit cedfc4d688
18 changed files with 174 additions and 38 deletions

11
BATCHING_DEFAULT_1.2.4.md Normal file
View File

@ -0,0 +1,11 @@
# UI Kit 1.2.4 — NextPagesRouter batching default
- `NextPagesRouter` in `uikit/next-pages-router` now enables `options.enableBatching` by default, in addition to the existing `shallow=true` default. Usage: `<NextPagesRouter />`.
- To override: `<NextPagesRouter options={{ enableBatching: false }} />`.
- Additional `options` values are preserved while applying the default.
- `NextAppRouter`, API, Keycloak, Permission, legacy `uikit/core`, and other components are unchanged.
- The published `dist/next-pages-router.js` and legacy-path alias `dist/provider-next-pages-router.js` are updated consistently.
- README and developer demo are updated to show the new default.
- Tests cover both default and explicit override with mixed options.
Note: run a full `yarn install && yarn build` in the project build environment before deployment; dependencies are unavailable in this artifact environment.

View File

@ -33,6 +33,7 @@ import { Keycloak, useKeycloak } from "uikit/keycloak";
برای Permission جدید: `uikit/permission`.
برای Axios Context جدید: `uikit/api` و Hook `useApi`.
در `uikit/next-pages-router` مقدارهای پیش‌فرض `shallow=true` و `options.enableBatching=true` هستند؛ می‌توان آن‌ها را صریحاً override کرد.
`logoutOnUnauthorized` اختیاری است و در حالت ماژولار پیش‌فرض `false` دارد.
در `Api` و `Permission` ترتیب توکن یکسان است: ابتدا Keycloak، سپس `getToken` خارجی و در نبود هر دو بدون Bearer. استفاده از `getToken` به حضور Keycloak وابسته نیست. `auth={false}` در `Api` تزریق خودکار توکن را خاموش می‌کند.

View File

@ -462,7 +462,7 @@ function Users() {
### uikit/next-pages-router
**`NextPagesRouter`**: marker برای `QueryParamProvider` در Next.js Pages Router. `shallow` به صورت پیش‌فرض `true` است؛ سایر props مانند `options` به QueryParamProvider منتقل می‌شوند. از `useQueryParam` و `StringParam` در `use-query-params` استفاده کنید؛ اینها export مسیر UI Kit نیستند. **با QueryParamProvider دستی یا NextAppRouter هم‌زمان اضافه نشود.**
**`NextPagesRouter`**: marker برای `QueryParamProvider` در Next.js Pages Router. `shallow` و `options.enableBatching` هر دو به صورت پیش‌فرض `true` هستند. سایر گزینه‌های `options` به QueryParamProvider منتقل می‌شوند؛ در صورت نیاز می‌توانید با `options={{ enableBatching: false }}` پیش‌فرض را غیرفعال کنید. از `useQueryParam` و `StringParam` در `use-query-params` استفاده کنید؛ اینها export مسیر UI Kit نیستند. **با QueryParamProvider دستی یا NextAppRouter هم‌زمان اضافه نشود.**
```jsx
// Next.js Pages Router: pages/_app.jsx
@ -473,10 +473,7 @@ import { useQueryParam, StringParam } from "use-query-params";
export default function MyApp({ Component, pageProps }) {
return (
<BiProvider>
<NextPagesRouter
shallow={true}
options={{ enableBatching: true }}
/>
<NextPagesRouter />
<Component {...pageProps} />
</BiProvider>
);
@ -490,6 +487,8 @@ export function SearchFilter() {
);
}
// پیش‌فرض‌ها: shallow=true و enableBatching=true
// برای غیرفعال‌سازی batching: <NextPagesRouter options={{ enableBatching: false }} />
// NextPagesRouter فقط برای Pages Router است؛ اگر از قبل
// QueryParamProvider دارید، هر دو را هم‌زمان اضافه نکنید.
```

View File

@ -0,0 +1,9 @@
# UI Kit 1.2.3 — Next.js Query Params adapter compatibility
Fixed `uikit/next-pages-router` (and the matching `uikit/next-app-router`) to handle the nested CommonJS/ESM exports returned by `next-query-params` in Next.js/Webpack. Previously the adapter could be a plain object, causing `QueryParamProvider` to throw `Element type is invalid`.
No API or component prop changes are required. Continue using `<NextPagesRouter shallow={true} options={{ enableBatching: true }} />` inside `<BiProvider>`. No standalone `QueryParamProvider` is necessary after upgrading to the patched UI Kit.
The UI Kit package version has been set to 1.2.3 in this archive. Publish this version/tag in your own Git repository before updating downstream Git dependency references.
Changes limited to both Next.js router adapters, their built outputs, the adapter resolution helper, and this release note/version. Other providers and UI Kit components remain unchanged.

View File

@ -0,0 +1,17 @@
function u(f, n) {
const r = /* @__PURE__ */ new Set();
let e = f;
for (let o = 0; o < 6 && e != null && !r.has(e); o += 1) {
if (typeof e == "function") return e;
if (typeof e != "object") break;
r.add(e);
const t = e[n];
if (typeof t == "function") return t;
if (t && typeof t.default == "function") return t.default;
e = e.default;
}
throw new Error(`uikit: Unable to resolve ${n} from next-query-params.`);
}
export {
u as r
};

View File

@ -1,13 +1,15 @@
"use client";
import { jsx as e } from "react/jsx-runtime";
import { jsx as t } from "react/jsx-runtime";
import "react";
import p from "next-query-params/app";
import * as p from "next-query-params/app";
import { QueryParamProvider as o } from "use-query-params";
import { d as m } from "./chunks/feature-registry-B2iuEiEx.js";
function a({ children: r, ...t }) {
return /* @__PURE__ */ e(o, { adapter: p, ...t, children: r });
import { d as a } from "./chunks/feature-registry-B2iuEiEx.js";
import { r as m } from "./chunks/resolve-next-adapter-DK8qNoX5.js";
const A = m(p, "NextAdapterApp");
function d({ children: r, ...e }) {
return /* @__PURE__ */ t(o, { adapter: A, ...e, children: r });
}
const n = m("NextAppRouter", 30, a);
const u = a("NextAppRouter", 30, d);
export {
n as NextAppRouter
u as NextAppRouter
};

View File

@ -1,2 +1,2 @@
export interface NextPagesRouterProps { shallow?: boolean; [prop: string]: unknown }
export interface NextPagesRouterProps { shallow?: boolean; options?: { enableBatching?: boolean; [key: string]: unknown }; [prop: string]: unknown }
export declare function NextPagesRouter(props: NextPagesRouterProps): null;

View File

@ -1,15 +1,17 @@
"use client";
import { jsx as e } from "react/jsx-runtime";
import "react";
import r from "next-query-params/pages";
import { QueryParamProvider as s } from "use-query-params";
import { d as u } from "./chunks/feature-registry-B2iuEiEx.js";
function m({ children: t, shallow: o = !0, ...a }) {
return /* @__PURE__ */ e(s, { adapter: o ? r : function(n) {
import * as p from "next-query-params/pages";
import { QueryParamProvider as i } from "use-query-params";
import { d as m } from "./chunks/feature-registry-B2iuEiEx.js";
import { r as d } from "./chunks/resolve-next-adapter-DK8qNoX5.js";
const r = d(p, "NextAdapterPages");
function u({ children: t, shallow: a = !0, options: o = {}, ...s }) {
return /* @__PURE__ */ e(i, { adapter: a ? r : function(n) {
return /* @__PURE__ */ e(r, { ...n, shallow: !1 });
}, ...a, children: t });
}, options: { enableBatching: !0, ...o }, ...s, children: t });
}
const c = u("NextPagesRouter", 30, m);
const A = m("NextPagesRouter", 30, u);
export {
c as NextPagesRouter
A as NextPagesRouter
};

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="light" />
<title>UI Kit Remote Demo</title>
<script type="module" crossorigin src="./demo-assets/index-D8dVDvmu.js"></script>
<script type="module" crossorigin src="./demo-assets/index-DNhZDl2y.js"></script>
</head>
<body>
<div id="root"></div>

View File

@ -1,6 +1,6 @@
{
"name": "uikit",
"version": "1.2.2",
"version": "1.2.4",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",

View File

@ -253,10 +253,7 @@ import { useQueryParam, StringParam } from "use-query-params";
export default function MyApp({ Component, pageProps }) {
return (
<BiProvider>
<NextPagesRouter
shallow={true}
options={{ enableBatching: true }}
/>
<NextPagesRouter />
<Component {...pageProps} />
</BiProvider>
);
@ -270,6 +267,8 @@ export function SearchFilter() {
);
}
// پیش‌فرض‌ها: shallow=true و enableBatching=true
// برای غیرفعال‌سازی batching: <NextPagesRouter options={{ enableBatching: false }} />
// NextPagesRouter فقط برای Pages Router است؛ اگر از قبل
// QueryParamProvider دارید، هر دو را هم‌زمان اضافه نکنید.`;

View File

@ -0,0 +1,19 @@
"use client";
// Next.js/Webpack and Vite can expose next-query-params adapters through
// different CJS/ESM interop layers. Resolve the actual React component instead
// of passing an object to QueryParamProvider's `adapter` prop.
export function resolveNextAdapter(module, exportName) {
const seen = new Set();
let current = module;
for (let depth = 0; depth < 6 && current != null && !seen.has(current); depth += 1) {
if (typeof current === "function") return current;
if (typeof current !== "object") break;
seen.add(current);
const named = current[exportName];
if (typeof named === "function") return named;
if (named && typeof named.default === "function") return named.default;
current = current.default;
}
throw new Error(`uikit: Unable to resolve ${exportName} from next-query-params.`);
}

View File

@ -1,9 +1,12 @@
"use client";
import React from "react";
import NextAdapterApp from "next-query-params/app";
import * as nextAdapterAppModule from "next-query-params/app";
import { QueryParamProvider } from "use-query-params";
import { defineFeature } from "../internal/feature-registry.jsx";
import { resolveNextAdapter } from "../internal/resolve-next-adapter.js";
const NextAdapterApp = resolveNextAdapter(nextAdapterAppModule, "NextAdapterApp");
function NextAppLayer({ children, ...props }) {
return <QueryParamProvider adapter={NextAdapterApp} {...props}>{children}</QueryParamProvider>;

View File

@ -1,2 +1,2 @@
export interface NextPagesRouterProps { shallow?: boolean; [prop: string]: unknown }
export interface NextPagesRouterProps { shallow?: boolean; options?: { enableBatching?: boolean; [key: string]: unknown }; [prop: string]: unknown }
export declare function NextPagesRouter(props: NextPagesRouterProps): null;

View File

@ -1,15 +1,18 @@
"use client";
import React from "react";
import NextAdapterPages from "next-query-params/pages";
import * as nextAdapterPagesModule from "next-query-params/pages";
import { QueryParamProvider } from "use-query-params";
import { defineFeature } from "../internal/feature-registry.jsx";
import { resolveNextAdapter } from "../internal/resolve-next-adapter.js";
function NextPagesLayer({ children, shallow = true, ...props }) {
const NextAdapterPages = resolveNextAdapter(nextAdapterPagesModule, "NextAdapterPages");
function NextPagesLayer({ children, shallow = true, options = {}, ...props }) {
const adapter = shallow ? NextAdapterPages : function UnshallowAdapter(adapterProps) {
return <NextAdapterPages {...adapterProps} shallow={false} />;
};
return <QueryParamProvider adapter={adapter} {...props}>{children}</QueryParamProvider>;
return <QueryParamProvider adapter={adapter} options={{ enableBatching: true, ...options }} {...props}>{children}</QueryParamProvider>;
}
export const NextPagesRouter = defineFeature("NextPagesRouter", 30, NextPagesLayer);

View File

@ -0,0 +1,72 @@
import assert from 'node:assert/strict';
import { mkdtemp, mkdir, copyFile, writeFile, rm } from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { resolveNextAdapter } from '../src/internal/resolve-next-adapter.js';
function Adapter() {}
const samples = [
Adapter,
{ default: Adapter },
{ NextAdapterPages: Adapter },
{ default: { default: Adapter } },
{ default: { NextAdapterPages: Adapter } },
{ NextAdapterPages: { default: Adapter } },
];
for (const sample of samples) {
assert.equal(resolveNextAdapter(sample, 'NextAdapterPages'), Adapter);
}
assert.throws(() => resolveNextAdapter({default: {}}, 'NextAdapterPages'), /Unable to resolve/);
const temp = await mkdtemp(path.join(os.tmpdir(), 'uikit-next-interop-'));
try {
await writeFile(path.join(temp, 'package.json'), '{"type":"module"}');
await mkdir(path.join(temp, 'chunks'));
await copyFile('dist/chunks/_shared-DHh79jO9.js', path.join(temp, 'chunks/_shared-DHh79jO9.js'));
await copyFile('dist/next-pages-router.js', path.join(temp, 'next-pages-router.js'));
await copyFile('dist/provider-next-pages-router.js', path.join(temp, 'provider-next-pages-router.js'));
await copyFile('dist/next-app-router.js', path.join(temp, 'next-app-router.js'));
const createPackage = async (name, files, pkg) => {
const dir=path.join(temp,'node_modules',name);
await mkdir(dir,{recursive:true});
await writeFile(path.join(dir,'package.json'),JSON.stringify(pkg));
for(const [file,content] of Object.entries(files)) await writeFile(path.join(dir,file),content);
};
await createPackage('react',{
'index.js': `const React={isValidElement:()=>false};export default React;`,
'jsx-runtime.js': `export function jsx(type, props){return {type,props};} export {jsx as jsxs};`
},{name:'react',type:'module',exports:{'.':'./index.js','./jsx-runtime':'./jsx-runtime.js'}});
await createPackage('next-query-params',{
'pages.js': 'export default {default: function PagesAdapter(){}};',
'app.js': 'export const NextAdapterApp = function AppAdapter(){};'
},{name:'next-query-params',type:'module',exports:{'./pages':'./pages.js','./app':'./app.js'}});
await createPackage('use-query-params',{
'index.js': 'export function QueryParamProvider() {}'
},{name:'use-query-params',type:'module',exports:{'.':'./index.js'}});
const pages = await import(pathToFileURL(path.join(temp,'next-pages-router.js')));
const app = await import(pathToFileURL(path.join(temp,'next-app-router.js')));
const legacyPages = await import(pathToFileURL(path.join(temp,'provider-next-pages-router.js')));
const feature = Symbol.for('uikit.provider.feature.v1');
const pagesLayer = pages.NextPagesRouter[feature].Provider;
const p = pagesLayer({children:'app',shallow:true});
assert.equal(p.type.name,'QueryParamProvider');
assert.equal(typeof p.props.adapter,'function');
assert.equal(p.props.adapter.name,'PagesAdapter');
assert.deepEqual(p.props.options, {enableBatching:true}, 'enableBatching defaults to true');
const extra = pagesLayer({children:'app',options:{skipNull:true}});
assert.deepEqual(extra.props.options, {enableBatching:true,skipNull:true}, 'custom options merge with defaults');
const disabled = pagesLayer({children:'app',options:{enableBatching:false,skipNull:true}});
assert.deepEqual(disabled.props.options, {enableBatching:false,skipNull:true}, 'explicit false overrides default');
const legacyLayer = legacyPages.NextPagesRouter[feature].Provider;
assert.equal(legacyLayer({children:'app'}).props.options.enableBatching,true, 'old subpath alias matches new behavior');
const p2 = pagesLayer({children:'app',shallow:false});
assert.equal(typeof p2.props.adapter,'function');
const nested = p2.props.adapter({a:1});
assert.equal(nested.type.name,'PagesAdapter');
assert.equal(nested.props.shallow,false);
const a = app.NextAppRouter[feature].Provider({children:'app'});
assert.equal(a.props.adapter.name,'AppAdapter');
assert.equal(a.props.options,undefined,'App Router default is unchanged');
console.log('PASS: Pages default batching=true, override=false, extra options, shallow routing, old alias; App Router unchanged.');
} finally {await rm(temp,{force:true,recursive:true});}