diff --git a/package-lock.json b/package-lock.json index 3bb573cd7c..cbb755abe7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2964,6 +2964,14 @@ "dev": true, "license": "MIT" }, + "node_modules/@react-native/assets-registry": { + "version": "0.74.84", + "resolved": "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.74.84.tgz", + "integrity": "sha512-dzUhwyaX04QosWZ8zyaaNB/WYZIdeDN1lcpfQbqiOhZJShRH+FLTDVONE/dqlMQrP+EO7lDqF0RrlIt9lnOCQQ==", + "engines": { + "node": ">=18" + } + }, "node_modules/@react-native/normalize-colors": { "version": "0.74.1", "resolved": "https://registry.npmjs.org/@react-native/normalize-colors/-/normalize-colors-0.74.1.tgz", @@ -15508,6 +15516,7 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.6", + "@react-native/assets-registry": "0.74.84", "@react-native/normalize-colors": "^0.74.1", "fbjs": "^3.0.4", "inline-style-prefixer": "^6.0.1", @@ -17389,6 +17398,11 @@ "version": "1.0.0-next.21", "dev": true }, + "@react-native/assets-registry": { + "version": "0.74.84", + "resolved": "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.74.84.tgz", + "integrity": "sha512-dzUhwyaX04QosWZ8zyaaNB/WYZIdeDN1lcpfQbqiOhZJShRH+FLTDVONE/dqlMQrP+EO7lDqF0RrlIt9lnOCQQ==" + }, "@react-native/normalize-colors": { "version": "0.74.1", "resolved": "https://registry.npmjs.org/@react-native/normalize-colors/-/normalize-colors-0.74.1.tgz", @@ -23696,6 +23710,7 @@ "version": "file:packages/react-native-web", "requires": { "@babel/runtime": "^7.18.6", + "@react-native/assets-registry": "0.74.84", "@react-native/normalize-colors": "^0.74.1", "fbjs": "^3.0.4", "inline-style-prefixer": "^6.0.1", diff --git a/packages/react-native-web/package.json b/packages/react-native-web/package.json index b2424ff70f..2e231f5945 100644 --- a/packages/react-native-web/package.json +++ b/packages/react-native-web/package.json @@ -23,6 +23,7 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", + "@react-native/assets-registry": "0.74.84", "@react-native/normalize-colors": "^0.74.1", "fbjs": "^3.0.4", "inline-style-prefixer": "^6.0.1", diff --git a/packages/react-native-web/src/exports/Image/__tests__/index-test.js b/packages/react-native-web/src/exports/Image/__tests__/index-test.js index 6bdd81337b..7f41f16da2 100644 --- a/packages/react-native-web/src/exports/Image/__tests__/index-test.js +++ b/packages/react-native-web/src/exports/Image/__tests__/index-test.js @@ -7,7 +7,7 @@ /* eslint-disable react/jsx-no-bind */ -import * as AssetRegistry from '../../../modules/AssetRegistry'; +import * as AssetRegistry from '@react-native/assets-registry/registry'; import Image from '../'; import ImageLoader, { ImageUriCache } from '../../../modules/ImageLoader'; import PixelRatio from '../../PixelRatio'; diff --git a/packages/react-native-web/src/exports/Image/index.js b/packages/react-native-web/src/exports/Image/index.js index 5a81b0b461..308a4a9ef7 100644 --- a/packages/react-native-web/src/exports/Image/index.js +++ b/packages/react-native-web/src/exports/Image/index.js @@ -10,9 +10,9 @@ import type { ImageProps } from './types'; +import { getAssetByID } from '@react-native/assets-registry/registry'; import * as React from 'react'; import createElement from '../createElement'; -import { getAssetByID } from '../../modules/AssetRegistry'; import { createBoxShadowValue } from '../StyleSheet/preprocess'; import ImageLoader from '../../modules/ImageLoader'; import PixelRatio from '../PixelRatio'; diff --git a/packages/react-native-web/src/modules/AssetRegistry/index.js b/packages/react-native-web/src/modules/AssetRegistry/index.js deleted file mode 100644 index 69d1ec492d..0000000000 --- a/packages/react-native-web/src/modules/AssetRegistry/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Nicolas Gallagher. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export type PackagerAsset = { - __packager_asset: boolean, - fileSystemLocation: string, - httpServerLocation: string, - width: ?number, - height: ?number, - scales: Array, - hash: string, - name: string, - type: string -}; - -const assets: Array = []; - -export function registerAsset(asset: PackagerAsset): number { - // `push` returns new array length, so the first asset will - // get id 1 (not 0) to make the value truthy - return assets.push(asset); -} - -export function getAssetByID(assetId: number): PackagerAsset { - return assets[assetId - 1]; -}