Skip to content

Commit

Permalink
fix #1927, fix #1929, fix #1931, update storage API
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Oct 26, 2023
1 parent 3f3a339 commit cf0542a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 39 deletions.
6 changes: 6 additions & 0 deletions .changeset/chatty-chefs-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"babel-preset-solid": patch
"solid-js": patch
---

fix #1927, fix #1929, fix #1931, update storage API
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@
"@rollup/plugin-replace": "^5.0.2",
"@types/node": "^18.11.19",
"@vitest/coverage-c8": "^0.29.7",
"babel-plugin-jsx-dom-expressions": "^0.37.2",
"babel-plugin-jsx-dom-expressions": "^0.37.8",
"coveralls": "^3.1.1",
"csstype": "^3.1.0",
"dom-expressions": "0.37.6",
"hyper-dom-expressions": "0.37.6",
"dom-expressions": "0.37.8",
"hyper-dom-expressions": "0.37.8",
"jsdom": "^21.1.1",
"lit-dom-expressions": "0.37.6",
"lit-dom-expressions": "0.37.8",
"ncp": "^2.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"rimraf": "^3.0.2",
"rollup": "^3.7.5",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-copy": "^3.4.0",
"seroval": "^0.11.6",
"seroval": "^0.12.0",
"simple-git-hooks": "^2.8.1",
"symlink-dir": "^5.0.1",
"tsconfig-replace-paths": "^0.0.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "node test.js"
},
"dependencies": {
"babel-plugin-jsx-dom-expressions": "^0.37.2"
"babel-plugin-jsx-dom-expressions": "^0.37.8"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@
],
"dependencies": {
"csstype": "^3.1.0",
"seroval": "^0.11.6"
"seroval": "^0.12.0"
}
}
6 changes: 2 additions & 4 deletions packages/solid/web/storage/storage.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/// <reference types="node" />
import { AsyncLocalStorage } from "node:async_hooks";
import type { RequestEvent } from "../server";
export default function initializeServerStorage<T extends RequestEvent>(): AsyncLocalStorage<T>;
import type { RequestEvent } from "solid-js/web";
export function provideRequestEvent<T extends RequestEvent, U>(init: T, cb: () => U): U;
5 changes: 3 additions & 2 deletions packages/solid/web/storage/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import type { RequestEvent } from "solid-js/web";
import { isServer, RequestContext } from "solid-js/web";

// using global on a symbol for locating it later and detaching for environments that don't support it.
export default function initializeServerStorage<T extends RequestEvent>(): AsyncLocalStorage<T> {
export function provideRequestEvent<T extends RequestEvent, U>(init: T, cb: () => U): U {
if (!isServer) throw new Error("Attempting to use server context in non-server build");
return ((globalThis as any)[RequestContext] =
const ctx: AsyncLocalStorage<T> = ((globalThis as any)[RequestContext] =
(globalThis as any)[RequestContext] || new AsyncLocalStorage<T>());
return ctx.run(init, cb);
}
52 changes: 26 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf0542a

Please sign in to comment.