@buoy-gg/core 7.0.36 → 7.0.38

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 (103) hide show
  1. package/README.md +57 -69
  2. package/bin/buoy.js +71 -20
  3. package/lib/commonjs/Buoy.js +3 -16
  4. package/lib/commonjs/floatingMenu/AppHost.js +1 -1
  5. package/lib/commonjs/floatingMenu/AppHost.web.js +1 -1
  6. package/lib/commonjs/floatingMenu/AppIcon.web.js +53 -0
  7. package/lib/commonjs/floatingMenu/DevToolsSettingsModal.js +12 -5
  8. package/lib/commonjs/floatingMenu/DevToolsSettingsModal.web.js +14 -34
  9. package/lib/commonjs/floatingMenu/FloatingDevTools.js +32 -48
  10. package/lib/commonjs/floatingMenu/FloatingDevTools.web.js +24 -4
  11. package/lib/commonjs/floatingMenu/FloatingMenu.js +1 -1
  12. package/lib/commonjs/floatingMenu/ToolHost.js +1 -0
  13. package/lib/commonjs/floatingMenu/autoExternalSync.js +3 -2
  14. package/lib/commonjs/floatingMenu/dial/DialDevTools.js +43 -10
  15. package/lib/commonjs/floatingMenu/dial/DialDevTools.web.js +18 -5
  16. package/lib/commonjs/floatingMenu/dial/dialUsageStore.js +13 -17
  17. package/lib/commonjs/floatingMenu/dial/onboardingConstants.js +37 -65
  18. package/lib/commonjs/floatingMenu/dial/onboardingConstants.web.js +37 -29
  19. package/lib/commonjs/floatingMenu/floatingTools.js +23 -889
  20. package/lib/commonjs/floatingMenu/floatingTools.web.js +24 -514
  21. package/lib/commonjs/floatingMenu/optionalRequire.js +4 -0
  22. package/lib/commonjs/telemetry/installPing.js +7 -0
  23. package/lib/commonjs/version.js +1 -1
  24. package/lib/module/Buoy.js +3 -16
  25. package/lib/module/floatingMenu/AppHost.js +1 -1
  26. package/lib/module/floatingMenu/AppHost.web.js +1 -1
  27. package/lib/module/floatingMenu/AppIcon.web.js +47 -0
  28. package/lib/module/floatingMenu/DevToolsSettingsModal.js +13 -6
  29. package/lib/module/floatingMenu/DevToolsSettingsModal.web.js +15 -35
  30. package/lib/module/floatingMenu/FloatingDevTools.js +35 -49
  31. package/lib/module/floatingMenu/FloatingDevTools.web.js +24 -3
  32. package/lib/module/floatingMenu/FloatingMenu.js +1 -1
  33. package/lib/module/floatingMenu/ToolHost.js +1 -0
  34. package/lib/module/floatingMenu/autoExternalSync.js +3 -2
  35. package/lib/module/floatingMenu/dial/DialDevTools.js +43 -10
  36. package/lib/module/floatingMenu/dial/DialDevTools.web.js +18 -5
  37. package/lib/module/floatingMenu/dial/dialUsageStore.js +14 -18
  38. package/lib/module/floatingMenu/dial/onboardingConstants.js +1 -62
  39. package/lib/module/floatingMenu/dial/onboardingConstants.web.js +1 -25
  40. package/lib/module/floatingMenu/floatingTools.js +15 -890
  41. package/lib/module/floatingMenu/floatingTools.web.js +1 -517
  42. package/lib/module/floatingMenu/optionalRequire.js +4 -0
  43. package/lib/module/telemetry/installPing.js +7 -0
  44. package/lib/module/version.js +1 -1
  45. package/lib/typescript/commonjs/Buoy.d.ts +14 -3
  46. package/lib/typescript/commonjs/Buoy.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/floatingMenu/AppIcon.web.d.ts +14 -0
  48. package/lib/typescript/commonjs/floatingMenu/AppIcon.web.d.ts.map +1 -0
  49. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.web.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts +4 -14
  52. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.web.d.ts +4 -19
  54. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.web.d.ts.map +1 -1
  55. package/lib/typescript/commonjs/floatingMenu/ToolHost.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/floatingMenu/autoExternalSync.d.ts +3 -4
  57. package/lib/typescript/commonjs/floatingMenu/autoExternalSync.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.web.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/floatingMenu/dial/dialUsageStore.d.ts +3 -15
  61. package/lib/typescript/commonjs/floatingMenu/dial/dialUsageStore.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.d.ts +1 -29
  63. package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.web.d.ts +1 -12
  65. package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.web.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/floatingMenu/floatingTools.d.ts +6 -55
  67. package/lib/typescript/commonjs/floatingMenu/floatingTools.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/floatingMenu/floatingTools.web.d.ts +3 -53
  69. package/lib/typescript/commonjs/floatingMenu/floatingTools.web.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/floatingMenu/optionalRequire.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/telemetry/installPing.d.ts +8 -1
  72. package/lib/typescript/commonjs/telemetry/installPing.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/version.d.ts +1 -1
  74. package/lib/typescript/module/Buoy.d.ts +14 -3
  75. package/lib/typescript/module/Buoy.d.ts.map +1 -1
  76. package/lib/typescript/module/floatingMenu/AppIcon.web.d.ts +14 -0
  77. package/lib/typescript/module/floatingMenu/AppIcon.web.d.ts.map +1 -0
  78. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -1
  79. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.web.d.ts.map +1 -1
  80. package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts +4 -14
  81. package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts.map +1 -1
  82. package/lib/typescript/module/floatingMenu/FloatingDevTools.web.d.ts +4 -19
  83. package/lib/typescript/module/floatingMenu/FloatingDevTools.web.d.ts.map +1 -1
  84. package/lib/typescript/module/floatingMenu/ToolHost.d.ts.map +1 -1
  85. package/lib/typescript/module/floatingMenu/autoExternalSync.d.ts +3 -4
  86. package/lib/typescript/module/floatingMenu/autoExternalSync.d.ts.map +1 -1
  87. package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts.map +1 -1
  88. package/lib/typescript/module/floatingMenu/dial/DialDevTools.web.d.ts.map +1 -1
  89. package/lib/typescript/module/floatingMenu/dial/dialUsageStore.d.ts +3 -15
  90. package/lib/typescript/module/floatingMenu/dial/dialUsageStore.d.ts.map +1 -1
  91. package/lib/typescript/module/floatingMenu/dial/onboardingConstants.d.ts +1 -29
  92. package/lib/typescript/module/floatingMenu/dial/onboardingConstants.d.ts.map +1 -1
  93. package/lib/typescript/module/floatingMenu/dial/onboardingConstants.web.d.ts +1 -12
  94. package/lib/typescript/module/floatingMenu/dial/onboardingConstants.web.d.ts.map +1 -1
  95. package/lib/typescript/module/floatingMenu/floatingTools.d.ts +6 -55
  96. package/lib/typescript/module/floatingMenu/floatingTools.d.ts.map +1 -1
  97. package/lib/typescript/module/floatingMenu/floatingTools.web.d.ts +3 -53
  98. package/lib/typescript/module/floatingMenu/floatingTools.web.d.ts.map +1 -1
  99. package/lib/typescript/module/floatingMenu/optionalRequire.d.ts.map +1 -1
  100. package/lib/typescript/module/telemetry/installPing.d.ts +8 -1
  101. package/lib/typescript/module/telemetry/installPing.d.ts.map +1 -1
  102. package/lib/typescript/module/version.d.ts +1 -1
  103. package/package.json +6 -6
@@ -1,18 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  /**
4
- * Dial Usage Store - persists and ranks dial tool usage.
5
- *
6
- * Wraps the pure scoring logic from `@buoy-gg/floating-tools-core` with a
7
- * persisted, in-memory cache. The dial menu uses this to order tools by how
8
- * recently/frequently they are used, so the most-used tools land on page 1.
9
- *
10
- * The cache is loaded eagerly on import so `getRankedToolIds` can run
11
- * synchronously by the time the dial opens.
4
+ * Persists dial usage and orders tools by their last launch.
5
+ * The cache loads on import so opening the dial can rank tools synchronously.
12
6
  */
13
7
 
14
8
  import { persistentStorage, devToolsStorageKeys } from "@buoy-gg/shared-ui";
15
- import { rankToolIds, recordUsage, pruneUsage } from "@buoy-gg/floating-tools-core";
9
+ import { recordUsage, pruneUsage } from "@buoy-gg/floating-tools-core";
16
10
  const STORAGE_KEY = devToolsStorageKeys.dial.usage();
17
11
  let cache = {};
18
12
  let loaded = false;
@@ -50,15 +44,15 @@ export function isDialUsageLoaded() {
50
44
  return loaded;
51
45
  }
52
46
 
53
- /**
54
- * Rank tool ids by recency-weighted usage, highest first. Synchronous —
55
- * operates against the in-memory cache. Never-used tools keep their original
56
- * order as a tie-breaker.
57
- *
58
- * @param orderedIds - Tool ids in their default/registration order
59
- */
47
+ /** Most recently opened first; unused tools keep registration order. */
60
48
  export function getRankedToolIds(orderedIds) {
61
- return rankToolIds(orderedIds, cache, Date.now());
49
+ return orderedIds.map((id, index) => ({
50
+ id,
51
+ index,
52
+ lastUsed: cache[id]?.lastUsed ?? 0
53
+ })).sort((a, b) => b.lastUsed - a.lastUsed || a.index - b.index).map(({
54
+ id
55
+ }) => id);
62
56
  }
63
57
 
64
58
  /**
@@ -69,7 +63,9 @@ export function getRankedToolIds(orderedIds) {
69
63
  export async function recordToolUsage(id) {
70
64
  if (!id) return;
71
65
  if (!loaded) await loadDialUsage();
72
- const now = Date.now();
66
+
67
+ // Preserve launch order even when presses share a timestamp or the clock moves back.
68
+ const now = Math.max(Date.now(), ...Object.values(cache).map(entry => entry.lastUsed + 1));
73
69
  cache = pruneUsage(recordUsage(cache, id, now), now);
74
70
  try {
75
71
  await persistentStorage.setItem(STORAGE_KEY, JSON.stringify(cache));
@@ -1,64 +1,3 @@
1
1
  "use strict";
2
2
 
3
- import { Dimensions } from "react-native";
4
-
5
- /**
6
- * Shared constants for onboarding tooltip positioning
7
- * These ensure the floating menu aligns perfectly under the tooltip arrow
8
- * All positions are calculated dynamically based on screen size
9
- */
10
-
11
- // Arrow dimensions (relative positioning)
12
- export const ARROW_BOTTOM_OFFSET = -40; // Arrow extends below tooltip
13
- export const ARROW_HEIGHT = 20; // borderTopWidth of arrow
14
- export const SPACING_GAP = 10; // Gap between arrow tip and target element
15
-
16
- /**
17
- * Calculate the center Y position of the screen
18
- * This is used to vertically center the onboarding UI
19
- *
20
- * @returns Y coordinate at the center of the screen
21
- */
22
- export function getScreenCenterY() {
23
- const {
24
- height: screenHeight
25
- } = Dimensions.get("window");
26
- return screenHeight / 2;
27
- }
28
-
29
- /**
30
- * Calculate the tooltip position to center it vertically on screen
31
- * Uses flexbox-style centering - tooltip will center itself with its actual size
32
- *
33
- * @returns Distance from screen bottom for tooltip positioning
34
- */
35
- export function calculateTooltipPosition() {
36
- // Position from center - tooltip will be centered with transform or flex
37
- // We return a value that's slightly above center to account for the arrow below
38
- const centerY = getScreenCenterY();
39
-
40
- // Approximate offset to center the tooltip+arrow combo
41
- // This is a reasonable estimate that works for most tooltip sizes
42
- const estimatedHalfHeight = 130; // ~half of (tooltip + arrow)
43
-
44
- return centerY - estimatedHalfHeight;
45
- }
46
-
47
- /**
48
- * Calculate the position where a target element should be placed
49
- * to align directly under the tooltip arrow
50
- *
51
- * @returns Distance from screen bottom where element should be positioned
52
- */
53
- export function calculateTargetPosition() {
54
- const tooltipBottom = calculateTooltipPosition();
55
-
56
- // Arrow tip position = tooltip bottom + arrow offset (arrow extends below, so negative)
57
- const arrowTipFromBottom = tooltipBottom + ARROW_BOTTOM_OFFSET;
58
-
59
- // Subtract arrow height to get to the actual tip
60
- const actualArrowTip = arrowTipFromBottom - ARROW_HEIGHT;
61
-
62
- // Subtract spacing gap to position element below arrow
63
- return actualArrowTip - SPACING_GAP;
64
- }
3
+ export { ARROW_BOTTOM_OFFSET, ARROW_HEIGHT, SPACING_GAP, getScreenCenterY, calculateTooltipPosition, calculateTargetPosition } from "@buoy-gg/shared-ui";
@@ -1,27 +1,3 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Web twin of onboardingConstants.ts — same math, window.innerHeight instead
5
- * of RN Dimensions.
6
- */
7
- export const ARROW_BOTTOM_OFFSET = -40; // Arrow extends below tooltip
8
- export const ARROW_HEIGHT = 20; // borderTopWidth of arrow
9
- export const SPACING_GAP = 10; // Gap between arrow tip and target element
10
-
11
- export function getScreenCenterY() {
12
- return window.innerHeight / 2;
13
- }
14
-
15
- /** Distance from screen bottom for tooltip positioning (centered-ish). */
16
- export function calculateTooltipPosition() {
17
- const estimatedHalfHeight = 130; // ~half of (tooltip + arrow)
18
- return getScreenCenterY() - estimatedHalfHeight;
19
- }
20
-
21
- /** Distance from screen bottom where the bubble should sit (under the arrow). */
22
- export function calculateTargetPosition() {
23
- const tooltipBottom = calculateTooltipPosition();
24
- const arrowTipFromBottom = tooltipBottom + ARROW_BOTTOM_OFFSET;
25
- const actualArrowTip = arrowTipFromBottom - ARROW_HEIGHT;
26
- return actualArrowTip - SPACING_GAP;
27
- }
3
+ export { ARROW_BOTTOM_OFFSET, ARROW_HEIGHT, SPACING_GAP, getScreenCenterY, calculateTooltipPosition, calculateTargetPosition } from "@buoy-gg/shared-ui/floating";