Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@tanstack/start-storage-context

Package Overview
Dependencies
Maintainers
5
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/start-storage-context - npm Package Compare versions

Comparing version
1.167.7
to
1.167.8
+3
-3
dist/esm/async-local-storage.d.ts

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

import { Awaitable, RegisteredRouter, RouterManagedTag } from '@tanstack/router-core';
import { Awaitable, ManifestRouteAssets, RegisteredRouter } from '@tanstack/router-core';
export type StartHandlerType = 'router' | 'serverFn';

@@ -12,6 +12,6 @@ export interface StartStorageContext {

* Additional assets to inject for this request.
* Plugins can push RouterManagedTag items here during request processing.
* Plugins can add manifest route assets here during request processing.
* Merged into manifest at dehydration time without mutating cached manifest.
*/
requestAssets?: Array<RouterManagedTag>;
requestAssets?: ManifestRouteAssets;
}

@@ -18,0 +18,0 @@ export declare function runWithStartContext<T>(context: StartStorageContext, fn: () => T | Promise<T>): Promise<T>;

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

{"version":3,"file":"async-local-storage.js","names":[],"sources":["../../src/async-local-storage.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type {\n Awaitable,\n RegisteredRouter,\n RouterManagedTag,\n} from '@tanstack/router-core'\n\nexport type StartHandlerType = 'router' | 'serverFn'\n\nexport interface StartStorageContext {\n getRouter: () => Awaitable<RegisteredRouter>\n request: Request\n // TODO type this properly\n startOptions: /* AnyStartInstanceOptions*/ any\n\n contextAfterGlobalMiddlewares: any\n // Track middlewares that have already executed in the request phase\n // to prevent duplicate execution\n executedRequestMiddlewares: Set<any>\n // Type of handler processing this request\n handlerType: StartHandlerType\n\n /**\n * Additional assets to inject for this request.\n * Plugins can push RouterManagedTag items here during request processing.\n * Merged into manifest at dehydration time without mutating cached manifest.\n */\n requestAssets?: Array<RouterManagedTag>\n}\n\n// Use a global symbol to ensure the same AsyncLocalStorage instance is shared\n// across different bundles that may each bundle this module.\nconst GLOBAL_STORAGE_KEY = Symbol.for('tanstack-start:start-storage-context')\n\nconst globalObj = globalThis as typeof globalThis & {\n [GLOBAL_STORAGE_KEY]?: AsyncLocalStorage<StartStorageContext>\n}\n\nif (!globalObj[GLOBAL_STORAGE_KEY]) {\n globalObj[GLOBAL_STORAGE_KEY] = new AsyncLocalStorage<StartStorageContext>()\n}\n\nconst startStorage = globalObj[GLOBAL_STORAGE_KEY]\n\nexport async function runWithStartContext<T>(\n context: StartStorageContext,\n fn: () => T | Promise<T>,\n): Promise<T> {\n return startStorage.run(context, fn)\n}\n\nexport function getStartContext<TThrow extends boolean = true>(opts?: {\n throwIfNotFound?: TThrow\n}): TThrow extends false\n ? StartStorageContext | undefined\n : StartStorageContext {\n const context = startStorage.getStore()\n if (!context && opts?.throwIfNotFound !== false) {\n throw new Error(\n `No Start context found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`,\n )\n }\n return context as any\n}\n"],"mappings":";;AAgCA,IAAM,qBAAqB,OAAO,IAAI,uCAAuC;AAE7E,IAAM,YAAY;AAIlB,IAAI,CAAC,UAAU,oBACb,WAAU,sBAAsB,IAAI,mBAAwC;AAG9E,IAAM,eAAe,UAAU;AAE/B,eAAsB,oBACpB,SACA,IACY;AACZ,QAAO,aAAa,IAAI,SAAS,GAAG;;AAGtC,SAAgB,gBAA+C,MAIvC;CACtB,MAAM,UAAU,aAAa,UAAU;AACvC,KAAI,CAAC,WAAW,MAAM,oBAAoB,MACxC,OAAM,IAAI,MACR,+GACD;AAEH,QAAO"}
{"version":3,"file":"async-local-storage.js","names":[],"sources":["../../src/async-local-storage.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type {\n Awaitable,\n ManifestRouteAssets,\n RegisteredRouter,\n} from '@tanstack/router-core'\n\nexport type StartHandlerType = 'router' | 'serverFn'\n\nexport interface StartStorageContext {\n getRouter: () => Awaitable<RegisteredRouter>\n request: Request\n // TODO type this properly\n startOptions: /* AnyStartInstanceOptions*/ any\n\n contextAfterGlobalMiddlewares: any\n // Track middlewares that have already executed in the request phase\n // to prevent duplicate execution\n executedRequestMiddlewares: Set<any>\n // Type of handler processing this request\n handlerType: StartHandlerType\n\n /**\n * Additional assets to inject for this request.\n * Plugins can add manifest route assets here during request processing.\n * Merged into manifest at dehydration time without mutating cached manifest.\n */\n requestAssets?: ManifestRouteAssets\n}\n\n// Use a global symbol to ensure the same AsyncLocalStorage instance is shared\n// across different bundles that may each bundle this module.\nconst GLOBAL_STORAGE_KEY = Symbol.for('tanstack-start:start-storage-context')\n\nconst globalObj = globalThis as typeof globalThis & {\n [GLOBAL_STORAGE_KEY]?: AsyncLocalStorage<StartStorageContext>\n}\n\nif (!globalObj[GLOBAL_STORAGE_KEY]) {\n globalObj[GLOBAL_STORAGE_KEY] = new AsyncLocalStorage<StartStorageContext>()\n}\n\nconst startStorage = globalObj[GLOBAL_STORAGE_KEY]\n\nexport async function runWithStartContext<T>(\n context: StartStorageContext,\n fn: () => T | Promise<T>,\n): Promise<T> {\n return startStorage.run(context, fn)\n}\n\nexport function getStartContext<TThrow extends boolean = true>(opts?: {\n throwIfNotFound?: TThrow\n}): TThrow extends false\n ? StartStorageContext | undefined\n : StartStorageContext {\n const context = startStorage.getStore()\n if (!context && opts?.throwIfNotFound !== false) {\n throw new Error(\n `No Start context found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`,\n )\n }\n return context as any\n}\n"],"mappings":";;AAgCA,IAAM,qBAAqB,OAAO,IAAI,uCAAuC;AAE7E,IAAM,YAAY;AAIlB,IAAI,CAAC,UAAU,oBACb,WAAU,sBAAsB,IAAI,mBAAwC;AAG9E,IAAM,eAAe,UAAU;AAE/B,eAAsB,oBACpB,SACA,IACY;AACZ,QAAO,aAAa,IAAI,SAAS,GAAG;;AAGtC,SAAgB,gBAA+C,MAIvC;CACtB,MAAM,UAAU,aAAa,UAAU;AACvC,KAAI,CAAC,WAAW,MAAM,oBAAoB,MACxC,OAAM,IAAI,MACR,+GACD;AAEH,QAAO"}
{
"name": "@tanstack/start-storage-context",
"version": "1.167.7",
"version": "1.167.8",
"description": "Modern and scalable routing for React applications",

@@ -46,3 +46,3 @@ "author": "Tanner Linsley",

"dependencies": {
"@tanstack/router-core": "1.171.5"
"@tanstack/router-core": "1.171.6"
},

@@ -49,0 +49,0 @@ "devDependencies": {

import { AsyncLocalStorage } from 'node:async_hooks'
import type {
Awaitable,
ManifestRouteAssets,
RegisteredRouter,
RouterManagedTag,
} from '@tanstack/router-core'

@@ -25,6 +25,6 @@

* Additional assets to inject for this request.
* Plugins can push RouterManagedTag items here during request processing.
* Plugins can add manifest route assets here during request processing.
* Merged into manifest at dehydration time without mutating cached manifest.
*/
requestAssets?: Array<RouterManagedTag>
requestAssets?: ManifestRouteAssets
}

@@ -31,0 +31,0 @@