@keepkit/core 0.28.19 → 0.28.20
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 +8 -3
- package/dist/{chunk-HTTOCLOC.js → chunk-IBODMDW3.js} +21 -2
- package/dist/chunk-IBODMDW3.js.map +1 -0
- package/dist/{chunk-OLGYOC3D.js → chunk-OHKVHU5I.js} +2 -2
- package/dist/chunk-OHKVHU5I.js.map +1 -0
- package/dist/chunk-R5BTN27K.js +62 -0
- package/dist/chunk-R5BTN27K.js.map +1 -0
- package/dist/core.d.ts +3 -3
- package/dist/core.js +5 -3
- package/dist/core.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +17 -9
- package/dist/react.js.map +1 -1
- package/dist/schema.d.ts +2 -1
- package/dist/schema.js +3 -1
- package/dist/storage.js +2 -2
- package/dist/{store-3LwroO9A.d.ts → store-Brz6nTKv.d.ts} +4 -2
- package/package.json +1 -1
- package/dist/chunk-5W4QSJHV.js +0 -41
- package/dist/chunk-5W4QSJHV.js.map +0 -1
- package/dist/chunk-HTTOCLOC.js.map +0 -1
- package/dist/chunk-OLGYOC3D.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
queryKeepItems,
|
|
10
10
|
reorderKeepItems,
|
|
11
11
|
revalidateKeepItems
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OHKVHU5I.js";
|
|
13
13
|
import {
|
|
14
14
|
createBrowserStorageAdapter,
|
|
15
15
|
exportItems,
|
|
@@ -18,10 +18,11 @@ import {
|
|
|
18
18
|
normalizeKeepTags,
|
|
19
19
|
persistKeepItems,
|
|
20
20
|
removeKeepItems
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-IBODMDW3.js";
|
|
22
22
|
import {
|
|
23
|
-
parseKeepMeta
|
|
24
|
-
|
|
23
|
+
parseKeepMeta,
|
|
24
|
+
stripUndefinedMeta
|
|
25
|
+
} from "./chunk-R5BTN27K.js";
|
|
25
26
|
|
|
26
27
|
// src/react/components/KeepButton.tsx
|
|
27
28
|
import {
|
|
@@ -379,7 +380,8 @@ function KeepProviderContent({
|
|
|
379
380
|
(action, id, update, onSuccess) => runMutation(action, id, (previous) => {
|
|
380
381
|
const current = previous.find((item) => item.id === id);
|
|
381
382
|
if (!current) return void 0;
|
|
382
|
-
const
|
|
383
|
+
const updated = update(current);
|
|
384
|
+
const next = { ...updated, meta: stripUndefinedMeta(updated.meta) };
|
|
383
385
|
return {
|
|
384
386
|
next: previous.map((item) => item.id === id ? next : item),
|
|
385
387
|
persist: () => storage.set(next),
|
|
@@ -393,7 +395,7 @@ function KeepProviderContent({
|
|
|
393
395
|
async (item) => {
|
|
394
396
|
let normalizedItem;
|
|
395
397
|
try {
|
|
396
|
-
const meta = migrationRef.current.schema ? await parseKeepMeta(migrationRef.current.schema, item.meta) : item.meta;
|
|
398
|
+
const meta = migrationRef.current.schema ? stripUndefinedMeta(await parseKeepMeta(migrationRef.current.schema, item.meta)) : stripUndefinedMeta(item.meta);
|
|
397
399
|
normalizedItem = {
|
|
398
400
|
...item,
|
|
399
401
|
meta,
|
|
@@ -887,7 +889,13 @@ function KeepProviderContent({
|
|
|
887
889
|
let persistenceStarted = false;
|
|
888
890
|
let summary;
|
|
889
891
|
try {
|
|
890
|
-
const
|
|
892
|
+
const batch = !revalidator ? autoRevalidationRef.current?.revalidateMany : void 0;
|
|
893
|
+
const batchResults = batch && previous.length ? await batch(previous) : void 0;
|
|
894
|
+
const activeRevalidator = batchResults ? (item) => {
|
|
895
|
+
const result = Object.keys(batchResults).includes(item.id) ? batchResults[item.id] : void 0;
|
|
896
|
+
if (!result) throw new Error(`Missing revalidation result for ${item.id}.`);
|
|
897
|
+
return result;
|
|
898
|
+
} : revalidator ?? autoRevalidationRef.current?.revalidator ?? validateItem ?? (batch ? () => "available" : void 0);
|
|
891
899
|
if (!activeRevalidator)
|
|
892
900
|
throw new Error("KeepProvider.revalidateItems requires a revalidator or validateItem.");
|
|
893
901
|
summary = await revalidateKeepItems(previous, activeRevalidator, {
|
|
@@ -946,8 +954,8 @@ function KeepProviderContent({
|
|
|
946
954
|
useEffect(() => {
|
|
947
955
|
const settings = autoRevalidationRef.current;
|
|
948
956
|
const activeRevalidator = settings?.revalidator ?? validateItem;
|
|
949
|
-
if (!settings || !activeRevalidator) return;
|
|
950
|
-
const run = () => void revalidateItems(
|
|
957
|
+
if (!settings || !activeRevalidator && !settings.revalidateMany) return;
|
|
958
|
+
const run = () => void revalidateItems(void 0, { removeStatuses: settings.removeStatuses }).catch(() => void 0);
|
|
951
959
|
if (isHydrated && settings.onMount !== false && !didMountRevalidateRef.current) {
|
|
952
960
|
didMountRevalidateRef.current = true;
|
|
953
961
|
run();
|