@buoy-gg/time-machine 7.0.41 → 7.0.42

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.
Files changed (172) hide show
  1. package/lib/commonjs/components/HeaderActions.js +1 -91
  2. package/lib/commonjs/components/HeaderReloadButton.js +1 -58
  3. package/lib/commonjs/components/TimeMachineBody.js +1 -282
  4. package/lib/commonjs/components/TimeMachineModal.js +1 -74
  5. package/lib/commonjs/components/confirm.js +2 -38
  6. package/lib/commonjs/components/floating/NamePromptModal.js +1 -193
  7. package/lib/commonjs/components/floating/TimeMachineFloatingTool.js +1 -715
  8. package/lib/commonjs/components/floating/armedPoint.js +1 -92
  9. package/lib/commonjs/components/floating/barSettings.js +1 -66
  10. package/lib/commonjs/components/format.js +1 -24
  11. package/lib/commonjs/components/list/CaptureBar.js +1 -97
  12. package/lib/commonjs/components/list/RestoreOutcomeCard.js +1 -175
  13. package/lib/commonjs/components/list/SnapshotRow.js +1 -170
  14. package/lib/commonjs/components/list/SourcesStrip.js +1 -172
  15. package/lib/commonjs/components/list/UndoDeleteBar.js +1 -85
  16. package/lib/commonjs/components/list/WipeAllRow.js +1 -46
  17. package/lib/commonjs/components/preview/ItemDiffPanel.js +1 -79
  18. package/lib/commonjs/components/preview/PreviewFlow.js +1 -51
  19. package/lib/commonjs/components/preview/RestorePointNameRow.js +1 -83
  20. package/lib/commonjs/components/preview/RestorePreviewScreen.js +1 -1010
  21. package/lib/commonjs/components/preview/verdictMeta.js +1 -58
  22. package/lib/commonjs/components/sources.js +1 -83
  23. package/lib/commonjs/hooks/useTimeMachine.js +1 -24
  24. package/lib/commonjs/index.js +1 -161
  25. package/lib/commonjs/preset.js +1 -56
  26. package/lib/commonjs/store/routeRestore.js +1 -188
  27. package/lib/commonjs/store/snapshotVault.js +1 -186
  28. package/lib/commonjs/store/sourceIds.js +1 -9
  29. package/lib/commonjs/store/sourceSettings.js +1 -79
  30. package/lib/commonjs/store/timeMachineStore.js +1 -848
  31. package/lib/commonjs/sync/timeMachineSyncAdapter.js +1 -258
  32. package/lib/commonjs/ui/SwipeActionsRow.js +1 -178
  33. package/lib/commonjs/ui/primitives.js +1 -172
  34. package/lib/commonjs/ui/tmTheme.js +1 -118
  35. package/lib/module/components/HeaderActions.js +1 -85
  36. package/lib/module/components/HeaderReloadButton.js +1 -53
  37. package/lib/module/components/TimeMachineBody.js +1 -277
  38. package/lib/module/components/TimeMachineModal.js +1 -68
  39. package/lib/module/components/confirm.js +2 -33
  40. package/lib/module/components/floating/NamePromptModal.js +1 -188
  41. package/lib/module/components/floating/TimeMachineFloatingTool.js +1 -708
  42. package/lib/module/components/floating/armedPoint.js +1 -82
  43. package/lib/module/components/floating/barSettings.js +1 -57
  44. package/lib/module/components/format.js +1 -19
  45. package/lib/module/components/list/CaptureBar.js +1 -92
  46. package/lib/module/components/list/RestoreOutcomeCard.js +1 -169
  47. package/lib/module/components/list/SnapshotRow.js +1 -167
  48. package/lib/module/components/list/SourcesStrip.js +1 -169
  49. package/lib/module/components/list/UndoDeleteBar.js +1 -82
  50. package/lib/module/components/list/WipeAllRow.js +1 -41
  51. package/lib/module/components/preview/ItemDiffPanel.js +1 -74
  52. package/lib/module/components/preview/PreviewFlow.js +1 -46
  53. package/lib/module/components/preview/RestorePointNameRow.js +1 -78
  54. package/lib/module/components/preview/RestorePreviewScreen.js +1 -1005
  55. package/lib/module/components/preview/verdictMeta.js +1 -54
  56. package/lib/module/components/sources.js +1 -73
  57. package/lib/module/hooks/useTimeMachine.js +1 -19
  58. package/lib/module/index.js +1 -46
  59. package/lib/module/preset.js +1 -51
  60. package/lib/module/store/routeRestore.js +1 -176
  61. package/lib/module/store/snapshotVault.js +1 -170
  62. package/lib/module/store/sourceIds.js +1 -5
  63. package/lib/module/store/sourceSettings.js +1 -69
  64. package/lib/module/store/timeMachineStore.js +1 -839
  65. package/lib/module/sync/timeMachineSyncAdapter.js +1 -253
  66. package/lib/module/ui/SwipeActionsRow.js +1 -173
  67. package/lib/module/ui/primitives.js +1 -164
  68. package/lib/module/ui/tmTheme.js +1 -114
  69. package/lib/web/index.mjs +2 -3
  70. package/package.json +7 -7
  71. package/lib/commonjs/components/HeaderActions.js.map +0 -1
  72. package/lib/commonjs/components/HeaderReloadButton.js.map +0 -1
  73. package/lib/commonjs/components/TimeMachineBody.js.map +0 -1
  74. package/lib/commonjs/components/TimeMachineModal.js.map +0 -1
  75. package/lib/commonjs/components/confirm.js.map +0 -1
  76. package/lib/commonjs/components/floating/NamePromptModal.js.map +0 -1
  77. package/lib/commonjs/components/floating/TimeMachineFloatingTool.js.map +0 -1
  78. package/lib/commonjs/components/floating/armedPoint.js.map +0 -1
  79. package/lib/commonjs/components/floating/barSettings.js.map +0 -1
  80. package/lib/commonjs/components/format.js.map +0 -1
  81. package/lib/commonjs/components/list/CaptureBar.js.map +0 -1
  82. package/lib/commonjs/components/list/RestoreOutcomeCard.js.map +0 -1
  83. package/lib/commonjs/components/list/SnapshotRow.js.map +0 -1
  84. package/lib/commonjs/components/list/SourcesStrip.js.map +0 -1
  85. package/lib/commonjs/components/list/UndoDeleteBar.js.map +0 -1
  86. package/lib/commonjs/components/list/WipeAllRow.js.map +0 -1
  87. package/lib/commonjs/components/preview/ItemDiffPanel.js.map +0 -1
  88. package/lib/commonjs/components/preview/PreviewFlow.js.map +0 -1
  89. package/lib/commonjs/components/preview/RestorePointNameRow.js.map +0 -1
  90. package/lib/commonjs/components/preview/RestorePreviewScreen.js.map +0 -1
  91. package/lib/commonjs/components/preview/verdictMeta.js.map +0 -1
  92. package/lib/commonjs/components/sources.js.map +0 -1
  93. package/lib/commonjs/hooks/useTimeMachine.js.map +0 -1
  94. package/lib/commonjs/index.js.map +0 -1
  95. package/lib/commonjs/preset.js.map +0 -1
  96. package/lib/commonjs/store/routeRestore.js.map +0 -1
  97. package/lib/commonjs/store/snapshotVault.js.map +0 -1
  98. package/lib/commonjs/store/sourceIds.js.map +0 -1
  99. package/lib/commonjs/store/sourceSettings.js.map +0 -1
  100. package/lib/commonjs/store/timeMachineStore.js.map +0 -1
  101. package/lib/commonjs/sync/timeMachineSyncAdapter.js.map +0 -1
  102. package/lib/commonjs/ui/SwipeActionsRow.js.map +0 -1
  103. package/lib/commonjs/ui/primitives.js.map +0 -1
  104. package/lib/commonjs/ui/tmTheme.js.map +0 -1
  105. package/lib/module/components/HeaderActions.js.map +0 -1
  106. package/lib/module/components/HeaderReloadButton.js.map +0 -1
  107. package/lib/module/components/TimeMachineBody.js.map +0 -1
  108. package/lib/module/components/TimeMachineModal.js.map +0 -1
  109. package/lib/module/components/confirm.js.map +0 -1
  110. package/lib/module/components/floating/NamePromptModal.js.map +0 -1
  111. package/lib/module/components/floating/TimeMachineFloatingTool.js.map +0 -1
  112. package/lib/module/components/floating/armedPoint.js.map +0 -1
  113. package/lib/module/components/floating/barSettings.js.map +0 -1
  114. package/lib/module/components/format.js.map +0 -1
  115. package/lib/module/components/list/CaptureBar.js.map +0 -1
  116. package/lib/module/components/list/RestoreOutcomeCard.js.map +0 -1
  117. package/lib/module/components/list/SnapshotRow.js.map +0 -1
  118. package/lib/module/components/list/SourcesStrip.js.map +0 -1
  119. package/lib/module/components/list/UndoDeleteBar.js.map +0 -1
  120. package/lib/module/components/list/WipeAllRow.js.map +0 -1
  121. package/lib/module/components/preview/ItemDiffPanel.js.map +0 -1
  122. package/lib/module/components/preview/PreviewFlow.js.map +0 -1
  123. package/lib/module/components/preview/RestorePointNameRow.js.map +0 -1
  124. package/lib/module/components/preview/RestorePreviewScreen.js.map +0 -1
  125. package/lib/module/components/preview/verdictMeta.js.map +0 -1
  126. package/lib/module/components/sources.js.map +0 -1
  127. package/lib/module/hooks/useTimeMachine.js.map +0 -1
  128. package/lib/module/index.js.map +0 -1
  129. package/lib/module/preset.js.map +0 -1
  130. package/lib/module/store/routeRestore.js.map +0 -1
  131. package/lib/module/store/snapshotVault.js.map +0 -1
  132. package/lib/module/store/sourceIds.js.map +0 -1
  133. package/lib/module/store/sourceSettings.js.map +0 -1
  134. package/lib/module/store/timeMachineStore.js.map +0 -1
  135. package/lib/module/sync/timeMachineSyncAdapter.js.map +0 -1
  136. package/lib/module/ui/SwipeActionsRow.js.map +0 -1
  137. package/lib/module/ui/primitives.js.map +0 -1
  138. package/lib/module/ui/tmTheme.js.map +0 -1
  139. package/lib/typescript/components/HeaderActions.d.ts.map +0 -1
  140. package/lib/typescript/components/HeaderReloadButton.d.ts.map +0 -1
  141. package/lib/typescript/components/TimeMachineBody.d.ts.map +0 -1
  142. package/lib/typescript/components/TimeMachineModal.d.ts.map +0 -1
  143. package/lib/typescript/components/confirm.d.ts.map +0 -1
  144. package/lib/typescript/components/floating/NamePromptModal.d.ts.map +0 -1
  145. package/lib/typescript/components/floating/TimeMachineFloatingTool.d.ts.map +0 -1
  146. package/lib/typescript/components/floating/armedPoint.d.ts.map +0 -1
  147. package/lib/typescript/components/floating/barSettings.d.ts.map +0 -1
  148. package/lib/typescript/components/format.d.ts.map +0 -1
  149. package/lib/typescript/components/list/CaptureBar.d.ts.map +0 -1
  150. package/lib/typescript/components/list/RestoreOutcomeCard.d.ts.map +0 -1
  151. package/lib/typescript/components/list/SnapshotRow.d.ts.map +0 -1
  152. package/lib/typescript/components/list/SourcesStrip.d.ts.map +0 -1
  153. package/lib/typescript/components/list/UndoDeleteBar.d.ts.map +0 -1
  154. package/lib/typescript/components/list/WipeAllRow.d.ts.map +0 -1
  155. package/lib/typescript/components/preview/ItemDiffPanel.d.ts.map +0 -1
  156. package/lib/typescript/components/preview/PreviewFlow.d.ts.map +0 -1
  157. package/lib/typescript/components/preview/RestorePointNameRow.d.ts.map +0 -1
  158. package/lib/typescript/components/preview/RestorePreviewScreen.d.ts.map +0 -1
  159. package/lib/typescript/components/preview/verdictMeta.d.ts.map +0 -1
  160. package/lib/typescript/components/sources.d.ts.map +0 -1
  161. package/lib/typescript/hooks/useTimeMachine.d.ts.map +0 -1
  162. package/lib/typescript/index.d.ts.map +0 -1
  163. package/lib/typescript/preset.d.ts.map +0 -1
  164. package/lib/typescript/store/routeRestore.d.ts.map +0 -1
  165. package/lib/typescript/store/snapshotVault.d.ts.map +0 -1
  166. package/lib/typescript/store/sourceIds.d.ts.map +0 -1
  167. package/lib/typescript/store/sourceSettings.d.ts.map +0 -1
  168. package/lib/typescript/store/timeMachineStore.d.ts.map +0 -1
  169. package/lib/typescript/sync/timeMachineSyncAdapter.d.ts.map +0 -1
  170. package/lib/typescript/ui/SwipeActionsRow.d.ts.map +0 -1
  171. package/lib/typescript/ui/primitives.d.ts.map +0 -1
  172. package/lib/typescript/ui/tmTheme.d.ts.map +0 -1
@@ -1,186 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.deleteSnapshot = deleteSnapshot;
7
- exports.duplicateSnapshot = duplicateSnapshot;
8
- exports.loadIndex = loadIndex;
9
- exports.loadSnapshot = loadSnapshot;
10
- exports.markSnapshotRestored = markSnapshotRestored;
11
- exports.readSnapshot = readSnapshot;
12
- exports.renameSnapshot = renameSnapshot;
13
- exports.restoreDeletedSnapshot = restoreDeletedSnapshot;
14
- exports.saveSnapshot = saveSnapshot;
15
- exports.setSnapshotExclusions = setSnapshotExclusions;
16
- exports.setSnapshotRestoreRoute = setSnapshotRestoreRoute;
17
- exports.setSnapshotScope = setSnapshotScope;
18
- var _sharedUi = require("@buoy-gg/shared-ui");
19
- /**
20
- * Snapshot persistence for Time Machine.
21
- *
22
- * Snapshots live ON-DEVICE in persistentStorage (FileSystem → AsyncStorage →
23
- * localStorage → Memory fallback): no size caps, survives restarts, and never
24
- * crosses the 2MB external-sync snapshot budget — only metadata does.
25
- *
26
- * Layout: ONE storage key per snapshot (persistentStorage's FileSystem
27
- * backend writes one file per key, and its multiGet is sequential — a single
28
- * big key beats many small ones), plus one index key holding the metadata
29
- * list for cheap listing.
30
- *
31
- * Keys use the `@react_buoy` family so every tool's isDevToolsStorageKey
32
- * filter (including our own storage provider) excludes the vault itself from
33
- * snapshots — a snapshot must never contain snapshots.
34
- */
35
-
36
- const INDEX_KEY = "@react_buoy_time_machine:index";
37
- const SNAP_PREFIX = "@react_buoy_time_machine:snap:";
38
- async function loadIndex() {
39
- try {
40
- const raw = await _sharedUi.persistentStorage.getItem(INDEX_KEY);
41
- if (!raw) return [];
42
- const parsed = JSON.parse(raw);
43
- return Array.isArray(parsed) ? parsed : [];
44
- } catch {
45
- return [];
46
- }
47
- }
48
- async function saveIndex(metas) {
49
- await _sharedUi.persistentStorage.setItem(INDEX_KEY, JSON.stringify(metas));
50
- }
51
-
52
- /** Persists the snapshot, stamps meta.sizeBytes, and updates the index. */
53
- async function saveSnapshot(snapshot, metas) {
54
- const serialized = JSON.stringify(snapshot);
55
- snapshot.meta.sizeBytes = serialized.length;
56
- await _sharedUi.persistentStorage.setItem(SNAP_PREFIX + snapshot.meta.id,
57
- // Re-stringify so the persisted copy carries the final sizeBytes.
58
- JSON.stringify(snapshot));
59
- const next = [snapshot.meta, ...metas.filter(m => m.id !== snapshot.meta.id)];
60
- await saveIndex(next);
61
- return next;
62
- }
63
- async function loadSnapshot(id) {
64
- try {
65
- const raw = await _sharedUi.persistentStorage.getItem(SNAP_PREFIX + id);
66
- return raw ? JSON.parse(raw) : null;
67
- } catch {
68
- return null;
69
- }
70
- }
71
- async function deleteSnapshot(id, metas) {
72
- await _sharedUi.persistentStorage.removeItem(SNAP_PREFIX + id);
73
- const next = metas.filter(m => m.id !== id);
74
- await saveIndex(next);
75
- return next;
76
- }
77
-
78
- /**
79
- * Rewrite one snapshot's metadata in BOTH places it lives — the index and the
80
- * snapshot's own record — so a reload can't resurrect the old value from
81
- * whichever one was missed.
82
- */
83
- async function patchMeta(id, patch, metas) {
84
- const apply = m => m.id === id ? patch(m) : m;
85
- const next = metas.map(apply);
86
- await _sharedUi.persistentStorage.setItem(INDEX_KEY, JSON.stringify(next));
87
- const stored = await loadSnapshot(id);
88
- if (stored) {
89
- stored.meta = apply(stored.meta);
90
- await _sharedUi.persistentStorage.setItem(SNAP_PREFIX + id, JSON.stringify(stored));
91
- }
92
- return next;
93
- }
94
-
95
- /** Set (or clear with null/empty) the "only these items" restore scope. */
96
- function setSnapshotScope(id, scope, metas) {
97
- return patchMeta(id, m => {
98
- const next = {
99
- ...m
100
- };
101
- if (scope && scope.length > 0) next.scope = scope;else delete next.scope;
102
- return next;
103
- }, metas);
104
- }
105
-
106
- /**
107
- * Set (or clear with null/empty) the items a restore of this snapshot must
108
- * leave alone. Saving exclusions also clears any legacy `scope`: the two
109
- * answer the same question in opposite directions, and the one the user just
110
- * chose in the preview wins.
111
- */
112
- function setSnapshotExclusions(id, excludedKeys, metas) {
113
- return patchMeta(id, m => {
114
- const next = {
115
- ...m
116
- };
117
- delete next.scope;
118
- if (excludedKeys && excludedKeys.length > 0) next.excludedKeys = excludedKeys;else delete next.excludedKeys;
119
- return next;
120
- }, metas);
121
- }
122
-
123
- /** Turn this point's route restore on or off — the row's route toggle. */
124
- function setSnapshotRestoreRoute(id, restoreRoute, metas) {
125
- return patchMeta(id, m => ({
126
- ...m,
127
- restoreRoute
128
- }), metas);
129
- }
130
-
131
- /** Stamp a restore so the list can say which point you are currently in. */
132
- function markSnapshotRestored(id, at, metas) {
133
- return patchMeta(id, m => ({
134
- ...m,
135
- lastRestoredAt: at
136
- }), metas);
137
- }
138
-
139
- /**
140
- * Copy a stored snapshot under a new id and name. The payload is copied by
141
- * reference into a fresh record — the vault serializes it on write, so the
142
- * two never share mutable state.
143
- */
144
- async function duplicateSnapshot(id, name, metas) {
145
- const stored = await loadSnapshot(id);
146
- if (!stored) return null;
147
- const copy = {
148
- meta: {
149
- ...stored.meta,
150
- id: `${stored.meta.id}_copy_${Date.now().toString(36)}`,
151
- name,
152
- createdAt: Date.now(),
153
- lastRestoredAt: undefined
154
- },
155
- data: stored.data
156
- };
157
- delete copy.meta.lastRestoredAt;
158
- return {
159
- metas: await saveSnapshot(copy, metas),
160
- meta: copy.meta
161
- };
162
- }
163
-
164
- /** Read a whole record so a delete can be held in memory and undone. */
165
- async function readSnapshot(id) {
166
- return loadSnapshot(id);
167
- }
168
-
169
- /** Put a held record back exactly as it was. */
170
- async function restoreDeletedSnapshot(stored, metas) {
171
- return saveSnapshot(stored, metas);
172
- }
173
- async function renameSnapshot(id, name, metas) {
174
- const next = metas.map(m => m.id === id ? {
175
- ...m,
176
- name
177
- } : m);
178
- await saveIndex(next);
179
- const stored = await loadSnapshot(id);
180
- if (stored) {
181
- stored.meta.name = name;
182
- await _sharedUi.persistentStorage.setItem(SNAP_PREFIX + id, JSON.stringify(stored));
183
- }
184
- return next;
185
- }
186
- //# sourceMappingURL=snapshotVault.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.deleteSnapshot=deleteSnapshot;exports.duplicateSnapshot=duplicateSnapshot;exports.loadIndex=loadIndex;exports.loadSnapshot=loadSnapshot;exports.markSnapshotRestored=markSnapshotRestored;exports.readSnapshot=readSnapshot;exports.renameSnapshot=renameSnapshot;exports.restoreDeletedSnapshot=restoreDeletedSnapshot;exports.saveSnapshot=saveSnapshot;exports.setSnapshotExclusions=setSnapshotExclusions;exports.setSnapshotRestoreRoute=setSnapshotRestoreRoute;exports.setSnapshotScope=setSnapshotScope;var _sharedUi=require("@buoy-gg/shared-ui");const INDEX_KEY="@react_buoy_time_machine:index";const SNAP_PREFIX="@react_buoy_time_machine:snap:";async function loadIndex(){try{const t=await _sharedUi.persistentStorage.getItem(INDEX_KEY);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}async function saveIndex(t){await _sharedUi.persistentStorage.setItem(INDEX_KEY,JSON.stringify(t))}async function saveSnapshot(t,e){const s=JSON.stringify(t);t.meta.sizeBytes=s.length;await _sharedUi.persistentStorage.setItem(SNAP_PREFIX+t.meta.id,JSON.stringify(t));const n=[t.meta,...e.filter(a=>a.id!==t.meta.id)];await saveIndex(n);return n}async function loadSnapshot(t){try{const e=await _sharedUi.persistentStorage.getItem(SNAP_PREFIX+t);return e?JSON.parse(e):null}catch{return null}}async function deleteSnapshot(t,e){await _sharedUi.persistentStorage.removeItem(SNAP_PREFIX+t);const s=e.filter(n=>n.id!==t);await saveIndex(s);return s}async function patchMeta(t,e,s){const n=o=>o.id===t?e(o):o;const a=s.map(n);await _sharedUi.persistentStorage.setItem(INDEX_KEY,JSON.stringify(a));const r=await loadSnapshot(t);if(r){r.meta=n(r.meta);await _sharedUi.persistentStorage.setItem(SNAP_PREFIX+t,JSON.stringify(r))}return a}function setSnapshotScope(t,e,s){return patchMeta(t,n=>{const a={...n};if(e&&e.length>0)a.scope=e;else delete a.scope;return a},s)}function setSnapshotExclusions(t,e,s){return patchMeta(t,n=>{const a={...n};delete a.scope;if(e&&e.length>0)a.excludedKeys=e;else delete a.excludedKeys;return a},s)}function setSnapshotRestoreRoute(t,e,s){return patchMeta(t,n=>({...n,restoreRoute:e}),s)}function markSnapshotRestored(t,e,s){return patchMeta(t,n=>({...n,lastRestoredAt:e}),s)}async function duplicateSnapshot(t,e,s){const n=await loadSnapshot(t);if(!n)return null;const a={meta:{...n.meta,id:`${n.meta.id}_copy_${Date.now().toString(36)}`,name:e,createdAt:Date.now(),lastRestoredAt:void 0},data:n.data};delete a.meta.lastRestoredAt;return{metas:await saveSnapshot(a,s),meta:a.meta}}async function readSnapshot(t){return loadSnapshot(t)}async function restoreDeletedSnapshot(t,e){return saveSnapshot(t,e)}async function renameSnapshot(t,e,s){const n=s.map(r=>r.id===t?{...r,name:e}:r);await saveIndex(n);const a=await loadSnapshot(t);if(a){a.meta.name=e;await _sharedUi.persistentStorage.setItem(SNAP_PREFIX+t,JSON.stringify(a))}return n}
@@ -1,9 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ROUTE_SOURCE_ID = void 0;
7
- /** Id of the route "source": a device capability, not a snapshot provider. */
8
- const ROUTE_SOURCE_ID = exports.ROUTE_SOURCE_ID = "route";
9
- //# sourceMappingURL=sourceIds.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ROUTE_SOURCE_ID=void 0;const ROUTE_SOURCE_ID=exports.ROUTE_SOURCE_ID="route";
@@ -1,79 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ensureSourceSettingsLoaded = ensureSourceSettingsLoaded;
7
- exports.getDisabledSources = getDisabledSources;
8
- exports.isSourceEnabled = isSourceEnabled;
9
- exports.resetSourceSettingsForTests = resetSourceSettingsForTests;
10
- exports.setSourceEnabled = setSourceEnabled;
11
- exports.subscribeSourceSettings = subscribeSourceSettings;
12
- var _sharedUi = require("@buoy-gg/shared-ui");
13
- /**
14
- * Which sources Time Machine is allowed to touch.
15
- *
16
- * A source switched off here is left out of every capture and every restore,
17
- * from the tool, the bar, the desktop and MCP alike: "off" has to mean off
18
- * everywhere, or the one path that forgets it is the one that breaks the app.
19
- * The case this exists for is a store whose full replace the app cannot
20
- * survive (a Zustand store holding live handles, say): leave it off and the
21
- * rest of the state still round-trips.
22
- *
23
- * Persisted as the set of ids that are OFF, so a source that registers for
24
- * the first time tomorrow starts on, and the default is "everything".
25
- */
26
-
27
- const setting = (0, _sharedUi.definePersistedSetting)(_sharedUi.devToolsStorageKeys.timeMachine.disabledSources(), [], {
28
- sanitize: value => Array.isArray(value) ? value.filter(v => typeof v === "string") : []
29
- });
30
- let disabled = new Set();
31
- let loaded = false;
32
- let loadPromise = null;
33
- const listeners = new Set();
34
- const notify = () => listeners.forEach(listener => listener());
35
- function ensureSourceSettingsLoaded() {
36
- if (loaded) return Promise.resolve();
37
- if (!loadPromise) {
38
- loadPromise = setting.load().then(ids => {
39
- // A toggle made while the read was in flight wins over the disk copy.
40
- if (disabled.size === 0) {
41
- disabled = new Set(ids);
42
- notify();
43
- }
44
- }).finally(() => {
45
- loaded = true;
46
- });
47
- }
48
- return loadPromise;
49
- }
50
- function subscribeSourceSettings(listener) {
51
- listeners.add(listener);
52
- return () => {
53
- listeners.delete(listener);
54
- };
55
- }
56
-
57
- /** Stable across renders until something changes, for useSyncExternalStore. */
58
- function getDisabledSources() {
59
- return disabled;
60
- }
61
- function isSourceEnabled(id) {
62
- return !disabled.has(id);
63
- }
64
- function setSourceEnabled(id, enabled) {
65
- if (enabled === !disabled.has(id)) return;
66
- const next = new Set(disabled);
67
- if (enabled) next.delete(id);else next.add(id);
68
- disabled = next;
69
- notify();
70
- void setting.save([...next]);
71
- }
72
-
73
- /** Test seam: forget everything without touching storage. */
74
- function resetSourceSettingsForTests() {
75
- disabled = new Set();
76
- loaded = false;
77
- loadPromise = null;
78
- }
79
- //# sourceMappingURL=sourceSettings.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ensureSourceSettingsLoaded=ensureSourceSettingsLoaded;exports.getDisabledSources=getDisabledSources;exports.isSourceEnabled=isSourceEnabled;exports.resetSourceSettingsForTests=resetSourceSettingsForTests;exports.setSourceEnabled=setSourceEnabled;exports.subscribeSourceSettings=subscribeSourceSettings;var _sharedUi=require("@buoy-gg/shared-ui");const setting=(0,_sharedUi.definePersistedSetting)(_sharedUi.devToolsStorageKeys.timeMachine.disabledSources(),[],{sanitize:e=>Array.isArray(e)?e.filter(t=>typeof t==="string"):[]});let disabled=new Set;let loaded=false;let loadPromise=null;const listeners=new Set;const notify=()=>listeners.forEach(e=>e());function ensureSourceSettingsLoaded(){if(loaded)return Promise.resolve();if(!loadPromise){loadPromise=setting.load().then(e=>{if(disabled.size===0){disabled=new Set(e);notify()}}).finally(()=>{loaded=true})}return loadPromise}function subscribeSourceSettings(e){listeners.add(e);return()=>{listeners.delete(e)}}function getDisabledSources(){return disabled}function isSourceEnabled(e){return!disabled.has(e)}function setSourceEnabled(e,t){if(t===!disabled.has(e))return;const s=new Set(disabled);if(t)s.delete(e);else s.add(e);disabled=s;notify();void setting.save([...s])}function resetSourceSettingsForTests(){disabled=new Set;loaded=false;loadPromise=null}