@emeryld/rrroutes-client 2.5.8 → 2.5.9

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/dist/index.cjs CHANGED
@@ -166,6 +166,7 @@ function isBlobLike(value) {
166
166
  function assertFileFieldValue(sourceKey, targetField, value) {
167
167
  if (value == null) return;
168
168
  if (isBlobLike(value)) return;
169
+ if (isReactNativeFile(value)) return;
169
170
  if (typeof FileList !== "undefined" && value instanceof FileList) {
170
171
  for (const item of Array.from(value)) {
171
172
  if (!isBlobLike(item)) {
@@ -178,7 +179,7 @@ function assertFileFieldValue(sourceKey, targetField, value) {
178
179
  }
179
180
  if (Array.isArray(value)) {
180
181
  for (const item of value) {
181
- if (!isBlobLike(item)) {
182
+ if (!isBlobLike(item) && !isReactNativeFile(item)) {
182
183
  throw new Error(
183
184
  `Multipart field "${sourceKey}" must contain Blob/File values for "${targetField}".`
184
185
  );
@@ -187,7 +188,7 @@ function assertFileFieldValue(sourceKey, targetField, value) {
187
188
  return;
188
189
  }
189
190
  throw new Error(
190
- `Multipart field "${sourceKey}" must be Blob/File, Blob[] or FileList.`
191
+ `Multipart field "${sourceKey}" must be Blob/File, ReactNativeFile, Blob[]/ReactNativeFile[] or FileList. ReactNativeFile = { uri: string, name: string, type: string }.`
191
192
  );
192
193
  }
193
194
  function splitMultipartBody(body, fields) {
@@ -220,9 +221,7 @@ var isFile = (v) => typeof File !== "undefined" && v instanceof File;
220
221
  var isBlob = (v) => typeof Blob !== "undefined" && v instanceof Blob;
221
222
  function toFormData(body, bodyFiles = []) {
222
223
  const fd = new FormData();
223
- const fileKeys = new Set(
224
- bodyFiles.flatMap((f) => [f.name, `file_${f.name}`])
225
- );
224
+ const fileKeys = new Set(bodyFiles.flatMap((f) => [f.name, `file_${f.name}`]));
226
225
  const appendFile = (fieldName, value) => {
227
226
  if (value == null) return;
228
227
  if (isReactNativeFile(value)) {