@take-out/hooks 0.0.62 → 0.0.65
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/package.json +3 -3
- package/types/index.d.ts +14 -0
- package/types/index.d.ts.map +1 -0
- package/types/useClickOutside.d.ts +8 -0
- package/types/useClickOutside.d.ts.map +1 -0
- package/types/useDebouncePrepend.d.ts +4 -0
- package/types/useDebouncePrepend.d.ts.map +1 -0
- package/types/useDeepMemoizedObject.d.ts +8 -0
- package/types/useDeepMemoizedObject.d.ts.map +1 -0
- package/types/useDeepMemoizedObject.test.d.ts +2 -0
- package/types/useDeepMemoizedObject.test.d.ts.map +1 -0
- package/types/useDeferredBoolean.d.ts +2 -0
- package/types/useDeferredBoolean.d.ts.map +1 -0
- package/types/useEffectOnceGlobally.d.ts +11 -0
- package/types/useEffectOnceGlobally.d.ts.map +1 -0
- package/types/useEvent.d.ts +2 -0
- package/types/useEvent.d.ts.map +1 -0
- package/types/useIsMounted.d.ts +2 -0
- package/types/useIsMounted.d.ts.map +1 -0
- package/types/useLastValue.d.ts +2 -0
- package/types/useLastValue.d.ts.map +1 -0
- package/types/useLastValueIf.d.ts +2 -0
- package/types/useLastValueIf.d.ts.map +1 -0
- package/types/useMemoStable.d.ts +7 -0
- package/types/useMemoStable.d.ts.map +1 -0
- package/types/useMemoizedObjectList.d.ts +13 -0
- package/types/useMemoizedObjectList.d.ts.map +1 -0
- package/types/useThrottle.d.ts +2 -0
- package/types/useThrottle.d.ts.map +1 -0
- package/types/useWarnIfDepsChange.d.ts +7 -0
- package/types/useWarnIfDepsChange.d.ts.map +1 -0
- package/types/useWarnIfMemoChangesOften.d.ts +2 -0
- package/types/useWarnIfMemoChangesOften.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@take-out/hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/cjs",
|
|
8
8
|
"module": "dist/esm",
|
|
9
|
-
"types": "./
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"src",
|
|
12
12
|
"types",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-native": "*"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@tamagui/build": "2.0.0-rc.0-
|
|
46
|
+
"@tamagui/build": "2.0.0-rc.0-1769998500160",
|
|
47
47
|
"react": "*",
|
|
48
48
|
"react-native": "*"
|
|
49
49
|
},
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './useClickOutside';
|
|
2
|
+
export * from './useDebouncePrepend';
|
|
3
|
+
export * from './useDeepMemoizedObject';
|
|
4
|
+
export * from './useDeferredBoolean';
|
|
5
|
+
export * from './useEffectOnceGlobally';
|
|
6
|
+
export * from './useIsMounted';
|
|
7
|
+
export * from './useLastValue';
|
|
8
|
+
export * from './useLastValueIf';
|
|
9
|
+
export * from './useMemoizedObjectList';
|
|
10
|
+
export * from './useMemoStable';
|
|
11
|
+
export * from './useThrottle';
|
|
12
|
+
export * from './useWarnIfDepsChange';
|
|
13
|
+
export * from './useWarnIfMemoChangesOften';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type UseClickOutsideProps = {
|
|
2
|
+
ref: React.RefObject<HTMLElement | null>;
|
|
3
|
+
active: boolean;
|
|
4
|
+
onClickOutside?: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const useClickOutside: ({ ref, active, onClickOutside, }: UseClickOutsideProps) => void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=useClickOutside.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClickOutside.d.ts","sourceRoot":"","sources":["../src/useClickOutside.ts"],"names":[],"mappings":"AAGA,KAAK,oBAAoB,GAAG;IAC1B,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACxC,MAAM,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,kCAI7B,oBAAoB,SAoBtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncePrepend.d.ts","sourceRoot":"","sources":["../src/useDebouncePrepend.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS;IAAE,EAAE,EAAE,GAAG,CAAA;CAAE,EAAE,EACjE,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,GACZ,CAAC,CAwDH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ImmutableToNestedChanges = Record<string, boolean>;
|
|
2
|
+
export interface Options {
|
|
3
|
+
immutableToNestedChanges?: ImmutableToNestedChanges;
|
|
4
|
+
}
|
|
5
|
+
export declare function shouldBeImmutable(path: string[], immutableToNestedChanges?: ImmutableToNestedChanges): boolean;
|
|
6
|
+
export declare function deepMemoize<T>(current: T, previous: T, path?: string[], immutableToNestedChanges?: ImmutableToNestedChanges): T;
|
|
7
|
+
export declare function useDeepMemoizedObject<T>(value: T, options?: Options): T;
|
|
8
|
+
//# sourceMappingURL=useDeepMemoizedObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeepMemoizedObject.d.ts","sourceRoot":"","sources":["../src/useDeepMemoizedObject.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE9D,MAAM,WAAW,OAAO;IACtB,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;CACpD;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EAAE,EACd,wBAAwB,CAAC,EAAE,wBAAwB,GAClD,OAAO,CAUT;AAwKD,wBAAgB,WAAW,CAAC,CAAC,EAC3B,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,CAAC,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,wBAAwB,CAAC,EAAE,wBAAwB,GAClD,CAAC,CAqBH;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAavE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeepMemoizedObject.test.d.ts","sourceRoot":"","sources":["../src/useDeepMemoizedObject.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeferredBoolean.d.ts","sourceRoot":"","sources":["../src/useDeferredBoolean.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,OAYnD,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type WithId = {
|
|
2
|
+
id: string;
|
|
3
|
+
};
|
|
4
|
+
type KeyType<T> = string | string[] | WithId | WithId[] | readonly WithId[] | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Hook that ensures an effect only runs once globally across all component instances
|
|
7
|
+
* Uses a key (or array of keys) to determine if the effect has already been executed
|
|
8
|
+
*/
|
|
9
|
+
export declare function useEffectOnceGlobally<T extends KeyType<T>>(key: T, callback: T extends undefined ? () => void : (value: NonNullable<T>) => void): void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=useEffectOnceGlobally.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEffectOnceGlobally.d.ts","sourceRoot":"","sources":["../src/useEffectOnceGlobally.ts"],"names":[],"mappings":"AAIA,KAAK,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5B,KAAK,OAAO,CAAC,CAAC,IAAI,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;AAEvF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EACxD,GAAG,EAAE,CAAC,EACN,QAAQ,EAAE,CAAC,SAAS,SAAS,GAAG,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,QA0B7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEvent.d.ts","sourceRoot":"","sources":["../src/useEvent.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAIpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMounted.d.ts","sourceRoot":"","sources":["../src/useIsMounted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,eAQxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLastValue.d.ts","sourceRoot":"","sources":["../src/useLastValue.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAEvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLastValueIf.d.ts","sourceRoot":"","sources":["../src/useLastValueIf.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,UAAO,GAAG,CAAC,GAAG,SAAS,CAY1E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface UseMemoStableOptions {
|
|
2
|
+
maxChanges?: number;
|
|
3
|
+
ignoreIndexBefore?: number;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function useMemoStable<Value, T extends readonly unknown[]>(getValue: () => Value, deps: T, options?: UseMemoStableOptions): Value;
|
|
7
|
+
//# sourceMappingURL=useMemoStable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMemoStable.d.ts","sourceRoot":"","sources":["../src/useMemoStable.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,SAAS,SAAS,OAAO,EAAE,EAC/D,QAAQ,EAAE,MAAM,KAAK,EACrB,IAAI,EAAE,CAAC,EACP,OAAO,GAAE,oBAER,GACA,KAAK,CAKP"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When zero mutates and inserts, it creates all new objects for everything, but this
|
|
3
|
+
* breaks react memoization, even when only the last item is mutated, or the last item
|
|
4
|
+
* is inserted. This hook should be considered temporary, I've brought up the idea with
|
|
5
|
+
* the zero team to implement this internally, as that would be significantly faster.
|
|
6
|
+
*
|
|
7
|
+
* for now, this basically will re-use the last message if JSON.stringify says its the same
|
|
8
|
+
* that way you skip a lot of re-rendering work when changing long lists of items
|
|
9
|
+
*
|
|
10
|
+
* NOTE: this leaks memory
|
|
11
|
+
*/
|
|
12
|
+
export declare function useMemoizedObjectList<Items extends readonly object[], Item extends Items[0] = Items[0], ItemKey extends keyof Item = keyof Item>(list: Items, identityKey: ItemKey): Items;
|
|
13
|
+
//# sourceMappingURL=useMemoizedObjectList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMemoizedObjectList.d.ts","sourceRoot":"","sources":["../src/useMemoizedObjectList.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,SAAS,SAAS,MAAM,EAAE,EAC/B,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAChC,OAAO,SAAS,MAAM,IAAI,GAAG,MAAM,IAAI,EACvC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,GAAG,KAAK,CAuD1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThrottle.d.ts","sourceRoot":"","sources":["../src/useThrottle.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,CAAC,EAAE,cAAW,KAAG,CA6BnF,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface UseWarnIfDepsChangeOptions {
|
|
2
|
+
maxChanges?: number;
|
|
3
|
+
ignoreIndexBefore?: number;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function useWarnIfDepsChange<T extends readonly unknown[]>(deps: T, options: UseWarnIfDepsChangeOptions): void;
|
|
7
|
+
//# sourceMappingURL=useWarnIfDepsChange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWarnIfDepsChange.d.ts","sourceRoot":"","sources":["../src/useWarnIfDepsChange.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,0BAA0B;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAC9D,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,0BAA0B,GAClC,IAAI,CAgDN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWarnIfMemoChangesOften.d.ts","sourceRoot":"","sources":["../src/useWarnIfMemoChangesOften.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,GAG/B,CAAC,SAAS,CAAC,6BAAwB,MAAM,SAiBzC,CAAA"}
|