-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: use singleton globals * chore: update
- Loading branch information
1 parent
a110001
commit c8aeca4
Showing
6 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@zag-js/preact": patch | ||
"@zag-js/react": patch | ||
"@zag-js/store": patch | ||
--- | ||
|
||
Fix issue where multiple versions of @zag-js/store could lead to "proxy state is not iterable" errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function getGlobal(): any { | ||
if (typeof globalThis !== "undefined") return globalThis | ||
if (typeof self !== "undefined") return self | ||
if (typeof window !== "undefined") return window | ||
if (typeof global !== "undefined") return global | ||
} | ||
|
||
export function makeGlobal<T>(key: string, value: () => T): T { | ||
const g = getGlobal() | ||
if (!g) return value() | ||
g[key] ||= value() | ||
return g[key] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { proxy, ref, snapshot, subscribe, type Snapshot, type Ref } from "./proxy" | ||
export { makeGlobal } from "./global" | ||
export { proxy, ref, snapshot, subscribe, type Ref, type Snapshot } from "./proxy" | ||
export { proxyWithComputed } from "./proxy-computed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters