@keepkit/core 0.28.19 → 0.28.21
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 +14 -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 +31 -18
- 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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[日本語](#日本語) | [English](#english)
|
|
4
4
|
|
|
5
|
-
Release: v0.28.
|
|
5
|
+
Release: v0.28.21
|
|
6
6
|
|
|
7
7
|
## 日本語
|
|
8
8
|
|
|
@@ -74,7 +74,7 @@ hooksはProvider内のコンポーネントで呼び出します。
|
|
|
74
74
|
| 複数コレクションへの所属・順序 | `addKeepItemToCollection`、`getKeepCollectionItems`、`reorderKeepCollectionItems`、`removeKeepItemFromCollection` |
|
|
75
75
|
| 再発見 | `useKeepItem(item).recordOpen()`、`createRediscoveryQuery`、`useKeepRediscovery` |
|
|
76
76
|
| 閲覧履歴・鑑賞記録・進行位置 | `LocalStorageKeepHistoryStorage`、`LocalStorageKeepViewingRecordStorage`、`LocalStorageKeepProgressStorage` |
|
|
77
|
-
| 保存対象の再検証 | Providerの`validateItem` / `resolveItem`、`revalidateItems` |
|
|
77
|
+
| 保存対象の再検証 | Providerの`validateItem` / `resolveItem`、`autoRevalidation.revalidateMany`、`revalidateItems` |
|
|
78
78
|
|
|
79
79
|
一覧は未アーカイブのアイテムを既定で返します。`archiveScope: "all"`で両方を、`archived: true`でアーカイブを取得できます。
|
|
80
80
|
複数コレクションへの所属はアイテムと別に保存され、所属を外しても共有アイテムやメモは残ります。
|
|
@@ -85,7 +85,10 @@ hooksはProvider内のコンポーネントで呼び出します。
|
|
|
85
85
|
|
|
86
86
|
### 保存・同期・バックアップ
|
|
87
87
|
|
|
88
|
+
`KeepButton` の既定の読み上げ名は保存状態にかかわらず一定で、状態は `aria-pressed` で伝えます。`savedAriaLabel` / `unsavedAriaLabel` や `getAriaLabel` による明示的な上書きも引き続き使えます。ボタンのエラー表示と render props の `error` は、そのボタンの操作失敗を示し、再操作時にクリアされます。
|
|
89
|
+
|
|
88
90
|
- `createBrowserStorageAdapter`はIndexedDB優先で、localStorageへフォールバックします。`scope`でユーザー/テナントを分離できます。
|
|
91
|
+
- `key` は localStorage 用で、IndexedDB の既定名は `keepkit` です。同一オリジンで別の保存先を使う場合は、`databaseName` も別々に指定してください。既存データの保存先を変更すると、そのデータは新しい名前からは参照されません。
|
|
89
92
|
- `SyncStorageAdapter`と`RemoteSyncDriver`で永続オフラインキュー・再試行・競合処理を組み込みます。定義・所属の同期には、それぞれ`pushCollection` / `pullCollections`、`pushMembership` / `pullMemberships`が必要です。
|
|
90
93
|
- `remote.pull()`の結果は既定(`itemPullMode: "merge"`)で部分的な一覧として統合し、ローカルのアイテムを削除しません。APIがscope内の全アイテムを返す場合は`itemPullMode: "snapshot"`を指定すると、サーバー受理済み(`revision`あり)で一覧から消えたアイテムを削除します。未送信の変更があるアイテムは残るため、オフライン中に編集したアイテムは再送されます。pullしたアイテムの`revision`がローカルと異なる場合は、`updatedAt`にかかわらずサーバー版を採用します。
|
|
91
94
|
- 400〜499のうち認証・一時エラーではないpush失敗は`getSyncState().rejectedOperations`に残り、独立した後続操作は同期を続けます。ホストは`resolveRejectedSyncOperation(operationId, "retry" | "discard")`で再試行または破棄できます。共有localStorageキューは複数タブの追加・削除をWeb Locks APIで直列化します。ブラウザーがWeb Locksに対応しない場合、安全な更新を拒否します。
|
|
@@ -202,7 +205,7 @@ Use `keep.useItem(article)` for saves, removal, and note updates, and `keep.useL
|
|
|
202
205
|
| Multiple collections and ordering | `addKeepItemToCollection`, `getKeepCollectionItems`, `reorderKeepCollectionItems`, `removeKeepItemFromCollection` |
|
|
203
206
|
| Rediscovery | `useKeepItem(item).recordOpen()`, `createRediscoveryQuery`, and `useKeepRediscovery` |
|
|
204
207
|
| History, viewing records, and progress | `LocalStorageKeepHistoryStorage`, `LocalStorageKeepViewingRecordStorage`, `LocalStorageKeepProgressStorage` |
|
|
205
|
-
| Source revalidation | Provider `validateItem` / `resolveItem` and `revalidateItems` |
|
|
208
|
+
| Source revalidation | Provider `validateItem` / `resolveItem`, `autoRevalidation.revalidateMany`, and `revalidateItems` |
|
|
206
209
|
|
|
207
210
|
Lists return unarchived items by default. Use `archiveScope: "all"` for both or `archived: true` for archived items.
|
|
208
211
|
Memberships are stored separately; removing one leaves the shared item and note intact.
|
|
@@ -213,7 +216,10 @@ Changing storage or storage scope clears the previous `lastChange` and Undo stat
|
|
|
213
216
|
|
|
214
217
|
### Storage, sync, and backups
|
|
215
218
|
|
|
219
|
+
The default accessible name of `KeepButton` stays constant while `aria-pressed` communicates its state. Explicit `savedAriaLabel`, `unsavedAriaLabel`, and `getAriaLabel` overrides remain available. A button's error state and render-prop `error` reflect its own failed action and clear on retry.
|
|
220
|
+
|
|
216
221
|
- `createBrowserStorageAdapter` prefers IndexedDB and falls back to localStorage. Use `scope` to isolate users and tenants.
|
|
222
|
+
- `key` names only the localStorage entry; IndexedDB defaults to `keepkit`. Set a distinct `databaseName` to isolate storage within the same origin. Changing an existing database name does not move its data.
|
|
217
223
|
- Combine `SyncStorageAdapter` and `RemoteSyncDriver` for durable offline queues, retries, and conflicts. Definition and membership sync require `pushCollection` / `pullCollections` and `pushMembership` / `pullMemberships`, respectively.
|
|
218
224
|
- By default (`itemPullMode: "merge"`), `remote.pull()` results are merged as a partial list and never delete local items. If your API returns every item in the scope, set `itemPullMode: "snapshot"` to remove server-acknowledged items (with a `revision`) that are no longer listed. Items with pending local changes are kept, so an item edited offline is pushed again. A pulled item whose `revision` differs from the local copy is adopted regardless of `updatedAt`.
|
|
219
225
|
- Non-authentication, non-transient 4xx push failures are retained in `getSyncState().rejectedOperations`, while later independent operations continue syncing. Hosts can retry or discard one with `resolveRejectedSyncOperation(operationId, "retry" | "discard")`. Shared localStorage queues serialize cross-tab additions and removals with the Web Locks API and reject unsafe writes in browsers without it.
|
|
@@ -250,3 +256,8 @@ Browser writes to localStorage history, viewing records, and progress require th
|
|
|
250
256
|
Namespace history and progress keys per account, and pass matching language, content version, and audio ID when reading progress.
|
|
251
257
|
|
|
252
258
|
See the [repository README](../../README.md) for demos and development, and the [release notes](../../RELEASE_NOTES.md) for changes.
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
`autoRevalidation={{ revalidateMany: async (items) => statuses }}` batches mount, reconnect and manual `revalidateItems()` calls. Return a status or revalidation result for every item ID; an incomplete response fails without applying changes. An explicitly passed single-item revalidator takes precedence.
|
|
262
|
+
|
|
263
|
+
`autoRevalidation.revalidateMany` はマウント時・再接続時・引数なしの `revalidateItems()` を一括処理します。全アイテムIDに対するステータスまたは検証結果を返してください。不完全な応答は変更せず失敗します。単件コールバックを明示した場合はそちらを使用します。
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
stripUndefinedMeta,
|
|
2
3
|
validateKeepItem
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-R5BTN27K.js";
|
|
4
5
|
|
|
5
6
|
// src/features/items/types.ts
|
|
6
7
|
var KeepSyncAuthError = class extends Error {
|
|
@@ -57,6 +58,10 @@ function normalizeKeepTags(tags) {
|
|
|
57
58
|
|
|
58
59
|
// src/features/persistence/helpers.ts
|
|
59
60
|
async function persistKeepItems(storage, items) {
|
|
61
|
+
items = items.map((item) => {
|
|
62
|
+
const meta = stripUndefinedMeta(item.meta);
|
|
63
|
+
return meta === item.meta ? item : { ...item, meta };
|
|
64
|
+
});
|
|
60
65
|
if (storage.setMany) {
|
|
61
66
|
await storage.setMany(items);
|
|
62
67
|
return;
|
|
@@ -2620,12 +2625,18 @@ var FallbackStorageAdapter = class {
|
|
|
2620
2625
|
return this.readAll();
|
|
2621
2626
|
}
|
|
2622
2627
|
set(item) {
|
|
2628
|
+
const meta = stripUndefinedMeta(item.meta);
|
|
2629
|
+
if (meta !== item.meta) item = { ...item, meta };
|
|
2623
2630
|
if (this.scope) item = { ...item, scope: this.scope };
|
|
2624
2631
|
if (this.journalController)
|
|
2625
2632
|
return this.journalController.write({ type: "setItems", items: [item] }, (adapter) => adapter.set(item));
|
|
2626
2633
|
return this.executeWrite((adapter) => adapter.set(item));
|
|
2627
2634
|
}
|
|
2628
2635
|
setMany(items) {
|
|
2636
|
+
items = items.map((item) => {
|
|
2637
|
+
const meta = stripUndefinedMeta(item.meta);
|
|
2638
|
+
return meta === item.meta ? item : { ...item, meta };
|
|
2639
|
+
});
|
|
2629
2640
|
if (this.scope) items = items.map((item) => ({ ...item, scope: this.scope }));
|
|
2630
2641
|
if (this.journalController) return this.journalController.write({ type: "setItems", items });
|
|
2631
2642
|
return this.executeWrite(
|
|
@@ -2978,6 +2989,10 @@ var LocalStorageAdapter = class {
|
|
|
2978
2989
|
await this.setMany([item]);
|
|
2979
2990
|
}
|
|
2980
2991
|
async setMany(items) {
|
|
2992
|
+
items = items.map((item) => {
|
|
2993
|
+
const meta = stripUndefinedMeta(item.meta);
|
|
2994
|
+
return meta === item.meta ? item : { ...item, meta };
|
|
2995
|
+
});
|
|
2981
2996
|
const current = await this.getAll();
|
|
2982
2997
|
const byScopeAndId = new Map(current.map((item) => [getItemStorageKey(item), item]));
|
|
2983
2998
|
for (const item of items) byScopeAndId.set(getItemStorageKey(item), item);
|
|
@@ -3162,6 +3177,10 @@ var IndexedDBAdapter = class {
|
|
|
3162
3177
|
return this.setMany([item]);
|
|
3163
3178
|
}
|
|
3164
3179
|
async setMany(items) {
|
|
3180
|
+
items = items.map((item) => {
|
|
3181
|
+
const meta = stripUndefinedMeta(item.meta);
|
|
3182
|
+
return meta === item.meta ? item : { ...item, meta };
|
|
3183
|
+
});
|
|
3165
3184
|
const database = await this.open("set");
|
|
3166
3185
|
if (!database) return;
|
|
3167
3186
|
try {
|
|
@@ -3446,4 +3465,4 @@ export {
|
|
|
3446
3465
|
LocalStorageAdapter,
|
|
3447
3466
|
IndexedDBAdapter
|
|
3448
3467
|
};
|
|
3449
|
-
//# sourceMappingURL=chunk-
|
|
3468
|
+
//# sourceMappingURL=chunk-IBODMDW3.js.map
|