@react-three/fiber 8.14.3 → 8.14.5
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/CHANGELOG.md +12 -0
- package/dist/declarations/src/core/events.d.ts +71 -71
- package/dist/declarations/src/core/hooks.d.ts +29 -29
- package/dist/declarations/src/core/index.d.ts +57 -57
- package/dist/declarations/src/core/loop.d.ts +14 -14
- package/dist/declarations/src/core/renderer.d.ts +58 -58
- package/dist/declarations/src/core/store.d.ts +95 -95
- package/dist/declarations/src/core/utils.d.ts +94 -94
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +10 -10
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +12 -12
- package/dist/declarations/src/three-types.d.ts +334 -334
- package/dist/declarations/src/web/Canvas.d.ts +13 -13
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-a401adf5.cjs.prod.js → index-0ed4bbca.cjs.prod.js} +7 -1
- package/dist/{index-dc6125bc.esm.js → index-563322db.esm.js} +7 -1
- package/dist/{index-2f978f7b.cjs.dev.js → index-886811f8.cjs.dev.js} +7 -1
- package/dist/react-three-fiber.cjs.dev.js +1 -1
- package/dist/react-three-fiber.cjs.prod.js +1 -1
- package/dist/react-three-fiber.esm.js +2 -2
- package/native/dist/react-three-fiber-native.cjs.dev.js +47 -16
- package/native/dist/react-three-fiber-native.cjs.prod.js +47 -16
- package/native/dist/react-three-fiber-native.esm.js +49 -18
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from '../core';
|
|
4
|
-
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
fallback?: React.ReactNode;
|
|
7
|
-
resize?: ResizeOptions;
|
|
8
|
-
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
9
|
-
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
10
|
-
}
|
|
11
|
-
export interface Props extends CanvasProps {
|
|
12
|
-
}
|
|
13
|
-
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from '../core';
|
|
4
|
+
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
fallback?: React.ReactNode;
|
|
7
|
+
resize?: ResizeOptions;
|
|
8
|
+
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
9
|
+
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
10
|
+
}
|
|
11
|
+
export interface Props extends CanvasProps {
|
|
12
|
+
}
|
|
13
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseBoundStore } from 'zustand';
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import { EventManager } from '../core/events';
|
|
4
|
-
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import { EventManager } from '../core/events';
|
|
4
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -643,6 +643,7 @@ function diffProps(instance, {
|
|
|
643
643
|
changes
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
+
const __DEV__ = typeof process !== 'undefined' && "production" !== 'production';
|
|
646
647
|
|
|
647
648
|
// This function applies a set of changes to the instance
|
|
648
649
|
function applyProps$1(instance, data) {
|
|
@@ -723,7 +724,12 @@ function applyProps$1(instance, data) {
|
|
|
723
724
|
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
724
725
|
}
|
|
725
726
|
// Test again target.copy(class) next ...
|
|
726
|
-
else if (targetProp.copy && value && value.constructor &&
|
|
727
|
+
else if (targetProp.copy && value && value.constructor && (
|
|
728
|
+
// Some environments may break strict identity checks by duplicating versions of three.js.
|
|
729
|
+
// Loosen to unminified names, ignoring descendents.
|
|
730
|
+
// https://github.com/pmndrs/react-three-fiber/issues/2856
|
|
731
|
+
// TODO: fix upstream and remove in v9
|
|
732
|
+
__DEV__ ? targetProp.constructor.name === value.constructor.name : targetProp.constructor === value.constructor)) {
|
|
727
733
|
targetProp.copy(value);
|
|
728
734
|
}
|
|
729
735
|
// If nothing else fits, just set the single value, ignore undefined
|
|
@@ -616,6 +616,7 @@ function diffProps(instance, {
|
|
|
616
616
|
changes
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
|
+
const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
|
|
619
620
|
|
|
620
621
|
// This function applies a set of changes to the instance
|
|
621
622
|
function applyProps$1(instance, data) {
|
|
@@ -696,7 +697,12 @@ function applyProps$1(instance, data) {
|
|
|
696
697
|
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
697
698
|
}
|
|
698
699
|
// Test again target.copy(class) next ...
|
|
699
|
-
else if (targetProp.copy && value && value.constructor &&
|
|
700
|
+
else if (targetProp.copy && value && value.constructor && (
|
|
701
|
+
// Some environments may break strict identity checks by duplicating versions of three.js.
|
|
702
|
+
// Loosen to unminified names, ignoring descendents.
|
|
703
|
+
// https://github.com/pmndrs/react-three-fiber/issues/2856
|
|
704
|
+
// TODO: fix upstream and remove in v9
|
|
705
|
+
__DEV__ ? targetProp.constructor.name === value.constructor.name : targetProp.constructor === value.constructor)) {
|
|
700
706
|
targetProp.copy(value);
|
|
701
707
|
}
|
|
702
708
|
// If nothing else fits, just set the single value, ignore undefined
|
|
@@ -643,6 +643,7 @@ function diffProps(instance, {
|
|
|
643
643
|
changes
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
+
const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
|
|
646
647
|
|
|
647
648
|
// This function applies a set of changes to the instance
|
|
648
649
|
function applyProps$1(instance, data) {
|
|
@@ -723,7 +724,12 @@ function applyProps$1(instance, data) {
|
|
|
723
724
|
if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
|
|
724
725
|
}
|
|
725
726
|
// Test again target.copy(class) next ...
|
|
726
|
-
else if (targetProp.copy && value && value.constructor &&
|
|
727
|
+
else if (targetProp.copy && value && value.constructor && (
|
|
728
|
+
// Some environments may break strict identity checks by duplicating versions of three.js.
|
|
729
|
+
// Loosen to unminified names, ignoring descendents.
|
|
730
|
+
// https://github.com/pmndrs/react-three-fiber/issues/2856
|
|
731
|
+
// TODO: fix upstream and remove in v9
|
|
732
|
+
__DEV__ ? targetProp.constructor.name === value.constructor.name : targetProp.constructor === value.constructor)) {
|
|
727
733
|
targetProp.copy(value);
|
|
728
734
|
}
|
|
729
735
|
// If nothing else fits, just set the single value, ignore undefined
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-886811f8.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-0ed4bbca.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-563322db.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-563322db.esm.js';
|
|
3
3
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import * as THREE from 'three';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-886811f8.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -282,21 +282,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(p
|
|
|
282
282
|
});
|
|
283
283
|
|
|
284
284
|
function polyfills() {
|
|
285
|
-
// Patch Blob for ArrayBuffer if unsupported
|
|
286
|
-
try {
|
|
287
|
-
new Blob([new ArrayBuffer(4)]);
|
|
288
|
-
} catch (_) {
|
|
289
|
-
global.Blob = class extends Blob {
|
|
290
|
-
constructor(parts, options) {
|
|
291
|
-
super(parts == null ? void 0 : parts.map(part => {
|
|
292
|
-
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
293
|
-
part = base64Js.fromByteArray(new Uint8Array(part));
|
|
294
|
-
}
|
|
295
|
-
return part;
|
|
296
|
-
}), options);
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
285
|
function uuidv4() {
|
|
301
286
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
302
287
|
const r = Math.random() * 16 | 0,
|
|
@@ -304,6 +289,52 @@ function polyfills() {
|
|
|
304
289
|
return v.toString(16);
|
|
305
290
|
});
|
|
306
291
|
}
|
|
292
|
+
|
|
293
|
+
// Patch Blob for ArrayBuffer if unsupported
|
|
294
|
+
if (reactNative.Platform.OS !== 'web') {
|
|
295
|
+
try {
|
|
296
|
+
new Blob([new ArrayBuffer(4)]);
|
|
297
|
+
} catch (_) {
|
|
298
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
299
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
300
|
+
const blobId = uuidv4();
|
|
301
|
+
const items = parts.map(part => {
|
|
302
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
303
|
+
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
304
|
+
return {
|
|
305
|
+
data,
|
|
306
|
+
type: 'string'
|
|
307
|
+
};
|
|
308
|
+
} else if (part instanceof Blob) {
|
|
309
|
+
return {
|
|
310
|
+
data: part.data,
|
|
311
|
+
type: 'blob'
|
|
312
|
+
};
|
|
313
|
+
} else {
|
|
314
|
+
return {
|
|
315
|
+
data: String(part),
|
|
316
|
+
type: 'string'
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const size = items.reduce((acc, curr) => {
|
|
321
|
+
if (curr.type === 'string') {
|
|
322
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
323
|
+
} else {
|
|
324
|
+
return acc + curr.data.size;
|
|
325
|
+
}
|
|
326
|
+
}, 0);
|
|
327
|
+
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
328
|
+
return BlobManager.createFromOptions({
|
|
329
|
+
blobId,
|
|
330
|
+
offset: 0,
|
|
331
|
+
size,
|
|
332
|
+
type: options ? options.type : '',
|
|
333
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
307
338
|
async function getAsset(input) {
|
|
308
339
|
if (typeof input === 'string') {
|
|
309
340
|
// Don't process storage or data uris
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-0ed4bbca.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -282,21 +282,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(p
|
|
|
282
282
|
});
|
|
283
283
|
|
|
284
284
|
function polyfills() {
|
|
285
|
-
// Patch Blob for ArrayBuffer if unsupported
|
|
286
|
-
try {
|
|
287
|
-
new Blob([new ArrayBuffer(4)]);
|
|
288
|
-
} catch (_) {
|
|
289
|
-
global.Blob = class extends Blob {
|
|
290
|
-
constructor(parts, options) {
|
|
291
|
-
super(parts == null ? void 0 : parts.map(part => {
|
|
292
|
-
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
293
|
-
part = base64Js.fromByteArray(new Uint8Array(part));
|
|
294
|
-
}
|
|
295
|
-
return part;
|
|
296
|
-
}), options);
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
285
|
function uuidv4() {
|
|
301
286
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
302
287
|
const r = Math.random() * 16 | 0,
|
|
@@ -304,6 +289,52 @@ function polyfills() {
|
|
|
304
289
|
return v.toString(16);
|
|
305
290
|
});
|
|
306
291
|
}
|
|
292
|
+
|
|
293
|
+
// Patch Blob for ArrayBuffer if unsupported
|
|
294
|
+
if (reactNative.Platform.OS !== 'web') {
|
|
295
|
+
try {
|
|
296
|
+
new Blob([new ArrayBuffer(4)]);
|
|
297
|
+
} catch (_) {
|
|
298
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
299
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
300
|
+
const blobId = uuidv4();
|
|
301
|
+
const items = parts.map(part => {
|
|
302
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
303
|
+
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
304
|
+
return {
|
|
305
|
+
data,
|
|
306
|
+
type: 'string'
|
|
307
|
+
};
|
|
308
|
+
} else if (part instanceof Blob) {
|
|
309
|
+
return {
|
|
310
|
+
data: part.data,
|
|
311
|
+
type: 'blob'
|
|
312
|
+
};
|
|
313
|
+
} else {
|
|
314
|
+
return {
|
|
315
|
+
data: String(part),
|
|
316
|
+
type: 'string'
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const size = items.reduce((acc, curr) => {
|
|
321
|
+
if (curr.type === 'string') {
|
|
322
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
323
|
+
} else {
|
|
324
|
+
return acc + curr.data.size;
|
|
325
|
+
}
|
|
326
|
+
}, 0);
|
|
327
|
+
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
328
|
+
return BlobManager.createFromOptions({
|
|
329
|
+
blobId,
|
|
330
|
+
offset: 0,
|
|
331
|
+
size,
|
|
332
|
+
type: options ? options.type : '',
|
|
333
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
307
338
|
async function getAsset(input) {
|
|
308
339
|
if (typeof input === 'string') {
|
|
309
340
|
// Don't process storage or data uris
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-563322db.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-563322db.esm.js';
|
|
3
3
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import * as THREE from 'three';
|
|
6
|
-
import { PanResponder, PixelRatio, View, StyleSheet, Image } from 'react-native';
|
|
6
|
+
import { PanResponder, PixelRatio, View, StyleSheet, Platform, NativeModules, Image } from 'react-native';
|
|
7
7
|
import { GLView } from 'expo-gl';
|
|
8
8
|
import { FiberProvider, useContextBridge } from 'its-fine';
|
|
9
9
|
import { Asset } from 'expo-asset';
|
|
@@ -257,21 +257,6 @@ const Canvas = /*#__PURE__*/React.forwardRef(function CanvasWrapper(props, ref)
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
function polyfills() {
|
|
260
|
-
// Patch Blob for ArrayBuffer if unsupported
|
|
261
|
-
try {
|
|
262
|
-
new Blob([new ArrayBuffer(4)]);
|
|
263
|
-
} catch (_) {
|
|
264
|
-
global.Blob = class extends Blob {
|
|
265
|
-
constructor(parts, options) {
|
|
266
|
-
super(parts == null ? void 0 : parts.map(part => {
|
|
267
|
-
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
268
|
-
part = fromByteArray(new Uint8Array(part));
|
|
269
|
-
}
|
|
270
|
-
return part;
|
|
271
|
-
}), options);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
260
|
function uuidv4() {
|
|
276
261
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
277
262
|
const r = Math.random() * 16 | 0,
|
|
@@ -279,6 +264,52 @@ function polyfills() {
|
|
|
279
264
|
return v.toString(16);
|
|
280
265
|
});
|
|
281
266
|
}
|
|
267
|
+
|
|
268
|
+
// Patch Blob for ArrayBuffer if unsupported
|
|
269
|
+
if (Platform.OS !== 'web') {
|
|
270
|
+
try {
|
|
271
|
+
new Blob([new ArrayBuffer(4)]);
|
|
272
|
+
} catch (_) {
|
|
273
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
274
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
275
|
+
const blobId = uuidv4();
|
|
276
|
+
const items = parts.map(part => {
|
|
277
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
278
|
+
const data = fromByteArray(new Uint8Array(part));
|
|
279
|
+
return {
|
|
280
|
+
data,
|
|
281
|
+
type: 'string'
|
|
282
|
+
};
|
|
283
|
+
} else if (part instanceof Blob) {
|
|
284
|
+
return {
|
|
285
|
+
data: part.data,
|
|
286
|
+
type: 'blob'
|
|
287
|
+
};
|
|
288
|
+
} else {
|
|
289
|
+
return {
|
|
290
|
+
data: String(part),
|
|
291
|
+
type: 'string'
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
const size = items.reduce((acc, curr) => {
|
|
296
|
+
if (curr.type === 'string') {
|
|
297
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
298
|
+
} else {
|
|
299
|
+
return acc + curr.data.size;
|
|
300
|
+
}
|
|
301
|
+
}, 0);
|
|
302
|
+
NativeModules.BlobModule.createFromParts(items, blobId);
|
|
303
|
+
return BlobManager.createFromOptions({
|
|
304
|
+
blobId,
|
|
305
|
+
offset: 0,
|
|
306
|
+
size,
|
|
307
|
+
type: options ? options.type : '',
|
|
308
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
282
313
|
async function getAsset(input) {
|
|
283
314
|
if (typeof input === 'string') {
|
|
284
315
|
// Don't process storage or data uris
|