@tanstack/start-storage-context 1.132.0-alpha.4 → 1.132.0
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,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Awaitable, RegisteredRouter } from '@tanstack/router-core';
|
|
2
2
|
export interface StartStorageContext {
|
|
3
|
-
|
|
3
|
+
getRouter: () => Awaitable<RegisteredRouter>;
|
|
4
|
+
startOptions: any;
|
|
5
|
+
contextAfterGlobalMiddlewares: any;
|
|
4
6
|
}
|
|
5
7
|
export declare function runWithStartContext<T>(context: StartStorageContext, fn: () => T | Promise<T>): Promise<T>;
|
|
6
8
|
export declare function getStartContext<TThrow extends boolean = true>(opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-local-storage.js","sources":["../../src/async-local-storage.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type {
|
|
1
|
+
{"version":3,"file":"async-local-storage.js","sources":["../../src/async-local-storage.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type { Awaitable, RegisteredRouter } from '@tanstack/router-core'\n\nexport interface StartStorageContext {\n getRouter: () => Awaitable<RegisteredRouter>\n\n // TODO type this properly\n startOptions: /* AnyStartInstanceOptions*/ any\n\n contextAfterGlobalMiddlewares: any\n}\n\nconst startStorage = new AsyncLocalStorage<StartStorageContext>()\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"],"names":[],"mappings":";AAYA,MAAM,eAAe,IAAI,kBAAA;AAEzB,eAAsB,oBACpB,SACA,IACY;AACZ,SAAO,aAAa,IAAI,SAAS,EAAE;AACrC;AAEO,SAAS,gBAA+C,MAIvC;AACtB,QAAM,UAAU,aAAa,SAAA;AAC7B,MAAI,CAAC,WAAW,MAAM,oBAAoB,OAAO;AAC/C,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/start-storage-context",
|
|
3
|
-
"version": "1.132.0
|
|
3
|
+
"version": "1.132.0",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"src"
|
|
41
41
|
],
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=12"
|
|
43
|
+
"node": ">=22.12.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@tanstack/router-core": "1.132.0
|
|
46
|
+
"@tanstack/router-core": "1.132.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {}
|
|
49
49
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
2
|
-
import type {
|
|
2
|
+
import type { Awaitable, RegisteredRouter } from '@tanstack/router-core'
|
|
3
3
|
|
|
4
4
|
export interface StartStorageContext {
|
|
5
|
-
|
|
5
|
+
getRouter: () => Awaitable<RegisteredRouter>
|
|
6
|
+
|
|
7
|
+
// TODO type this properly
|
|
8
|
+
startOptions: /* AnyStartInstanceOptions*/ any
|
|
9
|
+
|
|
10
|
+
contextAfterGlobalMiddlewares: any
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
const startStorage = new AsyncLocalStorage<StartStorageContext>()
|