@tanstack/start-storage-context 1.131.5 → 1.132.0-alpha.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.
- package/dist/esm/async-local-storage.js +1 -1
- package/dist/esm/async-local-storage.js.map +1 -1
- package/package.json +2 -6
- package/dist/cjs/async-local-storage.cjs +0 -19
- package/dist/cjs/async-local-storage.cjs.map +0 -1
- package/dist/cjs/async-local-storage.d.cts +0 -8
- package/dist/cjs/index.cjs +0 -6
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -2
|
@@ -5,7 +5,7 @@ async function runWithStartContext(context, fn) {
|
|
|
5
5
|
}
|
|
6
6
|
function getStartContext(opts) {
|
|
7
7
|
const context = startStorage.getStore();
|
|
8
|
-
if (!context &&
|
|
8
|
+
if (!context && opts?.throwIfNotFound !== false) {
|
|
9
9
|
throw new Error(
|
|
10
10
|
`No Start context found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`
|
|
11
11
|
);
|
|
@@ -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 { AnyRouter } from '@tanstack/router-core'\n\nexport interface StartStorageContext {\n router: AnyRouter\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":";AAOA,MAAM,eAAe,IAAI,
|
|
1
|
+
{"version":3,"file":"async-local-storage.js","sources":["../../src/async-local-storage.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport interface StartStorageContext {\n router: AnyRouter\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":";AAOA,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.
|
|
3
|
+
"version": "1.132.0-alpha.0",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,10 +30,6 @@
|
|
|
30
30
|
"import": {
|
|
31
31
|
"types": "./dist/esm/index.d.ts",
|
|
32
32
|
"default": "./dist/esm/index.js"
|
|
33
|
-
},
|
|
34
|
-
"require": {
|
|
35
|
-
"types": "./dist/cjs/index.d.cts",
|
|
36
|
-
"default": "./dist/cjs/index.cjs"
|
|
37
33
|
}
|
|
38
34
|
},
|
|
39
35
|
"./package.json": "./package.json"
|
|
@@ -47,7 +43,7 @@
|
|
|
47
43
|
"node": ">=12"
|
|
48
44
|
},
|
|
49
45
|
"dependencies": {
|
|
50
|
-
"@tanstack/router-core": "1.
|
|
46
|
+
"@tanstack/router-core": "1.132.0-alpha.0"
|
|
51
47
|
},
|
|
52
48
|
"scripts": {}
|
|
53
49
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const node_async_hooks = require("node:async_hooks");
|
|
4
|
-
const startStorage = new node_async_hooks.AsyncLocalStorage();
|
|
5
|
-
async function runWithStartContext(context, fn) {
|
|
6
|
-
return startStorage.run(context, fn);
|
|
7
|
-
}
|
|
8
|
-
function getStartContext(opts) {
|
|
9
|
-
const context = startStorage.getStore();
|
|
10
|
-
if (!context && (opts == null ? void 0 : opts.throwIfNotFound) !== false) {
|
|
11
|
-
throw new Error(
|
|
12
|
-
`No Start context found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
}
|
|
17
|
-
exports.getStartContext = getStartContext;
|
|
18
|
-
exports.runWithStartContext = runWithStartContext;
|
|
19
|
-
//# sourceMappingURL=async-local-storage.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-local-storage.cjs","sources":["../../src/async-local-storage.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport interface StartStorageContext {\n router: AnyRouter\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":["AsyncLocalStorage"],"mappings":";;;AAOA,MAAM,eAAe,IAAIA,iBAAAA,kBAAuC;AAE1C,eAAA,oBACpB,SACA,IACY;AACL,SAAA,aAAa,IAAI,SAAS,EAAE;AACrC;AAEO,SAAS,gBAA+C,MAIvC;AAChB,QAAA,UAAU,aAAa,SAAS;AACtC,MAAI,CAAC,YAAW,6BAAM,qBAAoB,OAAO;AAC/C,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEK,SAAA;AACT;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AnyRouter } from '@tanstack/router-core';
|
|
2
|
-
export interface StartStorageContext {
|
|
3
|
-
router: AnyRouter;
|
|
4
|
-
}
|
|
5
|
-
export declare function runWithStartContext<T>(context: StartStorageContext, fn: () => T | Promise<T>): Promise<T>;
|
|
6
|
-
export declare function getStartContext<TThrow extends boolean = true>(opts?: {
|
|
7
|
-
throwIfNotFound?: TThrow;
|
|
8
|
-
}): TThrow extends false ? StartStorageContext | undefined : StartStorageContext;
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const asyncLocalStorage = require("./async-local-storage.cjs");
|
|
4
|
-
exports.getStartContext = asyncLocalStorage.getStartContext;
|
|
5
|
-
exports.runWithStartContext = asyncLocalStorage.runWithStartContext;
|
|
6
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/cjs/index.d.cts
DELETED