@dynamic-labs/react-hooks 2.1.0-alpha.0 → 2.1.0-alpha.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/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useRef, useState, useCallback, useEffect, useMemo, useContext, createContext } from 'react';
1
+ import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
3
2
  import { effect, stop } from '@vue/reactivity';
4
3
 
5
4
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -1621,28 +1620,4 @@ const useReactivityProxy = target => {
1621
1620
  }, [target]);
1622
1621
  };
1623
1622
 
1624
- const dynamicClientContext = /*#__PURE__*/createContext(undefined);
1625
- const DynamicClientProvider = ({
1626
- client,
1627
- children
1628
- }) => jsx(dynamicClientContext.Provider, {
1629
- value: {
1630
- client
1631
- },
1632
- children: children
1633
- });
1634
- const useDynamicClient = ({
1635
- watch: _watch = true
1636
- } = {}) => {
1637
- const context = useContext(dynamicClientContext);
1638
- if (context === undefined) {
1639
- throw new Error('useDynamicClient must be used within a DynamicClientProvider');
1640
- }
1641
- const reactiveClient = useReactivityProxy(context.client);
1642
- if (_watch) {
1643
- return reactiveClient;
1644
- }
1645
- return context.client;
1646
- };
1647
-
1648
- export { DynamicClientProvider, useDynamicClient };
1623
+ export { useReactivityProxy as useReactiveClient };
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "@dynamic-labs/react-hooks",
3
- "version": "2.1.0-alpha.0",
4
- "peerDependencies": {
5
- "react": "^18.0.0",
6
- "@vue/reactivity": "^3.4.21",
7
- "@dynamic-labs/client": "2.1.0-alpha.0"
8
- },
9
- "module": "./index.js",
3
+ "version": "2.1.0-alpha.2",
10
4
  "main": "./index.js",
11
- "type": "module",
5
+ "module": "./index.js",
12
6
  "types": "./src/index.d.ts",
13
- "dependencies": {}
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "import": "./src/index.js",
12
+ "require": "./src/index.cjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "dependencies": {
17
+ "@vue/reactivity": "3.4.21"
18
+ },
19
+ "peerDependencies": {
20
+ "react": "^18.0.0"
21
+ }
14
22
  }
package/src/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export type { DefaultClient } from './lib/types/DefaultClient';
2
- export { DynamicClientProvider, useDynamicClient, } from './lib/context/DynamicClientContext';
1
+ export { useReactivityProxy as useReactiveClient } from './hooks/useReactivityProxy';
@@ -1,11 +0,0 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- import { DefaultClient } from '../types/DefaultClient';
3
- type DynamicClientProviderProps = {
4
- client: DefaultClient;
5
- };
6
- export declare const DynamicClientProvider: FC<PropsWithChildren<DynamicClientProviderProps>>;
7
- type UseDynamicClientProps = {
8
- watch?: boolean;
9
- };
10
- export declare const useDynamicClient: ({ watch, }?: UseDynamicClientProps) => DefaultClient;
11
- export {};
@@ -1,2 +0,0 @@
1
- import { createClient } from '@dynamic-labs/client';
2
- export type DefaultClient = ReturnType<typeof createClient>;