@react-three/fiber 8.15.2 → 8.15.3
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
CHANGED
|
@@ -294,47 +294,79 @@ function polyfills() {
|
|
|
294
294
|
|
|
295
295
|
// Patch Blob for ArrayBuffer if unsupported
|
|
296
296
|
// https://github.com/facebook/react-native/pull/39276
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
data: part.data,
|
|
313
|
-
type: 'blob'
|
|
314
|
-
};
|
|
315
|
-
} else {
|
|
316
|
-
return {
|
|
317
|
-
data: String(part),
|
|
318
|
-
type: 'string'
|
|
319
|
-
};
|
|
297
|
+
if (reactNative.Platform.OS !== 'web') {
|
|
298
|
+
try {
|
|
299
|
+
const blob = new Blob([new ArrayBuffer(4)]);
|
|
300
|
+
const url = URL.createObjectURL(blob);
|
|
301
|
+
URL.revokeObjectURL(url);
|
|
302
|
+
} catch (_) {
|
|
303
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
304
|
+
let BLOB_URL_PREFIX = null;
|
|
305
|
+
const {
|
|
306
|
+
BlobModule
|
|
307
|
+
} = reactNative.NativeModules;
|
|
308
|
+
if (BlobModule && typeof BlobModule.BLOB_URI_SCHEME === 'string') {
|
|
309
|
+
BLOB_URL_PREFIX = BlobModule.BLOB_URI_SCHEME + ':';
|
|
310
|
+
if (typeof BlobModule.BLOB_URI_HOST === 'string') {
|
|
311
|
+
BLOB_URL_PREFIX += `//${BlobModule.BLOB_URI_HOST}/`;
|
|
320
312
|
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
313
|
+
}
|
|
314
|
+
URL.createObjectURL = function createObjectURL(blob) {
|
|
315
|
+
const data = blob.data;
|
|
316
|
+
if (BLOB_URL_PREFIX === null) {
|
|
317
|
+
// https://github.com/pmndrs/react-three-fiber/issues/3058
|
|
318
|
+
// throw new Error('Cannot create URL for blob!')
|
|
319
|
+
return `data:${blob.type};base64,${data._base64}`;
|
|
327
320
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
blobId
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
321
|
+
return `${BLOB_URL_PREFIX}${data.blobId}?offset=${data.offset}&size=${blob.size}`;
|
|
322
|
+
};
|
|
323
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
324
|
+
const blobId = uuidv4();
|
|
325
|
+
const items = parts.map(part => {
|
|
326
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
327
|
+
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
328
|
+
return {
|
|
329
|
+
data,
|
|
330
|
+
type: 'string'
|
|
331
|
+
};
|
|
332
|
+
} else if (part instanceof Blob) {
|
|
333
|
+
return {
|
|
334
|
+
data: part.data,
|
|
335
|
+
type: 'blob'
|
|
336
|
+
};
|
|
337
|
+
} else {
|
|
338
|
+
return {
|
|
339
|
+
data: String(part),
|
|
340
|
+
type: 'string'
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
const size = items.reduce((acc, curr) => {
|
|
345
|
+
if (curr.type === 'string') {
|
|
346
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
347
|
+
} else {
|
|
348
|
+
return acc + curr.data.size;
|
|
349
|
+
}
|
|
350
|
+
}, 0);
|
|
351
|
+
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
352
|
+
const blob = BlobManager.createFromOptions({
|
|
353
|
+
blobId,
|
|
354
|
+
offset: 0,
|
|
355
|
+
size,
|
|
356
|
+
type: options ? options.type : '',
|
|
357
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
358
|
+
});
|
|
359
|
+
if (BLOB_URL_PREFIX === null) {
|
|
360
|
+
let data = '';
|
|
361
|
+
for (const item of items) {
|
|
362
|
+
var _item$data$_base;
|
|
363
|
+
data += (_item$data$_base = item.data._base64) != null ? _item$data$_base : item.data;
|
|
364
|
+
}
|
|
365
|
+
blob.data._base64 = data;
|
|
366
|
+
}
|
|
367
|
+
return blob;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
338
370
|
}
|
|
339
371
|
async function getAsset(input) {
|
|
340
372
|
if (typeof input === 'string') {
|
|
@@ -294,47 +294,79 @@ function polyfills() {
|
|
|
294
294
|
|
|
295
295
|
// Patch Blob for ArrayBuffer if unsupported
|
|
296
296
|
// https://github.com/facebook/react-native/pull/39276
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
data: part.data,
|
|
313
|
-
type: 'blob'
|
|
314
|
-
};
|
|
315
|
-
} else {
|
|
316
|
-
return {
|
|
317
|
-
data: String(part),
|
|
318
|
-
type: 'string'
|
|
319
|
-
};
|
|
297
|
+
if (reactNative.Platform.OS !== 'web') {
|
|
298
|
+
try {
|
|
299
|
+
const blob = new Blob([new ArrayBuffer(4)]);
|
|
300
|
+
const url = URL.createObjectURL(blob);
|
|
301
|
+
URL.revokeObjectURL(url);
|
|
302
|
+
} catch (_) {
|
|
303
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
304
|
+
let BLOB_URL_PREFIX = null;
|
|
305
|
+
const {
|
|
306
|
+
BlobModule
|
|
307
|
+
} = reactNative.NativeModules;
|
|
308
|
+
if (BlobModule && typeof BlobModule.BLOB_URI_SCHEME === 'string') {
|
|
309
|
+
BLOB_URL_PREFIX = BlobModule.BLOB_URI_SCHEME + ':';
|
|
310
|
+
if (typeof BlobModule.BLOB_URI_HOST === 'string') {
|
|
311
|
+
BLOB_URL_PREFIX += `//${BlobModule.BLOB_URI_HOST}/`;
|
|
320
312
|
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
313
|
+
}
|
|
314
|
+
URL.createObjectURL = function createObjectURL(blob) {
|
|
315
|
+
const data = blob.data;
|
|
316
|
+
if (BLOB_URL_PREFIX === null) {
|
|
317
|
+
// https://github.com/pmndrs/react-three-fiber/issues/3058
|
|
318
|
+
// throw new Error('Cannot create URL for blob!')
|
|
319
|
+
return `data:${blob.type};base64,${data._base64}`;
|
|
327
320
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
blobId
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
321
|
+
return `${BLOB_URL_PREFIX}${data.blobId}?offset=${data.offset}&size=${blob.size}`;
|
|
322
|
+
};
|
|
323
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
324
|
+
const blobId = uuidv4();
|
|
325
|
+
const items = parts.map(part => {
|
|
326
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
327
|
+
const data = base64Js.fromByteArray(new Uint8Array(part));
|
|
328
|
+
return {
|
|
329
|
+
data,
|
|
330
|
+
type: 'string'
|
|
331
|
+
};
|
|
332
|
+
} else if (part instanceof Blob) {
|
|
333
|
+
return {
|
|
334
|
+
data: part.data,
|
|
335
|
+
type: 'blob'
|
|
336
|
+
};
|
|
337
|
+
} else {
|
|
338
|
+
return {
|
|
339
|
+
data: String(part),
|
|
340
|
+
type: 'string'
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
const size = items.reduce((acc, curr) => {
|
|
345
|
+
if (curr.type === 'string') {
|
|
346
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
347
|
+
} else {
|
|
348
|
+
return acc + curr.data.size;
|
|
349
|
+
}
|
|
350
|
+
}, 0);
|
|
351
|
+
reactNative.NativeModules.BlobModule.createFromParts(items, blobId);
|
|
352
|
+
const blob = BlobManager.createFromOptions({
|
|
353
|
+
blobId,
|
|
354
|
+
offset: 0,
|
|
355
|
+
size,
|
|
356
|
+
type: options ? options.type : '',
|
|
357
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
358
|
+
});
|
|
359
|
+
if (BLOB_URL_PREFIX === null) {
|
|
360
|
+
let data = '';
|
|
361
|
+
for (const item of items) {
|
|
362
|
+
var _item$data$_base;
|
|
363
|
+
data += (_item$data$_base = item.data._base64) != null ? _item$data$_base : item.data;
|
|
364
|
+
}
|
|
365
|
+
blob.data._base64 = data;
|
|
366
|
+
}
|
|
367
|
+
return blob;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
338
370
|
}
|
|
339
371
|
async function getAsset(input) {
|
|
340
372
|
if (typeof input === 'string') {
|
|
@@ -3,7 +3,7 @@ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as
|
|
|
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, NativeModules, Image
|
|
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';
|
|
@@ -269,47 +269,79 @@ function polyfills() {
|
|
|
269
269
|
|
|
270
270
|
// Patch Blob for ArrayBuffer if unsupported
|
|
271
271
|
// https://github.com/facebook/react-native/pull/39276
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
data: part.data,
|
|
288
|
-
type: 'blob'
|
|
289
|
-
};
|
|
290
|
-
} else {
|
|
291
|
-
return {
|
|
292
|
-
data: String(part),
|
|
293
|
-
type: 'string'
|
|
294
|
-
};
|
|
272
|
+
if (Platform.OS !== 'web') {
|
|
273
|
+
try {
|
|
274
|
+
const blob = new Blob([new ArrayBuffer(4)]);
|
|
275
|
+
const url = URL.createObjectURL(blob);
|
|
276
|
+
URL.revokeObjectURL(url);
|
|
277
|
+
} catch (_) {
|
|
278
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager.js');
|
|
279
|
+
let BLOB_URL_PREFIX = null;
|
|
280
|
+
const {
|
|
281
|
+
BlobModule
|
|
282
|
+
} = NativeModules;
|
|
283
|
+
if (BlobModule && typeof BlobModule.BLOB_URI_SCHEME === 'string') {
|
|
284
|
+
BLOB_URL_PREFIX = BlobModule.BLOB_URI_SCHEME + ':';
|
|
285
|
+
if (typeof BlobModule.BLOB_URI_HOST === 'string') {
|
|
286
|
+
BLOB_URL_PREFIX += `//${BlobModule.BLOB_URI_HOST}/`;
|
|
295
287
|
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
288
|
+
}
|
|
289
|
+
URL.createObjectURL = function createObjectURL(blob) {
|
|
290
|
+
const data = blob.data;
|
|
291
|
+
if (BLOB_URL_PREFIX === null) {
|
|
292
|
+
// https://github.com/pmndrs/react-three-fiber/issues/3058
|
|
293
|
+
// throw new Error('Cannot create URL for blob!')
|
|
294
|
+
return `data:${blob.type};base64,${data._base64}`;
|
|
302
295
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
blobId
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
296
|
+
return `${BLOB_URL_PREFIX}${data.blobId}?offset=${data.offset}&size=${blob.size}`;
|
|
297
|
+
};
|
|
298
|
+
BlobManager.createFromParts = function createFromParts(parts, options) {
|
|
299
|
+
const blobId = uuidv4();
|
|
300
|
+
const items = parts.map(part => {
|
|
301
|
+
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
|
|
302
|
+
const data = fromByteArray(new Uint8Array(part));
|
|
303
|
+
return {
|
|
304
|
+
data,
|
|
305
|
+
type: 'string'
|
|
306
|
+
};
|
|
307
|
+
} else if (part instanceof Blob) {
|
|
308
|
+
return {
|
|
309
|
+
data: part.data,
|
|
310
|
+
type: 'blob'
|
|
311
|
+
};
|
|
312
|
+
} else {
|
|
313
|
+
return {
|
|
314
|
+
data: String(part),
|
|
315
|
+
type: 'string'
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
const size = items.reduce((acc, curr) => {
|
|
320
|
+
if (curr.type === 'string') {
|
|
321
|
+
return acc + global.unescape(encodeURI(curr.data)).length;
|
|
322
|
+
} else {
|
|
323
|
+
return acc + curr.data.size;
|
|
324
|
+
}
|
|
325
|
+
}, 0);
|
|
326
|
+
NativeModules.BlobModule.createFromParts(items, blobId);
|
|
327
|
+
const blob = BlobManager.createFromOptions({
|
|
328
|
+
blobId,
|
|
329
|
+
offset: 0,
|
|
330
|
+
size,
|
|
331
|
+
type: options ? options.type : '',
|
|
332
|
+
lastModified: options ? options.lastModified : Date.now()
|
|
333
|
+
});
|
|
334
|
+
if (BLOB_URL_PREFIX === null) {
|
|
335
|
+
let data = '';
|
|
336
|
+
for (const item of items) {
|
|
337
|
+
var _item$data$_base;
|
|
338
|
+
data += (_item$data$_base = item.data._base64) != null ? _item$data$_base : item.data;
|
|
339
|
+
}
|
|
340
|
+
blob.data._base64 = data;
|
|
341
|
+
}
|
|
342
|
+
return blob;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
313
345
|
}
|
|
314
346
|
async function getAsset(input) {
|
|
315
347
|
if (typeof input === 'string') {
|