reroute-js 1.0.0-alpha.39 → 1.0.0-alpha.40
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 +34 -0
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +231 -50
- package/cli/bin.js.map +13 -13
- package/cli/index.d.ts +1 -1
- package/cli/index.js +8 -5
- package/cli/index.js.map +11 -10
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/build.d.ts +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/gen.d.ts.map +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.d.ts +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +1 -1
- package/cli/src/commands/lib/images.d.ts +1 -1
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
- package/cli/src/commands/lib/prerender.d.ts +1 -1
- package/cli/src/commands/lib/production.d.ts +1 -1
- package/cli/src/commands/lib/routes.d.ts +1 -1
- package/cli/src/commands/lib/server.d.ts +1 -1
- package/cli/src/commands/lib/ssr-strip.d.ts +1 -1
- package/cli/src/commands/lib/static.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
- package/cli/src/commands/lib/supervise.d.ts +1 -1
- package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
- package/cli/src/commands/lib/theme.d.ts +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/lib/watch.d.ts +1 -1
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/commands/static-render.d.ts +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +221 -46
- package/core/index.js.map +12 -12
- package/core/src/app-paths.d.ts +1 -1
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/i18n/catalog.d.ts +1 -1
- package/core/src/i18n/discover.d.ts +1 -1
- package/core/src/i18n/discover.d.ts.map +1 -1
- package/core/src/i18n/index.d.ts +2 -2
- package/core/src/i18n/index.d.ts.map +1 -1
- package/core/src/i18n/messages.d.ts +1 -1
- package/core/src/i18n/negotiate.d.ts +1 -1
- package/core/src/i18n/pathname.d.ts +32 -4
- package/core/src/i18n/pathname.d.ts.map +1 -1
- package/core/src/i18n/resolve.d.ts +3 -2
- package/core/src/i18n/resolve.d.ts.map +1 -1
- package/core/src/i18n/types.d.ts +44 -1
- package/core/src/i18n/types.d.ts.map +1 -1
- package/core/src/image.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/discovery.d.ts +1 -1
- package/core/src/llms/extractor.d.ts +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/full-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts +1 -1
- package/core/src/llms/index.d.ts +1 -1
- package/core/src/og/discovery.d.ts +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +1 -1
- package/core/src/sitemap/generator.d.ts +12 -2
- package/core/src/sitemap/generator.d.ts.map +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +1 -1
- package/core/src/ssr/lib/cleanup.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts.map +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts.map +1 -1
- package/core/src/ssr/lib/content-path.d.ts +13 -2
- package/core/src/ssr/lib/content-path.d.ts.map +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/html.d.ts +1 -1
- package/core/src/ssr/lib/imports.d.ts +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts.map +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +1 -1
- package/core/src/ssr/lib/route-match.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +1 -1
- package/core/src/ssr/lib/serialize.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +1 -1
- package/core/src/ssr/lib/styles.d.ts +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +7 -1
- package/core/src/ssr/lib/types.d.ts.map +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/stream.d.ts +1 -1
- package/core/src/ssr/stream.d.ts.map +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +370 -87
- package/elysia/index.js.map +18 -17
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/devReload.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/i18n.d.ts +14 -3
- package/elysia/src/libs/i18n.d.ts.map +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/libs/index.d.ts +1 -1
- package/elysia/src/libs/lazyData.d.ts +38 -0
- package/elysia/src/libs/lazyData.d.ts.map +1 -0
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts.map +1 -1
- package/elysia/src/routes/liveReloadClient.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +1 -1
- package/elysia/src/routes/rss.d.ts +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts.map +1 -1
- package/elysia/src/routes/ssr.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts.map +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/routes/themeCssRefresh.d.ts +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +85 -20
- package/react/index.js.map +6 -6
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/i18n/LocaleProvider.d.ts +20 -2
- package/react/src/i18n/LocaleProvider.d.ts.map +1 -1
- package/react/src/i18n/helpers.d.ts +31 -3
- package/react/src/i18n/helpers.d.ts.map +1 -1
- package/react/src/i18n/index.d.ts +2 -2
- package/react/src/i18n/index.d.ts.map +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/bundle.d.ts +1 -1
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +1 -1
- package/react/src/lib/index.d.ts +1 -1
- package/react/src/lib/layouts.d.ts +1 -1
- package/react/src/lib/lazy-route.d.ts +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/lib/static-data.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts.map +1 -1
- package/react/src/providers/RouterProvider.d.ts +4 -2
- package/react/src/providers/RouterProvider.d.ts.map +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +7 -1
- package/react/src/types/router.d.ts.map +1 -1
- package/telemetry/react.d.ts +1 -1
- package/telemetry/react.js +2 -2
- package/telemetry/react.js.map +1 -1
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +6 -3
- package/telemetry/server.js.map +11 -10
- package/telemetry/src/react/api.d.ts +1 -1
- package/telemetry/src/react/context.d.ts +1 -1
- package/telemetry/src/react/index.d.ts +1 -1
- package/telemetry/src/react/telemetry.d.ts +1 -1
- package/telemetry/src/server/context.d.ts +1 -1
- package/telemetry/src/server/headers/extractor.d.ts +1 -1
- package/telemetry/src/server/headers/index.d.ts +1 -1
- package/telemetry/src/server/headers/presets.d.ts +1 -1
- package/telemetry/src/server/index.d.ts +1 -1
- package/telemetry/src/server/instrumentation.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts +1 -1
- package/telemetry/src/server/sourcemap.d.ts +1 -1
package/elysia/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v1.0.0-alpha.
|
|
2
|
+
* reroute-js v1.0.0-alpha.40
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 stewones <hi@stewan.io>
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Built with Bun <3
|
|
9
9
|
*/
|
|
10
|
+
import { type ResolvedI18n } from 'reroute-js/core';
|
|
11
|
+
type LoadedI18n = ResolvedI18n & {
|
|
12
|
+
collections?: string[];
|
|
13
|
+
};
|
|
14
|
+
declare function loadI18nState(cwd: string): Promise<LoadedI18n>;
|
|
10
15
|
type I18nRequestResult = {
|
|
11
16
|
enabled: boolean;
|
|
12
17
|
locale: string;
|
|
@@ -15,12 +20,18 @@ type I18nRequestResult = {
|
|
|
15
20
|
cookie: string;
|
|
16
21
|
catalogs: Record<string, unknown>;
|
|
17
22
|
collections?: string[];
|
|
18
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Set-Cookie header value when locale should be persisted. With
|
|
25
|
+
* `prefixPages`, only on a `?lang=` redirect (pages stay cacheable) and
|
|
26
|
+
* on `unprefixedPaths` pages, which resolve as without it.
|
|
27
|
+
*/
|
|
19
28
|
setCookie?: string;
|
|
20
29
|
/** 302 Location when a redirect is required */
|
|
21
30
|
redirectTo?: string;
|
|
31
|
+
/** Redirect with 301: the URL moved for good (`prefixPages`). */
|
|
32
|
+
permanent?: boolean;
|
|
22
33
|
hydration: Record<string, unknown>;
|
|
23
34
|
};
|
|
24
35
|
declare function resolveI18nForRequest(cwd: string, pathname: string, headers: Record<string, string>, collections?: string[], search?: string): Promise<I18nRequestResult>;
|
|
25
|
-
export { resolveI18nForRequest };
|
|
36
|
+
export { loadI18nState, resolveI18nForRequest };
|
|
26
37
|
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/libs/i18n.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/libs/i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,KAAK,YAAY,EAEjB,MAAM,iBAAiB,CAAC;AAEzB,KAAK,UAAU,GAAG,YAAY,GAAG;IAChC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAiBF,iBAAe,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAkB7D;AAED,KAAK,iBAAiB,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAeF,iBAAe,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,MAAM,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CA0F5B;AAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reroute-js v1.0.0-alpha.40
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 stewones <hi@stewan.io>
|
|
6
|
+
* @see https://github.com/Intenseloop/reroute
|
|
7
|
+
*
|
|
8
|
+
* Built with Bun <3
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The data a lazy marker points at, kept between the marker's answer and its
|
|
12
|
+
* follow-up request (`&key=`), so a route's `ssr.data` runs once per
|
|
13
|
+
* navigation or hover instead of once per request.
|
|
14
|
+
*
|
|
15
|
+
* Entries belong to one exact request (see lazyDataRequest), are taken once,
|
|
16
|
+
* and expire on their own when no follow-up comes.
|
|
17
|
+
*/
|
|
18
|
+
type LazyDataStore = {
|
|
19
|
+
/** Keep the promises of a just-computed answer for its follow-ups. */
|
|
20
|
+
keep(request: string, pathname: string, data: Record<string, unknown>): void;
|
|
21
|
+
/** The kept promise for one key, removed as it's handed out. */
|
|
22
|
+
take(request: string, pathname: string, key: string): Promise<unknown> | undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The request a marker was made for: every header that could reach
|
|
26
|
+
* `ssr.data` (cookie, authorization, language, country, IP…). A follow-up
|
|
27
|
+
* takes kept data only when it is the same request; anything else computes
|
|
28
|
+
* its own.
|
|
29
|
+
*/
|
|
30
|
+
declare function lazyDataRequest(headers: Record<string, string | undefined> | undefined): string;
|
|
31
|
+
declare function createLazyDataStore(options?: {
|
|
32
|
+
ttlMs?: number;
|
|
33
|
+
maxEntries?: number;
|
|
34
|
+
now?: () => number;
|
|
35
|
+
}): LazyDataStore;
|
|
36
|
+
export { createLazyDataStore, lazyDataRequest };
|
|
37
|
+
export type { LazyDataStore };
|
|
38
|
+
//# sourceMappingURL=lazyData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyData.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/libs/lazyData.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,KAAK,aAAa,GAAG;IACpB,sEAAsE;IACtE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7E,gEAAgE;IAChE,IAAI,CACH,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;CAChC,CAAC;AAyBF;;;;;GAKG;AACH,iBAAS,eAAe,CACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,GACrD,MAAM,CAOR;AAED,iBAAS,mBAAmB,CAC3B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GACvE,aAAa,CAkDf;AAED,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
package/elysia/src/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/routes/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAEX,cAAc,EACd,SAAS,EACT,QAAQ,EACR,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/routes/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAEX,cAAc,EACd,SAAS,EACT,QAAQ,EACR,MAAM,iBAAiB,CAAC;AAWzB,KAAK,oBAAoB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,QAAQ,CAAC,EAAE;QACV,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1B,YAAY,CAAC,EAAE,SAAS,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,4DAA4D;QAC5D,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,GACrD,OAAO,CAET;AAoCD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,oBAAoB,GACxB,MAAM,CAyXR;AAED;;GAEG;AACH,KAAK,eAAe,GAAG;IACtB,OAAO,EAAE,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC9C,sEAAsE;IACtE,aAAa,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;CACtC,CAAC;AA0OF;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,eAAe,GACpB,MAAM,CA+DR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/routes/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAGN,KAAK,cAAc,EAEnB,KAAK,QAAQ,IAAI,YAAY,EAC7B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/routes/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAGN,KAAK,cAAc,EAEnB,KAAK,QAAQ,IAAI,YAAY,EAC7B,MAAM,iBAAiB,CAAC;AAMzB,KAAK,mBAAmB,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AA0FF,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,mBAAmB,GAC1B,MAAM,CA4ER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/routes/ssr.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAGN,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,SAAS,EAGd,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/elysia/src/routes/ssr.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAGN,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,SAAS,EAGd,MAAM,iBAAiB,CAAC;AAkFzB,KAAK,eAAe,GAAG;IACtB,aAAa,EAAE,YAAY,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACzD,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAyrBxE;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/elysia/src/types.d.ts
CHANGED
package/package.json
CHANGED
package/react/index.d.ts
CHANGED
package/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v1.0.0-alpha.
|
|
2
|
+
* reroute-js v1.0.0-alpha.40
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 stewones <hi@stewan.io>
|
|
@@ -486,13 +486,42 @@ function localizeContentHref(collection, name, locale, defaultLocale) {
|
|
|
486
486
|
}
|
|
487
487
|
return `/${collection}/${locale}/${name}`;
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function parseLocalePrefix(pathname, availableLocales) {
|
|
490
|
+
const pathOnly = pathname.split("?")[0].split("#")[0];
|
|
491
|
+
const [, segment = "", ...rest] = pathOnly.split("/");
|
|
492
|
+
const locale = availableLocales.find((l) => l.toLowerCase() === segment.toLowerCase());
|
|
493
|
+
if (!locale)
|
|
494
|
+
return;
|
|
495
|
+
return { locale, routingPathname: `/${rest.join("/")}` };
|
|
496
|
+
}
|
|
497
|
+
function localizePagePath(pathname, locale, defaultLocale) {
|
|
498
|
+
if (locale === defaultLocale)
|
|
499
|
+
return pathname;
|
|
500
|
+
return pathname === "/" ? `/${locale}` : `/${locale}${pathname}`;
|
|
501
|
+
}
|
|
502
|
+
function pathLocale(pathname, availableLocales, defaultLocale, collections = []) {
|
|
503
|
+
const prefix = parseLocalePrefix(pathname, availableLocales);
|
|
504
|
+
const page = prefix?.routingPathname ?? pathname;
|
|
505
|
+
return parseContentPath(page, availableLocales, collections)?.locale ?? prefix?.locale ?? defaultLocale;
|
|
506
|
+
}
|
|
507
|
+
function isUnprefixedPath(pathname, unprefixedPaths = []) {
|
|
508
|
+
const path = pathname.split("?")[0].split("#")[0];
|
|
509
|
+
return unprefixedPaths.some((prefix) => {
|
|
510
|
+
const base = prefix.replace(/\/+$/, "");
|
|
511
|
+
return base === "" || path === base || path.startsWith(`${base}/`);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function localizeHref(to, locale, defaultLocale, availableLocales = [], collections, prefixPages) {
|
|
490
515
|
try {
|
|
491
516
|
const url = new URL(to, "http://local");
|
|
492
|
-
const parsed = parseContentPath(url.pathname, availableLocales, collections);
|
|
493
|
-
if (
|
|
517
|
+
const parsed = parseContentPath(url.pathname, availableLocales, prefixPages ? collections ?? [] : collections);
|
|
518
|
+
if (parsed) {
|
|
519
|
+
url.pathname = localizeContentHref(parsed.collection, parsed.name, locale, defaultLocale);
|
|
520
|
+
} else if (prefixPages && to.startsWith("/") && url.origin === "http://local" && !/\.[^/]+$/.test(url.pathname) && !parseLocalePrefix(url.pathname, availableLocales) && !isUnprefixedPath(url.pathname, prefixPages.unprefixedPaths)) {
|
|
521
|
+
url.pathname = localizePagePath(url.pathname, locale, defaultLocale);
|
|
522
|
+
} else {
|
|
494
523
|
return to;
|
|
495
|
-
|
|
524
|
+
}
|
|
496
525
|
return `${url.pathname}${url.search}${url.hash}`;
|
|
497
526
|
} catch {
|
|
498
527
|
return to;
|
|
@@ -529,14 +558,16 @@ function readHydration() {
|
|
|
529
558
|
locales: Array.isArray(raw.locales) ? raw.locales : [],
|
|
530
559
|
cookie: raw.cookie || "reroute-locale",
|
|
531
560
|
catalogs: raw.catalogs || {},
|
|
532
|
-
collections: raw.collections
|
|
561
|
+
collections: raw.collections,
|
|
562
|
+
prefixPages: raw.prefixPages,
|
|
563
|
+
unprefixedPaths: raw.unprefixedPaths
|
|
533
564
|
};
|
|
534
565
|
}
|
|
535
566
|
} catch {}
|
|
536
567
|
return DISABLED_STATE;
|
|
537
568
|
}
|
|
538
569
|
function sameHydration(a, b) {
|
|
539
|
-
return a.enabled === b.enabled && a.locale === b.locale && a.defaultLocale === b.defaultLocale && a.cookie === b.cookie && a.catalogs === b.catalogs && a.locales === b.locales && a.collections === b.collections;
|
|
570
|
+
return a.enabled === b.enabled && a.locale === b.locale && a.defaultLocale === b.defaultLocale && a.cookie === b.cookie && a.catalogs === b.catalogs && a.locales === b.locales && a.collections === b.collections && a.prefixPages === b.prefixPages && a.unprefixedPaths === b.unprefixedPaths;
|
|
540
571
|
}
|
|
541
572
|
var store = {
|
|
542
573
|
state: readHydration(),
|
|
@@ -612,7 +643,7 @@ function LocaleProvider({
|
|
|
612
643
|
const localizePath = useCallback((to) => {
|
|
613
644
|
if (!state.enabled)
|
|
614
645
|
return to;
|
|
615
|
-
return localizeHref(to, state.locale, state.defaultLocale, state.locales, state.collections);
|
|
646
|
+
return localizeHref(to, state.locale, state.defaultLocale, state.locales, state.collections, state.prefixPages ? { unprefixedPaths: state.unprefixedPaths } : undefined);
|
|
616
647
|
}, [state]);
|
|
617
648
|
const localizeContentPath = useCallback((collection, name) => {
|
|
618
649
|
if (!state.enabled)
|
|
@@ -634,6 +665,28 @@ function LocaleProvider({
|
|
|
634
665
|
children
|
|
635
666
|
});
|
|
636
667
|
}
|
|
668
|
+
function leavesLocale(pathname, current) {
|
|
669
|
+
const state = getSnapshot();
|
|
670
|
+
if (!(state.enabled && state.prefixPages))
|
|
671
|
+
return false;
|
|
672
|
+
const prefix = parseLocalePrefix(pathname, state.locales);
|
|
673
|
+
const page = prefix?.routingPathname ?? pathname;
|
|
674
|
+
if (isUnprefixedPath(page, state.unprefixedPaths)) {
|
|
675
|
+
return !!prefix || !isUnprefixedPath(current, state.unprefixedPaths);
|
|
676
|
+
}
|
|
677
|
+
return pathLocale(pathname, state.locales, state.defaultLocale, state.collections) !== state.locale;
|
|
678
|
+
}
|
|
679
|
+
function carryLocale(pathname, current) {
|
|
680
|
+
const state = getSnapshot();
|
|
681
|
+
if (!(state.enabled && state.prefixPages))
|
|
682
|
+
return;
|
|
683
|
+
const page = parseLocalePrefix(pathname, state.locales)?.routingPathname ?? pathname;
|
|
684
|
+
if (!isUnprefixedPath(page, state.unprefixedPaths))
|
|
685
|
+
return;
|
|
686
|
+
if (isUnprefixedPath(current, state.unprefixedPaths))
|
|
687
|
+
return;
|
|
688
|
+
writeLocaleCookie(state.cookie, state.locale);
|
|
689
|
+
}
|
|
637
690
|
function useLocaleContext() {
|
|
638
691
|
const ctx = useContext(LocaleContext);
|
|
639
692
|
if (ctx)
|
|
@@ -1647,6 +1700,7 @@ function layoutWraps(layout, pathname, routePattern) {
|
|
|
1647
1700
|
|
|
1648
1701
|
// packages/react/src/providers/RouterProvider.tsx
|
|
1649
1702
|
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1703
|
+
var samePath = (path) => path;
|
|
1650
1704
|
var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
1651
1705
|
var OutletContext = createContext3(null);
|
|
1652
1706
|
var LayoutPatternContext = createContext3(null);
|
|
@@ -1748,6 +1802,11 @@ function navigateInternal(to, options = {}) {
|
|
|
1748
1802
|
window.location.href = to;
|
|
1749
1803
|
return;
|
|
1750
1804
|
}
|
|
1805
|
+
if (leavesLocale(url.pathname, window.location.pathname)) {
|
|
1806
|
+
carryLocale(url.pathname, window.location.pathname);
|
|
1807
|
+
window.location.assign(to);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1751
1810
|
const newPath = url.pathname + url.search + url.hash;
|
|
1752
1811
|
const currentPath2 = window.location.pathname + window.location.search + window.location.hash;
|
|
1753
1812
|
if (newPath === currentPath2)
|
|
@@ -1827,6 +1886,7 @@ function RouterProvider({
|
|
|
1827
1886
|
children,
|
|
1828
1887
|
layouts = [],
|
|
1829
1888
|
matchRoute,
|
|
1889
|
+
routingPath = samePath,
|
|
1830
1890
|
notFoundRoutes = [],
|
|
1831
1891
|
notFound: NotFound,
|
|
1832
1892
|
pathname = "/",
|
|
@@ -2098,6 +2158,7 @@ function RouterProvider({
|
|
|
2098
2158
|
}, [notFoundRoutes]);
|
|
2099
2159
|
const contextValue = useMemo5(() => ({
|
|
2100
2160
|
pathname: location.pathname,
|
|
2161
|
+
routingPathname: routingPath(location.pathname),
|
|
2101
2162
|
params,
|
|
2102
2163
|
searchParams,
|
|
2103
2164
|
navigate,
|
|
@@ -2106,6 +2167,7 @@ function RouterProvider({
|
|
|
2106
2167
|
notFoundResolver
|
|
2107
2168
|
}), [
|
|
2108
2169
|
location.pathname,
|
|
2170
|
+
routingPath,
|
|
2109
2171
|
params,
|
|
2110
2172
|
searchParams,
|
|
2111
2173
|
navigate,
|
|
@@ -2114,10 +2176,10 @@ function RouterProvider({
|
|
|
2114
2176
|
notFoundResolver
|
|
2115
2177
|
]);
|
|
2116
2178
|
const matchingLayouts = useMemo5(() => {
|
|
2117
|
-
return layouts.filter((layout) => layoutWraps(layout, location.pathname, target?.route.pattern)).sort((a, b) => {
|
|
2179
|
+
return layouts.filter((layout) => layoutWraps(layout, routingPath(location.pathname), target?.route.pattern)).sort((a, b) => {
|
|
2118
2180
|
return a.pattern.split("/").filter(Boolean).length - b.pattern.split("/").filter(Boolean).length;
|
|
2119
2181
|
});
|
|
2120
|
-
}, [layouts, location.pathname, target]);
|
|
2182
|
+
}, [layouts, location.pathname, routingPath, target]);
|
|
2121
2183
|
let content;
|
|
2122
2184
|
if (target) {
|
|
2123
2185
|
const Component = target.route.component;
|
|
@@ -2136,7 +2198,7 @@ function RouterProvider({
|
|
|
2136
2198
|
}
|
|
2137
2199
|
content = outletContent;
|
|
2138
2200
|
} else {
|
|
2139
|
-
const Fallback = notFoundResolver(location.pathname) || NotFound;
|
|
2201
|
+
const Fallback = notFoundResolver(routingPath(location.pathname)) || NotFound;
|
|
2140
2202
|
if (Fallback) {
|
|
2141
2203
|
content = /* @__PURE__ */ jsx4(Fallback, {});
|
|
2142
2204
|
} else {
|
|
@@ -2213,14 +2275,14 @@ function RerouteProvider({
|
|
|
2213
2275
|
return Object.keys(byCollection);
|
|
2214
2276
|
return;
|
|
2215
2277
|
}, [i18n?.collections, byCollection]);
|
|
2216
|
-
const
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2278
|
+
const prefixPages = !!i18n?.prefixPages;
|
|
2279
|
+
const routingPath = useCallback6((path) => {
|
|
2280
|
+
if (!(i18n?.enabled && locales.length))
|
|
2281
|
+
return path;
|
|
2282
|
+
const page = prefixPages && parseLocalePrefix(path, locales)?.routingPathname || path;
|
|
2283
|
+
return parseContentPath(page, locales, collections)?.routingPathname || page;
|
|
2284
|
+
}, [i18n?.enabled, prefixPages, locales, collections]);
|
|
2285
|
+
const matchRouteWithLocale = useCallback6((path) => resolvedMatchRoute(routingPath(path)), [routingPath, resolvedMatchRoute]);
|
|
2224
2286
|
return /* @__PURE__ */ jsx5(LocaleProvider, {
|
|
2225
2287
|
value: i18n,
|
|
2226
2288
|
children: /* @__PURE__ */ jsx5(ContentProvider, {
|
|
@@ -2231,6 +2293,7 @@ function RerouteProvider({
|
|
|
2231
2293
|
children: /* @__PURE__ */ jsx5(RouterProvider, {
|
|
2232
2294
|
layouts: resolvedLayouts,
|
|
2233
2295
|
matchRoute: matchRouteWithLocale,
|
|
2296
|
+
routingPath,
|
|
2234
2297
|
notFoundRoutes: resolvedNotFoundRoutes,
|
|
2235
2298
|
notFound,
|
|
2236
2299
|
pathname,
|
|
@@ -4035,6 +4098,7 @@ export {
|
|
|
4035
4098
|
layoutWraps,
|
|
4036
4099
|
localizeContentHref,
|
|
4037
4100
|
localizeHref,
|
|
4101
|
+
localizePagePath,
|
|
4038
4102
|
missingBundleMessage,
|
|
4039
4103
|
namesViewTransition,
|
|
4040
4104
|
navigationHeadFor,
|
|
@@ -4044,6 +4108,7 @@ export {
|
|
|
4044
4108
|
parseContentHref,
|
|
4045
4109
|
parseContentPath,
|
|
4046
4110
|
parseLocalUrl,
|
|
4111
|
+
parseLocalePrefix,
|
|
4047
4112
|
prefetchContent,
|
|
4048
4113
|
prefetchContentModule,
|
|
4049
4114
|
prefetchRouteData,
|
|
@@ -4083,4 +4148,4 @@ export {
|
|
|
4083
4148
|
wouldUnload
|
|
4084
4149
|
};
|
|
4085
4150
|
|
|
4086
|
-
//# debugId=
|
|
4151
|
+
//# debugId=538C9CF2568B4E8964756E2164756E21
|