@buoy-gg/floating-tools-core 3.0.1 → 3.0.2

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 (111) hide show
  1. package/lib/commonjs/FloatingToolsStore.js +501 -1
  2. package/lib/commonjs/colors.js +54 -1
  3. package/lib/commonjs/constants.js +31 -1
  4. package/lib/commonjs/devToolsState.js +325 -1
  5. package/lib/commonjs/dial.js +617 -1
  6. package/lib/commonjs/dialUsage.js +130 -1
  7. package/lib/commonjs/easing.js +69 -1
  8. package/lib/commonjs/icons/benchmark-icon.js +24 -1
  9. package/lib/commonjs/icons/env-icon.js +24 -1
  10. package/lib/commonjs/icons/events-icon.js +24 -1
  11. package/lib/commonjs/icons/highlight-icon.js +24 -1
  12. package/lib/commonjs/icons/icon-data.js +2268 -1
  13. package/lib/commonjs/icons/icon-factories.js +173 -1
  14. package/lib/commonjs/icons/icon-primitives.js +559 -1
  15. package/lib/commonjs/icons/icon-primitives.native.js +779 -1
  16. package/lib/commonjs/icons/icon-renderer.js +260 -1
  17. package/lib/commonjs/icons/network-icon.js +24 -1
  18. package/lib/commonjs/icons/query-icon.js +24 -1
  19. package/lib/commonjs/icons/redux-icon.js +85 -1
  20. package/lib/commonjs/icons/renders-icon.js +33 -1
  21. package/lib/commonjs/icons/routes-icon.js +49 -1
  22. package/lib/commonjs/icons/sentry-icon.js +24 -1
  23. package/lib/commonjs/icons/storage-icon.js +24 -1
  24. package/lib/commonjs/icons/wifi-icon.js +24 -1
  25. package/lib/commonjs/index.js +760 -1
  26. package/lib/commonjs/settings.js +601 -1
  27. package/lib/commonjs/utils.js +72 -1
  28. package/lib/module/FloatingToolsStore.js +496 -1
  29. package/lib/module/colors.js +49 -1
  30. package/lib/module/constants.js +27 -1
  31. package/lib/module/devToolsState.js +318 -1
  32. package/lib/module/dial.js +603 -1
  33. package/lib/module/dialUsage.js +122 -1
  34. package/lib/module/easing.js +62 -1
  35. package/lib/module/icons/benchmark-icon.js +15 -1
  36. package/lib/module/icons/env-icon.js +15 -1
  37. package/lib/module/icons/events-icon.js +15 -1
  38. package/lib/module/icons/highlight-icon.js +15 -1
  39. package/lib/module/icons/icon-data.js +2264 -1
  40. package/lib/module/icons/icon-factories.js +163 -1
  41. package/lib/module/icons/icon-primitives.js +547 -1
  42. package/lib/module/icons/icon-primitives.native.js +767 -1
  43. package/lib/module/icons/icon-renderer.js +255 -1
  44. package/lib/module/icons/network-icon.js +15 -1
  45. package/lib/module/icons/query-icon.js +15 -1
  46. package/lib/module/icons/redux-icon.js +81 -1
  47. package/lib/module/icons/renders-icon.js +17 -1
  48. package/lib/module/icons/routes-icon.js +41 -1
  49. package/lib/module/icons/sentry-icon.js +15 -1
  50. package/lib/module/icons/storage-icon.js +15 -1
  51. package/lib/module/icons/wifi-icon.js +15 -1
  52. package/lib/module/index.js +106 -1
  53. package/lib/module/settings.js +589 -1
  54. package/lib/module/utils.js +66 -1
  55. package/lib/typescript/commonjs/FloatingToolsStore.d.ts.map +1 -0
  56. package/lib/typescript/commonjs/colors.d.ts.map +1 -0
  57. package/lib/typescript/commonjs/constants.d.ts.map +1 -0
  58. package/lib/typescript/commonjs/devToolsState.d.ts.map +1 -0
  59. package/lib/typescript/commonjs/dial.d.ts.map +1 -0
  60. package/lib/typescript/commonjs/dialUsage.d.ts.map +1 -0
  61. package/lib/typescript/commonjs/easing.d.ts.map +1 -0
  62. package/lib/typescript/commonjs/icons/benchmark-icon.d.ts.map +1 -0
  63. package/lib/typescript/commonjs/icons/env-icon.d.ts.map +1 -0
  64. package/lib/typescript/commonjs/icons/events-icon.d.ts.map +1 -0
  65. package/lib/typescript/commonjs/icons/highlight-icon.d.ts.map +1 -0
  66. package/lib/typescript/commonjs/icons/icon-data.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/icons/icon-factories.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/icons/icon-primitives.d.ts.map +1 -0
  69. package/lib/typescript/commonjs/icons/icon-primitives.native.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/icons/icon-renderer.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/icons/network-icon.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/icons/query-icon.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/icons/redux-icon.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/icons/renders-icon.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/icons/routes-icon.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/icons/sentry-icon.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/icons/storage-icon.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/icons/wifi-icon.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/settings.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/utils.d.ts.map +1 -0
  83. package/lib/typescript/module/FloatingToolsStore.d.ts.map +1 -0
  84. package/lib/typescript/module/colors.d.ts.map +1 -0
  85. package/lib/typescript/module/constants.d.ts.map +1 -0
  86. package/lib/typescript/module/devToolsState.d.ts.map +1 -0
  87. package/lib/typescript/module/dial.d.ts.map +1 -0
  88. package/lib/typescript/module/dialUsage.d.ts.map +1 -0
  89. package/lib/typescript/module/easing.d.ts.map +1 -0
  90. package/lib/typescript/module/icons/benchmark-icon.d.ts.map +1 -0
  91. package/lib/typescript/module/icons/env-icon.d.ts.map +1 -0
  92. package/lib/typescript/module/icons/events-icon.d.ts.map +1 -0
  93. package/lib/typescript/module/icons/highlight-icon.d.ts.map +1 -0
  94. package/lib/typescript/module/icons/icon-data.d.ts.map +1 -0
  95. package/lib/typescript/module/icons/icon-factories.d.ts.map +1 -0
  96. package/lib/typescript/module/icons/icon-primitives.d.ts.map +1 -0
  97. package/lib/typescript/module/icons/icon-primitives.native.d.ts.map +1 -0
  98. package/lib/typescript/module/icons/icon-renderer.d.ts.map +1 -0
  99. package/lib/typescript/module/icons/network-icon.d.ts.map +1 -0
  100. package/lib/typescript/module/icons/query-icon.d.ts.map +1 -0
  101. package/lib/typescript/module/icons/redux-icon.d.ts.map +1 -0
  102. package/lib/typescript/module/icons/renders-icon.d.ts.map +1 -0
  103. package/lib/typescript/module/icons/routes-icon.d.ts.map +1 -0
  104. package/lib/typescript/module/icons/sentry-icon.d.ts.map +1 -0
  105. package/lib/typescript/module/icons/storage-icon.d.ts.map +1 -0
  106. package/lib/typescript/module/icons/wifi-icon.d.ts.map +1 -0
  107. package/lib/typescript/module/index.d.ts.map +1 -0
  108. package/lib/typescript/module/settings.d.ts.map +1 -0
  109. package/lib/typescript/module/types.d.ts.map +1 -0
  110. package/lib/typescript/module/utils.d.ts.map +1 -0
  111. package/package.json +1 -1
@@ -1 +1,122 @@
1
- "use strict";export const USAGE_HALF_LIFE_MS=2592e5;export const USAGE_MIN_SCORE=.01;export function decayScore(e,o){if(!e||e.score<=0)return 0;const r=o-e.lastUsed;return r<=0?e.score:e.score*Math.pow(.5,r/2592e5)}export function recordUsage(e,o,r){const c=decayScore(e[o],r);return{...e,[o]:{score:c+1,lastUsed:r}}}export function rankToolIds(e,o,r){const c=e.map((e,c)=>({id:e,index:c,score:decayScore(o[e],r)}));return c.sort((e,o)=>o.score!==e.score?o.score-e.score:e.index-o.index),c.map(e=>e.id)}export function pruneUsage(e,o){const r={};for(const[c,t]of Object.entries(e))decayScore(t,o)>.01&&(r[c]=t);return r}
1
+ "use strict";
2
+
3
+ /**
4
+ * Dial Usage - Recency-weighted usage tracking for the dial menu.
5
+ *
6
+ * Pure scoring/ranking logic. No React or platform-specific code.
7
+ *
8
+ * The dial menu ranks tools by how recently and frequently they are used.
9
+ * Each press adds 1 point to a tool's score; that score decays exponentially
10
+ * over time (half-life ~3 days) so the ordering reflects "what I'm using most
11
+ * lately" rather than all-time totals.
12
+ */
13
+
14
+ // =============================
15
+ // Constants
16
+ // =============================
17
+
18
+ /**
19
+ * Half-life of a usage score, in milliseconds (~3 days).
20
+ * After this much time, an untouched tool's score halves.
21
+ */
22
+ export const USAGE_HALF_LIFE_MS = 3 * 24 * 60 * 60 * 1000;
23
+
24
+ /**
25
+ * Scores at or below this value are treated as zero. Entries that decay
26
+ * below it can be safely pruned from storage.
27
+ */
28
+ export const USAGE_MIN_SCORE = 0.01;
29
+
30
+ // =============================
31
+ // Types
32
+ // =============================
33
+
34
+ /**
35
+ * A single tool's usage record.
36
+ */
37
+
38
+ /** Map of tool id to its usage record. */
39
+
40
+ // =============================
41
+ // Scoring
42
+ // =============================
43
+
44
+ /**
45
+ * Decay a stored score forward to `now`.
46
+ *
47
+ * @param entry - The usage entry to evaluate
48
+ * @param now - Current epoch ms
49
+ * @returns The score decayed to `now` (never negative)
50
+ */
51
+ export function decayScore(entry, now) {
52
+ if (!entry || entry.score <= 0) return 0;
53
+ const elapsed = now - entry.lastUsed;
54
+ // Guard against clock skew producing a score boost.
55
+ if (elapsed <= 0) return entry.score;
56
+ return entry.score * Math.pow(0.5, elapsed / USAGE_HALF_LIFE_MS);
57
+ }
58
+
59
+ /**
60
+ * Record a single press of a tool, returning a new usage map.
61
+ *
62
+ * The existing score is decayed forward to `now` before adding 1, so a
63
+ * burst of presses accumulates while stale scores naturally fade.
64
+ *
65
+ * @param map - Current usage map
66
+ * @param id - Tool id that was pressed
67
+ * @param now - Current epoch ms
68
+ * @returns A new usage map (input is not mutated)
69
+ */
70
+ export function recordUsage(map, id, now) {
71
+ const decayed = decayScore(map[id], now);
72
+ return {
73
+ ...map,
74
+ [id]: {
75
+ score: decayed + 1,
76
+ lastUsed: now
77
+ }
78
+ };
79
+ }
80
+
81
+ /**
82
+ * Rank tool ids by decayed usage score, highest first.
83
+ *
84
+ * The sort is stable: tools with equal scores (including never-used tools,
85
+ * which score 0) keep their original order in `orderedIds`. This preserves
86
+ * registration order as the tie-breaker.
87
+ *
88
+ * @param orderedIds - Tool ids in their default/registration order
89
+ * @param map - Current usage map
90
+ * @param now - Current epoch ms
91
+ * @returns A new array of ids sorted by usage
92
+ */
93
+ export function rankToolIds(orderedIds, map, now) {
94
+ const scored = orderedIds.map((id, index) => ({
95
+ id,
96
+ index,
97
+ score: decayScore(map[id], now)
98
+ }));
99
+ scored.sort((a, b) => {
100
+ if (b.score !== a.score) return b.score - a.score;
101
+ return a.index - b.index;
102
+ });
103
+ return scored.map(entry => entry.id);
104
+ }
105
+
106
+ /**
107
+ * Drop entries whose decayed score has fallen below `USAGE_MIN_SCORE`,
108
+ * keeping the persisted map from growing unbounded.
109
+ *
110
+ * @param map - Current usage map
111
+ * @param now - Current epoch ms
112
+ * @returns A new, pruned usage map
113
+ */
114
+ export function pruneUsage(map, now) {
115
+ const pruned = {};
116
+ for (const [id, entry] of Object.entries(map)) {
117
+ if (decayScore(entry, now) > USAGE_MIN_SCORE) {
118
+ pruned[id] = entry;
119
+ }
120
+ }
121
+ return pruned;
122
+ }
@@ -1 +1,62 @@
1
- "use strict";export const easing={linear:e=>e,easeOutCubic:e=>1-Math.pow(1-e,3),easeInCubic:e=>e*e*e,easeInOutCubic:e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,easeOutQuad:e=>1-(1-e)*(1-e),easeOutExpo:e=>1===e?1:1-Math.pow(2,-10*e)};export function getEasing(e){return easing[e]}export function interpolate(e,t,a,n=easing.easeOutCubic){return e+(t-e)*n(Math.max(0,Math.min(1,a)))}export function interpolatePosition(e,t,a,n=easing.easeOutCubic){return{x:interpolate(e.x,t.x,a,n),y:interpolate(e.y,t.y,a,n)}}
1
+ "use strict";
2
+
3
+ /**
4
+ * Animation easing functions.
5
+ * Platform-agnostic - used by both web (RAF) and mobile (Animated).
6
+ */
7
+
8
+ /**
9
+ * Easing functions for animations.
10
+ * All functions take progress (0-1) and return eased value (0-1).
11
+ */
12
+ export const easing = {
13
+ /**
14
+ * Linear - no easing.
15
+ */
16
+ linear: t => t,
17
+ /**
18
+ * Ease out cubic - decelerates towards end.
19
+ * Used for hide/show animations.
20
+ */
21
+ easeOutCubic: t => 1 - Math.pow(1 - t, 3),
22
+ /**
23
+ * Ease in cubic - accelerates from start.
24
+ */
25
+ easeInCubic: t => t * t * t,
26
+ /**
27
+ * Ease in-out cubic - smooth acceleration and deceleration.
28
+ */
29
+ easeInOutCubic: t => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2,
30
+ /**
31
+ * Ease out quad - lighter deceleration than cubic.
32
+ */
33
+ easeOutQuad: t => 1 - (1 - t) * (1 - t),
34
+ /**
35
+ * Ease out expo - strong deceleration (snappy feel).
36
+ */
37
+ easeOutExpo: t => t === 1 ? 1 : 1 - Math.pow(2, -10 * t)
38
+ };
39
+ /**
40
+ * Get an easing function by name.
41
+ */
42
+ export function getEasing(name) {
43
+ return easing[name];
44
+ }
45
+
46
+ /**
47
+ * Interpolate between two values using an easing function.
48
+ */
49
+ export function interpolate(from, to, progress, easingFn = easing.easeOutCubic) {
50
+ const eased = easingFn(Math.max(0, Math.min(1, progress)));
51
+ return from + (to - from) * eased;
52
+ }
53
+
54
+ /**
55
+ * Interpolate a position (x, y) using an easing function.
56
+ */
57
+ export function interpolatePosition(from, to, progress, easingFn = easing.easeOutCubic) {
58
+ return {
59
+ x: interpolate(from.x, to.x, progress, easingFn),
60
+ y: interpolate(from.y, to.y, progress, easingFn)
61
+ };
62
+ }
@@ -1 +1,15 @@
1
- "use strict";import{createIcon}from"./icon-renderer.js";import{benchmarkIconData,BENCHMARK_ICON_COLOR}from"./icon-data.js";export{BENCHMARK_ICON_COLOR};export const BenchmarkIcon=createIcon(benchmarkIconData);
1
+ "use strict";
2
+
3
+ /**
4
+ * BenchmarkIcon - Data-driven icon
5
+ *
6
+ * The icon is defined as pure data in icon-data.ts
7
+ * The renderer transforms it to components.
8
+ *
9
+ * To change: edit benchmarkIconData in icon-data.ts
10
+ */
11
+
12
+ import { createIcon } from "./icon-renderer.js";
13
+ import { benchmarkIconData, BENCHMARK_ICON_COLOR } from "./icon-data.js";
14
+ export { BENCHMARK_ICON_COLOR };
15
+ export const BenchmarkIcon = createIcon(benchmarkIconData);
@@ -1 +1,15 @@
1
- "use strict";import{createIcon}from"./icon-renderer.js";import{envIconData,ENV_ICON_COLOR}from"./icon-data.js";export{ENV_ICON_COLOR};export const EnvIcon=createIcon(envIconData);
1
+ "use strict";
2
+
3
+ /**
4
+ * EnvIcon - Data-driven icon
5
+ *
6
+ * The icon is defined as pure data in icon-data.ts
7
+ * The renderer transforms it to components.
8
+ *
9
+ * To change: edit envIconData in icon-data.ts
10
+ */
11
+
12
+ import { createIcon } from "./icon-renderer.js";
13
+ import { envIconData, ENV_ICON_COLOR } from "./icon-data.js";
14
+ export { ENV_ICON_COLOR };
15
+ export const EnvIcon = createIcon(envIconData);
@@ -1 +1,15 @@
1
- "use strict";import{createIcon}from"./icon-renderer.js";import{eventsIconData,EVENTS_ICON_COLOR}from"./icon-data.js";export{EVENTS_ICON_COLOR};export const EventsIcon=createIcon(eventsIconData);
1
+ "use strict";
2
+
3
+ /**
4
+ * EventsIcon - Data-driven icon
5
+ *
6
+ * The icon is defined as pure data in icon-data.ts
7
+ * The renderer transforms it to components.
8
+ *
9
+ * To change: edit eventsIconData in icon-data.ts
10
+ */
11
+
12
+ import { createIcon } from "./icon-renderer.js";
13
+ import { eventsIconData, EVENTS_ICON_COLOR } from "./icon-data.js";
14
+ export { EVENTS_ICON_COLOR };
15
+ export const EventsIcon = createIcon(eventsIconData);
@@ -1 +1,15 @@
1
- "use strict";import{createIcon}from"./icon-renderer.js";import{highlightIconData,HIGHLIGHT_ICON_COLOR}from"./icon-data.js";export{HIGHLIGHT_ICON_COLOR};export const HighlightIcon=createIcon(highlightIconData);
1
+ "use strict";
2
+
3
+ /**
4
+ * HighlightIcon - Data-driven icon (also known as StackPulseIcon/RenderPulseIcon)
5
+ *
6
+ * The icon is defined as pure data in icon-data.ts
7
+ * The renderer transforms it to components.
8
+ *
9
+ * To change: edit highlightIconData in icon-data.ts
10
+ */
11
+
12
+ import { createIcon } from "./icon-renderer.js";
13
+ import { highlightIconData, HIGHLIGHT_ICON_COLOR } from "./icon-data.js";
14
+ export { HIGHLIGHT_ICON_COLOR };
15
+ export const HighlightIcon = createIcon(highlightIconData);