tinybase 7.2.0-beta.3 → 7.2.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/index.js +58 -31
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +41 -32
- package/omni/with-schemas/index.js +41 -32
- package/package.json +3 -3
- package/queries/index.js +77 -40
- package/queries/with-schemas/index.js +77 -40
- package/readme.md +13 -13
- package/releases.md +40 -40
- package/ui-react/index.js +4 -1
- package/ui-react/with-schemas/index.js +4 -1
- package/ui-react-dom/index.js +4 -1
- package/ui-react-dom/with-schemas/index.js +4 -1
- package/ui-react-inspector/index.js +4 -1
- package/ui-react-inspector/with-schemas/index.js +4 -1
- package/with-schemas/index.js +58 -31
package/ui-react/index.js
CHANGED
|
@@ -91,6 +91,8 @@ const objDel = (obj, id) => {
|
|
|
91
91
|
return obj;
|
|
92
92
|
};
|
|
93
93
|
const objSize = (obj) => size(objIds(obj));
|
|
94
|
+
|
|
95
|
+
/* istanbul ignore next */
|
|
94
96
|
const objIsEqual = (
|
|
95
97
|
obj1,
|
|
96
98
|
obj2,
|
|
@@ -101,7 +103,8 @@ const objIsEqual = (
|
|
|
101
103
|
size(entries1) === objSize(obj2) &&
|
|
102
104
|
arrayEvery(entries1, ([index, value1]) =>
|
|
103
105
|
isObject(value1)
|
|
104
|
-
?
|
|
106
|
+
? /* istanbul ignore next */
|
|
107
|
+
isObject(obj2[index])
|
|
105
108
|
? objIsEqual(obj2[index], value1)
|
|
106
109
|
: false
|
|
107
110
|
: isEqual(value1, obj2[index]),
|
|
@@ -91,6 +91,8 @@ const objDel = (obj, id) => {
|
|
|
91
91
|
return obj;
|
|
92
92
|
};
|
|
93
93
|
const objSize = (obj) => size(objIds(obj));
|
|
94
|
+
|
|
95
|
+
/* istanbul ignore next */
|
|
94
96
|
const objIsEqual = (
|
|
95
97
|
obj1,
|
|
96
98
|
obj2,
|
|
@@ -101,7 +103,8 @@ const objIsEqual = (
|
|
|
101
103
|
size(entries1) === objSize(obj2) &&
|
|
102
104
|
arrayEvery(entries1, ([index, value1]) =>
|
|
103
105
|
isObject(value1)
|
|
104
|
-
?
|
|
106
|
+
? /* istanbul ignore next */
|
|
107
|
+
isObject(obj2[index])
|
|
105
108
|
? objIsEqual(obj2[index], value1)
|
|
106
109
|
: false
|
|
107
110
|
: isEqual(value1, obj2[index]),
|
package/ui-react-dom/index.js
CHANGED
|
@@ -89,6 +89,8 @@ const objToArray = (obj, cb) =>
|
|
|
89
89
|
const objMap = (obj, cb) =>
|
|
90
90
|
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
|
|
91
91
|
const objSize = (obj) => size(objIds(obj));
|
|
92
|
+
|
|
93
|
+
/* istanbul ignore next */
|
|
92
94
|
const objIsEqual = (
|
|
93
95
|
obj1,
|
|
94
96
|
obj2,
|
|
@@ -99,7 +101,8 @@ const objIsEqual = (
|
|
|
99
101
|
size(entries1) === objSize(obj2) &&
|
|
100
102
|
arrayEvery(entries1, ([index, value1]) =>
|
|
101
103
|
isObject(value1)
|
|
102
|
-
?
|
|
104
|
+
? /* istanbul ignore next */
|
|
105
|
+
isObject(obj2[index])
|
|
103
106
|
? objIsEqual(obj2[index], value1)
|
|
104
107
|
: false
|
|
105
108
|
: isEqual(value1, obj2[index]),
|
|
@@ -89,6 +89,8 @@ const objToArray = (obj, cb) =>
|
|
|
89
89
|
const objMap = (obj, cb) =>
|
|
90
90
|
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
|
|
91
91
|
const objSize = (obj) => size(objIds(obj));
|
|
92
|
+
|
|
93
|
+
/* istanbul ignore next */
|
|
92
94
|
const objIsEqual = (
|
|
93
95
|
obj1,
|
|
94
96
|
obj2,
|
|
@@ -99,7 +101,8 @@ const objIsEqual = (
|
|
|
99
101
|
size(entries1) === objSize(obj2) &&
|
|
100
102
|
arrayEvery(entries1, ([index, value1]) =>
|
|
101
103
|
isObject(value1)
|
|
102
|
-
?
|
|
104
|
+
? /* istanbul ignore next */
|
|
105
|
+
isObject(obj2[index])
|
|
103
106
|
? objIsEqual(obj2[index], value1)
|
|
104
107
|
: false
|
|
105
108
|
: isEqual(value1, obj2[index]),
|
|
@@ -164,6 +164,8 @@ const objMap = (obj, cb) =>
|
|
|
164
164
|
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
|
|
165
165
|
const objSize = (obj) => size(objIds(obj));
|
|
166
166
|
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
|
|
167
|
+
|
|
168
|
+
/* istanbul ignore next */
|
|
167
169
|
const objIsEqual = (
|
|
168
170
|
obj1,
|
|
169
171
|
obj2,
|
|
@@ -174,7 +176,8 @@ const objIsEqual = (
|
|
|
174
176
|
size(entries1) === objSize(obj2) &&
|
|
175
177
|
arrayEvery(entries1, ([index, value1]) =>
|
|
176
178
|
isObject(value1)
|
|
177
|
-
?
|
|
179
|
+
? /* istanbul ignore next */
|
|
180
|
+
isObject(obj2[index])
|
|
178
181
|
? objIsEqual(obj2[index], value1)
|
|
179
182
|
: false
|
|
180
183
|
: isEqual(value1, obj2[index]),
|
|
@@ -164,6 +164,8 @@ const objMap = (obj, cb) =>
|
|
|
164
164
|
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
|
|
165
165
|
const objSize = (obj) => size(objIds(obj));
|
|
166
166
|
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
|
|
167
|
+
|
|
168
|
+
/* istanbul ignore next */
|
|
167
169
|
const objIsEqual = (
|
|
168
170
|
obj1,
|
|
169
171
|
obj2,
|
|
@@ -174,7 +176,8 @@ const objIsEqual = (
|
|
|
174
176
|
size(entries1) === objSize(obj2) &&
|
|
175
177
|
arrayEvery(entries1, ([index, value1]) =>
|
|
176
178
|
isObject(value1)
|
|
177
|
-
?
|
|
179
|
+
? /* istanbul ignore next */
|
|
180
|
+
isObject(obj2[index])
|
|
178
181
|
? objIsEqual(obj2[index], value1)
|
|
179
182
|
: false
|
|
180
183
|
: isEqual(value1, obj2[index]),
|
package/with-schemas/index.js
CHANGED
|
@@ -149,6 +149,7 @@ const isObject = (obj) =>
|
|
|
149
149
|
const objIds = object.keys;
|
|
150
150
|
const objFreeze = object.freeze;
|
|
151
151
|
const objNew = (entries = []) => object.fromEntries(entries);
|
|
152
|
+
const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
|
|
152
153
|
const objHas = (obj, id) => id in obj;
|
|
153
154
|
const objDel = (obj, id) => {
|
|
154
155
|
delete obj[id];
|
|
@@ -163,6 +164,26 @@ const objMap = (obj, cb) =>
|
|
|
163
164
|
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
|
|
164
165
|
const objSize = (obj) => size(objIds(obj));
|
|
165
166
|
const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
|
|
167
|
+
|
|
168
|
+
/* istanbul ignore next */
|
|
169
|
+
const objIsEqual = (
|
|
170
|
+
obj1,
|
|
171
|
+
obj2,
|
|
172
|
+
isEqual = (value1, value2) => value1 === value2,
|
|
173
|
+
) => {
|
|
174
|
+
const entries1 = objEntries(obj1);
|
|
175
|
+
return (
|
|
176
|
+
size(entries1) === objSize(obj2) &&
|
|
177
|
+
arrayEvery(entries1, ([index, value1]) =>
|
|
178
|
+
isObject(value1)
|
|
179
|
+
? /* istanbul ignore next */
|
|
180
|
+
isObject(obj2[index])
|
|
181
|
+
? objIsEqual(obj2[index], value1)
|
|
182
|
+
: false
|
|
183
|
+
: isEqual(value1, obj2[index]),
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
};
|
|
166
187
|
const objEnsure = (obj, id, getDefaultValue) => {
|
|
167
188
|
if (!objHas(obj, id)) {
|
|
168
189
|
obj[id] = getDefaultValue();
|
|
@@ -3289,8 +3310,10 @@ const createQueries = getCreateFunction((store) => {
|
|
|
3289
3310
|
),
|
|
3290
3311
|
);
|
|
3291
3312
|
const setQueryDefinition = (queryId, tableId, build, paramValues = {}) => {
|
|
3313
|
+
const oldParamValues = getParamValues(queryId);
|
|
3292
3314
|
setDefinition(queryId, tableId);
|
|
3293
3315
|
setQueryArgs(queryId, [build, objToMap(paramValues)]);
|
|
3316
|
+
callParamListeners(queryId, oldParamValues, paramValues);
|
|
3294
3317
|
resetPreStores(queryId);
|
|
3295
3318
|
const [, paramsMap] = getQueryArgs(queryId);
|
|
3296
3319
|
const selectEntries = [];
|
|
@@ -3619,32 +3642,36 @@ const createQueries = getCreateFunction((store) => {
|
|
|
3619
3642
|
);
|
|
3620
3643
|
return queries;
|
|
3621
3644
|
};
|
|
3645
|
+
const callParamListeners = (queryId, oldParamValues, newParamValues) => {
|
|
3646
|
+
const allParamIds = setNew([
|
|
3647
|
+
...objIds(oldParamValues),
|
|
3648
|
+
...objIds(newParamValues),
|
|
3649
|
+
]);
|
|
3650
|
+
let changed = 0;
|
|
3651
|
+
collForEach(allParamIds, (paramId) => {
|
|
3652
|
+
const newParamValue = objGet(newParamValues, paramId);
|
|
3653
|
+
if (!arrayOrValueEqual(objGet(oldParamValues, paramId), newParamValue)) {
|
|
3654
|
+
changed = 1;
|
|
3655
|
+
callListeners(paramValueListeners, [queryId, paramId], newParamValue);
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
if (changed) {
|
|
3659
|
+
callListeners(paramValuesListeners, [queryId], newParamValues);
|
|
3660
|
+
}
|
|
3661
|
+
};
|
|
3622
3662
|
const delQueryDefinition = (queryId) => {
|
|
3623
|
-
const oldParamValues =
|
|
3663
|
+
const oldParamValues = getParamValues(queryId);
|
|
3624
3664
|
resetPreStores(queryId);
|
|
3625
3665
|
delDefinition(queryId);
|
|
3626
|
-
|
|
3627
|
-
mapForEach(paramValues, (paramId) =>
|
|
3628
|
-
callListeners(paramValueListeners, [queryId, paramId], void 0),
|
|
3629
|
-
);
|
|
3630
|
-
callListeners(paramValuesListeners, [queryId], {});
|
|
3631
|
-
});
|
|
3666
|
+
callParamListeners(queryId, oldParamValues, {});
|
|
3632
3667
|
return queries;
|
|
3633
3668
|
};
|
|
3634
|
-
const setParamValues = (queryId, paramValues) => {
|
|
3669
|
+
const setParamValues = (queryId, paramValues, force = 0) => {
|
|
3635
3670
|
ifNotUndefined(getQueryArgs(queryId), ([definition, oldParamValues]) => {
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
oldParamValues,
|
|
3639
|
-
|
|
3640
|
-
(_, paramId, newValue) => {
|
|
3641
|
-
if (!arrayOrValueEqual(newValue, mapGet(oldParamValues, paramId))) {
|
|
3642
|
-
mapSet(changedParamValues, paramId, newValue);
|
|
3643
|
-
}
|
|
3644
|
-
},
|
|
3645
|
-
(_, paramId) => mapSet(changedParamValues, paramId, void 0),
|
|
3646
|
-
);
|
|
3647
|
-
if (!collIsEmpty(changedParamValues)) {
|
|
3671
|
+
if (
|
|
3672
|
+
force ||
|
|
3673
|
+
!objIsEqual(mapToObj(oldParamValues), paramValues, arrayOrValueEqual)
|
|
3674
|
+
) {
|
|
3648
3675
|
resultStore.transaction(() =>
|
|
3649
3676
|
setQueryDefinition(
|
|
3650
3677
|
queryId,
|
|
@@ -3653,21 +3680,21 @@ const createQueries = getCreateFunction((store) => {
|
|
|
3653
3680
|
paramValues,
|
|
3654
3681
|
),
|
|
3655
3682
|
);
|
|
3656
|
-
mapForEach(changedParamValues, (paramId, value) =>
|
|
3657
|
-
callListeners(paramValueListeners, [queryId, paramId], value),
|
|
3658
|
-
);
|
|
3659
|
-
callListeners(paramValuesListeners, [queryId], {...paramValues});
|
|
3660
3683
|
}
|
|
3661
3684
|
});
|
|
3662
3685
|
return queries;
|
|
3663
3686
|
};
|
|
3664
|
-
const setParamValue = (queryId, paramId, value) =>
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3687
|
+
const setParamValue = (queryId, paramId, value) => {
|
|
3688
|
+
if (!arrayOrValueEqual(getParamValue(queryId, paramId), value)) {
|
|
3689
|
+
setParamValues(
|
|
3690
|
+
queryId,
|
|
3691
|
+
{...getParamValues(queryId), [paramId]: value},
|
|
3692
|
+
1,
|
|
3693
|
+
);
|
|
3694
|
+
}
|
|
3695
|
+
return queries;
|
|
3696
|
+
};
|
|
3697
|
+
const getParamValues = (queryId) => mapToObj(getQueryArgs(queryId)?.[1]);
|
|
3671
3698
|
const getParamValue = (queryId, paramId) =>
|
|
3672
3699
|
mapGet(getQueryArgs(queryId)?.[1], paramId);
|
|
3673
3700
|
const addQueryIdsListener = (listener) =>
|