@keepkit/core 0.28.9 → 0.28.10
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 +51 -3
- package/dist/chunk-CSBPFROD.js +276 -0
- package/dist/chunk-CSBPFROD.js.map +1 -0
- package/dist/{chunk-SLH4DFYQ.js → chunk-SS22UTBH.js} +1438 -92
- package/dist/chunk-SS22UTBH.js.map +1 -0
- package/dist/core.d.ts +5 -7
- package/dist/core.js +22 -33
- package/dist/core.js.map +1 -1
- package/dist/react.d.ts +4 -5
- package/dist/react.js +87 -54
- package/dist/react.js.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/storage.d.ts +23 -10
- package/dist/storage.js +4 -1
- package/dist/{store-98vWM3tV.d.ts → store-C8cxvXRV.d.ts} +2 -73
- package/dist/{types-GTCMFt5T.d.ts → types-DjXvE9Zb.d.ts} +243 -1
- package/package.json +1 -1
- package/dist/chunk-EMOPFB5D.js +0 -594
- package/dist/chunk-EMOPFB5D.js.map +0 -1
- package/dist/chunk-SLH4DFYQ.js.map +0 -1
- package/dist/scope-1bxGd68Y.d.ts +0 -46
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[日本語](#日本語) | [English](#english)
|
|
4
4
|
|
|
5
|
-
Release: v0.28.
|
|
5
|
+
Release: v0.28.10
|
|
6
6
|
|
|
7
7
|
## 日本語
|
|
8
8
|
|
|
@@ -75,6 +75,8 @@ hooksはProvider内のコンポーネントで呼び出します。
|
|
|
75
75
|
一覧は未アーカイブのアイテムを既定で返します。`archiveScope: "all"`で両方を、`archived: true`でアーカイブを取得できます。
|
|
76
76
|
複数コレクションへの所属はアイテムと別に保存され、所属を外しても共有アイテムやメモは残ります。
|
|
77
77
|
|
|
78
|
+
`before`プラグインや永続化の失敗は保存操作を拒否します。保存成功後のコールバック、`after`プラグイン、`onChange`の例外は`onError(error, { action, id, phase: "notification" })`で報告し、保存済み状態とUndoを維持します。通知例外でも保存操作のPromiseは成功し、後続通知は継続します。
|
|
79
|
+
|
|
78
80
|
### 保存・同期・バックアップ
|
|
79
81
|
|
|
80
82
|
- `createBrowserStorageAdapter`はIndexedDB優先で、localStorageへフォールバックします。`scope`でユーザー/テナントを分離できます。
|
|
@@ -82,9 +84,31 @@ hooksはProvider内のコンポーネントで呼び出します。
|
|
|
82
84
|
- 認証方式はアプリ側で管理します。[認証付き同期の例](../../examples/authenticated-sync/README.md)でトークン取得とscope切り替えを確認できます。
|
|
83
85
|
- `exportItems(storage)` / `importItems(storage, json, { mode: "merge" })`で保存アイテム・コレクション定義・所属をバックアップ・復元します。閲覧履歴・鑑賞記録・進行位置は含みません。
|
|
84
86
|
|
|
87
|
+
fallbackの更新・削除・全消去・コレクション・所属操作は、ストレージとscopeごとのlocalStorage journalに記録します。journal保存が成功判定です。実データへの反映が失敗しても記録から変更を読み取り、再起動後も復旧を試します。全操作をprimaryへ再生し、読み取りとjournal消去が成功した後にIndexedDBへ戻ります。`clear()`はアイテムと所属を消去し、コレクション定義を保持します。
|
|
88
|
+
|
|
89
|
+
fallbackへの書き込みと復旧にはWeb Locks APIとJSON保存可能なメタデータが必要です。journal保存失敗はデータ変更前にエラーを返します。Web Locks未対応でも、未反映操作がなくIndexedDBが正常なら従来の保存が使えます。正常なIndexedDBのメタデータにJSON制約は追加しません。
|
|
90
|
+
|
|
91
|
+
journal v2は完全なアイテム・コレクション・所属のスナップショットと取得時刻を保存します。v1の保留操作も読み込み、空primaryへの既存データ移行後にスナップショットを作ります。障害中の読み取りは最後の永続スナップショットと保留操作を使います。primary保存後のスナップショット更新失敗は保存成功を維持し、`storage.recovery?.getState()`で`snapshotStale`と`issue`を報告します。次の正常読み取りで更新を再試行します。
|
|
92
|
+
|
|
93
|
+
標準browser factoryは旧v1保存キーからも読み込み、新しい記録の永続化後に旧キーを削除します。旧キーだけではbackendやscopeを一意に判定できない場合は、記録を保持してエラーを返します。独自の`createRecoveryJournal`を使う場合は、その実装で旧キーを移行してください。
|
|
94
|
+
|
|
95
|
+
`StorageAdapter.recovery`は任意です。`getState()` / `subscribe()`で状態を観察し、`inspect({ selections })`で書き込みなしに保存元と退避済み旧fallbackを比較します。異なるIDは両方保持し、同じIDの競合は明示選択が必要です。`apply({ token, selections })`は適用直前に再照合し、古い確認を拒否します。修復前のバックアップv2と承認済み操作を一回のjournal保存で確定します。`status: "pending"`は修復内容を保存済み・反映待ちなので、再提出せず`retry()`で続行してください。バックアップは自動削除しません。後続の`inspect()`が返す`retainedBackups`から修復前のJSONバックアップv2を取得できます。項目・所属・コレクションは対象scopeだけを比較・変更します。
|
|
96
|
+
|
|
97
|
+
`KeepFallbackRecovery`はこの能力を明示的に渡すUIです。[UIガイド](../keepkit-ui/README.md)を参照してください。`SyncStorageAdapter.recovery`は状態表示だけを公開します。分岐の修復は同期を開始する前のstandalone local adapterで行います。
|
|
98
|
+
|
|
99
|
+
独自の`FallbackStorageAdapter`には`recoveryJournal: FallbackRecoveryJournal<TMeta>`を渡せます。`read` / `write`でv1またはv2の状態を永続化し、`runExclusive`で同じbackendへのアクセスを排他します。任意の`subscribe`は別タブの変更を通知します。browser factoryの`createRecoveryJournal`には保存キー・排他キー・scopeが渡されます。独自排他機構を接続でき、標準実装は排他なしのjournal変更・復旧を拒否します。同一backendの全scopeで排他キーを共有してください。localStorageを使う独自実装は、読み取り前と書き込み後のタスク終了までロックを保持します。標準`LocalStorageRecoveryJournal`はこの待機を含みます。
|
|
100
|
+
|
|
101
|
+
JSON保存するmetadata・バックアップ・localStorage同期キューは、Date、Map/Set、非有限数、undefined、function、symbol、BigInt、循環参照などを`KeepStorageSerializationError`で拒否します。既知の任意フィールドのundefinedは省略できます。正常なIndexedDB保存はJSON互換性を要求しませんが、予備スナップショットの更新やJSON出力は失敗し得ます。
|
|
102
|
+
|
|
103
|
+
scope付きadapterを別のscopeで包み直しても書き込み先は切り替わりません。その構成の変更操作は保存前に拒否します。切替先のscopeからadapterを作成してください。
|
|
104
|
+
|
|
105
|
+
導入時は旧実装のタブをすべて更新してください。記録のない削除意図や失われた内容は自動復元できません。スナップショット保存自体が失敗した期間の完全な障害時表示と、排他機構のない環境での安全な書き込みは保証できません。
|
|
106
|
+
|
|
107
|
+
既存IndexedDBのコレクション保存先は`databaseName:storeName:collections`です。たとえば`("a:b", "c")`と`("a", "b:c")`は同じ保存先になるため、同じscopeで併用しないでください。この既存形式の曖昧なデータは、journal移行では自動分離できません。
|
|
108
|
+
|
|
85
109
|
**Replace(置換)は空のバックアップでも対象範囲を置き換え、ロールバックしません。** 途中失敗は`KeepBackupImportError`の`failedStage`と`applied`で確認できます。スコープ付きadapterは別scopeのデータを変更前に拒否します。
|
|
86
110
|
|
|
87
|
-
独自の`StorageAdapter`で定義・所属を扱う場合は、`getCollections` / `setCollection` / `removeCollection`と`getCollectionMemberships` / `setCollectionMembership` / `removeCollectionMembership
|
|
111
|
+
独自の`StorageAdapter`で定義・所属を扱う場合は、`getCollections` / `setCollection` / `removeCollection`と`getCollectionMemberships` / `setCollectionMembership` / `removeCollectionMembership`を実装してください。Providerのコレクション作成・改名・削除は定義メソッドが揃わない場合に拒否し、アイテムの所属も変更しません。
|
|
88
112
|
|
|
89
113
|
履歴・鑑賞記録・進行位置のlocalStorage書き込みには、ブラウザーでWeb Locks APIが必要です。未対応や保存先が利用できない場合はエラーを返します。SSRで初期化できますが、永続化操作はブラウザー側で行います。
|
|
90
114
|
履歴・進行位置のキーはアプリ側でユーザーごとに分け、進行位置の取得には記録と一致する言語・コンテンツ版・音声IDを渡してください。
|
|
@@ -162,6 +186,8 @@ Use `keep.useItem(article)` for saves, removal, and note updates, and `keep.useL
|
|
|
162
186
|
Lists return unarchived items by default. Use `archiveScope: "all"` for both or `archived: true` for archived items.
|
|
163
187
|
Memberships are stored separately; removing one leaves the shared item and note intact.
|
|
164
188
|
|
|
189
|
+
Failures in `before` plugins or persistence reject the mutation. Errors from post-save callbacks, `after` plugins, and `onChange` are reported through `onError(error, { action, id, phase: "notification" })`, preserving committed state and Undo. The mutation resolves successfully and later notifications still run.
|
|
190
|
+
|
|
165
191
|
### Storage, sync, and backups
|
|
166
192
|
|
|
167
193
|
- `createBrowserStorageAdapter` prefers IndexedDB and falls back to localStorage. Use `scope` to isolate users and tenants.
|
|
@@ -169,9 +195,31 @@ Memberships are stored separately; removing one leaves the shared item and note
|
|
|
169
195
|
- Authentication belongs to your app. See the [authenticated sync example](../../examples/authenticated-sync/README.md) for tokens and scope changes.
|
|
170
196
|
- Use `exportItems(storage)` / `importItems(storage, json, { mode: "merge" })` to back up and restore saved items, collection definitions, and memberships. History, viewing records, and progress are excluded.
|
|
171
197
|
|
|
198
|
+
Fallback updates, removals, clears, collection changes, and memberships enter a localStorage journal isolated by storage configuration and scope. Saving the journal commits the mutation. Reads apply recorded changes even if their projection into fallback storage fails, and recovery retries after restart. The adapter returns to IndexedDB after replaying every operation, reading the primary successfully, and clearing the journal. `clear()` removes items and memberships, preserving collection definitions.
|
|
199
|
+
|
|
200
|
+
Fallback writes and recovery require the Web Locks API and JSON-compatible metadata. Journal write failures reject before changing data. Browsers without Web Locks can still save to a healthy IndexedDB primary when no operations are pending. Healthy IndexedDB metadata gains no JSON restriction.
|
|
201
|
+
|
|
202
|
+
Journal v2 stores complete item, collection, and membership snapshots with their capture time. It also reads pending v1 operations and creates its first snapshot after migrating legacy data into an empty primary. Outage reads use the last durable snapshot plus pending operations. Failure to refresh the snapshot after a primary commit preserves mutation success and reports `snapshotStale` and `issue` through `storage.recovery?.getState()`. The next healthy read retries the refresh.
|
|
203
|
+
|
|
204
|
+
The standard browser factory also reads the original v1 storage key and removes it only after persisting the new record. If the old key cannot identify the backend or scope unambiguously, it preserves the record and reports an error. Custom `createRecoveryJournal` implementations must migrate their own older keys.
|
|
205
|
+
|
|
206
|
+
`StorageAdapter.recovery` is optional. Observe status through `getState()` / `subscribe()`, and compare storage sources and archived legacy fallback through `inspect({ selections })` without writing. Distinct IDs are retained together; conflicting records with the same identity need an explicit choice. `apply({ token, selections })` rechecks the data immediately before applying and rejects stale confirmation. It commits pre-repair v2 backups and the approved operation list in one journal write. A `status: "pending"` result means the repair is saved and awaiting projection: continue through `retry()` instead of submitting it again. Backups are never automatically deleted. Later `inspect()` results expose earlier v2 JSON backups through `retainedBackups`. Comparisons and changes include only the active scope.
|
|
207
|
+
|
|
208
|
+
`KeepFallbackRecovery` accepts this capability explicitly; see the [UI guide](../keepkit-ui/README.md). `SyncStorageAdapter.recovery` exposes status only. Repair existing branches through a standalone local adapter before starting synchronization.
|
|
209
|
+
|
|
210
|
+
Custom `FallbackStorageAdapter` instances can accept `recoveryJournal: FallbackRecoveryJournal<TMeta>`. Persist v1 or v2 state through `read` / `write` and provide exclusive access to the same backend through `runExclusive`. Optional `subscribe` notifies consumers of other tabs' changes. The browser factory's `createRecoveryJournal` receives the storage key, lock key, and scope. It supports a custom lock implementation; the default rejects journal changes and recovery without exclusive access. Share the lock key across all scopes using the same backend. Custom localStorage journals must hold the lock across task boundaries before reads and after writes. The standard `LocalStorageRecoveryJournal` includes these waits.
|
|
211
|
+
|
|
212
|
+
JSON metadata, backups, and localStorage sync queues reject Date, Map/Set, non-finite numbers, undefined, functions, symbols, BigInt, and circular references through `KeepStorageSerializationError`. Known optional fields may omit undefined. Healthy IndexedDB saves do not require JSON compatibility, but reserve snapshots and JSON exports may consequently fail.
|
|
213
|
+
|
|
214
|
+
Wrapping an already scoped adapter with a different scope does not switch its write destination. Such mutations reject before persistence. Create an adapter for the destination scope when switching accounts.
|
|
215
|
+
|
|
216
|
+
Refresh all tabs running the older implementation when adopting this journal. Missing deletion intent and already lost content cannot be reconstructed automatically. Complete outage views during snapshot-write failures and safe writes without an exclusive-access mechanism cannot be guaranteed.
|
|
217
|
+
|
|
218
|
+
The existing IndexedDB collection database is named `databaseName:storeName:collections`. For example, `("a:b", "c")` and `("a", "b:c")` share that database, so do not combine them within the same scope. Journal migration cannot automatically separate ambiguous data in this existing format.
|
|
219
|
+
|
|
172
220
|
**Replace imports overwrite the target data, even with an empty backup, and do not roll back.** Inspect `KeepBackupImportError.failedStage` and `applied` after partial failure. Scoped adapters reject data from another scope before mutation.
|
|
173
221
|
|
|
174
|
-
Custom `StorageAdapter` implementations need `getCollections` / `setCollection` / `removeCollection` and `getCollectionMemberships` / `setCollectionMembership` / `removeCollectionMembership` to support definitions and memberships.
|
|
222
|
+
Custom `StorageAdapter` implementations need `getCollections` / `setCollection` / `removeCollection` and `getCollectionMemberships` / `setCollectionMembership` / `removeCollectionMembership` to support definitions and memberships. Provider collection creation, renaming, and removal reject before changing item assignments when definition methods are incomplete.
|
|
175
223
|
|
|
176
224
|
Browser writes to localStorage history, viewing records, and progress require the Web Locks API. Unsupported locks or unavailable storage produce errors. Construction is SSR-safe; persistent operations run in the browser.
|
|
177
225
|
Namespace history and progress keys per account, and pass matching language, content version, and audio ID when reading progress.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import {
|
|
2
|
+
persistKeepItems,
|
|
3
|
+
removeKeepItems
|
|
4
|
+
} from "./chunk-SS22UTBH.js";
|
|
5
|
+
|
|
6
|
+
// src/features/items/navigation.ts
|
|
7
|
+
function orderKeepItems(items) {
|
|
8
|
+
if (!items.some((item) => item.order !== void 0)) return [...items];
|
|
9
|
+
return items.map((item, index) => ({ item, index })).sort((left, right) => {
|
|
10
|
+
const leftOrder = left.item.order;
|
|
11
|
+
const rightOrder = right.item.order;
|
|
12
|
+
if (leftOrder === void 0 && rightOrder !== void 0) return 1;
|
|
13
|
+
if (leftOrder !== void 0 && rightOrder === void 0) return -1;
|
|
14
|
+
if (leftOrder !== void 0 && rightOrder !== void 0 && leftOrder !== rightOrder) {
|
|
15
|
+
return leftOrder - rightOrder;
|
|
16
|
+
}
|
|
17
|
+
return left.index - right.index;
|
|
18
|
+
}).map(({ item }) => item);
|
|
19
|
+
}
|
|
20
|
+
function getKeepNavigationState(source, current) {
|
|
21
|
+
const items = orderKeepItems(source);
|
|
22
|
+
const currentIndex = typeof current === "number" ? Number.isInteger(current) && current >= 0 && current < items.length ? current : -1 : current === void 0 ? -1 : items.findIndex((item) => item.id === current);
|
|
23
|
+
const currentItem = currentIndex >= 0 ? items[currentIndex] ?? null : null;
|
|
24
|
+
return {
|
|
25
|
+
items,
|
|
26
|
+
currentIndex,
|
|
27
|
+
currentPosition: currentIndex >= 0 ? currentIndex + 1 : null,
|
|
28
|
+
currentItem,
|
|
29
|
+
hasNext: currentIndex >= 0 && currentIndex < items.length - 1,
|
|
30
|
+
hasPrev: currentIndex > 0,
|
|
31
|
+
nextItem: currentIndex >= 0 ? items[currentIndex + 1] ?? null : null,
|
|
32
|
+
prevItem: currentIndex > 0 ? items[currentIndex - 1] ?? null : null
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function reorderKeepItems(source, orderedIds) {
|
|
36
|
+
const byId = new Map(source.map((item) => [item.id, item]));
|
|
37
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const id of orderedIds) {
|
|
39
|
+
if (!byId.has(id)) throw new Error(`Cannot reorder unknown Keep item "${id}".`);
|
|
40
|
+
if (seen.has(id)) throw new Error(`Cannot reorder Keep items with duplicate id "${id}".`);
|
|
41
|
+
seen.add(id);
|
|
42
|
+
}
|
|
43
|
+
const current = orderKeepItems(source);
|
|
44
|
+
const sequence = [...orderedIds, ...current.map((item) => item.id).filter((id) => !seen.has(id))];
|
|
45
|
+
return sequence.map((id, order) => {
|
|
46
|
+
const item = byId.get(id);
|
|
47
|
+
if (!item) throw new Error(`Cannot reorder unknown Keep item "${id}".`);
|
|
48
|
+
return { ...item, order };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function moveKeepItem(source, id, targetIndex) {
|
|
52
|
+
const items = orderKeepItems(source);
|
|
53
|
+
const currentIndex = items.findIndex((item2) => item2.id === id);
|
|
54
|
+
if (currentIndex < 0) throw new Error(`Cannot move unknown Keep item "${id}".`);
|
|
55
|
+
if (!Number.isInteger(targetIndex)) throw new Error("Keep item targetIndex must be an integer.");
|
|
56
|
+
const nextIndex = Math.min(Math.max(0, targetIndex), items.length - 1);
|
|
57
|
+
const [item] = items.splice(currentIndex, 1);
|
|
58
|
+
items.splice(nextIndex, 0, item);
|
|
59
|
+
return reorderKeepItems(
|
|
60
|
+
items,
|
|
61
|
+
items.map((entry) => entry.id)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/features/items/query.ts
|
|
66
|
+
function createInboxQuery(options = {}) {
|
|
67
|
+
return { organization: { collection: "unassigned", ...options.organization } };
|
|
68
|
+
}
|
|
69
|
+
var DEFAULT_REDISCOVERY_INACTIVE_FOR_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
70
|
+
function createRediscoveryQuery(options) {
|
|
71
|
+
if (options.strategy === "never-opened") return { activity: { opened: "never" } };
|
|
72
|
+
if (options.strategy === "recently-opened") {
|
|
73
|
+
return { activity: { opened: "ever" }, sort: { by: "lastOpenedAt", direction: "desc" } };
|
|
74
|
+
}
|
|
75
|
+
return { activity: { inactiveForMs: options.inactiveForMs ?? DEFAULT_REDISCOVERY_INACTIVE_FOR_MS } };
|
|
76
|
+
}
|
|
77
|
+
function queryKeepItems(source, query = {}) {
|
|
78
|
+
const filtered = source.filter((item) => {
|
|
79
|
+
const [from, to] = query.savedBetween ?? [];
|
|
80
|
+
const savedAt = item.savedAt;
|
|
81
|
+
const lowerBound = from === void 0 ? void 0 : toTimestamp(from);
|
|
82
|
+
const upperBound = to === void 0 ? void 0 : toTimestamp(to);
|
|
83
|
+
return (query.targetType === void 0 || item.targetType === query.targetType) && (query.tags === void 0 || query.tags.every((tag) => item.tags?.includes(tag))) && matchesArchiveScope(item, query) && (query.collectionId === void 0 || item.collectionId === query.collectionId) && matchesOrganization(item, query.organization) && matchesActivity(item, query.activity) && (lowerBound === void 0 || savedAt >= lowerBound) && (upperBound === void 0 || savedAt <= upperBound) && matchesSearch(item, query.search) && (query.filter?.(item) ?? true);
|
|
84
|
+
});
|
|
85
|
+
const tagCounts = getTagCounts(filtered);
|
|
86
|
+
const sortBy = query.sort?.by;
|
|
87
|
+
const direction = query.sort?.direction === "asc" ? 1 : -1;
|
|
88
|
+
const sortedBase = sortBy ? filtered.map((item, index) => ({ item, index })).sort((a, b) => compareSortValues(a.item[sortBy], b.item[sortBy], direction) || a.index - b.index).map(({ item }) => item) : orderKeepItems(filtered);
|
|
89
|
+
const sorted = query.pinnedFirst ? [...sortedBase.filter((item) => item.pinned === true), ...sortedBase.filter((item) => item.pinned !== true)] : sortedBase;
|
|
90
|
+
const pageSize = Math.max(1, query.pagination?.pageSize ?? (sorted.length || 1));
|
|
91
|
+
const pageCount = Math.max(1, Math.ceil(sorted.length / pageSize));
|
|
92
|
+
const page = Math.min(Math.max(1, query.pagination?.page ?? 1), pageCount);
|
|
93
|
+
const offset = (page - 1) * pageSize;
|
|
94
|
+
return {
|
|
95
|
+
items: sorted.slice(offset, offset + pageSize),
|
|
96
|
+
totalCount: sorted.length,
|
|
97
|
+
tagCounts,
|
|
98
|
+
page,
|
|
99
|
+
pageCount,
|
|
100
|
+
hasNextPage: page < pageCount,
|
|
101
|
+
hasPreviousPage: page > 1
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function matchesOrganization(item, organization) {
|
|
105
|
+
if (organization?.collection === "assigned" && !item.collectionId?.trim()) return false;
|
|
106
|
+
if (organization?.collection === "unassigned" && item.collectionId?.trim()) return false;
|
|
107
|
+
if (organization?.tags === "assigned" && !item.tags?.some((tag) => tag.trim())) return false;
|
|
108
|
+
if (organization?.tags === "unassigned" && item.tags?.some((tag) => tag.trim())) return false;
|
|
109
|
+
if (organization?.note === "assigned" && !item.note?.trim()) return false;
|
|
110
|
+
if (organization?.note === "unassigned" && item.note?.trim()) return false;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
function matchesActivity(item, activity) {
|
|
114
|
+
if (!activity) return true;
|
|
115
|
+
const lastOpenedAt = item.lastOpenedAt;
|
|
116
|
+
const opened = lastOpenedAt !== void 0;
|
|
117
|
+
if (activity.opened === "ever" && !opened) return false;
|
|
118
|
+
if (activity.opened === "never" && opened) return false;
|
|
119
|
+
if (activity.lastOpenedBefore !== void 0 && (!opened || lastOpenedAt >= activity.lastOpenedBefore)) return false;
|
|
120
|
+
if (activity.lastOpenedAfter !== void 0 && (!opened || lastOpenedAt <= activity.lastOpenedAfter)) return false;
|
|
121
|
+
if (activity.inactiveForMs !== void 0) {
|
|
122
|
+
const cutoff = Date.now() - activity.inactiveForMs;
|
|
123
|
+
const lastActivityAt = item.lastOpenedAt ?? item.savedAt;
|
|
124
|
+
if (lastActivityAt > cutoff) return false;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
function compareSortValues(left, right, direction) {
|
|
129
|
+
if (left === void 0 && right === void 0) return 0;
|
|
130
|
+
if (left === void 0) return 1;
|
|
131
|
+
if (right === void 0) return -1;
|
|
132
|
+
return (left - right) * direction;
|
|
133
|
+
}
|
|
134
|
+
function matchesArchiveScope(item, query) {
|
|
135
|
+
if (query.archiveScope === "all") return true;
|
|
136
|
+
if (query.archiveScope === "archived") return item.archived === true;
|
|
137
|
+
if (query.archiveScope === "active") return item.archived !== true;
|
|
138
|
+
return query.archived === true ? item.archived === true : item.archived !== true;
|
|
139
|
+
}
|
|
140
|
+
function getTagCounts(items) {
|
|
141
|
+
const counts = {};
|
|
142
|
+
for (const item of items) {
|
|
143
|
+
for (const tag of item.tags ?? []) counts[tag] = (counts[tag] ?? 0) + 1;
|
|
144
|
+
}
|
|
145
|
+
return Object.fromEntries(Object.entries(counts).sort(([a], [b]) => a.localeCompare(b)));
|
|
146
|
+
}
|
|
147
|
+
function matchesSearch(item, search) {
|
|
148
|
+
const query = search?.query;
|
|
149
|
+
if (!query?.trim()) return true;
|
|
150
|
+
const fields = search?.fields ?? ["note", "meta", "tags"];
|
|
151
|
+
const values = fields.map((field) => {
|
|
152
|
+
if (field === "note") return item.note ?? "";
|
|
153
|
+
if (field === "tags") return (item.tags ?? []).join(" ");
|
|
154
|
+
try {
|
|
155
|
+
return JSON.stringify(item.meta) ?? "";
|
|
156
|
+
} catch {
|
|
157
|
+
return String(item.meta);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const text = values.join(" ").toLocaleLowerCase();
|
|
161
|
+
const normalized = query.trim().toLocaleLowerCase();
|
|
162
|
+
const needles = search?.tokenize === false ? [normalized] : normalized.split(/\s+/).filter(Boolean);
|
|
163
|
+
const matches = needles.map((needle) => text.includes(needle));
|
|
164
|
+
return search?.mode === "or" ? matches.some(Boolean) : matches.every(Boolean);
|
|
165
|
+
}
|
|
166
|
+
function toTimestamp(value) {
|
|
167
|
+
return value instanceof Date ? value.getTime() : value;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/features/items/revalidation.ts
|
|
171
|
+
function isKeepItemMetadataStale(item, maxAgeMs, now = Date.now) {
|
|
172
|
+
return item.metaUpdatedAt === void 0 || now() - item.metaUpdatedAt >= maxAgeMs;
|
|
173
|
+
}
|
|
174
|
+
async function revalidateKeepItems(source, revalidator, options = {}) {
|
|
175
|
+
const removeStatuses = new Set(options.removeStatuses ?? []);
|
|
176
|
+
const now = options.now ?? Date.now;
|
|
177
|
+
const items = [];
|
|
178
|
+
const updatedItems = [];
|
|
179
|
+
const removedIds = [];
|
|
180
|
+
const results = [];
|
|
181
|
+
for (const item of source) {
|
|
182
|
+
const rawResult = await revalidator(item);
|
|
183
|
+
const result = typeof rawResult === "string" ? { status: rawResult } : rawResult;
|
|
184
|
+
const reason = result.status === "available" ? void 0 : result.reason;
|
|
185
|
+
const defaultResolved = {
|
|
186
|
+
...item,
|
|
187
|
+
status: result.status,
|
|
188
|
+
...result.status === "available" ? { statusReason: void 0 } : { statusReason: reason }
|
|
189
|
+
};
|
|
190
|
+
const resolved = options.resolveItem ? await options.resolveItem(item, result) : defaultResolved;
|
|
191
|
+
if (resolved === void 0) {
|
|
192
|
+
removedIds.push(item.id);
|
|
193
|
+
results.push({ item, status: result.status, reason, updated: false });
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (result.status === "available") {
|
|
197
|
+
const timestamp = now();
|
|
198
|
+
const availableItem = clearItemStatus(resolved);
|
|
199
|
+
const updated = result.meta === void 0 ? availableItem : { ...availableItem, meta: result.meta, metaUpdatedAt: timestamp, updatedAt: timestamp };
|
|
200
|
+
const didUpdate = updated !== item;
|
|
201
|
+
items.push(updated);
|
|
202
|
+
if (didUpdate) updatedItems.push(updated);
|
|
203
|
+
results.push({ item: updated, status: "available", updated: didUpdate });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const withStatus = { ...resolved, status: result.status, ...reason ? { statusReason: reason } : {} };
|
|
207
|
+
const shouldRemove = removeStatuses.has(result.status);
|
|
208
|
+
if (shouldRemove) removedIds.push(item.id);
|
|
209
|
+
else items.push(withStatus);
|
|
210
|
+
if (!shouldRemove && withStatus !== item) updatedItems.push(withStatus);
|
|
211
|
+
results.push({ item: withStatus, status: result.status, reason, updated: !shouldRemove && withStatus !== item });
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
items,
|
|
215
|
+
checked: source.length,
|
|
216
|
+
updated: updatedItems.length,
|
|
217
|
+
removed: removedIds.length,
|
|
218
|
+
updatedItems,
|
|
219
|
+
removedIds,
|
|
220
|
+
results
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async function reconcileKeepItems(storage, revalidator, options = {}) {
|
|
224
|
+
const source = await storage.getAll();
|
|
225
|
+
const summary = await revalidateKeepItems(source, revalidator, options);
|
|
226
|
+
if (summary.updatedItems.length > 0) await persistKeepItems(storage, summary.updatedItems);
|
|
227
|
+
if (summary.removedIds.length > 0) await removeKeepItems(storage, summary.removedIds);
|
|
228
|
+
return summary;
|
|
229
|
+
}
|
|
230
|
+
function clearItemStatus(item) {
|
|
231
|
+
const next = { ...item };
|
|
232
|
+
delete next.status;
|
|
233
|
+
delete next.statusReason;
|
|
234
|
+
return next;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/features/store/store.ts
|
|
238
|
+
var KeepStore = class {
|
|
239
|
+
constructor(initialState) {
|
|
240
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
241
|
+
this.getSnapshot = () => this.state;
|
|
242
|
+
this.subscribe = (listener) => {
|
|
243
|
+
this.listeners.add(listener);
|
|
244
|
+
return () => this.listeners.delete(listener);
|
|
245
|
+
};
|
|
246
|
+
this.state = initialState;
|
|
247
|
+
}
|
|
248
|
+
setState(next) {
|
|
249
|
+
let changed = false;
|
|
250
|
+
for (const key of Object.keys(next)) {
|
|
251
|
+
if (!Object.is(this.state[key], next[key])) {
|
|
252
|
+
changed = true;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (!changed) return;
|
|
257
|
+
this.state = { ...this.state, ...next };
|
|
258
|
+
for (const listener of this.listeners) listener();
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export {
|
|
263
|
+
orderKeepItems,
|
|
264
|
+
getKeepNavigationState,
|
|
265
|
+
reorderKeepItems,
|
|
266
|
+
moveKeepItem,
|
|
267
|
+
createInboxQuery,
|
|
268
|
+
createRediscoveryQuery,
|
|
269
|
+
queryKeepItems,
|
|
270
|
+
getTagCounts,
|
|
271
|
+
isKeepItemMetadataStale,
|
|
272
|
+
revalidateKeepItems,
|
|
273
|
+
reconcileKeepItems,
|
|
274
|
+
KeepStore
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=chunk-CSBPFROD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/items/navigation.ts","../src/features/items/query.ts","../src/features/items/revalidation.ts","../src/features/store/store.ts"],"sourcesContent":["import type { KeepItem } from \"./types\";\n\nexport type KeepNavigationState<TMeta = Record<string, unknown>> = {\n items: KeepItem<TMeta>[];\n currentIndex: number;\n currentPosition: number | null;\n currentItem: KeepItem<TMeta> | null;\n hasNext: boolean;\n hasPrev: boolean;\n nextItem: KeepItem<TMeta> | null;\n prevItem: KeepItem<TMeta> | null;\n};\n\n/** Return items in their persisted custom order, leaving legacy items stable. */\nexport function orderKeepItems<TMeta>(items: readonly KeepItem<TMeta>[]): KeepItem<TMeta>[] {\n if (!items.some((item) => item.order !== undefined)) return [...items];\n return items\n .map((item, index) => ({ item, index }))\n .sort((left, right) => {\n const leftOrder = left.item.order;\n const rightOrder = right.item.order;\n if (leftOrder === undefined && rightOrder !== undefined) return 1;\n if (leftOrder !== undefined && rightOrder === undefined) return -1;\n if (leftOrder !== undefined && rightOrder !== undefined && leftOrder !== rightOrder) {\n return leftOrder - rightOrder;\n }\n return left.index - right.index;\n })\n .map(({ item }) => item);\n}\n\n/** Derive the previous/current/next view for a list and an item id or index. */\nexport function getKeepNavigationState<TMeta = Record<string, unknown>>(\n source: readonly KeepItem<TMeta>[],\n current?: string | number,\n): KeepNavigationState<TMeta> {\n const items = orderKeepItems(source);\n const currentIndex =\n typeof current === \"number\"\n ? Number.isInteger(current) && current >= 0 && current < items.length\n ? current\n : -1\n : current === undefined\n ? -1\n : items.findIndex((item) => item.id === current);\n const currentItem = currentIndex >= 0 ? (items[currentIndex] ?? null) : null;\n return {\n items,\n currentIndex,\n currentPosition: currentIndex >= 0 ? currentIndex + 1 : null,\n currentItem,\n hasNext: currentIndex >= 0 && currentIndex < items.length - 1,\n hasPrev: currentIndex > 0,\n nextItem: currentIndex >= 0 ? (items[currentIndex + 1] ?? null) : null,\n prevItem: currentIndex > 0 ? (items[currentIndex - 1] ?? null) : null,\n };\n}\n\n/** Apply a partial or complete id order and assign stable zero-based positions. */\nexport function reorderKeepItems<TMeta = Record<string, unknown>>(\n source: readonly KeepItem<TMeta>[],\n orderedIds: readonly string[],\n): KeepItem<TMeta>[] {\n const byId = new Map(source.map((item) => [item.id, item]));\n const seen = new Set<string>();\n for (const id of orderedIds) {\n if (!byId.has(id)) throw new Error(`Cannot reorder unknown Keep item \"${id}\".`);\n if (seen.has(id)) throw new Error(`Cannot reorder Keep items with duplicate id \"${id}\".`);\n seen.add(id);\n }\n const current = orderKeepItems(source);\n const sequence = [...orderedIds, ...current.map((item) => item.id).filter((id) => !seen.has(id))];\n return sequence.map((id, order) => {\n const item = byId.get(id);\n if (!item) throw new Error(`Cannot reorder unknown Keep item \"${id}\".`);\n return { ...item, order };\n });\n}\n\n/** Move one item within the current custom/legacy order. */\nexport function moveKeepItem<TMeta = Record<string, unknown>>(\n source: readonly KeepItem<TMeta>[],\n id: string,\n targetIndex: number,\n): KeepItem<TMeta>[] {\n const items = orderKeepItems(source);\n const currentIndex = items.findIndex((item) => item.id === id);\n if (currentIndex < 0) throw new Error(`Cannot move unknown Keep item \"${id}\".`);\n if (!Number.isInteger(targetIndex)) throw new Error(\"Keep item targetIndex must be an integer.\");\n const nextIndex = Math.min(Math.max(0, targetIndex), items.length - 1);\n const [item] = items.splice(currentIndex, 1);\n items.splice(nextIndex, 0, item);\n return reorderKeepItems(\n items,\n items.map((entry) => entry.id),\n );\n}\n","import { orderKeepItems } from \"./navigation\";\nimport type { KeepItem } from \"./types\";\n\nexport type KeepListQuery<TMeta = Record<string, unknown>> = {\n targetType?: string;\n tags?: string[];\n /** Defaults to active (not archived) items; true selects archived items. */\n archived?: boolean;\n /** Optional explicit archive scope. When provided, this takes precedence over `archived`. */\n archiveScope?: \"active\" | \"archived\" | \"all\";\n collectionId?: string;\n organization?: {\n collection?: \"assigned\" | \"unassigned\";\n tags?: \"assigned\" | \"unassigned\";\n note?: \"assigned\" | \"unassigned\";\n };\n pinnedFirst?: boolean;\n activity?: {\n opened?: \"ever\" | \"never\";\n lastOpenedBefore?: number;\n lastOpenedAfter?: number;\n inactiveForMs?: number;\n };\n sort?: {\n by: \"savedAt\" | \"updatedAt\" | \"lastOpenedAt\";\n direction?: \"asc\" | \"desc\";\n };\n search?: {\n query?: string;\n mode?: \"and\" | \"or\";\n tokenize?: boolean;\n fields?: Array<\"note\" | \"meta\" | \"tags\">;\n };\n pagination?: {\n page?: number;\n pageSize?: number;\n };\n filter?: (item: KeepItem<TMeta>) => boolean;\n savedBetween?: readonly [Date | number, Date | number];\n};\n\nexport type QueryKeepItemsResult<TMeta = Record<string, unknown>> = {\n items: KeepItem<TMeta>[];\n totalCount: number;\n tagCounts: Record<string, number>;\n page: number;\n pageCount: number;\n hasNextPage: boolean;\n hasPreviousPage: boolean;\n};\n\nexport type KeepRediscoveryStrategy = \"never-opened\" | \"forgotten\" | \"recently-opened\";\n\nexport type KeepRediscoveryOptions = {\n strategy: KeepRediscoveryStrategy;\n inactiveForMs?: number;\n};\n\n/** Build the default Inbox query: active items without a collection. */\nexport function createInboxQuery<TMeta = Record<string, unknown>>(\n options: { organization?: KeepListQuery<TMeta>[\"organization\"] } = {},\n): KeepListQuery<TMeta> {\n return { organization: { collection: \"unassigned\", ...options.organization } };\n}\n\nconst DEFAULT_REDISCOVERY_INACTIVE_FOR_MS = 30 * 24 * 60 * 60 * 1000;\n\n/** Build a serializable query for common rediscovery views. */\nexport function createRediscoveryQuery<TMeta = Record<string, unknown>>(\n options: KeepRediscoveryOptions,\n): KeepListQuery<TMeta> {\n if (options.strategy === \"never-opened\") return { activity: { opened: \"never\" } };\n if (options.strategy === \"recently-opened\") {\n return { activity: { opened: \"ever\" }, sort: { by: \"lastOpenedAt\", direction: \"desc\" } };\n }\n return { activity: { inactiveForMs: options.inactiveForMs ?? DEFAULT_REDISCOVERY_INACTIVE_FOR_MS } };\n}\n\n/** Apply the collection query and one-based pagination without React. */\nexport function queryKeepItems<TMeta = Record<string, unknown>>(\n source: KeepItem<TMeta>[],\n query: KeepListQuery<TMeta> = {},\n): QueryKeepItemsResult<TMeta> {\n const filtered = source.filter((item) => {\n const [from, to] = query.savedBetween ?? [];\n const savedAt = item.savedAt;\n const lowerBound = from === undefined ? undefined : toTimestamp(from);\n const upperBound = to === undefined ? undefined : toTimestamp(to);\n return (\n (query.targetType === undefined || item.targetType === query.targetType) &&\n (query.tags === undefined || query.tags.every((tag) => item.tags?.includes(tag))) &&\n matchesArchiveScope(item, query) &&\n (query.collectionId === undefined || item.collectionId === query.collectionId) &&\n matchesOrganization(item, query.organization) &&\n matchesActivity(item, query.activity) &&\n (lowerBound === undefined || savedAt >= lowerBound) &&\n (upperBound === undefined || savedAt <= upperBound) &&\n matchesSearch(item, query.search) &&\n (query.filter?.(item) ?? true)\n );\n });\n const tagCounts = getTagCounts(filtered);\n const sortBy = query.sort?.by;\n const direction = query.sort?.direction === \"asc\" ? 1 : -1;\n const sortedBase = sortBy\n ? filtered\n .map((item, index) => ({ item, index }))\n .sort((a, b) => compareSortValues(a.item[sortBy], b.item[sortBy], direction) || a.index - b.index)\n .map(({ item }) => item)\n : orderKeepItems(filtered);\n const sorted = query.pinnedFirst\n ? [...sortedBase.filter((item) => item.pinned === true), ...sortedBase.filter((item) => item.pinned !== true)]\n : sortedBase;\n const pageSize = Math.max(1, query.pagination?.pageSize ?? (sorted.length || 1));\n const pageCount = Math.max(1, Math.ceil(sorted.length / pageSize));\n const page = Math.min(Math.max(1, query.pagination?.page ?? 1), pageCount);\n const offset = (page - 1) * pageSize;\n\n return {\n items: sorted.slice(offset, offset + pageSize),\n totalCount: sorted.length,\n tagCounts,\n page,\n pageCount,\n hasNextPage: page < pageCount,\n hasPreviousPage: page > 1,\n };\n}\n\nfunction matchesOrganization<TMeta>(\n item: KeepItem<TMeta>,\n organization: KeepListQuery<TMeta>[\"organization\"],\n): boolean {\n if (organization?.collection === \"assigned\" && !item.collectionId?.trim()) return false;\n if (organization?.collection === \"unassigned\" && item.collectionId?.trim()) return false;\n if (organization?.tags === \"assigned\" && !item.tags?.some((tag) => tag.trim())) return false;\n if (organization?.tags === \"unassigned\" && item.tags?.some((tag) => tag.trim())) return false;\n if (organization?.note === \"assigned\" && !item.note?.trim()) return false;\n if (organization?.note === \"unassigned\" && item.note?.trim()) return false;\n return true;\n}\n\nfunction matchesActivity<TMeta>(item: KeepItem<TMeta>, activity?: KeepListQuery<TMeta>[\"activity\"]): boolean {\n if (!activity) return true;\n const lastOpenedAt = item.lastOpenedAt;\n const opened = lastOpenedAt !== undefined;\n if (activity.opened === \"ever\" && !opened) return false;\n if (activity.opened === \"never\" && opened) return false;\n if (activity.lastOpenedBefore !== undefined && (!opened || lastOpenedAt >= activity.lastOpenedBefore)) return false;\n if (activity.lastOpenedAfter !== undefined && (!opened || lastOpenedAt <= activity.lastOpenedAfter)) return false;\n if (activity.inactiveForMs !== undefined) {\n const cutoff = Date.now() - activity.inactiveForMs;\n const lastActivityAt = item.lastOpenedAt ?? item.savedAt;\n if (lastActivityAt > cutoff) return false;\n }\n return true;\n}\n\nfunction compareSortValues(left: number | undefined, right: number | undefined, direction: 1 | -1): number {\n if (left === undefined && right === undefined) return 0;\n if (left === undefined) return 1;\n if (right === undefined) return -1;\n return (left - right) * direction;\n}\n\nfunction matchesArchiveScope<TMeta>(item: KeepItem<TMeta>, query: KeepListQuery<TMeta>): boolean {\n if (query.archiveScope === \"all\") return true;\n if (query.archiveScope === \"archived\") return item.archived === true;\n if (query.archiveScope === \"active\") return item.archived !== true;\n return query.archived === true ? item.archived === true : item.archived !== true;\n}\n\nexport function getTagCounts<TMeta = Record<string, unknown>>(items: KeepItem<TMeta>[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const item of items) {\n for (const tag of item.tags ?? []) counts[tag] = (counts[tag] ?? 0) + 1;\n }\n return Object.fromEntries(Object.entries(counts).sort(([a], [b]) => a.localeCompare(b)));\n}\n\nfunction matchesSearch<TMeta>(item: KeepItem<TMeta>, search?: KeepListQuery<TMeta>[\"search\"]): boolean {\n const query = search?.query;\n if (!query?.trim()) return true;\n const fields = search?.fields ?? [\"note\", \"meta\", \"tags\"];\n const values = fields.map((field) => {\n if (field === \"note\") return item.note ?? \"\";\n if (field === \"tags\") return (item.tags ?? []).join(\" \");\n try {\n return JSON.stringify(item.meta) ?? \"\";\n } catch {\n return String(item.meta);\n }\n });\n const text = values.join(\" \").toLocaleLowerCase();\n const normalized = query.trim().toLocaleLowerCase();\n const needles = search?.tokenize === false ? [normalized] : normalized.split(/\\s+/).filter(Boolean);\n const matches = needles.map((needle) => text.includes(needle));\n return search?.mode === \"or\" ? matches.some(Boolean) : matches.every(Boolean);\n}\n\nfunction toTimestamp(value: Date | number): number {\n return value instanceof Date ? value.getTime() : value;\n}\n","import { persistKeepItems, removeKeepItems } from \"../persistence/helpers\";\nimport type { KeepItem, KeepItemStatus, StorageAdapter } from \"./types\";\n\nexport type { KeepItemStatus } from \"./types\";\n\nexport type KeepItemRevalidationResult<TMeta = Record<string, unknown>> =\n | { status: \"available\"; meta?: TMeta }\n | { status: Exclude<KeepItemStatus, \"available\">; reason?: string };\n\nexport type KeepItemRevalidator<TMeta = Record<string, unknown>> = (\n item: KeepItem<TMeta>,\n) =>\n | KeepItemRevalidationResult<TMeta>\n | KeepItemRevalidationResult<TMeta>[\"status\"]\n | Promise<KeepItemRevalidationResult<TMeta> | KeepItemRevalidationResult<TMeta>[\"status\"]>;\n\nexport type KeepItemResolver<TMeta = Record<string, unknown>> = (\n item: KeepItem<TMeta>,\n result: KeepItemRevalidationResult<TMeta>,\n) => KeepItem<TMeta> | undefined | Promise<KeepItem<TMeta> | undefined>;\n\nexport type KeepItemMetadataRefresher<TMeta = Record<string, unknown>> = (\n item: KeepItem<TMeta>,\n) => TMeta | Promise<TMeta>;\n\n/** Return whether source metadata should be fetched again based on its age. */\nexport function isKeepItemMetadataStale<TMeta>(\n item: KeepItem<TMeta>,\n maxAgeMs: number,\n now: () => number = Date.now,\n): boolean {\n return item.metaUpdatedAt === undefined || now() - item.metaUpdatedAt >= maxAgeMs;\n}\n\nexport type KeepItemRevalidationRecord<TMeta = Record<string, unknown>> = {\n item: KeepItem<TMeta>;\n status: KeepItemStatus;\n reason?: string;\n updated: boolean;\n};\n\nexport type RevalidateKeepItemsOptions<TMeta = Record<string, unknown>> = {\n /** Statuses that should be removed after they are detected. Detection is the default. */\n removeStatuses?: Array<Exclude<KeepItemStatus, \"available\">>;\n now?: () => number;\n resolveItem?: KeepItemResolver<TMeta>;\n};\n\nexport type KeepAutoRevalidationOptions<TMeta = Record<string, unknown>> = {\n /** Revalidate after the provider hydrates. Defaults to true when validateItem is supplied. */\n onMount?: boolean;\n /** Revalidate when the browser returns online. Defaults to true. */\n onReconnect?: boolean;\n /** Revalidate repeatedly while mounted. Disabled by default. */\n intervalMs?: number;\n removeStatuses?: Array<Exclude<KeepItemStatus, \"available\">>;\n revalidator?: KeepItemRevalidator<TMeta>;\n};\n\nexport type KeepItemRevalidationSummary<TMeta = Record<string, unknown>> = {\n items: KeepItem<TMeta>[];\n checked: number;\n updated: number;\n removed: number;\n updatedItems: KeepItem<TMeta>[];\n removedIds: string[];\n results: KeepItemRevalidationRecord<TMeta>[];\n};\n\n/** Revalidate saved items without coupling the checker to a network client. */\nexport async function revalidateKeepItems<TMeta = Record<string, unknown>>(\n source: KeepItem<TMeta>[],\n revalidator: KeepItemRevalidator<TMeta>,\n options: RevalidateKeepItemsOptions<TMeta> = {},\n): Promise<KeepItemRevalidationSummary<TMeta>> {\n const removeStatuses = new Set(options.removeStatuses ?? []);\n const now = options.now ?? Date.now;\n const items: KeepItem<TMeta>[] = [];\n const updatedItems: KeepItem<TMeta>[] = [];\n const removedIds: string[] = [];\n const results: KeepItemRevalidationRecord<TMeta>[] = [];\n\n for (const item of source) {\n const rawResult = await revalidator(item);\n const result: KeepItemRevalidationResult<TMeta> = typeof rawResult === \"string\" ? { status: rawResult } : rawResult;\n const reason = result.status === \"available\" ? undefined : result.reason;\n const defaultResolved = {\n ...item,\n status: result.status,\n ...(result.status === \"available\" ? { statusReason: undefined } : { statusReason: reason }),\n };\n const resolved = options.resolveItem\n ? await (options.resolveItem as KeepItemResolver<TMeta>)(item, result)\n : defaultResolved;\n if (resolved === undefined) {\n removedIds.push(item.id);\n results.push({ item, status: result.status, reason, updated: false });\n continue;\n }\n if (result.status === \"available\") {\n const timestamp = now();\n const availableItem = clearItemStatus(resolved);\n const updated =\n result.meta === undefined\n ? availableItem\n : { ...availableItem, meta: result.meta, metaUpdatedAt: timestamp, updatedAt: timestamp };\n const didUpdate = updated !== item;\n items.push(updated);\n if (didUpdate) updatedItems.push(updated);\n results.push({ item: updated, status: \"available\", updated: didUpdate });\n continue;\n }\n\n const withStatus = { ...resolved, status: result.status, ...(reason ? { statusReason: reason } : {}) };\n const shouldRemove = removeStatuses.has(result.status);\n if (shouldRemove) removedIds.push(item.id);\n else items.push(withStatus);\n if (!shouldRemove && withStatus !== item) updatedItems.push(withStatus);\n results.push({ item: withStatus, status: result.status, reason, updated: !shouldRemove && withStatus !== item });\n }\n\n return {\n items,\n checked: source.length,\n updated: updatedItems.length,\n removed: removedIds.length,\n updatedItems,\n removedIds,\n results,\n };\n}\n\n/** Revalidate and persist saved items for framework-neutral applications. */\nexport async function reconcileKeepItems<TMeta = Record<string, unknown>>(\n storage: StorageAdapter<TMeta>,\n revalidator: KeepItemRevalidator<TMeta>,\n options: RevalidateKeepItemsOptions<TMeta> = {},\n): Promise<KeepItemRevalidationSummary<TMeta>> {\n const source = await storage.getAll();\n const summary = await revalidateKeepItems(source, revalidator, options);\n if (summary.updatedItems.length > 0) await persistKeepItems(storage, summary.updatedItems);\n if (summary.removedIds.length > 0) await removeKeepItems(storage, summary.removedIds);\n return summary;\n}\n\nfunction clearItemStatus<TMeta>(item: KeepItem<TMeta>): KeepItem<TMeta> {\n const next = { ...item };\n delete next.status;\n delete next.statusReason;\n return next;\n}\n","import type {\n KeepItemMetadataRefresher,\n KeepItemRevalidationSummary,\n KeepItemRevalidator,\n RevalidateKeepItemsOptions,\n} from \"../items/revalidation\";\nimport type { KeepChangeContext, KeepItem, KeepUndoState } from \"../items/types\";\n\nexport type KeepCollectionMeta = { name: string };\n\nexport type KeepStoreState<TMeta = Record<string, unknown>> = {\n items: KeepItem<TMeta>[];\n collections: Record<string, KeepCollectionMeta>;\n isLoading: boolean;\n isHydrated: boolean;\n isMutating: boolean;\n error: unknown | null;\n lastChange?: KeepChangeContext<TMeta>;\n undo?: KeepUndoState;\n};\n\nexport type KeepStoreActions<TMeta = Record<string, unknown>> = {\n saveItem: (item: KeepItem<TMeta>) => Promise<void>;\n recordOpen: (id: string, openedAt?: number) => Promise<void>;\n updateNote: (id: string, note?: string) => Promise<void>;\n updateTags: (id: string, tags?: string[]) => Promise<void>;\n toggleArchive: (id: string) => Promise<void>;\n archiveItem: (id: string) => Promise<void>;\n unarchiveItem: (id: string) => Promise<void>;\n togglePin: (id: string) => Promise<void>;\n moveToCollection: (id: string, collectionId?: string) => Promise<void>;\n archiveBatch: (ids: string[]) => Promise<void>;\n unarchiveBatch: (ids: string[]) => Promise<void>;\n pinBatch: (ids: string[]) => Promise<void>;\n unpinBatch: (ids: string[]) => Promise<void>;\n moveToCollectionBatch: (ids: string[], collectionId?: string) => Promise<void>;\n createCollection: (id: string, name: string) => Promise<void>;\n renameCollection: (id: string, name: string) => Promise<void>;\n removeCollection: (id: string) => Promise<void>;\n updateTagsBatch: (ids: string[], tags?: string[]) => Promise<void>;\n addTagsBatch: (ids: string[], tags: string[]) => Promise<void>;\n removeTagsBatch: (ids: string[], tags: string[]) => Promise<void>;\n removeItem: (id: string) => Promise<void>;\n removeItems: (ids: string[]) => Promise<void>;\n removeItemWithUndo: (id: string) => Promise<void>;\n removeItemsWithUndo: (ids: string[]) => Promise<void>;\n undoLastRemoval: () => Promise<void>;\n clear: () => Promise<void>;\n refresh: () => Promise<void>;\n refreshItemMetadata: (id: string, refresh: KeepItemMetadataRefresher<TMeta>) => Promise<void>;\n revalidateItems: (\n revalidator: KeepItemRevalidator<TMeta>,\n options?: RevalidateKeepItemsOptions<TMeta>,\n ) => Promise<KeepItemRevalidationSummary<TMeta>>;\n reorderItems: (orderedIds: string[]) => Promise<void>;\n moveItem: (id: string, targetIndex: number) => Promise<void>;\n};\n\nexport class KeepStore<TMeta = Record<string, unknown>> {\n private state: KeepStoreState<TMeta>;\n private readonly listeners = new Set<() => void>();\n\n constructor(initialState: KeepStoreState<TMeta>) {\n this.state = initialState;\n }\n\n getSnapshot = (): KeepStoreState<TMeta> => this.state;\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n };\n\n setState(next: Partial<KeepStoreState<TMeta>>): void {\n let changed = false;\n for (const key of Object.keys(next) as Array<keyof KeepStoreState<TMeta>>) {\n if (!Object.is(this.state[key], next[key])) {\n changed = true;\n break;\n }\n }\n if (!changed) return;\n this.state = { ...this.state, ...next };\n for (const listener of this.listeners) listener();\n }\n}\n"],"mappings":";;;;;;AAcO,SAAS,eAAsB,OAAsD;AAC1F,MAAI,CAAC,MAAM,KAAK,CAAC,SAAS,KAAK,UAAU,MAAS,EAAG,QAAO,CAAC,GAAG,KAAK;AACrE,SAAO,MACJ,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,MAAM,EAAE,EACtC,KAAK,CAAC,MAAM,UAAU;AACrB,UAAM,YAAY,KAAK,KAAK;AAC5B,UAAM,aAAa,MAAM,KAAK;AAC9B,QAAI,cAAc,UAAa,eAAe,OAAW,QAAO;AAChE,QAAI,cAAc,UAAa,eAAe,OAAW,QAAO;AAChE,QAAI,cAAc,UAAa,eAAe,UAAa,cAAc,YAAY;AACnF,aAAO,YAAY;AAAA,IACrB;AACA,WAAO,KAAK,QAAQ,MAAM;AAAA,EAC5B,CAAC,EACA,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAC3B;AAGO,SAAS,uBACd,QACA,SAC4B;AAC5B,QAAM,QAAQ,eAAe,MAAM;AACnC,QAAM,eACJ,OAAO,YAAY,WACf,OAAO,UAAU,OAAO,KAAK,WAAW,KAAK,UAAU,MAAM,SAC3D,UACA,KACF,YAAY,SACV,KACA,MAAM,UAAU,CAAC,SAAS,KAAK,OAAO,OAAO;AACrD,QAAM,cAAc,gBAAgB,IAAK,MAAM,YAAY,KAAK,OAAQ;AACxE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,iBAAiB,gBAAgB,IAAI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