UNPKG

@wordpress/core-data

Version:
8 lines (7 loc) 1.65 kB
{ "version": 3, "sources": ["../../src/locks/selectors.js"], "sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\titerateDescendants,\n\titeratePath,\n\thasConflictingLock,\n\tgetNode,\n} from './utils';\n\nexport function getPendingLockRequests( state ) {\n\treturn state.requests;\n}\n\nexport function isLockAvailable( state, store, path, { exclusive } ) {\n\tconst storePath = [ store, ...path ];\n\tconst locks = state.tree;\n\n\t// Validate all parents and the node itself\n\tfor ( const node of iteratePath( locks, storePath ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, node.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// iteratePath terminates early if path is unreachable, let's\n\t// re-fetch the node and check it exists in the tree.\n\tconst node = getNode( locks, storePath );\n\tif ( ! node ) {\n\t\treturn true;\n\t}\n\n\t// Validate all nested nodes\n\tfor ( const descendant of iterateDescendants( node ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, descendant.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAKO;AAEA,SAAS,uBAAwB,OAAQ;AAC/C,SAAO,MAAM;AACd;AAEO,SAAS,gBAAiB,OAAO,OAAO,MAAM,EAAE,UAAU,GAAI;AACpE,QAAM,YAAY,CAAE,OAAO,GAAG,IAAK;AACnC,QAAM,QAAQ,MAAM;AAGpB,aAAYA,aAAQ,0BAAa,OAAO,SAAU,GAAI;AACrD,YAAK,iCAAoB,EAAE,UAAU,GAAGA,MAAK,KAAM,GAAI;AACtD,aAAO;AAAA,IACR;AAAA,EACD;AAIA,QAAM,WAAO,sBAAS,OAAO,SAAU;AACvC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAGA,aAAY,kBAAc,iCAAoB,IAAK,GAAI;AACtD,YAAK,iCAAoB,EAAE,UAAU,GAAG,WAAW,KAAM,GAAI;AAC5D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;", "names": ["node"] }