signalium 1.0.1 → 1.0.2
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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +6 -0
- package/dist/cjs/react/signal-value.js +7 -8
- package/dist/cjs/react/signal-value.js.map +1 -1
- package/dist/esm/react/signal-value.js +7 -8
- package/dist/esm/react/signal-value.js.map +1 -1
- package/package.json +1 -1
- package/src/react/signal-value.ts +10 -10
package/.turbo/turbo-build.log
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
|
2
|
-
> signalium@1.0.
|
2
|
+
> signalium@1.0.2 build
|
3
3
|
> npm run build:esm && npm run build:cjs
|
4
4
|
|
5
5
|
|
6
|
-
> signalium@1.0.
|
6
|
+
> signalium@1.0.2 build:esm
|
7
7
|
> tsc
|
8
8
|
|
9
9
|
|
10
|
-
> signalium@1.0.
|
10
|
+
> signalium@1.0.2 build:cjs
|
11
11
|
> tsc --module commonjs --outDir dist/cjs --moduleResolution node
|
12
12
|
|
package/CHANGELOG.md
CHANGED
@@ -46,16 +46,15 @@ const async_js_1 = require("../internals/async.js");
|
|
46
46
|
const REACT_INTERNALS = react_1.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ||
|
47
47
|
react_1.default.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ||
|
48
48
|
react_1.default.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
49
|
+
const IS_REACT_18 = !!REACT_INTERNALS.ReactCurrentDispatcher;
|
49
50
|
const ReactCurrentDispatcher = REACT_INTERNALS.ReactCurrentDispatcher || REACT_INTERNALS;
|
50
|
-
const ReactCurrentOwner = REACT_INTERNALS.ReactCurrentOwner || REACT_INTERNALS;
|
51
|
-
const getReactCurrentDispatcher = () => {
|
52
|
-
return ReactCurrentDispatcher.current || REACT_INTERNALS.H;
|
53
|
-
};
|
54
|
-
const getReactCurrentOwner = () => {
|
55
|
-
return ReactCurrentOwner.current || REACT_INTERNALS.A;
|
56
|
-
};
|
57
51
|
function isRendering() {
|
58
|
-
|
52
|
+
const dispatcher = IS_REACT_18 ? ReactCurrentDispatcher.current : ReactCurrentDispatcher.H;
|
53
|
+
return (!!dispatcher &&
|
54
|
+
// dispatcher can be in a state where it's defined, but all hooks are invalid to call.
|
55
|
+
// Only way we can tell is that if they are invalid, they will all be equal to each other
|
56
|
+
// (e.g. because it's the function that throws an error)
|
57
|
+
dispatcher.useState !== dispatcher.useEffect);
|
59
58
|
}
|
60
59
|
function useStateSignal(signal) {
|
61
60
|
if (!isRendering()) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signal-value.js","sourceRoot":"","sources":["../../../src/react/signal-value.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,wCAUC;AAED,4CA4BC;AAxED,+CAA+C;AAC/C,+CAAiE;AAIjE,oEAAqE;AACrE,oDAA+D;AAE/D,wFAAwF;AACxF,oFAAoF;AACpF,mFAAmF;AACnF,0DAA0D;AAC1D,MAAM,eAAe,GAClB,eAAa,CAAC,kDAAkD;IAChE,eAAa,CAAC,+DAA+D;IAC7E,eAAa,CAAC,+DAA+D,CAAC;AAEjF,MAAM,
|
1
|
+
{"version":3,"file":"signal-value.js","sourceRoot":"","sources":["../../../src/react/signal-value.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,wCAUC;AAED,4CA4BC;AAxED,+CAA+C;AAC/C,+CAAiE;AAIjE,oEAAqE;AACrE,oDAA+D;AAE/D,wFAAwF;AACxF,oFAAoF;AACpF,mFAAmF;AACnF,0DAA0D;AAC1D,MAAM,eAAe,GAClB,eAAa,CAAC,kDAAkD;IAChE,eAAa,CAAC,+DAA+D;IAC7E,eAAa,CAAC,+DAA+D,CAAC;AAEjF,MAAM,WAAW,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,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,IAAA,iCAAiB,EAAC,KAAK,CAAC,EAAE,CAAC;QAC5E,IAAI,IAAA,iCAAsB,EAAC,KAAK,CAAC,EAAE,CAAC;YAClC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAkC,CAAC,CAAC;QACtE,CAAC;QAED,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,KAAyB,CAAC;AACnC,CAAC"}
|
@@ -9,16 +9,15 @@ import { isReactiveSubscription } from '../internals/async.js';
|
|
9
9
|
const REACT_INTERNALS = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ||
|
10
10
|
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ||
|
11
11
|
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
12
|
+
const IS_REACT_18 = !!REACT_INTERNALS.ReactCurrentDispatcher;
|
12
13
|
const ReactCurrentDispatcher = REACT_INTERNALS.ReactCurrentDispatcher || REACT_INTERNALS;
|
13
|
-
const ReactCurrentOwner = REACT_INTERNALS.ReactCurrentOwner || REACT_INTERNALS;
|
14
|
-
const getReactCurrentDispatcher = () => {
|
15
|
-
return ReactCurrentDispatcher.current || REACT_INTERNALS.H;
|
16
|
-
};
|
17
|
-
const getReactCurrentOwner = () => {
|
18
|
-
return ReactCurrentOwner.current || REACT_INTERNALS.A;
|
19
|
-
};
|
20
14
|
function isRendering() {
|
21
|
-
|
15
|
+
const dispatcher = IS_REACT_18 ? ReactCurrentDispatcher.current : ReactCurrentDispatcher.H;
|
16
|
+
return (!!dispatcher &&
|
17
|
+
// dispatcher can be in a state where it's defined, but all hooks are invalid to call.
|
18
|
+
// Only way we can tell is that if they are invalid, they will all be equal to each other
|
19
|
+
// (e.g. because it's the function that throws an error)
|
20
|
+
dispatcher.useState !== dispatcher.useEffect);
|
22
21
|
}
|
23
22
|
export function useStateSignal(signal) {
|
24
23
|
if (!isRendering()) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signal-value.js","sourceRoot":"","sources":["../../../src/react/signal-value.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,wFAAwF;AACxF,oFAAoF;AACpF,mFAAmF;AACnF,0DAA0D;AAC1D,MAAM,eAAe,GAClB,KAAa,CAAC,kDAAkD;IAChE,KAAa,CAAC,+DAA+D;IAC7E,KAAa,CAAC,+DAA+D,CAAC;AAEjF,MAAM,
|
1
|
+
{"version":3,"file":"signal-value.js","sourceRoot":"","sources":["../../../src/react/signal-value.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,wFAAwF;AACxF,oFAAoF;AACpF,mFAAmF;AACnF,0DAA0D;AAC1D,MAAM,eAAe,GAClB,KAAa,CAAC,kDAAkD;IAChE,KAAa,CAAC,+DAA+D;IAC7E,KAAa,CAAC,+DAA+D,CAAC;AAEjF,MAAM,WAAW,GAAG,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC;AAC7D,MAAM,sBAAsB,GAAG,eAAe,CAAC,sBAAsB,IAAI,eAAe,CAAC;AAEzF,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,C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AU,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,KAAyB,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
@@ -15,19 +15,19 @@ const REACT_INTERNALS =
|
|
15
15
|
(React as any).__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ||
|
16
16
|
(React as any).__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
17
17
|
|
18
|
+
const IS_REACT_18 = !!REACT_INTERNALS.ReactCurrentDispatcher;
|
18
19
|
const ReactCurrentDispatcher = REACT_INTERNALS.ReactCurrentDispatcher || REACT_INTERNALS;
|
19
|
-
const ReactCurrentOwner = REACT_INTERNALS.ReactCurrentOwner || REACT_INTERNALS;
|
20
|
-
|
21
|
-
const getReactCurrentDispatcher = () => {
|
22
|
-
return ReactCurrentDispatcher.current || REACT_INTERNALS.H;
|
23
|
-
};
|
24
|
-
|
25
|
-
const getReactCurrentOwner = () => {
|
26
|
-
return ReactCurrentOwner.current || REACT_INTERNALS.A;
|
27
|
-
};
|
28
20
|
|
29
21
|
function isRendering() {
|
30
|
-
|
22
|
+
const dispatcher = IS_REACT_18 ? ReactCurrentDispatcher.current : ReactCurrentDispatcher.H;
|
23
|
+
|
24
|
+
return (
|
25
|
+
!!dispatcher &&
|
26
|
+
// dispatcher can be in a state where it's defined, but all hooks are invalid to call.
|
27
|
+
// Only way we can tell is that if they are invalid, they will all be equal to each other
|
28
|
+
// (e.g. because it's the function that throws an error)
|
29
|
+
dispatcher.useState !== dispatcher.useEffect
|
30
|
+
);
|
31
31
|
}
|
32
32
|
|
33
33
|
export function useStateSignal<T>(signal: StateSignal<T>): T {
|