@bigbinary/neeto-commons-frontend 2.1.39 → 3.0.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 +6 -51
- package/configs/scripts/dead-code-eliminator/index.js +1 -4
- package/configs/scripts/jsdoc-builder/utils.mjs +1 -1
- package/configs/webpack/helpers/customize-default-rules.js +1 -4
- package/initializers.cjs.js +10 -9
- package/initializers.cjs.js.map +1 -1
- package/initializers.js +2 -1
- package/initializers.js.map +1 -1
- package/package.json +3 -7
- package/react-utils.cjs.js +2 -2
- package/react-utils.cjs.js.map +1 -1
- package/react-utils.js +1 -1
- package/react-utils.js.map +1 -1
- package/utils.cjs.js +3 -3
- package/utils.cjs.js.map +1 -1
- package/utils.js +1 -1
- package/utils.js.map +1 -1
- package/pure.cjs.js +0 -1191
- package/pure.cjs.js.map +0 -1
- package/pure.d.ts +0 -1801
- package/pure.js +0 -1115
- package/pure.js.map +0 -1
package/pure.cjs.js
DELETED
|
@@ -1,1191 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var ramda = require('ramda');
|
|
6
|
-
|
|
7
|
-
function _arrayWithHoles(arr) {
|
|
8
|
-
if (Array.isArray(arr)) return arr;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _iterableToArrayLimit(arr, i) {
|
|
12
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
13
|
-
if (null != _i) {
|
|
14
|
-
var _s,
|
|
15
|
-
_e,
|
|
16
|
-
_x,
|
|
17
|
-
_r,
|
|
18
|
-
_arr = [],
|
|
19
|
-
_n = !0,
|
|
20
|
-
_d = !1;
|
|
21
|
-
try {
|
|
22
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
23
|
-
if (Object(_i) !== _i) return;
|
|
24
|
-
_n = !1;
|
|
25
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
_d = !0, _e = err;
|
|
28
|
-
} finally {
|
|
29
|
-
try {
|
|
30
|
-
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
31
|
-
} finally {
|
|
32
|
-
if (_d) throw _e;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return _arr;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _arrayLikeToArray(arr, len) {
|
|
40
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
41
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
42
|
-
return arr2;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
46
|
-
if (!o) return;
|
|
47
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
48
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
49
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
50
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
51
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function _nonIterableRest() {
|
|
55
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _slicedToArray(arr, i) {
|
|
59
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function _typeof(obj) {
|
|
63
|
-
"@babel/helpers - typeof";
|
|
64
|
-
|
|
65
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
66
|
-
return typeof obj;
|
|
67
|
-
} : function (obj) {
|
|
68
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
69
|
-
}, _typeof(obj);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/utils/env.ts
|
|
73
|
-
var NOTHING = Symbol.for("immer-nothing");
|
|
74
|
-
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
75
|
-
var DRAFT_STATE = Symbol.for("immer-state");
|
|
76
|
-
|
|
77
|
-
// src/utils/errors.ts
|
|
78
|
-
var errors = process.env.NODE_ENV !== "production" ? [
|
|
79
|
-
// All error codes, starting by 0:
|
|
80
|
-
function(plugin) {
|
|
81
|
-
return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
|
|
82
|
-
},
|
|
83
|
-
function(thing) {
|
|
84
|
-
return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
|
|
85
|
-
},
|
|
86
|
-
"This object has been frozen and should not be mutated",
|
|
87
|
-
function(data) {
|
|
88
|
-
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
|
|
89
|
-
},
|
|
90
|
-
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
91
|
-
"Immer forbids circular references",
|
|
92
|
-
"The first or second argument to `produce` must be a function",
|
|
93
|
-
"The third argument to `produce` must be a function or undefined",
|
|
94
|
-
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
95
|
-
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
96
|
-
function(thing) {
|
|
97
|
-
return `'current' expects a draft, got: ${thing}`;
|
|
98
|
-
},
|
|
99
|
-
"Object.defineProperty() cannot be used on an Immer draft",
|
|
100
|
-
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
101
|
-
"Immer only supports deleting array indices",
|
|
102
|
-
"Immer only supports setting array indices and the 'length' property",
|
|
103
|
-
function(thing) {
|
|
104
|
-
return `'original' expects a draft, got: ${thing}`;
|
|
105
|
-
}
|
|
106
|
-
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
107
|
-
// See Patches.ts for additional errors
|
|
108
|
-
] : [];
|
|
109
|
-
function die(error, ...args) {
|
|
110
|
-
if (process.env.NODE_ENV !== "production") {
|
|
111
|
-
const e = errors[error];
|
|
112
|
-
const msg = typeof e === "function" ? e.apply(null, args) : e;
|
|
113
|
-
throw new Error(`[Immer] ${msg}`);
|
|
114
|
-
}
|
|
115
|
-
throw new Error(
|
|
116
|
-
`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// src/utils/common.ts
|
|
121
|
-
var getPrototypeOf = Object.getPrototypeOf;
|
|
122
|
-
function isDraft(value) {
|
|
123
|
-
return !!value && !!value[DRAFT_STATE];
|
|
124
|
-
}
|
|
125
|
-
function isDraftable(value) {
|
|
126
|
-
if (!value)
|
|
127
|
-
return false;
|
|
128
|
-
return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
|
|
129
|
-
}
|
|
130
|
-
var objectCtorString = Object.prototype.constructor.toString();
|
|
131
|
-
function isPlainObject(value) {
|
|
132
|
-
if (!value || typeof value !== "object")
|
|
133
|
-
return false;
|
|
134
|
-
const proto = getPrototypeOf(value);
|
|
135
|
-
if (proto === null) {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
139
|
-
if (Ctor === Object)
|
|
140
|
-
return true;
|
|
141
|
-
return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
|
|
142
|
-
}
|
|
143
|
-
function each(obj, iter) {
|
|
144
|
-
if (getArchtype(obj) === 0 /* Object */) {
|
|
145
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
146
|
-
iter(key, value, obj);
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
obj.forEach((entry, index) => iter(index, entry, obj));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function getArchtype(thing) {
|
|
153
|
-
const state = thing[DRAFT_STATE];
|
|
154
|
-
return state ? state.type_ : Array.isArray(thing) ? 1 /* Array */ : isMap(thing) ? 2 /* Map */ : isSet(thing) ? 3 /* Set */ : 0 /* Object */;
|
|
155
|
-
}
|
|
156
|
-
function has(thing, prop) {
|
|
157
|
-
return getArchtype(thing) === 2 /* Map */ ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
|
|
158
|
-
}
|
|
159
|
-
function set(thing, propOrOldValue, value) {
|
|
160
|
-
const t = getArchtype(thing);
|
|
161
|
-
if (t === 2 /* Map */)
|
|
162
|
-
thing.set(propOrOldValue, value);
|
|
163
|
-
else if (t === 3 /* Set */) {
|
|
164
|
-
thing.add(value);
|
|
165
|
-
} else
|
|
166
|
-
thing[propOrOldValue] = value;
|
|
167
|
-
}
|
|
168
|
-
function is(x, y) {
|
|
169
|
-
if (x === y) {
|
|
170
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
171
|
-
} else {
|
|
172
|
-
return x !== x && y !== y;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function isMap(target) {
|
|
176
|
-
return target instanceof Map;
|
|
177
|
-
}
|
|
178
|
-
function isSet(target) {
|
|
179
|
-
return target instanceof Set;
|
|
180
|
-
}
|
|
181
|
-
function latest(state) {
|
|
182
|
-
return state.copy_ || state.base_;
|
|
183
|
-
}
|
|
184
|
-
function shallowCopy(base, strict) {
|
|
185
|
-
if (isMap(base)) {
|
|
186
|
-
return new Map(base);
|
|
187
|
-
}
|
|
188
|
-
if (isSet(base)) {
|
|
189
|
-
return new Set(base);
|
|
190
|
-
}
|
|
191
|
-
if (Array.isArray(base))
|
|
192
|
-
return Array.prototype.slice.call(base);
|
|
193
|
-
if (!strict && isPlainObject(base)) {
|
|
194
|
-
if (!getPrototypeOf(base)) {
|
|
195
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
196
|
-
return Object.assign(obj, base);
|
|
197
|
-
}
|
|
198
|
-
return { ...base };
|
|
199
|
-
}
|
|
200
|
-
const descriptors = Object.getOwnPropertyDescriptors(base);
|
|
201
|
-
delete descriptors[DRAFT_STATE];
|
|
202
|
-
let keys = Reflect.ownKeys(descriptors);
|
|
203
|
-
for (let i = 0; i < keys.length; i++) {
|
|
204
|
-
const key = keys[i];
|
|
205
|
-
const desc = descriptors[key];
|
|
206
|
-
if (desc.writable === false) {
|
|
207
|
-
desc.writable = true;
|
|
208
|
-
desc.configurable = true;
|
|
209
|
-
}
|
|
210
|
-
if (desc.get || desc.set)
|
|
211
|
-
descriptors[key] = {
|
|
212
|
-
configurable: true,
|
|
213
|
-
writable: true,
|
|
214
|
-
// could live with !!desc.set as well here...
|
|
215
|
-
enumerable: desc.enumerable,
|
|
216
|
-
value: base[key]
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
return Object.create(getPrototypeOf(base), descriptors);
|
|
220
|
-
}
|
|
221
|
-
function freeze(obj, deep = false) {
|
|
222
|
-
if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
|
|
223
|
-
return obj;
|
|
224
|
-
if (getArchtype(obj) > 1) {
|
|
225
|
-
obj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections;
|
|
226
|
-
}
|
|
227
|
-
Object.freeze(obj);
|
|
228
|
-
if (deep)
|
|
229
|
-
each(obj, (_key, value) => freeze(value, true));
|
|
230
|
-
return obj;
|
|
231
|
-
}
|
|
232
|
-
function dontMutateFrozenCollections() {
|
|
233
|
-
die(2);
|
|
234
|
-
}
|
|
235
|
-
function isFrozen(obj) {
|
|
236
|
-
return Object.isFrozen(obj);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/utils/plugins.ts
|
|
240
|
-
var plugins = {};
|
|
241
|
-
function getPlugin(pluginKey) {
|
|
242
|
-
const plugin = plugins[pluginKey];
|
|
243
|
-
if (!plugin) {
|
|
244
|
-
die(0, pluginKey);
|
|
245
|
-
}
|
|
246
|
-
return plugin;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// src/core/scope.ts
|
|
250
|
-
var currentScope;
|
|
251
|
-
function getCurrentScope() {
|
|
252
|
-
return currentScope;
|
|
253
|
-
}
|
|
254
|
-
function createScope(parent_, immer_) {
|
|
255
|
-
return {
|
|
256
|
-
drafts_: [],
|
|
257
|
-
parent_,
|
|
258
|
-
immer_,
|
|
259
|
-
// Whenever the modified draft contains a draft from another scope, we
|
|
260
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
261
|
-
canAutoFreeze_: true,
|
|
262
|
-
unfinalizedDrafts_: 0
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
function usePatchesInScope(scope, patchListener) {
|
|
266
|
-
if (patchListener) {
|
|
267
|
-
getPlugin("Patches");
|
|
268
|
-
scope.patches_ = [];
|
|
269
|
-
scope.inversePatches_ = [];
|
|
270
|
-
scope.patchListener_ = patchListener;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
function revokeScope(scope) {
|
|
274
|
-
leaveScope(scope);
|
|
275
|
-
scope.drafts_.forEach(revokeDraft);
|
|
276
|
-
scope.drafts_ = null;
|
|
277
|
-
}
|
|
278
|
-
function leaveScope(scope) {
|
|
279
|
-
if (scope === currentScope) {
|
|
280
|
-
currentScope = scope.parent_;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
function enterScope(immer2) {
|
|
284
|
-
return currentScope = createScope(currentScope, immer2);
|
|
285
|
-
}
|
|
286
|
-
function revokeDraft(draft) {
|
|
287
|
-
const state = draft[DRAFT_STATE];
|
|
288
|
-
if (state.type_ === 0 /* Object */ || state.type_ === 1 /* Array */)
|
|
289
|
-
state.revoke_();
|
|
290
|
-
else
|
|
291
|
-
state.revoked_ = true;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// src/core/finalize.ts
|
|
295
|
-
function processResult(result, scope) {
|
|
296
|
-
scope.unfinalizedDrafts_ = scope.drafts_.length;
|
|
297
|
-
const baseDraft = scope.drafts_[0];
|
|
298
|
-
const isReplaced = result !== void 0 && result !== baseDraft;
|
|
299
|
-
if (isReplaced) {
|
|
300
|
-
if (baseDraft[DRAFT_STATE].modified_) {
|
|
301
|
-
revokeScope(scope);
|
|
302
|
-
die(4);
|
|
303
|
-
}
|
|
304
|
-
if (isDraftable(result)) {
|
|
305
|
-
result = finalize(scope, result);
|
|
306
|
-
if (!scope.parent_)
|
|
307
|
-
maybeFreeze(scope, result);
|
|
308
|
-
}
|
|
309
|
-
if (scope.patches_) {
|
|
310
|
-
getPlugin("Patches").generateReplacementPatches_(
|
|
311
|
-
baseDraft[DRAFT_STATE].base_,
|
|
312
|
-
result,
|
|
313
|
-
scope.patches_,
|
|
314
|
-
scope.inversePatches_
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
result = finalize(scope, baseDraft, []);
|
|
319
|
-
}
|
|
320
|
-
revokeScope(scope);
|
|
321
|
-
if (scope.patches_) {
|
|
322
|
-
scope.patchListener_(scope.patches_, scope.inversePatches_);
|
|
323
|
-
}
|
|
324
|
-
return result !== NOTHING ? result : void 0;
|
|
325
|
-
}
|
|
326
|
-
function finalize(rootScope, value, path) {
|
|
327
|
-
if (isFrozen(value))
|
|
328
|
-
return value;
|
|
329
|
-
const state = value[DRAFT_STATE];
|
|
330
|
-
if (!state) {
|
|
331
|
-
each(
|
|
332
|
-
value,
|
|
333
|
-
(key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path));
|
|
334
|
-
return value;
|
|
335
|
-
}
|
|
336
|
-
if (state.scope_ !== rootScope)
|
|
337
|
-
return value;
|
|
338
|
-
if (!state.modified_) {
|
|
339
|
-
maybeFreeze(rootScope, state.base_, true);
|
|
340
|
-
return state.base_;
|
|
341
|
-
}
|
|
342
|
-
if (!state.finalized_) {
|
|
343
|
-
state.finalized_ = true;
|
|
344
|
-
state.scope_.unfinalizedDrafts_--;
|
|
345
|
-
const result = state.copy_;
|
|
346
|
-
let resultEach = result;
|
|
347
|
-
let isSet2 = false;
|
|
348
|
-
if (state.type_ === 3 /* Set */) {
|
|
349
|
-
resultEach = new Set(result);
|
|
350
|
-
result.clear();
|
|
351
|
-
isSet2 = true;
|
|
352
|
-
}
|
|
353
|
-
each(
|
|
354
|
-
resultEach,
|
|
355
|
-
(key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path, isSet2)
|
|
356
|
-
);
|
|
357
|
-
maybeFreeze(rootScope, result, false);
|
|
358
|
-
if (path && rootScope.patches_) {
|
|
359
|
-
getPlugin("Patches").generatePatches_(
|
|
360
|
-
state,
|
|
361
|
-
path,
|
|
362
|
-
rootScope.patches_,
|
|
363
|
-
rootScope.inversePatches_
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return state.copy_;
|
|
368
|
-
}
|
|
369
|
-
function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
|
|
370
|
-
if (process.env.NODE_ENV !== "production" && childValue === targetObject)
|
|
371
|
-
die(5);
|
|
372
|
-
if (isDraft(childValue)) {
|
|
373
|
-
const path = rootPath && parentState && parentState.type_ !== 3 /* Set */ && // Set objects are atomic since they have no keys.
|
|
374
|
-
!has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0;
|
|
375
|
-
const res = finalize(rootScope, childValue, path);
|
|
376
|
-
set(targetObject, prop, res);
|
|
377
|
-
if (isDraft(res)) {
|
|
378
|
-
rootScope.canAutoFreeze_ = false;
|
|
379
|
-
} else
|
|
380
|
-
return;
|
|
381
|
-
} else if (targetIsSet) {
|
|
382
|
-
targetObject.add(childValue);
|
|
383
|
-
}
|
|
384
|
-
if (isDraftable(childValue) && !isFrozen(childValue)) {
|
|
385
|
-
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
finalize(rootScope, childValue);
|
|
389
|
-
if (!parentState || !parentState.scope_.parent_)
|
|
390
|
-
maybeFreeze(rootScope, childValue);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function maybeFreeze(scope, value, deep = false) {
|
|
394
|
-
if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
|
|
395
|
-
freeze(value, deep);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// src/core/proxy.ts
|
|
400
|
-
function createProxyProxy(base, parent) {
|
|
401
|
-
const isArray = Array.isArray(base);
|
|
402
|
-
const state = {
|
|
403
|
-
type_: isArray ? 1 /* Array */ : 0 /* Object */,
|
|
404
|
-
// Track which produce call this is associated with.
|
|
405
|
-
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
406
|
-
// True for both shallow and deep changes.
|
|
407
|
-
modified_: false,
|
|
408
|
-
// Used during finalization.
|
|
409
|
-
finalized_: false,
|
|
410
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
411
|
-
assigned_: {},
|
|
412
|
-
// The parent draft state.
|
|
413
|
-
parent_: parent,
|
|
414
|
-
// The base state.
|
|
415
|
-
base_: base,
|
|
416
|
-
// The base proxy.
|
|
417
|
-
draft_: null,
|
|
418
|
-
// set below
|
|
419
|
-
// The base copy with any updated values.
|
|
420
|
-
copy_: null,
|
|
421
|
-
// Called by the `produce` function.
|
|
422
|
-
revoke_: null,
|
|
423
|
-
isManual_: false
|
|
424
|
-
};
|
|
425
|
-
let target = state;
|
|
426
|
-
let traps = objectTraps;
|
|
427
|
-
if (isArray) {
|
|
428
|
-
target = [state];
|
|
429
|
-
traps = arrayTraps;
|
|
430
|
-
}
|
|
431
|
-
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
432
|
-
state.draft_ = proxy;
|
|
433
|
-
state.revoke_ = revoke;
|
|
434
|
-
return proxy;
|
|
435
|
-
}
|
|
436
|
-
var objectTraps = {
|
|
437
|
-
get(state, prop) {
|
|
438
|
-
if (prop === DRAFT_STATE)
|
|
439
|
-
return state;
|
|
440
|
-
const source = latest(state);
|
|
441
|
-
if (!has(source, prop)) {
|
|
442
|
-
return readPropFromProto(state, source, prop);
|
|
443
|
-
}
|
|
444
|
-
const value = source[prop];
|
|
445
|
-
if (state.finalized_ || !isDraftable(value)) {
|
|
446
|
-
return value;
|
|
447
|
-
}
|
|
448
|
-
if (value === peek(state.base_, prop)) {
|
|
449
|
-
prepareCopy(state);
|
|
450
|
-
return state.copy_[prop] = createProxy(value, state);
|
|
451
|
-
}
|
|
452
|
-
return value;
|
|
453
|
-
},
|
|
454
|
-
has(state, prop) {
|
|
455
|
-
return prop in latest(state);
|
|
456
|
-
},
|
|
457
|
-
ownKeys(state) {
|
|
458
|
-
return Reflect.ownKeys(latest(state));
|
|
459
|
-
},
|
|
460
|
-
set(state, prop, value) {
|
|
461
|
-
const desc = getDescriptorFromProto(latest(state), prop);
|
|
462
|
-
if (desc?.set) {
|
|
463
|
-
desc.set.call(state.draft_, value);
|
|
464
|
-
return true;
|
|
465
|
-
}
|
|
466
|
-
if (!state.modified_) {
|
|
467
|
-
const current2 = peek(latest(state), prop);
|
|
468
|
-
const currentState = current2?.[DRAFT_STATE];
|
|
469
|
-
if (currentState && currentState.base_ === value) {
|
|
470
|
-
state.copy_[prop] = value;
|
|
471
|
-
state.assigned_[prop] = false;
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
if (is(value, current2) && (value !== void 0 || has(state.base_, prop)))
|
|
475
|
-
return true;
|
|
476
|
-
prepareCopy(state);
|
|
477
|
-
markChanged(state);
|
|
478
|
-
}
|
|
479
|
-
if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
|
|
480
|
-
(value !== void 0 || prop in state.copy_) || // special case: NaN
|
|
481
|
-
Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
|
|
482
|
-
return true;
|
|
483
|
-
state.copy_[prop] = value;
|
|
484
|
-
state.assigned_[prop] = true;
|
|
485
|
-
return true;
|
|
486
|
-
},
|
|
487
|
-
deleteProperty(state, prop) {
|
|
488
|
-
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
489
|
-
state.assigned_[prop] = false;
|
|
490
|
-
prepareCopy(state);
|
|
491
|
-
markChanged(state);
|
|
492
|
-
} else {
|
|
493
|
-
delete state.assigned_[prop];
|
|
494
|
-
}
|
|
495
|
-
if (state.copy_) {
|
|
496
|
-
delete state.copy_[prop];
|
|
497
|
-
}
|
|
498
|
-
return true;
|
|
499
|
-
},
|
|
500
|
-
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
501
|
-
// the same guarantee in ES5 mode.
|
|
502
|
-
getOwnPropertyDescriptor(state, prop) {
|
|
503
|
-
const owner = latest(state);
|
|
504
|
-
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
505
|
-
if (!desc)
|
|
506
|
-
return desc;
|
|
507
|
-
return {
|
|
508
|
-
writable: true,
|
|
509
|
-
configurable: state.type_ !== 1 /* Array */ || prop !== "length",
|
|
510
|
-
enumerable: desc.enumerable,
|
|
511
|
-
value: owner[prop]
|
|
512
|
-
};
|
|
513
|
-
},
|
|
514
|
-
defineProperty() {
|
|
515
|
-
die(11);
|
|
516
|
-
},
|
|
517
|
-
getPrototypeOf(state) {
|
|
518
|
-
return getPrototypeOf(state.base_);
|
|
519
|
-
},
|
|
520
|
-
setPrototypeOf() {
|
|
521
|
-
die(12);
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
var arrayTraps = {};
|
|
525
|
-
each(objectTraps, (key, fn) => {
|
|
526
|
-
arrayTraps[key] = function() {
|
|
527
|
-
arguments[0] = arguments[0][0];
|
|
528
|
-
return fn.apply(this, arguments);
|
|
529
|
-
};
|
|
530
|
-
});
|
|
531
|
-
arrayTraps.deleteProperty = function(state, prop) {
|
|
532
|
-
if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
|
|
533
|
-
die(13);
|
|
534
|
-
return arrayTraps.set.call(this, state, prop, void 0);
|
|
535
|
-
};
|
|
536
|
-
arrayTraps.set = function(state, prop, value) {
|
|
537
|
-
if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
|
|
538
|
-
die(14);
|
|
539
|
-
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
540
|
-
};
|
|
541
|
-
function peek(draft, prop) {
|
|
542
|
-
const state = draft[DRAFT_STATE];
|
|
543
|
-
const source = state ? latest(state) : draft;
|
|
544
|
-
return source[prop];
|
|
545
|
-
}
|
|
546
|
-
function readPropFromProto(state, source, prop) {
|
|
547
|
-
const desc = getDescriptorFromProto(source, prop);
|
|
548
|
-
return desc ? `value` in desc ? desc.value : (
|
|
549
|
-
// This is a very special case, if the prop is a getter defined by the
|
|
550
|
-
// prototype, we should invoke it with the draft as context!
|
|
551
|
-
desc.get?.call(state.draft_)
|
|
552
|
-
) : void 0;
|
|
553
|
-
}
|
|
554
|
-
function getDescriptorFromProto(source, prop) {
|
|
555
|
-
if (!(prop in source))
|
|
556
|
-
return void 0;
|
|
557
|
-
let proto = getPrototypeOf(source);
|
|
558
|
-
while (proto) {
|
|
559
|
-
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
560
|
-
if (desc)
|
|
561
|
-
return desc;
|
|
562
|
-
proto = getPrototypeOf(proto);
|
|
563
|
-
}
|
|
564
|
-
return void 0;
|
|
565
|
-
}
|
|
566
|
-
function markChanged(state) {
|
|
567
|
-
if (!state.modified_) {
|
|
568
|
-
state.modified_ = true;
|
|
569
|
-
if (state.parent_) {
|
|
570
|
-
markChanged(state.parent_);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
function prepareCopy(state) {
|
|
575
|
-
if (!state.copy_) {
|
|
576
|
-
state.copy_ = shallowCopy(
|
|
577
|
-
state.base_,
|
|
578
|
-
state.scope_.immer_.useStrictShallowCopy_
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// src/core/immerClass.ts
|
|
584
|
-
var Immer2 = class {
|
|
585
|
-
constructor(config) {
|
|
586
|
-
this.autoFreeze_ = true;
|
|
587
|
-
this.useStrictShallowCopy_ = false;
|
|
588
|
-
/**
|
|
589
|
-
* The `produce` function takes a value and a "recipe function" (whose
|
|
590
|
-
* return value often depends on the base state). The recipe function is
|
|
591
|
-
* free to mutate its first argument however it wants. All mutations are
|
|
592
|
-
* only ever applied to a __copy__ of the base state.
|
|
593
|
-
*
|
|
594
|
-
* Pass only a function to create a "curried producer" which relieves you
|
|
595
|
-
* from passing the recipe function every time.
|
|
596
|
-
*
|
|
597
|
-
* Only plain objects and arrays are made mutable. All other objects are
|
|
598
|
-
* considered uncopyable.
|
|
599
|
-
*
|
|
600
|
-
* Note: This function is __bound__ to its `Immer` instance.
|
|
601
|
-
*
|
|
602
|
-
* @param {any} base - the initial state
|
|
603
|
-
* @param {Function} recipe - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
604
|
-
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
605
|
-
* @returns {any} a new state, or the initial state if nothing was modified
|
|
606
|
-
*/
|
|
607
|
-
this.produce = (base, recipe, patchListener) => {
|
|
608
|
-
if (typeof base === "function" && typeof recipe !== "function") {
|
|
609
|
-
const defaultBase = recipe;
|
|
610
|
-
recipe = base;
|
|
611
|
-
const self = this;
|
|
612
|
-
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
613
|
-
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
if (typeof recipe !== "function")
|
|
617
|
-
die(6);
|
|
618
|
-
if (patchListener !== void 0 && typeof patchListener !== "function")
|
|
619
|
-
die(7);
|
|
620
|
-
let result;
|
|
621
|
-
if (isDraftable(base)) {
|
|
622
|
-
const scope = enterScope(this);
|
|
623
|
-
const proxy = createProxy(base, void 0);
|
|
624
|
-
let hasError = true;
|
|
625
|
-
try {
|
|
626
|
-
result = recipe(proxy);
|
|
627
|
-
hasError = false;
|
|
628
|
-
} finally {
|
|
629
|
-
if (hasError)
|
|
630
|
-
revokeScope(scope);
|
|
631
|
-
else
|
|
632
|
-
leaveScope(scope);
|
|
633
|
-
}
|
|
634
|
-
usePatchesInScope(scope, patchListener);
|
|
635
|
-
return processResult(result, scope);
|
|
636
|
-
} else if (!base || typeof base !== "object") {
|
|
637
|
-
result = recipe(base);
|
|
638
|
-
if (result === void 0)
|
|
639
|
-
result = base;
|
|
640
|
-
if (result === NOTHING)
|
|
641
|
-
result = void 0;
|
|
642
|
-
if (this.autoFreeze_)
|
|
643
|
-
freeze(result, true);
|
|
644
|
-
if (patchListener) {
|
|
645
|
-
const p = [];
|
|
646
|
-
const ip = [];
|
|
647
|
-
getPlugin("Patches").generateReplacementPatches_(base, result, p, ip);
|
|
648
|
-
patchListener(p, ip);
|
|
649
|
-
}
|
|
650
|
-
return result;
|
|
651
|
-
} else
|
|
652
|
-
die(1, base);
|
|
653
|
-
};
|
|
654
|
-
this.produceWithPatches = (base, recipe) => {
|
|
655
|
-
if (typeof base === "function") {
|
|
656
|
-
return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
657
|
-
}
|
|
658
|
-
let patches, inversePatches;
|
|
659
|
-
const result = this.produce(base, recipe, (p, ip) => {
|
|
660
|
-
patches = p;
|
|
661
|
-
inversePatches = ip;
|
|
662
|
-
});
|
|
663
|
-
return [result, patches, inversePatches];
|
|
664
|
-
};
|
|
665
|
-
if (typeof config?.autoFreeze === "boolean")
|
|
666
|
-
this.setAutoFreeze(config.autoFreeze);
|
|
667
|
-
if (typeof config?.useStrictShallowCopy === "boolean")
|
|
668
|
-
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
669
|
-
}
|
|
670
|
-
createDraft(base) {
|
|
671
|
-
if (!isDraftable(base))
|
|
672
|
-
die(8);
|
|
673
|
-
if (isDraft(base))
|
|
674
|
-
base = current(base);
|
|
675
|
-
const scope = enterScope(this);
|
|
676
|
-
const proxy = createProxy(base, void 0);
|
|
677
|
-
proxy[DRAFT_STATE].isManual_ = true;
|
|
678
|
-
leaveScope(scope);
|
|
679
|
-
return proxy;
|
|
680
|
-
}
|
|
681
|
-
finishDraft(draft, patchListener) {
|
|
682
|
-
const state = draft && draft[DRAFT_STATE];
|
|
683
|
-
if (!state || !state.isManual_)
|
|
684
|
-
die(9);
|
|
685
|
-
const { scope_: scope } = state;
|
|
686
|
-
usePatchesInScope(scope, patchListener);
|
|
687
|
-
return processResult(void 0, scope);
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
691
|
-
*
|
|
692
|
-
* By default, auto-freezing is enabled.
|
|
693
|
-
*/
|
|
694
|
-
setAutoFreeze(value) {
|
|
695
|
-
this.autoFreeze_ = value;
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Pass true to enable strict shallow copy.
|
|
699
|
-
*
|
|
700
|
-
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
701
|
-
*/
|
|
702
|
-
setUseStrictShallowCopy(value) {
|
|
703
|
-
this.useStrictShallowCopy_ = value;
|
|
704
|
-
}
|
|
705
|
-
applyPatches(base, patches) {
|
|
706
|
-
let i;
|
|
707
|
-
for (i = patches.length - 1; i >= 0; i--) {
|
|
708
|
-
const patch = patches[i];
|
|
709
|
-
if (patch.path.length === 0 && patch.op === "replace") {
|
|
710
|
-
base = patch.value;
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
if (i > -1) {
|
|
715
|
-
patches = patches.slice(i + 1);
|
|
716
|
-
}
|
|
717
|
-
const applyPatchesImpl = getPlugin("Patches").applyPatches_;
|
|
718
|
-
if (isDraft(base)) {
|
|
719
|
-
return applyPatchesImpl(base, patches);
|
|
720
|
-
}
|
|
721
|
-
return this.produce(
|
|
722
|
-
base,
|
|
723
|
-
(draft) => applyPatchesImpl(draft, patches)
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
function createProxy(value, parent) {
|
|
728
|
-
const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
|
|
729
|
-
const scope = parent ? parent.scope_ : getCurrentScope();
|
|
730
|
-
scope.drafts_.push(draft);
|
|
731
|
-
return draft;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// src/core/current.ts
|
|
735
|
-
function current(value) {
|
|
736
|
-
if (!isDraft(value))
|
|
737
|
-
die(10, value);
|
|
738
|
-
return currentImpl(value);
|
|
739
|
-
}
|
|
740
|
-
function currentImpl(value) {
|
|
741
|
-
if (!isDraftable(value) || isFrozen(value))
|
|
742
|
-
return value;
|
|
743
|
-
const state = value[DRAFT_STATE];
|
|
744
|
-
let copy;
|
|
745
|
-
if (state) {
|
|
746
|
-
if (!state.modified_)
|
|
747
|
-
return state.base_;
|
|
748
|
-
state.finalized_ = true;
|
|
749
|
-
copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
750
|
-
} else {
|
|
751
|
-
copy = shallowCopy(value, true);
|
|
752
|
-
}
|
|
753
|
-
each(copy, (key, childValue) => {
|
|
754
|
-
set(copy, key, currentImpl(childValue));
|
|
755
|
-
});
|
|
756
|
-
if (state) {
|
|
757
|
-
state.finalized_ = false;
|
|
758
|
-
}
|
|
759
|
-
return copy;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// src/immer.ts
|
|
763
|
-
var immer = new Immer2();
|
|
764
|
-
var produce = immer.produce;
|
|
765
|
-
immer.produceWithPatches.bind(
|
|
766
|
-
immer
|
|
767
|
-
);
|
|
768
|
-
immer.setAutoFreeze.bind(immer);
|
|
769
|
-
immer.setUseStrictShallowCopy.bind(immer);
|
|
770
|
-
immer.applyPatches.bind(immer);
|
|
771
|
-
immer.createDraft.bind(immer);
|
|
772
|
-
immer.finishDraft.bind(immer);
|
|
773
|
-
|
|
774
|
-
/* eslint-disable @bigbinary/neeto/neetocommons-tips */
|
|
775
|
-
|
|
776
|
-
/**
|
|
777
|
-
* @template {Function} T
|
|
778
|
-
* @param {T} func
|
|
779
|
-
* @returns {T}
|
|
780
|
-
*/
|
|
781
|
-
var nullSafe = function nullSafe(func) {
|
|
782
|
-
return (
|
|
783
|
-
// @ts-ignore
|
|
784
|
-
ramda.curryN(func.length, function () {
|
|
785
|
-
var _ref;
|
|
786
|
-
var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref]);
|
|
787
|
-
return ramda.isNil(dataArg) ? dataArg : func.apply(void 0, arguments);
|
|
788
|
-
})
|
|
789
|
-
);
|
|
790
|
-
};
|
|
791
|
-
var noop = function noop() {};
|
|
792
|
-
var toLabelAndValue = function toLabelAndValue(string) {
|
|
793
|
-
return {
|
|
794
|
-
label: string,
|
|
795
|
-
value: string
|
|
796
|
-
};
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
// eslint-disable-next-line default-param-last
|
|
800
|
-
var getRandomInt = function getRandomInt() {
|
|
801
|
-
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
|
|
802
|
-
var b = arguments.length > 1 ? arguments[1] : undefined;
|
|
803
|
-
if (b) {
|
|
804
|
-
a = Math.ceil(a);
|
|
805
|
-
b = Math.floor(b);
|
|
806
|
-
} else {
|
|
807
|
-
b = a;
|
|
808
|
-
a = 0;
|
|
809
|
-
}
|
|
810
|
-
return Math.floor(Math.random() * (b - a) + a);
|
|
811
|
-
};
|
|
812
|
-
var randomPick = function randomPick() {
|
|
813
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
814
|
-
args[_key] = arguments[_key];
|
|
815
|
-
}
|
|
816
|
-
var randomNumber = getRandomInt(0, args.length);
|
|
817
|
-
return args[randomNumber];
|
|
818
|
-
};
|
|
819
|
-
var dynamicArray = function dynamicArray(count, elementGenerator) {
|
|
820
|
-
return Array.from({
|
|
821
|
-
length: count
|
|
822
|
-
}, function (_, index) {
|
|
823
|
-
return elementGenerator(index);
|
|
824
|
-
});
|
|
825
|
-
};
|
|
826
|
-
var isNotEmpty = /*#__PURE__*/ramda.complement(ramda.isEmpty);
|
|
827
|
-
var notEquals = /*#__PURE__*/ramda.curry(function (x, y) {
|
|
828
|
-
return x !== y;
|
|
829
|
-
});
|
|
830
|
-
var isNot = notEquals;
|
|
831
|
-
var isNotPresent = /*#__PURE__*/ramda.either(ramda.isNil, ramda.isEmpty);
|
|
832
|
-
var isPresent = /*#__PURE__*/ramda.complement(isNotPresent);
|
|
833
|
-
var notEqualsDeep = /*#__PURE__*/ramda.complement(ramda.equals);
|
|
834
|
-
var isNotEqualDeep = notEqualsDeep;
|
|
835
|
-
var modifyWithImmer = /*#__PURE__*/ramda.curry(function (modifier, data) {
|
|
836
|
-
return produce(data, modifier);
|
|
837
|
-
});
|
|
838
|
-
|
|
839
|
-
/* eslint-disable @bigbinary/neeto/neetocommons-tips */
|
|
840
|
-
var slugify = function slugify(string) {
|
|
841
|
-
return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
|
|
842
|
-
.replace(/&/g, "-and-") // Replace & with 'and'
|
|
843
|
-
.replace(/[^\w-]+/g, "") // Remove all non-word characters
|
|
844
|
-
.replace(/--+/g, "-") // Replace multiple - with single -
|
|
845
|
-
.replace(/^-+/, "") // Trim - from start of text
|
|
846
|
-
.replace(/-+$/, "");
|
|
847
|
-
}; // Trim - from end of text
|
|
848
|
-
|
|
849
|
-
var humanize = function humanize(string) {
|
|
850
|
-
string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
|
|
851
|
-
string = string.charAt(0).toUpperCase() + string.slice(1);
|
|
852
|
-
return string;
|
|
853
|
-
};
|
|
854
|
-
var snakeToCamelCase = function snakeToCamelCase(string) {
|
|
855
|
-
return string.replace(/(_\w)/g, function (letter) {
|
|
856
|
-
return letter[1].toUpperCase();
|
|
857
|
-
});
|
|
858
|
-
};
|
|
859
|
-
var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
860
|
-
return string.replace(/[A-Z]/g, function (letter) {
|
|
861
|
-
return "_".concat(letter.toLowerCase());
|
|
862
|
-
});
|
|
863
|
-
};
|
|
864
|
-
var capitalize = function capitalize(string) {
|
|
865
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
866
|
-
};
|
|
867
|
-
var truncate = function truncate(string, length) {
|
|
868
|
-
return string.length > length ? ramda.concat(ramda.slice(0, length, string), "...") : string;
|
|
869
|
-
};
|
|
870
|
-
var _slugify = /*#__PURE__*/nullSafe(slugify);
|
|
871
|
-
var _humanize = /*#__PURE__*/nullSafe(humanize);
|
|
872
|
-
var _snakeToCamelCase = /*#__PURE__*/nullSafe(snakeToCamelCase);
|
|
873
|
-
var _camelToSnakeCase = /*#__PURE__*/nullSafe(camelToSnakeCase);
|
|
874
|
-
var _capitalize = /*#__PURE__*/nullSafe(capitalize);
|
|
875
|
-
var _truncate = function _truncate(string, length) {
|
|
876
|
-
return ramda.isNil(string) ? string : truncate(string, length);
|
|
877
|
-
};
|
|
878
|
-
|
|
879
|
-
var matchesImpl = function matchesImpl(pattern, object) {
|
|
880
|
-
var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
881
|
-
if (object === pattern) return true;
|
|
882
|
-
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
883
|
-
if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
|
|
884
|
-
if (_typeof(pattern) !== "object") return false;
|
|
885
|
-
return Object.entries(pattern).every(function (_ref) {
|
|
886
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
887
|
-
key = _ref2[0],
|
|
888
|
-
value = _ref2[1];
|
|
889
|
-
return matchesImpl(value, object[key], __parent);
|
|
890
|
-
});
|
|
891
|
-
};
|
|
892
|
-
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
893
|
-
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
894
|
-
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
895
|
-
object = objectPreProcessor(object);
|
|
896
|
-
}
|
|
897
|
-
if (Array.isArray(object)) {
|
|
898
|
-
return object.map(function (obj) {
|
|
899
|
-
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
900
|
-
});
|
|
901
|
-
} else if (object === null || _typeof(object) !== "object") {
|
|
902
|
-
return object;
|
|
903
|
-
}
|
|
904
|
-
return Object.fromEntries(Object.entries(object).map(function (_ref3) {
|
|
905
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
906
|
-
key = _ref4[0],
|
|
907
|
-
value = _ref4[1];
|
|
908
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
909
|
-
}));
|
|
910
|
-
};
|
|
911
|
-
var keysToCamelCase = function keysToCamelCase(object) {
|
|
912
|
-
return transformObjectDeep(object, function (key, value) {
|
|
913
|
-
return [snakeToCamelCase(key), value];
|
|
914
|
-
});
|
|
915
|
-
};
|
|
916
|
-
var keysToSnakeCase = function keysToSnakeCase(object) {
|
|
917
|
-
return transformObjectDeep(object, function (key, value) {
|
|
918
|
-
return [camelToSnakeCase(key), value];
|
|
919
|
-
});
|
|
920
|
-
};
|
|
921
|
-
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
922
|
-
return transformObjectDeep(object, function (key, value) {
|
|
923
|
-
return [camelToSnakeCase(key), value];
|
|
924
|
-
}, function (object) {
|
|
925
|
-
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
926
|
-
});
|
|
927
|
-
};
|
|
928
|
-
var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
929
|
-
return transformObjectDeep(object, function (key, value) {
|
|
930
|
-
return [key, value];
|
|
931
|
-
}, function (object) {
|
|
932
|
-
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
933
|
-
});
|
|
934
|
-
};
|
|
935
|
-
var deepFreezeObject = function deepFreezeObject(object) {
|
|
936
|
-
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
|
937
|
-
Object.keys(object).forEach(function (property) {
|
|
938
|
-
return deepFreezeObject(object[property]);
|
|
939
|
-
});
|
|
940
|
-
Object.freeze(object);
|
|
941
|
-
}
|
|
942
|
-
return object;
|
|
943
|
-
};
|
|
944
|
-
var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
|
|
945
|
-
return matchesImpl(pattern, object);
|
|
946
|
-
});
|
|
947
|
-
var filterNonNull = function filterNonNull(object) {
|
|
948
|
-
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
949
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
950
|
-
v = _ref6[1];
|
|
951
|
-
return !ramda.isNil(v);
|
|
952
|
-
}).map(function (_ref7) {
|
|
953
|
-
var _ref8 = _slicedToArray(_ref7, 2),
|
|
954
|
-
k = _ref8[0],
|
|
955
|
-
v = _ref8[1];
|
|
956
|
-
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
957
|
-
}));
|
|
958
|
-
};
|
|
959
|
-
var _filterNonNull = nullSafe(filterNonNull);
|
|
960
|
-
|
|
961
|
-
function _toPrimitive(input, hint) {
|
|
962
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
963
|
-
var prim = input[Symbol.toPrimitive];
|
|
964
|
-
if (prim !== undefined) {
|
|
965
|
-
var res = prim.call(input, hint || "default");
|
|
966
|
-
if (_typeof(res) !== "object") return res;
|
|
967
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
968
|
-
}
|
|
969
|
-
return (hint === "string" ? String : Number)(input);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
function _toPropertyKey(arg) {
|
|
973
|
-
var key = _toPrimitive(arg, "string");
|
|
974
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
function _defineProperty(obj, key, value) {
|
|
978
|
-
key = _toPropertyKey(key);
|
|
979
|
-
if (key in obj) {
|
|
980
|
-
Object.defineProperty(obj, key, {
|
|
981
|
-
value: value,
|
|
982
|
-
enumerable: true,
|
|
983
|
-
configurable: true,
|
|
984
|
-
writable: true
|
|
985
|
-
});
|
|
986
|
-
} else {
|
|
987
|
-
obj[key] = value;
|
|
988
|
-
}
|
|
989
|
-
return obj;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
993
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
994
|
-
var removeById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
995
|
-
return array.filter(function (item) {
|
|
996
|
-
return item.id !== id;
|
|
997
|
-
});
|
|
998
|
-
});
|
|
999
|
-
var findById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
1000
|
-
return array.find(function (item) {
|
|
1001
|
-
return item.id === id;
|
|
1002
|
-
});
|
|
1003
|
-
});
|
|
1004
|
-
var replaceById = /*#__PURE__*/ramda.curry(function (id, newItem, array) {
|
|
1005
|
-
return array.map(function (item) {
|
|
1006
|
-
return item.id === id ? newItem : item;
|
|
1007
|
-
});
|
|
1008
|
-
});
|
|
1009
|
-
var modifyById = /*#__PURE__*/ramda.curry(function (id, modifier, array) {
|
|
1010
|
-
return array.map(function (item) {
|
|
1011
|
-
return item.id === id ? modifier(item) : item;
|
|
1012
|
-
});
|
|
1013
|
-
});
|
|
1014
|
-
var findBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1015
|
-
return array.find(matches(pattern));
|
|
1016
|
-
});
|
|
1017
|
-
var removeBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1018
|
-
return array.filter(ramda.complement(matches(pattern)));
|
|
1019
|
-
});
|
|
1020
|
-
var replaceBy = /*#__PURE__*/ramda.curry(function (pattern, newItem, array) {
|
|
1021
|
-
return array.map(function (item) {
|
|
1022
|
-
return matches(pattern, item) ? newItem : item;
|
|
1023
|
-
});
|
|
1024
|
-
});
|
|
1025
|
-
var modifyBy = /*#__PURE__*/ramda.curry(function (pattern, modifier, array) {
|
|
1026
|
-
return array.map(function (item) {
|
|
1027
|
-
return matches(pattern, item) ? modifier(item) : item;
|
|
1028
|
-
});
|
|
1029
|
-
});
|
|
1030
|
-
var existsById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
1031
|
-
return array.some(function (item) {
|
|
1032
|
-
return item.id === id;
|
|
1033
|
-
});
|
|
1034
|
-
});
|
|
1035
|
-
var existsBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1036
|
-
return array.some(matches(pattern));
|
|
1037
|
-
});
|
|
1038
|
-
var findLastBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1039
|
-
return ramda.findLast(matches(pattern), array);
|
|
1040
|
-
});
|
|
1041
|
-
var findIndexById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
1042
|
-
return array.findIndex(function (item) {
|
|
1043
|
-
return item.id === id;
|
|
1044
|
-
});
|
|
1045
|
-
});
|
|
1046
|
-
var findIndexBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1047
|
-
return array.findIndex(matches(pattern));
|
|
1048
|
-
});
|
|
1049
|
-
var findLastIndexBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1050
|
-
return ramda.findLastIndex(matches(pattern), array);
|
|
1051
|
-
});
|
|
1052
|
-
var filterBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1053
|
-
return array.filter(matches(pattern));
|
|
1054
|
-
});
|
|
1055
|
-
var countBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
1056
|
-
return ramda.count(matches(pattern), array);
|
|
1057
|
-
});
|
|
1058
|
-
var copyKeys = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
|
|
1059
|
-
return objectArray.map(function (object) {
|
|
1060
|
-
var shallowCopy = _objectSpread({}, object);
|
|
1061
|
-
for (var source in keyMap) {
|
|
1062
|
-
shallowCopy[keyMap[source]] = object[source];
|
|
1063
|
-
}
|
|
1064
|
-
return shallowCopy;
|
|
1065
|
-
});
|
|
1066
|
-
});
|
|
1067
|
-
var renameKeys = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
|
|
1068
|
-
return objectArray.map(function (object) {
|
|
1069
|
-
var shallowCopy = _objectSpread({}, object);
|
|
1070
|
-
for (var source in keyMap) {
|
|
1071
|
-
shallowCopy[keyMap[source]] = object[source];
|
|
1072
|
-
delete shallowCopy[source];
|
|
1073
|
-
}
|
|
1074
|
-
return shallowCopy;
|
|
1075
|
-
});
|
|
1076
|
-
});
|
|
1077
|
-
var copyKeysDeep = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
|
|
1078
|
-
var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
|
|
1079
|
-
var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
1080
|
-
return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
|
|
1081
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
1082
|
-
destination = _ref2[0],
|
|
1083
|
-
source = _ref2[1];
|
|
1084
|
-
if (typeof source === "function") {
|
|
1085
|
-
return [destination, source(object[destination], root)];
|
|
1086
|
-
} else if (Array.isArray(source)) {
|
|
1087
|
-
return [destination, ramda.path(source, root)];
|
|
1088
|
-
} else if (_typeof(source) === "object") {
|
|
1089
|
-
return [destination, copyKeysSingleObject(object[destination], source, root)];
|
|
1090
|
-
}
|
|
1091
|
-
return [destination, object[source]];
|
|
1092
|
-
})));
|
|
1093
|
-
};
|
|
1094
|
-
return objectArray.map(function (object) {
|
|
1095
|
-
return copyKeysSingleObject(object, keyMap);
|
|
1096
|
-
});
|
|
1097
|
-
});
|
|
1098
|
-
var _removeById = /*#__PURE__*/nullSafe(removeById);
|
|
1099
|
-
var _findById = /*#__PURE__*/nullSafe(findById);
|
|
1100
|
-
var _replaceById = /*#__PURE__*/nullSafe(replaceById);
|
|
1101
|
-
var _modifyById = /*#__PURE__*/nullSafe(modifyById);
|
|
1102
|
-
var _findBy = /*#__PURE__*/nullSafe(findBy);
|
|
1103
|
-
var _removeBy = /*#__PURE__*/nullSafe(removeBy);
|
|
1104
|
-
var _replaceBy = /*#__PURE__*/nullSafe(replaceBy);
|
|
1105
|
-
var _modifyBy = /*#__PURE__*/nullSafe(modifyBy);
|
|
1106
|
-
var _existsById = /*#__PURE__*/nullSafe(existsById);
|
|
1107
|
-
var _existsBy = /*#__PURE__*/nullSafe(existsBy);
|
|
1108
|
-
var _findLastBy = /*#__PURE__*/nullSafe(findLastBy);
|
|
1109
|
-
var _findIndexById = /*#__PURE__*/nullSafe(findIndexById);
|
|
1110
|
-
var _findIndexBy = /*#__PURE__*/nullSafe(findIndexBy);
|
|
1111
|
-
var _findLastIndexBy = /*#__PURE__*/nullSafe(findLastIndexBy);
|
|
1112
|
-
var _filterBy = /*#__PURE__*/nullSafe(filterBy);
|
|
1113
|
-
var _countBy = /*#__PURE__*/nullSafe(countBy);
|
|
1114
|
-
var _copyKeys = /*#__PURE__*/nullSafe(copyKeys);
|
|
1115
|
-
var _renameKeys = /*#__PURE__*/nullSafe(renameKeys);
|
|
1116
|
-
var _copyKeysDeep = /*#__PURE__*/nullSafe(copyKeysDeep);
|
|
1117
|
-
|
|
1118
|
-
exports._camelToSnakeCase = _camelToSnakeCase;
|
|
1119
|
-
exports._capitalize = _capitalize;
|
|
1120
|
-
exports._copyKeys = _copyKeys;
|
|
1121
|
-
exports._copyKeysDeep = _copyKeysDeep;
|
|
1122
|
-
exports._countBy = _countBy;
|
|
1123
|
-
exports._existsBy = _existsBy;
|
|
1124
|
-
exports._existsById = _existsById;
|
|
1125
|
-
exports._filterBy = _filterBy;
|
|
1126
|
-
exports._filterNonNull = _filterNonNull;
|
|
1127
|
-
exports._findBy = _findBy;
|
|
1128
|
-
exports._findById = _findById;
|
|
1129
|
-
exports._findIndexBy = _findIndexBy;
|
|
1130
|
-
exports._findIndexById = _findIndexById;
|
|
1131
|
-
exports._findLastBy = _findLastBy;
|
|
1132
|
-
exports._findLastIndexBy = _findLastIndexBy;
|
|
1133
|
-
exports._humanize = _humanize;
|
|
1134
|
-
exports._modifyBy = _modifyBy;
|
|
1135
|
-
exports._modifyById = _modifyById;
|
|
1136
|
-
exports._removeBy = _removeBy;
|
|
1137
|
-
exports._removeById = _removeById;
|
|
1138
|
-
exports._renameKeys = _renameKeys;
|
|
1139
|
-
exports._replaceBy = _replaceBy;
|
|
1140
|
-
exports._replaceById = _replaceById;
|
|
1141
|
-
exports._slugify = _slugify;
|
|
1142
|
-
exports._snakeToCamelCase = _snakeToCamelCase;
|
|
1143
|
-
exports._truncate = _truncate;
|
|
1144
|
-
exports.camelToSnakeCase = camelToSnakeCase;
|
|
1145
|
-
exports.capitalize = capitalize;
|
|
1146
|
-
exports.copyKeys = copyKeys;
|
|
1147
|
-
exports.copyKeysDeep = copyKeysDeep;
|
|
1148
|
-
exports.countBy = countBy;
|
|
1149
|
-
exports.deepFreezeObject = deepFreezeObject;
|
|
1150
|
-
exports.dynamicArray = dynamicArray;
|
|
1151
|
-
exports.existsBy = existsBy;
|
|
1152
|
-
exports.existsById = existsById;
|
|
1153
|
-
exports.filterBy = filterBy;
|
|
1154
|
-
exports.filterNonNull = filterNonNull;
|
|
1155
|
-
exports.findBy = findBy;
|
|
1156
|
-
exports.findById = findById;
|
|
1157
|
-
exports.findIndexBy = findIndexBy;
|
|
1158
|
-
exports.findIndexById = findIndexById;
|
|
1159
|
-
exports.findLastBy = findLastBy;
|
|
1160
|
-
exports.findLastIndexBy = findLastIndexBy;
|
|
1161
|
-
exports.getRandomInt = getRandomInt;
|
|
1162
|
-
exports.humanize = humanize;
|
|
1163
|
-
exports.isNot = isNot;
|
|
1164
|
-
exports.isNotEmpty = isNotEmpty;
|
|
1165
|
-
exports.isNotEqualDeep = isNotEqualDeep;
|
|
1166
|
-
exports.isNotPresent = isNotPresent;
|
|
1167
|
-
exports.isPresent = isPresent;
|
|
1168
|
-
exports.keysToCamelCase = keysToCamelCase;
|
|
1169
|
-
exports.keysToSnakeCase = keysToSnakeCase;
|
|
1170
|
-
exports.matches = matches;
|
|
1171
|
-
exports.modifyBy = modifyBy;
|
|
1172
|
-
exports.modifyById = modifyById;
|
|
1173
|
-
exports.modifyWithImmer = modifyWithImmer;
|
|
1174
|
-
exports.noop = noop;
|
|
1175
|
-
exports.notEquals = notEquals;
|
|
1176
|
-
exports.notEqualsDeep = notEqualsDeep;
|
|
1177
|
-
exports.nullSafe = nullSafe;
|
|
1178
|
-
exports.preprocessForSerialization = preprocessForSerialization;
|
|
1179
|
-
exports.randomPick = randomPick;
|
|
1180
|
-
exports.removeBy = removeBy;
|
|
1181
|
-
exports.removeById = removeById;
|
|
1182
|
-
exports.renameKeys = renameKeys;
|
|
1183
|
-
exports.replaceBy = replaceBy;
|
|
1184
|
-
exports.replaceById = replaceById;
|
|
1185
|
-
exports.serializeKeysToSnakeCase = serializeKeysToSnakeCase;
|
|
1186
|
-
exports.slugify = slugify;
|
|
1187
|
-
exports.snakeToCamelCase = snakeToCamelCase;
|
|
1188
|
-
exports.toLabelAndValue = toLabelAndValue;
|
|
1189
|
-
exports.transformObjectDeep = transformObjectDeep;
|
|
1190
|
-
exports.truncate = truncate;
|
|
1191
|
-
//# sourceMappingURL=pure.cjs.js.map
|