Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tamagui/use-did-finish-ssr

Package Overview
Dependencies
Maintainers
1
Versions
929
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tamagui/use-did-finish-ssr - npm Package Compare versions

Comparing version 1.99.1 to 1.100.0

25

dist/cjs/index.js

@@ -18,3 +18,4 @@ var __defProp = Object.defineProperty;

useClientValue: () => useClientValue,
useDidFinishSSR: () => useDidFinishSSR
useDidFinishSSR: () => useDidFinishSSR,
useDidFinishSSRSync: () => useDidFinishSSRSync
});

@@ -25,9 +26,19 @@ module.exports = __toCommonJS(src_exports);

}, emptyFnFn = () => emptyFn;
function useDidFinishSSR(value) {
return (0, import_react.useSyncExternalStore)(
emptyFnFn,
() => value ?? !0,
() => !1
);
function useDidFinishSSR(value, options) {
if (options?.sync)
return (0, import_react.useSyncExternalStore)(
emptyFnFn,
() => value ?? !0,
() => !1
);
const [cur, setCur] = (0, import_react.useState)(value);
return (0, import_react.useEffect)(() => {
setCur(value ?? !0);
}, []), cur ?? !1;
}
function useDidFinishSSRSync(value) {
return useDidFinishSSR(value, {
sync: !0
});
}
function useClientValue(value) {

@@ -34,0 +45,0 @@ return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;

@@ -19,12 +19,61 @@ "use strict";

useClientValue: () => useClientValue,
useDidFinishSSR: () => useDidFinishSSR
useDidFinishSSR: () => useDidFinishSSR,
useDidFinishSSRSync: () => useDidFinishSSRSync
});
module.exports = __toCommonJS(src_exports);
var import_react = require("react"), emptyFn = function() {
var import_react = require("react");
function _array_like_to_array(arr, len) {
(len == null || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i != null) {
var _arr = [], _n = !0, _d = !1, _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
;
} catch (err) {
_d = !0, _e = err;
} finally {
try {
!_n && _i.return != null && _i.return();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (o) {
if (typeof o == "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
}
var emptyFn = function() {
}, emptyFnFn = function() {
return emptyFn;
};
function useDidFinishSSR(value) {
function useDidFinishSSR(value, options) {
return value ?? !0;
var _useState, cur, setCur;
}
function useDidFinishSSRSync(value) {
return useDidFinishSSR(value, {
sync: !0
});
}
function useClientValue(value) {

@@ -37,4 +86,5 @@ var done = useDidFinishSSR();

useClientValue,
useDidFinishSSR
useDidFinishSSR,
useDidFinishSSRSync
});
//# sourceMappingURL=index.js.map

@@ -1,11 +0,21 @@

import { useSyncExternalStore } from "react";
import { useEffect, useState, useSyncExternalStore } from "react";
const emptyFn = () => {
}, emptyFnFn = () => emptyFn;
function useDidFinishSSR(value) {
return useSyncExternalStore(
emptyFnFn,
() => value ?? !0,
() => !1
);
function useDidFinishSSR(value, options) {
if (options?.sync)
return useSyncExternalStore(
emptyFnFn,
() => value ?? !0,
() => !1
);
const [cur, setCur] = useState(value);
return useEffect(() => {
setCur(value ?? !0);
}, []), cur ?? !1;
}
function useDidFinishSSRSync(value) {
return useDidFinishSSR(value, {
sync: !0
});
}
function useClientValue(value) {

@@ -16,4 +26,5 @@ return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;

useClientValue,
useDidFinishSSR
useDidFinishSSR,
useDidFinishSSRSync
};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,43 @@

import { useSyncExternalStore } from "react";
import { useEffect, useState, useSyncExternalStore } from "react";
function _array_like_to_array(arr, len) {
(len == null || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i != null) {
var _arr = [], _n = !0, _d = !1, _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
;
} catch (err) {
_d = !0, _e = err;
} finally {
try {
!_n && _i.return != null && _i.return();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (o) {
if (typeof o == "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
}
var emptyFn = function() {

@@ -6,5 +47,11 @@ }, emptyFnFn = function() {

};
function useDidFinishSSR(value) {
function useDidFinishSSR(value, options) {
return value ?? !0;
var _useState, cur, setCur;
}
function useDidFinishSSRSync(value) {
return useDidFinishSSR(value, {
sync: !0
});
}
function useClientValue(value) {

@@ -16,4 +63,5 @@ var done = useDidFinishSSR();

useClientValue,
useDidFinishSSR
useDidFinishSSR,
useDidFinishSSRSync
};
//# sourceMappingURL=index.js.map
{
"name": "@tamagui/use-did-finish-ssr",
"version": "1.99.1",
"version": "1.100.0",
"types": "./types/index.d.ts",

@@ -30,6 +30,6 @@ "main": "dist/cjs",

"dependencies": {
"@tamagui/constants": "1.99.1"
"@tamagui/constants": "1.100.0"
},
"devDependencies": {
"@tamagui/build": "1.99.1",
"@tamagui/build": "1.100.0",
"react": "^18.2.0"

@@ -36,0 +36,0 @@ },

@@ -1,2 +0,2 @@

import { useSyncExternalStore } from 'react'
import { useEffect, useState, useSyncExternalStore } from 'react'

@@ -6,3 +6,8 @@ const emptyFn = () => {}

export function useDidFinishSSR<A = boolean>(value?: A): A | false {
export function useDidFinishSSR<A = boolean>(
value?: A,
options?: {
sync?: boolean
}
): A | false {
if (process.env.TAMAGUI_TARGET === 'native') {

@@ -13,9 +18,26 @@ // @ts-expect-error

return useSyncExternalStore(
emptyFnFn,
() => (value == undefined ? true : value),
() => false as any
)
if (options?.sync) {
return useSyncExternalStore(
emptyFnFn,
() => (value == undefined ? true : value),
() => false as any
)
}
const [cur, setCur] = useState<any>(value)
useEffect(() => {
setCur(value ?? true)
}, [])
return cur ?? false
}
// const useIsomorphicLayoutEffect =
// typeof window === 'undefined' ? useEffect : useLayoutEffect
export function useDidFinishSSRSync<A = boolean>(value?: A): A | false {
return useDidFinishSSR(value, {
sync: true,
})
}
type FunctionOrValue<Value> = Value extends () => infer X ? X : Value

@@ -22,0 +44,0 @@

@@ -1,2 +0,5 @@

export declare function useDidFinishSSR<A = boolean>(value?: A): A | false;
export declare function useDidFinishSSR<A = boolean>(value?: A, options?: {
sync?: boolean;
}): A | false;
export declare function useDidFinishSSRSync<A = boolean>(value?: A): A | false;
type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;

@@ -3,0 +6,0 @@ export declare function useClientValue<Value>(value?: Value): FunctionOrValue<Value> | undefined;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc