@webkrafters/react-observable-context 3.0.0 → 4.0.0-alpha.0
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-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,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports["default"] = void 0;
|
|
6
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
7
|
+
var _lodash2 = _interopRequireDefault(require("lodash.isequal"));
|
|
8
|
+
var _lodash3 = _interopRequireDefault(require("lodash.isplainobject"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
+
/** @param {{[x:string]: any}} obj */
|
|
18
|
+
var isIndexBasedObj = function isIndexBasedObj(obj) {
|
|
19
|
+
return Object.keys(obj).every(function (k) {
|
|
20
|
+
var i = +k;
|
|
21
|
+
return Number.isInteger(i) && i > -1;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
* Mutates its arguments
|
|
1
26
|
*
|
|
2
27
|
* @param {HasArrayRoot<K>|HasObjectRoot<K>} state
|
|
3
28
|
* @param {HasArrayRoot<K>|HasObjectRoot<K>} newState
|
|
4
29
|
* @param {K} stateKey
|
|
5
30
|
* @param {Stats} stats
|
|
6
31
|
* @template {KeyTypes} K
|
|
7
32
|
*/
|
|
33
|
+
function setAtomic(state, newState, stateKey, stats) {
|
|
34
|
+
if ((0, _lodash2["default"])(state[stateKey], newState[stateKey])) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var isPlainObjectNewState = (0, _lodash3["default"])(newState[stateKey]);
|
|
38
|
+
var isArrayNewState = Array.isArray(newState[stateKey]);
|
|
39
|
+
if (Array.isArray(state[stateKey])) {
|
|
40
|
+
if (isArrayNewState) {
|
|
41
|
+
return setArray(state, newState, stateKey, stats);
|
|
42
|
+
}
|
|
43
|
+
if (isPlainObjectNewState && isIndexBasedObj(newState[stateKey])) {
|
|
44
|
+
return setArrayIndex(state, newState, stateKey, stats);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (isPlainObjectNewState && (0, _lodash3["default"])(state[stateKey])) {
|
|
48
|
+
return setPlainObject(state, newState, stateKey, stats);
|
|
49
|
+
}
|
|
50
|
+
stats.hasChanges = true;
|
|
51
|
+
state[stateKey] = isArrayNewState || isPlainObjectNewState ? (0, _lodash["default"])(newState[stateKey]) : newState[stateKey];
|
|
52
|
+
}
|
|
53
|
+
;
|
|
54
|
+
/**
|
|
8
55
|
* Mutates its arguments
|
|
9
56
|
*
|
|
10
57
|
* @param {HasArrayRoot<K>} state
|
|
11
58
|
* @param {HasArrayRoot<K>} newState
|
|
12
59
|
* @param {K} rootKey
|
|
13
60
|
* @param {Stats} stats
|
|
14
61
|
* @template {KeyTypes} K
|
|
15
62
|
*/
|
|
63
|
+
function setArray(state, newState, rootKey, stats) {
|
|
64
|
+
var nsLength = newState[rootKey].length;
|
|
65
|
+
if (state[rootKey].length !== nsLength) {
|
|
66
|
+
state[rootKey].length = nsLength;
|
|
67
|
+
stats.hasChanges = true;
|
|
68
|
+
}
|
|
69
|
+
for (var i = 0; i < nsLength; i++) {
|
|
70
|
+
setAtomic(state[rootKey], newState[rootKey], i, stats);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
;
|
|
74
|
+
/**
|
|
16
75
|
* Mutates its arguments
|
|
17
76
|
*
|
|
18
77
|
* @param {HasArrayRoot<K>} state
|
|
19
78
|
* @param {HasObjectRoot<K>} newState
|
|
20
79
|
* @param {K} rootKey
|
|
21
80
|
* @param {Stats} stats
|
|
22
81
|
* @template {KeyTypes} K
|
|
23
82
|
*/
|
|
83
|
+
function setArrayIndex(state, newState, rootKey, stats) {
|
|
84
|
+
var incomingIndexes = Object.keys(newState[rootKey]).map(function (i) {
|
|
85
|
+
return +i;
|
|
86
|
+
});
|
|
87
|
+
var maxIncomingIndex = Math.max.apply(Math, _toConsumableArray(incomingIndexes));
|
|
88
|
+
if (maxIncomingIndex >= state[rootKey].length) {
|
|
89
|
+
state[rootKey].length = maxIncomingIndex + 1;
|
|
90
|
+
stats.hasChanges = true;
|
|
91
|
+
}
|
|
92
|
+
var _iterator = _createForOfIteratorHelper(incomingIndexes),
|
|
93
|
+
_step;
|
|
94
|
+
try {
|
|
95
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
96
|
+
var i = _step.value;
|
|
97
|
+
setAtomic(state[rootKey], newState[rootKey], i, stats);
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_iterator.e(err);
|
|
101
|
+
} finally {
|
|
102
|
+
_iterator.f();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
;
|
|
106
|
+
/**
|
|
24
107
|
* Mutates its arguments
|
|
25
108
|
*
|
|
26
109
|
* @param {HasObjectRoot<K>} state
|
|
27
110
|
* @param {HasObjectRoot<K>} newState
|
|
28
111
|
* @param {K} rootKey
|
|
29
112
|
* @param {Stats} stats
|
|
30
113
|
* @template {KeyTypes} K
|
|
31
114
|
*/
|
|
115
|
+
function setPlainObject(state, newState, rootKey, stats) {
|
|
116
|
+
set(state[rootKey], newState[rootKey], stats);
|
|
117
|
+
}
|
|
118
|
+
;
|
|
119
|
+
/**
|
|
32
120
|
* Mutates its arguments
|
|
33
121
|
*
|
|
34
122
|
* @param {HasObjectRoot} state
|
|
35
123
|
* @param {HasObjectRoot} newState
|
|
36
124
|
* @param {Stats} stats
|
|
37
125
|
*/
|
|
126
|
+
function set(state, newState, stats) {
|
|
127
|
+
for (var k in newState) {
|
|
128
|
+
setAtomic(state, newState, k, stats);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
;
|
|
132
|
+
/**
|
|
38
133
|
* @param {T} state
|
|
39
134
|
* @param {PartialState<T>} newState
|
|
40
135
|
* @param {Listener<T>} [onStateChange]
|
|
41
136
|
* @template {State} T
|
|
42
137
|
*/
|
|
138
|
+
function setState(state, newState, onStateChange) {
|
|
139
|
+
var stats = {
|
|
140
|
+
hasChanges: false
|
|
141
|
+
};
|
|
142
|
+
set(state, newState, stats);
|
|
143
|
+
stats.hasChanges && (onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(state));
|
|
144
|
+
}
|
|
145
|
+
;
|
|
146
|
+
var _default = setState;
|
|
147
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default AccessorCache;
|
|
2
|
/** @param {T} origin State object reference from which slices stored in this cache are to be curated */
|
|
1
3
|
constructor(origin: T);
|
|
2
4
|
/**
|
|
3
5
|
* Gets state slice from the cache matching the `propertyPaths`.\
|
|
4
6
|
* If not found, creates a new entry for the client from source, and returns it.
|
|
5
7
|
*
|
|
6
8
|
* @param {string} clientId
|
|
7
9
|
* @param {...string} propertyPaths
|
|
8
10
|
* @return {Readonly<PartialState<T>>}
|
|
9
11
|
*/
|
|
10
12
|
get(clientId: string, ...propertyPaths: string[]): Readonly<PartialState<T>>;
|
|
11
13
|
/**
|
|
12
14
|
* Unlinks a consumer from the cache: performing synchronized state cleanup
|
|
13
15
|
*
|
|
14
16
|
* @param {string} clientId
|
|
15
17
|
*/
|
|
16
18
|
unlinkClient(clientId: string): void;
|
|
17
19
|
/** Observes the origin state bearing ObservableContext store for state changes to update accessors. */
|
|
18
20
|
watchSource(): void;
|
|
19
21
|
#private;
|
|
@@ -0,0 +1,165 @@
|
|
|
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.get"));
|
|
8
|
+
var _lodash2 = _interopRequireDefault(require("lodash.isempty"));
|
|
9
|
+
var _lodash3 = _interopRequireDefault(require("lodash.isequal"));
|
|
10
|
+
var _constants = require("../../constants");
|
|
11
|
+
var _atom = _interopRequireDefault(require("../atom"));
|
|
12
|
+
var _accessor = _interopRequireDefault(require("../accessor"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
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); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
22
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
23
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
24
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
25
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
26
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
27
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
28
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
29
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
30
|
+
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; } }
|
|
31
|
+
var _accessors = new WeakMap();
|
|
32
|
+
var _atoms = new WeakMap();
|
|
33
|
+
var _origin = new WeakMap();
|
|
34
|
+
var _createAccessor = new WeakSet();
|
|
35
|
+
/** @template {State} T */
|
|
36
|
+
var AccessorCache = function () {
|
|
37
|
+
/** @type {{[propertyPaths: string]: Accessor<T>}} */
|
|
38
|
+
/** @type {{[propertyPath: string]: Atom}} */
|
|
39
|
+
/** @type {T} */
|
|
40
|
+
/** @param {T} origin State object reference from which slices stored in this cache are to be curated */
|
|
41
|
+
function AccessorCache(origin) {
|
|
42
|
+
_classCallCheck(this, AccessorCache);
|
|
43
|
+
_classPrivateMethodInitSpec(this, _createAccessor);
|
|
44
|
+
_classPrivateFieldInitSpec(this, _accessors, {
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
_classPrivateFieldInitSpec(this, _atoms, {
|
|
49
|
+
writable: true,
|
|
50
|
+
value: void 0
|
|
51
|
+
});
|
|
52
|
+
_classPrivateFieldInitSpec(this, _origin, {
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
56
|
+
_classPrivateFieldSet(this, _accessors, {});
|
|
57
|
+
_classPrivateFieldSet(this, _atoms, {});
|
|
58
|
+
_classPrivateFieldSet(this, _origin, origin);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
* Add new cache entry
|
|
1
62
|
*
|
|
2
63
|
* @param {string} cacheKey
|
|
3
64
|
* @param {Array<string>} propertyPaths
|
|
4
65
|
* @return {Accessor<T>}
|
|
5
66
|
*/
|
|
67
|
+
_createClass(AccessorCache, [{
|
|
68
|
+
key: "get",
|
|
69
|
+
value:
|
|
70
|
+
/**
|
|
6
71
|
* Gets state slice from the cache matching the `propertyPaths`.\
|
|
7
72
|
* If not found, creates a new entry for the client from source, and returns it.
|
|
8
73
|
*
|
|
9
74
|
* @param {string} clientId
|
|
10
75
|
* @param {...string} propertyPaths
|
|
11
76
|
* @return {Readonly<PartialState<T>>}
|
|
12
77
|
*/
|
|
78
|
+
function get(clientId) {
|
|
79
|
+
for (var _len = arguments.length, propertyPaths = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
80
|
+
propertyPaths[_key - 1] = arguments[_key];
|
|
81
|
+
}
|
|
82
|
+
if ((0, _lodash2["default"])(propertyPaths)) {
|
|
83
|
+
propertyPaths = [_constants.DEFAULT_STATE_PATH];
|
|
84
|
+
}
|
|
85
|
+
var cacheKey = JSON.stringify(propertyPaths);
|
|
86
|
+
var accessor = cacheKey in _classPrivateFieldGet(this, _accessors) ? _classPrivateFieldGet(this, _accessors)[cacheKey] : _classPrivateMethodGet(this, _createAccessor, _createAccessor2).call(this, cacheKey, propertyPaths);
|
|
87
|
+
!accessor.hasClient(clientId) && accessor.addClient(clientId);
|
|
88
|
+
return accessor.refreshValue(_classPrivateFieldGet(this, _atoms));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
13
91
|
* Unlinks a consumer from the cache: performing synchronized state cleanup
|
|
14
92
|
*
|
|
15
93
|
* @param {string} clientId
|
|
16
94
|
*/
|
|
95
|
+
}, {
|
|
96
|
+
key: "unlinkClient",
|
|
97
|
+
value: function unlinkClient(clientId) {
|
|
98
|
+
var accessors = _classPrivateFieldGet(this, _accessors);
|
|
99
|
+
var atoms = _classPrivateFieldGet(this, _atoms);
|
|
100
|
+
for (var k in accessors) {
|
|
101
|
+
var accessor = accessors[k];
|
|
102
|
+
if (!accessor.removeClient(clientId) || accessor.numClients) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
var _iterator = _createForOfIteratorHelper(accessor.paths),
|
|
106
|
+
_step;
|
|
107
|
+
try {
|
|
108
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
109
|
+
var p = _step.value;
|
|
110
|
+
if (p in atoms && atoms[p].disconnect(accessor.id) < 1) {
|
|
111
|
+
delete atoms[p];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
_iterator.e(err);
|
|
116
|
+
} finally {
|
|
117
|
+
_iterator.f();
|
|
118
|
+
}
|
|
119
|
+
delete accessors[k];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/** Observes the origin state bearing ObservableContext store for state changes to update accessors. */
|
|
123
|
+
}, {
|
|
124
|
+
key: "watchSource",
|
|
125
|
+
value: function watchSource() {
|
|
126
|
+
var accessors = _classPrivateFieldGet(this, _accessors);
|
|
127
|
+
var atoms = _classPrivateFieldGet(this, _atoms);
|
|
128
|
+
var state = _classPrivateFieldGet(this, _origin);
|
|
129
|
+
var updatedPaths = {};
|
|
130
|
+
for (var path in atoms) {
|
|
131
|
+
var newAtomVal = (0, _lodash["default"])(state, path);
|
|
132
|
+
if ((0, _lodash3["default"])(newAtomVal, atoms[path].value)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
atoms[path].setValue(newAtomVal);
|
|
136
|
+
updatedPaths[path] = true;
|
|
137
|
+
}
|
|
138
|
+
if ((0, _lodash2["default"])(updatedPaths)) {
|
|
139
|
+
for (var k in accessors) {
|
|
140
|
+
if (accessors[k].paths[0] === _constants.DEFAULT_STATE_PATH) {
|
|
141
|
+
accessors[k].refreshDue = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
for (var _k in accessors) {
|
|
147
|
+
if (accessors[_k].refreshDue) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
var accessorPaths = accessors[_k].paths;
|
|
151
|
+
accessors[_k].refreshDue = accessorPaths[0] === _constants.DEFAULT_STATE_PATH || accessorPaths.some(function (p) {
|
|
152
|
+
return p in updatedPaths;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}]);
|
|
157
|
+
return AccessorCache;
|
|
158
|
+
}();
|
|
159
|
+
function _createAccessor2(cacheKey, propertyPaths) {
|
|
160
|
+
var atoms = _classPrivateFieldGet(this, _atoms);
|
|
161
|
+
var accessor = new _accessor["default"](_classPrivateFieldGet(this, _origin), propertyPaths);
|
|
162
|
+
_classPrivateFieldGet(this, _accessors)[cacheKey] = accessor;
|
|
163
|
+
var _iterator2 = _createForOfIteratorHelper(accessor.paths),
|
|
164
|
+
_step2;
|
|
165
|
+
try {
|
|
166
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
167
|
+
var path = _step2.value;
|
|
168
|
+
if (path in atoms) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
atoms[path] = new _atom["default"]();
|
|
172
|
+
atoms[path].setValue((0, _lodash["default"])(_classPrivateFieldGet(this, _origin), path));
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
_iterator2.e(err);
|
|
176
|
+
} finally {
|
|
177
|
+
_iterator2.f();
|
|
178
|
+
}
|
|
179
|
+
return _classPrivateFieldGet(this, _accessors)[cacheKey];
|
|
180
|
+
}
|
|
181
|
+
var _default = AccessorCache;
|
|
182
|
+
exports["default"] = _default;
|
|
@@ -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;
|