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

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