@wordpress/core-data 4.0.1-next.253d9b6e21.0 → 4.0.3
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/README.md +11 -3
- package/build/actions.js +124 -117
- package/build/actions.js.map +1 -1
- package/build/batch/default-processor.js +58 -27
- package/build/batch/default-processor.js.map +1 -1
- package/build/entities.js +24 -18
- package/build/entities.js.map +1 -1
- package/build/index.js +9 -17
- package/build/index.js.map +1 -1
- package/build/locks/actions.js +17 -77
- package/build/locks/actions.js.map +1 -1
- package/build/locks/engine.js +77 -0
- package/build/locks/engine.js.map +1 -0
- package/build/locks/reducer.js +1 -5
- package/build/locks/reducer.js.map +1 -1
- package/build/locks/selectors.js +6 -6
- package/build/locks/selectors.js.map +1 -1
- package/build/queried-data/get-query-parts.js +9 -4
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/queried-data/selectors.js +3 -9
- package/build/queried-data/selectors.js.map +1 -1
- package/build/reducer.js +1 -4
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +120 -91
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +31 -11
- package/build/selectors.js.map +1 -1
- package/build/utils/if-not-resolved.js +6 -21
- package/build/utils/if-not-resolved.js.map +1 -1
- package/build/utils/index.js +8 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/is-raw-attribute.js +19 -0
- package/build/utils/is-raw-attribute.js.map +1 -0
- package/build-module/actions.js +106 -107
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/default-processor.js +57 -27
- package/build-module/batch/default-processor.js.map +1 -1
- package/build-module/entities.js +19 -14
- package/build-module/entities.js.map +1 -1
- package/build-module/index.js +10 -14
- package/build-module/index.js.map +1 -1
- package/build-module/locks/actions.js +14 -68
- package/build-module/locks/actions.js.map +1 -1
- package/build-module/locks/engine.js +66 -0
- package/build-module/locks/engine.js.map +1 -0
- package/build-module/locks/reducer.js +1 -2
- package/build-module/locks/reducer.js.map +1 -1
- package/build-module/locks/selectors.js +4 -4
- package/build-module/locks/selectors.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +9 -4
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/queried-data/selectors.js +3 -9
- package/build-module/queried-data/selectors.js.map +1 -1
- package/build-module/reducer.js +1 -3
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +94 -74
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +30 -10
- package/build-module/selectors.js.map +1 -1
- package/build-module/utils/if-not-resolved.js +6 -19
- package/build-module/utils/if-not-resolved.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/is-raw-attribute.js +12 -0
- package/build-module/utils/is-raw-attribute.js.map +1 -0
- package/package.json +11 -12
- package/src/actions.js +112 -189
- package/src/batch/default-processor.js +57 -26
- package/src/batch/test/default-processor.js +53 -26
- package/src/entities.js +15 -16
- package/src/index.js +7 -10
- package/src/locks/actions.js +10 -61
- package/src/locks/engine.js +43 -0
- package/src/locks/reducer.js +1 -3
- package/src/locks/selectors.js +4 -4
- package/src/locks/test/engine.js +135 -0
- package/src/locks/test/reducer.js +1 -1
- package/src/locks/test/selectors.js +105 -124
- package/src/queried-data/get-query-parts.js +11 -6
- package/src/queried-data/selectors.js +2 -9
- package/src/queried-data/test/get-query-parts.js +1 -1
- package/src/queried-data/test/selectors.js +1 -0
- package/src/reducer.js +0 -2
- package/src/resolvers.js +86 -106
- package/src/selectors.js +113 -40
- package/src/test/actions.js +243 -172
- package/src/test/entities.js +40 -26
- package/src/test/resolvers.js +270 -223
- package/src/test/selectors.js +71 -0
- package/src/utils/if-not-resolved.js +8 -26
- package/src/utils/index.js +1 -0
- package/src/utils/is-raw-attribute.js +11 -0
- package/src/utils/test/if-not-resolved.js +28 -27
- package/src/utils/test/is-raw-attribute.js +22 -0
- package/build/controls.js +0 -44
- package/build/controls.js.map +0 -1
- package/build/locks/index.js +0 -47
- package/build/locks/index.js.map +0 -1
- package/build-module/controls.js +0 -31
- package/build-module/controls.js.map +0 -1
- package/build-module/locks/index.js +0 -4
- package/build-module/locks/index.js.map +0 -1
- package/src/controls.js +0 -31
- package/src/locks/index.js +0 -3
- package/src/locks/test/actions.js +0 -307
- package/src/test/integration.js +0 -264
package/src/test/selectors.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
__experimentalGetEntityRecordNoResolver,
|
|
12
12
|
hasEntityRecords,
|
|
13
13
|
getEntityRecords,
|
|
14
|
+
getRawEntityRecord,
|
|
14
15
|
__experimentalGetDirtyEntityRecords,
|
|
15
16
|
__experimentalGetEntitiesBeingSaved,
|
|
16
17
|
getEntityRecordNonTransientEdits,
|
|
@@ -204,6 +205,76 @@ describe( 'hasEntityRecords', () => {
|
|
|
204
205
|
} );
|
|
205
206
|
} );
|
|
206
207
|
|
|
208
|
+
describe( 'getRawEntityRecord', () => {
|
|
209
|
+
const data = {
|
|
210
|
+
someKind: {
|
|
211
|
+
someName: {
|
|
212
|
+
queriedData: {
|
|
213
|
+
items: {
|
|
214
|
+
default: {
|
|
215
|
+
post: {
|
|
216
|
+
title: {
|
|
217
|
+
raw: { html: '<h1>post</h1>' },
|
|
218
|
+
rendered:
|
|
219
|
+
'<div id="post"><h1>rendered post</h1></div>',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
itemIsComplete: {
|
|
225
|
+
default: {
|
|
226
|
+
post: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
queries: {},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
it( 'should preserve the structure of `raw` field by default', () => {
|
|
235
|
+
const state = deepFreeze( {
|
|
236
|
+
entities: {
|
|
237
|
+
config: [
|
|
238
|
+
{
|
|
239
|
+
kind: 'someKind',
|
|
240
|
+
name: 'someName',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
data: { ...data },
|
|
244
|
+
},
|
|
245
|
+
} );
|
|
246
|
+
expect(
|
|
247
|
+
getRawEntityRecord( state, 'someKind', 'someName', 'post' )
|
|
248
|
+
).toEqual( {
|
|
249
|
+
title: {
|
|
250
|
+
raw: { html: '<h1>post</h1>' },
|
|
251
|
+
rendered: '<div id="post"><h1>rendered post</h1></div>',
|
|
252
|
+
},
|
|
253
|
+
} );
|
|
254
|
+
} );
|
|
255
|
+
it( 'should flatten the structure of `raw` field for entities configured with rawAttributes', () => {
|
|
256
|
+
const state = deepFreeze( {
|
|
257
|
+
entities: {
|
|
258
|
+
config: [
|
|
259
|
+
{
|
|
260
|
+
kind: 'someKind',
|
|
261
|
+
name: 'someName',
|
|
262
|
+
rawAttributes: [ 'title' ],
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
data: { ...data },
|
|
266
|
+
},
|
|
267
|
+
} );
|
|
268
|
+
expect(
|
|
269
|
+
getRawEntityRecord( state, 'someKind', 'someName', 'post' )
|
|
270
|
+
).toEqual( {
|
|
271
|
+
title: {
|
|
272
|
+
html: '<h1>post</h1>',
|
|
273
|
+
},
|
|
274
|
+
} );
|
|
275
|
+
} );
|
|
276
|
+
} );
|
|
277
|
+
|
|
207
278
|
describe( 'getEntityRecords', () => {
|
|
208
279
|
it( 'should return null by default', () => {
|
|
209
280
|
const state = deepFreeze( {
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { controls } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { STORE_NAME } from '../name';
|
|
10
|
-
|
|
11
1
|
/**
|
|
12
2
|
* Higher-order function which invokes the given resolver only if it has not
|
|
13
3
|
* already been resolved with the arguments passed to the enhanced function.
|
|
@@ -20,21 +10,13 @@ import { STORE_NAME } from '../name';
|
|
|
20
10
|
*
|
|
21
11
|
* @return {Function} Enhanced resolver.
|
|
22
12
|
*/
|
|
23
|
-
const ifNotResolved = ( resolver, selectorName ) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
selectorName,
|
|
32
|
-
args
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if ( ! hasStartedResolution ) {
|
|
36
|
-
yield* resolver( ...args );
|
|
37
|
-
}
|
|
38
|
-
};
|
|
13
|
+
const ifNotResolved = ( resolver, selectorName ) => ( ...args ) => async ( {
|
|
14
|
+
select,
|
|
15
|
+
dispatch,
|
|
16
|
+
} ) => {
|
|
17
|
+
if ( ! select.hasStartedResolution( selectorName, args ) ) {
|
|
18
|
+
await dispatch( resolver( ...args ) );
|
|
19
|
+
}
|
|
20
|
+
};
|
|
39
21
|
|
|
40
22
|
export default ifNotResolved;
|
package/src/utils/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { default as ifNotResolved } from './if-not-resolved';
|
|
|
5
5
|
export { default as onSubKey } from './on-sub-key';
|
|
6
6
|
export { default as replaceAction } from './replace-action';
|
|
7
7
|
export { default as withWeakMapCache } from './with-weak-map-cache';
|
|
8
|
+
export { default as isRawAttribute } from './is-raw-attribute';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the attribute is a "raw" attribute or not.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} entity Entity data.
|
|
5
|
+
* @param {string} attribute Attribute name.
|
|
6
|
+
*
|
|
7
|
+
* @return {boolean} Is the attribute raw
|
|
8
|
+
*/
|
|
9
|
+
export default function isRawAttribute( entity, attribute ) {
|
|
10
|
+
return ( entity.rawAttributes || [] ).includes( attribute );
|
|
11
|
+
}
|
|
@@ -27,49 +27,50 @@ describe( 'ifNotResolved', () => {
|
|
|
27
27
|
expect( resolver ).toBeInstanceOf( Function );
|
|
28
28
|
} );
|
|
29
29
|
|
|
30
|
-
it( 'triggers original resolver if not already resolved', () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
selectorName === 'hasStartedResolution' ? false : undefined,
|
|
34
|
-
} ) );
|
|
30
|
+
it( 'triggers original resolver if not already resolved', async () => {
|
|
31
|
+
const select = { hasStartedResolution: () => false };
|
|
32
|
+
const dispatch = () => {};
|
|
35
33
|
|
|
36
34
|
const originalResolver = jest
|
|
37
35
|
.fn()
|
|
38
|
-
.mockImplementation( function
|
|
36
|
+
.mockImplementation( async function () {} );
|
|
39
37
|
|
|
40
38
|
const resolver = ifNotResolved( originalResolver, 'originalResolver' );
|
|
41
|
-
|
|
42
|
-
const runResolver = resolver();
|
|
43
|
-
|
|
44
|
-
let next, nextValue;
|
|
45
|
-
do {
|
|
46
|
-
next = runResolver.next( nextValue );
|
|
47
|
-
nextValue = next.value?._nextValue;
|
|
48
|
-
} while ( ! next.done );
|
|
39
|
+
await resolver()( { select, dispatch } );
|
|
49
40
|
|
|
50
41
|
expect( originalResolver ).toHaveBeenCalledTimes( 1 );
|
|
51
42
|
} );
|
|
52
43
|
|
|
53
|
-
it( 'does not trigger original resolver if already resolved', () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
selectorName === 'hasStartedResolution' ? true : undefined,
|
|
57
|
-
} ) );
|
|
44
|
+
it( 'does not trigger original resolver if already resolved', async () => {
|
|
45
|
+
const select = { hasStartedResolution: () => true };
|
|
46
|
+
const dispatch = () => {};
|
|
58
47
|
|
|
59
48
|
const originalResolver = jest
|
|
60
49
|
.fn()
|
|
61
|
-
.mockImplementation( function
|
|
50
|
+
.mockImplementation( async function () {} );
|
|
62
51
|
|
|
63
52
|
const resolver = ifNotResolved( originalResolver, 'originalResolver' );
|
|
53
|
+
await resolver()( { select, dispatch } );
|
|
54
|
+
|
|
55
|
+
expect( originalResolver ).toHaveBeenCalledTimes( 0 );
|
|
56
|
+
} );
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
it( 'returns a promise when the resolver was not already resolved', async () => {
|
|
59
|
+
const select = { hasStartedResolution: () => false };
|
|
60
|
+
let thunkRetval;
|
|
61
|
+
const dispatch = jest.fn( ( thunk ) => {
|
|
62
|
+
thunkRetval = thunk();
|
|
63
|
+
return thunkRetval;
|
|
64
|
+
} );
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
nextValue = next.value?._nextValue;
|
|
71
|
-
} while ( ! next.done );
|
|
66
|
+
const originalResolver = jest.fn( () => () =>
|
|
67
|
+
Promise.resolve( 'success!' )
|
|
68
|
+
);
|
|
72
69
|
|
|
73
|
-
|
|
70
|
+
const resolver = ifNotResolved( originalResolver, 'originalResolver' );
|
|
71
|
+
const result = resolver()( { select, dispatch } );
|
|
72
|
+
|
|
73
|
+
await expect( result ).resolves.toBe( undefined );
|
|
74
|
+
await expect( thunkRetval ).resolves.toBe( 'success!' );
|
|
74
75
|
} );
|
|
75
76
|
} );
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { isRawAttribute } from '../';
|
|
5
|
+
|
|
6
|
+
describe( 'isRawAttribute', () => {
|
|
7
|
+
it( 'should correctly assess that the attribute is not raw', () => {
|
|
8
|
+
const entity = {
|
|
9
|
+
kind: 'someKind',
|
|
10
|
+
name: 'someName',
|
|
11
|
+
};
|
|
12
|
+
expect( isRawAttribute( entity, 'title' ) ).toBe( false );
|
|
13
|
+
} );
|
|
14
|
+
it( 'should correctly assess that the attribute is raw', () => {
|
|
15
|
+
const entity = {
|
|
16
|
+
kind: 'someKind',
|
|
17
|
+
name: 'someName',
|
|
18
|
+
rawAttributes: [ 'title' ],
|
|
19
|
+
};
|
|
20
|
+
expect( isRawAttribute( entity, 'title' ) ).toBe( true );
|
|
21
|
+
} );
|
|
22
|
+
} );
|
package/build/controls.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.regularFetch = regularFetch;
|
|
7
|
-
exports.getDispatch = getDispatch;
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
function regularFetch(url) {
|
|
16
|
-
return {
|
|
17
|
-
type: 'REGULAR_FETCH',
|
|
18
|
-
url
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getDispatch() {
|
|
23
|
-
return {
|
|
24
|
-
type: 'GET_DISPATCH'
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const controls = {
|
|
29
|
-
async REGULAR_FETCH({
|
|
30
|
-
url
|
|
31
|
-
}) {
|
|
32
|
-
const {
|
|
33
|
-
data
|
|
34
|
-
} = await window.fetch(url).then(res => res.json());
|
|
35
|
-
return data;
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
GET_DISPATCH: (0, _data.createRegistryControl)(({
|
|
39
|
-
dispatch
|
|
40
|
-
}) => () => dispatch)
|
|
41
|
-
};
|
|
42
|
-
var _default = controls;
|
|
43
|
-
exports.default = _default;
|
|
44
|
-
//# sourceMappingURL=controls.js.map
|
package/build/controls.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/controls.js"],"names":["regularFetch","url","type","getDispatch","controls","REGULAR_FETCH","data","window","fetch","then","res","json","GET_DISPATCH","dispatch"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,SAASA,YAAT,CAAuBC,GAAvB,EAA6B;AACnC,SAAO;AACNC,IAAAA,IAAI,EAAE,eADA;AAEND,IAAAA;AAFM,GAAP;AAIA;;AAEM,SAASE,WAAT,GAAuB;AAC7B,SAAO;AACND,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;;AAED,MAAME,QAAQ,GAAG;AAChB,QAAMC,aAAN,CAAqB;AAAEJ,IAAAA;AAAF,GAArB,EAA+B;AAC9B,UAAM;AAAEK,MAAAA;AAAF,QAAW,MAAMC,MAAM,CAC3BC,KADqB,CACdP,GADc,EAErBQ,IAFqB,CAEbC,GAAF,IAAWA,GAAG,CAACC,IAAJ,EAFI,CAAvB;AAIA,WAAOL,IAAP;AACA,GAPe;;AAShBM,EAAAA,YAAY,EAAE,iCAAuB,CAAE;AAAEC,IAAAA;AAAF,GAAF,KAAoB,MAAMA,QAAjD;AATE,CAAjB;eAYeT,Q","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistryControl } from '@wordpress/data';\n\nexport function regularFetch( url ) {\n\treturn {\n\t\ttype: 'REGULAR_FETCH',\n\t\turl,\n\t};\n}\n\nexport function getDispatch() {\n\treturn {\n\t\ttype: 'GET_DISPATCH',\n\t};\n}\n\nconst controls = {\n\tasync REGULAR_FETCH( { url } ) {\n\t\tconst { data } = await window\n\t\t\t.fetch( url )\n\t\t\t.then( ( res ) => res.json() );\n\n\t\treturn data;\n\t},\n\n\tGET_DISPATCH: createRegistryControl( ( { dispatch } ) => () => dispatch ),\n};\n\nexport default controls;\n"]}
|
package/build/locks/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
var _exportNames = {
|
|
9
|
-
reducer: true
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "reducer", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _reducer.default;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
var _actions = require("./actions");
|
|
19
|
-
|
|
20
|
-
Object.keys(_actions).forEach(function (key) {
|
|
21
|
-
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
-
if (key in exports && exports[key] === _actions[key]) return;
|
|
24
|
-
Object.defineProperty(exports, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _actions[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
var _selectors = require("./selectors");
|
|
33
|
-
|
|
34
|
-
Object.keys(_selectors).forEach(function (key) {
|
|
35
|
-
if (key === "default" || key === "__esModule") return;
|
|
36
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
37
|
-
if (key in exports && exports[key] === _selectors[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _selectors[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
47
|
-
//# sourceMappingURL=index.js.map
|
package/build/locks/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/locks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA","sourcesContent":["export * from './actions';\nexport * from './selectors';\nexport { default as reducer } from './reducer';\n"]}
|
package/build-module/controls.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createRegistryControl } from '@wordpress/data';
|
|
5
|
-
export function regularFetch(url) {
|
|
6
|
-
return {
|
|
7
|
-
type: 'REGULAR_FETCH',
|
|
8
|
-
url
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function getDispatch() {
|
|
12
|
-
return {
|
|
13
|
-
type: 'GET_DISPATCH'
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const controls = {
|
|
17
|
-
async REGULAR_FETCH({
|
|
18
|
-
url
|
|
19
|
-
}) {
|
|
20
|
-
const {
|
|
21
|
-
data
|
|
22
|
-
} = await window.fetch(url).then(res => res.json());
|
|
23
|
-
return data;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
GET_DISPATCH: createRegistryControl(({
|
|
27
|
-
dispatch
|
|
28
|
-
}) => () => dispatch)
|
|
29
|
-
};
|
|
30
|
-
export default controls;
|
|
31
|
-
//# sourceMappingURL=controls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/controls.js"],"names":["createRegistryControl","regularFetch","url","type","getDispatch","controls","REGULAR_FETCH","data","window","fetch","then","res","json","GET_DISPATCH","dispatch"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,qBAAT,QAAsC,iBAAtC;AAEA,OAAO,SAASC,YAAT,CAAuBC,GAAvB,EAA6B;AACnC,SAAO;AACNC,IAAAA,IAAI,EAAE,eADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED,OAAO,SAASE,WAAT,GAAuB;AAC7B,SAAO;AACND,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED,MAAME,QAAQ,GAAG;AAChB,QAAMC,aAAN,CAAqB;AAAEJ,IAAAA;AAAF,GAArB,EAA+B;AAC9B,UAAM;AAAEK,MAAAA;AAAF,QAAW,MAAMC,MAAM,CAC3BC,KADqB,CACdP,GADc,EAErBQ,IAFqB,CAEbC,GAAF,IAAWA,GAAG,CAACC,IAAJ,EAFI,CAAvB;AAIA,WAAOL,IAAP;AACA,GAPe;;AAShBM,EAAAA,YAAY,EAAEb,qBAAqB,CAAE,CAAE;AAAEc,IAAAA;AAAF,GAAF,KAAoB,MAAMA,QAA5B;AATnB,CAAjB;AAYA,eAAeT,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistryControl } from '@wordpress/data';\n\nexport function regularFetch( url ) {\n\treturn {\n\t\ttype: 'REGULAR_FETCH',\n\t\turl,\n\t};\n}\n\nexport function getDispatch() {\n\treturn {\n\t\ttype: 'GET_DISPATCH',\n\t};\n}\n\nconst controls = {\n\tasync REGULAR_FETCH( { url } ) {\n\t\tconst { data } = await window\n\t\t\t.fetch( url )\n\t\t\t.then( ( res ) => res.json() );\n\n\t\treturn data;\n\t},\n\n\tGET_DISPATCH: createRegistryControl( ( { dispatch } ) => () => dispatch ),\n};\n\nexport default controls;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/locks/index.js"],"names":["default","reducer"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,aAAd;AACA,SAASA,OAAO,IAAIC,OAApB,QAAmC,WAAnC","sourcesContent":["export * from './actions';\nexport * from './selectors';\nexport { default as reducer } from './reducer';\n"]}
|
package/src/controls.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createRegistryControl } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
export function regularFetch( url ) {
|
|
7
|
-
return {
|
|
8
|
-
type: 'REGULAR_FETCH',
|
|
9
|
-
url,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function getDispatch() {
|
|
14
|
-
return {
|
|
15
|
-
type: 'GET_DISPATCH',
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const controls = {
|
|
20
|
-
async REGULAR_FETCH( { url } ) {
|
|
21
|
-
const { data } = await window
|
|
22
|
-
.fetch( url )
|
|
23
|
-
.then( ( res ) => res.json() );
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
GET_DISPATCH: createRegistryControl( ( { dispatch } ) => () => dispatch ),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default controls;
|
package/src/locks/index.js
DELETED