vibe-design-system 2.8.0 → 2.8.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/package.json
CHANGED
|
@@ -170,6 +170,40 @@ function getPreviewPath(projectRoot) {
|
|
|
170
170
|
return null;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// React Router hooks that require a Router wrapper in Storybook
|
|
174
|
+
const ROUTER_HOOKS = new Set([
|
|
175
|
+
"useLocation", "useNavigate", "useParams", "useSearchParams",
|
|
176
|
+
"useMatch", "useHref", "useResolvedPath", "useOutlet", "useOutletContext",
|
|
177
|
+
"useMatches", "useRouteError", "useNavigation", "useRevalidator",
|
|
178
|
+
]);
|
|
179
|
+
|
|
180
|
+
function detectRouterPackage(projectRoot) {
|
|
181
|
+
const pkgPath = path.join(projectRoot, "package.json");
|
|
182
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
183
|
+
try {
|
|
184
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
185
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
186
|
+
if (deps["react-router-dom"]) return "react-router-dom";
|
|
187
|
+
if (deps["react-router"]) return "react-router";
|
|
188
|
+
} catch (_) {}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function projectUsesRouterHooks(projectRoot) {
|
|
193
|
+
const srcDir = path.join(projectRoot, "src");
|
|
194
|
+
if (!fs.existsSync(srcDir)) return false;
|
|
195
|
+
const files = getAllSourceFiles(srcDir, srcDir).map((r) => path.join(projectRoot, "src", r));
|
|
196
|
+
for (const file of files) {
|
|
197
|
+
try {
|
|
198
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
199
|
+
for (const hook of ROUTER_HOOKS) {
|
|
200
|
+
if (new RegExp("\\b" + hook + "\\s*[(<(]").test(content)) return true;
|
|
201
|
+
}
|
|
202
|
+
} catch (_) {}
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
|
|
173
207
|
/** Detect if project uses react-dnd (useDrag, useDrop, or import from react-dnd). */
|
|
174
208
|
function detectReactDnd(projectRoot) {
|
|
175
209
|
const srcDir = path.join(projectRoot, "src");
|
|
@@ -231,6 +265,12 @@ function collectProvidersAndWarnings(projectRoot) {
|
|
|
231
265
|
hooksWithoutProvider.add(hook);
|
|
232
266
|
}
|
|
233
267
|
}
|
|
268
|
+
// MemoryRouter: wrap components that use React Router hooks
|
|
269
|
+
const routerPackage = detectRouterPackage(projectRoot);
|
|
270
|
+
if (routerPackage && projectUsesRouterHooks(projectRoot) && !providersToAdd.some((p) => p.name === "MemoryRouter")) {
|
|
271
|
+
providersToAdd.unshift({ name: "MemoryRouter", importPath: routerPackage, props: "{ initialEntries: [\"/\"] }" });
|
|
272
|
+
console.log("[VDS] React Router tespit edildi → MemoryRouter decorator ekleniyor.");
|
|
273
|
+
}
|
|
234
274
|
if (detectReactDnd(projectRoot) && !providersToAdd.some((p) => p.name === "DndProvider")) {
|
|
235
275
|
providersToAdd.unshift({
|
|
236
276
|
name: "DndProvider",
|