From d83e974e4568b1d2d6f5ac6462e153925b0ed331 Mon Sep 17 00:00:00 2001 From: Trezy Date: Wed, 31 Jul 2024 21:42:57 -0500 Subject: [PATCH] chore: expose `UseAssetsStatus` values --- src/constants/UseAssetsStatus.ts | 5 +++++ src/hooks/useAsset.ts | 5 +---- src/hooks/useAssets.ts | 11 +++++------ src/index.ts | 1 + src/typedefs/UseAssetsStatus.ts | 6 ------ 5 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 src/constants/UseAssetsStatus.ts delete mode 100644 src/typedefs/UseAssetsStatus.ts diff --git a/src/constants/UseAssetsStatus.ts b/src/constants/UseAssetsStatus.ts new file mode 100644 index 00000000..c57961d5 --- /dev/null +++ b/src/constants/UseAssetsStatus.ts @@ -0,0 +1,5 @@ +export const UseAssetsStatus = { + ERROR: 'error', + PENDING: 'pending', + SUCCESS: 'success', +}; diff --git a/src/hooks/useAsset.ts b/src/hooks/useAsset.ts index 283ac9e0..c647120d 100644 --- a/src/hooks/useAsset.ts +++ b/src/hooks/useAsset.ts @@ -14,10 +14,7 @@ import type { ErrorCallback } from '../typedefs/ErrorCallback.ts'; const errorCache: Map = new Map(); -/** - * Loads assets, returning a hash of assets once they're loaded. - * @deprecated Use `useAssets` instead. - */ +/** @deprecated Use `useAssets` instead. */ export function useAsset( /** @description Asset options. */ options: (UnresolvedAsset & AssetRetryOptions) | string, diff --git a/src/hooks/useAssets.ts b/src/hooks/useAssets.ts index a0951190..d276bae9 100644 --- a/src/hooks/useAssets.ts +++ b/src/hooks/useAssets.ts @@ -3,8 +3,8 @@ import { Cache, } from 'pixi.js'; import { useState } from 'react'; +import { UseAssetsStatus } from '../constants/UseAssetsStatus.ts'; import { getAssetKey } from '../helpers/getAssetKey.ts'; -import { UseAssetsStatus } from '../typedefs/UseAssetsStatus.ts'; import type { AssetRetryState } from '../typedefs/AssetRetryState.ts'; import type { UnresolvedAsset } from '../typedefs/UnresolvedAsset.ts'; @@ -32,7 +32,7 @@ export function useAssets( isError: false, isPending: true, isSuccess: false, - status: UseAssetsStatus.Pending, + status: UseAssetsStatus.PENDING, }); if (typeof window === 'undefined') @@ -67,12 +67,11 @@ export function useAssets( isError: true, isPending: false, isSuccess: false, - status: UseAssetsStatus.Error, + status: UseAssetsStatus.ERROR, })); } - Assets - .load(assets, (progressValue) => + Assets.load(assets, (progressValue) => { if (typeof onProgress === 'function') { @@ -90,7 +89,7 @@ export function useAssets( isError: false, isPending: false, isSuccess: true, - status: UseAssetsStatus.Success, + status: UseAssetsStatus.SUCCESS, })); }) .catch((error) => diff --git a/src/index.ts b/src/index.ts index 5c60cd1e..4658bc50 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ Be aware that you are using a beta version of Pixi React. `); export { Application } from './components/Application.ts'; +export { UseAssetsStatus } from './constants/UseAssetsStatus.ts'; export { createRoot } from './core/createRoot.ts'; export * from './global.ts'; export { extend } from './helpers/extend.ts'; diff --git a/src/typedefs/UseAssetsStatus.ts b/src/typedefs/UseAssetsStatus.ts deleted file mode 100644 index f64fd83b..00000000 --- a/src/typedefs/UseAssetsStatus.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum UseAssetsStatus - { - Error, - Pending, - Success, -}