routerino 2.3.4 → 2.4.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/dist/routerino.js CHANGED
@@ -1,177 +1,226 @@
1
- import { jsx as g, jsxs as q, Fragment as F } from "react/jsx-runtime";
2
- import { useState as I, useEffect as O, createContext as _, Component as V, useContext as G } from "react";
3
- import t from "prop-types";
4
- const K = [480, 800, 1200, 1920], Z = "(max-width: 480px) 100vw, (max-width: 800px) 800px, (max-width: 1200px) 1200px, 1920px";
5
- function J(r, e = "") {
6
- const i = r.toLowerCase(), n = e.toLowerCase();
7
- return !!(i.includes("hero") || i.includes("banner") || n.includes("hero") || n.includes("banner") || n.includes("h-screen") || n.includes("h-full"));
1
+ import { jsx as g, jsxs as B, Fragment as G } from "react/jsx-runtime";
2
+ import { useState as z, useEffect as _, useMemo as J, createContext as N, Component as Q, useContext as X } from "react";
3
+ import o from "prop-types";
4
+ const Y = [480, 800, 1200, 1920], ee = "(max-width: 480px) 100vw, (max-width: 800px) 800px, (max-width: 1200px) 1200px, 1920px", H = /* @__PURE__ */ new Map();
5
+ function te(i, e = "") {
6
+ const r = i.toLowerCase(), n = e.toLowerCase();
7
+ return !!(r.includes("hero") || r.includes("banner") || n.includes("hero") || n.includes("banner") || n.includes("h-screen") || n.includes("h-full"));
8
8
  }
9
- function H(r, e, i = null) {
10
- const n = r.replace(/\.(jpe?g|png|webp)$/i, ""), h = i ? `.${i}` : r.match(/\.(jpe?g|png|webp)$/i)?.[0] || ".jpg";
11
- return e.map((l) => `${n}-${l}w${h} ${l}w`).join(", ");
9
+ function q(i, e, r = null) {
10
+ const n = i.replace(/\.(jpe?g|png|webp)$/i, ""), u = r ? `.${r}` : i.match(/\.(jpe?g|png|webp)$/i)?.[0] || ".jpg";
11
+ return e.map((a) => `${n}-${a}w${u} ${a}w`).join(", ");
12
12
  }
13
- function B(r) {
13
+ function oe(i) {
14
14
  const {
15
15
  src: e = "",
16
- alt: i = "",
16
+ alt: r = "",
17
17
  priority: n,
18
- widths: h = K,
19
- sizes: l = Z,
20
- className: p = "",
21
- style: L = {},
22
- loading: $,
23
- decoding: E = "async",
24
- fetchpriority: v,
25
- ...x
26
- } = r || {};
27
- if (typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1"))
18
+ widths: u = Y,
19
+ sizes: a = ee,
20
+ className: m = "",
21
+ style: O = {},
22
+ width: E,
23
+ height: S,
24
+ loading: I,
25
+ decoding: L = "async",
26
+ fetchpriority: f,
27
+ ...T
28
+ } = i || {}, W = typeof window > "u", b = !W && typeof document < "u" && typeof HTMLElement < "u" && document.createElement("div") instanceof HTMLElement, R = b && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1"), c = n ?? te(e, m), k = I || (c ? "eager" : "lazy"), P = f || (c ? "high" : void 0), [y, s] = z(null);
29
+ _(() => {
30
+ if (!b || R || !e) return;
31
+ const h = new window.Image();
32
+ h.onload = () => {
33
+ s({
34
+ width: h.naturalWidth,
35
+ height: h.naturalHeight
36
+ });
37
+ }, h.src = e;
38
+ }, [e, b, R]);
39
+ const v = J(() => y ? u.filter((h) => y.width >= h) : u, [y, u]), [j, F] = z(null);
40
+ _(() => {
41
+ if (!b || R) return;
42
+ let h = !1;
43
+ return (async () => {
44
+ const x = e.replace(/\.(jpe?g|png|webp)$/i, ""), A = e.match(/\.(jpe?g|png|webp)$/i)?.[0] || ".jpg", D = [];
45
+ for (const M of v) {
46
+ const C = `${x}-${M}w${A}`;
47
+ if (H.has(C)) {
48
+ H.get(C) && D.push(M);
49
+ continue;
50
+ }
51
+ try {
52
+ const V = await fetch(C, { method: "HEAD" });
53
+ H.set(C, V.ok), V.ok && D.push(M);
54
+ } catch {
55
+ H.set(C, !1);
56
+ }
57
+ }
58
+ h || F(
59
+ D.length > 0 ? D : v
60
+ );
61
+ })(), () => {
62
+ h = !0;
63
+ };
64
+ }, [e, v, b, R]);
65
+ const U = j ?? v, t = {};
66
+ E != null && (t.width = E), S != null && (t.height = S), y && E == null && S == null && (t.width = y.width, t.height = y.height);
67
+ const l = {
68
+ maxWidth: "100%",
69
+ height: "auto",
70
+ ...O
71
+ };
72
+ if (R)
28
73
  return /* @__PURE__ */ g(
29
74
  "img",
30
75
  {
31
76
  src: e,
32
- alt: i,
33
- loading: $ || "lazy",
34
- decoding: E,
35
- fetchPriority: v,
36
- className: p,
37
- style: L,
38
- ...x
77
+ alt: r,
78
+ loading: k,
79
+ decoding: L,
80
+ fetchPriority: P,
81
+ className: m,
82
+ style: l,
83
+ ...t,
84
+ ...T
39
85
  }
40
86
  );
41
- const [T, D] = I(null), S = e && typeof window < "u";
42
- O(() => {
43
- if (!S) return;
44
- const y = new B();
45
- y.onload = () => {
46
- D({
47
- width: y.naturalWidth,
48
- height: y.naturalHeight
49
- });
50
- }, y.src = e;
51
- }, [e, S]);
52
- const b = T ? h.filter((y) => T.width >= y) : h, [c, k] = I(b);
53
- O(() => {
54
- (async () => {
55
- if (typeof window > "u") {
56
- k(b);
57
- return;
58
- }
59
- const U = e.replace(/\.(jpe?g|png|webp)$/i, ""), o = e.match(/\.(jpe?g|png|webp)$/i)?.[0] || ".jpg", a = [];
60
- for (const w of b) {
61
- const f = `${U}-${w}w${o}`;
62
- try {
63
- (await fetch(f, { method: "HEAD" })).ok && a.push(w);
64
- } catch {
87
+ if (W)
88
+ return /* @__PURE__ */ B("picture", { "data-routerino-image": "true", "data-original-src": e, children: [
89
+ /* @__PURE__ */ g(
90
+ "source",
91
+ {
92
+ srcSet: q(e, u, "webp"),
93
+ type: "image/webp",
94
+ sizes: a
65
95
  }
66
- }
67
- a.length === 0 && b.length > 0 && a.push(Math.min(...b)), k(a);
68
- })();
69
- }, [e, b]);
70
- const P = n ?? J(e, p), W = $ || (P ? "eager" : "lazy"), s = v || (P ? "high" : void 0), j = H(e, c, "webp"), A = H(e, c);
71
- return /* @__PURE__ */ q("picture", { "data-routerino-image": "true", "data-original-src": e, children: [
72
- /* @__PURE__ */ g("source", { srcSet: j, type: "image/webp", sizes: l }),
96
+ ),
97
+ /* @__PURE__ */ g(
98
+ "img",
99
+ {
100
+ src: e,
101
+ alt: r,
102
+ srcSet: q(e, u),
103
+ sizes: a,
104
+ loading: k,
105
+ decoding: "async",
106
+ fetchPriority: P,
107
+ className: m,
108
+ style: l,
109
+ ...t,
110
+ ...T
111
+ }
112
+ )
113
+ ] });
114
+ const w = q(e, U, "webp"), d = q(e, U);
115
+ return /* @__PURE__ */ B("picture", { "data-routerino-image": "true", "data-original-src": e, children: [
116
+ /* @__PURE__ */ g("source", { srcSet: w, type: "image/webp", sizes: a }),
73
117
  /* @__PURE__ */ g(
74
118
  "img",
75
119
  {
76
120
  src: e,
77
- alt: i,
78
- srcSet: A,
79
- sizes: l,
80
- loading: W,
81
- decoding: E,
82
- fetchPriority: s,
83
- className: p,
84
- style: L,
85
- ...x
121
+ alt: r,
122
+ srcSet: d,
123
+ sizes: a,
124
+ loading: k,
125
+ decoding: L,
126
+ fetchPriority: P,
127
+ className: m,
128
+ style: l,
129
+ ...t,
130
+ ...T
86
131
  }
87
132
  )
88
133
  ] });
89
134
  }
90
- B.propTypes = {
135
+ oe.propTypes = {
91
136
  /** Image source URL (required) */
92
- src: t.string.isRequired,
137
+ src: o.string.isRequired,
93
138
  /** Alt text for accessibility (required) */
94
- alt: t.string.isRequired,
139
+ alt: o.string.isRequired,
95
140
  /** Override lazy loading for hero/LCP images */
96
- priority: t.bool,
141
+ priority: o.bool,
97
142
  /** Responsive widths to generate (defaults to [480, 800, 1200, 1920]) */
98
- widths: t.arrayOf(t.number),
143
+ widths: o.arrayOf(o.number),
99
144
  /** Responsive sizes attribute (has smart default) */
100
- sizes: t.string,
145
+ sizes: o.string,
101
146
  /** CSS classes (Tailwind/DaisyUI ready) */
102
- className: t.string,
147
+ className: o.string,
103
148
  /** Inline styles */
104
- style: t.object,
149
+ style: o.object,
150
+ /** Explicit width for CLS prevention */
151
+ width: o.number,
152
+ /** Explicit height for CLS prevention */
153
+ height: o.number,
105
154
  /** Loading behavior (auto-set based on priority) */
106
- loading: t.oneOf(["lazy", "eager"]),
155
+ loading: o.oneOf(["lazy", "eager"]),
107
156
  /** Decode timing */
108
- decoding: t.oneOf(["sync", "async", "auto"]),
157
+ decoding: o.oneOf(["sync", "async", "auto"]),
109
158
  /** Fetch priority (auto-set based on priority) */
110
- fetchpriority: t.oneOf(["high", "low", "auto"])
159
+ fetchpriority: o.oneOf(["high", "low", "auto"])
111
160
  };
112
- const z = _(null);
113
- function oe() {
114
- const r = G(z);
115
- if (!r)
161
+ const K = N(null);
162
+ function le() {
163
+ const i = X(K);
164
+ if (!i)
116
165
  throw new Error(
117
166
  "useRouterino must be used within a Routerino router. Make sure your component is rendered inside a <Routerino> component."
118
167
  );
119
- return r;
168
+ return i;
120
169
  }
121
- function u({ tag: r = "meta", soft: e = !1, ...i }) {
122
- const n = Object.keys(i);
170
+ function p({ tag: i = "meta", soft: e = !1, ...r }) {
171
+ const n = Object.keys(r);
123
172
  if (n.length < 1)
124
173
  return console.error(
125
- `[Routerino] updateHeadTag() received no attributes to set for ${r} tag`
174
+ `[Routerino] updateHeadTag() received no attributes to set for ${i} tag`
126
175
  );
127
- let h = null;
128
- for (let l = 0; l < n.length && (n[l] !== "content" && (h = document.querySelector(
129
- `${r}[${n[l]}='${i[n[l]]}']`
130
- )), !h); l++)
176
+ let u = null;
177
+ for (let a = 0; a < n.length && (n[a] !== "content" && (u = document.querySelector(
178
+ `${i}[${n[a]}='${r[n[a]]}']`
179
+ )), !u); a++)
131
180
  ;
132
- h && e || (h || (h = document.createElement(r)), n.forEach((l) => h.setAttribute(l, i[l])), document.querySelector("head").appendChild(h));
181
+ u && e || (u || (u = document.createElement(i)), n.forEach((a) => u.setAttribute(a, r[a])), document.querySelector("head").appendChild(u));
133
182
  }
134
- function N({ routePattern: r, currentRoute: e }) {
135
- let i = {}, n = r.split("/"), h = e.split("/");
136
- return n.forEach((l, p) => {
137
- l.startsWith(":") && (i[l.slice(1)] = h[p]);
138
- }), i;
183
+ function ne({ routePattern: i, currentRoute: e }) {
184
+ let r = {}, n = i.split("/"), u = e.split("/");
185
+ return n.forEach((a, m) => {
186
+ a.startsWith(":") && (r[a.slice(1)] = u[m]);
187
+ }), r;
139
188
  }
140
- class M extends V {
189
+ class Z extends Q {
141
190
  constructor(e) {
142
191
  super(e), this.state = { hasError: !1 };
143
192
  }
144
193
  static getDerivedStateFromError() {
145
194
  return { hasError: !0 };
146
195
  }
147
- componentDidCatch(e, i) {
196
+ componentDidCatch(e, r) {
148
197
  this.props.debug && (console.group(
149
198
  "%c[Routerino]%c Error Boundary Caught an Error",
150
199
  "color: #ff6b6b; font-weight: bold",
151
200
  "",
152
201
  e
153
- ), console.error("[Routerino] Component Stack:", i.componentStack), this.props.routePath && console.error("[Routerino] Failed Route:", this.props.routePath), console.error("[Routerino] Error occurred at:", (/* @__PURE__ */ new Date()).toISOString()), console.groupEnd()), document.title = this.props.errorTitleString, this.props.usePrerenderTags && u({ name: "prerender-status-code", content: "500" });
202
+ ), console.error("[Routerino] Component Stack:", r.componentStack), this.props.routePath && console.error("[Routerino] Failed Route:", this.props.routePath), console.error("[Routerino] Error occurred at:", (/* @__PURE__ */ new Date()).toISOString()), console.groupEnd()), document.title = this.props.errorTitleString, this.props.usePrerenderTags && p({ name: "prerender-status-code", content: "500" });
154
203
  }
155
204
  render() {
156
205
  return this.state.hasError ? this.props.fallback : this.props.children;
157
206
  }
158
207
  }
159
- M.propTypes = {
208
+ Z.propTypes = {
160
209
  /** The child components to render when there's no error */
161
- children: t.node,
210
+ children: o.node,
162
211
  /** The fallback UI to display when an error is caught */
163
- fallback: t.node,
212
+ fallback: o.node,
164
213
  /** The document title to set when an error occurs */
165
- errorTitleString: t.string.isRequired,
214
+ errorTitleString: o.string.isRequired,
166
215
  /** Whether to set prerender meta tags (status code 500) on error */
167
- usePrerenderTags: t.bool,
216
+ usePrerenderTags: o.bool,
168
217
  /** The current route path for better error context (optional) */
169
- routePath: t.string,
218
+ routePath: o.string,
170
219
  /** Whether to log debug messages to console (optional) */
171
- debug: t.bool
220
+ debug: o.bool
172
221
  };
173
- function Q({
174
- routes: r = [
222
+ function re({
223
+ routes: i = [
175
224
  {
176
225
  path: "/",
177
226
  element: /* @__PURE__ */ g("p", { children: "This is the default route. Pass an array of routes to the Routerino component in order to configure your own pages. Each route is a dictionary with at least `path` and `element` defined." }),
@@ -180,148 +229,157 @@ function Q({
180
229
  tags: [{ property: "og:locale", content: "en_US" }]
181
230
  }
182
231
  ],
183
- notFoundTemplate: e = /* @__PURE__ */ q(F, { children: [
232
+ notFoundTemplate: e = /* @__PURE__ */ B(G, { children: [
184
233
  /* @__PURE__ */ g("p", { children: "No page found for this URL. [404]" }),
185
234
  /* @__PURE__ */ g("p", { children: /* @__PURE__ */ g("a", { href: "/", children: "Home" }) })
186
235
  ] }),
187
- notFoundTitle: i = "Page not found [404]",
188
- errorTemplate: n = /* @__PURE__ */ q(F, { children: [
236
+ notFoundTitle: r = "Page not found [404]",
237
+ errorTemplate: n = /* @__PURE__ */ B(G, { children: [
189
238
  /* @__PURE__ */ g("p", { children: "Page failed to load. [500]" }),
190
239
  /* @__PURE__ */ g("p", { children: /* @__PURE__ */ g("a", { href: "/", children: "Home" }) })
191
240
  ] }),
192
- errorTitle: h = "Page error [500]",
193
- useTrailingSlash: l = !0,
194
- usePrerenderTags: p = !1,
195
- baseUrl: L = null,
196
- title: $ = "",
197
- separator: E = " | ",
198
- imageUrl: v = null,
199
- touchIconUrl: x = null,
200
- debug: d = !1
241
+ errorTitle: u = "Page error [500]",
242
+ useTrailingSlash: a = !0,
243
+ usePrerenderTags: m = !1,
244
+ baseUrl: O = null,
245
+ title: E = "",
246
+ separator: S = " | ",
247
+ imageUrl: I = null,
248
+ touchIconUrl: L = null,
249
+ debug: f = !1
201
250
  }) {
202
- const T = `${h}${E}${$}`, D = `${i}${E}${$}`;
251
+ const T = `${u}${S}${E}`, W = `${r}${S}${E}`;
203
252
  try {
204
- if (d) {
205
- const o = r.map((w) => w.path), a = o.filter(
206
- (w, f) => o.indexOf(w) !== f
253
+ if (f) {
254
+ const t = i.map((w) => w.path), l = t.filter(
255
+ (w, d) => t.indexOf(w) !== d
207
256
  );
208
- a.length > 0 && (console.warn(
257
+ l.length > 0 && (console.warn(
209
258
  "%c[Routerino]%c Duplicate route paths detected:",
210
259
  "color: #f59e0b; font-weight: bold",
211
260
  "",
212
- [...new Set(a)]
261
+ [...new Set(l)]
213
262
  ), console.warn(
214
263
  "%c[Routerino]%c The first matching route will be used",
215
264
  "color: #f59e0b; font-weight: bold",
216
265
  ""
217
266
  ));
218
267
  }
219
- const [S, b] = I(window?.location?.href ?? "/");
220
- O(() => {
268
+ const [b, R] = z(window?.location?.href ?? "/");
269
+ _(() => {
221
270
  if (typeof window > "u" || typeof document > "u")
222
271
  return;
223
- const o = (w) => {
224
- d && console.debug(
272
+ const t = (w) => {
273
+ f && console.debug(
225
274
  "%c[Routerino]%c click occurred",
226
275
  "color: #6b7280; font-weight: bold",
227
276
  ""
228
277
  );
229
- let f = w.target;
230
- for (; f.tagName !== "A" && f.parentElement; )
231
- f = f.parentElement;
232
- if (f.tagName !== "A") {
233
- d && console.debug(
278
+ let d = w.target;
279
+ for (; d.tagName !== "A" && d.parentElement; )
280
+ d = d.parentElement;
281
+ if (d.tagName !== "A") {
282
+ f && console.debug(
234
283
  "%c[Routerino]%c no anchor tag found during click",
235
284
  "color: #6b7280; font-weight: bold",
236
285
  ""
237
286
  );
238
287
  return;
239
288
  }
240
- const m = f.getAttribute("href") || f.href;
241
- if (!m) {
242
- d && console.debug(
289
+ const h = d.getAttribute("href") || d.href;
290
+ if (!h) {
291
+ f && console.debug(
243
292
  "%c[Routerino]%c anchor tag has no href",
244
293
  "color: #6b7280; font-weight: bold",
245
294
  ""
246
295
  );
247
296
  return;
248
297
  }
249
- if (!/^(https?:\/\/|\/|\.\/|\.\.\/|[^:]+$)/i.test(m)) {
250
- d && console.debug(
298
+ if (!/^(https?:\/\/|\/|\.\/|\.\.\/|[^:]+$)/i.test(h)) {
299
+ f && console.debug(
251
300
  "%c[Routerino]%c skipping non-http URL:",
252
301
  "color: #6b7280; font-weight: bold",
253
302
  "",
254
- m
303
+ h
255
304
  );
256
305
  return;
257
306
  }
258
- d && console.debug(
307
+ f && console.debug(
259
308
  "%c[Routerino]%c click target href:",
260
309
  "color: #6b7280; font-weight: bold",
261
310
  "",
262
- m
311
+ h
263
312
  );
264
- let R;
313
+ let $;
265
314
  try {
266
- R = new URL(m, window.location.href);
267
- } catch (C) {
268
- d && console.debug(
315
+ $ = new URL(h, window.location.href);
316
+ } catch (x) {
317
+ f && console.debug(
269
318
  "%c[Routerino]%c Invalid URL:",
270
319
  "color: #6b7280; font-weight: bold",
271
320
  "",
272
- m,
273
- C
321
+ h,
322
+ x
274
323
  );
275
324
  return;
276
325
  }
277
- d && console.debug(
326
+ if (f && console.debug(
278
327
  "%c[Routerino]%c targetUrl:",
279
328
  "color: #6b7280; font-weight: bold",
280
329
  "",
281
- R,
330
+ $,
282
331
  "current:",
283
332
  window.location
284
- ), R && window.location.origin === R.origin ? (d && console.debug(
285
- "%c[Routerino]%c target link is same origin, will use push-state transitioning",
286
- "color: #6b7280; font-weight: bold",
287
- ""
288
- ), w.preventDefault(), f.href !== window.location.href && (b(f.href), window.history.pushState({}, "", f.href)), window.scrollTo({
289
- top: 0,
290
- behavior: "auto"
291
- })) : d && console.debug(
333
+ ), $ && window.location.origin === $.origin)
334
+ if (f && console.debug(
335
+ "%c[Routerino]%c target link is same origin, will use push-state transitioning",
336
+ "color: #6b7280; font-weight: bold",
337
+ ""
338
+ ), w.preventDefault(), d.href !== window.location.href && (R(d.href), window.history.pushState({}, "", d.href)), d.hash) {
339
+ const x = decodeURIComponent(d.hash.slice(1));
340
+ setTimeout(() => {
341
+ const A = document.getElementById(x);
342
+ A ? A.scrollIntoView({ behavior: "auto" }) : window.scrollTo({ top: 0, behavior: "auto" });
343
+ }, 0);
344
+ } else
345
+ window.scrollTo({
346
+ top: 0,
347
+ behavior: "auto"
348
+ });
349
+ else f && console.debug(
292
350
  "%c[Routerino]%c target link does not share an origin, standard browser link handling applies",
293
351
  "color: #6b7280; font-weight: bold",
294
352
  ""
295
353
  );
296
354
  };
297
- document.addEventListener("click", o);
298
- const a = () => {
299
- d && console.debug(
355
+ document.addEventListener("click", t);
356
+ const l = () => {
357
+ f && console.debug(
300
358
  "%c[Routerino]%c route change ->",
301
359
  "color: #6b7280; font-weight: bold",
302
360
  "",
303
361
  window.location.pathname
304
- ), b(window.location.href);
362
+ ), R(window.location.href);
305
363
  };
306
- return window.addEventListener("popstate", a), () => {
307
- document.removeEventListener("click", o), window.removeEventListener("popstate", a);
364
+ return window.addEventListener("popstate", l), () => {
365
+ document.removeEventListener("click", t), window.removeEventListener("popstate", l);
308
366
  };
309
- }, [S]);
367
+ }, [b]);
310
368
  let c = window?.location?.pathname ?? "/";
311
369
  (c === "/index.html" || c === "") && (c = "/");
312
- const k = r.find((o) => o.path === c), P = r.find(
313
- (o) => `${o.path}/` === c || o.path === `${c}/`
314
- ), W = r.find((o) => {
315
- const a = o.path.endsWith("/") ? o.path.slice(0, -1) : o.path, w = c.endsWith("/") ? c.slice(0, -1) : c, f = a.split("/").filter(Boolean), m = w.split("/").filter(Boolean);
316
- return f.length !== m.length ? !1 : f.every((R, C) => R.startsWith(":") ? !0 : R === m[C]);
317
- }), s = k ?? P ?? W;
318
- if (d && console.debug(
370
+ const k = i.find((t) => t.path === c), P = i.find(
371
+ (t) => `${t.path}/` === c || t.path === `${c}/`
372
+ ), y = i.find((t) => {
373
+ const l = t.path.endsWith("/") ? t.path.slice(0, -1) : t.path, w = c.endsWith("/") ? c.slice(0, -1) : c, d = l.split("/").filter(Boolean), h = w.split("/").filter(Boolean);
374
+ return d.length !== h.length ? !1 : d.every(($, x) => $.startsWith(":") ? !0 : $ === h[x]);
375
+ }), s = k ?? P ?? y;
376
+ if (f && console.debug(
319
377
  "%c[Routerino]%c Route matching:",
320
378
  "color: #6b7280; font-weight: bold",
321
379
  "",
322
- { match: s, exactMatch: k, addSlashMatch: P, paramsMatch: W }
380
+ { match: s, exactMatch: k, addSlashMatch: P, paramsMatch: y }
323
381
  ), !s)
324
- return d && (console.group(
382
+ return f && (console.group(
325
383
  "%c[Routerino]%c 404 - No matching route",
326
384
  "color: #f59e0b; font-weight: bold",
327
385
  ""
@@ -334,79 +392,79 @@ function Q({
334
392
  "%c[Routerino]%c Available routes:",
335
393
  "color: #f59e0b; font-weight: bold",
336
394
  "",
337
- r.map((o) => o.path)
338
- ), console.groupEnd()), document.title = D, p && u({ name: "prerender-status-code", content: "404" }), e;
339
- if (p) {
340
- const o = document.querySelector(
395
+ i.map((t) => t.path)
396
+ ), console.groupEnd()), document.title = W, m && p({ name: "prerender-status-code", content: "404" }), e;
397
+ if (m) {
398
+ const t = document.querySelector(
341
399
  'meta[name="prerender-status-code"]'
342
400
  );
343
- o && o.remove();
344
- const a = document.querySelector(
401
+ t && t.remove();
402
+ const l = document.querySelector(
345
403
  'meta[name="prerender-header"]'
346
404
  );
347
- a && a.remove();
405
+ l && l.remove();
348
406
  }
349
- const j = l && !c.endsWith("/") && c !== "/", A = !l && c.endsWith("/") && c !== "/", y = j ? `${c}/` : A ? c.slice(0, -1) : c, U = `${L ?? window?.location?.origin ?? ""}${y}`;
407
+ const v = a && !c.endsWith("/") && c !== "/", j = !a && c.endsWith("/") && c !== "/", F = v ? `${c}/` : j ? c.slice(0, -1) : c, U = `${O ?? window?.location?.origin ?? ""}${F}`;
350
408
  if (s.title) {
351
- const o = `${s.title}${E}${$}`;
352
- document.title = o, u({
409
+ const t = `${s.title}${S}${E}`;
410
+ document.title = t, p({
353
411
  tag: "link",
354
412
  rel: "canonical",
355
413
  href: U
356
- }), s.tags?.find(({ property: a }) => a === "og:title") || u({
414
+ }), s.tags?.find(({ property: l }) => l === "og:title") || p({
357
415
  property: "og:title",
358
- content: o
359
- }), s.tags?.find(({ property: a }) => a === "og:url") || u({
416
+ content: t
417
+ }), s.tags?.find(({ property: l }) => l === "og:url") || p({
360
418
  property: "og:url",
361
419
  content: U
362
420
  });
363
421
  }
364
- if (s.description && (u({ name: "description", content: s.description }), s.tags?.find(({ property: o }) => o === "og:description") || u({
422
+ if (s.description && (p({ name: "description", content: s.description }), s.tags?.find(({ property: t }) => t === "og:description") || p({
365
423
  property: "og:description",
366
424
  content: s.description
367
- })), (v || s.imageUrl) && u({
425
+ })), (I || s.imageUrl) && p({
368
426
  property: "og:image",
369
- content: s.imageUrl ?? v
370
- }), s.tags?.find(({ property: o }) => o === "twitter:card") || u({
427
+ content: s.imageUrl ?? I
428
+ }), s.tags?.find(({ property: t }) => t === "twitter:card") || p({
371
429
  name: "twitter:card",
372
430
  content: "summary_large_image"
373
- }), x && u({
431
+ }), L && p({
374
432
  tag: "link",
375
433
  rel: "apple-touch-icon",
376
- href: x
377
- }), p && (j || A) && (u({ name: "prerender-status-code", content: "301" }), u({
434
+ href: L
435
+ }), m && (v || j) && (p({ name: "prerender-status-code", content: "301" }), p({
378
436
  name: "prerender-header",
379
437
  content: `Location: ${U}`
380
- })), s.tags && s.tags.length ? (s.tags.find(({ property: o }) => o === "og:type") || u({ property: "og:type", content: "website" }), s.tags.forEach((o) => u(o))) : u({ property: "og:type", content: "website" }), s.element) {
381
- const o = N({
438
+ })), s.tags && s.tags.length ? (s.tags.find(({ property: t }) => t === "og:type") || p({ property: "og:type", content: "website" }), s.tags.forEach((t) => p(t))) : p({ property: "og:type", content: "website" }), s.element) {
439
+ const t = ne({
382
440
  routePattern: s.path,
383
441
  currentRoute: c
384
- }), a = {
442
+ }), l = {
385
443
  currentRoute: c,
386
- params: o,
444
+ params: t,
387
445
  routePattern: s.path,
388
- updateHeadTag: u
446
+ updateHeadTag: p
389
447
  };
390
- return /* @__PURE__ */ g(z.Provider, { value: a, children: /* @__PURE__ */ g(
391
- M,
448
+ return /* @__PURE__ */ g(K.Provider, { value: l, children: /* @__PURE__ */ g(
449
+ Z,
392
450
  {
393
451
  fallback: n,
394
452
  errorTitleString: T,
395
- usePrerenderTags: p,
453
+ usePrerenderTags: m,
396
454
  routePath: c,
397
- debug: d,
455
+ debug: f,
398
456
  children: s.element
399
457
  }
400
458
  ) });
401
459
  }
402
- return d && console.error(
460
+ return f && console.error(
403
461
  "%c[Routerino]%c No route found for",
404
462
  "color: #ff6b6b; font-weight: bold",
405
463
  "",
406
464
  c
407
- ), document.title = D, p && u({ name: "prerender-status-code", content: "404" }), e;
408
- } catch (S) {
409
- return d && (console.group(
465
+ ), document.title = W, m && p({ name: "prerender-status-code", content: "404" }), e;
466
+ } catch (b) {
467
+ return f && (console.group(
410
468
  "%c[Routerino]%c Fatal Error",
411
469
  "color: #ff6b6b; font-weight: bold",
412
470
  ""
@@ -418,64 +476,64 @@ function Q({
418
476
  "%c[Routerino]%c Error:",
419
477
  "color: #ff6b6b; font-weight: bold",
420
478
  "",
421
- S
479
+ b
422
480
  ), console.error(
423
481
  "%c[Routerino]%c This typically means an issue with route configuration or router setup",
424
482
  "color: #ff6b6b; font-weight: bold",
425
483
  ""
426
- ), console.groupEnd()), p && u({ name: "prerender-status-code", content: "500" }), document.title = T, n;
484
+ ), console.groupEnd()), m && p({ name: "prerender-status-code", content: "500" }), document.title = T, n;
427
485
  }
428
486
  }
429
- const X = t.exact({
430
- path: (r, e, i) => {
431
- const n = r[e];
487
+ const ie = o.exact({
488
+ path: (i, e, r) => {
489
+ const n = i[e];
432
490
  return n == null ? new Error(
433
- `The prop \`${e}\` is marked as required in \`${i}\`, but its value is \`${n}\`.`
491
+ `The prop \`${e}\` is marked as required in \`${r}\`, but its value is \`${n}\`.`
434
492
  ) : typeof n != "string" ? new Error(
435
- `Invalid prop \`${e}\` of type \`${typeof n}\` supplied to \`${i}\`, expected \`string\`.`
493
+ `Invalid prop \`${e}\` of type \`${typeof n}\` supplied to \`${r}\`, expected \`string\`.`
436
494
  ) : n.startsWith("/") ? null : new Error(
437
- `Invalid prop \`${e}\` value \`${n}\` supplied to \`${i}\`. Route paths must start with a forward slash (/).`
495
+ `Invalid prop \`${e}\` value \`${n}\` supplied to \`${r}\`. Route paths must start with a forward slash (/).`
438
496
  );
439
497
  },
440
- element: t.element.isRequired,
441
- title: t.string,
442
- description: t.string,
443
- tags: t.arrayOf(t.object),
444
- imageUrl: t.string
498
+ element: o.element.isRequired,
499
+ title: o.string,
500
+ description: o.string,
501
+ tags: o.arrayOf(o.object),
502
+ imageUrl: o.string
445
503
  });
446
- Q.propTypes = {
447
- routes: t.arrayOf(X),
448
- title: t.string,
449
- separator: t.string,
450
- notFoundTemplate: t.element,
451
- notFoundTitle: t.string,
452
- errorTemplate: t.element,
453
- errorTitle: t.string,
454
- useTrailingSlash: t.bool,
455
- usePrerenderTags: t.bool,
456
- baseUrl: (r, e, i) => {
457
- const n = r[e];
504
+ re.propTypes = {
505
+ routes: o.arrayOf(ie),
506
+ title: o.string,
507
+ separator: o.string,
508
+ notFoundTemplate: o.element,
509
+ notFoundTitle: o.string,
510
+ errorTemplate: o.element,
511
+ errorTitle: o.string,
512
+ useTrailingSlash: o.bool,
513
+ usePrerenderTags: o.bool,
514
+ baseUrl: (i, e, r) => {
515
+ const n = i[e];
458
516
  if (n != null) {
459
517
  if (typeof n != "string")
460
518
  return new Error(
461
- `Invalid prop \`${e}\` of type \`${typeof n}\` supplied to \`${i}\`, expected \`string\`.`
519
+ `Invalid prop \`${e}\` of type \`${typeof n}\` supplied to \`${r}\`, expected \`string\`.`
462
520
  );
463
521
  if (n.endsWith("/"))
464
522
  return new Error(
465
- `Invalid prop \`${e}\` supplied to \`${i}\`. The baseUrl should not end with a slash. Got: "${n}"`
523
+ `Invalid prop \`${e}\` supplied to \`${r}\`. The baseUrl should not end with a slash. Got: "${n}"`
466
524
  );
467
525
  }
468
526
  return null;
469
527
  },
470
- imageUrl: t.string,
471
- touchIconUrl: t.string,
472
- debug: t.bool
528
+ imageUrl: o.string,
529
+ touchIconUrl: o.string,
530
+ debug: o.bool
473
531
  };
474
532
  export {
475
- M as ErrorBoundary,
476
- B as Image,
477
- Q as Routerino,
478
- Q as default,
479
- u as updateHeadTag,
480
- oe as useRouterino
533
+ Z as ErrorBoundary,
534
+ oe as Image,
535
+ re as Routerino,
536
+ re as default,
537
+ p as updateHeadTag,
538
+ le as useRouterino
481
539
  };