@tanstack/vue-router 1.168.5 → 1.168.6

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.
@@ -1,13 +1,13 @@
1
1
  import { HistoryAction } from '@tanstack/history';
2
2
  import { AnyRoute, AnyRouter, ParseRoute, RegisteredRouter } from '@tanstack/router-core';
3
3
  import * as Vue from 'vue';
4
- interface ShouldBlockFnLocation<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema> {
4
+ type ShouldBlockFnLocation<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema> = {
5
5
  routeId: TRouteId;
6
6
  fullPath: TFullPath;
7
7
  pathname: string;
8
8
  params: TAllParams;
9
9
  search: TFullSearchSchema;
10
- }
10
+ };
11
11
  type MakeShouldBlockFnLocationUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? ShouldBlockFnLocation<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema']> : never;
12
12
  type BlockerResolver<TRouter extends AnyRouter = RegisteredRouter> = {
13
13
  status: 'blocked';
@@ -1 +1 @@
1
- {"version":3,"file":"useBlocker.js","names":["Vue","useRouter","_resolveBlockerOpts","opts","condition","undefined","shouldBlockFn","withResolver","shouldBlock","Boolean","_customBlockerFn","enableBeforeUnload","fn","blockerFn","useBlocker","disabled","router","history","resolver","ref","status","current","next","action","proceed","reset","watchEffect","onCleanup","blockerFnComposed","blockerFnArgs","getLocation","location","parsedLocation","parseLocation","matchedRoutes","getMatchedRoutes","pathname","foundRoute","routeId","fullPath","params","routeParams","search","id","currentLocation","nextLocation","promise","Promise","resolve","value","canNavigateAsync","unsubscribe","block","_resolvePromptBlockerArgs","props","BlockImpl","defineComponent","name","type","Function","required","default","Object","setup","slots","blockerArgs","computed","args","defaultSlot","h","Fragment","slotContent","Block","children","rest"],"sources":["../../src/useBlocker.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { useRouter } from './useRouter'\nimport type {\n BlockerFnArgs,\n HistoryAction,\n HistoryLocation,\n} from '@tanstack/history'\nimport type {\n AnyRoute,\n AnyRouter,\n ParseRoute,\n RegisteredRouter,\n} from '@tanstack/router-core'\n\ninterface ShouldBlockFnLocation<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n> {\n routeId: TRouteId\n fullPath: TFullPath\n pathname: string\n params: TAllParams\n search: TFullSearchSchema\n}\n\ntype AnyShouldBlockFnLocation = ShouldBlockFnLocation<any, any, any, any>\ntype MakeShouldBlockFnLocationUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? ShouldBlockFnLocation<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema']\n >\n : never\n\ntype BlockerResolver<TRouter extends AnyRouter = RegisteredRouter> =\n | {\n status: 'blocked'\n current: MakeShouldBlockFnLocationUnion<TRouter>\n next: MakeShouldBlockFnLocationUnion<TRouter>\n action: HistoryAction\n proceed: () => void\n reset: () => void\n }\n | {\n status: 'idle'\n current: undefined\n next: undefined\n action: undefined\n proceed: undefined\n reset: undefined\n }\n\ntype ShouldBlockFnArgs<TRouter extends AnyRouter = RegisteredRouter> = {\n current: MakeShouldBlockFnLocationUnion<TRouter>\n next: MakeShouldBlockFnLocationUnion<TRouter>\n action: HistoryAction\n}\n\nexport type ShouldBlockFn<TRouter extends AnyRouter = RegisteredRouter> = (\n args: ShouldBlockFnArgs<TRouter>,\n) => boolean | Promise<boolean>\nexport type UseBlockerOpts<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n> = {\n shouldBlockFn: ShouldBlockFn<TRouter>\n enableBeforeUnload?: boolean | (() => boolean)\n disabled?: boolean\n withResolver?: TWithResolver\n}\n\ntype LegacyBlockerFn = () => Promise<any> | any\ntype LegacyBlockerOpts = {\n blockerFn?: LegacyBlockerFn\n condition?: boolean | any\n}\n\nfunction _resolveBlockerOpts(\n opts?: UseBlockerOpts | LegacyBlockerOpts | LegacyBlockerFn,\n condition?: boolean | any,\n): UseBlockerOpts {\n if (opts === undefined) {\n return {\n shouldBlockFn: () => true,\n withResolver: false,\n }\n }\n\n if ('shouldBlockFn' in opts) {\n return opts\n }\n\n if (typeof opts === 'function') {\n const shouldBlock = Boolean(condition ?? true)\n\n const _customBlockerFn = async () => {\n if (shouldBlock) return await opts()\n return false\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n withResolver: false,\n }\n }\n\n const shouldBlock = Boolean(opts.condition ?? true)\n const fn = opts.blockerFn\n\n const _customBlockerFn = async () => {\n if (shouldBlock && fn !== undefined) {\n return await fn()\n }\n return shouldBlock\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n withResolver: fn === undefined,\n }\n}\n\nexport function useBlocker<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = false,\n>(\n opts: UseBlockerOpts<TRouter, TWithResolver>,\n): TWithResolver extends true ? Vue.Ref<BlockerResolver<TRouter>> : void\n\n/**\n * @deprecated Use the shouldBlockFn property instead\n */\nexport function useBlocker(\n blockerFnOrOpts?: LegacyBlockerOpts,\n): Vue.Ref<BlockerResolver>\n\n/**\n * @deprecated Use the UseBlockerOpts object syntax instead\n */\nexport function useBlocker(\n blockerFn?: LegacyBlockerFn,\n condition?: boolean | any,\n): Vue.Ref<BlockerResolver>\n\nexport function useBlocker(\n opts?: UseBlockerOpts | LegacyBlockerOpts | LegacyBlockerFn,\n condition?: boolean | any,\n): Vue.Ref<BlockerResolver> | void {\n const {\n shouldBlockFn,\n enableBeforeUnload = true,\n disabled = false,\n withResolver = false,\n } = _resolveBlockerOpts(opts, condition)\n\n const router = useRouter()\n const { history } = router\n\n const resolver = Vue.ref<BlockerResolver>({\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n })\n\n Vue.watchEffect((onCleanup) => {\n const blockerFnComposed = async (blockerFnArgs: BlockerFnArgs) => {\n function getLocation(\n location: HistoryLocation,\n ): AnyShouldBlockFnLocation {\n const parsedLocation = router.parseLocation(location)\n const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname)\n if (matchedRoutes.foundRoute === undefined) {\n return {\n routeId: '__notFound__',\n fullPath: parsedLocation.pathname,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n return {\n routeId: matchedRoutes.foundRoute.id,\n fullPath: matchedRoutes.foundRoute.fullPath,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n\n const current = getLocation(blockerFnArgs.currentLocation)\n const next = getLocation(blockerFnArgs.nextLocation)\n\n // Allow navigation away from 404 pages to valid routes\n if (\n current.routeId === '__notFound__' &&\n next.routeId !== '__notFound__'\n ) {\n return false\n }\n\n const shouldBlock = await shouldBlockFn({\n action: blockerFnArgs.action,\n current,\n next,\n })\n if (!withResolver) {\n return shouldBlock\n }\n\n if (!shouldBlock) {\n return false\n }\n\n const promise = new Promise<boolean>((resolve) => {\n resolver.value = {\n status: 'blocked',\n current,\n next,\n action: blockerFnArgs.action,\n proceed: () => resolve(false),\n reset: () => resolve(true),\n }\n })\n\n const canNavigateAsync = await promise\n resolver.value = {\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n }\n\n return canNavigateAsync\n }\n\n if (disabled) {\n return\n }\n\n const unsubscribe = history.block({\n blockerFn: blockerFnComposed,\n enableBeforeUnload,\n })\n\n onCleanup(() => {\n if (unsubscribe) unsubscribe()\n })\n })\n\n return withResolver ? resolver : undefined\n}\n\nconst _resolvePromptBlockerArgs = (\n props: PromptProps | LegacyPromptProps,\n): UseBlockerOpts => {\n if ('shouldBlockFn' in props) {\n return { ...props }\n }\n\n const shouldBlock = Boolean(props.condition ?? true)\n const fn = props.blockerFn\n\n const _customBlockerFn = async () => {\n if (shouldBlock && fn !== undefined) {\n return await fn()\n }\n return shouldBlock\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n withResolver: fn === undefined,\n }\n}\n\n// Internal Block implementation as a proper Vue component for reactivity\nconst BlockImpl = Vue.defineComponent({\n name: 'Block',\n props: {\n shouldBlockFn: {\n type: Function as Vue.PropType<ShouldBlockFn<any>>,\n required: false,\n },\n enableBeforeUnload: {\n type: [Boolean, Function] as Vue.PropType<boolean | (() => boolean)>,\n default: true,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n withResolver: {\n type: Boolean,\n default: false,\n },\n // Legacy props\n blockerFn: {\n type: Function as Vue.PropType<LegacyBlockerFn>,\n required: false,\n },\n condition: {\n type: [Boolean, Object] as Vue.PropType<boolean | any>,\n required: false,\n },\n },\n setup(props, { slots }) {\n // Create a computed that resolves the blocker args reactively\n const blockerArgs = Vue.computed<UseBlockerOpts>(() => {\n if (props.shouldBlockFn) {\n return {\n shouldBlockFn: props.shouldBlockFn,\n enableBeforeUnload: props.enableBeforeUnload,\n disabled: props.disabled,\n withResolver: props.withResolver,\n }\n }\n\n // Legacy handling\n const shouldBlock = Boolean(props.condition ?? true)\n const fn = props.blockerFn\n\n const _customBlockerFn = async () => {\n if (shouldBlock && fn !== undefined) {\n return await fn()\n }\n return shouldBlock\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n disabled: props.disabled,\n withResolver: fn === undefined,\n }\n })\n\n // Use a reactive useBlocker that re-subscribes when args change\n const router = useRouter()\n const { history } = router\n\n const resolver = Vue.ref<BlockerResolver>({\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n })\n\n Vue.watchEffect((onCleanup) => {\n const args = blockerArgs.value\n\n if (args.disabled) {\n return\n }\n\n const blockerFnComposed = async (blockerFnArgs: BlockerFnArgs) => {\n function getLocation(\n location: HistoryLocation,\n ): AnyShouldBlockFnLocation {\n const parsedLocation = router.parseLocation(location)\n const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname)\n if (matchedRoutes.foundRoute === undefined) {\n return {\n routeId: '__notFound__',\n fullPath: parsedLocation.pathname,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n return {\n routeId: matchedRoutes.foundRoute.id,\n fullPath: matchedRoutes.foundRoute.fullPath,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n\n const current = getLocation(blockerFnArgs.currentLocation)\n const next = getLocation(blockerFnArgs.nextLocation)\n\n // Allow navigation away from 404 pages to valid routes\n if (\n current.routeId === '__notFound__' &&\n next.routeId !== '__notFound__'\n ) {\n return false\n }\n\n const shouldBlock = await args.shouldBlockFn({\n action: blockerFnArgs.action,\n current,\n next,\n })\n if (!args.withResolver) {\n return shouldBlock\n }\n\n if (!shouldBlock) {\n return false\n }\n\n const promise = new Promise<boolean>((resolve) => {\n resolver.value = {\n status: 'blocked',\n current,\n next,\n action: blockerFnArgs.action,\n proceed: () => resolve(false),\n reset: () => resolve(true),\n }\n })\n\n const canNavigateAsync = await promise\n resolver.value = {\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n }\n\n return canNavigateAsync\n }\n\n const unsubscribe = history.block({\n blockerFn: blockerFnComposed,\n enableBeforeUnload: args.enableBeforeUnload,\n })\n\n onCleanup(() => {\n if (unsubscribe) unsubscribe()\n })\n })\n\n return () => {\n const defaultSlot = slots.default\n if (!defaultSlot) {\n return Vue.h(Vue.Fragment, null)\n }\n\n // If slot is a function that takes resolver, call it with the resolver\n const slotContent = defaultSlot(resolver.value as any)\n return Vue.h(Vue.Fragment, null, slotContent)\n }\n },\n})\n\nexport function Block<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n>(opts: PromptProps<TRouter, TWithResolver>): Vue.VNode\n\n/**\n * @deprecated Use the UseBlockerOpts property instead\n */\nexport function Block(opts: LegacyPromptProps): Vue.VNode\n\nexport function Block(opts: PromptProps | LegacyPromptProps): Vue.VNode {\n const { children, ...rest } = opts\n\n // Convert children to slot format for the component\n const slots = children\n ? typeof children === 'function'\n ? { default: children }\n : { default: () => children }\n : undefined\n\n return Vue.h(BlockImpl, rest as any, slots)\n}\n\ntype LegacyPromptProps = {\n blockerFn?: LegacyBlockerFn\n condition?: boolean | any\n children?: Vue.VNode | ((params: BlockerResolver) => Vue.VNode)\n}\n\ntype PromptProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n TParams = TWithResolver extends true ? BlockerResolver<TRouter> : void,\n> = UseBlockerOpts<TRouter, TWithResolver> & {\n children?: Vue.VNode | ((params: TParams) => Vue.VNode)\n}\n"],"mappings":";;;AAmFA,SAASE,oBACPC,MACAC,WACgB;AAChB,KAAID,SAASE,KAAAA,EACX,QAAO;EACLC,qBAAqB;EACrBC,cAAc;EACf;AAGH,KAAI,mBAAmBJ,KACrB,QAAOA;AAGT,KAAI,OAAOA,SAAS,YAAY;EAC9B,MAAMK,cAAcC,QAAQL,aAAa,KAAK;EAE9C,MAAMM,mBAAmB,YAAY;AACnC,OAAIF,YAAa,QAAO,MAAML,MAAM;AACpC,UAAO;;AAGT,SAAO;GACLG,eAAeI;GACfC,oBAAoBH;GACpBD,cAAc;GACf;;CAGH,MAAMC,cAAcC,QAAQN,KAAKC,aAAa,KAAK;CACnD,MAAMQ,KAAKT,KAAKU;CAEhB,MAAMH,mBAAmB,YAAY;AACnC,MAAIF,eAAeI,OAAOP,KAAAA,EACxB,QAAO,MAAMO,IAAI;AAEnB,SAAOJ;;AAGT,QAAO;EACLF,eAAeI;EACfC,oBAAoBH;EACpBD,cAAcK,OAAOP,KAAAA;EACtB;;;;;;;;AAyBH,SAAgBS,WACdX,MAC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,QAAQ;MACf7B,QAAQ;MACRC;MACAC;MACAC,QAAQM,cAAcN;MACtBC,eAAewB,QAAQ,MAAM;MAC7BvB,aAAauB,QAAQ,KAAI;MAC1B;MACD;AAGF9B,aAAS+B,QAAQ;KACf7B,QAAQ;KACRC,SAAShB,KAAAA;KACTiB,MAAMjB,KAAAA;KACNkB,QAAQlB,KAAAA;KACRmB,SAASnB,KAAAA;KACToB,OAAOpB,KAAAA;KACR;AAED,WAAO6C;;GAGT,MAAMC,cAAclC,QAAQmC,MAAM;IAChCvC,WAAWe;IACXjB,oBAAoBwD,KAAKxD;IAC1B,CAAC;AAEFgB,mBAAgB;AACd,QAAIwB,YAAaA,cAAa;KAC9B;IACF;AAEF,eAAa;GACX,MAAMiB,cAAcJ,MAAMH;AAC1B,OAAI,CAACO,YACH,QAAOpE,IAAIqE,EAAErE,IAAIsE,UAAU,KAAK;GAIlC,MAAMC,cAAcH,YAAYlD,SAAS+B,MAAa;AACtD,UAAOjD,IAAIqE,EAAErE,IAAIsE,UAAU,MAAMC,YAAY;;;CAGlD,CAAC;;;;AAYF,SAAgBC,MAAMrE,MAAkD;CACtE,MAAM,EAAEsE,UAAU,GAAGC,SAASvE;CAG9B,MAAM6D,QAAQS,WACV,OAAOA,aAAa,aAClB,EAAEZ,SAASY,UAAU,GACrB,EAAEZ,eAAeY,UAAU,GAC7BpE,KAAAA;AAEJ,QAAOL,IAAIqE,EAAEd,WAAWmB,MAAaV,MAAM"}
1
+ {"version":3,"file":"useBlocker.js","names":["Vue","useRouter","_resolveBlockerOpts","opts","condition","undefined","shouldBlockFn","withResolver","shouldBlock","Boolean","_customBlockerFn","enableBeforeUnload","fn","blockerFn","useBlocker","disabled","router","history","resolver","ref","status","current","next","action","proceed","reset","watchEffect","onCleanup","blockerFnComposed","blockerFnArgs","getLocation","location","parsedLocation","parseLocation","matchedRoutes","getMatchedRoutes","pathname","foundRoute","routeId","fullPath","params","routeParams","search","id","currentLocation","nextLocation","promise","Promise","resolve","value","canNavigateAsync","unsubscribe","block","_resolvePromptBlockerArgs","props","BlockImpl","defineComponent","name","type","Function","required","default","Object","setup","slots","blockerArgs","computed","args","defaultSlot","h","Fragment","slotContent","Block","children","rest"],"sources":["../../src/useBlocker.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { useRouter } from './useRouter'\nimport type {\n BlockerFnArgs,\n HistoryAction,\n HistoryLocation,\n} from '@tanstack/history'\nimport type {\n AnyRoute,\n AnyRouter,\n ParseRoute,\n RegisteredRouter,\n} from '@tanstack/router-core'\n\ntype ShouldBlockFnLocation<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n> = {\n routeId: TRouteId\n fullPath: TFullPath\n pathname: string\n params: TAllParams\n search: TFullSearchSchema\n}\n\ntype AnyShouldBlockFnLocation = ShouldBlockFnLocation<any, any, any, any>\ntype MakeShouldBlockFnLocationUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? ShouldBlockFnLocation<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema']\n >\n : never\n\ntype BlockerResolver<TRouter extends AnyRouter = RegisteredRouter> =\n | {\n status: 'blocked'\n current: MakeShouldBlockFnLocationUnion<TRouter>\n next: MakeShouldBlockFnLocationUnion<TRouter>\n action: HistoryAction\n proceed: () => void\n reset: () => void\n }\n | {\n status: 'idle'\n current: undefined\n next: undefined\n action: undefined\n proceed: undefined\n reset: undefined\n }\n\ntype ShouldBlockFnArgs<TRouter extends AnyRouter = RegisteredRouter> = {\n current: MakeShouldBlockFnLocationUnion<TRouter>\n next: MakeShouldBlockFnLocationUnion<TRouter>\n action: HistoryAction\n}\n\nexport type ShouldBlockFn<TRouter extends AnyRouter = RegisteredRouter> = (\n args: ShouldBlockFnArgs<TRouter>,\n) => boolean | Promise<boolean>\nexport type UseBlockerOpts<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n> = {\n shouldBlockFn: ShouldBlockFn<TRouter>\n enableBeforeUnload?: boolean | (() => boolean)\n disabled?: boolean\n withResolver?: TWithResolver\n}\n\ntype LegacyBlockerFn = () => Promise<any> | any\ntype LegacyBlockerOpts = {\n blockerFn?: LegacyBlockerFn\n condition?: boolean | any\n}\n\nfunction _resolveBlockerOpts(\n opts?: UseBlockerOpts | LegacyBlockerOpts | LegacyBlockerFn,\n condition?: boolean | any,\n): UseBlockerOpts {\n if (opts === undefined) {\n return {\n shouldBlockFn: () => true,\n withResolver: false,\n }\n }\n\n if ('shouldBlockFn' in opts) {\n return opts\n }\n\n if (typeof opts === 'function') {\n const shouldBlock = Boolean(condition ?? true)\n\n const _customBlockerFn = async () => {\n if (shouldBlock) return await opts()\n return false\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n withResolver: false,\n }\n }\n\n const shouldBlock = Boolean(opts.condition ?? true)\n const fn = opts.blockerFn\n\n const _customBlockerFn = async () => {\n if (shouldBlock && fn !== undefined) {\n return await fn()\n }\n return shouldBlock\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n withResolver: fn === undefined,\n }\n}\n\nexport function useBlocker<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = false,\n>(\n opts: UseBlockerOpts<TRouter, TWithResolver>,\n): TWithResolver extends true ? Vue.Ref<BlockerResolver<TRouter>> : void\n\n/**\n * @deprecated Use the shouldBlockFn property instead\n */\nexport function useBlocker(\n blockerFnOrOpts?: LegacyBlockerOpts,\n): Vue.Ref<BlockerResolver>\n\n/**\n * @deprecated Use the UseBlockerOpts object syntax instead\n */\nexport function useBlocker(\n blockerFn?: LegacyBlockerFn,\n condition?: boolean | any,\n): Vue.Ref<BlockerResolver>\n\nexport function useBlocker(\n opts?: UseBlockerOpts | LegacyBlockerOpts | LegacyBlockerFn,\n condition?: boolean | any,\n): Vue.Ref<BlockerResolver> | void {\n const {\n shouldBlockFn,\n enableBeforeUnload = true,\n disabled = false,\n withResolver = false,\n } = _resolveBlockerOpts(opts, condition)\n\n const router = useRouter()\n const { history } = router\n\n const resolver = Vue.ref<BlockerResolver>({\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n })\n\n Vue.watchEffect((onCleanup) => {\n const blockerFnComposed = async (blockerFnArgs: BlockerFnArgs) => {\n function getLocation(\n location: HistoryLocation,\n ): AnyShouldBlockFnLocation {\n const parsedLocation = router.parseLocation(location)\n const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname)\n if (matchedRoutes.foundRoute === undefined) {\n return {\n routeId: '__notFound__',\n fullPath: parsedLocation.pathname,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n return {\n routeId: matchedRoutes.foundRoute.id,\n fullPath: matchedRoutes.foundRoute.fullPath,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n\n const current = getLocation(blockerFnArgs.currentLocation)\n const next = getLocation(blockerFnArgs.nextLocation)\n\n // Allow navigation away from 404 pages to valid routes\n if (\n current.routeId === '__notFound__' &&\n next.routeId !== '__notFound__'\n ) {\n return false\n }\n\n const shouldBlock = await shouldBlockFn({\n action: blockerFnArgs.action,\n current,\n next,\n })\n if (!withResolver) {\n return shouldBlock\n }\n\n if (!shouldBlock) {\n return false\n }\n\n const promise = new Promise<boolean>((resolve) => {\n resolver.value = {\n status: 'blocked',\n current,\n next,\n action: blockerFnArgs.action,\n proceed: () => resolve(false),\n reset: () => resolve(true),\n }\n })\n\n const canNavigateAsync = await promise\n resolver.value = {\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n }\n\n return canNavigateAsync\n }\n\n if (disabled) {\n return\n }\n\n const unsubscribe = history.block({\n blockerFn: blockerFnComposed,\n enableBeforeUnload,\n })\n\n onCleanup(() => {\n if (unsubscribe) unsubscribe()\n })\n })\n\n return withResolver ? resolver : undefined\n}\n\nconst _resolvePromptBlockerArgs = (\n props: PromptProps | LegacyPromptProps,\n): UseBlockerOpts => {\n if ('shouldBlockFn' in props) {\n return { ...props }\n }\n\n const shouldBlock = Boolean(props.condition ?? true)\n const fn = props.blockerFn\n\n const _customBlockerFn = async () => {\n if (shouldBlock && fn !== undefined) {\n return await fn()\n }\n return shouldBlock\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n withResolver: fn === undefined,\n }\n}\n\n// Internal Block implementation as a proper Vue component for reactivity\nconst BlockImpl = Vue.defineComponent({\n name: 'Block',\n props: {\n shouldBlockFn: {\n type: Function as Vue.PropType<ShouldBlockFn<any>>,\n required: false,\n },\n enableBeforeUnload: {\n type: [Boolean, Function] as Vue.PropType<boolean | (() => boolean)>,\n default: true,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n withResolver: {\n type: Boolean,\n default: false,\n },\n // Legacy props\n blockerFn: {\n type: Function as Vue.PropType<LegacyBlockerFn>,\n required: false,\n },\n condition: {\n type: [Boolean, Object] as Vue.PropType<boolean | any>,\n required: false,\n },\n },\n setup(props, { slots }) {\n // Create a computed that resolves the blocker args reactively\n const blockerArgs = Vue.computed<UseBlockerOpts>(() => {\n if (props.shouldBlockFn) {\n return {\n shouldBlockFn: props.shouldBlockFn,\n enableBeforeUnload: props.enableBeforeUnload,\n disabled: props.disabled,\n withResolver: props.withResolver,\n }\n }\n\n // Legacy handling\n const shouldBlock = Boolean(props.condition ?? true)\n const fn = props.blockerFn\n\n const _customBlockerFn = async () => {\n if (shouldBlock && fn !== undefined) {\n return await fn()\n }\n return shouldBlock\n }\n\n return {\n shouldBlockFn: _customBlockerFn,\n enableBeforeUnload: shouldBlock,\n disabled: props.disabled,\n withResolver: fn === undefined,\n }\n })\n\n // Use a reactive useBlocker that re-subscribes when args change\n const router = useRouter()\n const { history } = router\n\n const resolver = Vue.ref<BlockerResolver>({\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n })\n\n Vue.watchEffect((onCleanup) => {\n const args = blockerArgs.value\n\n if (args.disabled) {\n return\n }\n\n const blockerFnComposed = async (blockerFnArgs: BlockerFnArgs) => {\n function getLocation(\n location: HistoryLocation,\n ): AnyShouldBlockFnLocation {\n const parsedLocation = router.parseLocation(location)\n const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname)\n if (matchedRoutes.foundRoute === undefined) {\n return {\n routeId: '__notFound__',\n fullPath: parsedLocation.pathname,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n return {\n routeId: matchedRoutes.foundRoute.id,\n fullPath: matchedRoutes.foundRoute.fullPath,\n pathname: parsedLocation.pathname,\n params: matchedRoutes.routeParams,\n search: parsedLocation.search,\n }\n }\n\n const current = getLocation(blockerFnArgs.currentLocation)\n const next = getLocation(blockerFnArgs.nextLocation)\n\n // Allow navigation away from 404 pages to valid routes\n if (\n current.routeId === '__notFound__' &&\n next.routeId !== '__notFound__'\n ) {\n return false\n }\n\n const shouldBlock = await args.shouldBlockFn({\n action: blockerFnArgs.action,\n current,\n next,\n })\n if (!args.withResolver) {\n return shouldBlock\n }\n\n if (!shouldBlock) {\n return false\n }\n\n const promise = new Promise<boolean>((resolve) => {\n resolver.value = {\n status: 'blocked',\n current,\n next,\n action: blockerFnArgs.action,\n proceed: () => resolve(false),\n reset: () => resolve(true),\n }\n })\n\n const canNavigateAsync = await promise\n resolver.value = {\n status: 'idle',\n current: undefined,\n next: undefined,\n action: undefined,\n proceed: undefined,\n reset: undefined,\n }\n\n return canNavigateAsync\n }\n\n const unsubscribe = history.block({\n blockerFn: blockerFnComposed,\n enableBeforeUnload: args.enableBeforeUnload,\n })\n\n onCleanup(() => {\n if (unsubscribe) unsubscribe()\n })\n })\n\n return () => {\n const defaultSlot = slots.default\n if (!defaultSlot) {\n return Vue.h(Vue.Fragment, null)\n }\n\n // If slot is a function that takes resolver, call it with the resolver\n const slotContent = defaultSlot(resolver.value as any)\n return Vue.h(Vue.Fragment, null, slotContent)\n }\n },\n})\n\nexport function Block<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n>(opts: PromptProps<TRouter, TWithResolver>): Vue.VNode\n\n/**\n * @deprecated Use the UseBlockerOpts property instead\n */\nexport function Block(opts: LegacyPromptProps): Vue.VNode\n\nexport function Block(opts: PromptProps | LegacyPromptProps): Vue.VNode {\n const { children, ...rest } = opts\n\n // Convert children to slot format for the component\n const slots = children\n ? typeof children === 'function'\n ? { default: children }\n : { default: () => children }\n : undefined\n\n return Vue.h(BlockImpl, rest as any, slots)\n}\n\ntype LegacyPromptProps = {\n blockerFn?: LegacyBlockerFn\n condition?: boolean | any\n children?: Vue.VNode | ((params: BlockerResolver) => Vue.VNode)\n}\n\ntype PromptProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n TParams = TWithResolver extends true ? BlockerResolver<TRouter> : void,\n> = UseBlockerOpts<TRouter, TWithResolver> & {\n children?: Vue.VNode | ((params: TParams) => Vue.VNode)\n}\n"],"mappings":";;;AAmFA,SAASE,oBACPC,MACAC,WACgB;AAChB,KAAID,SAASE,KAAAA,EACX,QAAO;EACLC,qBAAqB;EACrBC,cAAc;EACf;AAGH,KAAI,mBAAmBJ,KACrB,QAAOA;AAGT,KAAI,OAAOA,SAAS,YAAY;EAC9B,MAAMK,cAAcC,QAAQL,aAAa,KAAK;EAE9C,MAAMM,mBAAmB,YAAY;AACnC,OAAIF,YAAa,QAAO,MAAML,MAAM;AACpC,UAAO;;AAGT,SAAO;GACLG,eAAeI;GACfC,oBAAoBH;GACpBD,cAAc;GACf;;CAGH,MAAMC,cAAcC,QAAQN,KAAKC,aAAa,KAAK;CACnD,MAAMQ,KAAKT,KAAKU;CAEhB,MAAMH,mBAAmB,YAAY;AACnC,MAAIF,eAAeI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cAAcN;KACtBF;KACAC;KACD,CAAC;AACF,QAAI,CAAC6C,KAAK5D,aACR,QAAOC;AAGT,QAAI,CAACA,YACH,QAAO;IAcT,MAAM0C,mBAAmB,MAXT,IAAIH,SAAkBC,YAAY;AAChD9B,cAAS+B,QAAQ;MACf7B,QAAQ;MACRC;MACAC;MACAC,QAAQM,cAAcN;MACtBC,eAAewB,QAAQ,MAAM;MAC7BvB,aAAauB,QAAQ,KAAI;MAC1B;MACD;AAGF9B,aAAS+B,QAAQ;KACf7B,QAAQ;KACRC,SAAShB,KAAAA;KACTiB,MAAMjB,KAAAA;KACNkB,QAAQlB,KAAAA;KACRmB,SAASnB,KAAAA;KACToB,OAAOpB,KAAAA;KACR;AAED,WAAO6C;;GAGT,MAAMC,cAAclC,QAAQmC,MAAM;IAChCvC,WAAWe;IACXjB,oBAAoBwD,KAAKxD;IAC1B,CAAC;AAEFgB,mBAAgB;AACd,QAAIwB,YAAaA,cAAa;KAC9B;IACF;AAEF,eAAa;GACX,MAAMiB,cAAcJ,MAAMH;AAC1B,OAAI,CAACO,YACH,QAAOpE,IAAIqE,EAAErE,IAAIsE,UAAU,KAAK;GAIlC,MAAMC,cAAcH,YAAYlD,SAAS+B,MAAa;AACtD,UAAOjD,IAAIqE,EAAErE,IAAIsE,UAAU,MAAMC,YAAY;;;CAGlD,CAAC;;;;AAYF,SAAgBC,MAAMrE,MAAkD;CACtE,MAAM,EAAEsE,UAAU,GAAGC,SAASvE;CAG9B,MAAM6D,QAAQS,WACV,OAAOA,aAAa,aAClB,EAAEZ,SAASY,UAAU,GACrB,EAAEZ,eAAeY,UAAU,GAC7BpE,KAAAA;AAEJ,QAAOL,IAAIqE,EAAEd,WAAWmB,MAAaV,MAAM"}
@@ -1,13 +1,13 @@
1
1
  import * as Vue from 'vue';
2
2
  import type { HistoryAction } from '@tanstack/history';
3
3
  import type { AnyRoute, AnyRouter, ParseRoute, RegisteredRouter } from '@tanstack/router-core';
4
- interface ShouldBlockFnLocation<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema> {
4
+ type ShouldBlockFnLocation<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema> = {
5
5
  routeId: TRouteId;
6
6
  fullPath: TFullPath;
7
7
  pathname: string;
8
8
  params: TAllParams;
9
9
  search: TFullSearchSchema;
10
- }
10
+ };
11
11
  type MakeShouldBlockFnLocationUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? ShouldBlockFnLocation<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema']> : never;
12
12
  type BlockerResolver<TRouter extends AnyRouter = RegisteredRouter> = {
13
13
  status: 'blocked';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-router",
3
- "version": "1.168.5",
3
+ "version": "1.168.6",
4
4
  "description": "Modern and scalable routing for Vue applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -65,7 +65,7 @@
65
65
  "isbot": "^5.1.22",
66
66
  "jsesc": "^3.0.2",
67
67
  "@tanstack/history": "1.161.6",
68
- "@tanstack/router-core": "1.168.5"
68
+ "@tanstack/router-core": "1.168.6"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tanstack/intent": "^0.0.14",
@@ -12,12 +12,12 @@ import type {
12
12
  RegisteredRouter,
13
13
  } from '@tanstack/router-core'
14
14
 
15
- interface ShouldBlockFnLocation<
15
+ type ShouldBlockFnLocation<
16
16
  out TRouteId,
17
17
  out TFullPath,
18
18
  out TAllParams,
19
19
  out TFullSearchSchema,
20
- > {
20
+ > = {
21
21
  routeId: TRouteId
22
22
  fullPath: TFullPath
23
23
  pathname: string