@reckona/mreact-router 0.0.150 → 0.0.151

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/index.d.ts CHANGED
@@ -41,14 +41,14 @@ export declare const getSession: typeof getSessionInternal;
41
41
  export declare const rotateSession: typeof rotateSessionInternal;
42
42
  export type { AwsLambdaArtifactManifest, BuildAppPhase, BuildAppPhaseTiming, BuildAppOptions, BuildAppProgressEvent, BuildAppResult, BuiltImportPolicyArtifact, CloudflarePagesArtifactManifest, PackageAwsLambdaArtifactOptions, PackageCloudflarePagesArtifactOptions, } from "./build.js";
43
43
  export type { ServerActionContext } from "./actions.js";
44
- export type { AppRouteHref, DynamicHrefOptions, RouteParamsFor, RouteSearchParams, RouteSearchValue, StaticHrefOptions, } from "./typed-routes.js";
44
+ export type { AppRouteHref, AppRouteLinkHref, AppRouteLinkHrefSuffix, AppRouteLinkPathname, AppRouteLinkSegment, AppRouteLinkSegments, DynamicHrefOptions, RouteParamsFor, RouteSearchParams, RouteSearchValue, StaticHrefOptions, } from "./typed-routes.js";
45
45
  export type { InferLoaderData, InferLoaderParams, LayoutProps, LoaderContext, GenerateMetadataContext, ManifestContext, ManifestDescriptor, MetadataImage, MetadataScalar, MetadataThemeColor, MetadataViewport, MReactNode, PageProps, PageComponent, RobotsContext, RobotsManifest, RobotsRule, RouteHeadDescriptor, RouteHandlerContext, RouteLoader, RouteMetadata, RouteParams, RouteSecurityHeaders, RouteStrictTransportSecurity, SitemapContext, SitemapEntry, } from "./types.js";
46
46
  export type { AppRouterBuildTarget, AppRouterClientConsoleMethod, AppRouterClientSourceMapMode, AppRouterClientSourceMapOption, AppRouterProductionOptions, } from "./config.js";
47
47
  export type { AssetHelperOptions, AssetLinkDescriptor, AssetManifest, AssetManifestEntry, } from "./assets.js";
48
48
  export type { AppRouterCache, AppRouterCacheEntry, CacheControlOptions, MemoryRouteCacheOptions, RouteCachePolicy, } from "./cache.js";
49
49
  export type { CookieOptions } from "./cookies.js";
50
50
  export type { AppRouterImportPolicy } from "./import-policy.js";
51
- export type { LinkChild, LinkOptions, LinkPrefetch, LinkProps, LinkScroll, LinkTransition, TrustedLinkHtml, } from "./link.js";
51
+ export type { AppRouteDeclarations, ConcreteLinkHrefGuard, LinkChild, LinkHref, LinkOptions, LinkPrefetch, LinkProps, RegisteredAppRoutePath, LinkScroll, LinkTransition, TrustedLinkHtml, } from "./link.js";
52
52
  export type { AppRouterNavigationState, AppRouterNavigationStateListener, AppRouterNavigationType, } from "./navigation-state.js";
53
53
  export type { RouterRuntimeCacheStat } from "./runtime-cache.js";
54
54
  export type { MemorySessionStoreOptionsInternal as MemorySessionStoreOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EACV,0BAA0B,EAC1B,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,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AACrD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAsGnD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAkBnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAiBpB,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AASxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nexport { assetHref, assetPreloadLinks } from \"./assets.js\";\nexport { cacheControl, createMemoryRouteCache, revalidatePath } from \"./cache.js\";\nexport { deleteCookie, parseCookieHeader, serializeCookie, setCookie } from \"./cookies.js\";\nexport { defineMessages, detectLocale } from \"./i18n.js\";\nexport { defer, isDeferredLoaderData } from \"./deferred.js\";\nexport type { DeferredLoaderData } from \"./deferred.js\";\nexport { definePage } from \"./types.js\";\nexport { Link, linkProps } from \"./link.js\";\nexport { href } from \"./typed-routes.js\";\nexport { parseMultipartStream } from \"./multipart.js\";\nexport type {\n MultipartFixedLengthStream,\n MultipartStreamFieldOptions,\n MultipartStreamParseOptions,\n MultipartStreamPart,\n} from \"./multipart.js\";\nexport { getNavigationState, subscribeNavigationState } from \"./navigation-state.js\";\nexport { getRouterRuntimeCacheStats } from \"./runtime-cache.js\";\nexport type { HttpUpgradeHandler } from \"./upgrade.js\";\nexport {\n cookies,\n headers,\n html,\n isNotFoundError,\n isRedirectError,\n json,\n next,\n notFound,\n parseForm,\n redirect,\n redirect303,\n redirectExternal,\n rewrite,\n textError,\n throwNotFound,\n} from \"./navigation.js\";\nexport type { ParseSchema } from \"./navigation.js\";\nexport { createMemoryPrerenderStore } from \"./prerender-store.js\";\nexport { getServerRuntimeState } from \"./runtime-state.js\";\nimport {\n createMemorySessionStore as createMemorySessionStoreInternal,\n createSession as createSessionInternal,\n destroySession as destroySessionInternal,\n getSession as getSessionInternal,\n rotateSession as rotateSessionInternal,\n} from \"./session.js\";\nimport type {\n MemorySessionStoreOptions as MemorySessionStoreOptionsInternal,\n SessionCookieOptions as SessionCookieOptionsInternal,\n SessionRecord as SessionRecordInternal,\n SessionStore as SessionStoreInternal,\n} from \"./session.js\";\n\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createMemorySessionStore = createMemorySessionStoreInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createSession = createSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const destroySession = destroySessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const getSession = getSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const rotateSession = rotateSessionInternal;\nexport type {\n AwsLambdaArtifactManifest,\n BuildAppPhase,\n BuildAppPhaseTiming,\n BuildAppOptions,\n BuildAppProgressEvent,\n BuildAppResult,\n BuiltImportPolicyArtifact,\n CloudflarePagesArtifactManifest,\n PackageAwsLambdaArtifactOptions,\n PackageCloudflarePagesArtifactOptions,\n} from \"./build.js\";\nexport type { ServerActionContext } from \"./actions.js\";\nexport type {\n AppRouteHref,\n DynamicHrefOptions,\n RouteParamsFor,\n RouteSearchParams,\n RouteSearchValue,\n StaticHrefOptions,\n} from \"./typed-routes.js\";\nexport type {\n InferLoaderData,\n InferLoaderParams,\n LayoutProps,\n LoaderContext,\n GenerateMetadataContext,\n ManifestContext,\n ManifestDescriptor,\n MetadataImage,\n MetadataScalar,\n MetadataThemeColor,\n MetadataViewport,\n MReactNode,\n PageProps,\n PageComponent,\n RobotsContext,\n RobotsManifest,\n RobotsRule,\n RouteHeadDescriptor,\n RouteHandlerContext,\n RouteLoader,\n RouteMetadata,\n RouteParams,\n RouteSecurityHeaders,\n RouteStrictTransportSecurity,\n SitemapContext,\n SitemapEntry,\n} from \"./types.js\";\nexport type {\n AppRouterBuildTarget,\n AppRouterClientConsoleMethod,\n AppRouterClientSourceMapMode,\n AppRouterClientSourceMapOption,\n AppRouterProductionOptions,\n} from \"./config.js\";\nexport type {\n AssetHelperOptions,\n AssetLinkDescriptor,\n AssetManifest,\n AssetManifestEntry,\n} from \"./assets.js\";\nexport type {\n AppRouterCache,\n AppRouterCacheEntry,\n CacheControlOptions,\n MemoryRouteCacheOptions,\n RouteCachePolicy,\n} from \"./cache.js\";\nexport type { CookieOptions } from \"./cookies.js\";\nexport type { AppRouterImportPolicy } from \"./import-policy.js\";\nexport type {\n LinkChild,\n LinkOptions,\n LinkPrefetch,\n LinkProps,\n LinkScroll,\n LinkTransition,\n TrustedLinkHtml,\n} from \"./link.js\";\nexport type {\n AppRouterNavigationState,\n AppRouterNavigationStateListener,\n AppRouterNavigationType,\n} from \"./navigation-state.js\";\nexport type { RouterRuntimeCacheStat } from \"./runtime-cache.js\";\nexport type { MemorySessionStoreOptionsInternal as MemorySessionStoreOptions };\nexport type {\n AppRouterCspInlineNonceWarningLogEvent,\n AppRouterLogError,\n AppRouterLogEvent,\n AppRouterLogger,\n AppRouterLogLevel,\n AppRouterRuntime,\n AppRouterRequestEndLogEvent,\n AppRouterRequestErrorLogEvent,\n AppRouterRenderTimingLogEvent,\n AppRouterRequestStartLogEvent,\n AppRouterRequestTimingLogEvent,\n} from \"./logger.js\";\nexport type { DetectedLocale, LocaleRoutingOptions, MessageTree } from \"./i18n.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n validateFormCsrf,\n} from \"./csrf.js\";\nexport type {\n AppRouterAllowedServerAction,\n AppRouterServerActionOptions,\n PreparedFormActionReference,\n} from \"./actions.js\";\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionCookieOptions = SessionCookieOptionsInternal;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionRecord<TData = unknown> = SessionRecordInternal<TData>;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionStore<TData = unknown> = SessionStoreInternal<TData>;\nexport { startDevServer } from \"./dev-server.js\";\nexport type { StartDevServerOptions } from \"./dev-server.js\";\nexport { renderAppRequest } from \"./render.js\";\nexport type {\n AppRouterResponseHook,\n AppRouterResponseHookContext,\n RenderAppRequestOptions,\n} from \"./render.js\";\nexport {\n parseTraceContext,\n traceContextFromRequest,\n} from \"./trace.js\";\nexport type {\n RouterInstrumentation,\n RouterMiddlewareEndInstrumentationEvent,\n RouterMiddlewareInstrumentationEvent,\n RouterRequestEndInstrumentationEvent,\n RouterRequestInstrumentationEvent,\n RouterRouteEndInstrumentationEvent,\n RouterRouteInstrumentationEvent,\n RouterTraceContext,\n} from \"./trace.js\";\nexport type {\n FileSystemPrerenderStoreOptions,\n KeyValuePrerenderStoreAdapter,\n KeyValuePrerenderStoreOptions,\n MemoryPrerenderStoreOptions,\n} from \"./prerender-store.js\";\nexport { createFileSystemPrerenderStore, createKeyValuePrerenderStore } from \"./prerender-store.js\";\nexport { preloadBuiltAppRuntime, renderBuiltAppRequest, startServer } from \"./serve.js\";\nexport type {\n BuiltAppRuntimePreloadMode,\n AppRouterPrerenderStore,\n BuiltAppRuntimePreloadStrategy,\n RenderBuiltAppRequestOptions,\n RequestHostPolicy,\n StartServerOptions,\n} from \"./serve.js\";\nexport { matchRoute, scanAppRoutes } from \"./routes.js\";\nexport type { AppFileConvention } from \"./file-conventions.js\";\nexport type {\n AppAssetRoute,\n AppMetadataRoute,\n AppRoute,\n MatchedRoute,\n PageRoute,\n RouteSegment,\n ServerRoute,\n} from \"./routes.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EACL,OAAO,EACP,OAAO,EACP,IAAI,EACJ,eAAe,EACf,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,wBAAwB,IAAI,gCAAgC,EAC5D,aAAa,IAAI,qBAAqB,EACtC,cAAc,IAAI,sBAAsB,EACxC,UAAU,IAAI,kBAAkB,EAChC,aAAa,IAAI,qBAAqB,GACvC,MAAM,cAAc,CAAC;AAQtB;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,gCAAgC,CAAC;AACzE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AACnD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AACrD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AA+GnD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAkBnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAiBpB,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AASxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nexport { assetHref, assetPreloadLinks } from \"./assets.js\";\nexport { cacheControl, createMemoryRouteCache, revalidatePath } from \"./cache.js\";\nexport { deleteCookie, parseCookieHeader, serializeCookie, setCookie } from \"./cookies.js\";\nexport { defineMessages, detectLocale } from \"./i18n.js\";\nexport { defer, isDeferredLoaderData } from \"./deferred.js\";\nexport type { DeferredLoaderData } from \"./deferred.js\";\nexport { definePage } from \"./types.js\";\nexport { Link, linkProps } from \"./link.js\";\nexport { href } from \"./typed-routes.js\";\nexport { parseMultipartStream } from \"./multipart.js\";\nexport type {\n MultipartFixedLengthStream,\n MultipartStreamFieldOptions,\n MultipartStreamParseOptions,\n MultipartStreamPart,\n} from \"./multipart.js\";\nexport { getNavigationState, subscribeNavigationState } from \"./navigation-state.js\";\nexport { getRouterRuntimeCacheStats } from \"./runtime-cache.js\";\nexport type { HttpUpgradeHandler } from \"./upgrade.js\";\nexport {\n cookies,\n headers,\n html,\n isNotFoundError,\n isRedirectError,\n json,\n next,\n notFound,\n parseForm,\n redirect,\n redirect303,\n redirectExternal,\n rewrite,\n textError,\n throwNotFound,\n} from \"./navigation.js\";\nexport type { ParseSchema } from \"./navigation.js\";\nexport { createMemoryPrerenderStore } from \"./prerender-store.js\";\nexport { getServerRuntimeState } from \"./runtime-state.js\";\nimport {\n createMemorySessionStore as createMemorySessionStoreInternal,\n createSession as createSessionInternal,\n destroySession as destroySessionInternal,\n getSession as getSessionInternal,\n rotateSession as rotateSessionInternal,\n} from \"./session.js\";\nimport type {\n MemorySessionStoreOptions as MemorySessionStoreOptionsInternal,\n SessionCookieOptions as SessionCookieOptionsInternal,\n SessionRecord as SessionRecordInternal,\n SessionStore as SessionStoreInternal,\n} from \"./session.js\";\n\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createMemorySessionStore = createMemorySessionStoreInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createSession = createSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const destroySession = destroySessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const getSession = getSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const rotateSession = rotateSessionInternal;\nexport type {\n AwsLambdaArtifactManifest,\n BuildAppPhase,\n BuildAppPhaseTiming,\n BuildAppOptions,\n BuildAppProgressEvent,\n BuildAppResult,\n BuiltImportPolicyArtifact,\n CloudflarePagesArtifactManifest,\n PackageAwsLambdaArtifactOptions,\n PackageCloudflarePagesArtifactOptions,\n} from \"./build.js\";\nexport type { ServerActionContext } from \"./actions.js\";\nexport type {\n AppRouteHref,\n AppRouteLinkHref,\n AppRouteLinkHrefSuffix,\n AppRouteLinkPathname,\n AppRouteLinkSegment,\n AppRouteLinkSegments,\n DynamicHrefOptions,\n RouteParamsFor,\n RouteSearchParams,\n RouteSearchValue,\n StaticHrefOptions,\n} from \"./typed-routes.js\";\nexport type {\n InferLoaderData,\n InferLoaderParams,\n LayoutProps,\n LoaderContext,\n GenerateMetadataContext,\n ManifestContext,\n ManifestDescriptor,\n MetadataImage,\n MetadataScalar,\n MetadataThemeColor,\n MetadataViewport,\n MReactNode,\n PageProps,\n PageComponent,\n RobotsContext,\n RobotsManifest,\n RobotsRule,\n RouteHeadDescriptor,\n RouteHandlerContext,\n RouteLoader,\n RouteMetadata,\n RouteParams,\n RouteSecurityHeaders,\n RouteStrictTransportSecurity,\n SitemapContext,\n SitemapEntry,\n} from \"./types.js\";\nexport type {\n AppRouterBuildTarget,\n AppRouterClientConsoleMethod,\n AppRouterClientSourceMapMode,\n AppRouterClientSourceMapOption,\n AppRouterProductionOptions,\n} from \"./config.js\";\nexport type {\n AssetHelperOptions,\n AssetLinkDescriptor,\n AssetManifest,\n AssetManifestEntry,\n} from \"./assets.js\";\nexport type {\n AppRouterCache,\n AppRouterCacheEntry,\n CacheControlOptions,\n MemoryRouteCacheOptions,\n RouteCachePolicy,\n} from \"./cache.js\";\nexport type { CookieOptions } from \"./cookies.js\";\nexport type { AppRouterImportPolicy } from \"./import-policy.js\";\nexport type {\n AppRouteDeclarations,\n ConcreteLinkHrefGuard,\n LinkChild,\n LinkHref,\n LinkOptions,\n LinkPrefetch,\n LinkProps,\n RegisteredAppRoutePath,\n LinkScroll,\n LinkTransition,\n TrustedLinkHtml,\n} from \"./link.js\";\nexport type {\n AppRouterNavigationState,\n AppRouterNavigationStateListener,\n AppRouterNavigationType,\n} from \"./navigation-state.js\";\nexport type { RouterRuntimeCacheStat } from \"./runtime-cache.js\";\nexport type { MemorySessionStoreOptionsInternal as MemorySessionStoreOptions };\nexport type {\n AppRouterCspInlineNonceWarningLogEvent,\n AppRouterLogError,\n AppRouterLogEvent,\n AppRouterLogger,\n AppRouterLogLevel,\n AppRouterRuntime,\n AppRouterRequestEndLogEvent,\n AppRouterRequestErrorLogEvent,\n AppRouterRenderTimingLogEvent,\n AppRouterRequestStartLogEvent,\n AppRouterRequestTimingLogEvent,\n} from \"./logger.js\";\nexport type { DetectedLocale, LocaleRoutingOptions, MessageTree } from \"./i18n.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n validateFormCsrf,\n} from \"./csrf.js\";\nexport type {\n AppRouterAllowedServerAction,\n AppRouterServerActionOptions,\n PreparedFormActionReference,\n} from \"./actions.js\";\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionCookieOptions = SessionCookieOptionsInternal;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionRecord<TData = unknown> = SessionRecordInternal<TData>;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionStore<TData = unknown> = SessionStoreInternal<TData>;\nexport { startDevServer } from \"./dev-server.js\";\nexport type { StartDevServerOptions } from \"./dev-server.js\";\nexport { renderAppRequest } from \"./render.js\";\nexport type {\n AppRouterResponseHook,\n AppRouterResponseHookContext,\n RenderAppRequestOptions,\n} from \"./render.js\";\nexport {\n parseTraceContext,\n traceContextFromRequest,\n} from \"./trace.js\";\nexport type {\n RouterInstrumentation,\n RouterMiddlewareEndInstrumentationEvent,\n RouterMiddlewareInstrumentationEvent,\n RouterRequestEndInstrumentationEvent,\n RouterRequestInstrumentationEvent,\n RouterRouteEndInstrumentationEvent,\n RouterRouteInstrumentationEvent,\n RouterTraceContext,\n} from \"./trace.js\";\nexport type {\n FileSystemPrerenderStoreOptions,\n KeyValuePrerenderStoreAdapter,\n KeyValuePrerenderStoreOptions,\n MemoryPrerenderStoreOptions,\n} from \"./prerender-store.js\";\nexport { createFileSystemPrerenderStore, createKeyValuePrerenderStore } from \"./prerender-store.js\";\nexport { preloadBuiltAppRuntime, renderBuiltAppRequest, startServer } from \"./serve.js\";\nexport type {\n BuiltAppRuntimePreloadMode,\n AppRouterPrerenderStore,\n BuiltAppRuntimePreloadStrategy,\n RenderBuiltAppRequestOptions,\n RequestHostPolicy,\n StartServerOptions,\n} from \"./serve.js\";\nexport { matchRoute, scanAppRoutes } from \"./routes.js\";\nexport type { AppFileConvention } from \"./file-conventions.js\";\nexport type {\n AppAssetRoute,\n AppMetadataRoute,\n AppRoute,\n MatchedRoute,\n PageRoute,\n RouteSegment,\n ServerRoute,\n} from \"./routes.js\";\n"]}
package/dist/link.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { HtmlSink } from "@reckona/mreact-shared/compiler-contract";
2
2
  import type { ReactCompatElement, ReactCompatNode } from "@reckona/mreact-compat";
3
+ import type { AppRouteLinkHref } from "./typed-routes.js";
4
+ export type { AppRouteLinkHref, AppRouteLinkHrefSuffix, AppRouteLinkPathname, AppRouteLinkSegment, AppRouteLinkSegments, } from "./typed-routes.js";
3
5
  declare const TRUSTED_LINK_HTML: unique symbol;
4
6
  export type LinkPrefetch = "intent" | "viewport" | "none" | false;
5
7
  export type LinkScroll = "top" | "preserve";
@@ -8,19 +10,27 @@ export type TrustedLinkHtml = {
8
10
  readonly [TRUSTED_LINK_HTML]: string;
9
11
  };
10
12
  export type LinkChild = ReactCompatNode | Node | TrustedLinkHtml | readonly LinkChild[];
11
- export interface LinkOptions {
12
- href: string;
13
+ export interface AppRouteDeclarations {
14
+ }
15
+ export type RegisteredAppRoutePath = AppRouteDeclarations extends {
16
+ readonly path: infer Path;
17
+ } ? Extract<Path, `/${string}`> : never;
18
+ export type LinkHref = [RegisteredAppRoutePath] extends [never] ? string : AppRouteLinkHref<RegisteredAppRoutePath>;
19
+ export interface LinkOptions<Href extends string = LinkHref> {
20
+ href: Href;
13
21
  prefetch?: LinkPrefetch | undefined;
14
22
  reload?: boolean | undefined;
15
23
  scroll?: LinkScroll | undefined;
16
24
  transition?: LinkTransition | undefined;
17
25
  }
18
- export interface LinkProps extends LinkOptions {
26
+ export interface LinkProps<Href extends string = LinkHref> extends LinkOptions<Href> {
19
27
  children?: LinkChild;
20
28
  [attribute: string]: unknown;
21
29
  }
22
- export declare function linkProps(options: LinkOptions): Record<string, string>;
23
- export declare function Link(props: LinkProps): ReactCompatElement;
24
- export declare function Link(sink: HtmlSink, props: LinkProps): void;
25
- export {};
30
+ export declare function linkProps(options: LinkOptions<string>): Record<string, string>;
31
+ export type ConcreteLinkHrefGuard<Href extends string> = [RegisteredAppRoutePath] extends [never] ? unknown : Href extends Extract<RegisteredAppRoutePath, `${string}:${string}`> ? {
32
+ readonly __mreactRoutePatternHrefError__: never;
33
+ } : unknown;
34
+ export declare function Link<const Href extends LinkHref>(props: LinkProps<Href> & ConcreteLinkHrefGuard<Href>): ReactCompatElement;
35
+ export declare function Link(sink: HtmlSink, props: LinkProps<string>): void;
26
36
  //# sourceMappingURL=link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGlF,QAAA,MAAM,iBAAiB,eAAuD,CAAC;AAE/E,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;AACl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AAC;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,iBAAiB,IAAI,KAAK;QAC1B,OAAQ,KAAyB,CAAC,iBAAiB,CAAC,KAAK,QAAQ,CAClE,CAAC;AACJ,CAAC","sourcesContent":["import { escapeHtmlAttribute, escapeHtmlText } from \"@reckona/mreact-shared/html-escape\";\nimport type { HtmlSink } from \"@reckona/mreact-shared/compiler-contract\";\nimport type { ReactCompatElement, ReactCompatNode } from \"@reckona/mreact-compat\";\nimport { safeUrlAttributeValue } from \"@reckona/mreact-shared/url-safety\";\n\nconst TRUSTED_LINK_HTML = Symbol.for(\"modular.react.router.trusted_link_html\");\n\nexport type LinkPrefetch = \"intent\" | \"viewport\" | \"none\" | false;\nexport type LinkScroll = \"top\" | \"preserve\";\nexport type LinkTransition = \"auto\" | \"none\" | false;\nexport type TrustedLinkHtml = { readonly [TRUSTED_LINK_HTML]: string };\nexport type LinkChild = ReactCompatNode | Node | TrustedLinkHtml | readonly LinkChild[];\n\nexport interface LinkOptions {\n href: string;\n prefetch?: LinkPrefetch | undefined;\n reload?: boolean | undefined;\n scroll?: LinkScroll | undefined;\n transition?: LinkTransition | undefined;\n}\n\nexport interface LinkProps extends LinkOptions {\n children?: LinkChild;\n [attribute: string]: unknown;\n}\n\nexport function linkProps(options: LinkOptions): Record<string, string> {\n return {\n href: options.href,\n ...(options.prefetch === undefined || options.prefetch === \"intent\"\n ? {}\n : { \"data-mreact-prefetch\": options.prefetch === false ? \"none\" : options.prefetch }),\n ...(options.reload === true ? { \"data-mreact-reload\": \"true\" } : {}),\n ...(options.scroll === undefined || options.scroll === \"top\"\n ? {}\n : { \"data-mreact-scroll\": options.scroll }),\n ...(options.transition === undefined || options.transition === false || options.transition === \"none\"\n ? {}\n : { \"data-mreact-transition\": options.transition }),\n };\n}\n\nexport function Link(props: LinkProps): ReactCompatElement;\nexport function Link(sink: HtmlSink, props: LinkProps): void;\nexport function Link(\n sinkOrProps: HtmlSink | LinkProps,\n maybeProps?: LinkProps,\n): ReactCompatElement | string | HTMLAnchorElement | void {\n if (maybeProps !== undefined) {\n (sinkOrProps as HtmlSink).append(renderLinkString(maybeProps));\n return;\n }\n\n return renderLink(sinkOrProps as LinkProps);\n}\n\n(Link as typeof Link & { trustedHtml(html: string): TrustedLinkHtml }).trustedHtml = (\n html: string,\n): TrustedLinkHtml => ({\n [TRUSTED_LINK_HTML]: html,\n});\n\nfunction renderLink(props: LinkProps): string | HTMLAnchorElement {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n const propsWithLinkAttrs = {\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n };\n\n if (typeof document !== \"undefined\" && typeof document.createElement === \"function\") {\n return createAnchorElement(propsWithLinkAttrs);\n }\n\n return renderAnchorString(propsWithLinkAttrs);\n}\n\nfunction renderLinkString(props: LinkProps): string {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n\n return renderAnchorString({\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n });\n}\n\nfunction createAnchorElement(props: Record<string, unknown>): HTMLAnchorElement {\n const anchor = document.createElement(\"a\");\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\") {\n appendLinkChild(anchor, value as LinkChild);\n continue;\n }\n\n if (!shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const safeValue = safeUrlAttributeValue(attrName, String(value));\n\n if (safeValue === undefined) {\n continue;\n }\n\n anchor.setAttribute(attrName, safeValue);\n }\n\n return anchor;\n}\n\nfunction appendLinkChild(parent: Node, child: LinkChild): void {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return;\n }\n\n if (Array.isArray(child)) {\n for (const item of child) {\n appendLinkChild(parent, item);\n }\n return;\n }\n\n if (child instanceof Node) {\n parent.appendChild(child);\n return;\n }\n\n parent.appendChild(document.createTextNode(String(child)));\n}\n\nfunction renderAnchorString(props: Record<string, unknown>): string {\n return `<a${renderAnchorAttributes(props)}>${renderChildren(props.children as LinkChild)}</a>`;\n}\n\nfunction renderAnchorAttributes(props: Record<string, unknown>): string {\n const attrs: string[] = [];\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\" || !shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const attrValue = String(value);\n const safeValue = safeUrlAttributeValue(attrName, attrValue);\n\n if (safeValue === undefined) {\n continue;\n }\n\n attrs.push(`${escapeHtmlAttribute(attrName)}=\"${escapeHtmlAttribute(safeValue)}\"`);\n }\n\n return attrs.length === 0 ? \"\" : ` ${attrs.join(\" \")}`;\n}\n\nfunction shouldSetAttribute(name: string, value: unknown): boolean {\n return (\n name !== \"key\" &&\n name !== \"ref\" &&\n value !== null &&\n value !== undefined &&\n value !== false &&\n typeof value !== \"function\" &&\n typeof value !== \"symbol\"\n );\n}\n\nfunction attributeName(name: string): string {\n return name === \"className\" ? \"class\" : name;\n}\n\nfunction renderChildren(child: LinkChild): string {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return \"\";\n }\n\n if (Array.isArray(child)) {\n return child.map(renderChildren).join(\"\");\n }\n\n if (isTrustedLinkHtml(child)) {\n return child[TRUSTED_LINK_HTML];\n }\n\n return escapeHtmlText(child);\n}\n\nfunction isTrustedLinkHtml(value: unknown): value is TrustedLinkHtml {\n return (\n typeof value === \"object\" &&\n value !== null &&\n TRUSTED_LINK_HTML in value &&\n typeof (value as TrustedLinkHtml)[TRUSTED_LINK_HTML] === \"string\"\n );\n}\n"]}
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAU1E,MAAM,iBAAiB,GAAG,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AC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,iBAAiB,IAAI,KAAK;QAC1B,OAAQ,KAAyB,CAAC,iBAAiB,CAAC,KAAK,QAAQ,CAClE,CAAC;AACJ,CAAC","sourcesContent":["import { escapeHtmlAttribute, escapeHtmlText } from \"@reckona/mreact-shared/html-escape\";\nimport type { HtmlSink } from \"@reckona/mreact-shared/compiler-contract\";\nimport type { ReactCompatElement, ReactCompatNode } from \"@reckona/mreact-compat\";\nimport { safeUrlAttributeValue } from \"@reckona/mreact-shared/url-safety\";\nimport type { AppRouteLinkHref } from \"./typed-routes.js\";\nexport type {\n AppRouteLinkHref,\n AppRouteLinkHrefSuffix,\n AppRouteLinkPathname,\n AppRouteLinkSegment,\n AppRouteLinkSegments,\n} from \"./typed-routes.js\";\n\nconst TRUSTED_LINK_HTML = Symbol.for(\"modular.react.router.trusted_link_html\");\n\nexport type LinkPrefetch = \"intent\" | \"viewport\" | \"none\" | false;\nexport type LinkScroll = \"top\" | \"preserve\";\nexport type LinkTransition = \"auto\" | \"none\" | false;\nexport type TrustedLinkHtml = { readonly [TRUSTED_LINK_HTML]: string };\nexport type LinkChild = ReactCompatNode | Node | TrustedLinkHtml | readonly LinkChild[];\nexport interface AppRouteDeclarations {}\nexport type RegisteredAppRoutePath = AppRouteDeclarations extends { readonly path: infer Path }\n ? Extract<Path, `/${string}`>\n : never;\nexport type LinkHref = [RegisteredAppRoutePath] extends [never]\n ? string\n : AppRouteLinkHref<RegisteredAppRoutePath>;\n\nexport interface LinkOptions<Href extends string = LinkHref> {\n href: Href;\n prefetch?: LinkPrefetch | undefined;\n reload?: boolean | undefined;\n scroll?: LinkScroll | undefined;\n transition?: LinkTransition | undefined;\n}\n\nexport interface LinkProps<Href extends string = LinkHref> extends LinkOptions<Href> {\n children?: LinkChild;\n [attribute: string]: unknown;\n}\n\nexport function linkProps(options: LinkOptions<string>): Record<string, string> {\n return {\n href: options.href,\n ...(options.prefetch === undefined || options.prefetch === \"intent\"\n ? {}\n : { \"data-mreact-prefetch\": options.prefetch === false ? \"none\" : options.prefetch }),\n ...(options.reload === true ? { \"data-mreact-reload\": \"true\" } : {}),\n ...(options.scroll === undefined || options.scroll === \"top\"\n ? {}\n : { \"data-mreact-scroll\": options.scroll }),\n ...(options.transition === undefined || options.transition === false || options.transition === \"none\"\n ? {}\n : { \"data-mreact-transition\": options.transition }),\n };\n}\n\nexport type ConcreteLinkHrefGuard<Href extends string> = [RegisteredAppRoutePath] extends [never]\n ? unknown\n : Href extends Extract<RegisteredAppRoutePath, `${string}:${string}`>\n ? { readonly __mreactRoutePatternHrefError__: never }\n : unknown;\n\nexport function Link<const Href extends LinkHref>(\n props: LinkProps<Href> & ConcreteLinkHrefGuard<Href>,\n): ReactCompatElement;\nexport function Link(sink: HtmlSink, props: LinkProps<string>): void;\nexport function Link(\n sinkOrProps: HtmlSink | LinkProps<string>,\n maybeProps?: LinkProps<string>,\n): ReactCompatElement | string | HTMLAnchorElement | void {\n if (maybeProps !== undefined) {\n (sinkOrProps as HtmlSink).append(renderLinkString(maybeProps));\n return;\n }\n\n return renderLink(sinkOrProps as LinkProps);\n}\n\n(Link as typeof Link & { trustedHtml(html: string): TrustedLinkHtml }).trustedHtml = (\n html: string,\n): TrustedLinkHtml => ({\n [TRUSTED_LINK_HTML]: html,\n});\n\nfunction renderLink(props: LinkProps<string>): string | HTMLAnchorElement {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n const propsWithLinkAttrs = {\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n };\n\n if (typeof document !== \"undefined\" && typeof document.createElement === \"function\") {\n return createAnchorElement(propsWithLinkAttrs);\n }\n\n return renderAnchorString(propsWithLinkAttrs);\n}\n\nfunction renderLinkString(props: LinkProps<string>): string {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n\n return renderAnchorString({\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n });\n}\n\nfunction createAnchorElement(props: Record<string, unknown>): HTMLAnchorElement {\n const anchor = document.createElement(\"a\");\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\") {\n appendLinkChild(anchor, value as LinkChild);\n continue;\n }\n\n if (!shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const safeValue = safeUrlAttributeValue(attrName, String(value));\n\n if (safeValue === undefined) {\n continue;\n }\n\n anchor.setAttribute(attrName, safeValue);\n }\n\n return anchor;\n}\n\nfunction appendLinkChild(parent: Node, child: LinkChild): void {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return;\n }\n\n if (Array.isArray(child)) {\n for (const item of child) {\n appendLinkChild(parent, item);\n }\n return;\n }\n\n if (child instanceof Node) {\n parent.appendChild(child);\n return;\n }\n\n parent.appendChild(document.createTextNode(String(child)));\n}\n\nfunction renderAnchorString(props: Record<string, unknown>): string {\n return `<a${renderAnchorAttributes(props)}>${renderChildren(props.children as LinkChild)}</a>`;\n}\n\nfunction renderAnchorAttributes(props: Record<string, unknown>): string {\n const attrs: string[] = [];\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\" || !shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const attrValue = String(value);\n const safeValue = safeUrlAttributeValue(attrName, attrValue);\n\n if (safeValue === undefined) {\n continue;\n }\n\n attrs.push(`${escapeHtmlAttribute(attrName)}=\"${escapeHtmlAttribute(safeValue)}\"`);\n }\n\n return attrs.length === 0 ? \"\" : ` ${attrs.join(\" \")}`;\n}\n\nfunction shouldSetAttribute(name: string, value: unknown): boolean {\n return (\n name !== \"key\" &&\n name !== \"ref\" &&\n value !== null &&\n value !== undefined &&\n value !== false &&\n typeof value !== \"function\" &&\n typeof value !== \"symbol\"\n );\n}\n\nfunction attributeName(name: string): string {\n return name === \"className\" ? \"class\" : name;\n}\n\nfunction renderChildren(child: LinkChild): string {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return \"\";\n }\n\n if (Array.isArray(child)) {\n return child.map(renderChildren).join(\"\");\n }\n\n if (isTrustedLinkHtml(child)) {\n return child[TRUSTED_LINK_HTML];\n }\n\n return escapeHtmlText(child);\n}\n\nfunction isTrustedLinkHtml(value: unknown): value is TrustedLinkHtml {\n return (\n typeof value === \"object\" &&\n value !== null &&\n TRUSTED_LINK_HTML in value &&\n typeof (value as TrustedLinkHtml)[TRUSTED_LINK_HTML] === \"string\"\n );\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  export type RouteSearchValue = boolean | number | string | null | undefined;
2
2
  export type RouteSearchParams = Record<string, RouteSearchValue | readonly RouteSearchValue[]>;
3
3
  export type RouteParamsFor<Path extends `/${string}`> = Simplify<ExtractRouteParams<Path>>;
4
- export type AppRouteHref<Path extends `/${string}`> = HasRouteParams<Path> extends true ? (options: DynamicHrefOptions<Path>) => string : (options?: StaticHrefOptions) => string;
4
+ export type AppRouteHref<Path extends `/${string}`> = keyof RouteParamsFor<Path> extends never ? (options?: StaticHrefOptions) => string : (options: DynamicHrefOptions<Path>) => string;
5
+ export type AppRouteLinkHref<Path extends `/${string}`> = `${AppRouteLinkPathname<Path>}${AppRouteLinkHrefSuffix}`;
5
6
  export interface StaticHrefOptions {
6
7
  hash?: string | undefined;
7
8
  search?: RouteSearchParams | undefined;
@@ -19,6 +20,10 @@ type SegmentRouteParam<Segment extends string> = Segment extends `:...${infer Na
19
20
  type Simplify<T> = {
20
21
  [Key in keyof T]: T[Key];
21
22
  } & {};
23
+ export type AppRouteLinkHrefSuffix = "" | `?${string}` | `#${string}` | `?${string}#${string}`;
24
+ export type AppRouteLinkPathname<Path extends `/${string}`> = Path extends "/" ? "/" : Path extends `/${infer Segments}` ? `/${AppRouteLinkSegments<Segments>}` : never;
25
+ export type AppRouteLinkSegments<Segments extends string> = Segments extends `${infer Segment}/${infer Rest}` ? `${AppRouteLinkSegment<Segment>}/${AppRouteLinkSegments<Rest>}` : AppRouteLinkSegment<Segments>;
26
+ export type AppRouteLinkSegment<Segment extends string> = Segment extends `:${string}` ? string : Segment;
22
27
  export declare function href<const Path extends `/${string}`>(path: Path, ...args: HasRouteParams<Path> extends true ? [options: DynamicHrefOptions<Path>] : [options?: StaticHrefOptions]): string;
23
28
  export {};
24
29
  //# sourceMappingURL=typed-routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typed-routes.d.ts","sourceRoot":"","sources":["../src/typed-routes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAC5E,MAAM,MAAM,iBAAiB,GAAG,MAAM,CACpC,MAAM,EACN,gBAAgB,GAAG,SAAS,gBAAgB,EAAE,CAC/C,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,IAAI,MAAM,EAAE,IAAI,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;AAE3F,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,IAAI,MAAM,EAAE,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,IAAI,GACnF,CAAC,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,MAAM,GAC7C,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,MAAM,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAA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AC;QAEpC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,MAAqC;IACzD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IAErC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAEtD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAEhC,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC;AACzC,CAAC","sourcesContent":["export type RouteSearchValue = boolean | number | string | null | undefined;\nexport type RouteSearchParams = Record<\n string,\n RouteSearchValue | readonly RouteSearchValue[]\n>;\n\nexport type RouteParamsFor<Path extends `/${string}`> = Simplify<ExtractRouteParams<Path>>;\n\nexport type AppRouteHref<Path extends `/${string}`> = HasRouteParams<Path> extends true\n ? (options: DynamicHrefOptions<Path>) => string\n : (options?: StaticHrefOptions) => string;\n\nexport interface StaticHrefOptions {\n hash?: string | undefined;\n search?: RouteSearchParams | undefined;\n}\n\nexport interface DynamicHrefOptions<Path extends `/${string}`> extends StaticHrefOptions {\n params: RouteParamsFor<Path>;\n}\n\ntype HasRouteParams<Path extends `/${string}`> = keyof RouteParamsFor<Path> extends never\n ? false\n : true;\n\ntype ExtractRouteParams<Path extends string> = Path extends `${infer Segment}/${infer Rest}`\n ? SegmentRouteParam<Segment> & ExtractRouteParams<Rest>\n : SegmentRouteParam<Path>;\n\ntype SegmentRouteParam<Segment extends string> = Segment extends `:...${infer Name}`\n ? { [Key in Name]: readonly string[] }\n : Segment extends `:${infer Name}`\n ? { [Key in Name]: string }\n : Record<never, never>;\n\ntype Simplify<T> = { [Key in keyof T]: T[Key] } & {};\n\nexport function href<const Path extends `/${string}`>(\n path: Path,\n ...args: HasRouteParams<Path> extends true\n ? [options: DynamicHrefOptions<Path>]\n : [options?: StaticHrefOptions]\n): string {\n assertInternalRoutePath(path);\n\n const options = args[0] as\n | (StaticHrefOptions & { params?: Record<string, readonly string[] | string> | undefined })\n | undefined;\n const params =\n options !== undefined && \"params\" in options && options.params !== undefined\n ? (options.params as Record<string, readonly string[] | string>)\n : {};\n const pathname = path\n .split(\"/\")\n .map((segment) => {\n if (segment.startsWith(\":...\")) {\n const name = segment.slice(4);\n const value = params[name];\n\n if (!Array.isArray(value)) {\n throw new Error(`Missing catch-all route param ${JSON.stringify(name)} for ${path}.`);\n }\n\n return value.map((part) => encodeURIComponent(part)).join(\"/\");\n }\n\n if (segment.startsWith(\":\")) {\n const name = segment.slice(1);\n const value = params[name];\n\n if (typeof value !== \"string\") {\n throw new Error(`Missing route param ${JSON.stringify(name)} for ${path}.`);\n }\n\n return encodeURIComponent(value);\n }\n\n return segment;\n })\n .join(\"/\");\n const search = searchString(options?.search);\n const hash = options?.hash === undefined ? \"\" : `#${encodeURIComponent(options.hash)}`;\n\n return `${pathname}${search}${hash}`;\n}\n\nfunction assertInternalRoutePath(path: string): void {\n if (!path.startsWith(\"/\") || path.startsWith(\"//\")) {\n throw new Error(`href() expected an internal route path, received ${JSON.stringify(path)}.`);\n }\n\n for (let index = 0; index < path.length; index += 1) {\n const code = path.charCodeAt(index);\n\n if (code <= 0x1f || code === 0x7f) {\n throw new Error(\"href() route paths must not contain control characters.\");\n }\n }\n}\n\nfunction searchString(search: RouteSearchParams | undefined): string {\n if (search === undefined) {\n return \"\";\n }\n\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(search)) {\n const values = Array.isArray(value) ? value : [value];\n\n for (const entry of values) {\n if (entry !== undefined && entry !== null) {\n params.append(key, String(entry));\n }\n }\n }\n\n const value = params.toString();\n\n return value === \"\" ? \"\" : `?${value}`;\n}\n"]}
1
+ {"version":3,"file":"typed-routes.js","sourceRoot":"","sources":["../src/typed-routes.ts"],"names":[],"mappings":"AAwDA,MAAM,UAAU,IAAI,CAClB,IAAU,EACV,GAAG,IAE8B;IAEjC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAET,CAAC;IACd,MAAM,MAAM,GACV,OAAO,KAAK,SAAS,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAC1E,CAAC,CAAE,OAAO,CAAC,MAAqD;QAChE,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,QAAQ,GAAG,IAAI;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAE3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC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KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,MAAqC;IACzD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IAErC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAEtD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAEhC,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC;AACzC,CAAC","sourcesContent":["export type RouteSearchValue = boolean | number | string | null | undefined;\nexport type RouteSearchParams = Record<\n string,\n RouteSearchValue | readonly RouteSearchValue[]\n>;\n\nexport type RouteParamsFor<Path extends `/${string}`> = Simplify<ExtractRouteParams<Path>>;\n\nexport type AppRouteHref<Path extends `/${string}`> = keyof RouteParamsFor<Path> extends never\n ? (options?: StaticHrefOptions) => string\n : (options: DynamicHrefOptions<Path>) => string;\n\nexport type AppRouteLinkHref<Path extends `/${string}`> =\n `${AppRouteLinkPathname<Path>}${AppRouteLinkHrefSuffix}`;\n\nexport interface StaticHrefOptions {\n hash?: string | undefined;\n search?: RouteSearchParams | undefined;\n}\n\nexport interface DynamicHrefOptions<Path extends `/${string}`> extends StaticHrefOptions {\n params: RouteParamsFor<Path>;\n}\n\ntype HasRouteParams<Path extends `/${string}`> = keyof RouteParamsFor<Path> extends never\n ? false\n : true;\n\ntype ExtractRouteParams<Path extends string> = Path extends `${infer Segment}/${infer Rest}`\n ? SegmentRouteParam<Segment> & ExtractRouteParams<Rest>\n : SegmentRouteParam<Path>;\n\ntype SegmentRouteParam<Segment extends string> = Segment extends `:...${infer Name}`\n ? { [Key in Name]: readonly string[] }\n : Segment extends `:${infer Name}`\n ? { [Key in Name]: string }\n : Record<never, never>;\n\ntype Simplify<T> = { [Key in keyof T]: T[Key] } & {};\n\nexport type AppRouteLinkHrefSuffix = \"\" | `?${string}` | `#${string}` | `?${string}#${string}`;\n\nexport type AppRouteLinkPathname<Path extends `/${string}`> = Path extends \"/\"\n ? \"/\"\n : Path extends `/${infer Segments}`\n ? `/${AppRouteLinkSegments<Segments>}`\n : never;\n\nexport type AppRouteLinkSegments<Segments extends string> = Segments extends `${infer Segment}/${infer Rest}`\n ? `${AppRouteLinkSegment<Segment>}/${AppRouteLinkSegments<Rest>}`\n : AppRouteLinkSegment<Segments>;\n\nexport type AppRouteLinkSegment<Segment extends string> = Segment extends `:${string}`\n ? string\n : Segment;\n\nexport function href<const Path extends `/${string}`>(\n path: Path,\n ...args: HasRouteParams<Path> extends true\n ? [options: DynamicHrefOptions<Path>]\n : [options?: StaticHrefOptions]\n): string {\n assertInternalRoutePath(path);\n\n const options = args[0] as\n | (StaticHrefOptions & { params?: Record<string, readonly string[] | string> | undefined })\n | undefined;\n const params =\n options !== undefined && \"params\" in options && options.params !== undefined\n ? (options.params as Record<string, readonly string[] | string>)\n : {};\n const pathname = path\n .split(\"/\")\n .map((segment) => {\n if (segment.startsWith(\":...\")) {\n const name = segment.slice(4);\n const value = params[name];\n\n if (!Array.isArray(value)) {\n throw new Error(`Missing catch-all route param ${JSON.stringify(name)} for ${path}.`);\n }\n\n return value.map((part) => encodeURIComponent(part)).join(\"/\");\n }\n\n if (segment.startsWith(\":\")) {\n const name = segment.slice(1);\n const value = params[name];\n\n if (typeof value !== \"string\") {\n throw new Error(`Missing route param ${JSON.stringify(name)} for ${path}.`);\n }\n\n return encodeURIComponent(value);\n }\n\n return segment;\n })\n .join(\"/\");\n const search = searchString(options?.search);\n const hash = options?.hash === undefined ? \"\" : `#${encodeURIComponent(options.hash)}`;\n\n return `${pathname}${search}${hash}`;\n}\n\nfunction assertInternalRoutePath(path: string): void {\n if (!path.startsWith(\"/\") || path.startsWith(\"//\")) {\n throw new Error(`href() expected an internal route path, received ${JSON.stringify(path)}.`);\n }\n\n for (let index = 0; index < path.length; index += 1) {\n const code = path.charCodeAt(index);\n\n if (code <= 0x1f || code === 0x7f) {\n throw new Error(\"href() route paths must not contain control characters.\");\n }\n }\n}\n\nfunction searchString(search: RouteSearchParams | undefined): string {\n if (search === undefined) {\n return \"\";\n }\n\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(search)) {\n const values = Array.isArray(value) ? value : [value];\n\n for (const entry of values) {\n if (entry !== undefined && entry !== null) {\n params.append(key, String(entry));\n }\n }\n }\n\n const value = params.toString();\n\n return value === \"\" ? \"\" : `?${value}`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-router",
3
- "version": "0.0.150",
3
+ "version": "0.0.151",
4
4
  "description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
5
5
  "keywords": [
6
6
  "jsx",
@@ -105,20 +105,20 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "typescript": "^6.0.3",
108
- "@reckona/mreact": "0.0.150",
109
- "@reckona/mreact-compiler": "0.0.150",
110
- "@reckona/mreact-devtools": "0.0.150",
111
- "@reckona/mreact-query": "0.0.150",
112
- "@reckona/mreact-reactive-core": "0.0.150",
113
- "@reckona/mreact-compat": "0.0.150",
114
- "@reckona/mreact-reactive-dom": "0.0.150",
115
- "@reckona/mreact-server": "0.0.150",
116
- "@reckona/mreact-shared": "0.0.150"
108
+ "@reckona/mreact": "0.0.151",
109
+ "@reckona/mreact-compat": "0.0.151",
110
+ "@reckona/mreact-devtools": "0.0.151",
111
+ "@reckona/mreact-reactive-core": "0.0.151",
112
+ "@reckona/mreact-query": "0.0.151",
113
+ "@reckona/mreact-compiler": "0.0.151",
114
+ "@reckona/mreact-reactive-dom": "0.0.151",
115
+ "@reckona/mreact-shared": "0.0.151",
116
+ "@reckona/mreact-server": "0.0.151"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "vite": ">=8 <9"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@reckona/mreact-router-native": "0.0.150"
122
+ "@reckona/mreact-router-native": "0.0.151"
123
123
  }
124
124
  }
package/src/build.ts CHANGED
@@ -744,17 +744,17 @@ function typedRoutesDeclaration(routes: readonly AppRoute[]): string {
744
744
  return left.localeCompare(right);
745
745
  });
746
746
  const routeUnion = routePaths.map((routePath) => JSON.stringify(routePath)).join(" | ");
747
- const routesObject = routePaths
748
- .map((routePath) => ` readonly ${JSON.stringify(routePath)}: AppRouteHref<${JSON.stringify(routePath)}>;`)
749
- .join("\n");
750
-
751
747
  return [
752
- `import type { AppRouteHref } from "@reckona/mreact-router";`,
748
+ `import type { AppRouteLinkHref as MreactAppRouteLinkHref } from "@reckona/mreact-router";`,
753
749
  ``,
754
750
  `export type AppRoutePath = ${routeUnion === "" ? "never" : routeUnion};`,
755
- `export declare const routes: {`,
756
- routesObject,
757
- `};`,
751
+ `export type AppRouteHref = MreactAppRouteLinkHref<AppRoutePath>;`,
752
+ ``,
753
+ `declare module "@reckona/mreact-router/link" {`,
754
+ ` interface AppRouteDeclarations {`,
755
+ ` readonly path: AppRoutePath;`,
756
+ ` }`,
757
+ `}`,
758
758
  ``,
759
759
  ].join("\n");
760
760
  }
package/src/index.ts CHANGED
@@ -87,6 +87,11 @@ export type {
87
87
  export type { ServerActionContext } from "./actions.js";
88
88
  export type {
89
89
  AppRouteHref,
90
+ AppRouteLinkHref,
91
+ AppRouteLinkHrefSuffix,
92
+ AppRouteLinkPathname,
93
+ AppRouteLinkSegment,
94
+ AppRouteLinkSegments,
90
95
  DynamicHrefOptions,
91
96
  RouteParamsFor,
92
97
  RouteSearchParams,
@@ -144,10 +149,14 @@ export type {
144
149
  export type { CookieOptions } from "./cookies.js";
145
150
  export type { AppRouterImportPolicy } from "./import-policy.js";
146
151
  export type {
152
+ AppRouteDeclarations,
153
+ ConcreteLinkHrefGuard,
147
154
  LinkChild,
155
+ LinkHref,
148
156
  LinkOptions,
149
157
  LinkPrefetch,
150
158
  LinkProps,
159
+ RegisteredAppRoutePath,
151
160
  LinkScroll,
152
161
  LinkTransition,
153
162
  TrustedLinkHtml,
package/src/link.ts CHANGED
@@ -2,6 +2,14 @@ import { escapeHtmlAttribute, escapeHtmlText } from "@reckona/mreact-shared/html
2
2
  import type { HtmlSink } from "@reckona/mreact-shared/compiler-contract";
3
3
  import type { ReactCompatElement, ReactCompatNode } from "@reckona/mreact-compat";
4
4
  import { safeUrlAttributeValue } from "@reckona/mreact-shared/url-safety";
5
+ import type { AppRouteLinkHref } from "./typed-routes.js";
6
+ export type {
7
+ AppRouteLinkHref,
8
+ AppRouteLinkHrefSuffix,
9
+ AppRouteLinkPathname,
10
+ AppRouteLinkSegment,
11
+ AppRouteLinkSegments,
12
+ } from "./typed-routes.js";
5
13
 
6
14
  const TRUSTED_LINK_HTML = Symbol.for("modular.react.router.trusted_link_html");
7
15
 
@@ -10,21 +18,28 @@ export type LinkScroll = "top" | "preserve";
10
18
  export type LinkTransition = "auto" | "none" | false;
11
19
  export type TrustedLinkHtml = { readonly [TRUSTED_LINK_HTML]: string };
12
20
  export type LinkChild = ReactCompatNode | Node | TrustedLinkHtml | readonly LinkChild[];
13
-
14
- export interface LinkOptions {
15
- href: string;
21
+ export interface AppRouteDeclarations {}
22
+ export type RegisteredAppRoutePath = AppRouteDeclarations extends { readonly path: infer Path }
23
+ ? Extract<Path, `/${string}`>
24
+ : never;
25
+ export type LinkHref = [RegisteredAppRoutePath] extends [never]
26
+ ? string
27
+ : AppRouteLinkHref<RegisteredAppRoutePath>;
28
+
29
+ export interface LinkOptions<Href extends string = LinkHref> {
30
+ href: Href;
16
31
  prefetch?: LinkPrefetch | undefined;
17
32
  reload?: boolean | undefined;
18
33
  scroll?: LinkScroll | undefined;
19
34
  transition?: LinkTransition | undefined;
20
35
  }
21
36
 
22
- export interface LinkProps extends LinkOptions {
37
+ export interface LinkProps<Href extends string = LinkHref> extends LinkOptions<Href> {
23
38
  children?: LinkChild;
24
39
  [attribute: string]: unknown;
25
40
  }
26
41
 
27
- export function linkProps(options: LinkOptions): Record<string, string> {
42
+ export function linkProps(options: LinkOptions<string>): Record<string, string> {
28
43
  return {
29
44
  href: options.href,
30
45
  ...(options.prefetch === undefined || options.prefetch === "intent"
@@ -40,11 +55,19 @@ export function linkProps(options: LinkOptions): Record<string, string> {
40
55
  };
41
56
  }
42
57
 
43
- export function Link(props: LinkProps): ReactCompatElement;
44
- export function Link(sink: HtmlSink, props: LinkProps): void;
58
+ export type ConcreteLinkHrefGuard<Href extends string> = [RegisteredAppRoutePath] extends [never]
59
+ ? unknown
60
+ : Href extends Extract<RegisteredAppRoutePath, `${string}:${string}`>
61
+ ? { readonly __mreactRoutePatternHrefError__: never }
62
+ : unknown;
63
+
64
+ export function Link<const Href extends LinkHref>(
65
+ props: LinkProps<Href> & ConcreteLinkHrefGuard<Href>,
66
+ ): ReactCompatElement;
67
+ export function Link(sink: HtmlSink, props: LinkProps<string>): void;
45
68
  export function Link(
46
- sinkOrProps: HtmlSink | LinkProps,
47
- maybeProps?: LinkProps,
69
+ sinkOrProps: HtmlSink | LinkProps<string>,
70
+ maybeProps?: LinkProps<string>,
48
71
  ): ReactCompatElement | string | HTMLAnchorElement | void {
49
72
  if (maybeProps !== undefined) {
50
73
  (sinkOrProps as HtmlSink).append(renderLinkString(maybeProps));
@@ -60,7 +83,7 @@ export function Link(
60
83
  [TRUSTED_LINK_HTML]: html,
61
84
  });
62
85
 
63
- function renderLink(props: LinkProps): string | HTMLAnchorElement {
86
+ function renderLink(props: LinkProps<string>): string | HTMLAnchorElement {
64
87
  const { href, prefetch, reload, scroll, transition, ...rest } = props;
65
88
  const propsWithLinkAttrs = {
66
89
  ...rest,
@@ -74,7 +97,7 @@ function renderLink(props: LinkProps): string | HTMLAnchorElement {
74
97
  return renderAnchorString(propsWithLinkAttrs);
75
98
  }
76
99
 
77
- function renderLinkString(props: LinkProps): string {
100
+ function renderLinkString(props: LinkProps<string>): string {
78
101
  const { href, prefetch, reload, scroll, transition, ...rest } = props;
79
102
 
80
103
  return renderAnchorString({
@@ -6,9 +6,12 @@ export type RouteSearchParams = Record<
6
6
 
7
7
  export type RouteParamsFor<Path extends `/${string}`> = Simplify<ExtractRouteParams<Path>>;
8
8
 
9
- export type AppRouteHref<Path extends `/${string}`> = HasRouteParams<Path> extends true
10
- ? (options: DynamicHrefOptions<Path>) => string
11
- : (options?: StaticHrefOptions) => string;
9
+ export type AppRouteHref<Path extends `/${string}`> = keyof RouteParamsFor<Path> extends never
10
+ ? (options?: StaticHrefOptions) => string
11
+ : (options: DynamicHrefOptions<Path>) => string;
12
+
13
+ export type AppRouteLinkHref<Path extends `/${string}`> =
14
+ `${AppRouteLinkPathname<Path>}${AppRouteLinkHrefSuffix}`;
12
15
 
13
16
  export interface StaticHrefOptions {
14
17
  hash?: string | undefined;
@@ -35,6 +38,22 @@ type SegmentRouteParam<Segment extends string> = Segment extends `:...${infer Na
35
38
 
36
39
  type Simplify<T> = { [Key in keyof T]: T[Key] } & {};
37
40
 
41
+ export type AppRouteLinkHrefSuffix = "" | `?${string}` | `#${string}` | `?${string}#${string}`;
42
+
43
+ export type AppRouteLinkPathname<Path extends `/${string}`> = Path extends "/"
44
+ ? "/"
45
+ : Path extends `/${infer Segments}`
46
+ ? `/${AppRouteLinkSegments<Segments>}`
47
+ : never;
48
+
49
+ export type AppRouteLinkSegments<Segments extends string> = Segments extends `${infer Segment}/${infer Rest}`
50
+ ? `${AppRouteLinkSegment<Segment>}/${AppRouteLinkSegments<Rest>}`
51
+ : AppRouteLinkSegment<Segments>;
52
+
53
+ export type AppRouteLinkSegment<Segment extends string> = Segment extends `:${string}`
54
+ ? string
55
+ : Segment;
56
+
38
57
  export function href<const Path extends `/${string}`>(
39
58
  path: Path,
40
59
  ...args: HasRouteParams<Path> extends true