@buoy-gg/shared-ui 7.0.33 → 7.0.34

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 (189) hide show
  1. package/lib/commonjs/JsModal.js +57 -22
  2. package/lib/commonjs/hooks/index.js +26 -0
  3. package/lib/commonjs/hooks/safe-area-impl.js +1 -1
  4. package/lib/commonjs/hooks/useChangeLog.js +55 -0
  5. package/lib/commonjs/hooks/useEventStoreEvents.js +65 -0
  6. package/lib/commonjs/hooks/usePersistedState.js +45 -10
  7. package/lib/commonjs/index.js +143 -0
  8. package/lib/commonjs/storage/definePersistedSetting.js +67 -0
  9. package/lib/commonjs/storage/index.js +8 -1
  10. package/lib/commonjs/stores/ChangeLog.js +197 -0
  11. package/lib/commonjs/stores/createToolStore.js +175 -0
  12. package/lib/commonjs/stores/index.js +15 -1
  13. package/lib/commonjs/sync/toolSyncAdapter.js +63 -0
  14. package/lib/commonjs/sync/wireForm.js +172 -0
  15. package/lib/commonjs/tools/defineTool.js +79 -0
  16. package/lib/commonjs/ui/components/ChangeRow.js +110 -0
  17. package/lib/commonjs/ui/components/ChipStrip.js +94 -0
  18. package/lib/commonjs/ui/components/DetailViewToggle.js +130 -0
  19. package/lib/commonjs/ui/components/DevToolsCard.js +3 -1
  20. package/lib/commonjs/ui/components/EntityFilterView.js +354 -0
  21. package/lib/commonjs/ui/components/ExportPreview.js +174 -0
  22. package/lib/commonjs/ui/components/InfoRow.js +90 -0
  23. package/lib/commonjs/ui/components/ModalHeader.js +40 -7
  24. package/lib/commonjs/ui/components/Pill.js +114 -0
  25. package/lib/commonjs/ui/components/ToggleRow.js +116 -0
  26. package/lib/commonjs/ui/components/ToolFooter.js +204 -0
  27. package/lib/commonjs/ui/components/index.js +100 -1
  28. package/lib/commonjs/ui/index.js +24 -2
  29. package/lib/commonjs/ui/listPresets.js +43 -0
  30. package/lib/commonjs/ui/night/primitives.js +3 -1
  31. package/lib/commonjs/utils/snapshotProviderKit.js +167 -0
  32. package/lib/commonjs/utils/stateTools.js +160 -0
  33. package/lib/module/JsModal.js +57 -22
  34. package/lib/module/hooks/index.js +3 -1
  35. package/lib/module/hooks/safe-area-impl.js +1 -1
  36. package/lib/module/hooks/useChangeLog.js +50 -0
  37. package/lib/module/hooks/useEventStoreEvents.js +61 -0
  38. package/lib/module/hooks/usePersistedState.js +44 -10
  39. package/lib/module/index.js +11 -1
  40. package/lib/module/storage/definePersistedSetting.js +63 -0
  41. package/lib/module/storage/index.js +2 -1
  42. package/lib/module/stores/ChangeLog.js +192 -0
  43. package/lib/module/stores/createToolStore.js +171 -0
  44. package/lib/module/stores/index.js +3 -1
  45. package/lib/module/sync/toolSyncAdapter.js +58 -0
  46. package/lib/module/sync/wireForm.js +159 -0
  47. package/lib/module/tools/defineTool.js +74 -0
  48. package/lib/module/ui/components/ChangeRow.js +105 -0
  49. package/lib/module/ui/components/ChipStrip.js +91 -0
  50. package/lib/module/ui/components/DetailViewToggle.js +125 -0
  51. package/lib/module/ui/components/DevToolsCard.js +3 -1
  52. package/lib/module/ui/components/EntityFilterView.js +350 -0
  53. package/lib/module/ui/components/ExportPreview.js +169 -0
  54. package/lib/module/ui/components/InfoRow.js +86 -0
  55. package/lib/module/ui/components/ModalHeader.js +40 -7
  56. package/lib/module/ui/components/Pill.js +110 -0
  57. package/lib/module/ui/components/ToggleRow.js +112 -0
  58. package/lib/module/ui/components/ToolFooter.js +196 -0
  59. package/lib/module/ui/components/index.js +10 -1
  60. package/lib/module/ui/index.js +4 -1
  61. package/lib/module/ui/listPresets.js +39 -0
  62. package/lib/module/ui/night/primitives.js +3 -1
  63. package/lib/module/utils/snapshotProviderKit.js +156 -0
  64. package/lib/module/utils/stateTools.js +154 -0
  65. package/lib/typescript/commonjs/JsModal.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/hooks/index.d.ts +3 -1
  67. package/lib/typescript/commonjs/hooks/index.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/hooks/safe-area-impl.d.ts +1 -1
  69. package/lib/typescript/commonjs/hooks/useChangeLog.d.ts +38 -0
  70. package/lib/typescript/commonjs/hooks/useChangeLog.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/hooks/useEventStoreEvents.d.ts +25 -0
  72. package/lib/typescript/commonjs/hooks/useEventStoreEvents.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/hooks/usePersistedState.d.ts +34 -5
  74. package/lib/typescript/commonjs/hooks/usePersistedState.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/index.d.ts +6 -1
  76. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/storage/definePersistedSetting.d.ts +39 -0
  78. package/lib/typescript/commonjs/storage/definePersistedSetting.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/storage/index.d.ts +1 -0
  80. package/lib/typescript/commonjs/storage/index.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/stores/ChangeLog.d.ts +100 -0
  82. package/lib/typescript/commonjs/stores/ChangeLog.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/stores/createToolStore.d.ts +92 -0
  84. package/lib/typescript/commonjs/stores/createToolStore.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/stores/index.d.ts +2 -0
  86. package/lib/typescript/commonjs/stores/index.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/sync/toolSyncAdapter.d.ts +66 -0
  88. package/lib/typescript/commonjs/sync/toolSyncAdapter.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/sync/wireForm.d.ts +100 -0
  90. package/lib/typescript/commonjs/sync/wireForm.d.ts.map +1 -0
  91. package/lib/typescript/commonjs/tools/defineTool.d.ts +100 -0
  92. package/lib/typescript/commonjs/tools/defineTool.d.ts.map +1 -0
  93. package/lib/typescript/commonjs/ui/components/ChangeRow.d.ts +52 -0
  94. package/lib/typescript/commonjs/ui/components/ChangeRow.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/ui/components/ChipStrip.d.ts +41 -0
  96. package/lib/typescript/commonjs/ui/components/ChipStrip.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/ui/components/DetailViewToggle.d.ts +36 -0
  98. package/lib/typescript/commonjs/ui/components/DetailViewToggle.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/ui/components/DevToolsCard.d.ts +8 -1
  100. package/lib/typescript/commonjs/ui/components/DevToolsCard.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/ui/components/EntityFilterView.d.ts +51 -0
  102. package/lib/typescript/commonjs/ui/components/EntityFilterView.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/ui/components/ExportPreview.d.ts +48 -0
  104. package/lib/typescript/commonjs/ui/components/ExportPreview.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/ui/components/InfoRow.d.ts +33 -0
  106. package/lib/typescript/commonjs/ui/components/InfoRow.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/ui/components/ModalHeader.d.ts +31 -1
  108. package/lib/typescript/commonjs/ui/components/ModalHeader.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/ui/components/Pill.d.ts +38 -0
  110. package/lib/typescript/commonjs/ui/components/Pill.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/ui/components/ToggleRow.d.ts +33 -0
  112. package/lib/typescript/commonjs/ui/components/ToggleRow.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/ui/components/ToolFooter.d.ts +69 -0
  114. package/lib/typescript/commonjs/ui/components/ToolFooter.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/ui/components/index.d.ts +9 -0
  116. package/lib/typescript/commonjs/ui/components/index.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/ui/index.d.ts +1 -0
  118. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/ui/listPresets.d.ts +28 -0
  120. package/lib/typescript/commonjs/ui/listPresets.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/ui/night/primitives.d.ts +3 -1
  122. package/lib/typescript/commonjs/ui/night/primitives.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/utils/snapshotProviderKit.d.ts +81 -0
  124. package/lib/typescript/commonjs/utils/snapshotProviderKit.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/utils/stateTools.d.ts +44 -0
  126. package/lib/typescript/commonjs/utils/stateTools.d.ts.map +1 -0
  127. package/lib/typescript/module/JsModal.d.ts.map +1 -1
  128. package/lib/typescript/module/hooks/index.d.ts +3 -1
  129. package/lib/typescript/module/hooks/index.d.ts.map +1 -1
  130. package/lib/typescript/module/hooks/safe-area-impl.d.ts +1 -1
  131. package/lib/typescript/module/hooks/useChangeLog.d.ts +38 -0
  132. package/lib/typescript/module/hooks/useChangeLog.d.ts.map +1 -0
  133. package/lib/typescript/module/hooks/useEventStoreEvents.d.ts +25 -0
  134. package/lib/typescript/module/hooks/useEventStoreEvents.d.ts.map +1 -0
  135. package/lib/typescript/module/hooks/usePersistedState.d.ts +34 -5
  136. package/lib/typescript/module/hooks/usePersistedState.d.ts.map +1 -1
  137. package/lib/typescript/module/index.d.ts +6 -1
  138. package/lib/typescript/module/index.d.ts.map +1 -1
  139. package/lib/typescript/module/storage/definePersistedSetting.d.ts +39 -0
  140. package/lib/typescript/module/storage/definePersistedSetting.d.ts.map +1 -0
  141. package/lib/typescript/module/storage/index.d.ts +1 -0
  142. package/lib/typescript/module/storage/index.d.ts.map +1 -1
  143. package/lib/typescript/module/stores/ChangeLog.d.ts +100 -0
  144. package/lib/typescript/module/stores/ChangeLog.d.ts.map +1 -0
  145. package/lib/typescript/module/stores/createToolStore.d.ts +92 -0
  146. package/lib/typescript/module/stores/createToolStore.d.ts.map +1 -0
  147. package/lib/typescript/module/stores/index.d.ts +2 -0
  148. package/lib/typescript/module/stores/index.d.ts.map +1 -1
  149. package/lib/typescript/module/sync/toolSyncAdapter.d.ts +66 -0
  150. package/lib/typescript/module/sync/toolSyncAdapter.d.ts.map +1 -0
  151. package/lib/typescript/module/sync/wireForm.d.ts +100 -0
  152. package/lib/typescript/module/sync/wireForm.d.ts.map +1 -0
  153. package/lib/typescript/module/tools/defineTool.d.ts +100 -0
  154. package/lib/typescript/module/tools/defineTool.d.ts.map +1 -0
  155. package/lib/typescript/module/ui/components/ChangeRow.d.ts +52 -0
  156. package/lib/typescript/module/ui/components/ChangeRow.d.ts.map +1 -0
  157. package/lib/typescript/module/ui/components/ChipStrip.d.ts +41 -0
  158. package/lib/typescript/module/ui/components/ChipStrip.d.ts.map +1 -0
  159. package/lib/typescript/module/ui/components/DetailViewToggle.d.ts +36 -0
  160. package/lib/typescript/module/ui/components/DetailViewToggle.d.ts.map +1 -0
  161. package/lib/typescript/module/ui/components/DevToolsCard.d.ts +8 -1
  162. package/lib/typescript/module/ui/components/DevToolsCard.d.ts.map +1 -1
  163. package/lib/typescript/module/ui/components/EntityFilterView.d.ts +51 -0
  164. package/lib/typescript/module/ui/components/EntityFilterView.d.ts.map +1 -0
  165. package/lib/typescript/module/ui/components/ExportPreview.d.ts +48 -0
  166. package/lib/typescript/module/ui/components/ExportPreview.d.ts.map +1 -0
  167. package/lib/typescript/module/ui/components/InfoRow.d.ts +33 -0
  168. package/lib/typescript/module/ui/components/InfoRow.d.ts.map +1 -0
  169. package/lib/typescript/module/ui/components/ModalHeader.d.ts +31 -1
  170. package/lib/typescript/module/ui/components/ModalHeader.d.ts.map +1 -1
  171. package/lib/typescript/module/ui/components/Pill.d.ts +38 -0
  172. package/lib/typescript/module/ui/components/Pill.d.ts.map +1 -0
  173. package/lib/typescript/module/ui/components/ToggleRow.d.ts +33 -0
  174. package/lib/typescript/module/ui/components/ToggleRow.d.ts.map +1 -0
  175. package/lib/typescript/module/ui/components/ToolFooter.d.ts +69 -0
  176. package/lib/typescript/module/ui/components/ToolFooter.d.ts.map +1 -0
  177. package/lib/typescript/module/ui/components/index.d.ts +9 -0
  178. package/lib/typescript/module/ui/components/index.d.ts.map +1 -1
  179. package/lib/typescript/module/ui/index.d.ts +1 -0
  180. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  181. package/lib/typescript/module/ui/listPresets.d.ts +28 -0
  182. package/lib/typescript/module/ui/listPresets.d.ts.map +1 -0
  183. package/lib/typescript/module/ui/night/primitives.d.ts +3 -1
  184. package/lib/typescript/module/ui/night/primitives.d.ts.map +1 -1
  185. package/lib/typescript/module/utils/snapshotProviderKit.d.ts +81 -0
  186. package/lib/typescript/module/utils/snapshotProviderKit.d.ts.map +1 -0
  187. package/lib/typescript/module/utils/stateTools.d.ts +44 -0
  188. package/lib/typescript/module/utils/stateTools.d.ts.map +1 -0
  189. package/package.json +4 -4
@@ -1,16 +1,45 @@
1
+ /** The two calls a backend needs. `persistentStorage` and AsyncStorage both fit. */
2
+ export interface PersistedStateStorage {
3
+ getItem(key: string): Promise<string | null>;
4
+ setItem(key: string, value: string): Promise<void>;
5
+ }
6
+ export interface PersistedStateOptions<T> {
7
+ /**
8
+ * Turn the stored string into a value. Return `undefined` to reject it
9
+ * (corrupt, or a value the UI no longer offers) and keep the default.
10
+ * Default: `JSON.parse`.
11
+ */
12
+ parse?: (raw: string) => T | undefined;
13
+ /** Turn a value into the stored string. Default: `JSON.stringify`. */
14
+ serialize?: (value: T) => string;
15
+ /**
16
+ * Where the value lives. Default: `persistentStorage` (FileSystem →
17
+ * AsyncStorage → memory). A tool whose keys were always written straight to
18
+ * AsyncStorage keeps reading them by passing AsyncStorage here.
19
+ */
20
+ storage?: PersistedStateStorage;
21
+ }
1
22
  /**
2
23
  * `useState` persisted through `persistentStorage` (FileSystem → AsyncStorage
3
24
  * → memory). Replaces the load-then-`hasLoaded`-guard `useEffect` pattern
4
25
  * every tool used to hand-roll.
5
26
  *
6
- * Values are JSON-serialized; the default is returned until hydration
7
- * completes (subsequent mounts of the same key hydrate synchronously from an
8
- * in-memory cache). The third tuple element reports hydration so callers can
9
- * defer writes that must not clobber a not-yet-loaded value.
27
+ * Values are JSON-serialized by default; the default is returned until
28
+ * hydration completes (subsequent mounts of the same key hydrate synchronously
29
+ * from an in-memory cache). The third tuple element reports hydration so
30
+ * callers can defer writes that must not clobber a not-yet-loaded value.
10
31
  *
11
32
  * ```tsx
12
33
  * const [tab, setTab, tabHydrated] = usePersistedState("@react_buoy_custom_flags_tab", "flags");
34
+ *
35
+ * // A Set, stored as an array:
36
+ * const [pins, setPins] = usePersistedState(key, new Set<string>(), {
37
+ * parse: (raw) => new Set(JSON.parse(raw) as string[]),
38
+ * serialize: (set) => JSON.stringify([...set]),
39
+ * });
13
40
  * ```
14
41
  */
15
- export declare function usePersistedState<T>(key: string, defaultValue: T): [T, (next: T | ((prev: T) => T)) => void, boolean];
42
+ export declare function usePersistedState<T>(key: string, defaultValue: T, options?: PersistedStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void, boolean];
43
+ /** Test seam: forget every hydrated value. */
44
+ export declare function resetPersistedStateCache(): void;
16
45
  //# sourceMappingURL=usePersistedState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePersistedState.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePersistedState.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GACd,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,CAoDpD"}
1
+ {"version":3,"file":"usePersistedState.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePersistedState.ts"],"names":[],"mappings":"AAUA,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,sEAAsE;IACtE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAUD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,qBAAqB,CAAC,CAAC,CAAM,GACrC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,CA+DpD;AAED,8CAA8C;AAC9C,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
@@ -1,10 +1,15 @@
1
1
  export * from "./ui";
2
2
  export * from "./stores";
3
3
  export * from "./sync/wireBudget";
4
+ export * from "./sync/wireForm";
5
+ export * from "./sync/toolSyncAdapter";
6
+ export * from "./tools/defineTool";
4
7
  export * from "./sync/toolActionRegistry";
5
8
  export * from "./sync/toolUiBridge";
6
9
  export { absoluteFill, displayValue, parseDisplayValue, getSafeAreaInsets, persistentStorage, isUsingPersistentStorage, getStorageBackendType, safeStringify, getValueType, isPrimitive, isJsonSerializable, isValidJson, getConstructorName, isEmpty, getValueSize, parseValue, formatValue, getTypeColor, truncateText, flattenObject, formatPath, loadOptionalModule, getCachedOptionalModule, setRenderCaptureProvider, getRenderCaptureProvider, type RenderCaptureProvider, type RenderCaptureSummary, type RenderCaptureTopComponent, type RenderCauseCounts, registerStateSnapshotProvider, getStateSnapshotProviders, getStateSnapshotProvider, subscribeToStateSnapshotProviders, type StateSnapshotProvider, type StateSnapshotProviderStatus, type StateSnapshotCapture, type StateSnapshotRestoreResult, type StateSnapshotPreview, type StateSnapshotPreviewItem, type StateSnapshotPreviewVerdict, superJsonSerialize, superJsonDeserialize, type SuperJSONResult, reloadApp, scheduleReloadApp, resolveReloadStrategy, REMOTE_RELOAD_DELAY_MS, type ReloadStrategy, type ResolvedReloadStrategy, getDevServerOrigin, Subscribable, type SubscribableListener, subscriberCountNotifier, subscribeToSubscriberCountChanges, notifySubscriberCountChange, useSafeRouter, useSafePathname, useSafeSegments, useSafeGlobalSearchParams, getSafeRouter, getSafeCurrentPathname, getSafeCurrentRoute, isExpoRouterAvailable, } from "./utils";
7
10
  export type { SafeRouteLocation } from "./utils";
11
+ export { PREVIEW_ITEM_RENDER_BYTE_LIMIT, createRestoreScope, emptyRestoreResult, failedRestore, skippedRestore, classifyPreviewItem, wontApply, unionKeys, type RestoreScope, type RestoreScopeOptions, type ClassifyOptions, type ClassifyInput, } from "./utils/snapshotProviderKit";
12
+ export { entityColor, formatValuePreview, shallowDiffSummary, type ValuePreviewOptions, type ShallowDiffSummary, } from "./utils/stateTools";
8
13
  export * from "./utils/formatting";
9
14
  export * from "./utils/time";
10
15
  export { isPlainObject as isPlainObjectUtil } from "./utils/typeHelpers";
@@ -13,7 +18,7 @@ export * from "./clipboard";
13
18
  export * from "./logger";
14
19
  export * from "./settings";
15
20
  export * from "./storage";
16
- export { useSafeAreaInsets, useFilterManager, usePersistedState, useDeviceInfo, getDeviceInfo, logDeviceInfo, type DeviceInfo, type PlatformInfo, type DisplayInfo, type AccessibilitySettings, type AppearanceInfo, type LocaleInfo, type StatusBarInfo, type KeyboardInfo, type AppStateInfo, type UniqueIdentifiers, type SettingsInfo, } from "./hooks";
21
+ export { useSafeAreaInsets, useFilterManager, usePersistedState, resetPersistedStateCache, type PersistedStateOptions, type PersistedStateStorage, useChangeLog, useSubscribedValue, useEventStoreEvents, type UseChangeLogOptions, type UseChangeLogResult, type UseEventStoreEventsOptions, type UseEventStoreEventsResult, useDeviceInfo, getDeviceInfo, logDeviceInfo, type DeviceInfo, type PlatformInfo, type DisplayInfo, type AccessibilitySettings, type AppearanceInfo, type LocaleInfo, type StatusBarInfo, type KeyboardInfo, type AppStateInfo, type UniqueIdentifiers, type SettingsInfo, } from "./hooks";
17
22
  export { JsModal } from "./JsModal";
18
23
  export type { ModalMode, ModalState } from "./JsModal";
19
24
  export { night, NIGHT_LABEL_TRACKING } from "./ui/night/nightTheme";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,MAAM,CAAC;AAGrB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AAGpC,OAAO,EAEL,YAAY,EAEZ,YAAY,EACZ,iBAAiB,EAEjB,iBAAiB,EAEjB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EAErB,aAAa,EAEb,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,YAAY,EAEZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EAEV,kBAAkB,EAClB,uBAAuB,EAEvB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EAEtB,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,iCAAiC,EACjC,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAEhC,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,eAAe,EAEpB,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAG3B,kBAAkB,EAElB,YA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,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3R,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * definePersistedSetting — the `load / save / clear` triple every tool wrote
3
+ * for its module-level settings (copy settings, HUD prefs, JS TOP prefs, …).
4
+ *
5
+ * Contract, the same one all of them followed:
6
+ * - `load()` never throws and never returns a partial object: the stored
7
+ * value is merged OVER the defaults so fields added in a later release
8
+ * get their default instead of `undefined`, then `sanitize` gets the last
9
+ * word (drop values the UI no longer offers, coerce types).
10
+ * - `save()` and `clear()` are best-effort; persistence is optional.
11
+ * - `loadOrNull()` distinguishes "nothing saved yet" from the defaults, for
12
+ * callers that treat first launch differently.
13
+ */
14
+ export interface PersistedSettingOptions<T> {
15
+ /** Merge-then-validate. Receives `{ ...defaults, ...stored }`; returns the value to use. */
16
+ sanitize?: (merged: T, stored: unknown) => T;
17
+ /** Default: `JSON.parse`. */
18
+ parse?: (raw: string) => unknown;
19
+ /** Default: `JSON.stringify`. */
20
+ serialize?: (value: T) => string;
21
+ /** Default: `persistentStorage`. */
22
+ storage?: {
23
+ getItem(key: string): Promise<string | null>;
24
+ setItem(key: string, value: string): Promise<void>;
25
+ removeItem(key: string): Promise<void>;
26
+ };
27
+ }
28
+ export interface PersistedSetting<T> {
29
+ readonly key: string;
30
+ readonly defaults: T;
31
+ /** The stored value merged over the defaults, or the defaults. Never throws. */
32
+ load(): Promise<T>;
33
+ /** Like `load()`, but `null` when nothing is stored (or it is unreadable). */
34
+ loadOrNull(): Promise<T | null>;
35
+ save(value: T): Promise<void>;
36
+ clear(): Promise<void>;
37
+ }
38
+ export declare function definePersistedSetting<T>(key: string, defaults: T, options?: PersistedSettingOptions<T>): PersistedSetting<T>;
39
+ //# sourceMappingURL=definePersistedSetting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definePersistedSetting.d.ts","sourceRoot":"","sources":["../../../../src/storage/definePersistedSetting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC;IAC7C,6BAA6B;IAC7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACjC,iCAAiC;IACjC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,oCAAoC;IACpC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACxC,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrB,gFAAgF;IAChF,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,8EAA8E;IAC9E,UAAU,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAMD,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,EACX,OAAO,GAAE,uBAAuB,CAAC,CAAC,CAAM,GACvC,gBAAgB,CAAC,CAAC,CAAC,CA6CrB"}
@@ -1,2 +1,3 @@
1
1
  export { devToolsStorageKeys, isDevToolsStorageKey } from './devToolsStorageKeys';
2
+ export { definePersistedSetting, type PersistedSetting, type PersistedSettingOptions, } from "./definePersistedSetting";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElF,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * ChangeLog — the class-shaped event log the state tools share.
3
+ *
4
+ * redux (`ReduxActionStore`), zustand (`ZustandStateStore`), jotai
5
+ * (`JotaiStateStore`) and react-query (`ReactQueryEventStore`) each carried
6
+ * the same ~120 lines: a newest-first ring buffer, a `Set` of array listeners
7
+ * (`(items) => void`), a `Set` of clear listeners for the desktop's mirror
8
+ * mode, an `enabled` flag (the UI's pause button), a `captureSuppressed` flag
9
+ * (the dashboard must never record its own traffic), a monotonic id counter,
10
+ * `getById`, and hydrate-by-id for lazily fetched detail payloads.
11
+ *
12
+ * This is that core. Tool stores `extend` it and keep their public method
13
+ * names (`addStateChange`, `getActions`, `clearAtomChanges`, …) as thin
14
+ * wrappers, so no call site — including Buoy Desktop — has to change.
15
+ *
16
+ * Semantics preserved from the originals, deliberately:
17
+ * - `getAll()` returns a COPY (`[...items]`) — consumers seed React state
18
+ * from it and rely on a fresh identity per notification.
19
+ * - `clear()` always notifies, even when already empty, then fires the clear
20
+ * listeners (the dashboard forwards the clear to the device either way).
21
+ * - `replaceAll()` respects `enabled`: the pause button freezes a mirror.
22
+ * - `disableCapture()` is permanent for the store's lifetime.
23
+ */
24
+ export type ChangeLogListener<T> = (items: T[]) => void;
25
+ export interface ChangeLogOptions {
26
+ /** Ring-buffer depth. Default 200 — what all four stores shipped with. */
27
+ max?: number;
28
+ }
29
+ export interface Identified {
30
+ id: string;
31
+ }
32
+ export declare class ChangeLog<T extends Identified> {
33
+ /** Newest first. Subclasses may read; mutate only through the helpers. */
34
+ protected items: T[];
35
+ protected max: number;
36
+ private readonly itemListeners;
37
+ private readonly clearListeners;
38
+ private idCounter;
39
+ private enabled;
40
+ private captureSuppressed;
41
+ constructor(options?: ChangeLogOptions);
42
+ /** True when a new item should be recorded (not paused, not a mirror). */
43
+ protected canRecord(): boolean;
44
+ /** `${Date.now()}-${n}` — unique per store instance, sorts by time. */
45
+ protected nextId(): string;
46
+ /**
47
+ * Prepend one item and trim to `max`. Does NOT notify — subclasses often
48
+ * touch companion state (per-entity counters, raw-state eviction) before
49
+ * they notify. Call `notifyListeners()` when done, or use `record()`.
50
+ */
51
+ protected push(item: T): void;
52
+ /** `push()` + notify. The common case. */
53
+ protected record(item: T): void;
54
+ /** Replace the buffer wholesale (already merged/hydrated by the caller) and notify. */
55
+ protected setItems(next: T[]): void;
56
+ /** All items, newest first. Fresh array each call. */
57
+ getAll(): T[];
58
+ getById(id: string): T | undefined;
59
+ get size(): number;
60
+ /**
61
+ * Empty the buffer, notify, then fire clear listeners. Always notifies —
62
+ * a clear is a user action and the list must repaint even if nothing was
63
+ * in it. Subclasses that keep companion counters reset them first.
64
+ */
65
+ clear(): void;
66
+ /**
67
+ * Listen for `clear()` calls. Used in remote mirror mode to forward a
68
+ * clear performed in the dashboard UI to the synced device.
69
+ */
70
+ onClear(listener: () => void): () => void;
71
+ /**
72
+ * Permanently suppress local capture. Use when this store acts as a mirror
73
+ * of a remote device (the desktop dashboard): data arrives via
74
+ * `replaceAll()` / a subclass snapshot method and local instrumentation
75
+ * must never record.
76
+ */
77
+ disableCapture(): void;
78
+ /** Whether the store is in remote mirror mode (capture suppressed). */
79
+ isCaptureSuppressed(): boolean;
80
+ /**
81
+ * Replace the whole list from a remote snapshot and notify. Respects the
82
+ * enabled flag so the UI's pause button freezes the mirror. Returns false
83
+ * when skipped. Subclasses with hydration-preserving merges compute the
84
+ * merged list themselves and call `setItems()`.
85
+ */
86
+ replaceAll(next: T[]): boolean;
87
+ /**
88
+ * Patch one item in place (by id) and notify. Used to hydrate a mirrored
89
+ * item with detail payloads fetched on demand from the device.
90
+ */
91
+ hydrateById(id: string, patch: Partial<T>): void;
92
+ setEnabled(enabled: boolean): void;
93
+ getEnabled(): boolean;
94
+ setMax(max: number): void;
95
+ getMax(): number;
96
+ subscribe(listener: ChangeLogListener<T>): () => void;
97
+ protected notifyListeners(): void;
98
+ protected get listenerCount(): number;
99
+ }
100
+ //# sourceMappingURL=ChangeLog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeLog.d.ts","sourceRoot":"","sources":["../../../../src/stores/ChangeLog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,qBAAa,SAAS,CAAC,CAAC,SAAS,UAAU;IACzC,0EAA0E;IAC1E,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAM;IAC1B,SAAS,CAAC,GAAG,EAAE,MAAM,C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CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAOrD,SAAS,CAAC,eAAe,IAAI,IAAI;IAKjC,SAAS,KAAK,aAAa,IAAI,MAAM,CAEpC;CACF"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * createToolStore — the one bounded, subscribable buffer every tool used to
3
+ * hand-roll.
4
+ *
5
+ * Before this existed, console, sentry, images, assets, focus-inspector,
6
+ * tv-remote, redux, zustand, jotai and react-query each carried their own copy
7
+ * of the same ~100 lines: a `Set` of listeners, a `Set` of clear listeners
8
+ * (so the desktop dashboard can forward a clear to the device in mirror
9
+ * mode), a ring buffer with a max, an optional frame-coalesced emit, and the
10
+ * `__buoyFlushToolSync` escape hatch that pushes a tool's snapshot to the
11
+ * dashboard NOW (a crash's last words must not wait on the sync throttle).
12
+ *
13
+ * This is a plain function, not a class, on purpose: every consumer exposes a
14
+ * module-level functional API (`subscribe`, `getSnapshot`, `clearX`) and
15
+ * feeds `useSyncExternalStore`, so the store is a value the module wraps
16
+ * rather than something it extends. `BaseEventStore` stays for the
17
+ * class-based, auto-start/stop capture stores (network, storage, routes).
18
+ *
19
+ * Contract:
20
+ * - `getSnapshot()` returns the SAME array reference until the next
21
+ * mutation, so `useSyncExternalStore` never re-renders for nothing.
22
+ * - `order: "append"` keeps the newest item LAST (console-style scrollback);
23
+ * `order: "prepend"` keeps it FIRST (event-log style). Trimming drops from
24
+ * the opposite end. Consumers never have to `.reverse()`.
25
+ * - `clear()` fires `onClear` listeners even when the buffer is already
26
+ * empty — the dashboard's forwarded clear must reach the device regardless.
27
+ * - `set()` (mirror mode) never fires clear listeners; it is a replacement.
28
+ */
29
+ /** Listener signature: change-only, read the snapshot yourself. */
30
+ export type ToolStoreListener = () => void;
31
+ export type ToolStoreOrder = "append" | "prepend";
32
+ export interface ToolStoreOptions {
33
+ /** Tool id, as the sync layer knows it (`"console"`, `"sentry"`, …). Used by
34
+ * `flushSync()` so the dashboard pushes THIS tool's snapshot. */
35
+ id: string;
36
+ /** Ring-buffer depth. */
37
+ max: number;
38
+ /** Where new items land. Default `"append"` (newest last). */
39
+ order?: ToolStoreOrder;
40
+ /**
41
+ * `"frame"`: coalesce listener notifications onto one animation frame so a
42
+ * burst (a log loop, a navigation's several envelopes) is one React commit.
43
+ * `"sync"` (default): notify immediately.
44
+ */
45
+ coalesce?: "frame" | "sync";
46
+ /** Floor between opportunistic (non-forced) `flushSync()` calls. Default 150 ms. */
47
+ flushMinIntervalMs?: number;
48
+ /** First id `allocId()` hands out. Default 1. */
49
+ firstId?: number;
50
+ }
51
+ export interface ToolStore<T> {
52
+ /** Subscribe to any change (items, or a `notify()` from companion state). */
53
+ subscribe(listener: ToolStoreListener): () => void;
54
+ /** Current items. Stable reference between mutations. */
55
+ getSnapshot(): T[];
56
+ /** Number of items. */
57
+ size(): number;
58
+ /** Add one item at the configured end, trimming from the other. No-op while paused. */
59
+ add(item: T): void;
60
+ /** Replace all items (remote mirror mode, restore-from-disk). Trims to `max`. */
61
+ set(next: T[]): void;
62
+ /** Functional replace: `update(items => items.filter(...))`. Trims to `max`. */
63
+ update(fn: (items: T[]) => T[]): void;
64
+ /** Empty the buffer. Fires `onClear` listeners FIRST, always. */
65
+ clear(): void;
66
+ /** Listen for `clear()`. The dashboard uses this to forward a clear to the device. */
67
+ onClear(listener: ToolStoreListener): () => void;
68
+ /** Notify subscribers without touching items (companion state changed). */
69
+ notify(): void;
70
+ /**
71
+ * Push this tool's snapshot to any connected dashboard now, via the
72
+ * `__buoyFlushToolSync` global (@buoy-gg/external-sync `crashFlush`).
73
+ * Rate-limited unless `force` — a fatal is the app's last word and always goes out.
74
+ */
75
+ flushSync(force?: boolean): void;
76
+ /** While paused, `add()` is dropped. `set`/`update`/`clear` still apply. */
77
+ setPaused(paused: boolean): void;
78
+ isPaused(): boolean;
79
+ /** Change the ring-buffer depth; trims immediately if shrinking. */
80
+ setMax(max: number): void;
81
+ getMax(): number;
82
+ /** Monotonic id counter for items that need one. */
83
+ allocId(): number;
84
+ /** Raise the id floor (after restoring persisted items that carry ids). */
85
+ bumpIdAbove(id: number): void;
86
+ /** How many `subscribe` listeners are attached. */
87
+ listenerCount(): number;
88
+ /** The tool id this store was created with. */
89
+ readonly id: string;
90
+ }
91
+ export declare function createToolStore<T>(options: ToolStoreOptions): ToolStore<T>;
92
+ //# sourceMappingURL=createToolStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createToolStore.d.ts","sourceRoot":"","sources":["../../../../src/stores/createToolStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,mEAAmE;AACnE,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAE3C,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAC/B;qEACiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,oFAAoF;IACpF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAAC;IACnD,yDAAyD;IACzD,WAAW,IAAI,CAAC,EAAE,CAAC;IACnB,uBAAuB;IACvB,IAAI,IAAI,MAAM,CAAC;IACf,uFAAuF;IACvF,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACnB,iFAAiF;IACjF,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IACrB,gFAAgF;IAChF,MAAM,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC;IACtC,iEAAiE;IACjE,KAAK,IAAI,IAAI,CAAC;IACd,sFAAsF;IACtF,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAAC;IACjD,2EAA2E;IAC3E,MAAM,IAAI,IAAI,CAAC;IACf;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,4EAA4E;IAC5E,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,QAAQ,IAAI,OAAO,CAAC;IACpB,oEAAoE;IACpE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,IAAI,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,IAAI,MAAM,CAAC;IAClB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,mDAAmD;IACnD,aAAa,IAAI,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAYD,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC,CA6J1E"}
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export { BaseEventStore, type ArrayListener, type EventCallback, type BaseEventStoreOptions, } from "./BaseEventStore";
5
5
  export { ignoredPatternsStore, useIgnoredPatterns, urlMatchesIgnoredPattern, isUrlIgnored, type IgnoredPattern, type IgnoredPatternMatchMode, type UseIgnoredPatternsResult, } from "./ignoredPatternsStore";
6
+ export { createToolStore, type ToolStore, type ToolStoreOptions, type ToolStoreOrder, type ToolStoreListener, } from "./createToolStore";
7
+ export { ChangeLog, type ChangeLogListener, type ChangeLogOptions, type Identified, } from "./ChangeLog";
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,SAAS,EACT,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ToolSyncAdapter — the contract a tool implements to sync to Buoy Desktop /
3
+ * the MCP server, plus `createSyncAdapter`, the one way to build one.
4
+ *
5
+ * Every tool package used to declare its adapter as a bare object literal
6
+ * with the comment "structurally matches external-sync's ToolSyncAdapter so
7
+ * this package doesn't need a dependency on it". That kept the packages
8
+ * decoupled but left the contract unchecked: storage shipped `version: 3`
9
+ * while every sibling was on 2 and nothing noticed. The type now lives here,
10
+ * in shared (which every tool already depends on), and external-sync
11
+ * re-exports it — one definition, checked everywhere.
12
+ *
13
+ * `createSyncAdapter` is deliberately thin. It:
14
+ * - type-checks the literal against the contract (a wrong `subscribe`
15
+ * signature or a non-function action fails at compile time),
16
+ * - keeps the CONCRETE `actions` type, so `adapter.actions.getChangeDetail()`
17
+ * stays typed for tests and callers,
18
+ * - merges several change sources into one `subscribe` (a store plus its
19
+ * registry, envelopes plus drops) — the second most-copied block.
20
+ */
21
+ /** A remote-invocable action. Thrown errors are reported back to the dashboard. */
22
+ export type ToolAction = (params: unknown) => unknown | Promise<unknown>;
23
+ /** Anything that can tell the bridge "something changed". */
24
+ export type ChangeSource = (onChange: () => void) => () => void;
25
+ /**
26
+ * The contract each dev tool implements to become remotely syncable.
27
+ * Works with BaseEventStore, ChangeLog, createToolStore, or any pattern
28
+ * exposing subscribe + getSnapshot.
29
+ *
30
+ * Payloads (snapshots and action results) must be JSON-serializable —
31
+ * no functions, circular references, or class instances.
32
+ */
33
+ export interface ToolSyncAdapter {
34
+ /** Version of this tool's payload shape. Bump on breaking changes. */
35
+ version: number;
36
+ /** Current full state — sent when a dashboard starts watching or requests state. */
37
+ getSnapshot: () => unknown;
38
+ /**
39
+ * Fires on state changes. Only called while at least one dashboard is
40
+ * watching this tool; the bridge subscribes/unsubscribes on demand so
41
+ * stores with auto start/stop lifecycles stay idle when unwatched.
42
+ */
43
+ subscribe: ChangeSource;
44
+ /** Remote-invocable actions, keyed by action name. */
45
+ actions?: Record<string, ToolAction>;
46
+ }
47
+ export interface SyncAdapterDefinition<TSnapshot, TActions extends Record<string, ToolAction> | undefined> {
48
+ version: number;
49
+ getSnapshot: () => TSnapshot;
50
+ /** One source, or several that are merged into a single subscription. */
51
+ subscribe: ChangeSource | ChangeSource[];
52
+ actions?: TActions;
53
+ }
54
+ export type SyncAdapter<TSnapshot, TActions extends Record<string, ToolAction> | undefined> = {
55
+ version: number;
56
+ getSnapshot: () => TSnapshot;
57
+ subscribe: ChangeSource;
58
+ } & (TActions extends undefined ? {
59
+ actions?: undefined;
60
+ } : {
61
+ actions: TActions;
62
+ });
63
+ /** Subscribe to every source; the returned function unsubscribes from all. */
64
+ export declare function mergeChangeSources(sources: ChangeSource[]): ChangeSource;
65
+ export declare function createSyncAdapter<TSnapshot, TActions extends Record<string, ToolAction> | undefined = undefined>(definition: SyncAdapterDefinition<TSnapshot, TActions>): SyncAdapter<TSnapshot, TActions>;
66
+ //# sourceMappingURL=toolSyncAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolSyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/sync/toolSyncAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEzE,6DAA6D;AAC7D,MAAM,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B;;;;OAIG;IACH,SAAS,EAAE,YAAY,CAAC;IACxB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,qBAAqB,CACpC,SAAS,EACT,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS;IAEvD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,SAAS,CAAC;IAC7B,yEAAyE;IACzE,SAAS,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,CACrB,SAAS,EACT,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,IACrD;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,SAAS,CAAC;IAC7B,SAAS,EAAE,YAAY,CAAC;CACzB,GAAG,CAAC,QAAQ,SAAS,SAAS,GAAG;IAAE,OAAO,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEnF,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,CAQxE;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EACT,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,GAAG,SAAS,EACnE,UAAU,EAAE,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAW1F"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * wireForm — how a tool turns what it holds into what it may put on the wire.
3
+ *
4
+ * Every adapter that ships large values faces the same four problems, and
5
+ * nine of them solved each one separately:
6
+ *
7
+ * 1. A per-item cap on the snapshot stream (16 KB), with a MARKER left in
8
+ * the value's place so the dashboard knows to fetch it on demand.
9
+ * 2. A much larger cap on that on-demand detail fetch (8 MB), with a
10
+ * TRUNCATION NOTE when even that is exceeded.
11
+ * 3. An identity-keyed cache for the wire form, because a snapshot is
12
+ * rebuilt ~5×/sec while a dashboard watches and stores never mutate a
13
+ * recorded item — so converting each item once is correct and cheap.
14
+ * 4. For tools whose items are individually fat (console, sentry), a
15
+ * newest-first walk that keeps as many items as fit a snapshot budget.
16
+ *
17
+ * Marker KEY NAMES are part of the wire protocol — Buoy Desktop and the
18
+ * tool stores test for `__buoyStateOnDevice`, `__buoyPayloadOnDevice`,
19
+ * `__buoyValueOnDevice` — so the factory builds exactly those keys.
20
+ */
21
+ /** Per-item budget on the snapshot stream. Anything larger stays on-device. */
22
+ export declare const WIRE_INLINE_LIMIT_BYTES: number;
23
+ /**
24
+ * Upper bound for one on-demand detail response. Generous — this is a single
25
+ * explicit fetch, not a per-item stream — but still guarded so a pathological
26
+ * tree can't OOM the device through the reply emit.
27
+ */
28
+ export declare const WIRE_DETAIL_LIMIT_BYTES: number;
29
+ /** A frozen `{ __buoy<Kind>OnDevice: true, note }` marker. */
30
+ export type OnDeviceMarker<K extends string> = Readonly<{
31
+ [P in `__buoy${K}OnDevice`]: true;
32
+ } & {
33
+ note: string;
34
+ }>;
35
+ /**
36
+ * Build the sentinel a wire-form snapshot carries in place of a value that
37
+ * stays on the device. `kind` names the value ("State", "Payload", "Value",
38
+ * "Params", "Data", …) and becomes the key the reader tests for.
39
+ */
40
+ export declare function onDeviceMarker<K extends string>(kind: K, note: string): OnDeviceMarker<K>;
41
+ /** True when `value` is the on-device marker for `kind`. */
42
+ export declare function isOnDeviceMarker(value: unknown, kind: string): boolean;
43
+ /** The note a detail fetch returns when a single field exceeds the detail cap. */
44
+ export declare function truncatedNote(limitBytes?: number): {
45
+ __buoyTruncated: true;
46
+ note: string;
47
+ };
48
+ /**
49
+ * The value itself if it fits `limit` (and is serializable), else `marker`.
50
+ * `undefined` passes through untouched: an absent field must stay absent.
51
+ */
52
+ export declare function toWire<T>(value: unknown, marker: T, limit?: number): unknown;
53
+ /** Detail-fetch cap: the value, or a truncation note when it is too big. */
54
+ export declare function capDetail(value: unknown, limit?: number): unknown;
55
+ /**
56
+ * Memoize a wire-form conversion by item identity. Correct for any store
57
+ * that prepends and never mutates a recorded item — the cache self-invalidates
58
+ * when the item is dropped from the buffer.
59
+ */
60
+ export declare function memoByIdentity<T extends object, R>(convert: (item: T) => R): (item: T) => R;
61
+ export interface WireSized<T> {
62
+ value: T;
63
+ bytes: number;
64
+ }
65
+ export interface NewestFittingOptions<T, W> {
66
+ /** Convert one item to its wire form and its byte cost. Memoize with `memoByIdentity`. */
67
+ toWire: (item: T) => WireSized<W>;
68
+ /** Snapshot byte budget. */
69
+ budget: number;
70
+ /** Bytes the envelope around the list costs (`{"entries":[]}` ≈ 16). */
71
+ baseBytes?: number;
72
+ }
73
+ /**
74
+ * Walk `items` (oldest-first) from the newest end, keeping every item until
75
+ * the budget is spent. Always keeps at least one so an over-budget newest
76
+ * item still reaches the dashboard as a stub rather than an empty panel.
77
+ * Returns oldest-first, matching the input.
78
+ */
79
+ export declare function newestFitting<T, W>(items: T[], options: NewestFittingOptions<T, W>): W[];
80
+ /**
81
+ * Size one wire-form item against a per-item cap, substituting a stub when it
82
+ * is too fat. One walk decides both "too big?" and "what does it cost".
83
+ */
84
+ export declare function sizeOrStub<W>(wired: W, limit: number, stub: () => W): WireSized<W>;
85
+ /** `(params as T | undefined) ?? {}` — the first line of every action. */
86
+ export declare function readParams<T extends object>(params: unknown): Partial<T>;
87
+ export type DetailResult<R extends object> = {
88
+ found: false;
89
+ reason: "missing id" | "unknown id";
90
+ } | ({
91
+ found: true;
92
+ id: string;
93
+ } & R);
94
+ /**
95
+ * The on-demand detail action every change-log tool exposes: look one item
96
+ * up by id, and return its detail fields size-capped. Replaces the
97
+ * `missing id` / `unknown id` boilerplate copied into each adapter.
98
+ */
99
+ export declare function detailByIdAction<T, R extends object>(lookup: (id: string) => T | undefined, detail: (item: T, cap: (value: unknown) => unknown) => R, limit?: number): (params?: unknown) => DetailResult<R>;
100
+ //# sourceMappingURL=wireForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireForm.d.ts","sourceRoot":"","sources":["../../../../src/sync/wireForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,QAAY,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AAEvD,8DAA8D;AAC9D,MAAM,MAAM,cA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