pocketbase-react 0.1.2 → 0.1.5
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 +23 -4
- package/README.md +2 -5
- package/dist/pocketbase-react.js +6201 -489
- package/dist/pocketbase-react.min.js +28 -1
- package/es/context/Pocketbase.d.ts +1 -1
- package/es/context/Pocketbase.js +1 -2
- package/es/context/client.d.ts +1 -1
- package/es/context/content.js +0 -4
- package/es/hooks/useAppContent.js +0 -1
- package/es/hooks/useClientContext.d.ts +1 -1
- package/es/hooks/useClientContext.js +0 -2
- package/es/store/actions/records.js +0 -7
- package/es/store/reducers/records.js +0 -15
- package/es/store/store.d.ts +1 -1
- package/es/store/store.js +0 -2
- package/lib/context/Pocketbase.js +1 -15
- package/lib/context/client.js +0 -6
- package/lib/context/content.js +0 -13
- package/lib/context/index.js +0 -6
- package/lib/hooks/index.js +0 -4
- package/lib/hooks/useAppContent.js +0 -7
- package/lib/hooks/useClientContext.js +0 -4
- package/lib/index.js +0 -8
- package/lib/interfaces/index.js +0 -2
- package/lib/store/actions/index.js +0 -4
- package/lib/store/actions/records.js +0 -15
- package/lib/store/index.js +0 -8
- package/lib/store/reducers/index.js +0 -3
- package/lib/store/reducers/records.js +0 -21
- package/lib/store/store.js +0 -10
- package/package.json +9 -53
- package/src/context/Pocketbase.tsx +1 -2
- package/src/context/client.tsx +1 -1
- package/src/store/store.tsx +0 -2
|
@@ -2,20 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.useAppContent = useAppContent;
|
|
5
|
-
|
|
6
5
|
var _react = require("react");
|
|
7
|
-
|
|
8
6
|
var store = _interopRequireWildcard(require("../store"));
|
|
9
|
-
|
|
10
7
|
var _context = require("../context");
|
|
11
|
-
|
|
12
8
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
10
|
function useAppContent(collectionName, initialFetch = false) {
|
|
17
11
|
var _store$useAppSelector;
|
|
18
|
-
|
|
19
12
|
const records = (_store$useAppSelector = store.useAppSelector(state => state.reducer.records[collectionName])) != null ? _store$useAppSelector : [];
|
|
20
13
|
const context = (0, _react.useContext)(_context.ContentContext);
|
|
21
14
|
(0, _react.useEffect)(() => {
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.useClientContext = void 0;
|
|
5
|
-
|
|
6
5
|
var _react = require("react");
|
|
7
|
-
|
|
8
6
|
var _context = require("../context");
|
|
9
|
-
|
|
10
7
|
const useClientContext = () => {
|
|
11
8
|
const context = (0, _react.useContext)(_context.ClientContext);
|
|
12
9
|
return context;
|
|
13
10
|
};
|
|
14
|
-
|
|
15
11
|
exports.useClientContext = useClientContext;
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
|
|
5
4
|
var _hooks = require("./hooks");
|
|
6
|
-
|
|
7
5
|
Object.keys(_hooks).forEach(function (key) {
|
|
8
6
|
if (key === "default" || key === "__esModule") return;
|
|
9
7
|
if (key in exports && exports[key] === _hooks[key]) return;
|
|
@@ -14,9 +12,7 @@ Object.keys(_hooks).forEach(function (key) {
|
|
|
14
12
|
}
|
|
15
13
|
});
|
|
16
14
|
});
|
|
17
|
-
|
|
18
15
|
var _interfaces = require("./interfaces");
|
|
19
|
-
|
|
20
16
|
Object.keys(_interfaces).forEach(function (key) {
|
|
21
17
|
if (key === "default" || key === "__esModule") return;
|
|
22
18
|
if (key in exports && exports[key] === _interfaces[key]) return;
|
|
@@ -27,9 +23,7 @@ Object.keys(_interfaces).forEach(function (key) {
|
|
|
27
23
|
}
|
|
28
24
|
});
|
|
29
25
|
});
|
|
30
|
-
|
|
31
26
|
var _context = require("./context");
|
|
32
|
-
|
|
33
27
|
Object.keys(_context).forEach(function (key) {
|
|
34
28
|
if (key === "default" || key === "__esModule") return;
|
|
35
29
|
if (key in exports && exports[key] === _context[key]) return;
|
|
@@ -40,9 +34,7 @@ Object.keys(_context).forEach(function (key) {
|
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
36
|
});
|
|
43
|
-
|
|
44
37
|
var _store = require("./store");
|
|
45
|
-
|
|
46
38
|
Object.keys(_store).forEach(function (key) {
|
|
47
39
|
if (key === "default" || key === "__esModule") return;
|
|
48
40
|
if (key in exports && exports[key] === _store[key]) return;
|
package/lib/interfaces/index.js
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.recordsAction = void 0;
|
|
5
|
-
|
|
6
5
|
var recordsAction = _interopRequireWildcard(require("./records"));
|
|
7
|
-
|
|
8
6
|
exports.recordsAction = recordsAction;
|
|
9
|
-
|
|
10
7
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
|
|
12
8
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -2,57 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.updateRecord = exports.setRecords = exports.deleteRecords = exports.deleteRecord = exports.addRecords = exports.addRecord = void 0;
|
|
5
|
-
|
|
6
5
|
var ReduxType = _interopRequireWildcard(require("../types"));
|
|
7
|
-
|
|
8
6
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
|
|
10
7
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
-
|
|
12
8
|
const setRecords = (key, payload) => ({
|
|
13
9
|
type: ReduxType.SET_RECORDS,
|
|
14
10
|
key,
|
|
15
11
|
payload
|
|
16
12
|
});
|
|
17
|
-
|
|
18
13
|
exports.setRecords = setRecords;
|
|
19
|
-
|
|
20
14
|
const addRecord = (key, payload) => ({
|
|
21
15
|
type: ReduxType.ADD_RECORD,
|
|
22
16
|
key,
|
|
23
17
|
payload
|
|
24
18
|
});
|
|
25
|
-
|
|
26
19
|
exports.addRecord = addRecord;
|
|
27
|
-
|
|
28
20
|
const addRecords = (key, payload) => ({
|
|
29
21
|
type: ReduxType.ADD_RECORDS,
|
|
30
22
|
key,
|
|
31
23
|
payload
|
|
32
24
|
});
|
|
33
|
-
|
|
34
25
|
exports.addRecords = addRecords;
|
|
35
|
-
|
|
36
26
|
const deleteRecord = (key, payload) => ({
|
|
37
27
|
type: ReduxType.DELETE_RECORD,
|
|
38
28
|
key,
|
|
39
29
|
payload
|
|
40
30
|
});
|
|
41
|
-
|
|
42
31
|
exports.deleteRecord = deleteRecord;
|
|
43
|
-
|
|
44
32
|
const deleteRecords = (key, payload) => ({
|
|
45
33
|
type: ReduxType.DELETE_RECORDS,
|
|
46
34
|
key,
|
|
47
35
|
payload
|
|
48
36
|
});
|
|
49
|
-
|
|
50
37
|
exports.deleteRecords = deleteRecords;
|
|
51
|
-
|
|
52
38
|
const updateRecord = (key, payload) => ({
|
|
53
39
|
type: ReduxType.UPDATE_RECORD,
|
|
54
40
|
key,
|
|
55
41
|
payload
|
|
56
42
|
});
|
|
57
|
-
|
|
58
43
|
exports.updateRecord = updateRecord;
|
package/lib/store/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
|
|
5
4
|
var _actions = require("./actions");
|
|
6
|
-
|
|
7
5
|
Object.keys(_actions).forEach(function (key) {
|
|
8
6
|
if (key === "default" || key === "__esModule") return;
|
|
9
7
|
if (key in exports && exports[key] === _actions[key]) return;
|
|
@@ -14,9 +12,7 @@ Object.keys(_actions).forEach(function (key) {
|
|
|
14
12
|
}
|
|
15
13
|
});
|
|
16
14
|
});
|
|
17
|
-
|
|
18
15
|
var _reducers = require("./reducers");
|
|
19
|
-
|
|
20
16
|
Object.keys(_reducers).forEach(function (key) {
|
|
21
17
|
if (key === "default" || key === "__esModule") return;
|
|
22
18
|
if (key in exports && exports[key] === _reducers[key]) return;
|
|
@@ -27,9 +23,7 @@ Object.keys(_reducers).forEach(function (key) {
|
|
|
27
23
|
}
|
|
28
24
|
});
|
|
29
25
|
});
|
|
30
|
-
|
|
31
26
|
var _types = require("./types");
|
|
32
|
-
|
|
33
27
|
Object.keys(_types).forEach(function (key) {
|
|
34
28
|
if (key === "default" || key === "__esModule") return;
|
|
35
29
|
if (key in exports && exports[key] === _types[key]) return;
|
|
@@ -40,9 +34,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
36
|
});
|
|
43
|
-
|
|
44
37
|
var _store = require("./store");
|
|
45
|
-
|
|
46
38
|
Object.keys(_store).forEach(function (key) {
|
|
47
39
|
if (key === "default" || key === "__esModule") return;
|
|
48
40
|
if (key in exports && exports[key] === _store[key]) return;
|
|
@@ -1,49 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
exports.__esModule = true;
|
|
6
5
|
exports.records = void 0;
|
|
7
|
-
|
|
8
6
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
|
|
10
7
|
var ReduxType = _interopRequireWildcard(require("../types"));
|
|
11
|
-
|
|
12
8
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
10
|
function appendRecord(record, records) {
|
|
17
11
|
return [...records, record];
|
|
18
12
|
}
|
|
19
|
-
|
|
20
13
|
function appendRecords(recordsToAppend, records) {
|
|
21
14
|
return [...records, ...recordsToAppend];
|
|
22
15
|
}
|
|
23
|
-
|
|
24
16
|
function updateRecord(record, records) {
|
|
25
17
|
return records.map(r => {
|
|
26
18
|
if (r.id === record.id) {
|
|
27
19
|
return record;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
return r;
|
|
31
22
|
});
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function deleteRecord(record, records) {
|
|
35
25
|
return records.filter(r => r.id !== record.id);
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
function deleteRecords(recordsToDelete, records) {
|
|
39
28
|
return records.filter(r => !recordsToDelete.includes(r));
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
const records = (state = {}, action) => {
|
|
43
31
|
var _state$action$key;
|
|
44
|
-
|
|
45
32
|
const list = (_state$action$key = state[action.key]) != null ? _state$action$key : [];
|
|
46
|
-
|
|
47
33
|
switch (action.type) {
|
|
48
34
|
case ReduxType.SET_RECORDS:
|
|
49
35
|
if (Array.isArray(action.payload)) {
|
|
@@ -51,35 +37,28 @@ const records = (state = {}, action) => {
|
|
|
51
37
|
[action.key]: action.payload
|
|
52
38
|
});
|
|
53
39
|
}
|
|
54
|
-
|
|
55
40
|
case ReduxType.ADD_RECORD:
|
|
56
41
|
return (0, _extends2.default)({}, state, {
|
|
57
42
|
[action.key]: appendRecord(action.payload, list)
|
|
58
43
|
});
|
|
59
|
-
|
|
60
44
|
case ReduxType.ADD_RECORDS:
|
|
61
45
|
return (0, _extends2.default)({}, state, {
|
|
62
46
|
[action.key]: appendRecords(action.payload, list)
|
|
63
47
|
});
|
|
64
|
-
|
|
65
48
|
case ReduxType.DELETE_RECORD:
|
|
66
49
|
return (0, _extends2.default)({}, state, {
|
|
67
50
|
[action.key]: deleteRecord(action.payload, list)
|
|
68
51
|
});
|
|
69
|
-
|
|
70
52
|
case ReduxType.DELETE_RECORDS:
|
|
71
53
|
return (0, _extends2.default)({}, state, {
|
|
72
54
|
[action.key]: deleteRecords(action.payload, list)
|
|
73
55
|
});
|
|
74
|
-
|
|
75
56
|
case ReduxType.UPDATE_RECORD:
|
|
76
57
|
return (0, _extends2.default)({}, state, {
|
|
77
58
|
[action.key]: updateRecord(action.payload, list)
|
|
78
59
|
});
|
|
79
|
-
|
|
80
60
|
default:
|
|
81
61
|
return state;
|
|
82
62
|
}
|
|
83
63
|
};
|
|
84
|
-
|
|
85
64
|
exports.records = records;
|
package/lib/store/store.js
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
exports.__esModule = true;
|
|
6
5
|
exports.useAppSelector = exports.useAppDispatch = exports.store = exports.persistor = exports.persistConfig = void 0;
|
|
7
|
-
|
|
8
6
|
var _toolkit = require("@reduxjs/toolkit");
|
|
9
|
-
|
|
10
7
|
var _reduxPersist = require("redux-persist");
|
|
11
|
-
|
|
12
8
|
var _reactRedux = require("react-redux");
|
|
13
|
-
|
|
14
9
|
var _reducers = require("./reducers");
|
|
15
|
-
|
|
16
10
|
var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
|
|
17
|
-
|
|
18
11
|
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
19
|
-
|
|
20
12
|
const CustomStorage = {
|
|
21
13
|
getItem: async (_key, ..._args) => {
|
|
22
14
|
if (typeof document !== 'undefined') {
|
|
23
|
-
console.log("I'm on the web!");
|
|
24
15
|
return localStorage.getItem(_key);
|
|
25
16
|
} else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
26
|
-
console.log("I'm in react-native");
|
|
27
17
|
return await _asyncStorage.default.getItem(_key);
|
|
28
18
|
}
|
|
29
19
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pocketbase-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Unofficial React SDK (React, React Native, Expo) for interacting with the PocketBase JS SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pocketbase",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/tobicrain/pocketbase-react/issues"
|
|
24
24
|
},
|
|
25
|
-
"main": "
|
|
26
|
-
"types": "
|
|
25
|
+
"main": "lib/index.js",
|
|
26
|
+
"types": "es/index.d.ts",
|
|
27
27
|
"unpkg": "dist/pocketbase-react.js",
|
|
28
28
|
"module": "es/index.js",
|
|
29
29
|
"files": [
|
|
@@ -44,75 +44,31 @@
|
|
|
44
44
|
"rollup": "rollup -c",
|
|
45
45
|
"prepublishOnly": "npm run build"
|
|
46
46
|
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"pocketbase": "^0.7.1"
|
|
49
|
+
},
|
|
47
50
|
"devDependencies": {
|
|
48
51
|
"@babel/cli": "^7.12.1",
|
|
49
|
-
"@babel/core": "^7.
|
|
52
|
+
"@babel/core": "^7.19.3",
|
|
50
53
|
"@babel/plugin-proposal-decorators": "^7.12.1",
|
|
51
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
|
|
52
|
-
"@babel/plugin-transform-react-display-name": "^7.12.1",
|
|
53
54
|
"@babel/plugin-transform-react-jsx": "^7.12.1",
|
|
54
55
|
"@babel/plugin-transform-runtime": "^7.12.1",
|
|
55
56
|
"@babel/preset-env": "^7.12.1",
|
|
56
57
|
"@babel/preset-typescript": "^7.14.5",
|
|
57
|
-
"@microsoft/api-extractor": "^7.18.1",
|
|
58
58
|
"@rollup/plugin-babel": "^5.2.1",
|
|
59
59
|
"@rollup/plugin-commonjs": "^15.1.0",
|
|
60
60
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
61
61
|
"@rollup/plugin-replace": "^2.3.3",
|
|
62
|
-
"@testing-library/jest-dom": "^5.11.5",
|
|
63
|
-
"@testing-library/jest-native": "^3.4.3",
|
|
64
|
-
"@testing-library/react": "13.0.0",
|
|
65
|
-
"@testing-library/react-12": "npm:@testing-library/react@^12",
|
|
66
|
-
"@testing-library/react-hooks": "^3.4.2",
|
|
67
|
-
"@testing-library/react-native": "^7.1.0",
|
|
68
|
-
"@types/object-assign": "^4.0.30",
|
|
69
|
-
"@types/react": "^18",
|
|
70
|
-
"@types/react-dom": "^18",
|
|
71
|
-
"@types/react-is": "^17",
|
|
72
|
-
"@types/react-native": "^0.67.4",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
|
74
|
-
"@typescript-eslint/parser": "^4.28.0",
|
|
75
|
-
"babel-eslint": "^10.1.0",
|
|
76
|
-
"babel-jest": "^26.6.1",
|
|
77
|
-
"codecov": "^3.8.0",
|
|
78
|
-
"eslint": "^7.12.0",
|
|
79
|
-
"eslint-config-prettier": "^6.14.0",
|
|
80
|
-
"eslint-plugin-import": "^2.22.1",
|
|
81
|
-
"eslint-plugin-prettier": "^3.1.4",
|
|
82
|
-
"eslint-plugin-react": "^7.21.5",
|
|
83
|
-
"glob": "^7.1.6",
|
|
84
|
-
"jest": "^26.6.1",
|
|
85
|
-
"prettier": "^2.1.2",
|
|
86
|
-
"react": "18.0.0",
|
|
87
|
-
"react-17": "npm:react@^17",
|
|
88
|
-
"react-dom": "18.0.0",
|
|
89
|
-
"react-dom-17": "npm:react-dom@^17",
|
|
90
|
-
"react-native": "^0.64.1",
|
|
91
|
-
"react-test-renderer": "18.0.0",
|
|
92
|
-
"react-test-renderer-17": "npm:react-test-renderer@^17",
|
|
93
62
|
"cross-env": "^7.0.3",
|
|
63
|
+
"react": "18.0.0",
|
|
94
64
|
"rollup": "^2.32.1",
|
|
95
65
|
"rollup-plugin-terser": "^7.0.2",
|
|
96
|
-
"rimraf": "^3.0.2",
|
|
97
|
-
"ts-jest": "26.5.6",
|
|
98
66
|
"typescript": "^4.3.4"
|
|
99
67
|
},
|
|
100
|
-
"peerDependencies": {
|
|
101
|
-
"pocketbase": "^0.7.1",
|
|
102
|
-
"react": "^16.12.0",
|
|
103
|
-
"@react-native-async-storage/async-storage": "^1.17.10",
|
|
104
|
-
"@reduxjs/toolkit": "^1.8.5",
|
|
105
|
-
"node-localstorage": "^2.2.1",
|
|
106
|
-
"react-redux": "^8.0.4",
|
|
107
|
-
"redux": "^4.2.0",
|
|
108
|
-
"redux-persist": "^6.0.0"
|
|
109
|
-
},
|
|
110
68
|
"dependencies": {
|
|
111
|
-
"@babel/runtime": "^7.12.1",
|
|
112
|
-
"pocketbase": "^0.7.1",
|
|
113
69
|
"@react-native-async-storage/async-storage": "^1.17.10",
|
|
114
70
|
"@reduxjs/toolkit": "^1.8.5",
|
|
115
|
-
"
|
|
71
|
+
"@tobicrain/pocketbase": "^0.7.1",
|
|
116
72
|
"react-redux": "^8.0.4",
|
|
117
73
|
"redux": "^4.2.0",
|
|
118
74
|
"redux-persist": "^6.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createContext, useEffect } from 'react';
|
|
3
|
-
import PocketBase from 'pocketbase';
|
|
3
|
+
import PocketBase from '@tobicrain/pocketbase';
|
|
4
4
|
import { Provider } from 'react-redux';
|
|
5
5
|
import { PersistGate } from 'redux-persist/integration/react';
|
|
6
6
|
import * as store from '../store/store';
|
|
@@ -25,7 +25,6 @@ export const Pocketbase = (props: PocketbaseProviderProps) => {
|
|
|
25
25
|
const client = new PocketBase(props.serverURL);
|
|
26
26
|
client.admins.authViaEmail(props.credentials.username, props.credentials.password).then(() => {
|
|
27
27
|
setClient(client);
|
|
28
|
-
console.log('Pocketbase client initialized');
|
|
29
28
|
});
|
|
30
29
|
}, [props.serverURL]);
|
|
31
30
|
|
package/src/context/client.tsx
CHANGED
package/src/store/store.tsx
CHANGED
|
@@ -16,11 +16,9 @@ interface Storage {
|
|
|
16
16
|
const CustomStorage: Storage = {
|
|
17
17
|
getItem: async (_key: string, ..._args: Array<any>) => {
|
|
18
18
|
if (typeof document !== 'undefined') {
|
|
19
|
-
console.log("I'm on the web!")
|
|
20
19
|
return localStorage.getItem(_key);
|
|
21
20
|
}
|
|
22
21
|
else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
23
|
-
console.log("I'm in react-native")
|
|
24
22
|
return await AsyncStorage.getItem(_key);
|
|
25
23
|
}
|
|
26
24
|
},
|