@webkrafters/react-observable-context 3.0.0 → 4.0.0-alpha.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/README.md +11 -3
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +8 -0
- package/dist/main/hooks/use-prehooks-ref/index.d.ts +1 -0
- package/dist/main/hooks/use-prehooks-ref/index.js +16 -0
- package/dist/main/hooks/use-render-keys-manager/index.d.ts +1 -0
- package/dist/main/hooks/use-render-keys-manager/index.js +34 -0
- package/dist/main/hooks/use-state-manager/index.d.ts +1 -0
- package/dist/main/hooks/use-state-manager/index.js +48 -0
- package/dist/main/hooks/use-store/index.d.ts +1 -0
- package/dist/main/hooks/use-store/index.js +121 -0
- package/dist/main/index.d.ts +1 -0
- package/dist/main/index.js +172 -0
- package/dist/main/set-state/index.d.ts +1 -0
- package/dist/main/set-state/index.js +104 -0
- package/dist/model/accessor/index.d.ts +1 -0
- package/dist/model/accessor/index.js +258 -0
- package/dist/model/accessor-cache/index.d.ts +1 -0
- package/dist/model/accessor-cache/index.js +165 -0
- package/dist/model/atom/index.d.ts +1 -0
- package/dist/model/atom/index.js +76 -0
- package/dist/model/storage/index.d.ts +1 -0
- package/dist/model/storage/index.js +129 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +26 -0
- package/index.js +1 -1
- package/package.json +39 -12
- package/dist/index.d.ts +0 -33
- package/dist/index.js +0 -389
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default Atom;
|
|
2
|
[x: string]: any;
|
|
1
3
|
get value(): Readonly<Value>;
|
|
2
4
|
/**
|
|
3
5
|
* @param {number} accessorId
|
|
4
6
|
* @returns {number} Number of connections remaining
|
|
5
7
|
*/
|
|
6
8
|
connect(accessorId: number): number;
|
|
7
9
|
/**
|
|
8
10
|
* @param {number} accessorId
|
|
9
11
|
* @returns {number} Number of connections remaining
|
|
10
12
|
*/
|
|
11
13
|
disconnect(accessorId: number): number;
|
|
12
14
|
/** @param {number} accessorId */
|
|
13
15
|
isConnected(accessorId: number): boolean;
|
|
14
16
|
/** @param {Value|Readonly<Value>} newValue */
|
|
15
17
|
setValue(newValue: Value | Readonly<Value>): void;
|
|
16
18
|
#private;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
16
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
17
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
18
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
19
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
20
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
21
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
|
22
|
+
var _connections = new WeakMap();
|
|
23
|
+
var _value = new WeakMap();
|
|
24
|
+
/** An atom represents an entry for each individual property path of the state still in use by client components */
|
|
25
|
+
var Atom = function () {
|
|
26
|
+
/** @type {Set<number>} */
|
|
27
|
+
/** @type {Readonly<Value>} */
|
|
28
|
+
function Atom() {
|
|
29
|
+
_classCallCheck(this, Atom);
|
|
30
|
+
_classPrivateFieldInitSpec(this, _connections, {
|
|
31
|
+
writable: true,
|
|
32
|
+
value: void 0
|
|
33
|
+
});
|
|
34
|
+
_classPrivateFieldInitSpec(this, _value, {
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
_classPrivateFieldSet(this, _connections, new Set());
|
|
39
|
+
_classPrivateFieldSet(this, _value, (0, _utils.makeReadonly)({}));
|
|
40
|
+
}
|
|
41
|
+
_createClass(Atom, [{
|
|
42
|
+
key: "value",
|
|
43
|
+
get: function get() {
|
|
44
|
+
return _classPrivateFieldGet(this, _value);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
* @param {number} accessorId
|
|
1
48
|
* @returns {number} Number of connections remaining
|
|
2
49
|
*/
|
|
50
|
+
}, {
|
|
51
|
+
key: "connect",
|
|
52
|
+
value: function connect(accessorId) {
|
|
53
|
+
_classPrivateFieldGet(this, _connections).add(accessorId);
|
|
54
|
+
return _classPrivateFieldGet(this, _connections).size;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
3
57
|
* @param {number} accessorId
|
|
4
58
|
* @returns {number} Number of connections remaining
|
|
5
59
|
*/
|
|
60
|
+
}, {
|
|
61
|
+
key: "disconnect",
|
|
62
|
+
value: function disconnect(accessorId) {
|
|
63
|
+
_classPrivateFieldGet(this, _connections)["delete"](accessorId);
|
|
64
|
+
return _classPrivateFieldGet(this, _connections).size;
|
|
65
|
+
}
|
|
66
|
+
/** @param {number} accessorId */
|
|
67
|
+
}, {
|
|
68
|
+
key: "isConnected",
|
|
69
|
+
value: function isConnected(accessorId) {
|
|
70
|
+
return _classPrivateFieldGet(this, _connections).has(accessorId);
|
|
71
|
+
}
|
|
72
|
+
/** @param {Value|Readonly<Value>} newValue */
|
|
73
|
+
}, {
|
|
74
|
+
key: "setValue",
|
|
75
|
+
value: function setValue(newValue) {
|
|
76
|
+
_classPrivateFieldSet(this, _value, (0, _utils.makeReadonly)((0, _lodash["default"])(newValue)));
|
|
77
|
+
}
|
|
78
|
+
}]);
|
|
79
|
+
return Atom;
|
|
80
|
+
}();
|
|
81
|
+
var _default = Atom;
|
|
82
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
8
|
+
var _globalThis$sessionSt;
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
17
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
18
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
19
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
20
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
21
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
22
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
|
23
|
+
var _data = new WeakMap();
|
|
24
|
+
/**
|
|
25
|
* @class
|
|
1
26
|
* @template {State} T
|
|
2
27
|
*/
|
|
28
|
+
var MemoryStorage = function () {
|
|
29
|
+
/** @type {T} */
|
|
30
|
+
function MemoryStorage() {
|
|
31
|
+
_classCallCheck(this, MemoryStorage);
|
|
32
|
+
_classPrivateFieldInitSpec(this, _data, {
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
_classPrivateFieldSet(this, _data, null);
|
|
37
|
+
}
|
|
38
|
+
/** @type {IStorage<T>[ "getItem" ]} */
|
|
39
|
+
_createClass(MemoryStorage, [{
|
|
40
|
+
key: "getItem",
|
|
41
|
+
value: function getItem(key) {
|
|
42
|
+
return (0, _lodash["default"])(_classPrivateFieldGet(this, _data));
|
|
43
|
+
}
|
|
44
|
+
/** @type {IStorage<T>[ "removeItem" ]} */
|
|
45
|
+
}, {
|
|
46
|
+
key: "removeItem",
|
|
47
|
+
value: function removeItem(key) {
|
|
48
|
+
_classPrivateFieldSet(this, _data, null);
|
|
49
|
+
}
|
|
50
|
+
/** @type {IStorage<T>[ "setItem" ]} */
|
|
51
|
+
}, {
|
|
52
|
+
key: "setItem",
|
|
53
|
+
value: function setItem(key, data) {
|
|
54
|
+
_classPrivateFieldSet(this, _data, (0, _lodash["default"])(data));
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
return MemoryStorage;
|
|
58
|
+
}();
|
|
59
|
+
/**
|
|
3
60
|
* @extends {IStorage<T>}
|
|
4
61
|
* @template {State} T
|
|
5
62
|
*/
|
|
63
|
+
var _storage = new WeakMap();
|
|
64
|
+
var SessionStorage = function () {
|
|
65
|
+
/** @type {IStorage<T>} */
|
|
66
|
+
function SessionStorage() {
|
|
67
|
+
_classCallCheck(this, SessionStorage);
|
|
68
|
+
_classPrivateFieldInitSpec(this, _storage, {
|
|
69
|
+
writable: true,
|
|
70
|
+
value: void 0
|
|
71
|
+
});
|
|
72
|
+
_classPrivateFieldSet(this, _storage, globalThis.sessionStorage);
|
|
73
|
+
}
|
|
74
|
+
/** @type {IStorage<T>[ "getItem" ]} */
|
|
75
|
+
_createClass(SessionStorage, [{
|
|
76
|
+
key: "getItem",
|
|
77
|
+
value: function getItem(key) {
|
|
78
|
+
return JSON.parse(_classPrivateFieldGet(this, _storage).getItem(key));
|
|
79
|
+
}
|
|
80
|
+
/** @type {IStorage<T>[ "removeItem" ]} */
|
|
81
|
+
}, {
|
|
82
|
+
key: "removeItem",
|
|
83
|
+
value: function removeItem(key) {
|
|
84
|
+
return _classPrivateFieldGet(this, _storage).removeItem(key);
|
|
85
|
+
}
|
|
86
|
+
/** @type {IStorage<T>[ "setItem" ]} */
|
|
87
|
+
}, {
|
|
88
|
+
key: "setItem",
|
|
89
|
+
value: function setItem(key, data) {
|
|
90
|
+
return _classPrivateFieldGet(this, _storage).setItem(key, JSON.stringify(data));
|
|
91
|
+
}
|
|
92
|
+
}]);
|
|
93
|
+
return SessionStorage;
|
|
94
|
+
}();
|
|
95
|
+
/**
|
|
6
96
|
* @extends {IStorage<T>}
|
|
7
97
|
* @template {State} T
|
|
8
98
|
*/
|
|
99
|
+
var _storage2 = new WeakMap();
|
|
100
|
+
var Storage = function () {
|
|
101
|
+
/** @type {IStorage<T>} */
|
|
102
|
+
function Storage() {
|
|
103
|
+
_classCallCheck(this, Storage);
|
|
104
|
+
_classPrivateFieldInitSpec(this, _storage2, {
|
|
105
|
+
writable: true,
|
|
106
|
+
value: void 0
|
|
107
|
+
});
|
|
108
|
+
_classPrivateFieldSet(this, _storage2, Storage.supportsSession ? new SessionStorage() : new MemoryStorage());
|
|
109
|
+
}
|
|
110
|
+
_createClass(Storage, [{
|
|
111
|
+
key: "isKeyRequired",
|
|
112
|
+
get: function get() {
|
|
113
|
+
return _classPrivateFieldGet(this, _storage2) instanceof SessionStorage;
|
|
114
|
+
}
|
|
115
|
+
/** @type {IStorage<T>[ "getItem" ]} */
|
|
116
|
+
}, {
|
|
117
|
+
key: "getItem",
|
|
118
|
+
value: function getItem(key) {
|
|
119
|
+
return _classPrivateFieldGet(this, _storage2).getItem(key);
|
|
120
|
+
}
|
|
121
|
+
/** @type {IStorage<T>[ "removeItem" ]} */
|
|
122
|
+
}, {
|
|
123
|
+
key: "removeItem",
|
|
124
|
+
value: function removeItem(key) {
|
|
125
|
+
_classPrivateFieldGet(this, _storage2).removeItem(key);
|
|
126
|
+
}
|
|
127
|
+
/** @type {IStorage<T>[ "setItem" ]} */
|
|
128
|
+
}, {
|
|
129
|
+
key: "setItem",
|
|
130
|
+
value: function setItem(key, data) {
|
|
131
|
+
_classPrivateFieldGet(this, _storage2).setItem(key, data);
|
|
132
|
+
}
|
|
133
|
+
}]);
|
|
134
|
+
return Storage;
|
|
135
|
+
}();
|
|
136
|
+
_defineProperty(Storage, "supportsSession", typeof ((_globalThis$sessionSt = globalThis.sessionStorage) === null || _globalThis$sessionSt === void 0 ? void 0 : _globalThis$sessionSt.setItem) === 'undefined');
|
|
137
|
+
var _default = Storage;
|
|
138
|
+
exports["default"] = _default;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare const _default: any;
|
|
2
|
getItem: (key: string) => T;
|
|
1
3
|
removeItem: (key: string) => void;
|
|
2
4
|
setItem: (key: string, data: T) => void;
|
|
3
5
|
getState: NonReactUsageReport;
|
|
4
6
|
resetState: NonReactUsageReport;
|
|
5
7
|
setState: NonReactUsageReport;
|
|
6
8
|
subscribe: NonReactUsageReport;
|
|
7
9
|
resetState?: (state: {
|
|
8
10
|
current: T;
|
|
9
11
|
original: T;
|
|
10
12
|
}) => boolean;
|
|
11
13
|
setState?: (newChanges: PartialState<T>) => boolean;
|
|
12
14
|
[x: string]: any;
|
|
13
15
|
resetState: VoidFunction;
|
|
14
16
|
setState: (changes: PartialState<T>) => void;
|
|
15
17
|
getState: (clientId: string, ...propertyPaths?: string[]) => Readonly<PartialState<T>>;
|
|
16
18
|
subscribe: (listener: Listener<T>) => Unsubscribe;
|
|
17
19
|
unlinkCache: (clientId: string) => void;
|
|
18
20
|
data: PartialState<T>;
|
|
19
21
|
resetState: VoidFunction;
|
|
20
22
|
setState: (changes: PartialState<T>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function makeReadonly<T>(v: T): Readonly<T>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.makeReadonly = void 0;
|
|
6
|
+
var _lodash = _interopRequireDefault(require("lodash.isplainobject"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
+
/**
|
|
9
|
* Converts argument to readonly.
|
|
1
10
|
*
|
|
2
11
|
* Note: Mutates original argument.
|
|
3
12
|
*
|
|
4
13
|
* @param {T} v
|
|
5
14
|
* @returns {Readonly<T>}
|
|
6
15
|
* @template T
|
|
7
16
|
*/
|
|
17
|
+
var makeReadonly = function makeReadonly(v) {
|
|
18
|
+
var frozen = true;
|
|
19
|
+
if ((0, _lodash["default"])(v)) {
|
|
20
|
+
for (var k in v) {
|
|
21
|
+
makeReadonly(v[k]);
|
|
22
|
+
}
|
|
23
|
+
frozen = Object.isFrozen(v);
|
|
24
|
+
} else if (Array.isArray(v)) {
|
|
25
|
+
var vLen = v.length;
|
|
26
|
+
for (var i = 0; i < vLen; i++) {
|
|
27
|
+
makeReadonly(v[i]);
|
|
28
|
+
}
|
|
29
|
+
frozen = Object.isFrozen(v);
|
|
30
|
+
}
|
|
31
|
+
!frozen && Object.freeze(v);
|
|
32
|
+
return v;
|
|
33
|
+
};
|
|
34
|
+
exports.makeReadonly = makeReadonly;
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require( './dist' );
|
|
1
|
+
module.exports = require( './dist/main' );
|
package/package.json
CHANGED
|
@@ -8,31 +8,35 @@
|
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"lodash.clonedeep": "^4.5.0",
|
|
11
|
-
"lodash.
|
|
11
|
+
"lodash.get": "^4.4.2",
|
|
12
12
|
"lodash.isempty": "^4.4.0",
|
|
13
13
|
"lodash.isequal": "^4.5.0",
|
|
14
14
|
"lodash.isplainobject": "^4.0.6",
|
|
15
|
-
"lodash.omit": "^4.5.0"
|
|
15
|
+
"lodash.omit": "^4.5.0",
|
|
16
|
+
"lodash.pick": "^4.4.0",
|
|
17
|
+
"lodash.set": "^4.3.2",
|
|
18
|
+
"uuid": "^9.0.0"
|
|
16
19
|
},
|
|
17
20
|
"description": "Observable react context - prevents an automatic total component tree tear-down and re-rendering during context updates.",
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@babel/cli": "^7.17.0",
|
|
20
|
-
"@babel/core": "^7.
|
|
23
|
+
"@babel/core": "^7.20.5",
|
|
21
24
|
"@babel/node": "^7.12.10",
|
|
22
25
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
23
26
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
24
|
-
"@babel/preset-env": "^7.
|
|
27
|
+
"@babel/preset-env": "^7.20.2",
|
|
25
28
|
"@babel/preset-react": "^7.18.6",
|
|
26
29
|
"@testing-library/jest-dom": "^5.16.5",
|
|
27
30
|
"@testing-library/react": "^13.4.0",
|
|
31
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
28
32
|
"@testing-library/user-event": "^14.4.3",
|
|
29
33
|
"@types/jest-cli": "^24.3.0",
|
|
30
34
|
"babel-jest": "^26.6.3",
|
|
31
35
|
"babel-loader": "^8.2.5",
|
|
32
|
-
"eslint": "^
|
|
36
|
+
"eslint": "^8.29.0",
|
|
33
37
|
"eslint-config-standard": "^16.0.2",
|
|
34
38
|
"eslint-plugin-import": "^2.22.1",
|
|
35
|
-
"eslint-plugin-jest": "^
|
|
39
|
+
"eslint-plugin-jest": "^26.0.0",
|
|
36
40
|
"eslint-plugin-node": "^11.1.0",
|
|
37
41
|
"eslint-plugin-promise": "^4.2.1",
|
|
38
42
|
"eslint-plugin-react": "^7.31.11",
|
|
@@ -44,9 +48,32 @@
|
|
|
44
48
|
"typescript": "^4.8.2"
|
|
45
49
|
},
|
|
46
50
|
"files": [
|
|
47
|
-
"dist/
|
|
48
|
-
"dist/
|
|
49
|
-
"index",
|
|
51
|
+
"dist/constants.js",
|
|
52
|
+
"dist/constants.d.ts",
|
|
53
|
+
"dist/main/index.js",
|
|
54
|
+
"dist/main/index.d.ts",
|
|
55
|
+
"dist/main/set-state/index.js",
|
|
56
|
+
"dist/main/set-state/index.d.ts",
|
|
57
|
+
"dist/main/hooks/use-prehooks-ref/index.js",
|
|
58
|
+
"dist/main/hooks/use-prehooks-ref/index.d.ts",
|
|
59
|
+
"dist/main/hooks/use-render-keys-manager/index.js",
|
|
60
|
+
"dist/main/hooks/use-render-keys-manager/index.d.ts",
|
|
61
|
+
"dist/main/hooks/use-state-manager/index.js",
|
|
62
|
+
"dist/main/hooks/use-state-manager/index.d.ts",
|
|
63
|
+
"dist/main/hooks/use-store/index.js",
|
|
64
|
+
"dist/main/hooks/use-store/index.d.ts",
|
|
65
|
+
"dist/model/accessor/index.js",
|
|
66
|
+
"dist/model/accessor/index.d.ts",
|
|
67
|
+
"dist/model/accessor-cache/index.js",
|
|
68
|
+
"dist/model/accessor-cache/index.d.ts",
|
|
69
|
+
"dist/model/atom/index.js",
|
|
70
|
+
"dist/model/atom/index.d.ts",
|
|
71
|
+
"dist/model/storage/index.js",
|
|
72
|
+
"dist/model/storage/index.d.ts",
|
|
73
|
+
"dist/utils/index.js",
|
|
74
|
+
"dist/utils/index.d.ts",
|
|
75
|
+
"dist/types.d.ts",
|
|
76
|
+
"index.js",
|
|
50
77
|
"package.json"
|
|
51
78
|
],
|
|
52
79
|
"homepage": "https://github.com/steveswork/react-observable-context#readme",
|
|
@@ -76,10 +103,10 @@
|
|
|
76
103
|
"url": "git+https://github.com/steveswork/react-observable-context.git"
|
|
77
104
|
},
|
|
78
105
|
"scripts": {
|
|
79
|
-
"build": "eslint --fix && rm -rf dist && babel src -d dist && npx -p typescript tsc",
|
|
106
|
+
"build": "eslint --fix && rm -rf dist && babel src -d dist && npx -p typescript tsc && node ./trim-comments",
|
|
80
107
|
"test": "eslint --fix && jest --updateSnapshot",
|
|
81
108
|
"test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
|
|
82
109
|
},
|
|
83
|
-
"types": "dist/index.d.ts",
|
|
84
|
-
"version": "
|
|
110
|
+
"types": "dist/main/index.d.ts",
|
|
111
|
+
"version": "4.0.0-alpha.1"
|
|
85
112
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export class UsageError extends Error {
|
|
2
|
-
}
|
|
3
|
-
export function createContext<T_1 extends State>(): import("react").Context<Store<T_1>>;
|
|
4
|
-
export function useContext<T_1 extends State>(context: import("react").Context<Store<T_1>>, watchedKeys?: (string | keyof T_1)[]): Store<T_1>;
|
|
5
|
-
export type ObservableContext<T_1 extends State> = Context<Store<T>>;
|
|
6
|
-
export type OptionalTask<F = void> = F extends void ? () => never : F;
|
|
7
|
-
export type Listener<T_1 extends State> = (newValue: PartialState<T>, oldValue: PartialState<T>) => void;
|
|
8
|
-
export type State = {
|
|
9
|
-
[x: string]: any;
|
|
10
|
-
};
|
|
11
|
-
export type PartialState<T_1 extends State> = {
|
|
12
|
-
[x: string]: any;
|
|
13
|
-
} & { [K in keyof T]?: T[K]; };
|
|
14
|
-
export type Selector<T_1 extends State> = (state: T) => any;
|
|
15
|
-
export type Prehooks<T_1 extends State> = {
|
|
16
|
-
resetState?: (state: {
|
|
17
|
-
current: T;
|
|
18
|
-
original: T;
|
|
19
|
-
}) => boolean;
|
|
20
|
-
setState?: (newChanges: PartialState<T>) => boolean;
|
|
21
|
-
};
|
|
22
|
-
export type Store<T_1 extends State> = {
|
|
23
|
-
getState: (selector?: Selector<T>) => any;
|
|
24
|
-
resetState: OptionalTask<VoidFunction>;
|
|
25
|
-
setState: (changes: PartialState<T>) => void;
|
|
26
|
-
subscribe: (listener: Listener<T>) => Unsubscribe;
|
|
27
|
-
};
|
|
28
|
-
export type Unsubscribe = VoidFunction;
|
|
29
|
-
export type ReactNode = import("react").ReactNode;
|
|
30
|
-
export type FC<P = {}> = import("react").FC<P>;
|
|
31
|
-
export type Provider<T_1> = import("react").Provider<T>;
|
|
32
|
-
export type Context<T_1> = import("react").Context<T>;
|
|
33
|
-
//# sourceMappingURL=index.d.ts.map
|