Socket
Socket
Sign inDemoInstall

@tanstack/react-router

Package Overview
Dependencies
Maintainers
2
Versions
583
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/react-router - npm Package Compare versions

Comparing version 1.34.0 to 1.34.1

2

dist/esm/awaited.d.ts

@@ -6,3 +6,3 @@ import { DeferredPromise } from './defer.js';

};
export declare function useAwaited<T>({ promise }: AwaitOptions<T>): [T];
export declare function useAwaited<T>({ promise, }: AwaitOptions<T>): [T, DeferredPromise<T>];
export declare function Await<T>(props: AwaitOptions<T> & {

@@ -9,0 +9,0 @@ fallback?: React.ReactNode;

@@ -1,2 +0,2 @@

import { jsx } from "react/jsx-runtime";
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
import * as React from "react";

@@ -8,3 +8,5 @@ import warning from "tiny-warning";

import { isServerSideError, defaultDeserializeError } from "./Matches.js";
function useAwaited({ promise }) {
function useAwaited({
promise
}) {
var _a, _b;

@@ -40,13 +42,2 @@ const router = useRouter();

}
if (!isDehydratedDeferred(promise)) {
router.injectHtml(
`<script class='tsr_deferred_data'>window.__TSR__DEFERRED__${state.uid} = ${JSON.stringify(router.options.transformer.stringify(state))}
if (window.__TSR__ROUTER__) {
let deferred = window.__TSR__ROUTER__.getDeferred('${state.uid}');
if (deferred) deferred.resolve(window.__TSR__DEFERRED__${state.uid});
}
document.querySelectorAll('.tsr_deferred_data').forEach((el) => el.parentElement.removeChild(el));
<\/script>`
);
}
if (state.status === "error") {

@@ -70,3 +61,3 @@ if (typeof document !== "undefined") {

}
return [promise.__deferredState.data];
return [promise.__deferredState.data, promise];
}

@@ -81,5 +72,36 @@ function Await(props) {

function AwaitInner(props) {
const awaited = useAwaited(props);
return props.children(...awaited);
const router = useRouter();
const [data, promise] = useAwaited(props);
const state = promise.__deferredState;
return /* @__PURE__ */ jsxs(Fragment, { children: [
!isDehydratedDeferred(promise) ? /* @__PURE__ */ jsx(
ScriptOnce,
{
children: `window.__TSR__DEFERRED__${state.uid} = ${JSON.stringify(router.options.transformer.stringify(state))}
if (window.__TSR__ROUTER__) {
let deferred = window.__TSR__ROUTER__.getDeferred('${state.uid}');
if (deferred) deferred.resolve(window.__TSR__DEFERRED__${state.uid});
}
document.querySelectorAll('.tsr-script-once').forEach((el) => el.parentElement.removeChild(el));`
}
) : null,
props.children(data)
] });
}
function ScriptOnce({
className,
children,
...rest
}) {
return /* @__PURE__ */ jsx(
"script",
{
...rest,
className: `tsr-script-once ${className || ""}`,
dangerouslySetInnerHTML: {
__html: children
}
}
);
}
export {

@@ -86,0 +108,0 @@ Await,

@@ -10,3 +10,3 @@ import { Store, NoInfer } from '@tanstack/react-store';

import { SearchParser, SearchSerializer } from './searchParams.js';
import { BuildLocationFn, CommitLocationOptions, InjectedHtmlEntry, NavigateFn } from './RouterProvider.js';
import { BuildLocationFn, CommitLocationOptions, NavigateFn } from './RouterProvider.js';
import { AnyRedirect, ResolvedRedirect } from './redirects.js';

@@ -338,3 +338,2 @@ import { NotFoundError } from './not-found.js';

subscribers: Set<RouterListener<RouterEvent>>;
injectedHtml: Array<InjectedHtmlEntry>;
dehydratedData?: TDehydrated;

@@ -393,2 +392,5 @@ viewTransitionPromise?: ControlledPromise<true>;

matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TDehydrated, TSerializedError>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>['types']['allParams'];
/**
* @deprecated Injecting HTML directly is no longer supported. Use the new <ScriptOnce /> component instead.
*/
injectHtml: (html: string | (() => Promise<string> | string)) => Promise<void>;

@@ -398,10 +400,2 @@ registeredDeferredsIds: Map<string, {}>;

getDeferred: (uid: string) => DeferredPromiseState<any> | undefined;
/**
* @deprecated Please inject your own html using the `injectHtml` method
*/
dehydrateData: <T>(key: any, getData: T | (() => Promise<T> | T)) => () => T | undefined;
/**
* @deprecated Please extract your own data from scripts injected using the `injectHtml` method
*/
hydrateData: <T = unknown>(key: any) => T | undefined;
dehydrate: () => DehydratedRouter;

@@ -408,0 +402,0 @@ hydrate: (__do_not_use_server_ctx?: string) => Promise<void>;

import { createBrowserHistory, createMemoryHistory } from "@tanstack/history";
import { Store } from "@tanstack/react-store";
import invariant from "tiny-invariant";
import warning from "tiny-warning";
import { rootRouteId } from "./root.js";
import { defaultStringifySearch, defaultParseSearch } from "./searchParams.js";
import { createControlledPromise, replaceEqualDeep, pick, last, deepEqual, escapeJSON, functionalUpdate } from "./utils.js";
import { createControlledPromise, replaceEqualDeep, pick, last, deepEqual, functionalUpdate } from "./utils.js";
import { getRouteMatch } from "./RouterProvider.js";

@@ -33,3 +32,2 @@ import { trimPath, trimPathLeft, parsePathname, resolvePath, cleanPath, matchPathname, trimPathRight, interpolatePath, joinPaths } from "./path.js";

this.subscribers = /* @__PURE__ */ new Set();
this.injectedHtml = [];
this.isServer = typeof document === "undefined";

@@ -1151,3 +1149,2 @@ this.startReactTransition = (fn) => fn();

this.injectHtml = async (html) => {
this.injectedHtml.push(html);
};

@@ -1163,35 +1160,2 @@ this.registeredDeferredsIds = /* @__PURE__ */ new Map();

};
this.dehydrateData = (key, getData) => {
warning(
false,
`The dehydrateData method is deprecated. Please use the injectHtml method to inject your own data.`
);
if (typeof document === "undefined") {
const strKey = typeof key === "string" ? key : JSON.stringify(key);
this.injectHtml(async () => {
const id = `__TSR_DEHYDRATED__${strKey}`;
const data = typeof getData === "function" ? await getData() : getData;
return `<script id='${id}' suppressHydrationWarning>
window["__TSR_DEHYDRATED__${escapeJSON(
strKey
)}"] = ${JSON.stringify(this.options.transformer.stringify(data))}
<\/script>`;
});
return () => this.hydrateData(key);
}
return () => void 0;
};
this.hydrateData = (key) => {
warning(
false,
`The hydrateData method is deprecated. Please use the extractHtml method to extract your own data.`
);
if (typeof document !== "undefined") {
const strKey = typeof key === "string" ? key : JSON.stringify(key);
return this.options.transformer.parse(
window[`__TSR_DEHYDRATED__${strKey}`]
);
}
return void 0;
};
this.dehydrate = () => {

@@ -1198,0 +1162,0 @@ var _a;

@@ -18,3 +18,5 @@ import * as React from "react";

const previousIsAnyPending = usePrevious(isAnyPending);
router.startReactTransition = startReactTransition_;
if (!router.isServer) {
router.startReactTransition = startReactTransition_;
}
useLayoutEffect(() => {

@@ -21,0 +23,0 @@ const unsub = router.history.subscribe(router.load);

{
"name": "@tanstack/react-router",
"version": "1.34.0",
"version": "1.34.1",
"description": "",

@@ -5,0 +5,0 @@ "author": "Tanner Linsley",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc