react-router-sitemap-maker
Advanced tools
Comparing version 1.0.1 to 1.0.3
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = __importDefault(require("react")); | ||
const react_router_dom_1 = require("react-router-dom"); | ||
const react_1 = __importStar(require("react")); | ||
const createRoutesFromChildren = (children) => { | ||
let routes = []; | ||
react_1.default.Children.forEach(children, element => { | ||
if (!react_1.default.isValidElement(element) || (typeof element.type === "string" ? element.type : element.type.name) !== "Route") | ||
return; | ||
const props = element.props; | ||
if (element.type === react_1.Fragment) | ||
return routes.push.apply(routes, createRoutesFromChildren(props.children)); | ||
if (props.path === "*") | ||
return; | ||
let route = { | ||
caseSensitive: props.caseSensitive, | ||
element: props.element, | ||
index: props.index, | ||
path: props.path, | ||
}; | ||
if (props.children) | ||
route.children = createRoutesFromChildren(props.children); | ||
routes.push(route); | ||
}); | ||
return routes; | ||
}; | ||
const addBaseToPath = (routes, paths, base) => { | ||
@@ -20,6 +61,6 @@ routes.forEach((route) => { | ||
const ParseRoutes = (routes) => { | ||
if (!react_1.default.isValidElement(routes) || routes.type !== react_router_dom_1.Routes) | ||
if (!react_1.default.isValidElement(routes)) | ||
return []; | ||
const { children } = routes.props; | ||
const routePaths = (0, react_router_dom_1.createRoutesFromChildren)(children); | ||
const routePaths = createRoutesFromChildren(children); | ||
const paths = []; | ||
@@ -38,1 +79,2 @@ routePaths.forEach((route) => { | ||
exports.default = ParseRoutes; | ||
; |
@@ -32,2 +32,4 @@ "use strict"; | ||
this.Options = options; | ||
if (options.hashrouting) | ||
this.Routes.push(`${options.baseUrl}/`); | ||
} | ||
@@ -34,0 +36,0 @@ getRoutes = () => this.Routes; |
{ | ||
"name": "react-router-sitemap-maker", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Generates a sitemap from react-router-dom routes", | ||
@@ -32,3 +32,3 @@ "author": "RikThePixel", | ||
"react": "^18.1.0", | ||
"react-router-dom": "^6.3.0", | ||
"react-router-dom": ">=6.0.0", | ||
"ts-mocha": "^10.0.0", | ||
@@ -38,3 +38,4 @@ "typescript": "^4.6.4" | ||
"peerDependencies": { | ||
"react": "*" | ||
"react": "*", | ||
"react-router-dom": ">=6.0.0" | ||
}, | ||
@@ -41,0 +42,0 @@ "keywords": [ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9668
179
0
2