yeet
This commit is contained in:
2
node_modules/expo-asset/.eslintrc.js
generated
vendored
Normal file
2
node_modules/expo-asset/.eslintrc.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @generated by expo-module-scripts
|
||||
module.exports = require('expo-module-scripts/eslintrc.base.js');
|
43
node_modules/expo-asset/CHANGELOG.md
generated
vendored
Normal file
43
node_modules/expo-asset/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# Changelog
|
||||
|
||||
## Unpublished
|
||||
|
||||
### 🛠 Breaking changes
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
## 8.2.2 — 2021-01-15
|
||||
|
||||
_This version does not introduce any user-facing changes._
|
||||
|
||||
## 8.2.1 — 2020-11-17
|
||||
|
||||
_This version does not introduce any user-facing changes._
|
||||
|
||||
## 8.2.0 — 2020-08-18
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- Add `useAssets` hook to simplify assets handling. ([#8928](https://github.com/expo/expo/pull/8928) by [@bycedric](https://github.com/bycedric))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Fixed `Asset.loadAsync()` TypeScript signature to match `Asset.fromModule()` types. ([#9246](https://github.com/expo/expo/pull/9246) by [@barthap](https://github.com/barthap))
|
||||
|
||||
## 8.1.7 — 2020-05-29
|
||||
|
||||
*This version does not introduce any user-facing changes.*
|
||||
|
||||
## 8.1.6 — 2020-05-27
|
||||
|
||||
*This version does not introduce any user-facing changes.*
|
||||
|
||||
## 8.1.5
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- `asset.downloadAsync()` returns the resolved `Asset` when it resolves. ([#8646](https://github.com/expo/expo/pull/8646) by [@EvanBacon](https://github.com/EvanBacon))
|
||||
- `Asset.loadAsync()` returns an array of resolved `Asset`s when it finishes loading the resources. ([#8646](https://github.com/expo/expo/pull/8646) by [@EvanBacon](https://github.com/EvanBacon))
|
||||
- Added support for the `expo-updates` **no-publish workflow**. ([#8003](https://github.com/expo/expo/pull/8003) by [@esamelson](https://github.com/esamelson))
|
26
node_modules/expo-asset/README.md
generated
vendored
Normal file
26
node_modules/expo-asset/README.md
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
# expo-asset
|
||||
|
||||
An Expo universal module to download assets and pass them into other APIs
|
||||
|
||||
# API documentation
|
||||
|
||||
- [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/asset.md)
|
||||
- [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/asset/)
|
||||
|
||||
# Installation in managed Expo projects
|
||||
|
||||
For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/asset/). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
|
||||
|
||||
# Installation in bare React Native projects
|
||||
|
||||
For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
|
||||
|
||||
### Add the package to your npm dependencies
|
||||
|
||||
```
|
||||
expo install expo-asset
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
||||
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
|
35
node_modules/expo-asset/build/Asset.d.ts
generated
vendored
Normal file
35
node_modules/expo-asset/build/Asset.d.ts
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
import * as AssetSources from './AssetSources';
|
||||
declare type AssetDescriptor = {
|
||||
name: string;
|
||||
type: string;
|
||||
hash?: string | null;
|
||||
uri: string;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
};
|
||||
declare type DownloadPromiseCallbacks = {
|
||||
resolve: () => void;
|
||||
reject: (error: Error) => void;
|
||||
};
|
||||
export declare type AssetMetadata = AssetSources.AssetMetadata;
|
||||
export declare class Asset {
|
||||
static byHash: {};
|
||||
static byUri: {};
|
||||
name: string;
|
||||
type: string;
|
||||
hash: string | null;
|
||||
uri: string;
|
||||
localUri: string | null;
|
||||
width: number | null;
|
||||
height: number | null;
|
||||
downloading: boolean;
|
||||
downloaded: boolean;
|
||||
_downloadCallbacks: DownloadPromiseCallbacks[];
|
||||
constructor({ name, type, hash, uri, width, height }: AssetDescriptor);
|
||||
static loadAsync(moduleId: number | number[] | string | string[]): Promise<Asset[]>;
|
||||
static fromModule(virtualAssetModule: number | string): Asset;
|
||||
static fromMetadata(meta: AssetMetadata): Asset;
|
||||
static fromURI(uri: string): Asset;
|
||||
downloadAsync(): Promise<this>;
|
||||
}
|
||||
export {};
|
1
node_modules/expo-asset/build/Asset.fx.d.ts
generated
vendored
Normal file
1
node_modules/expo-asset/build/Asset.fx.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
22
node_modules/expo-asset/build/Asset.fx.js
generated
vendored
Normal file
22
node_modules/expo-asset/build/Asset.fx.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import { Asset } from './Asset';
|
||||
import { IS_ENV_WITH_UPDATES_ENABLED } from './PlatformUtils';
|
||||
import { setCustomSourceTransformer } from './resolveAssetSource';
|
||||
// Override React Native's asset resolution for `Image` components in contexts where it matters
|
||||
if (IS_ENV_WITH_UPDATES_ENABLED) {
|
||||
setCustomSourceTransformer(resolver => {
|
||||
try {
|
||||
// Bundler is using the hashAssetFiles plugin if and only if the fileHashes property exists
|
||||
if (resolver.asset.fileHashes) {
|
||||
const asset = Asset.fromMetadata(resolver.asset);
|
||||
return resolver.fromSource(asset.downloaded ? asset.localUri : asset.uri);
|
||||
}
|
||||
else {
|
||||
return resolver.defaultAsset();
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return resolver.defaultAsset();
|
||||
}
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=Asset.fx.js.map
|
1
node_modules/expo-asset/build/Asset.fx.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/Asset.fx.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Asset.fx.js","sourceRoot":"","sources":["../src/Asset.fx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,+FAA+F;AAC/F,IAAI,2BAA2B,EAAE;IAC/B,0BAA0B,CAAC,QAAQ,CAAC,EAAE;QACpC,IAAI;YACF,2FAA2F;YAC3F,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE;gBAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACjD,OAAO,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAC5E;iBAAM;gBACL,OAAO,QAAQ,CAAC,YAAY,EAAE,CAAC;aAChC;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,QAAQ,CAAC,YAAY,EAAE,CAAC;SAChC;IACH,CAAC,CAAC,CAAC;CACJ","sourcesContent":["import { Asset } from './Asset';\nimport { IS_ENV_WITH_UPDATES_ENABLED } from './PlatformUtils';\nimport { setCustomSourceTransformer } from './resolveAssetSource';\n\n// Override React Native's asset resolution for `Image` components in contexts where it matters\nif (IS_ENV_WITH_UPDATES_ENABLED) {\n setCustomSourceTransformer(resolver => {\n try {\n // Bundler is using the hashAssetFiles plugin if and only if the fileHashes property exists\n if (resolver.asset.fileHashes) {\n const asset = Asset.fromMetadata(resolver.asset);\n return resolver.fromSource(asset.downloaded ? asset.localUri! : asset.uri);\n } else {\n return resolver.defaultAsset();\n }\n } catch (e) {\n return resolver.defaultAsset();\n }\n });\n}\n"]}
|
161
node_modules/expo-asset/build/Asset.js
generated
vendored
Normal file
161
node_modules/expo-asset/build/Asset.js
generated
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
import { Platform } from '@unimodules/core';
|
||||
import { getAssetByID } from './AssetRegistry';
|
||||
import * as AssetSources from './AssetSources';
|
||||
import * as AssetUris from './AssetUris';
|
||||
import { getEmbeddedAssetUri } from './EmbeddedAssets';
|
||||
import * as ImageAssets from './ImageAssets';
|
||||
import { downloadAsync, IS_ENV_WITH_UPDATES_ENABLED } from './PlatformUtils';
|
||||
import resolveAssetSource from './resolveAssetSource';
|
||||
export class Asset {
|
||||
constructor({ name, type, hash = null, uri, width, height }) {
|
||||
this.hash = null;
|
||||
this.localUri = null;
|
||||
this.width = null;
|
||||
this.height = null;
|
||||
this.downloading = false;
|
||||
this.downloaded = false;
|
||||
this._downloadCallbacks = [];
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.hash = hash;
|
||||
this.uri = uri;
|
||||
if (typeof width === 'number') {
|
||||
this.width = width;
|
||||
}
|
||||
if (typeof height === 'number') {
|
||||
this.height = height;
|
||||
}
|
||||
if (hash) {
|
||||
this.localUri = getEmbeddedAssetUri(hash, type);
|
||||
if (this.localUri) {
|
||||
this.downloaded = true;
|
||||
}
|
||||
}
|
||||
if (Platform.OS === 'web') {
|
||||
if (!name) {
|
||||
this.name = AssetUris.getFilename(uri);
|
||||
}
|
||||
if (!type) {
|
||||
this.type = AssetUris.getFileExtension(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
static loadAsync(moduleId) {
|
||||
const moduleIds = Array.isArray(moduleId) ? moduleId : [moduleId];
|
||||
return Promise.all(moduleIds.map(moduleId => Asset.fromModule(moduleId).downloadAsync()));
|
||||
}
|
||||
static fromModule(virtualAssetModule) {
|
||||
if (typeof virtualAssetModule === 'string') {
|
||||
return Asset.fromURI(virtualAssetModule);
|
||||
}
|
||||
const meta = getAssetByID(virtualAssetModule);
|
||||
if (!meta) {
|
||||
throw new Error(`Module "${virtualAssetModule}" is missing from the asset registry`);
|
||||
}
|
||||
// Outside of the managed env we need the moduleId to initialize the asset
|
||||
// because resolveAssetSource depends on it
|
||||
if (!IS_ENV_WITH_UPDATES_ENABLED) {
|
||||
const { uri } = resolveAssetSource(virtualAssetModule);
|
||||
const asset = new Asset({
|
||||
name: meta.name,
|
||||
type: meta.type,
|
||||
hash: meta.hash,
|
||||
uri,
|
||||
width: meta.width,
|
||||
height: meta.height,
|
||||
});
|
||||
// TODO: FileSystem should probably support 'downloading' from drawable
|
||||
// resources But for now it doesn't (it only supports raw resources) and
|
||||
// React Native's Image works fine with drawable resource names for
|
||||
// images.
|
||||
if (Platform.OS === 'android' && !uri.includes(':') && (meta.width || meta.height)) {
|
||||
asset.localUri = asset.uri;
|
||||
asset.downloaded = true;
|
||||
}
|
||||
Asset.byHash[meta.hash] = asset;
|
||||
return asset;
|
||||
}
|
||||
return Asset.fromMetadata(meta);
|
||||
}
|
||||
static fromMetadata(meta) {
|
||||
// The hash of the whole asset, not to be confused with the hash of a specific file returned
|
||||
// from `selectAssetSource`
|
||||
const metaHash = meta.hash;
|
||||
if (Asset.byHash[metaHash]) {
|
||||
return Asset.byHash[metaHash];
|
||||
}
|
||||
const { uri, hash } = AssetSources.selectAssetSource(meta);
|
||||
const asset = new Asset({
|
||||
name: meta.name,
|
||||
type: meta.type,
|
||||
hash,
|
||||
uri,
|
||||
width: meta.width,
|
||||
height: meta.height,
|
||||
});
|
||||
Asset.byHash[metaHash] = asset;
|
||||
return asset;
|
||||
}
|
||||
static fromURI(uri) {
|
||||
if (Asset.byUri[uri]) {
|
||||
return Asset.byUri[uri];
|
||||
}
|
||||
// Possibly a Base64-encoded URI
|
||||
let type = '';
|
||||
if (uri.indexOf(';base64') > -1) {
|
||||
type = uri.split(';')[0].split('/')[1];
|
||||
}
|
||||
else {
|
||||
const extension = AssetUris.getFileExtension(uri);
|
||||
type = extension.startsWith('.') ? extension.substring(1) : extension;
|
||||
}
|
||||
const asset = new Asset({
|
||||
name: '',
|
||||
type,
|
||||
hash: null,
|
||||
uri,
|
||||
});
|
||||
Asset.byUri[uri] = asset;
|
||||
return asset;
|
||||
}
|
||||
async downloadAsync() {
|
||||
if (this.downloaded) {
|
||||
return this;
|
||||
}
|
||||
if (this.downloading) {
|
||||
await new Promise((resolve, reject) => {
|
||||
this._downloadCallbacks.push({ resolve, reject });
|
||||
});
|
||||
return this;
|
||||
}
|
||||
this.downloading = true;
|
||||
try {
|
||||
if (Platform.OS === 'web') {
|
||||
if (ImageAssets.isImageType(this.type)) {
|
||||
const { width, height, name } = await ImageAssets.getImageInfoAsync(this.uri);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.name = name;
|
||||
}
|
||||
else {
|
||||
this.name = AssetUris.getFilename(this.uri);
|
||||
}
|
||||
}
|
||||
this.localUri = await downloadAsync(this.uri, this.hash, this.type, this.name);
|
||||
this.downloaded = true;
|
||||
this._downloadCallbacks.forEach(({ resolve }) => resolve());
|
||||
}
|
||||
catch (e) {
|
||||
this._downloadCallbacks.forEach(({ reject }) => reject(e));
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this.downloading = false;
|
||||
this._downloadCallbacks = [];
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Asset.byHash = {};
|
||||
Asset.byUri = {};
|
||||
//# sourceMappingURL=Asset.js.map
|
1
node_modules/expo-asset/build/Asset.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/Asset.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/expo-asset/build/AssetHooks.d.ts
generated
vendored
Normal file
17
node_modules/expo-asset/build/AssetHooks.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { Asset } from './Asset';
|
||||
/**
|
||||
* Downloads and stores one or more assets locally.
|
||||
* After the assets are loaded, this hook returns a list of asset instances.
|
||||
* If something went wrong when loading the assets, an error is returned.
|
||||
*
|
||||
* Note, the assets are not "reloaded" when you dynamically change the asset list.
|
||||
*
|
||||
* @see https://docs.expo.io/versions/latest/sdk/asset/
|
||||
* @example
|
||||
* ```tsx
|
||||
* const [assets, error] = useAssets(require('path/to/asset.jpg'));
|
||||
*
|
||||
* return !assets ? null : <Image source={assets[0]} />;
|
||||
* ```
|
||||
*/
|
||||
export declare function useAssets(moduleIds: number | number[]): [Asset[] | undefined, Error | undefined];
|
28
node_modules/expo-asset/build/AssetHooks.js
generated
vendored
Normal file
28
node_modules/expo-asset/build/AssetHooks.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Asset } from './Asset';
|
||||
/**
|
||||
* Downloads and stores one or more assets locally.
|
||||
* After the assets are loaded, this hook returns a list of asset instances.
|
||||
* If something went wrong when loading the assets, an error is returned.
|
||||
*
|
||||
* Note, the assets are not "reloaded" when you dynamically change the asset list.
|
||||
*
|
||||
* @see https://docs.expo.io/versions/latest/sdk/asset/
|
||||
* @example
|
||||
* ```tsx
|
||||
* const [assets, error] = useAssets(require('path/to/asset.jpg'));
|
||||
*
|
||||
* return !assets ? null : <Image source={assets[0]} />;
|
||||
* ```
|
||||
*/
|
||||
export function useAssets(moduleIds) {
|
||||
const [assets, setAssets] = useState();
|
||||
const [error, setError] = useState();
|
||||
useEffect(() => {
|
||||
Asset.loadAsync(moduleIds)
|
||||
.then(setAssets)
|
||||
.catch(setError);
|
||||
}, []);
|
||||
return [assets, error];
|
||||
}
|
||||
//# sourceMappingURL=AssetHooks.js.map
|
1
node_modules/expo-asset/build/AssetHooks.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetHooks.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AssetHooks.js","sourceRoot":"","sources":["../src/AssetHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CAAC,SAA4B;IACpD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAAW,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAS,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;aACvB,IAAI,CAAC,SAAS,CAAC;aACf,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { Asset } from './Asset';\n\n/**\n * Downloads and stores one or more assets locally.\n * After the assets are loaded, this hook returns a list of asset instances.\n * If something went wrong when loading the assets, an error is returned.\n *\n * Note, the assets are not \"reloaded\" when you dynamically change the asset list.\n *\n * @see https://docs.expo.io/versions/latest/sdk/asset/\n * @example\n * ```tsx\n * const [assets, error] = useAssets(require('path/to/asset.jpg'));\n *\n * return !assets ? null : <Image source={assets[0]} />;\n * ```\n */\nexport function useAssets(moduleIds: number | number[]): [Asset[] | undefined, Error | undefined] {\n const [assets, setAssets] = useState<Asset[]>();\n const [error, setError] = useState<Error>();\n\n useEffect(() => {\n Asset.loadAsync(moduleIds)\n .then(setAssets)\n .catch(setError);\n }, []);\n\n return [assets, error];\n}\n"]}
|
1
node_modules/expo-asset/build/AssetRegistry.d.ts
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetRegistry.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from 'react-native/Libraries/Image/AssetRegistry';
|
2
node_modules/expo-asset/build/AssetRegistry.js
generated
vendored
Normal file
2
node_modules/expo-asset/build/AssetRegistry.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from 'react-native/Libraries/Image/AssetRegistry';
|
||||
//# sourceMappingURL=AssetRegistry.js.map
|
1
node_modules/expo-asset/build/AssetRegistry.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetRegistry.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AssetRegistry.js","sourceRoot":"","sources":["../src/AssetRegistry.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC","sourcesContent":["export * from 'react-native/Libraries/Image/AssetRegistry';\n"]}
|
1
node_modules/expo-asset/build/AssetRegistry.web.d.ts
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetRegistry.web.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from 'react-native-web/dist/modules/AssetRegistry';
|
2
node_modules/expo-asset/build/AssetRegistry.web.js
generated
vendored
Normal file
2
node_modules/expo-asset/build/AssetRegistry.web.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from 'react-native-web/dist/modules/AssetRegistry';
|
||||
//# sourceMappingURL=AssetRegistry.web.js.map
|
1
node_modules/expo-asset/build/AssetRegistry.web.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetRegistry.web.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AssetRegistry.web.js","sourceRoot":"","sources":["../src/AssetRegistry.web.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC","sourcesContent":["export * from 'react-native-web/dist/modules/AssetRegistry';\n"]}
|
3
node_modules/expo-asset/build/AssetSourceResolver.d.ts
generated
vendored
Normal file
3
node_modules/expo-asset/build/AssetSourceResolver.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import AssetSourceResolver from 'react-native/Libraries/Image/AssetSourceResolver';
|
||||
export default AssetSourceResolver;
|
||||
export * from 'react-native/Libraries/Image/AssetSourceResolver';
|
4
node_modules/expo-asset/build/AssetSourceResolver.js
generated
vendored
Normal file
4
node_modules/expo-asset/build/AssetSourceResolver.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import AssetSourceResolver from 'react-native/Libraries/Image/AssetSourceResolver';
|
||||
export default AssetSourceResolver;
|
||||
export * from 'react-native/Libraries/Image/AssetSourceResolver';
|
||||
//# sourceMappingURL=AssetSourceResolver.js.map
|
1
node_modules/expo-asset/build/AssetSourceResolver.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetSourceResolver.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AssetSourceResolver.js","sourceRoot":"","sources":["../src/AssetSourceResolver.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,kDAAkD,CAAC;AACnF,eAAe,mBAAmB,CAAC;AACnC,cAAc,kDAAkD,CAAC","sourcesContent":["import AssetSourceResolver from 'react-native/Libraries/Image/AssetSourceResolver';\nexport default AssetSourceResolver;\nexport * from 'react-native/Libraries/Image/AssetSourceResolver';\n"]}
|
35
node_modules/expo-asset/build/AssetSourceResolver.web.d.ts
generated
vendored
Normal file
35
node_modules/expo-asset/build/AssetSourceResolver.web.d.ts
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
declare type PackagerAsset = {
|
||||
__packager_asset: boolean;
|
||||
fileSystemLocation: string;
|
||||
httpServerLocation: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
scales: number[];
|
||||
hash: string;
|
||||
name: string;
|
||||
type: string;
|
||||
};
|
||||
export declare type ResolvedAssetSource = {
|
||||
__packager_asset: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
uri: string;
|
||||
scale: number;
|
||||
};
|
||||
export default class AssetSourceResolver {
|
||||
serverUrl?: string | null;
|
||||
jsbundleUrl?: string | null;
|
||||
asset: PackagerAsset;
|
||||
constructor(serverUrl: string | undefined | null, jsbundleUrl: string | undefined | null, asset: PackagerAsset);
|
||||
isLoadedFromServer(): boolean;
|
||||
isLoadedFromFileSystem(): boolean;
|
||||
defaultAsset(): ResolvedAssetSource;
|
||||
assetServerURL(): ResolvedAssetSource;
|
||||
scaledAssetPath(): ResolvedAssetSource;
|
||||
scaledAssetURLNearBundle(): ResolvedAssetSource;
|
||||
resourceIdentifierWithoutScale(): ResolvedAssetSource;
|
||||
drawableFolderInBundle(): ResolvedAssetSource;
|
||||
fromSource(source: string): ResolvedAssetSource;
|
||||
static pickScale(scales: number[], deviceScale: number): number;
|
||||
}
|
||||
export {};
|
77
node_modules/expo-asset/build/AssetSourceResolver.web.js
generated
vendored
Normal file
77
node_modules/expo-asset/build/AssetSourceResolver.web.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
import { Platform, UnavailabilityError } from '@unimodules/core';
|
||||
import invariant from 'invariant';
|
||||
import { Dimensions } from 'react-native';
|
||||
function getBasePath({ httpServerLocation }) {
|
||||
if (httpServerLocation[0] === '/') {
|
||||
return httpServerLocation.substr(1);
|
||||
}
|
||||
return httpServerLocation;
|
||||
}
|
||||
function getScale() {
|
||||
return Dimensions.get('window').scale;
|
||||
}
|
||||
function getScaledAssetPath(asset) {
|
||||
const scale = AssetSourceResolver.pickScale(asset.scales, getScale());
|
||||
const scaleSuffix = scale === 1 ? '' : '@' + scale + 'x';
|
||||
const assetDir = getBasePath(asset);
|
||||
return assetDir + '/' + asset.name + scaleSuffix + '.' + asset.type;
|
||||
}
|
||||
export default class AssetSourceResolver {
|
||||
constructor(serverUrl, jsbundleUrl, asset) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.jsbundleUrl = jsbundleUrl;
|
||||
this.asset = asset;
|
||||
}
|
||||
isLoadedFromServer() {
|
||||
return !!this.serverUrl;
|
||||
}
|
||||
isLoadedFromFileSystem() {
|
||||
return !!(this.jsbundleUrl && this.jsbundleUrl.startsWith('file://'));
|
||||
}
|
||||
defaultAsset() {
|
||||
if (this.isLoadedFromServer()) {
|
||||
return this.assetServerURL();
|
||||
}
|
||||
return this.scaledAssetURLNearBundle();
|
||||
}
|
||||
assetServerURL() {
|
||||
invariant(!!this.serverUrl, 'need server to load from');
|
||||
return this.fromSource(this.serverUrl +
|
||||
getScaledAssetPath(this.asset) +
|
||||
'?platform=' +
|
||||
Platform.OS +
|
||||
'&hash=' +
|
||||
this.asset.hash);
|
||||
}
|
||||
scaledAssetPath() {
|
||||
return this.fromSource(getScaledAssetPath(this.asset));
|
||||
}
|
||||
scaledAssetURLNearBundle() {
|
||||
const path = this.jsbundleUrl || 'file://';
|
||||
return this.fromSource(path + getScaledAssetPath(this.asset));
|
||||
}
|
||||
resourceIdentifierWithoutScale() {
|
||||
throw new UnavailabilityError('react-native', 'resourceIdentifierWithoutScale()');
|
||||
}
|
||||
drawableFolderInBundle() {
|
||||
throw new UnavailabilityError('react-native', 'drawableFolderInBundle()');
|
||||
}
|
||||
fromSource(source) {
|
||||
return {
|
||||
__packager_asset: true,
|
||||
width: this.asset.width,
|
||||
height: this.asset.height,
|
||||
uri: source,
|
||||
scale: AssetSourceResolver.pickScale(this.asset.scales, getScale()),
|
||||
};
|
||||
}
|
||||
static pickScale(scales, deviceScale) {
|
||||
for (let i = 0; i < scales.length; i++) {
|
||||
if (scales[i] >= deviceScale) {
|
||||
return scales[i];
|
||||
}
|
||||
}
|
||||
return scales[scales.length - 1] || 1;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=AssetSourceResolver.web.js.map
|
1
node_modules/expo-asset/build/AssetSourceResolver.web.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetSourceResolver.web.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/expo-asset/build/AssetSources.d.ts
generated
vendored
Normal file
29
node_modules/expo-asset/build/AssetSources.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
export declare type AssetMetadata = {
|
||||
hash: string;
|
||||
name: string;
|
||||
type: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
scales: number[];
|
||||
httpServerLocation: string;
|
||||
uri?: string;
|
||||
fileHashes?: string[];
|
||||
fileUris?: string[];
|
||||
};
|
||||
export declare type AssetSource = {
|
||||
uri: string;
|
||||
hash: string;
|
||||
};
|
||||
/**
|
||||
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
|
||||
* a { uri, hash } pair for the specific asset file.
|
||||
*
|
||||
* If the asset isn't an image with multiple scales, the first file is selected.
|
||||
*/
|
||||
export declare function selectAssetSource(meta: AssetMetadata): AssetSource;
|
||||
/**
|
||||
* Resolves the given URI to an absolute URI. If the given URI is already an absolute URI, it is
|
||||
* simply returned. Otherwise, if it is a relative URI, it is resolved relative to the manifest's
|
||||
* base URI.
|
||||
*/
|
||||
export declare function resolveUri(uri: string): string;
|
75
node_modules/expo-asset/build/AssetSources.js
generated
vendored
Normal file
75
node_modules/expo-asset/build/AssetSources.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
import { Platform } from '@unimodules/core';
|
||||
import path from 'path-browserify';
|
||||
import { PixelRatio } from 'react-native';
|
||||
import URL from 'url-parse';
|
||||
import AssetSourceResolver from './AssetSourceResolver';
|
||||
import { manifestBaseUrl, getManifest } from './PlatformUtils';
|
||||
// Fast lookup check if asset map has any overrides in the manifest
|
||||
const assetMapOverride = getManifest().assetMapOverride;
|
||||
/**
|
||||
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
|
||||
* a { uri, hash } pair for the specific asset file.
|
||||
*
|
||||
* If the asset isn't an image with multiple scales, the first file is selected.
|
||||
*/
|
||||
export function selectAssetSource(meta) {
|
||||
// Override with the asset map in manifest if available
|
||||
if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {
|
||||
meta = { ...meta, ...assetMapOverride[meta.hash] };
|
||||
}
|
||||
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
|
||||
// explicitly provided URIs
|
||||
const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());
|
||||
const index = meta.scales.findIndex(s => s === scale);
|
||||
const hash = meta.fileHashes ? meta.fileHashes[index] || meta.fileHashes[0] : meta.hash;
|
||||
// Allow asset processors to directly provide the URL to load
|
||||
const uri = meta.fileUris ? meta.fileUris[index] || meta.fileUris[0] : meta.uri;
|
||||
if (uri) {
|
||||
return { uri: resolveUri(uri), hash };
|
||||
}
|
||||
// Check if the assetUrl was overridden in the manifest
|
||||
const assetUrlOverride = getManifest().assetUrlOverride;
|
||||
if (assetUrlOverride) {
|
||||
const uri = path.join(assetUrlOverride, hash);
|
||||
return { uri: resolveUri(uri), hash };
|
||||
}
|
||||
const fileScale = scale === 1 ? '' : `@${scale}x`;
|
||||
const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : '';
|
||||
const suffix = `/${encodeURIComponent(meta.name)}${fileScale}${fileExtension}?platform=${encodeURIComponent(Platform.OS)}&hash=${encodeURIComponent(meta.hash)}`;
|
||||
// For assets with a specified absolute URL, we use the existing origin instead of prepending the
|
||||
// development server or production CDN URL origin
|
||||
if (/^https?:\/\//.test(meta.httpServerLocation)) {
|
||||
const uri = meta.httpServerLocation + suffix;
|
||||
return { uri, hash };
|
||||
}
|
||||
// For assets during development, we use the development server's URL origin
|
||||
if (getManifest().developer) {
|
||||
const baseUrl = new URL(getManifest().bundleUrl);
|
||||
baseUrl.set('pathname', meta.httpServerLocation + suffix);
|
||||
return { uri: baseUrl.href, hash };
|
||||
}
|
||||
// Production CDN URIs are based on each asset file hash
|
||||
return {
|
||||
uri: `https://d1wp6m56sqw74a.cloudfront.net/~assets/${encodeURIComponent(hash)}`,
|
||||
hash,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resolves the given URI to an absolute URI. If the given URI is already an absolute URI, it is
|
||||
* simply returned. Otherwise, if it is a relative URI, it is resolved relative to the manifest's
|
||||
* base URI.
|
||||
*/
|
||||
export function resolveUri(uri) {
|
||||
if (!manifestBaseUrl) {
|
||||
return uri;
|
||||
}
|
||||
const { protocol } = new URL(uri);
|
||||
if (protocol !== '') {
|
||||
return uri;
|
||||
}
|
||||
const baseUrl = new URL(manifestBaseUrl);
|
||||
const resolvedPath = uri.startsWith('/') ? uri : path.join(baseUrl.pathname, uri);
|
||||
baseUrl.set('pathname', resolvedPath);
|
||||
return baseUrl.href;
|
||||
}
|
||||
//# sourceMappingURL=AssetSources.js.map
|
1
node_modules/expo-asset/build/AssetSources.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetSources.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
node_modules/expo-asset/build/AssetUris.d.ts
generated
vendored
Normal file
14
node_modules/expo-asset/build/AssetUris.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
export declare function getFilename(url: string): string;
|
||||
export declare function getFileExtension(url: string): string;
|
||||
/**
|
||||
* Returns the base URL from a manifest's URL. For example, given a manifest hosted at
|
||||
* https://example.com/app/manifest.json, the base URL would be https://example.com/app/. Query
|
||||
* parameters and fragments also are removed.
|
||||
*
|
||||
* For an Expo-hosted project with a manifest hosted at https://expo.io/@user/project/index.exp, the
|
||||
* base URL would be https://expo.io/@user/project.
|
||||
*
|
||||
* We also normalize the "exp" protocol to "http" to handle internal URLs with the Expo schemes used
|
||||
* to tell the OS to open the URLs in the the Expo client.
|
||||
*/
|
||||
export declare function getManifestBaseUrl(manifestUrl: string): string;
|
39
node_modules/expo-asset/build/AssetUris.js
generated
vendored
Normal file
39
node_modules/expo-asset/build/AssetUris.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
import URL from 'url-parse';
|
||||
export function getFilename(url) {
|
||||
const { pathname } = new URL(url, {});
|
||||
return pathname.substring(pathname.lastIndexOf('/') + 1);
|
||||
}
|
||||
export function getFileExtension(url) {
|
||||
const filename = getFilename(url);
|
||||
const dotIndex = filename.lastIndexOf('.');
|
||||
// Ignore leading dots for hidden files
|
||||
return dotIndex > 0 ? filename.substring(dotIndex) : '';
|
||||
}
|
||||
/**
|
||||
* Returns the base URL from a manifest's URL. For example, given a manifest hosted at
|
||||
* https://example.com/app/manifest.json, the base URL would be https://example.com/app/. Query
|
||||
* parameters and fragments also are removed.
|
||||
*
|
||||
* For an Expo-hosted project with a manifest hosted at https://expo.io/@user/project/index.exp, the
|
||||
* base URL would be https://expo.io/@user/project.
|
||||
*
|
||||
* We also normalize the "exp" protocol to "http" to handle internal URLs with the Expo schemes used
|
||||
* to tell the OS to open the URLs in the the Expo client.
|
||||
*/
|
||||
export function getManifestBaseUrl(manifestUrl) {
|
||||
const urlObject = new URL(manifestUrl, {});
|
||||
// Change the scheme to http(s) if it is exp(s)
|
||||
if (urlObject.protocol === 'exp:') {
|
||||
urlObject.set('protocol', 'http:');
|
||||
}
|
||||
else if (urlObject.protocol === 'exps:') {
|
||||
urlObject.set('protocol', 'https:');
|
||||
}
|
||||
// Trim filename, query parameters, and fragment, if any
|
||||
const directory = urlObject.pathname.substring(0, urlObject.pathname.lastIndexOf('/') + 1);
|
||||
urlObject.set('pathname', directory);
|
||||
urlObject.set('query', '');
|
||||
urlObject.set('hash', '');
|
||||
return urlObject.href;
|
||||
}
|
||||
//# sourceMappingURL=AssetUris.js.map
|
1
node_modules/expo-asset/build/AssetUris.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/AssetUris.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AssetUris.js","sourceRoot":"","sources":["../src/AssetUris.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,WAAW,CAAC;AAE5B,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3C,uCAAuC;IACvC,OAAO,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAE3C,+CAA+C;IAC/C,IAAI,SAAS,CAAC,QAAQ,KAAK,MAAM,EAAE;QACjC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;KACpC;SAAM,IAAI,SAAS,CAAC,QAAQ,KAAK,OAAO,EAAE;QACzC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KACrC;IAED,wDAAwD;IACxD,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3F,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACrC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC3B,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAE1B,OAAO,SAAS,CAAC,IAAI,CAAC;AACxB,CAAC","sourcesContent":["import URL from 'url-parse';\n\nexport function getFilename(url: string): string {\n const { pathname } = new URL(url, {});\n return pathname.substring(pathname.lastIndexOf('/') + 1);\n}\n\nexport function getFileExtension(url: string): string {\n const filename = getFilename(url);\n const dotIndex = filename.lastIndexOf('.');\n // Ignore leading dots for hidden files\n return dotIndex > 0 ? filename.substring(dotIndex) : '';\n}\n\n/**\n * Returns the base URL from a manifest's URL. For example, given a manifest hosted at\n * https://example.com/app/manifest.json, the base URL would be https://example.com/app/. Query\n * parameters and fragments also are removed.\n *\n * For an Expo-hosted project with a manifest hosted at https://expo.io/@user/project/index.exp, the\n * base URL would be https://expo.io/@user/project.\n *\n * We also normalize the \"exp\" protocol to \"http\" to handle internal URLs with the Expo schemes used\n * to tell the OS to open the URLs in the the Expo client.\n */\nexport function getManifestBaseUrl(manifestUrl: string): string {\n const urlObject = new URL(manifestUrl, {});\n\n // Change the scheme to http(s) if it is exp(s)\n if (urlObject.protocol === 'exp:') {\n urlObject.set('protocol', 'http:');\n } else if (urlObject.protocol === 'exps:') {\n urlObject.set('protocol', 'https:');\n }\n\n // Trim filename, query parameters, and fragment, if any\n const directory = urlObject.pathname.substring(0, urlObject.pathname.lastIndexOf('/') + 1);\n urlObject.set('pathname', directory);\n urlObject.set('query', '');\n urlObject.set('hash', '');\n\n return urlObject.href;\n}\n"]}
|
5
node_modules/expo-asset/build/EmbeddedAssets.d.ts
generated
vendored
Normal file
5
node_modules/expo-asset/build/EmbeddedAssets.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Returns the local URI of an embedded asset from its hash and type, or null if the asset is not
|
||||
* included in the app bundle.
|
||||
*/
|
||||
export declare function getEmbeddedAssetUri(hash: string, type: string | null): string | null;
|
25
node_modules/expo-asset/build/EmbeddedAssets.js
generated
vendored
Normal file
25
node_modules/expo-asset/build/EmbeddedAssets.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import Constants from 'expo-constants';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { getLocalAssets } from './PlatformUtils';
|
||||
// Fast lookup check if assets are available in the local bundle in managed apps
|
||||
const bundledAssets = new Set(FileSystem.bundledAssets || []);
|
||||
// localAssets are provided by the expo-updates module
|
||||
const localAssets = getLocalAssets();
|
||||
/**
|
||||
* Returns the local URI of an embedded asset from its hash and type, or null if the asset is not
|
||||
* included in the app bundle.
|
||||
*/
|
||||
export function getEmbeddedAssetUri(hash, type) {
|
||||
const localAssetsKey = `${hash}.${type ?? ''}`;
|
||||
if (!localAssets.hasOwnProperty(localAssetsKey) && !__DEV__) {
|
||||
// check legacy location in case we're in Expo client/managed workflow
|
||||
// TODO(eric): remove this once bundledAssets is no longer exported from FileSystem
|
||||
const assetName = `asset_${hash}${type ? `.${type}` : ''}`;
|
||||
if (Constants.appOwnership !== 'standalone' || !bundledAssets.has(assetName)) {
|
||||
return null;
|
||||
}
|
||||
return `${FileSystem.bundleDirectory}${assetName}`;
|
||||
}
|
||||
return localAssets[localAssetsKey] ?? null;
|
||||
}
|
||||
//# sourceMappingURL=EmbeddedAssets.js.map
|
1
node_modules/expo-asset/build/EmbeddedAssets.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/EmbeddedAssets.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"EmbeddedAssets.js","sourceRoot":"","sources":["../src/EmbeddedAssets.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,gFAAgF;AAChF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;AAE9D,sDAAsD;AACtD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,IAAmB;IACnE,MAAM,cAAc,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;IAC/C,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE;QAC3D,sEAAsE;QACtE,mFAAmF;QACnF,MAAM,SAAS,GAAG,SAAS,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC3D,IAAI,SAAS,CAAC,YAAY,KAAK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC5E,OAAO,IAAI,CAAC;SACb;QACD,OAAO,GAAG,UAAU,CAAC,eAAe,GAAG,SAAS,EAAE,CAAC;KACpD;IACD,OAAO,WAAW,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC;AAC7C,CAAC","sourcesContent":["import Constants from 'expo-constants';\nimport * as FileSystem from 'expo-file-system';\n\nimport { getLocalAssets } from './PlatformUtils';\n\n// Fast lookup check if assets are available in the local bundle in managed apps\nconst bundledAssets = new Set(FileSystem.bundledAssets || []);\n\n// localAssets are provided by the expo-updates module\nconst localAssets = getLocalAssets();\n\n/**\n * Returns the local URI of an embedded asset from its hash and type, or null if the asset is not\n * included in the app bundle.\n */\nexport function getEmbeddedAssetUri(hash: string, type: string | null): string | null {\n const localAssetsKey = `${hash}.${type ?? ''}`;\n if (!localAssets.hasOwnProperty(localAssetsKey) && !__DEV__) {\n // check legacy location in case we're in Expo client/managed workflow\n // TODO(eric): remove this once bundledAssets is no longer exported from FileSystem\n const assetName = `asset_${hash}${type ? `.${type}` : ''}`;\n if (Constants.appOwnership !== 'standalone' || !bundledAssets.has(assetName)) {\n return null;\n }\n return `${FileSystem.bundleDirectory}${assetName}`;\n }\n return localAssets[localAssetsKey] ?? null;\n}\n"]}
|
1
node_modules/expo-asset/build/EmbeddedAssets.web.d.ts
generated
vendored
Normal file
1
node_modules/expo-asset/build/EmbeddedAssets.web.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function getEmbeddedAssetUri(hash: string, type: string | null): string | null;
|
5
node_modules/expo-asset/build/EmbeddedAssets.web.js
generated
vendored
Normal file
5
node_modules/expo-asset/build/EmbeddedAssets.web.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export function getEmbeddedAssetUri(hash, type) {
|
||||
// noop on web
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=EmbeddedAssets.web.js.map
|
1
node_modules/expo-asset/build/EmbeddedAssets.web.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/EmbeddedAssets.web.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"EmbeddedAssets.web.js","sourceRoot":"","sources":["../src/EmbeddedAssets.web.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,IAAmB;IACnE,cAAc;IACd,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function getEmbeddedAssetUri(hash: string, type: string | null): string | null {\n // noop on web\n return null;\n}\n"]}
|
8
node_modules/expo-asset/build/ImageAssets.d.ts
generated
vendored
Normal file
8
node_modules/expo-asset/build/ImageAssets.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
declare type ImageInfo = {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
export declare function isImageType(type: string): boolean;
|
||||
export declare function getImageInfoAsync(url: string): Promise<ImageInfo>;
|
||||
export {};
|
20
node_modules/expo-asset/build/ImageAssets.js
generated
vendored
Normal file
20
node_modules/expo-asset/build/ImageAssets.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/* eslint-env browser */
|
||||
import { getFilename } from './AssetUris';
|
||||
export function isImageType(type) {
|
||||
return /^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(type);
|
||||
}
|
||||
export function getImageInfoAsync(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onerror = reject;
|
||||
img.onload = () => {
|
||||
resolve({
|
||||
name: getFilename(url),
|
||||
width: img.naturalWidth,
|
||||
height: img.naturalHeight,
|
||||
});
|
||||
};
|
||||
img.src = url;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=ImageAssets.js.map
|
1
node_modules/expo-asset/build/ImageAssets.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/ImageAssets.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ImageAssets.js","sourceRoot":"","sources":["../src/ImageAssets.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ1C,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,qCAAqC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;QACrB,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;YAChB,OAAO,CAAC;gBACN,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC;gBACtB,KAAK,EAAE,GAAG,CAAC,YAAY;gBACvB,MAAM,EAAE,GAAG,CAAC,aAAa;aAC1B,CAAC,CAAC;QACL,CAAC,CAAC;QACF,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-env browser */\nimport { getFilename } from './AssetUris';\n\ntype ImageInfo = {\n name: string;\n width: number;\n height: number;\n};\n\nexport function isImageType(type: string): boolean {\n return /^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(type);\n}\n\nexport function getImageInfoAsync(url: string): Promise<ImageInfo> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onerror = reject;\n img.onload = () => {\n resolve({\n name: getFilename(url),\n width: img.naturalWidth,\n height: img.naturalHeight,\n });\n };\n img.src = url;\n });\n}\n"]}
|
10
node_modules/expo-asset/build/PlatformUtils.d.ts
generated
vendored
Normal file
10
node_modules/expo-asset/build/PlatformUtils.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export declare const IS_MANAGED_ENV: boolean;
|
||||
export declare const IS_BARE_ENV_WITH_UPDATES: boolean;
|
||||
export declare const IS_ENV_WITH_UPDATES_ENABLED: boolean;
|
||||
export declare const IS_BARE_ENV_WITHOUT_UPDATES: boolean;
|
||||
export declare function getLocalAssets(): any;
|
||||
export declare function getManifest(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
export declare const manifestBaseUrl: string | null;
|
||||
export declare function downloadAsync(uri: any, hash: any, type: any, name: any): Promise<string>;
|
78
node_modules/expo-asset/build/PlatformUtils.js
generated
vendored
Normal file
78
node_modules/expo-asset/build/PlatformUtils.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
import { NativeModulesProxy } from '@unimodules/core';
|
||||
import computeMd5 from 'blueimp-md5';
|
||||
import Constants from 'expo-constants';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { getManifestBaseUrl } from './AssetUris';
|
||||
// Constants.appOwnership is only available in managed apps (Expo client and standalone)
|
||||
export const IS_MANAGED_ENV = !!Constants.appOwnership;
|
||||
// In the future (SDK38+) expo-updates is likely to be used in managed apps, so we decide
|
||||
// that you are in a bare app with updates if you're not in a managed app and you have
|
||||
// local assets available.
|
||||
export const IS_BARE_ENV_WITH_UPDATES = !IS_MANAGED_ENV &&
|
||||
!!NativeModulesProxy.ExpoUpdates?.isEnabled &&
|
||||
// if expo-updates is installed but we're running directly from the embedded bundle, we don't want
|
||||
// to override the AssetSourceResolver
|
||||
!NativeModulesProxy.ExpoUpdates?.isUsingEmbeddedAssets;
|
||||
export const IS_ENV_WITH_UPDATES_ENABLED = IS_MANAGED_ENV || IS_BARE_ENV_WITH_UPDATES;
|
||||
// If it's not managed or bare w/ updates, then it must be bare w/o updates!
|
||||
export const IS_BARE_ENV_WITHOUT_UPDATES = !IS_MANAGED_ENV && !IS_BARE_ENV_WITH_UPDATES;
|
||||
// Get the localAssets property from the ExpoUpdates native module so that we do
|
||||
// not need to include expo-updates as a dependency of expo-asset
|
||||
export function getLocalAssets() {
|
||||
return NativeModulesProxy.ExpoUpdates?.localAssets ?? {};
|
||||
}
|
||||
export function getManifest() {
|
||||
return Constants.manifest ?? {};
|
||||
}
|
||||
// Compute manifest base URL if available
|
||||
export const manifestBaseUrl = Constants.experienceUrl
|
||||
? getManifestBaseUrl(Constants.experienceUrl)
|
||||
: null;
|
||||
// TODO: how should this behave in bare app with updates? re: hashAssetFiles
|
||||
export async function downloadAsync(uri, hash, type, name) {
|
||||
if (IS_MANAGED_ENV) {
|
||||
return _downloadAsyncManagedEnv(uri, hash, type, name);
|
||||
}
|
||||
return _downloadAsyncUnmanagedEnv(uri, hash, type);
|
||||
}
|
||||
/**
|
||||
* Check if the file exists on disk already, perform integrity check if so.
|
||||
* Otherwise, download it.
|
||||
*/
|
||||
async function _downloadAsyncManagedEnv(uri, hash, type, name) {
|
||||
const cacheFileId = hash || computeMd5(uri);
|
||||
const localUri = `${FileSystem.cacheDirectory}ExponentAsset-${cacheFileId}.${type}`;
|
||||
let { exists, md5 } = await FileSystem.getInfoAsync(localUri, {
|
||||
md5: true,
|
||||
});
|
||||
if (!exists || (hash !== null && md5 !== hash)) {
|
||||
({ md5 } = await FileSystem.downloadAsync(uri, localUri, {
|
||||
md5: true,
|
||||
}));
|
||||
if (hash !== null && md5 !== hash) {
|
||||
throw new Error(`Downloaded file for asset '${name}.${type}' ` +
|
||||
`Located at ${uri} ` +
|
||||
`failed MD5 integrity check`);
|
||||
}
|
||||
}
|
||||
return localUri;
|
||||
}
|
||||
/**
|
||||
* Just download the asset, don't perform integrity check because we don't have
|
||||
* the hash to compare it with (we don't have hashAssetFiles plugin). Hash is
|
||||
* only used for the file name.
|
||||
*/
|
||||
async function _downloadAsyncUnmanagedEnv(uri, hash, type) {
|
||||
// TODO: does this make sense to bail out if it's already at a file URL
|
||||
// because it's already available locally?
|
||||
if (uri.startsWith('file://')) {
|
||||
return uri;
|
||||
}
|
||||
const cacheFileId = hash || computeMd5(uri);
|
||||
const localUri = `${FileSystem.cacheDirectory}ExponentAsset-${cacheFileId}.${type}`;
|
||||
// We don't check the FileSystem for an existing version of the asset and we
|
||||
// also don't perform an integrity check!
|
||||
await FileSystem.downloadAsync(uri, localUri);
|
||||
return localUri;
|
||||
}
|
||||
//# sourceMappingURL=PlatformUtils.js.map
|
1
node_modules/expo-asset/build/PlatformUtils.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/PlatformUtils.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/expo-asset/build/PlatformUtils.web.d.ts
generated
vendored
Normal file
6
node_modules/expo-asset/build/PlatformUtils.web.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export declare const IS_MANAGED_ENV = false;
|
||||
export declare const IS_ENV_WITH_UPDATES_ENABLED = false;
|
||||
export declare const IS_ENV_WITHOUT_UPDATES_ENABLED = false;
|
||||
export declare const manifestBaseUrl: null;
|
||||
export declare function downloadAsync(uri: any, hash: any, type: any, name: any): Promise<string>;
|
||||
export declare function getManifest(): {};
|
12
node_modules/expo-asset/build/PlatformUtils.web.js
generated
vendored
Normal file
12
node_modules/expo-asset/build/PlatformUtils.web.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
export const IS_MANAGED_ENV = false;
|
||||
export const IS_ENV_WITH_UPDATES_ENABLED = false;
|
||||
export const IS_ENV_WITHOUT_UPDATES_ENABLED = false;
|
||||
// Compute manifest base URL if available
|
||||
export const manifestBaseUrl = null;
|
||||
export async function downloadAsync(uri, hash, type, name) {
|
||||
return uri;
|
||||
}
|
||||
export function getManifest() {
|
||||
return {};
|
||||
}
|
||||
//# sourceMappingURL=PlatformUtils.web.js.map
|
1
node_modules/expo-asset/build/PlatformUtils.web.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/PlatformUtils.web.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlatformUtils.web.js","sourceRoot":"","sources":["../src/PlatformUtils.web.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AACpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AACjD,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEpD,yCAAyC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACvD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["export const IS_MANAGED_ENV = false;\nexport const IS_ENV_WITH_UPDATES_ENABLED = false;\nexport const IS_ENV_WITHOUT_UPDATES_ENABLED = false;\n\n// Compute manifest base URL if available\nexport const manifestBaseUrl = null;\n\nexport async function downloadAsync(uri, hash, type, name): Promise<string> {\n return uri;\n}\n\nexport function getManifest() {\n return {};\n}\n"]}
|
3
node_modules/expo-asset/build/index.d.ts
generated
vendored
Normal file
3
node_modules/expo-asset/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import './Asset.fx';
|
||||
export * from './Asset';
|
||||
export * from './AssetHooks';
|
4
node_modules/expo-asset/build/index.js
generated
vendored
Normal file
4
node_modules/expo-asset/build/index.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import './Asset.fx';
|
||||
export * from './Asset';
|
||||
export * from './AssetHooks';
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/expo-asset/build/index.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC","sourcesContent":["import './Asset.fx';\n\nexport * from './Asset';\nexport * from './AssetHooks';\n"]}
|
3
node_modules/expo-asset/build/resolveAssetSource.d.ts
generated
vendored
Normal file
3
node_modules/expo-asset/build/resolveAssetSource.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
||||
export default resolveAssetSource;
|
||||
export * from 'react-native/Libraries/Image/resolveAssetSource';
|
4
node_modules/expo-asset/build/resolveAssetSource.js
generated
vendored
Normal file
4
node_modules/expo-asset/build/resolveAssetSource.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
||||
export default resolveAssetSource;
|
||||
export * from 'react-native/Libraries/Image/resolveAssetSource'; // eslint-disable-line import/export
|
||||
//# sourceMappingURL=resolveAssetSource.js.map
|
1
node_modules/expo-asset/build/resolveAssetSource.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/resolveAssetSource.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"resolveAssetSource.js","sourceRoot":"","sources":["../src/resolveAssetSource.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,iDAAiD,CAAC;AACjF,eAAe,kBAAkB,CAAC;AAClC,cAAc,iDAAiD,CAAC,CAAC,oCAAoC","sourcesContent":["import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';\nexport default resolveAssetSource;\nexport * from 'react-native/Libraries/Image/resolveAssetSource'; // eslint-disable-line import/export\n"]}
|
8
node_modules/expo-asset/build/resolveAssetSource.web.d.ts
generated
vendored
Normal file
8
node_modules/expo-asset/build/resolveAssetSource.web.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import AssetSourceResolver, { ResolvedAssetSource } from './AssetSourceResolver';
|
||||
export declare function setCustomSourceTransformer(transformer: (resolver: AssetSourceResolver) => ResolvedAssetSource): void;
|
||||
/**
|
||||
* `source` is either a number (opaque type returned by require('./foo.png'))
|
||||
* or an `ImageSource` like { uri: '<http location || file path>' }
|
||||
*/
|
||||
export default function resolveAssetSource(source: any): ResolvedAssetSource | undefined;
|
||||
export declare const pickScale: typeof AssetSourceResolver.pickScale;
|
82
node_modules/expo-asset/build/resolveAssetSource.web.js
generated
vendored
Normal file
82
node_modules/expo-asset/build/resolveAssetSource.web.js
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
import { NativeModules } from 'react-native';
|
||||
import { getAssetByID } from './AssetRegistry';
|
||||
import AssetSourceResolver from './AssetSourceResolver';
|
||||
let _customSourceTransformer;
|
||||
let _serverURL;
|
||||
let _scriptURL;
|
||||
let _sourceCodeScriptURL;
|
||||
function getSourceCodeScriptURL() {
|
||||
if (_sourceCodeScriptURL) {
|
||||
return _sourceCodeScriptURL;
|
||||
}
|
||||
let sourceCode = nativeExtensions && nativeExtensions.SourceCode;
|
||||
if (!sourceCode) {
|
||||
sourceCode = NativeModules && NativeModules.SourceCode;
|
||||
}
|
||||
_sourceCodeScriptURL = sourceCode.scriptURL;
|
||||
return _sourceCodeScriptURL;
|
||||
}
|
||||
function getDevServerURL() {
|
||||
if (_serverURL === undefined) {
|
||||
const sourceCodeScriptURL = getSourceCodeScriptURL();
|
||||
const match = sourceCodeScriptURL && sourceCodeScriptURL.match(/^https?:\/\/.*?\//);
|
||||
if (match) {
|
||||
// jsBundle was loaded from network
|
||||
_serverURL = match[0];
|
||||
}
|
||||
else {
|
||||
// jsBundle was loaded from file
|
||||
_serverURL = null;
|
||||
}
|
||||
}
|
||||
return _serverURL;
|
||||
}
|
||||
function _coerceLocalScriptURL(scriptURL) {
|
||||
if (scriptURL) {
|
||||
if (scriptURL.startsWith('assets://')) {
|
||||
// android: running from within assets, no offline path to use
|
||||
return null;
|
||||
}
|
||||
scriptURL = scriptURL.substring(0, scriptURL.lastIndexOf('/') + 1);
|
||||
if (!scriptURL.includes('://')) {
|
||||
// Add file protocol in case we have an absolute file path and not a URL.
|
||||
// This shouldn't really be necessary. scriptURL should be a URL.
|
||||
scriptURL = 'file://' + scriptURL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getScriptURL() {
|
||||
if (_scriptURL === undefined) {
|
||||
_scriptURL = _coerceLocalScriptURL(getSourceCodeScriptURL());
|
||||
}
|
||||
return _scriptURL;
|
||||
}
|
||||
export function setCustomSourceTransformer(transformer) {
|
||||
_customSourceTransformer = transformer;
|
||||
}
|
||||
/**
|
||||
* `source` is either a number (opaque type returned by require('./foo.png'))
|
||||
* or an `ImageSource` like { uri: '<http location || file path>' }
|
||||
*/
|
||||
export default function resolveAssetSource(source) {
|
||||
if (typeof source === 'object') {
|
||||
return source;
|
||||
}
|
||||
const asset = getAssetByID(source);
|
||||
if (!asset) {
|
||||
return undefined;
|
||||
}
|
||||
const resolver = new AssetSourceResolver(getDevServerURL(), getScriptURL(), asset);
|
||||
if (_customSourceTransformer) {
|
||||
return _customSourceTransformer(resolver);
|
||||
}
|
||||
return resolver.defaultAsset();
|
||||
}
|
||||
Object.defineProperty(resolveAssetSource, 'setCustomSourceTransformer', {
|
||||
get() {
|
||||
return setCustomSourceTransformer;
|
||||
},
|
||||
});
|
||||
export const { pickScale } = AssetSourceResolver;
|
||||
//# sourceMappingURL=resolveAssetSource.web.js.map
|
1
node_modules/expo-asset/build/resolveAssetSource.web.js.map
generated
vendored
Normal file
1
node_modules/expo-asset/build/resolveAssetSource.web.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
62
node_modules/expo-asset/package.json
generated
vendored
Normal file
62
node_modules/expo-asset/package.json
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "expo-asset",
|
||||
"version": "8.2.2",
|
||||
"description": "An Expo universal module to download assets and pass them into other APIs",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
"sideEffects": [
|
||||
"*.fx.js",
|
||||
"*.fx.web.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "expo-module build",
|
||||
"clean": "expo-module clean",
|
||||
"lint": "expo-module lint",
|
||||
"test": "expo-module test",
|
||||
"prepare": "expo-module prepare",
|
||||
"prepublishOnly": "expo-module prepublishOnly",
|
||||
"expo-module": "expo-module"
|
||||
},
|
||||
"keywords": [
|
||||
"react-native",
|
||||
"expo",
|
||||
"asset"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/expo/expo.git",
|
||||
"directory": "packages/expo-asset"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/expo/expo/issues"
|
||||
},
|
||||
"author": "650 Industries, Inc.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://docs.expo.io/versions/latest/sdk/asset/",
|
||||
"jest": {
|
||||
"preset": "expo-module-scripts/ios"
|
||||
},
|
||||
"unimodulePeerDependencies": {
|
||||
"@unimodules/core": "*",
|
||||
"expo-constants": "*",
|
||||
"expo-file-system": "*",
|
||||
"expo-updates": "*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"blueimp-md5": "^2.10.0",
|
||||
"invariant": "^2.2.4",
|
||||
"md5-file": "^3.2.3",
|
||||
"path-browserify": "^1.0.0",
|
||||
"url-parse": "^1.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/react-hooks": "^3.3.0",
|
||||
"@types/url-parse": "^1.4.1",
|
||||
"expo-module-scripts": "~1.2.0"
|
||||
},
|
||||
"gitHead": "e362887ddc6ba4e3518efd623d64b3cbd301a6a9"
|
||||
}
|
20
node_modules/expo-asset/src/Asset.fx.ts
generated
vendored
Normal file
20
node_modules/expo-asset/src/Asset.fx.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import { Asset } from './Asset';
|
||||
import { IS_ENV_WITH_UPDATES_ENABLED } from './PlatformUtils';
|
||||
import { setCustomSourceTransformer } from './resolveAssetSource';
|
||||
|
||||
// Override React Native's asset resolution for `Image` components in contexts where it matters
|
||||
if (IS_ENV_WITH_UPDATES_ENABLED) {
|
||||
setCustomSourceTransformer(resolver => {
|
||||
try {
|
||||
// Bundler is using the hashAssetFiles plugin if and only if the fileHashes property exists
|
||||
if (resolver.asset.fileHashes) {
|
||||
const asset = Asset.fromMetadata(resolver.asset);
|
||||
return resolver.fromSource(asset.downloaded ? asset.localUri! : asset.uri);
|
||||
} else {
|
||||
return resolver.defaultAsset();
|
||||
}
|
||||
} catch (e) {
|
||||
return resolver.defaultAsset();
|
||||
}
|
||||
});
|
||||
}
|
199
node_modules/expo-asset/src/Asset.ts
generated
vendored
Normal file
199
node_modules/expo-asset/src/Asset.ts
generated
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
import { Platform } from '@unimodules/core';
|
||||
|
||||
import { getAssetByID } from './AssetRegistry';
|
||||
import * as AssetSources from './AssetSources';
|
||||
import * as AssetUris from './AssetUris';
|
||||
import { getEmbeddedAssetUri } from './EmbeddedAssets';
|
||||
import * as ImageAssets from './ImageAssets';
|
||||
import { downloadAsync, IS_ENV_WITH_UPDATES_ENABLED } from './PlatformUtils';
|
||||
import resolveAssetSource from './resolveAssetSource';
|
||||
|
||||
type AssetDescriptor = {
|
||||
name: string;
|
||||
type: string;
|
||||
hash?: string | null;
|
||||
uri: string;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
};
|
||||
|
||||
type DownloadPromiseCallbacks = {
|
||||
resolve: () => void;
|
||||
reject: (error: Error) => void;
|
||||
};
|
||||
|
||||
export type AssetMetadata = AssetSources.AssetMetadata;
|
||||
|
||||
export class Asset {
|
||||
static byHash = {};
|
||||
static byUri = {};
|
||||
|
||||
name: string;
|
||||
type: string;
|
||||
hash: string | null = null;
|
||||
uri: string;
|
||||
localUri: string | null = null;
|
||||
width: number | null = null;
|
||||
height: number | null = null;
|
||||
downloading: boolean = false;
|
||||
downloaded: boolean = false;
|
||||
_downloadCallbacks: DownloadPromiseCallbacks[] = [];
|
||||
|
||||
constructor({ name, type, hash = null, uri, width, height }: AssetDescriptor) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.hash = hash;
|
||||
this.uri = uri;
|
||||
|
||||
if (typeof width === 'number') {
|
||||
this.width = width;
|
||||
}
|
||||
if (typeof height === 'number') {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
if (hash) {
|
||||
this.localUri = getEmbeddedAssetUri(hash, type);
|
||||
if (this.localUri) {
|
||||
this.downloaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Platform.OS === 'web') {
|
||||
if (!name) {
|
||||
this.name = AssetUris.getFilename(uri);
|
||||
}
|
||||
if (!type) {
|
||||
this.type = AssetUris.getFileExtension(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static loadAsync(moduleId: number | number[] | string | string[]): Promise<Asset[]> {
|
||||
const moduleIds = Array.isArray(moduleId) ? moduleId : [moduleId];
|
||||
return Promise.all(moduleIds.map(moduleId => Asset.fromModule(moduleId).downloadAsync()));
|
||||
}
|
||||
|
||||
static fromModule(virtualAssetModule: number | string): Asset {
|
||||
if (typeof virtualAssetModule === 'string') {
|
||||
return Asset.fromURI(virtualAssetModule);
|
||||
}
|
||||
|
||||
const meta = getAssetByID(virtualAssetModule);
|
||||
if (!meta) {
|
||||
throw new Error(`Module "${virtualAssetModule}" is missing from the asset registry`);
|
||||
}
|
||||
|
||||
// Outside of the managed env we need the moduleId to initialize the asset
|
||||
// because resolveAssetSource depends on it
|
||||
if (!IS_ENV_WITH_UPDATES_ENABLED) {
|
||||
const { uri } = resolveAssetSource(virtualAssetModule);
|
||||
const asset = new Asset({
|
||||
name: meta.name,
|
||||
type: meta.type,
|
||||
hash: meta.hash,
|
||||
uri,
|
||||
width: meta.width,
|
||||
height: meta.height,
|
||||
});
|
||||
|
||||
// TODO: FileSystem should probably support 'downloading' from drawable
|
||||
// resources But for now it doesn't (it only supports raw resources) and
|
||||
// React Native's Image works fine with drawable resource names for
|
||||
// images.
|
||||
if (Platform.OS === 'android' && !uri.includes(':') && (meta.width || meta.height)) {
|
||||
asset.localUri = asset.uri;
|
||||
asset.downloaded = true;
|
||||
}
|
||||
|
||||
Asset.byHash[meta.hash] = asset;
|
||||
return asset;
|
||||
}
|
||||
|
||||
return Asset.fromMetadata(meta);
|
||||
}
|
||||
|
||||
static fromMetadata(meta: AssetMetadata): Asset {
|
||||
// The hash of the whole asset, not to be confused with the hash of a specific file returned
|
||||
// from `selectAssetSource`
|
||||
const metaHash = meta.hash;
|
||||
if (Asset.byHash[metaHash]) {
|
||||
return Asset.byHash[metaHash];
|
||||
}
|
||||
|
||||
const { uri, hash } = AssetSources.selectAssetSource(meta);
|
||||
const asset = new Asset({
|
||||
name: meta.name,
|
||||
type: meta.type,
|
||||
hash,
|
||||
uri,
|
||||
width: meta.width,
|
||||
height: meta.height,
|
||||
});
|
||||
Asset.byHash[metaHash] = asset;
|
||||
return asset;
|
||||
}
|
||||
|
||||
static fromURI(uri: string): Asset {
|
||||
if (Asset.byUri[uri]) {
|
||||
return Asset.byUri[uri];
|
||||
}
|
||||
|
||||
// Possibly a Base64-encoded URI
|
||||
let type = '';
|
||||
if (uri.indexOf(';base64') > -1) {
|
||||
type = uri.split(';')[0].split('/')[1];
|
||||
} else {
|
||||
const extension = AssetUris.getFileExtension(uri);
|
||||
type = extension.startsWith('.') ? extension.substring(1) : extension;
|
||||
}
|
||||
|
||||
const asset = new Asset({
|
||||
name: '',
|
||||
type,
|
||||
hash: null,
|
||||
uri,
|
||||
});
|
||||
|
||||
Asset.byUri[uri] = asset;
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
async downloadAsync(): Promise<this> {
|
||||
if (this.downloaded) {
|
||||
return this;
|
||||
}
|
||||
if (this.downloading) {
|
||||
await new Promise((resolve, reject) => {
|
||||
this._downloadCallbacks.push({ resolve, reject });
|
||||
});
|
||||
return this;
|
||||
}
|
||||
this.downloading = true;
|
||||
|
||||
try {
|
||||
if (Platform.OS === 'web') {
|
||||
if (ImageAssets.isImageType(this.type)) {
|
||||
const { width, height, name } = await ImageAssets.getImageInfoAsync(this.uri);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.name = name;
|
||||
} else {
|
||||
this.name = AssetUris.getFilename(this.uri);
|
||||
}
|
||||
}
|
||||
this.localUri = await downloadAsync(this.uri, this.hash, this.type, this.name);
|
||||
|
||||
this.downloaded = true;
|
||||
this._downloadCallbacks.forEach(({ resolve }) => resolve());
|
||||
} catch (e) {
|
||||
this._downloadCallbacks.forEach(({ reject }) => reject(e));
|
||||
throw e;
|
||||
} finally {
|
||||
this.downloading = false;
|
||||
this._downloadCallbacks = [];
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
31
node_modules/expo-asset/src/AssetHooks.ts
generated
vendored
Normal file
31
node_modules/expo-asset/src/AssetHooks.ts
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { Asset } from './Asset';
|
||||
|
||||
/**
|
||||
* Downloads and stores one or more assets locally.
|
||||
* After the assets are loaded, this hook returns a list of asset instances.
|
||||
* If something went wrong when loading the assets, an error is returned.
|
||||
*
|
||||
* Note, the assets are not "reloaded" when you dynamically change the asset list.
|
||||
*
|
||||
* @see https://docs.expo.io/versions/latest/sdk/asset/
|
||||
* @example
|
||||
* ```tsx
|
||||
* const [assets, error] = useAssets(require('path/to/asset.jpg'));
|
||||
*
|
||||
* return !assets ? null : <Image source={assets[0]} />;
|
||||
* ```
|
||||
*/
|
||||
export function useAssets(moduleIds: number | number[]): [Asset[] | undefined, Error | undefined] {
|
||||
const [assets, setAssets] = useState<Asset[]>();
|
||||
const [error, setError] = useState<Error>();
|
||||
|
||||
useEffect(() => {
|
||||
Asset.loadAsync(moduleIds)
|
||||
.then(setAssets)
|
||||
.catch(setError);
|
||||
}, []);
|
||||
|
||||
return [assets, error];
|
||||
}
|
1
node_modules/expo-asset/src/AssetRegistry.ts
generated
vendored
Normal file
1
node_modules/expo-asset/src/AssetRegistry.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from 'react-native/Libraries/Image/AssetRegistry';
|
1
node_modules/expo-asset/src/AssetRegistry.web.ts
generated
vendored
Normal file
1
node_modules/expo-asset/src/AssetRegistry.web.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from 'react-native-web/dist/modules/AssetRegistry';
|
3
node_modules/expo-asset/src/AssetSourceResolver.ts
generated
vendored
Normal file
3
node_modules/expo-asset/src/AssetSourceResolver.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import AssetSourceResolver from 'react-native/Libraries/Image/AssetSourceResolver';
|
||||
export default AssetSourceResolver;
|
||||
export * from 'react-native/Libraries/Image/AssetSourceResolver';
|
114
node_modules/expo-asset/src/AssetSourceResolver.web.ts
generated
vendored
Normal file
114
node_modules/expo-asset/src/AssetSourceResolver.web.ts
generated
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
import { Platform, UnavailabilityError } from '@unimodules/core';
|
||||
import invariant from 'invariant';
|
||||
import { Dimensions } from 'react-native';
|
||||
|
||||
type PackagerAsset = {
|
||||
__packager_asset: boolean;
|
||||
fileSystemLocation: string;
|
||||
httpServerLocation: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
scales: number[];
|
||||
hash: string;
|
||||
name: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
function getBasePath({ httpServerLocation }: PackagerAsset): string {
|
||||
if (httpServerLocation[0] === '/') {
|
||||
return httpServerLocation.substr(1);
|
||||
}
|
||||
return httpServerLocation;
|
||||
}
|
||||
|
||||
export type ResolvedAssetSource = {
|
||||
__packager_asset: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
uri: string;
|
||||
scale: number;
|
||||
};
|
||||
|
||||
function getScale(): number {
|
||||
return Dimensions.get('window').scale;
|
||||
}
|
||||
|
||||
function getScaledAssetPath(asset): string {
|
||||
const scale = AssetSourceResolver.pickScale(asset.scales, getScale());
|
||||
const scaleSuffix = scale === 1 ? '' : '@' + scale + 'x';
|
||||
const assetDir = getBasePath(asset);
|
||||
return assetDir + '/' + asset.name + scaleSuffix + '.' + asset.type;
|
||||
}
|
||||
|
||||
export default class AssetSourceResolver {
|
||||
serverUrl?: string | null;
|
||||
// where the jsbundle is being run from
|
||||
jsbundleUrl?: string | null;
|
||||
// the asset to resolve
|
||||
asset: PackagerAsset;
|
||||
|
||||
constructor(
|
||||
serverUrl: string | undefined | null,
|
||||
jsbundleUrl: string | undefined | null,
|
||||
asset: PackagerAsset
|
||||
) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.jsbundleUrl = jsbundleUrl;
|
||||
this.asset = asset;
|
||||
}
|
||||
isLoadedFromServer(): boolean {
|
||||
return !!this.serverUrl;
|
||||
}
|
||||
isLoadedFromFileSystem(): boolean {
|
||||
return !!(this.jsbundleUrl && this.jsbundleUrl.startsWith('file://'));
|
||||
}
|
||||
defaultAsset(): ResolvedAssetSource {
|
||||
if (this.isLoadedFromServer()) {
|
||||
return this.assetServerURL();
|
||||
}
|
||||
|
||||
return this.scaledAssetURLNearBundle();
|
||||
}
|
||||
assetServerURL(): ResolvedAssetSource {
|
||||
invariant(!!this.serverUrl, 'need server to load from');
|
||||
return this.fromSource(
|
||||
this.serverUrl +
|
||||
getScaledAssetPath(this.asset) +
|
||||
'?platform=' +
|
||||
Platform.OS +
|
||||
'&hash=' +
|
||||
this.asset.hash
|
||||
);
|
||||
}
|
||||
scaledAssetPath(): ResolvedAssetSource {
|
||||
return this.fromSource(getScaledAssetPath(this.asset));
|
||||
}
|
||||
scaledAssetURLNearBundle(): ResolvedAssetSource {
|
||||
const path = this.jsbundleUrl || 'file://';
|
||||
return this.fromSource(path + getScaledAssetPath(this.asset));
|
||||
}
|
||||
resourceIdentifierWithoutScale(): ResolvedAssetSource {
|
||||
throw new UnavailabilityError('react-native', 'resourceIdentifierWithoutScale()');
|
||||
}
|
||||
drawableFolderInBundle(): ResolvedAssetSource {
|
||||
throw new UnavailabilityError('react-native', 'drawableFolderInBundle()');
|
||||
}
|
||||
fromSource(source: string): ResolvedAssetSource {
|
||||
return {
|
||||
__packager_asset: true,
|
||||
width: this.asset.width,
|
||||
height: this.asset.height,
|
||||
uri: source,
|
||||
scale: AssetSourceResolver.pickScale(this.asset.scales, getScale()),
|
||||
};
|
||||
}
|
||||
|
||||
static pickScale(scales: number[], deviceScale: number): number {
|
||||
for (let i = 0; i < scales.length; i++) {
|
||||
if (scales[i] >= deviceScale) {
|
||||
return scales[i];
|
||||
}
|
||||
}
|
||||
return scales[scales.length - 1] || 1;
|
||||
}
|
||||
}
|
109
node_modules/expo-asset/src/AssetSources.ts
generated
vendored
Normal file
109
node_modules/expo-asset/src/AssetSources.ts
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
import { Platform } from '@unimodules/core';
|
||||
import path from 'path-browserify';
|
||||
import { PixelRatio } from 'react-native';
|
||||
import URL from 'url-parse';
|
||||
|
||||
import AssetSourceResolver from './AssetSourceResolver';
|
||||
import { manifestBaseUrl, getManifest } from './PlatformUtils';
|
||||
|
||||
export type AssetMetadata = {
|
||||
hash: string;
|
||||
name: string;
|
||||
type: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
scales: number[];
|
||||
httpServerLocation: string;
|
||||
uri?: string;
|
||||
fileHashes?: string[];
|
||||
fileUris?: string[];
|
||||
};
|
||||
|
||||
export type AssetSource = {
|
||||
uri: string;
|
||||
hash: string;
|
||||
};
|
||||
|
||||
// Fast lookup check if asset map has any overrides in the manifest
|
||||
const assetMapOverride = getManifest().assetMapOverride;
|
||||
|
||||
/**
|
||||
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
|
||||
* a { uri, hash } pair for the specific asset file.
|
||||
*
|
||||
* If the asset isn't an image with multiple scales, the first file is selected.
|
||||
*/
|
||||
export function selectAssetSource(meta: AssetMetadata): AssetSource {
|
||||
// Override with the asset map in manifest if available
|
||||
if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {
|
||||
meta = { ...meta, ...assetMapOverride[meta.hash] };
|
||||
}
|
||||
|
||||
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
|
||||
// explicitly provided URIs
|
||||
const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());
|
||||
const index = meta.scales.findIndex(s => s === scale);
|
||||
const hash = meta.fileHashes ? meta.fileHashes[index] || meta.fileHashes[0] : meta.hash;
|
||||
|
||||
// Allow asset processors to directly provide the URL to load
|
||||
const uri = meta.fileUris ? meta.fileUris[index] || meta.fileUris[0] : meta.uri;
|
||||
if (uri) {
|
||||
return { uri: resolveUri(uri), hash };
|
||||
}
|
||||
|
||||
// Check if the assetUrl was overridden in the manifest
|
||||
const assetUrlOverride = getManifest().assetUrlOverride;
|
||||
if (assetUrlOverride) {
|
||||
const uri = path.join(assetUrlOverride, hash);
|
||||
return { uri: resolveUri(uri), hash };
|
||||
}
|
||||
|
||||
const fileScale = scale === 1 ? '' : `@${scale}x`;
|
||||
const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : '';
|
||||
const suffix = `/${encodeURIComponent(
|
||||
meta.name
|
||||
)}${fileScale}${fileExtension}?platform=${encodeURIComponent(
|
||||
Platform.OS
|
||||
)}&hash=${encodeURIComponent(meta.hash)}`;
|
||||
|
||||
// For assets with a specified absolute URL, we use the existing origin instead of prepending the
|
||||
// development server or production CDN URL origin
|
||||
if (/^https?:\/\//.test(meta.httpServerLocation)) {
|
||||
const uri = meta.httpServerLocation + suffix;
|
||||
return { uri, hash };
|
||||
}
|
||||
|
||||
// For assets during development, we use the development server's URL origin
|
||||
if (getManifest().developer) {
|
||||
const baseUrl = new URL(getManifest().bundleUrl);
|
||||
baseUrl.set('pathname', meta.httpServerLocation + suffix);
|
||||
return { uri: baseUrl.href, hash };
|
||||
}
|
||||
|
||||
// Production CDN URIs are based on each asset file hash
|
||||
return {
|
||||
uri: `https://d1wp6m56sqw74a.cloudfront.net/~assets/${encodeURIComponent(hash)}`,
|
||||
hash,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the given URI to an absolute URI. If the given URI is already an absolute URI, it is
|
||||
* simply returned. Otherwise, if it is a relative URI, it is resolved relative to the manifest's
|
||||
* base URI.
|
||||
*/
|
||||
export function resolveUri(uri: string): string {
|
||||
if (!manifestBaseUrl) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
const { protocol } = new URL(uri);
|
||||
if (protocol !== '') {
|
||||
return uri;
|
||||
}
|
||||
|
||||
const baseUrl = new URL(manifestBaseUrl);
|
||||
const resolvedPath = uri.startsWith('/') ? uri : path.join(baseUrl.pathname, uri);
|
||||
baseUrl.set('pathname', resolvedPath);
|
||||
return baseUrl.href;
|
||||
}
|
43
node_modules/expo-asset/src/AssetUris.ts
generated
vendored
Normal file
43
node_modules/expo-asset/src/AssetUris.ts
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
import URL from 'url-parse';
|
||||
|
||||
export function getFilename(url: string): string {
|
||||
const { pathname } = new URL(url, {});
|
||||
return pathname.substring(pathname.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
export function getFileExtension(url: string): string {
|
||||
const filename = getFilename(url);
|
||||
const dotIndex = filename.lastIndexOf('.');
|
||||
// Ignore leading dots for hidden files
|
||||
return dotIndex > 0 ? filename.substring(dotIndex) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base URL from a manifest's URL. For example, given a manifest hosted at
|
||||
* https://example.com/app/manifest.json, the base URL would be https://example.com/app/. Query
|
||||
* parameters and fragments also are removed.
|
||||
*
|
||||
* For an Expo-hosted project with a manifest hosted at https://expo.io/@user/project/index.exp, the
|
||||
* base URL would be https://expo.io/@user/project.
|
||||
*
|
||||
* We also normalize the "exp" protocol to "http" to handle internal URLs with the Expo schemes used
|
||||
* to tell the OS to open the URLs in the the Expo client.
|
||||
*/
|
||||
export function getManifestBaseUrl(manifestUrl: string): string {
|
||||
const urlObject = new URL(manifestUrl, {});
|
||||
|
||||
// Change the scheme to http(s) if it is exp(s)
|
||||
if (urlObject.protocol === 'exp:') {
|
||||
urlObject.set('protocol', 'http:');
|
||||
} else if (urlObject.protocol === 'exps:') {
|
||||
urlObject.set('protocol', 'https:');
|
||||
}
|
||||
|
||||
// Trim filename, query parameters, and fragment, if any
|
||||
const directory = urlObject.pathname.substring(0, urlObject.pathname.lastIndexOf('/') + 1);
|
||||
urlObject.set('pathname', directory);
|
||||
urlObject.set('query', '');
|
||||
urlObject.set('hash', '');
|
||||
|
||||
return urlObject.href;
|
||||
}
|
28
node_modules/expo-asset/src/EmbeddedAssets.ts
generated
vendored
Normal file
28
node_modules/expo-asset/src/EmbeddedAssets.ts
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
import Constants from 'expo-constants';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
|
||||
import { getLocalAssets } from './PlatformUtils';
|
||||
|
||||
// Fast lookup check if assets are available in the local bundle in managed apps
|
||||
const bundledAssets = new Set(FileSystem.bundledAssets || []);
|
||||
|
||||
// localAssets are provided by the expo-updates module
|
||||
const localAssets = getLocalAssets();
|
||||
|
||||
/**
|
||||
* Returns the local URI of an embedded asset from its hash and type, or null if the asset is not
|
||||
* included in the app bundle.
|
||||
*/
|
||||
export function getEmbeddedAssetUri(hash: string, type: string | null): string | null {
|
||||
const localAssetsKey = `${hash}.${type ?? ''}`;
|
||||
if (!localAssets.hasOwnProperty(localAssetsKey) && !__DEV__) {
|
||||
// check legacy location in case we're in Expo client/managed workflow
|
||||
// TODO(eric): remove this once bundledAssets is no longer exported from FileSystem
|
||||
const assetName = `asset_${hash}${type ? `.${type}` : ''}`;
|
||||
if (Constants.appOwnership !== 'standalone' || !bundledAssets.has(assetName)) {
|
||||
return null;
|
||||
}
|
||||
return `${FileSystem.bundleDirectory}${assetName}`;
|
||||
}
|
||||
return localAssets[localAssetsKey] ?? null;
|
||||
}
|
4
node_modules/expo-asset/src/EmbeddedAssets.web.ts
generated
vendored
Normal file
4
node_modules/expo-asset/src/EmbeddedAssets.web.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export function getEmbeddedAssetUri(hash: string, type: string | null): string | null {
|
||||
// noop on web
|
||||
return null;
|
||||
}
|
27
node_modules/expo-asset/src/ImageAssets.ts
generated
vendored
Normal file
27
node_modules/expo-asset/src/ImageAssets.ts
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/* eslint-env browser */
|
||||
import { getFilename } from './AssetUris';
|
||||
|
||||
type ImageInfo = {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
export function isImageType(type: string): boolean {
|
||||
return /^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(type);
|
||||
}
|
||||
|
||||
export function getImageInfoAsync(url: string): Promise<ImageInfo> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onerror = reject;
|
||||
img.onload = () => {
|
||||
resolve({
|
||||
name: getFilename(url),
|
||||
width: img.naturalWidth,
|
||||
height: img.naturalHeight,
|
||||
});
|
||||
};
|
||||
img.src = url;
|
||||
});
|
||||
}
|
94
node_modules/expo-asset/src/PlatformUtils.ts
generated
vendored
Normal file
94
node_modules/expo-asset/src/PlatformUtils.ts
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
import { NativeModulesProxy } from '@unimodules/core';
|
||||
import computeMd5 from 'blueimp-md5';
|
||||
import Constants from 'expo-constants';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
|
||||
import { getManifestBaseUrl } from './AssetUris';
|
||||
|
||||
// Constants.appOwnership is only available in managed apps (Expo client and standalone)
|
||||
export const IS_MANAGED_ENV = !!Constants.appOwnership;
|
||||
|
||||
// In the future (SDK38+) expo-updates is likely to be used in managed apps, so we decide
|
||||
// that you are in a bare app with updates if you're not in a managed app and you have
|
||||
// local assets available.
|
||||
export const IS_BARE_ENV_WITH_UPDATES =
|
||||
!IS_MANAGED_ENV &&
|
||||
!!NativeModulesProxy.ExpoUpdates?.isEnabled &&
|
||||
// if expo-updates is installed but we're running directly from the embedded bundle, we don't want
|
||||
// to override the AssetSourceResolver
|
||||
!NativeModulesProxy.ExpoUpdates?.isUsingEmbeddedAssets;
|
||||
|
||||
export const IS_ENV_WITH_UPDATES_ENABLED = IS_MANAGED_ENV || IS_BARE_ENV_WITH_UPDATES;
|
||||
|
||||
// If it's not managed or bare w/ updates, then it must be bare w/o updates!
|
||||
export const IS_BARE_ENV_WITHOUT_UPDATES = !IS_MANAGED_ENV && !IS_BARE_ENV_WITH_UPDATES;
|
||||
|
||||
// Get the localAssets property from the ExpoUpdates native module so that we do
|
||||
// not need to include expo-updates as a dependency of expo-asset
|
||||
export function getLocalAssets() {
|
||||
return NativeModulesProxy.ExpoUpdates?.localAssets ?? {};
|
||||
}
|
||||
|
||||
export function getManifest(): { [key: string]: any } {
|
||||
return Constants.manifest ?? {};
|
||||
}
|
||||
|
||||
// Compute manifest base URL if available
|
||||
export const manifestBaseUrl = Constants.experienceUrl
|
||||
? getManifestBaseUrl(Constants.experienceUrl)
|
||||
: null;
|
||||
|
||||
// TODO: how should this behave in bare app with updates? re: hashAssetFiles
|
||||
export async function downloadAsync(uri, hash, type, name): Promise<string> {
|
||||
if (IS_MANAGED_ENV) {
|
||||
return _downloadAsyncManagedEnv(uri, hash, type, name);
|
||||
}
|
||||
|
||||
return _downloadAsyncUnmanagedEnv(uri, hash, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file exists on disk already, perform integrity check if so.
|
||||
* Otherwise, download it.
|
||||
*/
|
||||
async function _downloadAsyncManagedEnv(uri, hash, type, name): Promise<string> {
|
||||
const cacheFileId = hash || computeMd5(uri);
|
||||
const localUri = `${FileSystem.cacheDirectory}ExponentAsset-${cacheFileId}.${type}`;
|
||||
let { exists, md5 } = await FileSystem.getInfoAsync(localUri, {
|
||||
md5: true,
|
||||
});
|
||||
if (!exists || (hash !== null && md5 !== hash)) {
|
||||
({ md5 } = await FileSystem.downloadAsync(uri, localUri, {
|
||||
md5: true,
|
||||
}));
|
||||
if (hash !== null && md5 !== hash) {
|
||||
throw new Error(
|
||||
`Downloaded file for asset '${name}.${type}' ` +
|
||||
`Located at ${uri} ` +
|
||||
`failed MD5 integrity check`
|
||||
);
|
||||
}
|
||||
}
|
||||
return localUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just download the asset, don't perform integrity check because we don't have
|
||||
* the hash to compare it with (we don't have hashAssetFiles plugin). Hash is
|
||||
* only used for the file name.
|
||||
*/
|
||||
async function _downloadAsyncUnmanagedEnv(uri, hash, type): Promise<string> {
|
||||
// TODO: does this make sense to bail out if it's already at a file URL
|
||||
// because it's already available locally?
|
||||
if (uri.startsWith('file://')) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
const cacheFileId = hash || computeMd5(uri);
|
||||
const localUri = `${FileSystem.cacheDirectory}ExponentAsset-${cacheFileId}.${type}`;
|
||||
|
||||
// We don't check the FileSystem for an existing version of the asset and we
|
||||
// also don't perform an integrity check!
|
||||
await FileSystem.downloadAsync(uri, localUri);
|
||||
return localUri;
|
||||
}
|
14
node_modules/expo-asset/src/PlatformUtils.web.ts
generated
vendored
Normal file
14
node_modules/expo-asset/src/PlatformUtils.web.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
export const IS_MANAGED_ENV = false;
|
||||
export const IS_ENV_WITH_UPDATES_ENABLED = false;
|
||||
export const IS_ENV_WITHOUT_UPDATES_ENABLED = false;
|
||||
|
||||
// Compute manifest base URL if available
|
||||
export const manifestBaseUrl = null;
|
||||
|
||||
export async function downloadAsync(uri, hash, type, name): Promise<string> {
|
||||
return uri;
|
||||
}
|
||||
|
||||
export function getManifest() {
|
||||
return {};
|
||||
}
|
4
node_modules/expo-asset/src/index.ts
generated
vendored
Normal file
4
node_modules/expo-asset/src/index.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import './Asset.fx';
|
||||
|
||||
export * from './Asset';
|
||||
export * from './AssetHooks';
|
3
node_modules/expo-asset/src/resolveAssetSource.ts
generated
vendored
Normal file
3
node_modules/expo-asset/src/resolveAssetSource.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
||||
export default resolveAssetSource;
|
||||
export * from 'react-native/Libraries/Image/resolveAssetSource'; // eslint-disable-line import/export
|
97
node_modules/expo-asset/src/resolveAssetSource.web.ts
generated
vendored
Normal file
97
node_modules/expo-asset/src/resolveAssetSource.web.ts
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
import { NativeModules } from 'react-native';
|
||||
|
||||
import { getAssetByID } from './AssetRegistry';
|
||||
import AssetSourceResolver, { ResolvedAssetSource } from './AssetSourceResolver';
|
||||
|
||||
declare let nativeExtensions: any;
|
||||
|
||||
let _customSourceTransformer;
|
||||
let _serverURL: string | undefined | null;
|
||||
let _scriptURL: string | undefined | null;
|
||||
let _sourceCodeScriptURL: string | undefined | null;
|
||||
|
||||
function getSourceCodeScriptURL(): string | undefined | null {
|
||||
if (_sourceCodeScriptURL) {
|
||||
return _sourceCodeScriptURL;
|
||||
}
|
||||
|
||||
let sourceCode = nativeExtensions && nativeExtensions.SourceCode;
|
||||
if (!sourceCode) {
|
||||
sourceCode = NativeModules && NativeModules.SourceCode;
|
||||
}
|
||||
_sourceCodeScriptURL = sourceCode.scriptURL;
|
||||
return _sourceCodeScriptURL;
|
||||
}
|
||||
|
||||
function getDevServerURL(): string | null {
|
||||
if (_serverURL === undefined) {
|
||||
const sourceCodeScriptURL = getSourceCodeScriptURL();
|
||||
const match = sourceCodeScriptURL && sourceCodeScriptURL.match(/^https?:\/\/.*?\//);
|
||||
if (match) {
|
||||
// jsBundle was loaded from network
|
||||
_serverURL = match[0];
|
||||
} else {
|
||||
// jsBundle was loaded from file
|
||||
_serverURL = null;
|
||||
}
|
||||
}
|
||||
return _serverURL;
|
||||
}
|
||||
|
||||
function _coerceLocalScriptURL(scriptURL: string | undefined | null): string | null {
|
||||
if (scriptURL) {
|
||||
if (scriptURL.startsWith('assets://')) {
|
||||
// android: running from within assets, no offline path to use
|
||||
return null;
|
||||
}
|
||||
scriptURL = scriptURL.substring(0, scriptURL.lastIndexOf('/') + 1);
|
||||
if (!scriptURL.includes('://')) {
|
||||
// Add file protocol in case we have an absolute file path and not a URL.
|
||||
// This shouldn't really be necessary. scriptURL should be a URL.
|
||||
scriptURL = 'file://' + scriptURL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getScriptURL(): string | null {
|
||||
if (_scriptURL === undefined) {
|
||||
_scriptURL = _coerceLocalScriptURL(getSourceCodeScriptURL());
|
||||
}
|
||||
return _scriptURL;
|
||||
}
|
||||
|
||||
export function setCustomSourceTransformer(
|
||||
transformer: (resolver: AssetSourceResolver) => ResolvedAssetSource
|
||||
): void {
|
||||
_customSourceTransformer = transformer;
|
||||
}
|
||||
|
||||
/**
|
||||
* `source` is either a number (opaque type returned by require('./foo.png'))
|
||||
* or an `ImageSource` like { uri: '<http location || file path>' }
|
||||
*/
|
||||
export default function resolveAssetSource(source: any): ResolvedAssetSource | undefined {
|
||||
if (typeof source === 'object') {
|
||||
return source;
|
||||
}
|
||||
|
||||
const asset = getAssetByID(source);
|
||||
if (!asset) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const resolver = new AssetSourceResolver(getDevServerURL(), getScriptURL(), asset);
|
||||
if (_customSourceTransformer) {
|
||||
return _customSourceTransformer(resolver);
|
||||
}
|
||||
return resolver.defaultAsset();
|
||||
}
|
||||
|
||||
Object.defineProperty(resolveAssetSource, 'setCustomSourceTransformer', {
|
||||
get() {
|
||||
return setCustomSourceTransformer;
|
||||
},
|
||||
});
|
||||
|
||||
export const { pickScale } = AssetSourceResolver;
|
8
node_modules/expo-asset/src/ts-declarations/path-browserify.d.ts
generated
vendored
Normal file
8
node_modules/expo-asset/src/ts-declarations/path-browserify.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
declare module 'path-browserify' {
|
||||
interface path {
|
||||
static join(...paths: string[]): string;
|
||||
}
|
||||
|
||||
const path: path;
|
||||
export = path;
|
||||
}
|
49
node_modules/expo-asset/src/ts-declarations/react-native-assets.d.ts
generated
vendored
Normal file
49
node_modules/expo-asset/src/ts-declarations/react-native-assets.d.ts
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
declare module 'react-native/Libraries/Image/AssetRegistry' {
|
||||
export type PackagerAsset = any;
|
||||
export function registerAsset(asset: PackagerAsset): number;
|
||||
export function getAssetByID(assetID: number): PackagerAsset | undefined;
|
||||
}
|
||||
|
||||
declare module 'react-native/Libraries/Image/AssetSourceResolver' {
|
||||
import { PackagerAsset } from 'react-native/Libraries/Image/AssetRegistry';
|
||||
|
||||
export type ResolvedAssetSource = {
|
||||
__packager_asset: boolean;
|
||||
width: number | null;
|
||||
height: number | null;
|
||||
uri: string;
|
||||
scale: number;
|
||||
};
|
||||
|
||||
export default class AssetSourceResolver {
|
||||
serverUrl: string | null;
|
||||
jsbundleUrl: string | null;
|
||||
asset: PackagerAsset;
|
||||
|
||||
constructor(serverUrl: string | null, jsbundleUrl: string | null, asset: PackagerAsset);
|
||||
|
||||
isLoadedFromServer(): boolean;
|
||||
isLoadedFromFileSystem(): boolean;
|
||||
defaultAsset(): ResolvedAssetSource;
|
||||
assetServerURL(): ResolvedAssetSource;
|
||||
scaledAssetPath(): ResolvedAssetSource;
|
||||
scaledAssetURLNearBundle(): ResolvedAssetSource;
|
||||
resourceIdentifierWithoutScale(): ResolvedAssetSource;
|
||||
drawableFolderInBundle(): ResolvedAssetSource;
|
||||
fromSource(source: string): ResolvedAssetSource;
|
||||
|
||||
static pickScale(scales: number[], deviceScale: number): number;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'react-native/Libraries/Image/resolveAssetSource' {
|
||||
import AssetSourceResolver, {
|
||||
ResolvedAssetSource,
|
||||
} from 'react-native/Libraries/Image/AssetSourceResolver';
|
||||
|
||||
export default function resolveAssetSource(source: any): ResolvedAssetSource;
|
||||
|
||||
export function setCustomSourceTransformer(
|
||||
transformer: (resolver: AssetSourceResolver) => ResolvedAssetSource
|
||||
): void;
|
||||
}
|
10
node_modules/expo-asset/tools/hashAssetFiles.js
generated
vendored
Normal file
10
node_modules/expo-asset/tools/hashAssetFiles.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const md5File = require('md5-file/promise');
|
||||
|
||||
module.exports = function hashAssetFiles(asset) {
|
||||
return Promise.all(asset.files.map(md5File)).then(hashes => {
|
||||
asset.fileHashes = hashes;
|
||||
return asset;
|
||||
});
|
||||
};
|
9
node_modules/expo-asset/tsconfig.json
generated
vendored
Normal file
9
node_modules/expo-asset/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
// @generated by expo-module-scripts
|
||||
{
|
||||
"extends": "expo-module-scripts/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"outDir": "./build"
|
||||
},
|
||||
"include": ["./src"],
|
||||
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
|
||||
}
|
4
node_modules/expo-asset/unimodule.json
generated
vendored
Normal file
4
node_modules/expo-asset/unimodule.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "expo-asset",
|
||||
"platforms": []
|
||||
}
|
Reference in New Issue
Block a user