@wordpress/core-data 6.35.0 → 7.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 +9 -1
- package/build/actions.js +6 -2
- package/build/actions.js.map +1 -1
- package/build/entities.js +2 -2
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js +17 -41
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/theme.js.map +1 -1
- package/build/queried-data/reducer.js +3 -3
- package/build/queried-data/reducer.js.map +1 -1
- package/build/reducer.js +1 -1
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +4 -3
- package/build/resolvers.js.map +1 -1
- package/build-module/actions.js +6 -2
- package/build-module/actions.js.map +1 -1
- package/build-module/entities.js +2 -2
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-provider.js +16 -38
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/entity-types/theme.js.map +1 -1
- package/build-module/queried-data/reducer.js +3 -3
- package/build-module/queried-data/reducer.js.map +1 -1
- package/build-module/reducer.js +1 -1
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +4 -3
- package/build-module/resolvers.js.map +1 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/entity-types/theme.d.ts +9 -0
- package/build-types/entity-types/theme.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/package.json +19 -18
- package/src/actions.js +6 -2
- package/src/entities.js +2 -2
- package/src/entity-provider.js +19 -36
- package/src/entity-types/theme.ts +10 -0
- package/src/queried-data/reducer.js +4 -3
- package/src/reducer.js +1 -1
- package/src/resolvers.js +4 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_blocks2","_name","_footnotes","_entities","EMPTY_ARRAY","entityContexts","rootEntitiesConfig","reduce","acc","loader","kind","name","context","createContext","undefined","additionalEntityConfigLoaders","getEntityContext","Error","EntityProvider","type","id","children","Provider","_react","createElement","value","useEntityId","useContext","useEntityProp","prop","_id","providerId","fullValue","useSelect","select","getEntityRecord","getEditedEntityRecord","STORE_NAME","record","editedRecord","editEntityRecord","useDispatch","setValue","useCallback","newValue","parsedBlocksCache","WeakMap","useEntityBlockEditor","getEntityRecordEdits","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","useMemo","edits","isUnedited","Object","keys","length","cackeKey","_blocks","get","parse","set","updateFootnotes","updateFootnotesFromMeta","onChange","newBlocks","options","noChange","selection","rest","blocksForSerialization","__unstableSerializeAndClean","isCached","onInput","footnotesChanges"],"sources":["@wordpress/core-data/src/entity-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { updateFootnotesFromMeta } from './footnotes';\n\n/** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Internal dependencies\n */\nimport { rootEntitiesConfig, additionalEntityConfigLoaders } from './entities';\n\nconst entityContexts = {\n\t...rootEntitiesConfig.reduce( ( acc, loader ) => {\n\t\tif ( ! acc[ loader.kind ] ) {\n\t\t\tacc[ loader.kind ] = {};\n\t\t}\n\t\tacc[ loader.kind ][ loader.name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t\treturn acc;\n\t}, {} ),\n\t...additionalEntityConfigLoaders.reduce( ( acc, loader ) => {\n\t\tacc[ loader.kind ] = {};\n\t\treturn acc;\n\t}, {} ),\n};\nconst getEntityContext = ( kind, name ) => {\n\tif ( ! entityContexts[ kind ] ) {\n\t\tthrow new Error( `Missing entity config for kind: ${ kind }.` );\n\t}\n\n\tif ( ! entityContexts[ kind ][ name ] ) {\n\t\tentityContexts[ kind ][ name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t}\n\n\treturn entityContexts[ kind ][ name ].context;\n};\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props The component's props.\n * @param {string} props.kind The entity kind.\n * @param {string} props.type The entity name.\n * @param {number} props.id The entity ID.\n * @param {*} props.children The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n * the entity's context provider.\n */\nexport default function EntityProvider( { kind, type: name, id, children } ) {\n\tconst Provider = getEntityContext( kind, name ).Provider;\n\treturn <Provider value={ id }>{ children }</Provider>;\n}\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport function useEntityId( kind, name ) {\n\treturn useContext( getEntityContext( kind, name ) );\n}\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n\nconst parsedBlocksCache = new WeakMap();\n\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[WPBlock[], Function, Function]} The block array and setters.\n */\nexport function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { getEntityRecord, getEntityRecordEdits } = useSelect( STORE_NAME );\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! id ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\tif ( ! content || typeof content !== 'string' ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\n\t\t// If there's an edit, cache the parsed blocks by the edit.\n\t\t// If not, cache by the original enity record.\n\t\tconst edits = getEntityRecordEdits( kind, name, id );\n\t\tconst isUnedited = ! edits || ! Object.keys( edits ).length;\n\t\tconst cackeKey = isUnedited ? getEntityRecord( kind, name, id ) : edits;\n\t\tlet _blocks = parsedBlocksCache.get( cackeKey );\n\n\t\tif ( ! _blocks ) {\n\t\t\t_blocks = parse( content );\n\t\t\tparsedBlocksCache.set( cackeKey, _blocks );\n\t\t}\n\n\t\treturn _blocks;\n\t}, [\n\t\tkind,\n\t\tname,\n\t\tid,\n\t\teditedBlocks,\n\t\tcontent,\n\t\tgetEntityRecord,\n\t\tgetEntityRecordEdits,\n\t] );\n\n\tconst updateFootnotes = useCallback(\n\t\t( _blocks ) => updateFootnotesFromMeta( _blocks, meta ),\n\t\t[ meta ]\n\t);\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection, ...rest } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotes( newBlocks ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: false,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tupdateFootnotes,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection, ...rest } = options;\n\t\t\tconst footnotesChanges = updateFootnotes( newBlocks );\n\t\t\tconst edits = { selection, ...footnotesChanges };\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: true,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[ kind, name, id, updateFootnotes, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AASA,IAAAK,SAAA,GAAAL,OAAA;AAzBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;;AAEA,MAAMM,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;;AAGA,MAAMC,cAAc,GAAG;EACtB,GAAGC,4BAAkB,CAACC,MAAM,CAAE,CAAEC,GAAG,EAAEC,MAAM,KAAM;IAChD,IAAK,CAAED,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,EAAG;MAC3BF,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,GAAG,CAAC,CAAC;IACxB;IACAF,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,CAAED,MAAM,CAACE,IAAI,CAAE,GAAG;MACnCC,OAAO,EAAE,IAAAC,sBAAa,EAAEC,SAAU;IACnC,CAAC;IACD,OAAON,GAAG;EACX,CAAC,EAAE,CAAC,CAAE,CAAC;EACP,GAAGO,uCAA6B,CAACR,MAAM,CAAE,CAAEC,GAAG,EAAEC,MAAM,KAAM;IAC3DD,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,GAAG,CAAC,CAAC;IACvB,OAA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EG,SAAU;IAC/B,CAAC;IAED5B,gBAAgB,CAAE9B,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAEmC,KAAK,EAAE;MACxCoB,QAAQ,EAAE,KAAK;MACf,GAAGH;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CACC9D,IAAI,EACJC,IAAI,EACJS,EAAE,EACFgC,MAAM,EACNa,eAAe,EACfZ,yBAAyB,EACzBb,gBAAgB,CAElB,CAAC;EAED,MAAMoC,OAAO,GAAG,IAAAjC,oBAAW,EAC1B,CAAEyB,SAAS,EAAEC,OAAO,KAAM;IACzB,MAAM;MAAEE,SAAS;MAAE,GAAGC;IAAK,CAAC,GAAGH,OAAO;IACtC,MAAMQ,gBAAgB,GAAGZ,eAAe,CAAEG,SAAU,CAAC;IACrD,MAAMb,KAAK,GAAG;MAAEgB,SAAS;MAAE,GAAGM;IAAiB,CAAC;IAEhDrC,gBAAgB,CAAE9B,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAEmC,KAAK,EAAE;MACxCoB,QAAQ,EAAE,IAAI;MACd,GAAGH;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CAAE9D,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAE6C,eAAe,EAAEzB,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAEY,MAAM,EAAEwB,OAAO,EAAET,QAAQ,CAAE;AACrC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_blocks2","_name","_footnotes","_jsxRuntime","EMPTY_ARRAY","EntityContext","createContext","EntityProvider","kind","type","name","id","children","parent","useContext","childContext","useMemo","jsx","Provider","value","useEntityId","context","useEntityProp","prop","_id","providerId","fullValue","useSelect","select","getEntityRecord","getEditedEntityRecord","STORE_NAME","record","editedRecord","editEntityRecord","useDispatch","setValue","useCallback","newValue","parsedBlocksCache","WeakMap","useEntityBlockEditor","getEntityRecordEdits","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","undefined","edits","isUnedited","Object","keys","length","cackeKey","_blocks","get","parse","set","updateFootnotes","updateFootnotesFromMeta","onChange","newBlocks","options","noChange","selection","rest","blocksForSerialization","__unstableSerializeAndClean","isCached","onInput","footnotesChanges"],"sources":["@wordpress/core-data/src/entity-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { updateFootnotesFromMeta } from './footnotes';\n\n/** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */\n\nconst EMPTY_ARRAY = [];\n\nconst EntityContext = createContext( {} );\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props The component's props.\n * @param {string} props.kind The entity kind.\n * @param {string} props.type The entity name.\n * @param {number} props.id The entity ID.\n * @param {*} props.children The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n * the entity's context provider.\n */\nexport default function EntityProvider( { kind, type: name, id, children } ) {\n\tconst parent = useContext( EntityContext );\n\tconst childContext = useMemo(\n\t\t() => ( {\n\t\t\t...parent,\n\t\t\t[ kind ]: {\n\t\t\t\t...parent?.[ kind ],\n\t\t\t\t[ name ]: id,\n\t\t\t},\n\t\t} ),\n\t\t[ parent, kind, name, id ]\n\t);\n\treturn (\n\t\t<EntityContext.Provider value={ childContext }>\n\t\t\t{ children }\n\t\t</EntityContext.Provider>\n\t);\n}\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport function useEntityId( kind, name ) {\n\tconst context = useContext( EntityContext );\n\treturn context?.[ kind ]?.[ name ];\n}\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n\nconst parsedBlocksCache = new WeakMap();\n\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[WPBlock[], Function, Function]} The block array and setters.\n */\nexport function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { getEntityRecord, getEntityRecordEdits } = useSelect( STORE_NAME );\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! id ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\tif ( ! content || typeof content !== 'string' ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\n\t\t// If there's an edit, cache the parsed blocks by the edit.\n\t\t// If not, cache by the original enity record.\n\t\tconst edits = getEntityRecordEdits( kind, name, id );\n\t\tconst isUnedited = ! edits || ! Object.keys( edits ).length;\n\t\tconst cackeKey = isUnedited ? getEntityRecord( kind, name, id ) : edits;\n\t\tlet _blocks = parsedBlocksCache.get( cackeKey );\n\n\t\tif ( ! _blocks ) {\n\t\t\t_blocks = parse( content );\n\t\t\tparsedBlocksCache.set( cackeKey, _blocks );\n\t\t}\n\n\t\treturn _blocks;\n\t}, [\n\t\tkind,\n\t\tname,\n\t\tid,\n\t\teditedBlocks,\n\t\tcontent,\n\t\tgetEntityRecord,\n\t\tgetEntityRecordEdits,\n\t] );\n\n\tconst updateFootnotes = useCallback(\n\t\t( _blocks ) => updateFootnotesFromMeta( _blocks, meta ),\n\t\t[ meta ]\n\t);\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection, ...rest } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotes( newBlocks ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: false,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tupdateFootnotes,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection, ...rest } = options;\n\t\t\tconst footnotesChanges = updateFootnotes( newBlocks );\n\t\t\tconst edits = { selection, ...footnotesChanges };\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: true,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[ kind, name, id, updateFootnotes, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAAsD,IAAAK,WAAA,GAAAL,OAAA;AAhBtD;AACA;AACA;;AAUA;AACA;AACA;;AAIA,6DAEA,MAAMM,WAAW,GAAG,EAAE;AAEtB,MAAMC,aAAa,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H;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CACC1D,IAAI,EACJE,IAAI,EACJC,EAAE,EACFmC,MAAM,EACNa,eAAe,EACfZ,yBAAyB,EACzBb,gBAAgB,CAElB,CAAC;EAED,MAAMoC,OAAO,GAAG,IAAAjC,oBAAW,EAC1B,CAAEyB,SAAS,EAAEC,OAAO,KAAM;IACzB,MAAM;MAAEE,SAAS;MAAE,GAAGC;IAAK,CAAC,GAAGH,OAAO;IACtC,MAAMQ,gBAAgB,GAAGZ,eAAe,CAAEG,SAAU,CAAC;IACrD,MAAMb,KAAK,GAAG;MAAEgB,SAAS;MAAE,GAAGM;IAAiB,CAAC;IAEhDrC,gBAAgB,CAAE1B,IAAI,EAAEE,IAAI,EAAEC,EAAE,EAAEsC,KAAK,EAAE;MACxCoB,QAAQ,EAAE,IAAI;MACd,GAAGH;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CAAE1D,IAAI,EAAEE,IAAI,EAAEC,EAAE,EAAEgD,eAAe,EAAEzB,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAEY,MAAM,EAAEwB,OAAO,EAAET,QAAQ,CAAE;AACrC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/theme.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, PostFormat, RenderedText, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Theme< C extends Context > {\n\t\t\t/**\n\t\t\t * The theme's stylesheet. This uniquely identifies the theme.\n\t\t\t */\n\t\t\tstylesheet: string;\n\t\t\t/**\n\t\t\t * The theme's template. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme's stylesheet.\n\t\t\t */\n\t\t\ttemplate: string;\n\t\t\t/**\n\t\t\t * The theme author.\n\t\t\t */\n\t\t\tauthor: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The website of the theme author.\n\t\t\t */\n\t\t\tauthor_uri: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * A description of the theme.\n\t\t\t */\n\t\t\tdescription: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The name of the theme.\n\t\t\t */\n\t\t\tname: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The minimum PHP version required for the theme to work.\n\t\t\t */\n\t\t\trequires_php: string;\n\t\t\t/**\n\t\t\t * The minimum WordPress version required for the theme to work.\n\t\t\t */\n\t\t\trequires_wp: string;\n\t\t\t/**\n\t\t\t * The theme's screenshot URL.\n\t\t\t */\n\t\t\tscreenshot: string;\n\t\t\t/**\n\t\t\t * Tags indicating styles and features of the theme.\n\t\t\t */\n\t\t\ttags: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The theme's text domain.\n\t\t\t */\n\t\t\ttextdomain: string;\n\t\t\t/**\n\t\t\t * Features supported by this theme.\n\t\t\t */\n\t\t\ttheme_supports: ThemeSupports;\n\t\t\t/**\n\t\t\t * The URI of the theme's webpage.\n\t\t\t */\n\t\t\ttheme_uri: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The theme's current version.\n\t\t\t */\n\t\t\tversion: string;\n\t\t\t/**\n\t\t\t * A named status for the theme.\n\t\t\t */\n\t\t\tstatus: ThemeStatus;\n\t\t}\n\n\t\texport type ThemeStatus = 'active' | 'inactive';\n\n\t\texport interface ThemeSupports {\n\t\t\t/**\n\t\t\t * Whether theme opts in to wide alignment CSS class.\n\t\t\t */\n\t\t\t'align-wide': boolean;\n\t\t\t/**\n\t\t\t * Whether appearanceTools are enabled in Global Styles.\n\t\t\t */\n\t\t\t'appearance-tools': boolean;\n\t\t\t/**\n\t\t\t * Whether posts and comments RSS feed links are added to head.\n\t\t\t */\n\t\t\t'automatic-feed-links': boolean;\n\t\t\t/**\n\t\t\t * Whether border settings are enabled.\n\t\t\t */\n\t\t\tborder: boolean;\n\t\t\t/**\n\t\t\t * Custom background if defined by the theme.\n\t\t\t */\n\t\t\t'custom-background': boolean | CustomBackground;\n\t\t\t/**\n\t\t\t * Custom header if defined by the theme.\n\t\t\t */\n\t\t\t'custom-header': boolean | CustomHeader;\n\t\t\t/**\n\t\t\t * Custom logo if defined by the theme.\n\t\t\t */\n\t\t\t'custom-logo': boolean | CustomLogo;\n\t\t\t/**\n\t\t\t * Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.\n\t\t\t */\n\t\t\t'customize-selective-refresh-widgets': boolean;\n\t\t\t/**\n\t\t\t * Whether theme opts in to the dark editor style UI.\n\t\t\t */\n\t\t\t'dark-editor-style': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom colors.\n\t\t\t */\n\t\t\t'disable-custom-colors': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom font sizes.\n\t\t\t */\n\t\t\t'disable-custom-font-sizes': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom gradients.\n\t\t\t */\n\t\t\t'disable-custom-gradients': boolean;\n\t\t\t/**\n\t\t\t * Custom color palette if defined by the theme.\n\t\t\t */\n\t\t\t'editor-color-palette': boolean | Color[];\n\t\t\t/**\n\t\t\t * Custom font sizes if defined by the theme.\n\t\t\t */\n\t\t\t'editor-font-sizes': boolean | FontSize[];\n\t\t\t/**\n\t\t\t * Custom gradient presets if defined by the theme.\n\t\t\t */\n\t\t\t'editor-gradient-presets': boolean | GradientPreset[];\n\t\t\t/**\n\t\t\t * Whether theme opts in to the editor styles CSS wrapper.\n\t\t\t */\n\t\t\t'editor-styles': boolean;\n\t\t\t/**\n\t\t\t * Allows use of HTML5 markup for search forms, comment forms, comment lists, gallery, and caption.\n\t\t\t */\n\t\t\thtml5: boolean | Html5Option[];\n\t\t\t/**\n\t\t\t * Post formats supported.\n\t\t\t */\n\t\t\tformats: PostFormat[];\n\t\t\t/**\n\t\t\t * Whether link colors are enabled.\n\t\t\t */\n\t\t\t'link-color': boolean;\n\t\t\t/**\n\t\t\t * The post types that support thumbnails or true if all post types are supported.\n\t\t\t */\n\t\t\t'post-thumbnails': boolean | string[];\n\t\t\t/**\n\t\t\t * Whether the theme supports responsive embedded content.\n\t\t\t */\n\t\t\t'responsive-embeds': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme can manage the document title tag.\n\t\t\t */\n\t\t\t'title-tag': boolean;\n\t\t\t/**\n\t\t\t * Whether theme opts in to default WordPress block styles for viewing.\n\t\t\t */\n\t\t\t'wp-block-styles': boolean;\n\t\t}\n\n\t\texport interface CustomBackground {\n\t\t\t'default-image': string;\n\t\t\t'default-preset': 'default' | 'fill' | 'fit' | 'repeat' | 'custom';\n\t\t\t'default-position-x': 'left' | 'center' | 'right';\n\t\t\t'default-position-y': 'left' | 'center' | 'right';\n\t\t\t'default-size': 'auto' | 'contain' | 'cover';\n\t\t\t'default-repeat': 'repeat-x' | 'repeat-y' | 'repeat' | 'no-repeat';\n\t\t\t'default-attachment': 'scroll' | 'fixed';\n\t\t\t'default-color': string;\n\t\t}\n\n\t\texport interface CustomHeader {\n\t\t\t'default-image': string;\n\t\t\t'random-default': boolean;\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\t'flex-height': boolean;\n\t\t\t'flex-width': boolean;\n\t\t\t'default-text-color': string;\n\t\t\t'header-text': boolean;\n\t\t\tuploads: boolean;\n\t\t\tvideo: boolean;\n\t\t}\n\n\t\texport interface CustomLogo {\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\t'flex-width': boolean;\n\t\t\t'flex-height': boolean;\n\t\t\t'header-text': string[];\n\t\t\t'unlink-homepage-logo': boolean;\n\t\t}\n\n\t\texport interface Color {\n\t\t\tname: string;\n\t\t\tslug: string;\n\t\t\tcolor: string;\n\t\t}\n\n\t\texport interface FontSize {\n\t\t\tname: string;\n\t\t\tsize: number;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport interface GradientPreset {\n\t\t\tname: string;\n\t\t\tgradient: string;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport type Html5Option =\n\t\t\t| 'search-form'\n\t\t\t| 'comment-form'\n\t\t\t| 'comment-list'\n\t\t\t| 'gallery'\n\t\t\t| 'caption'\n\t\t\t| 'script'\n\t\t\t| 'style';\n\t}\n}\n\nexport type Theme< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Theme< C >\n>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/theme.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, PostFormat, RenderedText, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Theme< C extends Context > {\n\t\t\t/**\n\t\t\t * The theme's stylesheet. This uniquely identifies the theme.\n\t\t\t */\n\t\t\tstylesheet: string;\n\t\t\t/**\n\t\t\t * The theme's template. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme's stylesheet.\n\t\t\t */\n\t\t\ttemplate: string;\n\t\t\t/**\n\t\t\t * The theme author.\n\t\t\t */\n\t\t\tauthor: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The website of the theme author.\n\t\t\t */\n\t\t\tauthor_uri: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * A description of the theme.\n\t\t\t */\n\t\t\tdescription: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The name of the theme.\n\t\t\t */\n\t\t\tname: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The minimum PHP version required for the theme to work.\n\t\t\t */\n\t\t\trequires_php: string;\n\t\t\t/**\n\t\t\t * The minimum WordPress version required for the theme to work.\n\t\t\t */\n\t\t\trequires_wp: string;\n\t\t\t/**\n\t\t\t * The theme's screenshot URL.\n\t\t\t */\n\t\t\tscreenshot: string;\n\t\t\t/**\n\t\t\t * Tags indicating styles and features of the theme.\n\t\t\t */\n\t\t\ttags: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The theme's text domain.\n\t\t\t */\n\t\t\ttextdomain: string;\n\t\t\t/**\n\t\t\t * Features supported by this theme.\n\t\t\t */\n\t\t\ttheme_supports: ThemeSupports;\n\t\t\t/**\n\t\t\t * The URI of the theme's webpage.\n\t\t\t */\n\t\t\ttheme_uri: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The theme's current version.\n\t\t\t */\n\t\t\tversion: string;\n\t\t\t/**\n\t\t\t * A named status for the theme.\n\t\t\t */\n\t\t\tstatus: ThemeStatus;\n\t\t}\n\n\t\texport type ThemeStatus = 'active' | 'inactive';\n\n\t\texport interface ThemeSupports {\n\t\t\t/**\n\t\t\t * Whether theme opts in to wide alignment CSS class.\n\t\t\t */\n\t\t\t'align-wide': boolean;\n\t\t\t/**\n\t\t\t * Whether appearanceTools are enabled in Global Styles.\n\t\t\t */\n\t\t\t'appearance-tools': boolean;\n\t\t\t/**\n\t\t\t * Whether posts and comments RSS feed links are added to head.\n\t\t\t */\n\t\t\t'automatic-feed-links': boolean;\n\t\t\t/**\n\t\t\t * Whether border settings are enabled.\n\t\t\t */\n\t\t\tborder: boolean;\n\t\t\t/**\n\t\t\t * Custom background if defined by the theme.\n\t\t\t */\n\t\t\t'custom-background': boolean | CustomBackground;\n\t\t\t/**\n\t\t\t * Custom header if defined by the theme.\n\t\t\t */\n\t\t\t'custom-header': boolean | CustomHeader;\n\t\t\t/**\n\t\t\t * Custom logo if defined by the theme.\n\t\t\t */\n\t\t\t'custom-logo': boolean | CustomLogo;\n\t\t\t/**\n\t\t\t * Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.\n\t\t\t */\n\t\t\t'customize-selective-refresh-widgets': boolean;\n\t\t\t/**\n\t\t\t * Whether theme opts in to the dark editor style UI.\n\t\t\t */\n\t\t\t'dark-editor-style': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom colors.\n\t\t\t */\n\t\t\t'disable-custom-colors': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom font sizes.\n\t\t\t */\n\t\t\t'disable-custom-font-sizes': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom gradients.\n\t\t\t */\n\t\t\t'disable-custom-gradients': boolean;\n\t\t\t/**\n\t\t\t * Custom color palette if defined by the theme.\n\t\t\t */\n\t\t\t'editor-color-palette': boolean | Color[];\n\t\t\t/**\n\t\t\t * Custom font sizes if defined by the theme.\n\t\t\t */\n\t\t\t'editor-font-sizes': boolean | FontSize[];\n\t\t\t/**\n\t\t\t * Custom spacing sizes if defined by the theme.\n\t\t\t */\n\t\t\t'editor-spacing-sizes': boolean | SpacingSize[];\n\t\t\t/**\n\t\t\t * Custom gradient presets if defined by the theme.\n\t\t\t */\n\t\t\t'editor-gradient-presets': boolean | GradientPreset[];\n\t\t\t/**\n\t\t\t * Whether theme opts in to the editor styles CSS wrapper.\n\t\t\t */\n\t\t\t'editor-styles': boolean;\n\t\t\t/**\n\t\t\t * Allows use of HTML5 markup for search forms, comment forms, comment lists, gallery, and caption.\n\t\t\t */\n\t\t\thtml5: boolean | Html5Option[];\n\t\t\t/**\n\t\t\t * Post formats supported.\n\t\t\t */\n\t\t\tformats: PostFormat[];\n\t\t\t/**\n\t\t\t * Whether link colors are enabled.\n\t\t\t */\n\t\t\t'link-color': boolean;\n\t\t\t/**\n\t\t\t * The post types that support thumbnails or true if all post types are supported.\n\t\t\t */\n\t\t\t'post-thumbnails': boolean | string[];\n\t\t\t/**\n\t\t\t * Whether the theme supports responsive embedded content.\n\t\t\t */\n\t\t\t'responsive-embeds': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme can manage the document title tag.\n\t\t\t */\n\t\t\t'title-tag': boolean;\n\t\t\t/**\n\t\t\t * Whether theme opts in to default WordPress block styles for viewing.\n\t\t\t */\n\t\t\t'wp-block-styles': boolean;\n\t\t}\n\n\t\texport interface CustomBackground {\n\t\t\t'default-image': string;\n\t\t\t'default-preset': 'default' | 'fill' | 'fit' | 'repeat' | 'custom';\n\t\t\t'default-position-x': 'left' | 'center' | 'right';\n\t\t\t'default-position-y': 'left' | 'center' | 'right';\n\t\t\t'default-size': 'auto' | 'contain' | 'cover';\n\t\t\t'default-repeat': 'repeat-x' | 'repeat-y' | 'repeat' | 'no-repeat';\n\t\t\t'default-attachment': 'scroll' | 'fixed';\n\t\t\t'default-color': string;\n\t\t}\n\n\t\texport interface CustomHeader {\n\t\t\t'default-image': string;\n\t\t\t'random-default': boolean;\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\t'flex-height': boolean;\n\t\t\t'flex-width': boolean;\n\t\t\t'default-text-color': string;\n\t\t\t'header-text': boolean;\n\t\t\tuploads: boolean;\n\t\t\tvideo: boolean;\n\t\t}\n\n\t\texport interface CustomLogo {\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\t'flex-width': boolean;\n\t\t\t'flex-height': boolean;\n\t\t\t'header-text': string[];\n\t\t\t'unlink-homepage-logo': boolean;\n\t\t}\n\n\t\texport interface Color {\n\t\t\tname: string;\n\t\t\tslug: string;\n\t\t\tcolor: string;\n\t\t}\n\n\t\texport interface FontSize {\n\t\t\tname: string;\n\t\t\tsize: number;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport interface SpacingSize {\n\t\t\tname: string;\n\t\t\tsize: number;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport interface GradientPreset {\n\t\t\tname: string;\n\t\t\tgradient: string;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport type Html5Option =\n\t\t\t| 'search-form'\n\t\t\t| 'comment-form'\n\t\t\t| 'comment-list'\n\t\t\t| 'gallery'\n\t\t\t| 'caption'\n\t\t\t| 'script'\n\t\t\t| 'style';\n\t}\n}\n\nexport type Theme< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Theme< C >\n>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -105,7 +105,7 @@ function items(state = {}, action) {
|
|
|
105
105
|
[context]: {
|
|
106
106
|
...state[context],
|
|
107
107
|
...action.items.reduce((accumulator, value) => {
|
|
108
|
-
const itemId = value[key];
|
|
108
|
+
const itemId = value?.[key];
|
|
109
109
|
accumulator[itemId] = (0, _utils.conservativeMapItem)(state?.[context]?.[itemId], value);
|
|
110
110
|
return accumulator;
|
|
111
111
|
}, {})
|
|
@@ -153,7 +153,7 @@ function itemIsComplete(state = {}, action) {
|
|
|
153
153
|
[context]: {
|
|
154
154
|
...state[context],
|
|
155
155
|
...action.items.reduce((result, item) => {
|
|
156
|
-
const itemId = item[key];
|
|
156
|
+
const itemId = item?.[key];
|
|
157
157
|
|
|
158
158
|
// Defer to completeness if already assigned. Technically the
|
|
159
159
|
// data may be outdated if receiving items for a field subset.
|
|
@@ -208,7 +208,7 @@ const receiveQueries = (0, _compose.compose)([
|
|
|
208
208
|
return state;
|
|
209
209
|
}
|
|
210
210
|
return {
|
|
211
|
-
itemIds: getMergedItemIds(state?.itemIds || [], action.items.map(item => item[key]), page, perPage),
|
|
211
|
+
itemIds: getMergedItemIds(state?.itemIds || [], action.items.map(item => item?.[key]).filter(Boolean), page, perPage),
|
|
212
212
|
meta: action.meta
|
|
213
213
|
};
|
|
214
214
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_compose","_utils","_entities","_getQueryParts","_interopRequireDefault","getContextFromAction","action","query","queryParts","getQueryParts","context","getMergedItemIds","itemIds","nextItemIds","page","perPage","_itemIds$length","receivedAllIds","nextItemIdsStartIndex","size","Math","max","length","mergedItemIds","Array","i","isInNextItemsRange","removeEntitiesById","entities","ids","Object","fromEntries","entries","filter","id","some","itemId","Number","isInteger","items","state","type","key","DEFAULT_ENTITY_KEY","reduce","accumulator","value","conservativeMapItem","map","contextState","itemIsComplete","isCompleteQuery","isArray","fields","result","item","receiveQueries","compose","ifMatchingAction","replaceAction","onSubKey","meta","queries","removedItems","queryGroup","contextQueries","queryItems","queryId","_default","exports","default","combineReducers"],"sources":["@wordpress/core-data/src/queried-data/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tconservativeMapItem,\n\tifMatchingAction,\n\treplaceAction,\n\tonSubKey,\n} from '../utils';\nimport { DEFAULT_ENTITY_KEY } from '../entities';\nimport getQueryParts from './get-query-parts';\n\nfunction getContextFromAction( action ) {\n\tconst { query } = action;\n\tif ( ! query ) {\n\t\treturn 'default';\n\t}\n\n\tconst queryParts = getQueryParts( query );\n\treturn queryParts.context;\n}\n\n/**\n * Returns a merged array of item IDs, given details of the received paginated\n * items. The array is sparse-like with `undefined` entries where holes exist.\n *\n * @param {?Array<number>} itemIds Original item IDs (default empty array).\n * @param {number[]} nextItemIds Item IDs to merge.\n * @param {number} page Page of items merged.\n * @param {number} perPage Number of items per page.\n *\n * @return {number[]} Merged array of item IDs.\n */\nexport function getMergedItemIds( itemIds, nextItemIds, page, perPage ) {\n\tconst receivedAllIds = page === 1 && perPage === -1;\n\tif ( receivedAllIds ) {\n\t\treturn nextItemIds;\n\t}\n\tconst nextItemIdsStartIndex = ( page - 1 ) * perPage;\n\n\t// If later page has already been received, default to the larger known\n\t// size of the existing array, else calculate as extending the existing.\n\tconst size = Math.max(\n\t\titemIds?.length ?? 0,\n\t\tnextItemIdsStartIndex + nextItemIds.length\n\t);\n\n\t// Preallocate array since size is known.\n\tconst mergedItemIds = new Array( size );\n\n\tfor ( let i = 0; i < size; i++ ) {\n\t\t// Preserve existing item ID except for subset of range of next items.\n\t\t// We need to check against the possible maximum upper boundary because\n\t\t// a page could receive fewer than what was previously stored.\n\t\tconst isInNextItemsRange =\n\t\t\ti >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + perPage;\n\t\tmergedItemIds[ i ] = isInNextItemsRange\n\t\t\t? nextItemIds[ i - nextItemIdsStartIndex ]\n\t\t\t: itemIds?.[ i ];\n\t}\n\n\treturn mergedItemIds;\n}\n\n/**\n * Helper function to filter out entities with certain IDs.\n * Entities are keyed by their ID.\n *\n * @param {Object} entities Entity objects, keyed by entity ID.\n * @param {Array} ids Entity IDs to filter out.\n *\n * @return {Object} Filtered entities.\n */\nfunction removeEntitiesById( entities, ids ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( entities ).filter(\n\t\t\t( [ id ] ) =>\n\t\t\t\t! ids.some( ( itemId ) => {\n\t\t\t\t\tif ( Number.isInteger( itemId ) ) {\n\t\t\t\t\t\treturn itemId === +id;\n\t\t\t\t\t}\n\t\t\t\t\treturn itemId === id;\n\t\t\t\t} )\n\t\t)\n\t);\n}\n\n/**\n * Reducer tracking items state, keyed by ID. Items are assumed to be normal,\n * where identifiers are common across all queries.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nexport function items( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS': {\n\t\t\tconst context = getContextFromAction( action );\n\t\t\tconst key = action.key || DEFAULT_ENTITY_KEY;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ context ]: {\n\t\t\t\t\t...state[ context ],\n\t\t\t\t\t...action.items.reduce( ( accumulator, value ) => {\n\t\t\t\t\t\tconst itemId = value[ key ];\n\t\t\t\t\t\taccumulator[ itemId ] = conservativeMapItem(\n\t\t\t\t\t\t\tstate?.[ context ]?.[ itemId ],\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t}, {} ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase 'REMOVE_ITEMS':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map( ( [ itemId, contextState ] ) => [\n\t\t\t\t\titemId,\n\t\t\t\t\tremoveEntitiesById( contextState, action.itemIds ),\n\t\t\t\t] )\n\t\t\t);\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking item completeness, keyed by ID. A complete item is one for\n * which all fields are known. This is used in supporting `_fields` queries,\n * where not all properties associated with an entity are necessarily returned.\n * In such cases, completeness is used as an indication of whether it would be\n * safe to use queried data for a non-`_fields`-limited request.\n *\n * @param {Object<string,Object<string,boolean>>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object<string,Object<string,boolean>>} Next state.\n */\nexport function itemIsComplete( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS': {\n\t\t\tconst context = getContextFromAction( action );\n\t\t\tconst { query, key = DEFAULT_ENTITY_KEY } = action;\n\n\t\t\t// An item is considered complete if it is received without an associated\n\t\t\t// fields query. Ideally, this would be implemented in such a way where the\n\t\t\t// complete aggregate of all fields would satisfy completeness. Since the\n\t\t\t// fields are not consistent across all entities, this would require\n\t\t\t// introspection on the REST schema for each entity to know which fields\n\t\t\t// compose a complete item for that entity.\n\t\t\tconst queryParts = query ? getQueryParts( query ) : {};\n\t\t\tconst isCompleteQuery =\n\t\t\t\t! query || ! Array.isArray( queryParts.fields );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ context ]: {\n\t\t\t\t\t...state[ context ],\n\t\t\t\t\t...action.items.reduce( ( result, item ) => {\n\t\t\t\t\t\tconst itemId = item[ key ];\n\n\t\t\t\t\t\t// Defer to completeness if already assigned. Technically the\n\t\t\t\t\t\t// data may be outdated if receiving items for a field subset.\n\t\t\t\t\t\tresult[ itemId ] =\n\t\t\t\t\t\t\tstate?.[ context ]?.[ itemId ] || isCompleteQuery;\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}, {} ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase 'REMOVE_ITEMS':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map( ( [ itemId, contextState ] ) => [\n\t\t\t\t\titemId,\n\t\t\t\t\tremoveEntitiesById( contextState, action.itemIds ),\n\t\t\t\t] )\n\t\t\t);\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking queries state, keyed by stable query key. Each reducer\n * query object includes `itemIds` and `requestingPageByPerPage`.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nconst receiveQueries = compose( [\n\t// Limit to matching action type so we don't attempt to replace action on\n\t// an unhandled action.\n\tifMatchingAction( ( action ) => 'query' in action ),\n\n\t// Inject query parts into action for use both in `onSubKey` and reducer.\n\treplaceAction( ( action ) => {\n\t\t// `ifMatchingAction` still passes on initialization, where state is\n\t\t// undefined and a query is not assigned. Avoid attempting to parse\n\t\t// parts. `onSubKey` will omit by lack of `stableKey`.\n\t\tif ( action.query ) {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\t...getQueryParts( action.query ),\n\t\t\t};\n\t\t}\n\n\t\treturn action;\n\t} ),\n\n\tonSubKey( 'context' ),\n\n\t// Queries shape is shared, but keyed by query `stableKey` part. Original\n\t// reducer tracks only a single query object.\n\tonSubKey( 'stableKey' ),\n] )( ( state = {}, action ) => {\n\tconst { type, page, perPage, key = DEFAULT_ENTITY_KEY } = action;\n\n\tif ( type !== 'RECEIVE_ITEMS' ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\titemIds: getMergedItemIds(\n\t\t\tstate?.itemIds || [],\n\t\t\taction.items.map( ( item ) => item[ key ] ),\n\t\t\tpage,\n\t\t\tperPage\n\t\t),\n\t\tmeta: action.meta,\n\t};\n} );\n\n/**\n * Reducer tracking queries state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nconst queries = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS':\n\t\t\treturn receiveQueries( state, action );\n\t\tcase 'REMOVE_ITEMS':\n\t\t\tconst removedItems = action.itemIds.reduce( ( result, itemId ) => {\n\t\t\t\tresult[ itemId ] = true;\n\t\t\t\treturn result;\n\t\t\t}, {} );\n\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map(\n\t\t\t\t\t( [ queryGroup, contextQueries ] ) => [\n\t\t\t\t\t\tqueryGroup,\n\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\tObject.entries( contextQueries ).map(\n\t\t\t\t\t\t\t\t( [ query, queryItems ] ) => [\n\t\t\t\t\t\t\t\t\tquery,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t...queryItems,\n\t\t\t\t\t\t\t\t\t\titemIds: queryItems.itemIds.filter(\n\t\t\t\t\t\t\t\t\t\t\t( queryId ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t! removedItems[ queryId ]\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn state;\n\t}\n};\n\nexport default combineReducers( {\n\titems,\n\titemIsComplete,\n\tqueries,\n} );\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA,SAASM,oBAAoBA,CAAEC,MAAM,EAAG;EACvC,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAK,CAAEC,KAAK,EAAG;IACd,OAAO,SAAS;EACjB;EAEA,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAAEF,KAAM,CAAC;EACzC,OAAOC,UAAU,CAACE,OAAO;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,OAAO,EAAEC,WAAW,EAAEC,IAAI,EAAEC,OAAO,EA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,CAAE,CAAC;MAEP,OAAOxB,MAAM,CAACC,WAAW,CACxBD,MAAM,CAACE,OAAO,CAAEQ,KAAM,CAAC,CAACQ,GAAG,CAC1B,CAAE,CAAEgB,UAAU,EAAEC,cAAc,CAAE,KAAM,CACrCD,UAAU,EACVlC,MAAM,CAACC,WAAW,CACjBD,MAAM,CAACE,OAAO,CAAEiC,cAAe,CAAC,CAACjB,GAAG,CACnC,CAAE,CAAEzC,KAAK,EAAE2D,UAAU,CAAE,KAAM,CAC5B3D,KAAK,EACL;QACC,GAAG2D,UAAU;QACbtD,OAAO,EAAEsD,UAAU,CAACtD,OAAO,CAACqB,MAAM,CAC/BkC,OAAO,IACR,CAAEJ,YAAY,CAAEI,OAAO,CACzB;MACD,CAAC,CAEH,CACD,CAAC,CAEH,CACD,CAAC;IACF;MACC,OAAO3B,KAAK;EACd;AACD,CAAC;AAAC,IAAA4B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,qBAAe,EAAE;EAC/BhC,KAAK;EACLW,cAAc;EACdY;AACD,CAAE,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_compose","_utils","_entities","_getQueryParts","_interopRequireDefault","getContextFromAction","action","query","queryParts","getQueryParts","context","getMergedItemIds","itemIds","nextItemIds","page","perPage","_itemIds$length","receivedAllIds","nextItemIdsStartIndex","size","Math","max","length","mergedItemIds","Array","i","isInNextItemsRange","removeEntitiesById","entities","ids","Object","fromEntries","entries","filter","id","some","itemId","Number","isInteger","items","state","type","key","DEFAULT_ENTITY_KEY","reduce","accumulator","value","conservativeMapItem","map","contextState","itemIsComplete","isCompleteQuery","isArray","fields","result","item","receiveQueries","compose","ifMatchingAction","replaceAction","onSubKey","Boolean","meta","queries","removedItems","queryGroup","contextQueries","queryItems","queryId","_default","exports","default","combineReducers"],"sources":["@wordpress/core-data/src/queried-data/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tconservativeMapItem,\n\tifMatchingAction,\n\treplaceAction,\n\tonSubKey,\n} from '../utils';\nimport { DEFAULT_ENTITY_KEY } from '../entities';\nimport getQueryParts from './get-query-parts';\n\nfunction getContextFromAction( action ) {\n\tconst { query } = action;\n\tif ( ! query ) {\n\t\treturn 'default';\n\t}\n\n\tconst queryParts = getQueryParts( query );\n\treturn queryParts.context;\n}\n\n/**\n * Returns a merged array of item IDs, given details of the received paginated\n * items. The array is sparse-like with `undefined` entries where holes exist.\n *\n * @param {?Array<number>} itemIds Original item IDs (default empty array).\n * @param {number[]} nextItemIds Item IDs to merge.\n * @param {number} page Page of items merged.\n * @param {number} perPage Number of items per page.\n *\n * @return {number[]} Merged array of item IDs.\n */\nexport function getMergedItemIds( itemIds, nextItemIds, page, perPage ) {\n\tconst receivedAllIds = page === 1 && perPage === -1;\n\tif ( receivedAllIds ) {\n\t\treturn nextItemIds;\n\t}\n\tconst nextItemIdsStartIndex = ( page - 1 ) * perPage;\n\n\t// If later page has already been received, default to the larger known\n\t// size of the existing array, else calculate as extending the existing.\n\tconst size = Math.max(\n\t\titemIds?.length ?? 0,\n\t\tnextItemIdsStartIndex + nextItemIds.length\n\t);\n\n\t// Preallocate array since size is known.\n\tconst mergedItemIds = new Array( size );\n\n\tfor ( let i = 0; i < size; i++ ) {\n\t\t// Preserve existing item ID except for subset of range of next items.\n\t\t// We need to check against the possible maximum upper boundary because\n\t\t// a page could receive fewer than what was previously stored.\n\t\tconst isInNextItemsRange =\n\t\t\ti >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + perPage;\n\t\tmergedItemIds[ i ] = isInNextItemsRange\n\t\t\t? nextItemIds[ i - nextItemIdsStartIndex ]\n\t\t\t: itemIds?.[ i ];\n\t}\n\n\treturn mergedItemIds;\n}\n\n/**\n * Helper function to filter out entities with certain IDs.\n * Entities are keyed by their ID.\n *\n * @param {Object} entities Entity objects, keyed by entity ID.\n * @param {Array} ids Entity IDs to filter out.\n *\n * @return {Object} Filtered entities.\n */\nfunction removeEntitiesById( entities, ids ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( entities ).filter(\n\t\t\t( [ id ] ) =>\n\t\t\t\t! ids.some( ( itemId ) => {\n\t\t\t\t\tif ( Number.isInteger( itemId ) ) {\n\t\t\t\t\t\treturn itemId === +id;\n\t\t\t\t\t}\n\t\t\t\t\treturn itemId === id;\n\t\t\t\t} )\n\t\t)\n\t);\n}\n\n/**\n * Reducer tracking items state, keyed by ID. Items are assumed to be normal,\n * where identifiers are common across all queries.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nexport function items( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS': {\n\t\t\tconst context = getContextFromAction( action );\n\t\t\tconst key = action.key || DEFAULT_ENTITY_KEY;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ context ]: {\n\t\t\t\t\t...state[ context ],\n\t\t\t\t\t...action.items.reduce( ( accumulator, value ) => {\n\t\t\t\t\t\tconst itemId = value?.[ key ];\n\n\t\t\t\t\t\taccumulator[ itemId ] = conservativeMapItem(\n\t\t\t\t\t\t\tstate?.[ context ]?.[ itemId ],\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t}, {} ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase 'REMOVE_ITEMS':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map( ( [ itemId, contextState ] ) => [\n\t\t\t\t\titemId,\n\t\t\t\t\tremoveEntitiesById( contextState, action.itemIds ),\n\t\t\t\t] )\n\t\t\t);\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking item completeness, keyed by ID. A complete item is one for\n * which all fields are known. This is used in supporting `_fields` queries,\n * where not all properties associated with an entity are necessarily returned.\n * In such cases, completeness is used as an indication of whether it would be\n * safe to use queried data for a non-`_fields`-limited request.\n *\n * @param {Object<string,Object<string,boolean>>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object<string,Object<string,boolean>>} Next state.\n */\nexport function itemIsComplete( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS': {\n\t\t\tconst context = getContextFromAction( action );\n\t\t\tconst { query, key = DEFAULT_ENTITY_KEY } = action;\n\n\t\t\t// An item is considered complete if it is received without an associated\n\t\t\t// fields query. Ideally, this would be implemented in such a way where the\n\t\t\t// complete aggregate of all fields would satisfy completeness. Since the\n\t\t\t// fields are not consistent across all entities, this would require\n\t\t\t// introspection on the REST schema for each entity to know which fields\n\t\t\t// compose a complete item for that entity.\n\t\t\tconst queryParts = query ? getQueryParts( query ) : {};\n\t\t\tconst isCompleteQuery =\n\t\t\t\t! query || ! Array.isArray( queryParts.fields );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ context ]: {\n\t\t\t\t\t...state[ context ],\n\t\t\t\t\t...action.items.reduce( ( result, item ) => {\n\t\t\t\t\t\tconst itemId = item?.[ key ];\n\n\t\t\t\t\t\t// Defer to completeness if already assigned. Technically the\n\t\t\t\t\t\t// data may be outdated if receiving items for a field subset.\n\t\t\t\t\t\tresult[ itemId ] =\n\t\t\t\t\t\t\tstate?.[ context ]?.[ itemId ] || isCompleteQuery;\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}, {} ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase 'REMOVE_ITEMS':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map( ( [ itemId, contextState ] ) => [\n\t\t\t\t\titemId,\n\t\t\t\t\tremoveEntitiesById( contextState, action.itemIds ),\n\t\t\t\t] )\n\t\t\t);\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking queries state, keyed by stable query key. Each reducer\n * query object includes `itemIds` and `requestingPageByPerPage`.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nconst receiveQueries = compose( [\n\t// Limit to matching action type so we don't attempt to replace action on\n\t// an unhandled action.\n\tifMatchingAction( ( action ) => 'query' in action ),\n\n\t// Inject query parts into action for use both in `onSubKey` and reducer.\n\treplaceAction( ( action ) => {\n\t\t// `ifMatchingAction` still passes on initialization, where state is\n\t\t// undefined and a query is not assigned. Avoid attempting to parse\n\t\t// parts. `onSubKey` will omit by lack of `stableKey`.\n\t\tif ( action.query ) {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\t...getQueryParts( action.query ),\n\t\t\t};\n\t\t}\n\n\t\treturn action;\n\t} ),\n\n\tonSubKey( 'context' ),\n\n\t// Queries shape is shared, but keyed by query `stableKey` part. Original\n\t// reducer tracks only a single query object.\n\tonSubKey( 'stableKey' ),\n] )( ( state = {}, action ) => {\n\tconst { type, page, perPage, key = DEFAULT_ENTITY_KEY } = action;\n\n\tif ( type !== 'RECEIVE_ITEMS' ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\titemIds: getMergedItemIds(\n\t\t\tstate?.itemIds || [],\n\t\t\taction.items.map( ( item ) => item?.[ key ] ).filter( Boolean ),\n\t\t\tpage,\n\t\t\tperPage\n\t\t),\n\t\tmeta: action.meta,\n\t};\n} );\n\n/**\n * Reducer tracking queries state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nconst queries = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS':\n\t\t\treturn receiveQueries( state, action );\n\t\tcase 'REMOVE_ITEMS':\n\t\t\tconst removedItems = action.itemIds.reduce( ( result, itemId ) => {\n\t\t\t\tresult[ itemId ] = true;\n\t\t\t\treturn result;\n\t\t\t}, {} );\n\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map(\n\t\t\t\t\t( [ queryGroup, contextQueries ] ) => [\n\t\t\t\t\t\tqueryGroup,\n\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\tObject.entries( contextQueries ).map(\n\t\t\t\t\t\t\t\t( [ query, queryItems ] ) => [\n\t\t\t\t\t\t\t\t\tquery,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t...queryItems,\n\t\t\t\t\t\t\t\t\t\titemIds: queryItems.itemIds.filter(\n\t\t\t\t\t\t\t\t\t\t\t( queryId ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t! removedItems[ queryId ]\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn state;\n\t}\n};\n\nexport default combineReducers( {\n\titems,\n\titemIsComplete,\n\tqueries,\n} );\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA,SAASM,oBAAoBA,CAAEC,MAAM,EAAG;EACvC,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAK,CAAEC,KAAK,EAAG;IACd,OAAO,SAAS;EACjB;EAEA,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAAEF,KAAM,CAAC;EACzC,OAAOC,UAAU,CAACE,OAAO;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,OAAO,EAAEC,WAAW,EAAEC,IAAI,EAAEC,OAAO,EAAG;EAAA,IAAAC,eAAA;EACvE,MAAMC,cAAc,GAAGH,IAAI,KAAK,C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AM,CAACC,WAAW,CACxBD,MAAM,CAACE,OAAO,CAAEQ,KAAM,CAAC,CAACQ,GAAG,CAC1B,CAAE,CAAEiB,UAAU,EAAEC,cAAc,CAAE,KAAM,CACrCD,UAAU,EACVnC,MAAM,CAACC,WAAW,CACjBD,MAAM,CAACE,OAAO,CAAEkC,cAAe,CAAC,CAAClB,GAAG,CACnC,CAAE,CAAEzC,KAAK,EAAE4D,UAAU,CAAE,KAAM,CAC5B5D,KAAK,EACL;QACC,GAAG4D,UAAU;QACbvD,OAAO,EAAEuD,UAAU,CAACvD,OAAO,CAACqB,MAAM,CAC/BmC,OAAO,IACR,CAAEJ,YAAY,CAAEI,OAAO,CACzB;MACD,CAAC,CAEH,CACD,CAAC,CAEH,CACD,CAAC;IACF;MACC,OAAO5B,KAAK;EACd;AACD,CAAC;AAAC,IAAA6B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,qBAAe,EAAE;EAC/BjC,KAAK;EACLW,cAAc;EACda;AACD,CAAE,CAAC","ignoreList":[]}
|
package/build/reducer.js
CHANGED
package/build/reducer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_es","_interopRequireDefault","require","_compose","_data","_undoManager","_utils","_queriedData","_entities","terms","state","action","type","taxonomy","users","byId","queries","reduce","newUsers","user","id","queryID","map","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","themeGlobalStyleVariations","variations","withMultiEntityRecordEdits","reducer","record","newState","forEach","kind","name","recordId","changes","edits","Object","entries","acc","key","value","from","to","entity","entityConfig","compose","ifMatchingAction","replaceAction","DEFAULT_ENTITY_KEY","combineReducers","queriedData","queriedDataReducer","_action$query$context","context","query","nextState","items","nextEdits","keys","_record$key$raw","fastDeepEqual","raw","persistedEdits","length","saving","pending","error","isAutosave","deleting","revisions","recordKey","fromEntries","filter","itemIds","some","itemId","Number","isInteger","entitiesConfig","rootEntitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","push","memo","subEntities","kindReducer","kindMemo","newData","records","exports","undoManager","createUndoManager","editsReference","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData","blockPatterns","patterns","blockPatternCategories","categories","userPatternCategories","patternCategories","navigationFallbackId","fallbackId","themeGlobalStyleRevisions","currentId","defaultTemplates","JSON","stringify","templateId","_default","default"],"sources":["@wordpress/core-data/src/reducer.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from '@wordpress/data';\nimport { createUndoManager } from '@wordpress/undo-manager';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\n\n/**\n * Reducer managing terms state. Keyed by taxonomy slug, the value is either\n * undefined (if no request has been made for given taxonomy), null (if a\n * request is in-flight for given taxonomy), or the array of terms for the\n * taxonomy.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function terms( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TERMS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.taxonomy ]: action.terms,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: action.users.map( ( user ) => user.id ),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing taxonomies.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function taxonomies( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TAXONOMIES':\n\t\t\treturn action.taxonomies;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current global styles id.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentGlobalStylesId( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme base global styles.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeBaseGlobalStyles( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.globalStyles,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst withMultiEntityRecordEdits = ( reducer ) => ( state, action ) => {\n\tif ( action.type === 'UNDO' || action.type === 'REDO' ) {\n\t\tconst { record } = action;\n\n\t\tlet newState = state;\n\t\trecord.forEach( ( { id: { kind, name, recordId }, changes } ) => {\n\t\t\tnewState = reducer( newState, {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tedits: Object.entries( changes ).reduce(\n\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\taction.type === 'UNDO' ? value.from : value.to;\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t),\n\t\t\t} );\n\t\t} );\n\t\treturn newState;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n * - Fetching\n * - Editing\n * - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\twithMultiEntityRecordEdits,\n\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t...action,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\n\t\t\t\t\t\tfor ( const record of action.items ) {\n\t\t\t\t\t\t\tconst recordId = record[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\trecord[ key ]?.raw ?? record[ key ]\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\trevisions: ( state = {}, action ) => {\n\t\t\t\t// Use the same queriedDataReducer shape for revisions.\n\t\t\t\tif ( action.type === 'RECEIVE_ITEM_REVISIONS' ) {\n\t\t\t\t\tconst recordKey = action.recordKey;\n\t\t\t\t\tdelete action.recordKey;\n\t\t\t\t\tconst newState = queriedDataReducer( state[ recordKey ], {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\ttype: 'RECEIVE_ITEMS',\n\t\t\t\t\t} );\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\t[ recordKey ]: newState,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif ( action.type === 'REMOVE_ITEMS' ) {\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tObject.entries( state ).filter(\n\t\t\t\t\t\t\t( [ id ] ) =>\n\t\t\t\t\t\t\t\t! action.itemIds.some( ( itemId ) => {\n\t\t\t\t\t\t\t\t\tif ( Number.isInteger( itemId ) ) {\n\t\t\t\t\t\t\t\t\t\treturn itemId === +id;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn itemId === id;\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = rootEntitiesConfig, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a dynamic reducer for the entities.\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = newConfig.reduce( ( acc, record ) => {\n\t\t\tconst { kind } = record;\n\t\t\tif ( ! acc[ kind ] ) {\n\t\t\t\tacc[ kind ] = [];\n\t\t\t}\n\t\t\tacc[ kind ].push( record );\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.entries( entitiesByKind ).reduce(\n\t\t\t\t( memo, [ kind, subEntities ] ) => {\n\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\tsubEntities.reduce(\n\t\t\t\t\t\t\t( kindMemo, entityConfig ) => ( {\n\t\t\t\t\t\t\t\t...kindMemo,\n\t\t\t\t\t\t\t\t[ entityConfig.name ]: entity( entityConfig ),\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tmemo[ kind ] = kindReducer;\n\t\t\t\t\treturn memo;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.records, action );\n\n\tif (\n\t\tnewData === state.records &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @type {UndoManager}\n */\nexport function undoManager( state = createUndoManager() ) {\n\treturn state;\n}\n\nexport function editsReference( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'UNDO':\n\t\tcase 'REDO':\n\t\t\treturn {};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport function userPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PATTERN_CATEGORIES':\n\t\t\treturn action.patternCategories;\n\t}\n\treturn state;\n}\n\nexport function navigationFallbackId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_NAVIGATION_FALLBACK_ID':\n\t\t\treturn action.fallbackId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles revisions.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleRevisions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.currentId ]: action.revisions,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the template lookup per query.\n *\n * @param {Record<string, string>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, string>} Updated state.\n */\nexport function defaultTemplates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_DEFAULT_TEMPLATE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ JSON.stringify( action.query ) ]: action.templateId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tterms,\n\tusers,\n\tcurrentTheme,\n\tcurrentGlobalStylesId,\n\tcurrentUser,\n\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\tthemeGlobalStyleRevisions,\n\ttaxonomies,\n\tentities,\n\teditsReference,\n\tundoManager,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n\tuserPatternCategories,\n\tnavigationFallbackId,\n\tdefaultTemplates,\n} );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,KAAKA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC3C,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,eAAe;MACnB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,QAAQ,GAAIF,MAAM,CAACF;MAC7B,CAAC;EACH;EAEA,OAAOC,KAAK;AACb;;AAEA;AACA;AAC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AAO5G,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS6G,yBAAyBA,CAAE7G,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC/D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,sCAAsC;MAC1C,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAAC6G,SAAS,GAAI7G,MAAM,CAACiE;MAC9B,CAAC;EACH;EAEA,OAAOlE,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS+G,gBAAgBA,CAAE/G,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACtD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,0BAA0B;MAC9B,OAAO;QACN,GAAGF,KAAK;QACR,CAAEgH,IAAI,CAACC,SAAS,CAAEhH,MAAM,CAACkD,KAAM,CAAC,GAAIlD,MAAM,CAACiH;MAC5C,CAAC;EACH;EAEA,OAAOlH,KAAK;AACb;AAAC,IAAAmH,QAAA,GAAA1B,OAAA,CAAA2B,OAAA,GAEc,IAAAtE,qBAAe,EAAE;EAC/B/C,KAAK;EACLK,KAAK;EACLW,YAAY;EACZG,qBAAqB;EACrBL,WAAW;EACXQ,0BAA0B;EAC1BF,qBAAqB;EACrB0F,yBAAyB;EACzB/F,UAAU;EACV+D,QAAQ;EACRe,cAAc;EACdF,WAAW;EACXG,aAAa;EACbG,eAAe;EACfE,SAAS;EACTG,aAAa;EACbE,sBAAsB;EACtBE,qBAAqB;EACrBE,oBAAoB;EACpBI;AACD,CAAE,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_es","_interopRequireDefault","require","_compose","_data","_undoManager","_utils","_queriedData","_entities","terms","state","action","type","taxonomy","users","byId","queries","reduce","newUsers","user","id","queryID","map","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","themeGlobalStyleVariations","variations","withMultiEntityRecordEdits","reducer","record","newState","forEach","kind","name","recordId","changes","edits","Object","entries","acc","key","value","from","to","entity","entityConfig","compose","ifMatchingAction","replaceAction","DEFAULT_ENTITY_KEY","combineReducers","queriedData","queriedDataReducer","_action$query$context","context","query","nextState","items","nextEdits","keys","_record$key$raw","fastDeepEqual","raw","persistedEdits","length","saving","pending","error","isAutosave","deleting","revisions","recordKey","fromEntries","filter","itemIds","some","itemId","Number","isInteger","entitiesConfig","rootEntitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","push","memo","subEntities","kindReducer","kindMemo","newData","records","exports","undoManager","createUndoManager","editsReference","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData","blockPatterns","patterns","blockPatternCategories","categories","userPatternCategories","patternCategories","navigationFallbackId","fallbackId","themeGlobalStyleRevisions","currentId","defaultTemplates","JSON","stringify","templateId","_default","default"],"sources":["@wordpress/core-data/src/reducer.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from '@wordpress/data';\nimport { createUndoManager } from '@wordpress/undo-manager';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\n\n/**\n * Reducer managing terms state. Keyed by taxonomy slug, the value is either\n * undefined (if no request has been made for given taxonomy), null (if a\n * request is in-flight for given taxonomy), or the array of terms for the\n * taxonomy.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function terms( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TERMS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.taxonomy ]: action.terms,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: action.users.map( ( user ) => user.id ),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing taxonomies.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function taxonomies( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TAXONOMIES':\n\t\t\treturn action.taxonomies;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current global styles id.\n *\n * @param {string|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentGlobalStylesId( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme base global styles.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeBaseGlobalStyles( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.globalStyles,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst withMultiEntityRecordEdits = ( reducer ) => ( state, action ) => {\n\tif ( action.type === 'UNDO' || action.type === 'REDO' ) {\n\t\tconst { record } = action;\n\n\t\tlet newState = state;\n\t\trecord.forEach( ( { id: { kind, name, recordId }, changes } ) => {\n\t\t\tnewState = reducer( newState, {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tedits: Object.entries( changes ).reduce(\n\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\taction.type === 'UNDO' ? value.from : value.to;\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t),\n\t\t\t} );\n\t\t} );\n\t\treturn newState;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n * - Fetching\n * - Editing\n * - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\twithMultiEntityRecordEdits,\n\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t...action,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\n\t\t\t\t\t\tfor ( const record of action.items ) {\n\t\t\t\t\t\t\tconst recordId = record?.[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\trecord[ key ]?.raw ?? record[ key ]\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\trevisions: ( state = {}, action ) => {\n\t\t\t\t// Use the same queriedDataReducer shape for revisions.\n\t\t\t\tif ( action.type === 'RECEIVE_ITEM_REVISIONS' ) {\n\t\t\t\t\tconst recordKey = action.recordKey;\n\t\t\t\t\tdelete action.recordKey;\n\t\t\t\t\tconst newState = queriedDataReducer( state[ recordKey ], {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\ttype: 'RECEIVE_ITEMS',\n\t\t\t\t\t} );\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\t[ recordKey ]: newState,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif ( action.type === 'REMOVE_ITEMS' ) {\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tObject.entries( state ).filter(\n\t\t\t\t\t\t\t( [ id ] ) =>\n\t\t\t\t\t\t\t\t! action.itemIds.some( ( itemId ) => {\n\t\t\t\t\t\t\t\t\tif ( Number.isInteger( itemId ) ) {\n\t\t\t\t\t\t\t\t\t\treturn itemId === +id;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn itemId === id;\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = rootEntitiesConfig, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a dynamic reducer for the entities.\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = newConfig.reduce( ( acc, record ) => {\n\t\t\tconst { kind } = record;\n\t\t\tif ( ! acc[ kind ] ) {\n\t\t\t\tacc[ kind ] = [];\n\t\t\t}\n\t\t\tacc[ kind ].push( record );\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.entries( entitiesByKind ).reduce(\n\t\t\t\t( memo, [ kind, subEntities ] ) => {\n\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\tsubEntities.reduce(\n\t\t\t\t\t\t\t( kindMemo, entityConfig ) => ( {\n\t\t\t\t\t\t\t\t...kindMemo,\n\t\t\t\t\t\t\t\t[ entityConfig.name ]: entity( entityConfig ),\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tmemo[ kind ] = kindReducer;\n\t\t\t\t\treturn memo;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.records, action );\n\n\tif (\n\t\tnewData === state.records &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @type {UndoManager}\n */\nexport function undoManager( state = createUndoManager() ) {\n\treturn state;\n}\n\nexport function editsReference( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'UNDO':\n\t\tcase 'REDO':\n\t\t\treturn {};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport function userPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PATTERN_CATEGORIES':\n\t\t\treturn action.patternCategories;\n\t}\n\treturn state;\n}\n\nexport function navigationFallbackId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_NAVIGATION_FALLBACK_ID':\n\t\t\treturn action.fallbackId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles revisions.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleRevisions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.currentId ]: action.revisions,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the template lookup per query.\n *\n * @param {Record<string, string>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, string>} Updated state.\n */\nexport function defaultTemplates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_DEFAULT_TEMPLATE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ JSON.stringify( action.query ) ]: action.templateId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tterms,\n\tusers,\n\tcurrentTheme,\n\tcurrentGlobalStylesId,\n\tcurrentUser,\n\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\tthemeGlobalStyleRevisions,\n\ttaxonomies,\n\tentities,\n\teditsReference,\n\tundoManager,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n\tuserPatternCategories,\n\tnavigationFallbackId,\n\tdefaultTemplates,\n} );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAK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SAAS;EACTG,aAAa;EACbE,sBAAsB;EACtBE,qBAAqB;EACrBE,oBAAoB;EACpBI;AACD,CAAE,CAAC","ignoreList":[]}
|
package/build/resolvers.js
CHANGED
|
@@ -82,7 +82,7 @@ const getEntityRecord = (kind, name, key = '', query) => async ({
|
|
|
82
82
|
// Entity supports configs,
|
|
83
83
|
// use the sync algorithm instead of the old fetch behavior.
|
|
84
84
|
if (window.__experimentalEnableSync && entityConfig.syncConfig && !query) {
|
|
85
|
-
if (
|
|
85
|
+
if (globalThis.IS_GUTENBERG_PLUGIN) {
|
|
86
86
|
const objectId = entityConfig.getSyncObjectId(key);
|
|
87
87
|
|
|
88
88
|
// Loads the persisted document.
|
|
@@ -233,7 +233,7 @@ const getEntityRecords = (kind, name, query = {}) => async ({
|
|
|
233
233
|
// See https://github.com/WordPress/gutenberg/pull/26575
|
|
234
234
|
if (!query?._fields && !query.context) {
|
|
235
235
|
const key = entityConfig.key || _entities.DEFAULT_ENTITY_KEY;
|
|
236
|
-
const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, record[key]]);
|
|
236
|
+
const resolutionsArgs = records.filter(record => record?.[key]).map(record => [kind, name, record[key]]);
|
|
237
237
|
dispatch({
|
|
238
238
|
type: 'START_RESOLUTIONS',
|
|
239
239
|
selectorName: 'getEntityRecord',
|
|
@@ -593,7 +593,8 @@ const getDefaultTemplateId = query => async ({
|
|
|
593
593
|
const template = await (0, _apiFetch.default)({
|
|
594
594
|
path: (0, _url.addQueryArgs)('/wp/v2/templates/lookup', query)
|
|
595
595
|
});
|
|
596
|
-
if
|
|
596
|
+
// Endpoint may return an empty object if no template is found.
|
|
597
|
+
if (template?.id) {
|
|
597
598
|
dispatch.receiveDefaultTemplateId(query, template.id);
|
|
598
599
|
}
|
|
599
600
|
};
|