expo-asset 8.14.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,24 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 9.0.1 — 2023-12-13
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 9.0.0 — 2023-12-12
18
+
19
+ ### 🛠 Breaking changes
20
+
21
+ - Removed support for the Classic Updates service for SDK 50 ([announcement](https://blog.expo.dev/sunsetting-expo-publish-and-classic-updates-6cb9cd295378)). Specifically, references to the Classic Updates CDN were removed. [Migrate](https://docs.expo.dev/eas-update/migrate-from-classic-updates/) to EAS or other service that conforms to the modern [Expo Updates protocol](https://docs.expo.dev/technical-specs/expo-updates-1/). ([#25613](https://github.com/expo/expo/pull/25613) by [@ide](https://github.com/ide))
22
+
23
+ ### 🎉 New features
24
+
25
+ - Added support for React Native 0.73.0. ([#24971](https://github.com/expo/expo/pull/24971), [#25453](https://github.com/expo/expo/pull/25453) by [@gabrieldonadel](https://github.com/gabrieldonadel))
26
+
27
+ ### 💡 Others
28
+
29
+ - Removed references to legacy `bundledAssets` constant from `expo-file-system` that was used only in standalone apps. ([#25484](https://github.com/expo/expo/pull/25484) by [@tsapeta](https://github.com/tsapeta))
30
+
13
31
  ## 8.14.0 — 2023-11-14
14
32
 
15
33
  ### 🐛 Bug fixes
@@ -1 +1 @@
1
- {"version":3,"file":"AssetSources.d.ts","sourceRoot":"","sources":["../src/AssetSources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAQ5E,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,aAAa,EACb,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAChF,GAAG;IACF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,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
2
- import { PixelRatio } from 'react-native';
2
+ import { PixelRatio, NativeModules } from 'react-native';
3
3
  import AssetSourceResolver from './AssetSourceResolver';
4
4
  import { getManifest, getManifest2, manifestBaseUrl } from './PlatformUtils';
5
5
  // Fast lookup check if asset map has any overrides in the manifest.
@@ -20,9 +20,9 @@ export function selectAssetSource(meta) {
20
20
  // explicitly provided URIs
21
21
  const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());
22
22
  const index = meta.scales.findIndex((s) => s === scale);
23
- const hash = meta.fileHashes ? meta.fileHashes[index] || meta.fileHashes[0] : meta.hash;
23
+ const hash = meta.fileHashes ? meta.fileHashes[index] ?? meta.fileHashes[0] : meta.hash;
24
24
  // Allow asset processors to directly provide the URL to load
25
- const uri = meta.fileUris ? meta.fileUris[index] || meta.fileUris[0] : meta.uri;
25
+ const uri = meta.fileUris ? meta.fileUris[index] ?? meta.fileUris[0] : meta.uri;
26
26
  if (uri) {
27
27
  return { uri: resolveUri(uri), hash };
28
28
  }
@@ -62,11 +62,15 @@ export function selectAssetSource(meta) {
62
62
  hash,
63
63
  };
64
64
  }
65
- // Production CDN URIs are based on each asset file hash
66
- return {
67
- uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`,
68
- hash,
69
- };
65
+ // Temporary fallback for loading assets in Expo Go home
66
+ if (NativeModules.ExponentKernel) {
67
+ return { uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`, hash };
68
+ }
69
+ // In correctly configured apps, we arrive here if the asset is locally available on disk due to
70
+ // being managed by expo-updates, and `getLocalAssetUri(hash)` must return a local URI for this
71
+ // hash. Since the asset is local, we don't have a remote URL and specify an invalid URL (an empty
72
+ // string) as a placeholder.
73
+ return { uri: '', hash };
70
74
  }
71
75
  /**
72
76
  * Resolves the given URI to an absolute URI. If the given URI is already an absolute URI, it is
@@ -1 +1 @@
1
- {"version":3,"file":"AssetSources.js","sourceRoot":"","sources":["../src/AssetSources.ts"],"names":[],"mappings":"AAC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,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,IAAI,CAAC,GAAG,CAAC;SACT,KAAK,CAAC,GAAG,CAAC,CAAC;IAEd,+BAA+B;IAC/B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;QAC3B,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,0CAA0C;SAC3D;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE;YACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;KACF;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { PackagerAsset } from '@react-native/assets-registry/registry';\nimport { Platform } from 'expo-modules-core';\nimport { PixelRatio } from 'react-native';\n\nimport AssetSourceResolver from './AssetSourceResolver';\nimport { getManifest, getManifest2, manifestBaseUrl } from './PlatformUtils';\n\n// @docsMissing\nexport type AssetMetadata = Pick<\n PackagerAsset,\n 'httpServerLocation' | 'name' | 'hash' | 'type' | 'scales' | 'width' | 'height'\n> & {\n uri?: string;\n fileHashes?: string[];\n fileUris?: string[];\n};\n\nexport type AssetSource = {\n uri: string;\n hash: string;\n};\n\n// Fast lookup check if asset map has any overrides in the manifest.\n// This value will always be either null or an absolute URL, e.g. `https://expo.dev/`\nconst assetMapOverride = getManifest().assetMapOverride;\n\n/**\n * Selects the best file for the given asset (ex: choosing the best scale for images) and returns\n * a { uri, hash } pair for the specific asset file.\n *\n * If the asset isn't an image with multiple scales, the first file is selected.\n */\nexport function selectAssetSource(meta: AssetMetadata): AssetSource {\n // Override with the asset map in manifest if available\n if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {\n meta = { ...meta, ...assetMapOverride[meta.hash] };\n }\n\n // This logic is based on that of AssetSourceResolver, with additional support for file hashes and\n // explicitly provided URIs\n const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());\n const index = meta.scales.findIndex((s) => s === scale);\n const hash = meta.fileHashes ? meta.fileHashes[index] || meta.fileHashes[0] : meta.hash;\n\n // Allow asset processors to directly provide the URL to load\n const uri = meta.fileUris ? meta.fileUris[index] || meta.fileUris[0] : meta.uri;\n if (uri) {\n return { uri: resolveUri(uri), hash };\n }\n\n // Check if the assetUrl was overridden in the manifest\n const assetUrlOverride = getManifest().assetUrlOverride;\n if (assetUrlOverride) {\n const uri = pathJoin(assetUrlOverride, hash);\n return { uri: resolveUri(uri), hash };\n }\n\n const fileScale = scale === 1 ? '' : `@${scale}x`;\n const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : '';\n const suffix = `/${encodeURIComponent(meta.name)}${fileScale}${fileExtension}`;\n const params = new URLSearchParams({\n platform: Platform.OS,\n hash: meta.hash,\n });\n\n // For assets with a specified absolute URL, we use the existing origin instead of prepending the\n // development server or production CDN URL origin\n if (/^https?:\\/\\//.test(meta.httpServerLocation)) {\n const uri = meta.httpServerLocation + suffix + '?' + params;\n return { uri, hash };\n }\n\n // For assets during development using manifest2, we use the development server's URL origin\n const manifest2 = getManifest2();\n\n const devServerUrl = manifest2?.extra?.expoGo?.developer\n ? 'http://' + manifest2.extra.expoGo.debuggerHost\n : // For assets during development, we use the development server's URL origin\n getManifest().developer\n ? getManifest().bundleUrl\n : null;\n if (devServerUrl) {\n const baseUrl = new URL(meta.httpServerLocation + suffix, devServerUrl);\n\n baseUrl.searchParams.set('platform', Platform.OS);\n baseUrl.searchParams.set('hash', meta.hash);\n return {\n uri: baseUrl.href,\n hash,\n };\n }\n\n // Production CDN URIs are based on each asset file hash\n return {\n uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`,\n hash,\n };\n}\n\n/**\n * Resolves the given URI to an absolute URI. If the given URI is already an absolute URI, it is\n * simply returned. Otherwise, if it is a relative URI, it is resolved relative to the manifest's\n * base URI.\n */\nexport function resolveUri(uri: string): string {\n // `manifestBaseUrl` is always an absolute URL or `null`.\n return manifestBaseUrl ? new URL(uri, manifestBaseUrl).href : uri;\n}\n\n// A very cheap path canonicalization like path.join but without depending on a `path` polyfill.\nexport function pathJoin(...paths: string[]): string {\n // Start by simply combining paths, without worrying about \"..\" or \".\"\n const combined = paths\n .map((part, index) => {\n if (index === 0) {\n return part.trim().replace(/\\/*$/, '');\n }\n return part.trim().replace(/(^\\/*|\\/*$)/g, '');\n })\n .filter((part) => part.length > 0)\n .join('/')\n .split('/');\n\n // Handle \"..\" and \".\" in paths\n const resolved: string[] = [];\n for (const part of combined) {\n if (part === '..') {\n resolved.pop(); // Remove the last element from the result\n } else if (part !== '.') {\n resolved.push(part);\n }\n }\n\n return resolved.join('/');\n}\n"]}
1
+ {"version":3,"file":"AssetSources.js","sourceRoot":"","sources":["../src/AssetSources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAiB7E,oEAAoE;AACpE,qFAAqF;AACrF,MAAM,gBAAgB,GAAG,WAAW,EAAE,CAAC,gBAAgB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAmB;IACnD,uDAAuD;IACvD,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAClE,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACpD;IAED,kGAAkG;IAClG,2BAA2B;IAC3B,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,M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CAAC","sourcesContent":["import type { PackagerAsset } from '@react-native/assets-registry/registry';\nimport { Platform } from 'expo-modules-core';\nimport { PixelRatio, NativeModules } from 'react-native';\n\nimport AssetSourceResolver from './AssetSourceResolver';\nimport { getManifest, getManifest2, manifestBaseUrl } from './PlatformUtils';\n\n// @docsMissing\nexport type AssetMetadata = Pick<\n PackagerAsset,\n 'httpServerLocation' | 'name' | 'hash' | 'type' | 'scales' | 'width' | 'height'\n> & {\n uri?: string;\n fileHashes?: string[];\n fileUris?: string[];\n};\n\nexport type AssetSource = {\n uri: string;\n hash: string;\n};\n\n// Fast lookup check if asset map has any overrides in the manifest.\n// This value will always be either null or an absolute URL, e.g. `https://expo.dev/`\nconst assetMapOverride = getManifest().assetMapOverride;\n\n/**\n * Selects the best file for the given asset (ex: choosing the best scale for images) and returns\n * a { uri, hash } pair for the specific asset file.\n *\n * If the asset isn't an image with multiple scales, the first file is selected.\n */\nexport function selectAssetSource(meta: AssetMetadata): AssetSource {\n // Override with the asset map in manifest if available\n if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {\n meta = { ...meta, ...assetMapOverride[meta.hash] };\n }\n\n // This logic is based on that of AssetSourceResolver, with additional support for file hashes and\n // explicitly provided URIs\n const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());\n const index = meta.scales.findIndex((s) => s === scale);\n const hash = meta.fileHashes ? meta.fileHashes[index] ?? meta.fileHashes[0] : meta.hash;\n\n // Allow asset processors to directly provide the URL to load\n const uri = meta.fileUris ? meta.fileUris[index] ?? meta.fileUris[0] : meta.uri;\n if (uri) {\n return { uri: resolveUri(uri), hash };\n }\n\n // Check if the assetUrl was overridden in the manifest\n const assetUrlOverride = getManifest().assetUrlOverride;\n if (assetUrlOverride) {\n const uri = pathJoin(assetUrlOverride, hash);\n return { uri: resolveUri(uri), hash };\n }\n\n const fileScale = scale === 1 ? '' : `@${scale}x`;\n const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : '';\n const suffix = `/${encodeURIComponent(meta.name)}${fileScale}${fileExtension}`;\n const params = new URLSearchParams({\n platform: Platform.OS,\n hash: meta.hash,\n });\n\n // For assets with a specified absolute URL, we use the existing origin instead of prepending the\n // development server or production CDN URL origin\n if (/^https?:\\/\\//.test(meta.httpServerLocation)) {\n const uri = meta.httpServerLocation + suffix + '?' + params;\n return { uri, hash };\n }\n\n // For assets during development using manifest2, we use the development server's URL origin\n const manifest2 = getManifest2();\n\n const devServerUrl = manifest2?.extra?.expoGo?.developer\n ? 'http://' + manifest2.extra.expoGo.debuggerHost\n : // For assets during development, we use the development server's URL origin\n getManifest().developer\n ? getManifest().bundleUrl\n : null;\n if (devServerUrl) {\n const baseUrl = new URL(meta.httpServerLocation + suffix, devServerUrl);\n\n baseUrl.searchParams.set('platform', Platform.OS);\n baseUrl.searchParams.set('hash', meta.hash);\n return {\n uri: baseUrl.href,\n hash,\n };\n }\n\n // Temporary fallback for loading assets in Expo Go home\n if (NativeModules.ExponentKernel) {\n return { uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`, hash };\n }\n\n // In correctly configured apps, we arrive here if the asset is locally available on disk due to\n // being managed by expo-updates, and `getLocalAssetUri(hash)` must return a local URI for this\n // hash. Since the asset is local, we don't have a remote URL and specify an invalid URL (an empty\n // string) as a placeholder.\n return { uri: '', hash };\n}\n\n/**\n * Resolves the given URI to an absolute URI. If the given URI is already an absolute URI, it is\n * simply returned. Otherwise, if it is a relative URI, it is resolved relative to the manifest's\n * base URI.\n */\nexport function resolveUri(uri: string): string {\n // `manifestBaseUrl` is always an absolute URL or `null`.\n return manifestBaseUrl ? new URL(uri, manifestBaseUrl).href : uri;\n}\n\n// A very cheap path canonicalization like path.join but without depending on a `path` polyfill.\nexport function pathJoin(...paths: string[]): string {\n // Start by simply combining paths, without worrying about \"..\" or \".\"\n const combined = paths\n .map((part, index) => {\n if (index === 0) {\n return part.trim().replace(/\\/*$/, '');\n }\n return part.trim().replace(/(^\\/*|\\/*$)/g, '');\n })\n .filter((part) => part.length > 0)\n .join('/')\n .split('/');\n\n // Handle \"..\" and \".\" in paths\n const resolved: string[] = [];\n for (const part of combined) {\n if (part === '..') {\n resolved.pop(); // Remove the last element from the result\n } else if (part !== '.') {\n resolved.push(part);\n }\n }\n\n return resolved.join('/');\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"LocalAssets.d.ts","sourceRoot":"","sources":["../src/LocalAssets.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAwBjF"}
1
+ {"version":3,"file":"LocalAssets.d.ts","sourceRoot":"","sources":["../src/LocalAssets.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAejF"}
@@ -1,8 +1,4 @@
1
- import Constants from 'expo-constants';
2
- import * as FileSystem from 'expo-file-system';
3
1
  import { getLocalAssets } from './PlatformUtils';
4
- // Fast lookup check if assets are available in the local bundle in managed apps
5
- const bundledAssets = new Set(FileSystem.bundledAssets || []);
6
2
  // localAssets are provided by the expo-updates module
7
3
  const localAssets = getLocalAssets();
8
4
  /**
@@ -19,15 +15,6 @@ export function getLocalAssetUri(hash, type) {
19
15
  // legacy updates store assets with an extension
20
16
  return localAssets[legacyLocalAssetsKey];
21
17
  }
22
- case !__DEV__: {
23
- // check legacy location in case we're in Expo client/managed workflow
24
- // TODO(eric): remove this once bundledAssets is no longer exported from FileSystem
25
- const assetName = `asset_${hash}${type ? `.${type}` : ''}`;
26
- if (Constants.appOwnership !== 'standalone' || !bundledAssets.has(assetName)) {
27
- return null;
28
- }
29
- return `${FileSystem.bundleDirectory}${assetName}`;
30
- }
31
18
  default:
32
19
  return null;
33
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LocalAssets.js","sourceRoot":"","sources":["../src/LocalAssets.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;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,IAAmB;IAChE,MAAM,cAAc,GAAG,IAAI,CAAC;IAC5B,MAAM,oBAAoB,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;IAErD,QAAQ,IAAI,EAAE;QACZ,KAAK,cAAc,IAAI,WAAW,CAAC,CAAC;YAClC,OAAO,WAAW,CAAC,cAAc,CAAC,CAAC;SACpC;QACD,KAAK,oBAAoB,IAAI,WAAW,CAAC,CAAC;YACxC,gDAAgD;YAChD,OAAO,WAAW,CAAC,oBAAoB,CAAC,CAAC;SAC1C;QACD,KAAK,CAAC,OAAO,CAAC,CAAC;YACb,sEAAsE;YACtE,mFAAmF;YACnF,MAAM,SAAS,GAAG,SAAS,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAC3D,IAAI,SAAS,CAAC,YAAY,KAAK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;gBAC5E,OAAO,IAAI,CAAC;aACb;YACD,OAAO,GAAG,UAAU,CAAC,eAAe,GAAG,SAAS,EAAE,CAAC;SACpD;QACD;YACE,OAAO,IAAI,CAAC;KACf;AACH,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 URI of a local asset from its hash, or null if the asset is not available locally\n */\nexport function getLocalAssetUri(hash: string, type: string | null): string | null {\n const localAssetsKey = hash;\n const legacyLocalAssetsKey = `${hash}.${type ?? ''}`;\n\n switch (true) {\n case localAssetsKey in localAssets: {\n return localAssets[localAssetsKey];\n }\n case legacyLocalAssetsKey in localAssets: {\n // legacy updates store assets with an extension\n return localAssets[legacyLocalAssetsKey];\n }\n case !__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 default:\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"LocalAssets.js","sourceRoot":"","sources":["../src/LocalAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,sDAAsD;AACtD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;AAErC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,IAAmB;IAChE,MAAM,cAAc,GAAG,IAAI,CAAC;IAC5B,MAAM,oBAAoB,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;IAErD,QAAQ,IAAI,EAAE;QACZ,KAAK,cAAc,IAAI,WAAW,CAAC,CAAC;YAClC,OAAO,WAAW,CAAC,cAAc,CAAC,CAAC;SACpC;QACD,KAAK,oBAAoB,IAAI,WAAW,CAAC,CAAC;YACxC,gDAAgD;YAChD,OAAO,WAAW,CAAC,oBAAoB,CAAC,CAAC;SAC1C;QACD;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC","sourcesContent":["import { getLocalAssets } from './PlatformUtils';\n\n// localAssets are provided by the expo-updates module\nconst localAssets = getLocalAssets();\n\n/**\n * Returns the URI of a local asset from its hash, or null if the asset is not available locally\n */\nexport function getLocalAssetUri(hash: string, type: string | null): string | null {\n const localAssetsKey = hash;\n const legacyLocalAssetsKey = `${hash}.${type ?? ''}`;\n\n switch (true) {\n case localAssetsKey in localAssets: {\n return localAssets[localAssetsKey];\n }\n case legacyLocalAssetsKey in localAssets: {\n // legacy updates store assets with an extension\n return localAssets[legacyLocalAssetsKey];\n }\n default:\n return null;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-asset",
3
- "version": "8.14.0",
3
+ "version": "9.0.1",
4
4
  "description": "An Expo universal module to download assets and pass them into other APIs",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -37,17 +37,17 @@
37
37
  "preset": "expo-module-scripts"
38
38
  },
39
39
  "dependencies": {
40
- "@react-native/assets-registry": "~0.72.0",
40
+ "@react-native/assets-registry": "~0.73.1",
41
41
  "blueimp-md5": "^2.10.0",
42
42
  "invariant": "^2.2.4",
43
43
  "md5-file": "^3.2.3",
44
- "expo-constants": "~15.3.0",
45
- "expo-file-system": "~15.9.0"
44
+ "expo-constants": "~15.4.0",
45
+ "expo-file-system": "~16.0.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@testing-library/react-hooks": "^7.0.1",
49
49
  "@types/react-native__assets": "~1.0.0",
50
50
  "expo-module-scripts": "^3.0.0"
51
51
  },
52
- "gitHead": "3142a086578deffd8704a8f1b6f0f661527d836c"
52
+ "gitHead": "1c97be7c8c3c8661698038bf7912fb7c64ba8c35"
53
53
  }
@@ -1,6 +1,6 @@
1
1
  import type { PackagerAsset } from '@react-native/assets-registry/registry';
2
2
  import { Platform } from 'expo-modules-core';
3
- import { PixelRatio } from 'react-native';
3
+ import { PixelRatio, NativeModules } from 'react-native';
4
4
 
5
5
  import AssetSourceResolver from './AssetSourceResolver';
6
6
  import { getManifest, getManifest2, manifestBaseUrl } from './PlatformUtils';
@@ -40,10 +40,10 @@ export function selectAssetSource(meta: AssetMetadata): AssetSource {
40
40
  // explicitly provided URIs
41
41
  const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());
42
42
  const index = meta.scales.findIndex((s) => s === scale);
43
- const hash = meta.fileHashes ? meta.fileHashes[index] || meta.fileHashes[0] : meta.hash;
43
+ const hash = meta.fileHashes ? meta.fileHashes[index] ?? meta.fileHashes[0] : meta.hash;
44
44
 
45
45
  // Allow asset processors to directly provide the URL to load
46
- const uri = meta.fileUris ? meta.fileUris[index] || meta.fileUris[0] : meta.uri;
46
+ const uri = meta.fileUris ? meta.fileUris[index] ?? meta.fileUris[0] : meta.uri;
47
47
  if (uri) {
48
48
  return { uri: resolveUri(uri), hash };
49
49
  }
@@ -90,11 +90,16 @@ export function selectAssetSource(meta: AssetMetadata): AssetSource {
90
90
  };
91
91
  }
92
92
 
93
- // Production CDN URIs are based on each asset file hash
94
- return {
95
- uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`,
96
- hash,
97
- };
93
+ // Temporary fallback for loading assets in Expo Go home
94
+ if (NativeModules.ExponentKernel) {
95
+ return { uri: `https://classic-assets.eascdn.net/~assets/${encodeURIComponent(hash)}`, hash };
96
+ }
97
+
98
+ // In correctly configured apps, we arrive here if the asset is locally available on disk due to
99
+ // being managed by expo-updates, and `getLocalAssetUri(hash)` must return a local URI for this
100
+ // hash. Since the asset is local, we don't have a remote URL and specify an invalid URL (an empty
101
+ // string) as a placeholder.
102
+ return { uri: '', hash };
98
103
  }
99
104
 
100
105
  /**
@@ -1,11 +1,5 @@
1
- import Constants from 'expo-constants';
2
- import * as FileSystem from 'expo-file-system';
3
-
4
1
  import { getLocalAssets } from './PlatformUtils';
5
2
 
6
- // Fast lookup check if assets are available in the local bundle in managed apps
7
- const bundledAssets = new Set(FileSystem.bundledAssets || []);
8
-
9
3
  // localAssets are provided by the expo-updates module
10
4
  const localAssets = getLocalAssets();
11
5
 
@@ -24,15 +18,6 @@ export function getLocalAssetUri(hash: string, type: string | null): string | nu
24
18
  // legacy updates store assets with an extension
25
19
  return localAssets[legacyLocalAssetsKey];
26
20
  }
27
- case !__DEV__: {
28
- // check legacy location in case we're in Expo client/managed workflow
29
- // TODO(eric): remove this once bundledAssets is no longer exported from FileSystem
30
- const assetName = `asset_${hash}${type ? `.${type}` : ''}`;
31
- if (Constants.appOwnership !== 'standalone' || !bundledAssets.has(assetName)) {
32
- return null;
33
- }
34
- return `${FileSystem.bundleDirectory}${assetName}`;
35
- }
36
21
  default:
37
22
  return null;
38
23
  }