@wipco/sdui 1.0.0 → 1.0.1
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/index.js +19 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -2503,6 +2503,11 @@ function SduiFragmentBody({
|
|
|
2503
2503
|
}
|
|
2504
2504
|
return /* @__PURE__ */ jsx(SduiFragmentChainContext.Provider, { value: nextChain, children: page.body.map((child, i) => renderChild(child, i, bodyScope, engine)) });
|
|
2505
2505
|
}
|
|
2506
|
+
function urlSeedSettled(state, seeded, baseline) {
|
|
2507
|
+
return Object.keys(seeded).every(
|
|
2508
|
+
(key) => Object.is(state[key], seeded[key]) || !Object.is(state[key], baseline[key])
|
|
2509
|
+
);
|
|
2510
|
+
}
|
|
2506
2511
|
function SduiRenderer({
|
|
2507
2512
|
page,
|
|
2508
2513
|
registry = defaultRegistry,
|
|
@@ -2520,6 +2525,8 @@ function SduiRenderer({
|
|
|
2520
2525
|
});
|
|
2521
2526
|
const [state, setState] = useState(() => ({ ...initialState ?? {} }));
|
|
2522
2527
|
const urlSeeded = useRef(false);
|
|
2528
|
+
const urlSeedPending = useRef(null);
|
|
2529
|
+
const urlHomePath = useRef(typeof window !== "undefined" ? window.location.pathname : "");
|
|
2523
2530
|
const [toasts, setToasts] = useState([]);
|
|
2524
2531
|
const toastSeq = useRef(0);
|
|
2525
2532
|
const toastTimers = useRef([]);
|
|
@@ -2554,10 +2561,21 @@ function SduiRenderer({
|
|
|
2554
2561
|
}
|
|
2555
2562
|
}
|
|
2556
2563
|
}
|
|
2557
|
-
if (Object.keys(seeded).length > 0)
|
|
2564
|
+
if (Object.keys(seeded).length > 0) {
|
|
2565
|
+
const baseline = {};
|
|
2566
|
+
for (const key of Object.keys(seeded)) baseline[key] = stateRef.current[key];
|
|
2567
|
+
urlSeedPending.current = { seeded, baseline };
|
|
2568
|
+
setEntries(seeded);
|
|
2569
|
+
}
|
|
2558
2570
|
}, [page.urlState, setEntries, syncUrlState]);
|
|
2559
2571
|
useEffect(() => {
|
|
2560
2572
|
if (!syncUrlState || !page.urlState?.length || !urlSeeded.current || typeof window === "undefined") return;
|
|
2573
|
+
if (window.location.pathname !== urlHomePath.current) return;
|
|
2574
|
+
if (urlSeedPending.current) {
|
|
2575
|
+
const { seeded, baseline } = urlSeedPending.current;
|
|
2576
|
+
if (!urlSeedSettled(state, seeded, baseline)) return;
|
|
2577
|
+
urlSeedPending.current = null;
|
|
2578
|
+
}
|
|
2561
2579
|
const params = new URLSearchParams(window.location.search);
|
|
2562
2580
|
let changed = false;
|
|
2563
2581
|
for (const key of page.urlState) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wipco/sdui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "WIPCO 서버 주도 UI(SDUI) 렌더러 — JSON 페이지 스펙을 React 컴포넌트로 렌더링",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sdui",
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
"dev": "tsup --watch",
|
|
209
209
|
"typecheck": "tsc --noEmit",
|
|
210
210
|
"check:meta": "node scripts/check-meta.mjs",
|
|
211
|
-
"test": "tsx --test test/*.test.ts",
|
|
211
|
+
"test": "tsx --test test/*.test.ts test/*.test.tsx",
|
|
212
212
|
"prepack": "pnpm run build"
|
|
213
213
|
},
|
|
214
214
|
"peerDependencies": {
|
|
@@ -232,6 +232,9 @@
|
|
|
232
232
|
"devDependencies": {
|
|
233
233
|
"@types/react": "^19.0.0",
|
|
234
234
|
"@types/react-dom": "^19.0.0",
|
|
235
|
+
"jsdom": "^26.1.0",
|
|
236
|
+
"react": "^19.2.8",
|
|
237
|
+
"react-dom": "^19.2.8",
|
|
235
238
|
"tsup": "^8.5.0",
|
|
236
239
|
"tsx": "^4.20.0",
|
|
237
240
|
"typescript": "^5.7.0"
|