@wix/sdk-react 0.1.4 → 0.1.6

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.
@@ -1,9 +1,9 @@
1
1
  // src/index.tsx
2
- import * as React from "react";
3
- import { createContext, useEffect, useMemo } from "react";
4
2
  import {
5
3
  createClient
6
4
  } from "@wix/sdk";
5
+ import * as React from "react";
6
+ import { createContext, useEffect, useMemo } from "react";
7
7
  export * from "@wix/sdk";
8
8
  var WixContext = createContext(void 0);
9
9
  var HostEnvironmentContext = createContext(void 0);
@@ -47,6 +47,10 @@ function useWix() {
47
47
  }
48
48
  return sdk;
49
49
  }
50
+ function useWixFetch() {
51
+ const sdk = useWix();
52
+ return sdk.fetch;
53
+ }
50
54
  function useWixAuth() {
51
55
  const sdk = useWix();
52
56
  return sdk.auth;
@@ -69,5 +73,6 @@ export {
69
73
  useEnvironment,
70
74
  useWix,
71
75
  useWixAuth,
76
+ useWixFetch,
72
77
  useWixModules
73
78
  };
package/build/index.d.mts CHANGED
@@ -1,15 +1,16 @@
1
- import * as React from 'react';
2
- import { Descriptors, Host, AuthenticationStrategy, AssertHostMatches, WixClient, BuildDescriptors } from '@wix/sdk';
1
+ import { Host, Descriptors, AuthenticationStrategy, AssertHostMatches, WixClient, BuildDescriptors } from '@wix/sdk';
3
2
  export * from '@wix/sdk';
3
+ import * as React from 'react';
4
4
 
5
- declare function WixProvider<T extends Descriptors<H>, H extends Host<any> = Host>(props: React.PropsWithChildren<{
5
+ declare function WixProvider<H extends Host<any> | undefined = undefined, T extends Descriptors = Descriptors>(props: React.PropsWithChildren<{
6
6
  auth?: AuthenticationStrategy<H>;
7
- modules?: AssertHostMatches<T, H>;
7
+ modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
8
8
  host?: H;
9
9
  }>): React.JSX.Element;
10
- declare function useWix<T extends WixClient = WixClient>(): T;
10
+ declare function useWix<T extends WixClient<Host<any> | undefined> = WixClient>(): T;
11
+ declare function useWixFetch(): (relativeUrl: string, options: RequestInit) => Promise<Response>;
11
12
  declare function useWixAuth<T extends AuthenticationStrategy>(): T;
12
- declare function useWixModules<T extends Descriptors<Host<any>>>(modules: T): BuildDescriptors<T>;
13
+ declare function useWixModules<T extends Descriptors>(modules: T): BuildDescriptors<T, Host<any>>;
13
14
  declare function useEnvironment<T>(): T;
14
15
 
15
- export { WixProvider, useEnvironment, useWix, useWixAuth, useWixModules };
16
+ export { WixProvider, useEnvironment, useWix, useWixAuth, useWixFetch, useWixModules };
package/build/index.d.ts CHANGED
@@ -1,15 +1,16 @@
1
- import * as React from 'react';
2
- import { Descriptors, Host, AuthenticationStrategy, AssertHostMatches, WixClient, BuildDescriptors } from '@wix/sdk';
1
+ import { Host, Descriptors, AuthenticationStrategy, AssertHostMatches, WixClient, BuildDescriptors } from '@wix/sdk';
3
2
  export * from '@wix/sdk';
3
+ import * as React from 'react';
4
4
 
5
- declare function WixProvider<T extends Descriptors<H>, H extends Host<any> = Host>(props: React.PropsWithChildren<{
5
+ declare function WixProvider<H extends Host<any> | undefined = undefined, T extends Descriptors = Descriptors>(props: React.PropsWithChildren<{
6
6
  auth?: AuthenticationStrategy<H>;
7
- modules?: AssertHostMatches<T, H>;
7
+ modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
8
8
  host?: H;
9
9
  }>): React.JSX.Element;
10
- declare function useWix<T extends WixClient = WixClient>(): T;
10
+ declare function useWix<T extends WixClient<Host<any> | undefined> = WixClient>(): T;
11
+ declare function useWixFetch(): (relativeUrl: string, options: RequestInit) => Promise<Response>;
11
12
  declare function useWixAuth<T extends AuthenticationStrategy>(): T;
12
- declare function useWixModules<T extends Descriptors<Host<any>>>(modules: T): BuildDescriptors<T>;
13
+ declare function useWixModules<T extends Descriptors>(modules: T): BuildDescriptors<T, Host<any>>;
13
14
  declare function useEnvironment<T>(): T;
14
15
 
15
- export { WixProvider, useEnvironment, useWix, useWixAuth, useWixModules };
16
+ export { WixProvider, useEnvironment, useWix, useWixAuth, useWixFetch, useWixModules };
package/build/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -34,12 +35,13 @@ __export(src_exports, {
34
35
  useEnvironment: () => useEnvironment,
35
36
  useWix: () => useWix,
36
37
  useWixAuth: () => useWixAuth,
38
+ useWixFetch: () => useWixFetch,
37
39
  useWixModules: () => useWixModules
38
40
  });
39
41
  module.exports = __toCommonJS(src_exports);
42
+ var import_sdk = require("@wix/sdk");
40
43
  var React = __toESM(require("react"));
41
44
  var import_react = require("react");
42
- var import_sdk = require("@wix/sdk");
43
45
  __reExport(src_exports, require("@wix/sdk"), module.exports);
44
46
  var WixContext = (0, import_react.createContext)(void 0);
45
47
  var HostEnvironmentContext = (0, import_react.createContext)(void 0);
@@ -83,6 +85,10 @@ function useWix() {
83
85
  }
84
86
  return sdk;
85
87
  }
88
+ function useWixFetch() {
89
+ const sdk = useWix();
90
+ return sdk.fetch;
91
+ }
86
92
  function useWixAuth() {
87
93
  const sdk = useWix();
88
94
  return sdk.auth;
@@ -106,6 +112,7 @@ function useEnvironment() {
106
112
  useEnvironment,
107
113
  useWix,
108
114
  useWixAuth,
115
+ useWixFetch,
109
116
  useWixModules,
110
117
  ...require("@wix/sdk")
111
118
  });
package/build/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/index.tsx
2
- import * as React from "react";
3
- import { createContext, useEffect, useMemo } from "react";
4
2
  import {
5
3
  createClient
6
4
  } from "@wix/sdk";
5
+ import * as React from "react";
6
+ import { createContext, useEffect, useMemo } from "react";
7
7
  export * from "@wix/sdk";
8
8
  var WixContext = createContext(void 0);
9
9
  var HostEnvironmentContext = createContext(void 0);
@@ -47,6 +47,10 @@ function useWix() {
47
47
  }
48
48
  return sdk;
49
49
  }
50
+ function useWixFetch() {
51
+ const sdk = useWix();
52
+ return sdk.fetch;
53
+ }
50
54
  function useWixAuth() {
51
55
  const sdk = useWix();
52
56
  return sdk.auth;
@@ -69,5 +73,6 @@ export {
69
73
  useEnvironment,
70
74
  useWix,
71
75
  useWixAuth,
76
+ useWixFetch,
72
77
  useWixModules
73
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk-react",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "license": "UNLICENSED",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.mjs",
@@ -21,18 +21,18 @@
21
21
  "typecheck": "tsc --noEmit"
22
22
  },
23
23
  "dependencies": {
24
- "@wix/sdk": "1.2.5"
24
+ "@wix/sdk": "1.2.7"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@swc/core": "^1.3.70",
30
+ "@swc/core": "^1.3.72",
31
31
  "@swc/jest": "^0.2.27",
32
32
  "@testing-library/jest-dom": "^5.17.0",
33
33
  "@testing-library/react": "^14.0.0",
34
- "@types/react": "^18.2.15",
35
- "@wix/ecom": "^1.0.274",
34
+ "@types/react": "^18.2.17",
35
+ "@wix/ecom": "^1.0.302",
36
36
  "eslint": "^7.32.0",
37
37
  "eslint-config-sdk": "0.0.0",
38
38
  "is-ci": "^3.0.1",
@@ -60,5 +60,5 @@
60
60
  "eslintConfig": {
61
61
  "extends": "sdk"
62
62
  },
63
- "falconPackageHash": "3687c57855777c7c9d98d85b5ac23659f9e5313f154b233ab089e777"
63
+ "falconPackageHash": "f297262dc25109d6d48829798904e68b7f3cd971c088c68d5521ce61"
64
64
  }