@arielgonzaguer/michi-router 3.0.3 → 3.3.0
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/README.md +2 -2
- package/dist/core.d.mts +12 -12
- package/dist/core.d.ts +12 -2
- package/dist/core.js +1 -9
- package/dist/core.mjs +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -3
- package/dist/index.js +7 -20
- package/dist/index.mjs +7 -7
- package/dist/protected.d.mts +7 -7
- package/dist/protected.d.ts +7 -2
- package/dist/protected.js +7 -8
- package/dist/protected.mjs +7 -7
- package/dist/{types-DvzlhMRY.d.mts → types-a1RLig1-.d.mts} +58 -58
- package/dist/{types-DvzlhMRY.d.ts → types-a1RLig1-.d.ts} +58 -58
- package/package.json +91 -82
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Router minimalista para React, enfocado en tamaño, DX y seguridad para navegaci
|
|
|
22
22
|
## Instalación
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
|
|
25
|
+
pnpm install @arielgonzaguer/michi-router
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Uso rápido
|
|
@@ -74,4 +74,4 @@ export default function App() {
|
|
|
74
74
|
- `@arielgonzaguer/michi-router/core`: router base sin `Protected`.
|
|
75
75
|
- `@arielgonzaguer/michi-router/protected`: export del componente `Protected`.
|
|
76
76
|
|
|
77
|
-
Documentación
|
|
77
|
+
[Documentación 😸](https://michirouter.netlify.app/)
|
package/dist/core.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { a as LinkProps, g as RouterProviderProps, f as RouterLocation, N as NavigateFn, d as RouteParams } from './types-
|
|
2
|
-
export { L as LayoutProps, b as NavigateOptions, R as Route, e as RouterContextType } from './types-
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import 'react';
|
|
5
|
-
|
|
6
|
-
declare function RouterProvider({ routes, children, notFound, basename, layout: Layout }: RouterProviderProps): react_jsx_runtime.JSX.Element;
|
|
7
|
-
declare const Link: ({ to, children, className, onClick, ...rest }: LinkProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
-
declare const useNavigate: () => NavigateFn;
|
|
9
|
-
declare const useLocation: () => RouterLocation;
|
|
10
|
-
declare const useParams: <T extends RouteParams = RouteParams>() => T;
|
|
11
|
-
|
|
12
|
-
export { Link, LinkProps, NavigateFn, RouteParams, RouterLocation, RouterProvider, RouterProviderProps, useLocation, useNavigate, useParams };
|
|
1
|
+
import { a as LinkProps, g as RouterProviderProps, f as RouterLocation, N as NavigateFn, d as RouteParams } from './types-a1RLig1-.mjs';
|
|
2
|
+
export { L as LayoutProps, b as NavigateOptions, R as Route, e as RouterContextType } from './types-a1RLig1-.mjs';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
declare function RouterProvider({ routes, children, notFound, basename, layout: Layout }: RouterProviderProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare const Link: ({ to, children, className, onClick, ...rest }: LinkProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const useNavigate: () => NavigateFn;
|
|
9
|
+
declare const useLocation: () => RouterLocation;
|
|
10
|
+
declare const useParams: <T extends RouteParams = RouteParams>() => T;
|
|
11
|
+
|
|
12
|
+
export { Link, LinkProps, NavigateFn, RouteParams, RouterLocation, RouterProvider, RouterProviderProps, useLocation, useNavigate, useParams };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
import { a as LinkProps, g as RouterProviderProps, f as RouterLocation, N as NavigateFn, d as RouteParams } from './types-a1RLig1-.js';
|
|
2
|
+
export { L as LayoutProps, b as NavigateOptions, R as Route, e as RouterContextType } from './types-a1RLig1-.js';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
declare function RouterProvider({ routes, children, notFound, basename, layout: Layout }: RouterProviderProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare const Link: ({ to, children, className, onClick, ...rest }: LinkProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const useNavigate: () => NavigateFn;
|
|
9
|
+
declare const useLocation: () => RouterLocation;
|
|
10
|
+
declare const useParams: <T extends RouteParams = RouteParams>() => T;
|
|
11
|
+
|
|
12
|
+
export { Link, LinkProps, NavigateFn, RouteParams, RouterLocation, RouterProvider, RouterProviderProps, useLocation, useNavigate, useParams };
|
package/dist/core.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useParams = exports.useNavigate = exports.useLocation = exports.RouterProvider = exports.Link = void 0;
|
|
4
|
-
var Michi_router_1 = require("./michi-router/Michi-router");
|
|
5
|
-
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Michi_router_1.Link; } });
|
|
6
|
-
Object.defineProperty(exports, "RouterProvider", { enumerable: true, get: function () { return Michi_router_1.RouterProvider; } });
|
|
7
|
-
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return Michi_router_1.useLocation; } });
|
|
8
|
-
Object.defineProperty(exports, "useNavigate", { enumerable: true, get: function () { return Michi_router_1.useNavigate; } });
|
|
9
|
-
Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return Michi_router_1.useParams; } });
|
|
1
|
+
"use strict";var v=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var n in e)v(t,n,{get:e[n],enumerable:!0})},A=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of b(e))!E.call(t,o)&&o!==n&&v(t,o,{get:()=>e[o],enumerable:!(r=O(e,o))||r.enumerable});return t};var U=t=>A(v({},"__esModule",{value:!0}),t);var q={};F(q,{Link:()=>I,RouterProvider:()=>k,useLocation:()=>z,useNavigate:()=>N,useParams:()=>B});module.exports=U(q);var c=require("react");var M="https://michi-router.local",W=new Set(["http:","https:"]),_=t=>t.startsWith("/")?t:`/${t}`,d=t=>{let e=t.trim();if(!e)return"/";let n=_(e);return(n.length>1?n.replace(/\/+$/,""):n)||"/"},L=t=>t?d(t):"/",D=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),H=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,j=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`,y=t=>{try{return decodeURIComponent(t)}catch{return t}},w=(t,e="/")=>{if(typeof t!="string")return null;let n=t.trim();if(!n||/[\u0000-\u001f\u007f]/.test(n))return null;let r=L(e),o=typeof window<"u"?window.location.origin:M,i=r==="/"?`${o}/`:`${o}${r}/`,s;try{s=new URL(n,i)}catch{return null}if(!W.has(s.protocol)||typeof window<"u"&&s.origin!==window.location.origin)return null;let a=d(s.pathname),u=D(a,r)?d(H(a,r)):a,l=d(j(r,u)),m=s.search||"",p=s.hash||"",h=`${u}${m}${p}`,g=`${l}${m}${p}`;return{pathname:u,search:m,hash:p,fullPath:h,browserPath:g}},C=(t,e)=>{let n=d(t),r=d(e);if(n==="*")return{"*":r==="/"?"":r.slice(1)};let o=n==="/"?[]:n.slice(1).split("/"),i=r==="/"?[]:r.slice(1).split("/"),s={},a=0,u=0;for(;a<o.length&&u<i.length;){let l=o[a];if(l==="*"){if(a!==o.length-1)return null;s["*"]=i.slice(u).map(y).join("/"),u=i.length,a=o.length;break}let m=i[u];if(l.startsWith(":")){let p=l.slice(1);if(!p)return null;s[p]=y(m)}else if(l!==m)return null;a+=1,u+=1}return a<o.length&&o[a]==="*"&&a===o.length-1&&(s["*"]="",a+=1),a!==o.length||u!==i.length?null:s};var R=require("react/jsx-runtime"),x=typeof window<"u",T={pathname:"/",search:"",hash:"",fullPath:"/"},S=t=>{if(!x)return T;let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=w(e,t);if(n)return{pathname:n.pathname,search:n.search,hash:n.hash,fullPath:n.fullPath};let r=d(window.location.pathname);return{pathname:r,search:window.location.search,hash:window.location.hash,fullPath:`${r}${window.location.search}${window.location.hash}`}},P=(0,c.createContext)({path:"/",location:T,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});function k({routes:t,children:e,notFound:n,basename:r,layout:o}){let i=(0,c.useMemo)(()=>L(r),[r]),[s,a]=(0,c.useState)(()=>S(i));(0,c.useEffect)(()=>{if(!x)return;let h=()=>a(S(i));return window.addEventListener("popstate",h),()=>window.removeEventListener("popstate",h)},[i]);let u=(0,c.useCallback)((h,g)=>{let f=w(h,i);if(!f){console.warn(`MichiRouter: navegaci\xF3n bloqueada. URL interna no v\xE1lida: "${h}"`);return}let $={pathname:f.pathname,search:f.search,hash:f.hash,fullPath:f.fullPath};if(!x){a($);return}g?.replace?window.history.replaceState(g?.state??null,"",f.browserPath):window.history.pushState(g?.state??null,"",f.browserPath),a($)},[i]),l=(0,c.useMemo)(()=>{for(let h of t){let g=C(h.path,s.pathname);if(g)return{route:h,params:g}}return null},[s.pathname,t]),m=l?.params??{},p=l?l.route.component:n??e;return(0,R.jsx)(P.Provider,{value:{path:s.pathname,location:s,params:m,basename:i,navigate:u},children:o?(0,R.jsx)(o,{children:p}):p})}var I=({to:t,children:e,className:n,onClick:r,...o})=>{let{navigate:i,basename:s}=(0,c.useContext)(P),a=w(t,s),u=a?a.browserPath:"#";return(0,R.jsx)("a",{href:u,className:n,onClick:l=>{r?.(l),!l.defaultPrevented&&(l.preventDefault(),i(t))},...o,children:e})},N=()=>(0,c.useContext)(P).navigate,z=()=>(0,c.useContext)(P).location,B=()=>(0,c.useContext)(P).params;0&&(module.exports={Link,RouterProvider,useLocation,useNavigate,useParams});
|
package/dist/core.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as b,createContext as E,useContext as w,useEffect as F,useMemo as C,useState as A}from"react";var k="https://michi-router.local",I=new Set(["http:","https:"]),N=t=>t.startsWith("/")?t:`/${t}`,g=t=>{let e=t.trim();if(!e)return"/";let n=N(e);return(n.length>1?n.replace(/\/+$/,""):n)||"/"},R=t=>t?g(t):"/",z=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),B=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,O=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`,$=t=>{try{return decodeURIComponent(t)}catch{return t}},P=(t,e="/")=>{if(typeof t!="string")return null;let n=t.trim();if(!n||/[\u0000-\u001f\u007f]/.test(n))return null;let o=R(e),s=typeof window<"u"?window.location.origin:k,i=o==="/"?`${s}/`:`${s}${o}/`,a;try{a=new URL(n,i)}catch{return null}if(!I.has(a.protocol)||typeof window<"u"&&a.origin!==window.location.origin)return null;let r=g(a.pathname),c=z(r,o)?g(B(r,o)):r,u=g(O(o,c)),p=a.search||"",h=a.hash||"",l=`${c}${p}${h}`,m=`${u}${p}${h}`;return{pathname:c,search:p,hash:h,fullPath:l,browserPath:m}},y=(t,e)=>{let n=g(t),o=g(e);if(n==="*")return{"*":o==="/"?"":o.slice(1)};let s=n==="/"?[]:n.slice(1).split("/"),i=o==="/"?[]:o.slice(1).split("/"),a={},r=0,c=0;for(;r<s.length&&c<i.length;){let u=s[r];if(u==="*"){if(r!==s.length-1)return null;a["*"]=i.slice(c).map($).join("/"),c=i.length,r=s.length;break}let p=i[c];if(u.startsWith(":")){let h=u.slice(1);if(!h)return null;a[h]=$(p)}else if(u!==p)return null;r+=1,c+=1}return r<s.length&&s[r]==="*"&&r===s.length-1&&(a["*"]="",r+=1),r!==s.length||c!==i.length?null:a};import{jsx as L}from"react/jsx-runtime";var v=typeof window<"u",T={pathname:"/",search:"",hash:"",fullPath:"/"},S=t=>{if(!v)return T;let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=P(e,t);if(n)return{pathname:n.pathname,search:n.search,hash:n.hash,fullPath:n.fullPath};let o=g(window.location.pathname);return{pathname:o,search:window.location.search,hash:window.location.hash,fullPath:`${o}${window.location.search}${window.location.hash}`}},f=E({path:"/",location:T,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});function U({routes:t,children:e,notFound:n,basename:o,layout:s}){let i=C(()=>R(o),[o]),[a,r]=A(()=>S(i));F(()=>{if(!v)return;let l=()=>r(S(i));return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[i]);let c=b((l,m)=>{let d=P(l,i);if(!d){console.warn(`MichiRouter: navegaci\xF3n bloqueada. URL interna no v\xE1lida: "${l}"`);return}let x={pathname:d.pathname,search:d.search,hash:d.hash,fullPath:d.fullPath};if(!v){r(x);return}m?.replace?window.history.replaceState(m?.state??null,"",d.browserPath):window.history.pushState(m?.state??null,"",d.browserPath),r(x)},[i]),u=C(()=>{for(let l of t){let m=y(l.path,a.pathname);if(m)return{route:l,params:m}}return null},[a.pathname,t]),p=u?.params??{},h=u?u.route.component:n??e;return L(f.Provider,{value:{path:a.pathname,location:a,params:p,basename:i,navigate:c},children:s?L(s,{children:h}):h})}var M=({to:t,children:e,className:n,onClick:o,...s})=>{let{navigate:i,basename:a}=w(f),r=P(t,a),c=r?r.browserPath:"#";return L("a",{href:c,className:n,onClick:u=>{o?.(u),!u.defaultPrevented&&(u.preventDefault(),i(t))},...s,children:e})},W=()=>w(f).navigate,_=()=>w(f).location,D=()=>w(f).params;export{M as Link,U as RouterProvider,_ as useLocation,W as useNavigate,D as useParams};
|
|
1
|
+
import{useCallback as b,createContext as E,useContext as w,useEffect as F,useMemo as C,useState as A}from"react";var k="https://michi-router.local",I=new Set(["http:","https:"]),N=t=>t.startsWith("/")?t:`/${t}`,g=t=>{let e=t.trim();if(!e)return"/";let n=N(e);return(n.length>1?n.replace(/\/+$/,""):n)||"/"},R=t=>t?g(t):"/",z=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),B=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,O=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`,$=t=>{try{return decodeURIComponent(t)}catch{return t}},P=(t,e="/")=>{if(typeof t!="string")return null;let n=t.trim();if(!n||/[\u0000-\u001f\u007f]/.test(n))return null;let o=R(e),s=typeof window<"u"?window.location.origin:k,i=o==="/"?`${s}/`:`${s}${o}/`,a;try{a=new URL(n,i)}catch{return null}if(!I.has(a.protocol)||typeof window<"u"&&a.origin!==window.location.origin)return null;let r=g(a.pathname),c=z(r,o)?g(B(r,o)):r,u=g(O(o,c)),p=a.search||"",h=a.hash||"",l=`${c}${p}${h}`,m=`${u}${p}${h}`;return{pathname:c,search:p,hash:h,fullPath:l,browserPath:m}},y=(t,e)=>{let n=g(t),o=g(e);if(n==="*")return{"*":o==="/"?"":o.slice(1)};let s=n==="/"?[]:n.slice(1).split("/"),i=o==="/"?[]:o.slice(1).split("/"),a={},r=0,c=0;for(;r<s.length&&c<i.length;){let u=s[r];if(u==="*"){if(r!==s.length-1)return null;a["*"]=i.slice(c).map($).join("/"),c=i.length,r=s.length;break}let p=i[c];if(u.startsWith(":")){let h=u.slice(1);if(!h)return null;a[h]=$(p)}else if(u!==p)return null;r+=1,c+=1}return r<s.length&&s[r]==="*"&&r===s.length-1&&(a["*"]="",r+=1),r!==s.length||c!==i.length?null:a};import{jsx as L}from"react/jsx-runtime";var v=typeof window<"u",T={pathname:"/",search:"",hash:"",fullPath:"/"},S=t=>{if(!v)return T;let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=P(e,t);if(n)return{pathname:n.pathname,search:n.search,hash:n.hash,fullPath:n.fullPath};let o=g(window.location.pathname);return{pathname:o,search:window.location.search,hash:window.location.hash,fullPath:`${o}${window.location.search}${window.location.hash}`}},f=E({path:"/",location:T,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});function U({routes:t,children:e,notFound:n,basename:o,layout:s}){let i=C(()=>R(o),[o]),[a,r]=A(()=>S(i));F(()=>{if(!v)return;let l=()=>r(S(i));return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[i]);let c=b((l,m)=>{let d=P(l,i);if(!d){console.warn(`MichiRouter: navegaci\xF3n bloqueada. URL interna no v\xE1lida: "${l}"`);return}let x={pathname:d.pathname,search:d.search,hash:d.hash,fullPath:d.fullPath};if(!v){r(x);return}m?.replace?window.history.replaceState(m?.state??null,"",d.browserPath):window.history.pushState(m?.state??null,"",d.browserPath),r(x)},[i]),u=C(()=>{for(let l of t){let m=y(l.path,a.pathname);if(m)return{route:l,params:m}}return null},[a.pathname,t]),p=u?.params??{},h=u?u.route.component:n??e;return L(f.Provider,{value:{path:a.pathname,location:a,params:p,basename:i,navigate:c},children:s?L(s,{children:h}):h})}var M=({to:t,children:e,className:n,onClick:o,...s})=>{let{navigate:i,basename:a}=w(f),r=P(t,a),c=r?r.browserPath:"#";return L("a",{href:c,className:n,onClick:u=>{o?.(u),!u.defaultPrevented&&(u.preventDefault(),i(t))},...s,children:e})},W=()=>w(f).navigate,_=()=>w(f).location,D=()=>w(f).params;export{M as Link,U as RouterProvider,_ as useLocation,W as useNavigate,D as useParams};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AuthState, L as LayoutProps, a as LinkProps, N as NavigateFn, b as NavigateOptions, P as ProtectedConfig, c as ProtectedProps, R as Route, d as RouteParams, e as RouterContextType, f as RouterLocation, g as RouterProviderProps } from './types-
|
|
2
|
-
export { Link, RouterProvider, useLocation, useNavigate, useParams } from './core.mjs';
|
|
3
|
-
export { Protected } from './protected.mjs';
|
|
4
|
-
import 'react';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
1
|
+
export { A as AuthState, L as LayoutProps, a as LinkProps, N as NavigateFn, b as NavigateOptions, P as ProtectedConfig, c as ProtectedProps, R as Route, d as RouteParams, e as RouterContextType, f as RouterLocation, g as RouterProviderProps } from './types-a1RLig1-.mjs';
|
|
2
|
+
export { Link, RouterProvider, useLocation, useNavigate, useParams } from './core.mjs';
|
|
3
|
+
export { Protected } from './protected.mjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
1
|
+
export { A as AuthState, L as LayoutProps, a as LinkProps, N as NavigateFn, b as NavigateOptions, P as ProtectedConfig, c as ProtectedProps, R as Route, d as RouteParams, e as RouterContextType, f as RouterLocation, g as RouterProviderProps } from './types-a1RLig1-.js';
|
|
2
|
+
export { Link, RouterProvider, useLocation, useNavigate, useParams } from './core.js';
|
|
3
|
+
export { Protected } from './protected.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'react/jsx-runtime';
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Protected = void 0;
|
|
18
|
-
__exportStar(require("./core"), exports);
|
|
19
|
-
var protected_1 = require("./protected");
|
|
20
|
-
Object.defineProperty(exports, "Protected", { enumerable: true, get: function () { return protected_1.Protected; } });
|
|
1
|
+
"use strict";var C=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var O=(t,e)=>{for(var r in e)C(t,r,{get:e[r],enumerable:!0})},W=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of b(e))!F.call(t,o)&&o!==r&&C(t,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return t};var _=t=>W(C({},"__esModule",{value:!0}),t);var V={};O(V,{Link:()=>z,Protected:()=>x,RouterProvider:()=>I,useLocation:()=>B,useNavigate:()=>L,useParams:()=>M});module.exports=_(V);var c=require("react");var q="https://michi-router.local",D=new Set(["http:","https:"]),H=t=>t.startsWith("/")?t:`/${t}`,m=t=>{let e=t.trim();if(!e)return"/";let r=H(e);return(r.length>1?r.replace(/\/+$/,""):r)||"/"},y=t=>t?m(t):"/",G=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),K=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,J=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`,T=t=>{try{return decodeURIComponent(t)}catch{return t}},w=(t,e="/")=>{if(typeof t!="string")return null;let r=t.trim();if(!r||/[\u0000-\u001f\u007f]/.test(r))return null;let n=y(e),o=typeof window<"u"?window.location.origin:q,i=n==="/"?`${o}/`:`${o}${n}/`,a;try{a=new URL(r,i)}catch{return null}if(!D.has(a.protocol)||typeof window<"u"&&a.origin!==window.location.origin)return null;let s=m(a.pathname),l=G(s,n)?m(K(s,n)):s,u=m(J(n,l)),p=a.search||"",d=a.hash||"",h=`${l}${p}${d}`,f=`${u}${p}${d}`;return{pathname:l,search:p,hash:d,fullPath:h,browserPath:f}},k=(t,e)=>{let r=m(t),n=m(e);if(r==="*")return{"*":n==="/"?"":n.slice(1)};let o=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/"),a={},s=0,l=0;for(;s<o.length&&l<i.length;){let u=o[s];if(u==="*"){if(s!==o.length-1)return null;a["*"]=i.slice(l).map(T).join("/"),l=i.length,s=o.length;break}let p=i[l];if(u.startsWith(":")){let d=u.slice(1);if(!d)return null;a[d]=T(p)}else if(u!==p)return null;s+=1,l+=1}return s<o.length&&o[s]==="*"&&s===o.length-1&&(a["*"]="",s+=1),s!==o.length||l!==i.length?null:a};var v=require("react/jsx-runtime"),$=typeof window<"u",E={pathname:"/",search:"",hash:"",fullPath:"/"},N=t=>{if(!$)return E;let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,r=w(e,t);if(r)return{pathname:r.pathname,search:r.search,hash:r.hash,fullPath:r.fullPath};let n=m(window.location.pathname);return{pathname:n,search:window.location.search,hash:window.location.hash,fullPath:`${n}${window.location.search}${window.location.hash}`}},R=(0,c.createContext)({path:"/",location:E,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});function I({routes:t,children:e,notFound:r,basename:n,layout:o}){let i=(0,c.useMemo)(()=>y(n),[n]),[a,s]=(0,c.useState)(()=>N(i));(0,c.useEffect)(()=>{if(!$)return;let h=()=>s(N(i));return window.addEventListener("popstate",h),()=>window.removeEventListener("popstate",h)},[i]);let l=(0,c.useCallback)((h,f)=>{let P=w(h,i);if(!P){console.warn(`MichiRouter: navegaci\xF3n bloqueada. URL interna no v\xE1lida: "${h}"`);return}let S={pathname:P.pathname,search:P.search,hash:P.hash,fullPath:P.fullPath};if(!$){s(S);return}f?.replace?window.history.replaceState(f?.state??null,"",P.browserPath):window.history.pushState(f?.state??null,"",P.browserPath),s(S)},[i]),u=(0,c.useMemo)(()=>{for(let h of t){let f=k(h.path,a.pathname);if(f)return{route:h,params:f}}return null},[a.pathname,t]),p=u?.params??{},d=u?u.route.component:r??e;return(0,v.jsx)(R.Provider,{value:{path:a.pathname,location:a,params:p,basename:i,navigate:l},children:o?(0,v.jsx)(o,{children:d}):d})}var z=({to:t,children:e,className:r,onClick:n,...o})=>{let{navigate:i,basename:a}=(0,c.useContext)(R),s=w(t,a),l=s?s.browserPath:"#";return(0,v.jsx)("a",{href:l,className:r,onClick:u=>{n?.(u),!u.defaultPrevented&&(u.preventDefault(),i(t))},...o,children:e})},L=()=>(0,c.useContext)(R).navigate,B=()=>(0,c.useContext)(R).location,M=()=>(0,c.useContext)(R).params;var A=require("react");var g=require("react/jsx-runtime"),Q=t=>{let e=w(t,"/");return e?e.fullPath:"/"};function x({children:t,configObject:e}){let r=L(),n={states:e?.states||{user:null,isLoading:!1},redirectionPath:e?.redirectionPath||"/",loadingComponent:e?.loadingComponent||null,defaultMessage:e?.defaultMessage||void 0};if(!e?.states)return console.error(`Componente Protected: El objeto de configuraci\xF3n es inv\xE1lido. Este es el formato esperado:
|
|
2
|
+
{
|
|
3
|
+
states: { user: any; isLoading: boolean };
|
|
4
|
+
redirectionPath: string;
|
|
5
|
+
loadingComponent?: React.ReactNode;
|
|
6
|
+
defaultMessage?: string;
|
|
7
|
+
}`),null;let o=Q(n.redirectionPath),{user:i,isLoading:a}=n.states;return(0,A.useEffect)(()=>{!a&&!i&&(o!==n.redirectionPath&&console.warn(`Protected: redirectionPath inseguro bloqueado ("${n.redirectionPath}"). Se usa "/" como fallback.`),r(o,{replace:!0}))},[a,i,r,o,n.redirectionPath]),a?n.loadingComponent?(0,g.jsx)(g.Fragment,{children:n.loadingComponent}):n.defaultMessage?(0,g.jsx)(g.Fragment,{children:n.defaultMessage}):null:i?(0,g.jsx)(g.Fragment,{children:t}):null}0&&(module.exports={Link,Protected,RouterProvider,useLocation,useNavigate,useParams});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{useCallback as F,createContext as O,useContext as w,useEffect as W,useMemo as N,useState as _}from"react";var z="https://michi-router.local",B=new Set(["http:","https:"]),M=t=>t.startsWith("/")?t:`/${t}`,f=t=>{let e=t.trim();if(!e)return"/";let r=M(e);return(r.length>1?r.replace(/\/+$/,""):r)||"/"},R=t=>t?f(t):"/",A=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),U=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,b=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`,T=t=>{try{return decodeURIComponent(t)}catch{return t}},g=(t,e="/")=>{if(typeof t!="string")return null;let r=t.trim();if(!r||/[\u0000-\u001f\u007f]/.test(r))return null;let n=R(e),s=typeof window<"u"?window.location.origin:z,i=n==="/"?`${s}/`:`${s}${n}/`,o;try{o=new URL(r,i)}catch{return null}if(!B.has(o.protocol)||typeof window<"u"&&o.origin!==window.location.origin)return null;let a=f(o.pathname),c=A(a,n)?f(U(a,n)):a,l=f(b(n,c)),d=o.search||"",h=o.hash||"",u=`${c}${d}${h}`,p=`${l}${d}${h}`;return{pathname:c,search:d,hash:h,fullPath:u,browserPath:p}},k=(t,e)=>{let r=f(t),n=f(e);if(r==="*")return{"*":n==="/"?"":n.slice(1)};let s=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/"),o={},a=0,c=0;for(;a<s.length&&c<i.length;){let l=s[a];if(l==="*"){if(a!==s.length-1)return null;o["*"]=i.slice(c).map(T).join("/"),c=i.length,a=s.length;break}let d=i[c];if(l.startsWith(":")){let h=l.slice(1);if(!h)return null;o[h]=T(d)}else if(l!==d)return null;a+=1,c+=1}return a<s.length&&s[a]==="*"&&a===s.length-1&&(o["*"]="",a+=1),a!==s.length||c!==i.length?null:o};import{jsx as L}from"react/jsx-runtime";var v=typeof window<"u",I={pathname:"/",search:"",hash:"",fullPath:"/"},E=t=>{if(!v)return I;let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,r=g(e,t);if(r)return{pathname:r.pathname,search:r.search,hash:r.hash,fullPath:r.fullPath};let n=f(window.location.pathname);return{pathname:n,search:window.location.search,hash:window.location.hash,fullPath:`${n}${window.location.search}${window.location.hash}`}},P=O({path:"/",location:I,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});function q({routes:t,children:e,notFound:r,basename:n,layout:s}){let i=N(()=>R(n),[n]),[o,a]=_(()=>E(i));W(()=>{if(!v)return;let u=()=>a(E(i));return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[i]);let c=F((u,p)=>{let m=g(u,i);if(!m){console.warn(`MichiRouter: navegaci\xF3n bloqueada. URL interna no v\xE1lida: "${u}"`);return}let S={pathname:m.pathname,search:m.search,hash:m.hash,fullPath:m.fullPath};if(!v){a(S);return}p?.replace?window.history.replaceState(p?.state??null,"",m.browserPath):window.history.pushState(p?.state??null,"",m.browserPath),a(S)},[i]),l=N(()=>{for(let u of t){let p=k(u.path,o.pathname);if(p)return{route:u,params:p}}return null},[o.pathname,t]),d=l?.params??{},h=l?l.route.component:r??e;return L(P.Provider,{value:{path:o.pathname,location:o,params:d,basename:i,navigate:c},children:s?L(s,{children:h}):h})}var D=({to:t,children:e,className:r,onClick:n,...s})=>{let{navigate:i,basename:o}=w(P),a=g(t,o),c=a?a.browserPath:"#";return L("a",{href:c,className:r,onClick:l=>{n?.(l),!l.defaultPrevented&&(l.preventDefault(),i(t))},...s,children:e})},x=()=>w(P).navigate,H=()=>w(P).location,G=()=>w(P).params;import{useEffect as K}from"react";import{Fragment as C,jsx as y}from"react/jsx-runtime";var J=t=>{let e=g(t,"/");return e?e.fullPath:"/"};function $({children:t,configObject:e}){let r=x(),n={states:e?.states||{user:null,isLoading:!1},redirectionPath:e?.redirectionPath||"/",loadingComponent:e?.loadingComponent||null,defaultMessage:e?.defaultMessage||void 0};if(!e?.states)return console.error(`Componente Protected: El objeto de configuraci\xF3n es inv\xE1lido. Este es el formato esperado:
|
|
2
|
-
{
|
|
3
|
-
states: { user: any; isLoading: boolean };
|
|
4
|
-
redirectionPath: string;
|
|
5
|
-
loadingComponent?: React.ReactNode;
|
|
6
|
-
defaultMessage?: string;
|
|
7
|
-
}`),null;let s=J(n.redirectionPath),{user:i,isLoading:o}=n.states;return K(()=>{!o&&!i&&(s!==n.redirectionPath&&console.warn(`Protected: redirectionPath inseguro bloqueado ("${n.redirectionPath}"). Se usa "/" como fallback.`),r(s,{replace:!0}))},[o,i,r,s,n.redirectionPath]),o?n.loadingComponent?y(C,{children:n.loadingComponent}):n.defaultMessage?y(C,{children:n.defaultMessage}):null:i?y(C,{children:t}):null}export{D as Link,$ as Protected,q as RouterProvider,H as useLocation,x as useNavigate,G as useParams};
|
|
1
|
+
import{useCallback as F,createContext as O,useContext as w,useEffect as W,useMemo as N,useState as _}from"react";var z="https://michi-router.local",B=new Set(["http:","https:"]),M=t=>t.startsWith("/")?t:`/${t}`,f=t=>{let e=t.trim();if(!e)return"/";let r=M(e);return(r.length>1?r.replace(/\/+$/,""):r)||"/"},R=t=>t?f(t):"/",A=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),U=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,b=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`,T=t=>{try{return decodeURIComponent(t)}catch{return t}},g=(t,e="/")=>{if(typeof t!="string")return null;let r=t.trim();if(!r||/[\u0000-\u001f\u007f]/.test(r))return null;let n=R(e),s=typeof window<"u"?window.location.origin:z,i=n==="/"?`${s}/`:`${s}${n}/`,o;try{o=new URL(r,i)}catch{return null}if(!B.has(o.protocol)||typeof window<"u"&&o.origin!==window.location.origin)return null;let a=f(o.pathname),c=A(a,n)?f(U(a,n)):a,l=f(b(n,c)),d=o.search||"",h=o.hash||"",u=`${c}${d}${h}`,p=`${l}${d}${h}`;return{pathname:c,search:d,hash:h,fullPath:u,browserPath:p}},k=(t,e)=>{let r=f(t),n=f(e);if(r==="*")return{"*":n==="/"?"":n.slice(1)};let s=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/"),o={},a=0,c=0;for(;a<s.length&&c<i.length;){let l=s[a];if(l==="*"){if(a!==s.length-1)return null;o["*"]=i.slice(c).map(T).join("/"),c=i.length,a=s.length;break}let d=i[c];if(l.startsWith(":")){let h=l.slice(1);if(!h)return null;o[h]=T(d)}else if(l!==d)return null;a+=1,c+=1}return a<s.length&&s[a]==="*"&&a===s.length-1&&(o["*"]="",a+=1),a!==s.length||c!==i.length?null:o};import{jsx as L}from"react/jsx-runtime";var v=typeof window<"u",I={pathname:"/",search:"",hash:"",fullPath:"/"},E=t=>{if(!v)return I;let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,r=g(e,t);if(r)return{pathname:r.pathname,search:r.search,hash:r.hash,fullPath:r.fullPath};let n=f(window.location.pathname);return{pathname:n,search:window.location.search,hash:window.location.hash,fullPath:`${n}${window.location.search}${window.location.hash}`}},P=O({path:"/",location:I,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});function q({routes:t,children:e,notFound:r,basename:n,layout:s}){let i=N(()=>R(n),[n]),[o,a]=_(()=>E(i));W(()=>{if(!v)return;let u=()=>a(E(i));return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[i]);let c=F((u,p)=>{let m=g(u,i);if(!m){console.warn(`MichiRouter: navegaci\xF3n bloqueada. URL interna no v\xE1lida: "${u}"`);return}let S={pathname:m.pathname,search:m.search,hash:m.hash,fullPath:m.fullPath};if(!v){a(S);return}p?.replace?window.history.replaceState(p?.state??null,"",m.browserPath):window.history.pushState(p?.state??null,"",m.browserPath),a(S)},[i]),l=N(()=>{for(let u of t){let p=k(u.path,o.pathname);if(p)return{route:u,params:p}}return null},[o.pathname,t]),d=l?.params??{},h=l?l.route.component:r??e;return L(P.Provider,{value:{path:o.pathname,location:o,params:d,basename:i,navigate:c},children:s?L(s,{children:h}):h})}var D=({to:t,children:e,className:r,onClick:n,...s})=>{let{navigate:i,basename:o}=w(P),a=g(t,o),c=a?a.browserPath:"#";return L("a",{href:c,className:r,onClick:l=>{n?.(l),!l.defaultPrevented&&(l.preventDefault(),i(t))},...s,children:e})},x=()=>w(P).navigate,H=()=>w(P).location,G=()=>w(P).params;import{useEffect as K}from"react";import{Fragment as C,jsx as y}from"react/jsx-runtime";var J=t=>{let e=g(t,"/");return e?e.fullPath:"/"};function $({children:t,configObject:e}){let r=x(),n={states:e?.states||{user:null,isLoading:!1},redirectionPath:e?.redirectionPath||"/",loadingComponent:e?.loadingComponent||null,defaultMessage:e?.defaultMessage||void 0};if(!e?.states)return console.error(`Componente Protected: El objeto de configuraci\xF3n es inv\xE1lido. Este es el formato esperado:
|
|
2
|
+
{
|
|
3
|
+
states: { user: any; isLoading: boolean };
|
|
4
|
+
redirectionPath: string;
|
|
5
|
+
loadingComponent?: React.ReactNode;
|
|
6
|
+
defaultMessage?: string;
|
|
7
|
+
}`),null;let s=J(n.redirectionPath),{user:i,isLoading:o}=n.states;return K(()=>{!o&&!i&&(s!==n.redirectionPath&&console.warn(`Protected: redirectionPath inseguro bloqueado ("${n.redirectionPath}"). Se usa "/" como fallback.`),r(s,{replace:!0}))},[o,i,r,s,n.redirectionPath]),o?n.loadingComponent?y(C,{children:n.loadingComponent}):n.defaultMessage?y(C,{children:n.defaultMessage}):null:i?y(C,{children:t}):null}export{D as Link,$ as Protected,q as RouterProvider,H as useLocation,x as useNavigate,G as useParams};
|
package/dist/protected.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as ProtectedProps } from './types-
|
|
2
|
-
export { A as AuthState, P as ProtectedConfig } from './types-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
declare function Protected<TUser = unknown>({ children, configObject }: ProtectedProps<TUser>): React.ReactElement | null;
|
|
6
|
-
|
|
7
|
-
export { Protected, ProtectedProps };
|
|
1
|
+
import { c as ProtectedProps } from './types-a1RLig1-.mjs';
|
|
2
|
+
export { A as AuthState, P as ProtectedConfig } from './types-a1RLig1-.mjs';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
declare function Protected<TUser = unknown>({ children, configObject }: ProtectedProps<TUser>): React.ReactElement | null;
|
|
6
|
+
|
|
7
|
+
export { Protected, ProtectedProps };
|
package/dist/protected.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
import { c as ProtectedProps } from './types-a1RLig1-.js';
|
|
2
|
+
export { A as AuthState, P as ProtectedConfig } from './types-a1RLig1-.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
declare function Protected<TUser = unknown>({ children, configObject }: ProtectedProps<TUser>): React.ReactElement | null;
|
|
6
|
+
|
|
7
|
+
export { Protected, ProtectedProps };
|
package/dist/protected.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "Protected", { enumerable: true, get: function () { return __importDefault(Protected_1).default; } });
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},y=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of x(e))!$.call(t,o)&&o!==r&&p(t,o,{get:()=>e[o],enumerable:!(n=C(e,o))||n.enumerable});return t};var T=t=>y(p({},"__esModule",{value:!0}),t);var W={};S(W,{Protected:()=>g});module.exports=T(W);var w=require("react");var s=require("react");var E="https://michi-router.local",I=new Set(["http:","https:"]),k=t=>t.startsWith("/")?t:`/${t}`,c=t=>{let e=t.trim();if(!e)return"/";let r=k(e);return(r.length>1?r.replace(/\/+$/,""):r)||"/"},z=t=>t?c(t):"/",B=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),M=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,N=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`;var m=(t,e="/")=>{if(typeof t!="string")return null;let r=t.trim();if(!r||/[\u0000-\u001f\u007f]/.test(r))return null;let n=z(e),o=typeof window<"u"?window.location.origin:E,l=n==="/"?`${o}/`:`${o}${n}/`,a;try{a=new URL(r,l)}catch{return null}if(!I.has(a.protocol)||typeof window<"u"&&a.origin!==window.location.origin)return null;let u=c(a.pathname),h=B(u,n)?c(M(u,n)):u,R=c(N(n,h)),d=a.search||"",f=a.hash||"",v=`${h}${d}${f}`,L=`${R}${d}${f}`;return{pathname:h,search:d,hash:f,fullPath:v,browserPath:L}};var A=require("react/jsx-runtime");var U={pathname:"/",search:"",hash:"",fullPath:"/"};var b=(0,s.createContext)({path:"/",location:U,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});var P=()=>(0,s.useContext)(b).navigate;var i=require("react/jsx-runtime"),F=t=>{let e=m(t,"/");return e?e.fullPath:"/"};function g({children:t,configObject:e}){let r=P(),n={states:e?.states||{user:null,isLoading:!1},redirectionPath:e?.redirectionPath||"/",loadingComponent:e?.loadingComponent||null,defaultMessage:e?.defaultMessage||void 0};if(!e?.states)return console.error(`Componente Protected: El objeto de configuraci\xF3n es inv\xE1lido. Este es el formato esperado:
|
|
2
|
+
{
|
|
3
|
+
states: { user: any; isLoading: boolean };
|
|
4
|
+
redirectionPath: string;
|
|
5
|
+
loadingComponent?: React.ReactNode;
|
|
6
|
+
defaultMessage?: string;
|
|
7
|
+
}`),null;let o=F(n.redirectionPath),{user:l,isLoading:a}=n.states;return(0,w.useEffect)(()=>{!a&&!l&&(o!==n.redirectionPath&&console.warn(`Protected: redirectionPath inseguro bloqueado ("${n.redirectionPath}"). Se usa "/" como fallback.`),r(o,{replace:!0}))},[a,l,r,o,n.redirectionPath]),a?n.loadingComponent?(0,i.jsx)(i.Fragment,{children:n.loadingComponent}):n.defaultMessage?(0,i.jsx)(i.Fragment,{children:n.defaultMessage}):null:l?(0,i.jsx)(i.Fragment,{children:t}):null}0&&(module.exports={Protected});
|
package/dist/protected.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{useEffect as z}from"react";import{useCallback as b,createContext as T,useContext as E,useEffect as A,useMemo as F,useState as W}from"react";var v="https://michi-router.local",L=new Set(["http:","https:"]),C=t=>t.startsWith("/")?t:`/${t}`,i=t=>{let e=t.trim();if(!e)return"/";let r=C(e);return(r.length>1?r.replace(/\/+$/,""):r)||"/"},x=t=>t?i(t):"/",$=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),S=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,y=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`;var p=(t,e="/")=>{if(typeof t!="string")return null;let r=t.trim();if(!r||/[\u0000-\u001f\u007f]/.test(r))return null;let n=x(e),a=typeof window<"u"?window.location.origin:v,s=n==="/"?`${a}/`:`${a}${n}/`,o;try{o=new URL(r,s)}catch{return null}if(!L.has(o.protocol)||typeof window<"u"&&o.origin!==window.location.origin)return null;let l=i(o.pathname),c=$(l,n)?i(S(l,n)):l,P=i(y(n,c)),u=o.search||"",h=o.hash||"",w=`${c}${u}${h}`,R=`${P}${u}${h}`;return{pathname:c,search:u,hash:h,fullPath:w,browserPath:R}};import{jsx as _}from"react/jsx-runtime";var I={pathname:"/",search:"",hash:"",fullPath:"/"};var k=T({path:"/",location:I,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});var g=()=>E(k).navigate;import{Fragment as d,jsx as f}from"react/jsx-runtime";var B=t=>{let e=p(t,"/");return e?e.fullPath:"/"};function m({children:t,configObject:e}){let r=g(),n={states:e?.states||{user:null,isLoading:!1},redirectionPath:e?.redirectionPath||"/",loadingComponent:e?.loadingComponent||null,defaultMessage:e?.defaultMessage||void 0};if(!e?.states)return console.error(`Componente Protected: El objeto de configuraci\xF3n es inv\xE1lido. Este es el formato esperado:
|
|
2
|
-
{
|
|
3
|
-
states: { user: any; isLoading: boolean };
|
|
4
|
-
redirectionPath: string;
|
|
5
|
-
loadingComponent?: React.ReactNode;
|
|
6
|
-
defaultMessage?: string;
|
|
7
|
-
}`),null;let a=B(n.redirectionPath),{user:s,isLoading:o}=n.states;return z(()=>{!o&&!s&&(a!==n.redirectionPath&&console.warn(`Protected: redirectionPath inseguro bloqueado ("${n.redirectionPath}"). Se usa "/" como fallback.`),r(a,{replace:!0}))},[o,s,r,a,n.redirectionPath]),o?n.loadingComponent?f(d,{children:n.loadingComponent}):n.defaultMessage?f(d,{children:n.defaultMessage}):null:s?f(d,{children:t}):null}export{m as Protected};
|
|
1
|
+
import{useEffect as z}from"react";import{useCallback as b,createContext as T,useContext as E,useEffect as A,useMemo as F,useState as W}from"react";var v="https://michi-router.local",L=new Set(["http:","https:"]),C=t=>t.startsWith("/")?t:`/${t}`,i=t=>{let e=t.trim();if(!e)return"/";let r=C(e);return(r.length>1?r.replace(/\/+$/,""):r)||"/"},x=t=>t?i(t):"/",$=(t,e)=>e==="/"?!0:t===e||t.startsWith(`${e}/`),S=(t,e)=>e==="/"?t:t===e?"/":t.startsWith(`${e}/`)?t.slice(e.length)||"/":t,y=(t,e)=>t==="/"?e:e==="/"?t:`${t}${e}`;var p=(t,e="/")=>{if(typeof t!="string")return null;let r=t.trim();if(!r||/[\u0000-\u001f\u007f]/.test(r))return null;let n=x(e),a=typeof window<"u"?window.location.origin:v,s=n==="/"?`${a}/`:`${a}${n}/`,o;try{o=new URL(r,s)}catch{return null}if(!L.has(o.protocol)||typeof window<"u"&&o.origin!==window.location.origin)return null;let l=i(o.pathname),c=$(l,n)?i(S(l,n)):l,P=i(y(n,c)),u=o.search||"",h=o.hash||"",w=`${c}${u}${h}`,R=`${P}${u}${h}`;return{pathname:c,search:u,hash:h,fullPath:w,browserPath:R}};import{jsx as _}from"react/jsx-runtime";var I={pathname:"/",search:"",hash:"",fullPath:"/"};var k=T({path:"/",location:I,params:{},basename:"/",navigate:()=>{console.warn("RouterContext usado fuera de RouterProvider")}});var g=()=>E(k).navigate;import{Fragment as d,jsx as f}from"react/jsx-runtime";var B=t=>{let e=p(t,"/");return e?e.fullPath:"/"};function m({children:t,configObject:e}){let r=g(),n={states:e?.states||{user:null,isLoading:!1},redirectionPath:e?.redirectionPath||"/",loadingComponent:e?.loadingComponent||null,defaultMessage:e?.defaultMessage||void 0};if(!e?.states)return console.error(`Componente Protected: El objeto de configuraci\xF3n es inv\xE1lido. Este es el formato esperado:
|
|
2
|
+
{
|
|
3
|
+
states: { user: any; isLoading: boolean };
|
|
4
|
+
redirectionPath: string;
|
|
5
|
+
loadingComponent?: React.ReactNode;
|
|
6
|
+
defaultMessage?: string;
|
|
7
|
+
}`),null;let a=B(n.redirectionPath),{user:s,isLoading:o}=n.states;return z(()=>{!o&&!s&&(a!==n.redirectionPath&&console.warn(`Protected: redirectionPath inseguro bloqueado ("${n.redirectionPath}"). Se usa "/" como fallback.`),r(a,{replace:!0}))},[o,s,r,a,n.redirectionPath]),o?n.loadingComponent?f(d,{children:n.loadingComponent}):n.defaultMessage?f(d,{children:n.defaultMessage}):null:s?f(d,{children:t}):null}export{m as Protected};
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { ReactNode, AnchorHTMLAttributes, ComponentType } from 'react';
|
|
2
|
-
|
|
3
|
-
interface LayoutProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
type RouteParams = Record<string, string>;
|
|
7
|
-
interface RouterLocation {
|
|
8
|
-
pathname: string;
|
|
9
|
-
search: string;
|
|
10
|
-
hash: string;
|
|
11
|
-
fullPath: string;
|
|
12
|
-
}
|
|
13
|
-
interface NavigateOptions {
|
|
14
|
-
replace?: boolean;
|
|
15
|
-
state?: unknown;
|
|
16
|
-
}
|
|
17
|
-
type NavigateFn = (to: string, options?: NavigateOptions) => void;
|
|
18
|
-
interface Route {
|
|
19
|
-
path: string;
|
|
20
|
-
component: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
interface RouterContextType {
|
|
23
|
-
path: string;
|
|
24
|
-
location: RouterLocation;
|
|
25
|
-
params: RouteParams;
|
|
26
|
-
basename: string;
|
|
27
|
-
navigate: NavigateFn;
|
|
28
|
-
}
|
|
29
|
-
interface RouterProviderProps {
|
|
30
|
-
routes: Route[];
|
|
31
|
-
children?: ReactNode;
|
|
32
|
-
notFound?: ReactNode;
|
|
33
|
-
basename?: string;
|
|
34
|
-
layout?: ComponentType<{
|
|
35
|
-
children: ReactNode;
|
|
36
|
-
}>;
|
|
37
|
-
}
|
|
38
|
-
interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
39
|
-
to: string;
|
|
40
|
-
children: ReactNode;
|
|
41
|
-
className?: string;
|
|
42
|
-
}
|
|
43
|
-
interface AuthState<TUser = unknown> {
|
|
44
|
-
user: TUser | null;
|
|
45
|
-
isLoading: boolean;
|
|
46
|
-
}
|
|
47
|
-
interface ProtectedConfig<TUser = unknown> {
|
|
48
|
-
states: AuthState<TUser>;
|
|
49
|
-
redirectionPath: string;
|
|
50
|
-
loadingComponent?: ReactNode;
|
|
51
|
-
defaultMessage?: string;
|
|
52
|
-
}
|
|
53
|
-
interface ProtectedProps<TUser = unknown> {
|
|
54
|
-
children: ReactNode;
|
|
55
|
-
configObject: ProtectedConfig<TUser>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type { AuthState as A, LayoutProps as L, NavigateFn as N, ProtectedConfig as P, Route as R, LinkProps as a, NavigateOptions as b, ProtectedProps as c, RouteParams as d, RouterContextType as e, RouterLocation as f, RouterProviderProps as g };
|
|
1
|
+
import { ReactNode, AnchorHTMLAttributes, ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
interface LayoutProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
type RouteParams = Record<string, string>;
|
|
7
|
+
interface RouterLocation {
|
|
8
|
+
pathname: string;
|
|
9
|
+
search: string;
|
|
10
|
+
hash: string;
|
|
11
|
+
fullPath: string;
|
|
12
|
+
}
|
|
13
|
+
interface NavigateOptions {
|
|
14
|
+
replace?: boolean;
|
|
15
|
+
state?: unknown;
|
|
16
|
+
}
|
|
17
|
+
type NavigateFn = (to: string, options?: NavigateOptions) => void;
|
|
18
|
+
interface Route {
|
|
19
|
+
path: string;
|
|
20
|
+
component: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
interface RouterContextType {
|
|
23
|
+
path: string;
|
|
24
|
+
location: RouterLocation;
|
|
25
|
+
params: RouteParams;
|
|
26
|
+
basename: string;
|
|
27
|
+
navigate: NavigateFn;
|
|
28
|
+
}
|
|
29
|
+
interface RouterProviderProps {
|
|
30
|
+
routes: Route[];
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
notFound?: ReactNode;
|
|
33
|
+
basename?: string;
|
|
34
|
+
layout?: ComponentType<{
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
39
|
+
to: string;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
interface AuthState<TUser = unknown> {
|
|
44
|
+
user: TUser | null;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface ProtectedConfig<TUser = unknown> {
|
|
48
|
+
states: AuthState<TUser>;
|
|
49
|
+
redirectionPath: string;
|
|
50
|
+
loadingComponent?: ReactNode;
|
|
51
|
+
defaultMessage?: string;
|
|
52
|
+
}
|
|
53
|
+
interface ProtectedProps<TUser = unknown> {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
configObject: ProtectedConfig<TUser>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type { AuthState as A, LayoutProps as L, NavigateFn as N, ProtectedConfig as P, Route as R, LinkProps as a, NavigateOptions as b, ProtectedProps as c, RouteParams as d, RouterContextType as e, RouterLocation as f, RouterProviderProps as g };
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { ReactNode, AnchorHTMLAttributes, ComponentType } from 'react';
|
|
2
|
-
|
|
3
|
-
interface LayoutProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
type RouteParams = Record<string, string>;
|
|
7
|
-
interface RouterLocation {
|
|
8
|
-
pathname: string;
|
|
9
|
-
search: string;
|
|
10
|
-
hash: string;
|
|
11
|
-
fullPath: string;
|
|
12
|
-
}
|
|
13
|
-
interface NavigateOptions {
|
|
14
|
-
replace?: boolean;
|
|
15
|
-
state?: unknown;
|
|
16
|
-
}
|
|
17
|
-
type NavigateFn = (to: string, options?: NavigateOptions) => void;
|
|
18
|
-
interface Route {
|
|
19
|
-
path: string;
|
|
20
|
-
component: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
interface RouterContextType {
|
|
23
|
-
path: string;
|
|
24
|
-
location: RouterLocation;
|
|
25
|
-
params: RouteParams;
|
|
26
|
-
basename: string;
|
|
27
|
-
navigate: NavigateFn;
|
|
28
|
-
}
|
|
29
|
-
interface RouterProviderProps {
|
|
30
|
-
routes: Route[];
|
|
31
|
-
children?: ReactNode;
|
|
32
|
-
notFound?: ReactNode;
|
|
33
|
-
basename?: string;
|
|
34
|
-
layout?: ComponentType<{
|
|
35
|
-
children: ReactNode;
|
|
36
|
-
}>;
|
|
37
|
-
}
|
|
38
|
-
interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
39
|
-
to: string;
|
|
40
|
-
children: ReactNode;
|
|
41
|
-
className?: string;
|
|
42
|
-
}
|
|
43
|
-
interface AuthState<TUser = unknown> {
|
|
44
|
-
user: TUser | null;
|
|
45
|
-
isLoading: boolean;
|
|
46
|
-
}
|
|
47
|
-
interface ProtectedConfig<TUser = unknown> {
|
|
48
|
-
states: AuthState<TUser>;
|
|
49
|
-
redirectionPath: string;
|
|
50
|
-
loadingComponent?: ReactNode;
|
|
51
|
-
defaultMessage?: string;
|
|
52
|
-
}
|
|
53
|
-
interface ProtectedProps<TUser = unknown> {
|
|
54
|
-
children: ReactNode;
|
|
55
|
-
configObject: ProtectedConfig<TUser>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type { AuthState as A, LayoutProps as L, NavigateFn as N, ProtectedConfig as P, Route as R, LinkProps as a, NavigateOptions as b, ProtectedProps as c, RouteParams as d, RouterContextType as e, RouterLocation as f, RouterProviderProps as g };
|
|
1
|
+
import { ReactNode, AnchorHTMLAttributes, ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
interface LayoutProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
type RouteParams = Record<string, string>;
|
|
7
|
+
interface RouterLocation {
|
|
8
|
+
pathname: string;
|
|
9
|
+
search: string;
|
|
10
|
+
hash: string;
|
|
11
|
+
fullPath: string;
|
|
12
|
+
}
|
|
13
|
+
interface NavigateOptions {
|
|
14
|
+
replace?: boolean;
|
|
15
|
+
state?: unknown;
|
|
16
|
+
}
|
|
17
|
+
type NavigateFn = (to: string, options?: NavigateOptions) => void;
|
|
18
|
+
interface Route {
|
|
19
|
+
path: string;
|
|
20
|
+
component: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
interface RouterContextType {
|
|
23
|
+
path: string;
|
|
24
|
+
location: RouterLocation;
|
|
25
|
+
params: RouteParams;
|
|
26
|
+
basename: string;
|
|
27
|
+
navigate: NavigateFn;
|
|
28
|
+
}
|
|
29
|
+
interface RouterProviderProps {
|
|
30
|
+
routes: Route[];
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
notFound?: ReactNode;
|
|
33
|
+
basename?: string;
|
|
34
|
+
layout?: ComponentType<{
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
39
|
+
to: string;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
interface AuthState<TUser = unknown> {
|
|
44
|
+
user: TUser | null;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface ProtectedConfig<TUser = unknown> {
|
|
48
|
+
states: AuthState<TUser>;
|
|
49
|
+
redirectionPath: string;
|
|
50
|
+
loadingComponent?: ReactNode;
|
|
51
|
+
defaultMessage?: string;
|
|
52
|
+
}
|
|
53
|
+
interface ProtectedProps<TUser = unknown> {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
configObject: ProtectedConfig<TUser>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type { AuthState as A, LayoutProps as L, NavigateFn as N, ProtectedConfig as P, Route as R, LinkProps as a, NavigateOptions as b, ProtectedProps as c, RouteParams as d, RouterContextType as e, RouterLocation as f, RouterProviderProps as g };
|
package/package.json
CHANGED
|
@@ -1,82 +1,91 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@arielgonzaguer/michi-router",
|
|
3
|
-
"private": false,
|
|
4
|
-
"version": "3.0
|
|
5
|
-
"description": "El router minimalista y simple para React.\nEl objetivo principal de esta herramienta es proporcionar la funcionalidad básica de enrutamiento.",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.mjs",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.mjs",
|
|
13
|
-
"require": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"./core": {
|
|
16
|
-
"types": "./dist/core.d.ts",
|
|
17
|
-
"import": "./dist/core.mjs",
|
|
18
|
-
"require": "./dist/core.js"
|
|
19
|
-
},
|
|
20
|
-
"./protected": {
|
|
21
|
-
"types": "./dist/protected.d.ts",
|
|
22
|
-
"import": "./dist/protected.mjs",
|
|
23
|
-
"require": "./dist/protected.js"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"sideEffects": false,
|
|
27
|
-
"files": [
|
|
28
|
-
"dist"
|
|
29
|
-
],
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
},
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@arielgonzaguer/michi-router",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "3.3.0",
|
|
5
|
+
"description": "El router minimalista y simple para React.\nEl objetivo principal de esta herramienta es proporcionar la funcionalidad básica de enrutamiento.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./core": {
|
|
16
|
+
"types": "./dist/core.d.ts",
|
|
17
|
+
"import": "./dist/core.mjs",
|
|
18
|
+
"require": "./dist/core.js"
|
|
19
|
+
},
|
|
20
|
+
"./protected": {
|
|
21
|
+
"types": "./dist/protected.d.ts",
|
|
22
|
+
"import": "./dist/protected.mjs",
|
|
23
|
+
"require": "./dist/protected.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"enrutado",
|
|
32
|
+
"react",
|
|
33
|
+
"router",
|
|
34
|
+
"typescript",
|
|
35
|
+
"michi",
|
|
36
|
+
"cats",
|
|
37
|
+
"gatos",
|
|
38
|
+
"front-end"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": ">=17.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/js": "^10.0.1",
|
|
45
|
+
"@swc/core": "1.13.5",
|
|
46
|
+
"@testing-library/jest-dom": "6.0.0",
|
|
47
|
+
"@testing-library/react": "14.0.0",
|
|
48
|
+
"@types/jest": "29.5.3",
|
|
49
|
+
"@types/react": "18.3.18",
|
|
50
|
+
"@types/react-dom": "18.3.5",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
52
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
53
|
+
"eslint": "^10.7.0",
|
|
54
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
55
|
+
"jsdom": "26.1.0",
|
|
56
|
+
"prettier": "^3.9.6",
|
|
57
|
+
"react": "18.3.1",
|
|
58
|
+
"react-dom": "18.3.1",
|
|
59
|
+
"rimraf": "6.0.1",
|
|
60
|
+
"tsup": "8.5.0",
|
|
61
|
+
"typescript": "5.7.3",
|
|
62
|
+
"typescript-eslint": "^8.65.0",
|
|
63
|
+
"vitest": "4.1.8"
|
|
64
|
+
},
|
|
65
|
+
"repository": {
|
|
66
|
+
"type": "git",
|
|
67
|
+
"url": "git+https://github.com/Ariel-GonzAguer/michi-router.git"
|
|
68
|
+
},
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/Ariel-GonzAguer/michi-router/issues"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://github.com/Ariel-GonzAguer/michi-router#readme",
|
|
73
|
+
"author": "Ariel Gonzales Agüero",
|
|
74
|
+
"license": "MIT",
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "tsc",
|
|
77
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
78
|
+
"prebuild": "pnpm run clean",
|
|
79
|
+
"test": "vitest --run",
|
|
80
|
+
"test:watch": "vitest --watch",
|
|
81
|
+
"build:bundle": "pnpm run clean && tsup src/index.ts src/core.ts src/protected.ts --format esm,cjs --minify --dts --out-dir dist --external react --splitting false",
|
|
82
|
+
"size:check": "node scripts/check-size.js",
|
|
83
|
+
"lint": "eslint src/ --ext .ts,.tsx",
|
|
84
|
+
"lint:fix": "eslint src/ --ext .ts,.tsx --fix",
|
|
85
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
86
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
|
|
87
|
+
"release:patch": "pnpm version patch && pnpm publish --access public && git push origin main --tags",
|
|
88
|
+
"release:minor": "pnpm version minor && pnpm publish --access public && git push origin main --tags",
|
|
89
|
+
"release:major": "pnpm version major && pnpm publish --access public && git push origin main --tags"
|
|
90
|
+
}
|
|
91
|
+
}
|