resourcerer 1.1.0 → 1.1.2

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export {default as Collection} from './lib/collection';
2
- export {default as Model} from './lib/model';
3
- export {default as sync, ajax} from './lib/sync';
1
+ export {default as Collection} from './lib/collection.js';
2
+ export {default as Model} from './lib/model.js';
3
+ export {default as sync, ajax} from './lib/sync.js';
4
4
  export {default as prefetch} from './lib/prefetch.js';
5
5
  export {default as request} from './lib/request.js';
6
6
  export {default as ModelCache} from './lib/model-cache.js';
package/lib/collection.js CHANGED
@@ -1,8 +1,8 @@
1
- import {isDeepEqual, sortBy} from './utils';
1
+ import {isDeepEqual, sortBy} from './utils.js';
2
2
 
3
- import Events from './events';
4
- import Model from './model';
5
- import sync from './sync';
3
+ import Events from './events.js';
4
+ import Model from './model.js';
5
+ import sync from './sync.js';
6
6
 
7
7
  /**
8
8
  * A Collection instance represents a list of items in a RESTful sense. Each item returned at the
package/lib/config.js CHANGED
@@ -1,6 +1,6 @@
1
- import {camelize, noOp} from './utils';
1
+ import {camelize, noOp} from './utils.js';
2
2
  import React from 'react';
3
- import {setRequestPrefilter} from './sync';
3
+ import {setRequestPrefilter} from './sync.js';
4
4
 
5
5
  /**
6
6
  * This module contains all the required setup for implementing withResources
@@ -1,6 +1,6 @@
1
- import {omit} from './utils';
1
+ import {omit} from './utils.js';
2
2
  import React from 'react';
3
- import {ResourcesConfig} from './config';
3
+ import {ResourcesConfig} from './config.js';
4
4
 
5
5
  /**
6
6
  * As of React 16, Error Boundaries (components with a componentDidCatch method)
@@ -1,4 +1,4 @@
1
- import {ResourcesConfig} from './config';
1
+ import {ResourcesConfig} from './config.js';
2
2
 
3
3
  // this is where all of our cached resources are stored
4
4
  const modelCache = new Map();
package/lib/model.js CHANGED
@@ -1,7 +1,7 @@
1
- import {isDeepEqual, result, uniqueId, urlError} from './utils';
1
+ import {isDeepEqual, result, uniqueId, urlError} from './utils.js';
2
2
 
3
- import Events from './events';
4
- import sync from './sync';
3
+ import Events from './events.js';
4
+ import sync from './sync.js';
5
5
 
6
6
  const RESERVED_OPTION_KEYS = [
7
7
  'Model',
package/lib/prefetch.js CHANGED
@@ -1,8 +1,8 @@
1
- import {ModelMap, ResourceKeys} from './config';
2
- import {noOp, once} from './utils';
1
+ import {ModelMap, ResourceKeys} from './config.js';
2
+ import {noOp, once} from './utils.js';
3
3
 
4
- import {getCacheKey} from './resourcerer';
5
- import request from './request';
4
+ import {getCacheKey} from './resourcerer.js';
5
+ import request from './request.js';
6
6
 
7
7
  // prevents api request bursts based on quick swipes
8
8
  const PREFETCH_TIMEOUT = 50;
package/lib/request.js CHANGED
@@ -1,5 +1,5 @@
1
- import Collection from './collection';
2
- import ModelCache from './model-cache';
1
+ import Collection from './collection.js';
2
+ import ModelCache from './model-cache.js';
3
3
 
4
4
  const loadingCache = {};
5
5
 
@@ -1,16 +1,16 @@
1
- import {hasErrored, hasLoaded, isLoading} from './utils';
2
- import {ModelMap, ResourceKeys, ResourcesConfig, UnfetchedResources} from './config';
1
+ import {hasErrored, hasLoaded, isLoading} from './utils.js';
2
+ import {ModelMap, ResourceKeys, ResourcesConfig, UnfetchedResources} from './config.js';
3
3
  /* eslint-disable no-unused-vars */
4
4
  import React, {useEffect, useReducer, useRef, useState} from 'react';
5
5
  /* eslint-enable no-unused-vars */
6
6
 
7
- import Collection from './collection';
8
- import ErrorBoundary from './error-boundary';
9
- import {LoadingStates} from './constants';
10
- import Model from './model';
11
- import ModelCache from './model-cache';
7
+ import Collection from './collection.js';
8
+ import ErrorBoundary from './error-boundary.js';
9
+ import {LoadingStates} from './constants.js';
10
+ import Model from './model.js';
11
+ import ModelCache from './model-cache.js';
12
12
  import ReactDOM from 'react-dom';
13
- import request from './request';
13
+ import request from './request.js';
14
14
 
15
15
  const SPREAD_PROVIDES_CHAR = '_';
16
16
 
@@ -340,9 +340,12 @@ export const withResources = (getResources) => (Component) =>
340
340
  var resources = useResources(getResources, props);
341
341
 
342
342
  return (
343
- <ErrorBoundary>
344
- <Component {...props} {...resources} />
345
- </ErrorBoundary>
343
+ React.createElement(ErrorBoundary, {
344
+ children: React.createElement(Component, {
345
+ ...props,
346
+ ...resources
347
+ })
348
+ })
346
349
  );
347
350
  };
348
351
 
package/lib/sync.js CHANGED
@@ -1,6 +1,6 @@
1
- import {result, urlError} from './utils';
1
+ import {result, urlError} from './utils.js';
2
2
 
3
- import {ResourcesConfig} from './config';
3
+ import {ResourcesConfig} from './config.js';
4
4
 
5
5
  const MIME_TYPE_JSON = 'application/json';
6
6
 
package/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import {LoadingStates} from './constants';
1
+ import {LoadingStates} from './constants.js';
2
2
 
3
3
  /**
4
4
  * Whether or not any loading state has errored. If a state is passed in,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resourcerer",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "repository": "github.com/noahgrant/resourcerer",
5
5
  "description": "Declarative data-fetching and caching framework for React",
6
6
  "keywords": [
@@ -16,6 +16,7 @@
16
16
  "docs/*.md"
17
17
  ],
18
18
  "main": "index.js",
19
+ "type": "module",
19
20
  "scripts": {
20
21
  "checks": "npm test && npm run lint",
21
22
  "lint": "eslint lib/*.js* test/*.js*",
@@ -36,7 +37,7 @@
36
37
  ],
37
38
  "testEnvironment": "jsdom"
38
39
  },
39
- "module": "index.js",
40
+ "exports": "./index.js",
40
41
  "devDependencies": {
41
42
  "@babel/cli": "^7.10.5",
42
43
  "@babel/core": "^7.10.5",