@plasmicpkgs/commerce 0.0.52 → 0.0.53

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.
@@ -1112,7 +1112,7 @@ var FetcherError = /*#__PURE__*/function (_CommerceError2) {
1112
1112
  return FetcherError;
1113
1113
  }(CommerceError);
1114
1114
 
1115
- var useData = function useData(options, input, fetcherFn, swrOptions) {
1115
+ var useData = function useData(options, input, fetcherFn, swrOptions, provider) {
1116
1116
  var hookInput = Array.isArray(input) ? input : Object.entries(input);
1117
1117
 
1118
1118
  var fetcher = /*#__PURE__*/function () {
@@ -1144,7 +1144,8 @@ var useData = function useData(options, input, fetcherFn, swrOptions) {
1144
1144
  obj[hookInput[i][0]] = val;
1145
1145
  return obj;
1146
1146
  }, {}),
1147
- fetch: fetcherFn
1147
+ fetch: fetcherFn,
1148
+ provider: provider
1148
1149
  });
1149
1150
 
1150
1151
  case 4:
@@ -1196,7 +1197,7 @@ var useData = function useData(options, input, fetcherFn, swrOptions) {
1196
1197
 
1197
1198
  /*
1198
1199
  Forked from https://github.com/vercel/commerce/tree/main/packages/commerce/src
1199
- Changes: None
1200
+ Changes: Add provider to useSWRHook and useMutationHook
1200
1201
  */
1201
1202
  function useFetcher() {
1202
1203
  var _providerRef$current$;
@@ -1207,20 +1208,27 @@ function useFetcher() {
1207
1208
 
1208
1209
  return (_providerRef$current$ = providerRef.current.fetcher) != null ? _providerRef$current$ : fetcherRef.current;
1209
1210
  }
1210
- function useHook(fn) {
1211
+ function useProvider() {
1211
1212
  var _useCommerce2 = useCommerce(),
1212
1213
  providerRef = _useCommerce2.providerRef;
1213
1214
 
1215
+ return providerRef.current;
1216
+ }
1217
+ function useHook(fn) {
1218
+ var _useCommerce3 = useCommerce(),
1219
+ providerRef = _useCommerce3.providerRef;
1220
+
1214
1221
  var provider = providerRef.current;
1215
1222
  return fn(provider);
1216
1223
  }
1217
1224
  function useSWRHook(hook) {
1218
1225
  var fetcher = useFetcher();
1226
+ var provider = useProvider();
1219
1227
  return hook.useHook({
1220
1228
  useData: function useData$1(ctx) {
1221
1229
  var _ctx$input;
1222
1230
 
1223
- var response = useData(hook, (_ctx$input = ctx == null ? void 0 : ctx.input) != null ? _ctx$input : [], fetcher, ctx == null ? void 0 : ctx.swrOptions);
1231
+ var response = useData(hook, (_ctx$input = ctx == null ? void 0 : ctx.input) != null ? _ctx$input : [], fetcher, ctx == null ? void 0 : ctx.swrOptions, provider);
1224
1232
 
1225
1233
  return response;
1226
1234
  }
@@ -1228,6 +1236,7 @@ function useSWRHook(hook) {
1228
1236
  }
1229
1237
  function useMutationHook(hook) {
1230
1238
  var fetcher = useFetcher();
1239
+ var provider = useProvider();
1231
1240
  return hook.useHook({
1232
1241
  fetch: useCallback(function (_temp) {
1233
1242
  var _ref = _temp === void 0 ? {} : _temp,
@@ -1236,7 +1245,8 @@ function useMutationHook(hook) {
1236
1245
  return hook.fetcher({
1237
1246
  input: input,
1238
1247
  options: hook.fetchOptions,
1239
- fetch: fetcher
1248
+ fetch: fetcher,
1249
+ provider: provider
1240
1250
  });
1241
1251
  }, [fetcher, hook.fetchOptions])
1242
1252
  });