@wordpress/upload-media
Version:
Core media upload logic.
8 lines (7 loc) • 2.18 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/store/selectors.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { QueueItem, Settings, State } from './types';\n\n/**\n * Returns all items currently being uploaded.\n *\n * @param state Upload state.\n *\n * @return Queue items.\n */\nexport function getItems( state: State ): QueueItem[] {\n\treturn state.queue;\n}\n\n/**\n * Determines whether any upload is currently in progress.\n *\n * @param state Upload state.\n *\n * @return Whether any upload is currently in progress.\n */\nexport function isUploading( state: State ): boolean {\n\treturn state.queue.length >= 1;\n}\n\n/**\n * Determines whether an upload is currently in progress given an attachment URL.\n *\n * @param state Upload state.\n * @param url Attachment URL.\n *\n * @return Whether upload is currently in progress for the given attachment.\n */\nexport function isUploadingByUrl( state: State, url: string ): boolean {\n\treturn state.queue.some(\n\t\t( item ) => item.attachment?.url === url || item.sourceUrl === url\n\t);\n}\n\n/**\n * Determines whether an upload is currently in progress given an attachment ID.\n *\n * @param state Upload state.\n * @param attachmentId Attachment ID.\n *\n * @return Whether upload is currently in progress for the given attachment.\n */\nexport function isUploadingById( state: State, attachmentId: number ): boolean {\n\treturn state.queue.some(\n\t\t( item ) =>\n\t\t\titem.attachment?.id === attachmentId ||\n\t\t\titem.sourceAttachmentId === attachmentId\n\t);\n}\n\n/**\n * Returns the media upload settings.\n *\n * @param state Upload state.\n *\n * @return Settings\n */\nexport function getSettings( state: State ): Settings {\n\treturn state.settings;\n}\n"],
"mappings": ";AAYO,SAAS,SAAU,OAA4B;AACrD,SAAO,MAAM;AACd;AASO,SAAS,YAAa,OAAwB;AACpD,SAAO,MAAM,MAAM,UAAU;AAC9B;AAUO,SAAS,iBAAkB,OAAc,KAAuB;AACtE,SAAO,MAAM,MAAM;AAAA,IAClB,CAAE,SAAU,KAAK,YAAY,QAAQ,OAAO,KAAK,cAAc;AAAA,EAChE;AACD;AAUO,SAAS,gBAAiB,OAAc,cAAgC;AAC9E,SAAO,MAAM,MAAM;AAAA,IAClB,CAAE,SACD,KAAK,YAAY,OAAO,gBACxB,KAAK,uBAAuB;AAAA,EAC9B;AACD;AASO,SAAS,YAAa,OAAyB;AACrD,SAAO,MAAM;AACd;",
"names": []
}