@buoy-gg/floating-tools-core 2.2.0 → 3.0.0
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.
- package/lib/commonjs/FloatingToolsStore.js +501 -1
- package/lib/commonjs/colors.js +54 -1
- package/lib/commonjs/constants.js +31 -1
- package/lib/commonjs/devToolsState.js +325 -1
- package/lib/commonjs/dial.js +617 -1
- package/lib/commonjs/dialUsage.js +130 -1
- package/lib/commonjs/easing.js +69 -1
- package/lib/commonjs/icons/benchmark-icon.js +24 -1
- package/lib/commonjs/icons/env-icon.js +24 -1
- package/lib/commonjs/icons/events-icon.js +24 -1
- package/lib/commonjs/icons/highlight-icon.js +24 -1
- package/lib/commonjs/icons/icon-data.js +2268 -1
- package/lib/commonjs/icons/icon-factories.js +173 -1
- package/lib/commonjs/icons/icon-primitives.js +559 -1
- package/lib/commonjs/icons/icon-primitives.native.js +779 -1
- package/lib/commonjs/icons/icon-renderer.js +260 -1
- package/lib/commonjs/icons/network-icon.js +24 -1
- package/lib/commonjs/icons/query-icon.js +24 -1
- package/lib/commonjs/icons/redux-icon.js +85 -1
- package/lib/commonjs/icons/renders-icon.js +33 -1
- package/lib/commonjs/icons/routes-icon.js +49 -1
- package/lib/commonjs/icons/sentry-icon.js +24 -1
- package/lib/commonjs/icons/storage-icon.js +24 -1
- package/lib/commonjs/icons/wifi-icon.js +24 -1
- package/lib/commonjs/index.js +760 -1
- package/lib/commonjs/settings.js +601 -1
- package/lib/commonjs/utils.js +72 -1
- package/lib/module/FloatingToolsStore.js +496 -1
- package/lib/module/colors.js +49 -1
- package/lib/module/constants.js +27 -1
- package/lib/module/devToolsState.js +318 -1
- package/lib/module/dial.js +603 -1
- package/lib/module/dialUsage.js +122 -1
- package/lib/module/easing.js +62 -1
- package/lib/module/icons/benchmark-icon.js +15 -1
- package/lib/module/icons/env-icon.js +15 -1
- package/lib/module/icons/events-icon.js +15 -1
- package/lib/module/icons/highlight-icon.js +15 -1
- package/lib/module/icons/icon-data.js +2264 -1
- package/lib/module/icons/icon-factories.js +163 -1
- package/lib/module/icons/icon-primitives.js +547 -1
- package/lib/module/icons/icon-primitives.native.js +767 -1
- package/lib/module/icons/icon-renderer.js +255 -1
- package/lib/module/icons/network-icon.js +15 -1
- package/lib/module/icons/query-icon.js +15 -1
- package/lib/module/icons/redux-icon.js +81 -1
- package/lib/module/icons/renders-icon.js +17 -1
- package/lib/module/icons/routes-icon.js +41 -1
- package/lib/module/icons/sentry-icon.js +15 -1
- package/lib/module/icons/storage-icon.js +15 -1
- package/lib/module/icons/wifi-icon.js +15 -1
- package/lib/module/index.js +106 -1
- package/lib/module/settings.js +589 -1
- package/lib/module/utils.js +66 -1
- package/lib/typescript/commonjs/FloatingToolsStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/devToolsState.d.ts.map +1 -0
- package/lib/typescript/commonjs/dial.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialUsage.d.ts.map +1 -0
- package/lib/typescript/commonjs/easing.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/benchmark-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/env-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/events-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/highlight-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/icon-data.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/icon-factories.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/icon-primitives.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/icon-primitives.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/icon-renderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/network-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/query-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/redux-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/renders-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/routes-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/sentry-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/storage-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/icons/wifi-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/settings.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils.d.ts.map +1 -0
- package/lib/typescript/module/FloatingToolsStore.d.ts.map +1 -0
- package/lib/typescript/module/colors.d.ts.map +1 -0
- package/lib/typescript/module/constants.d.ts.map +1 -0
- package/lib/typescript/module/devToolsState.d.ts.map +1 -0
- package/lib/typescript/module/dial.d.ts.map +1 -0
- package/lib/typescript/module/dialUsage.d.ts.map +1 -0
- package/lib/typescript/module/easing.d.ts.map +1 -0
- package/lib/typescript/module/icons/benchmark-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/env-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/events-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/highlight-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/icon-data.d.ts.map +1 -0
- package/lib/typescript/module/icons/icon-factories.d.ts.map +1 -0
- package/lib/typescript/module/icons/icon-primitives.d.ts.map +1 -0
- package/lib/typescript/module/icons/icon-primitives.native.d.ts.map +1 -0
- package/lib/typescript/module/icons/icon-renderer.d.ts.map +1 -0
- package/lib/typescript/module/icons/network-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/query-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/redux-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/renders-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/routes-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/sentry-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/storage-icon.d.ts.map +1 -0
- package/lib/typescript/module/icons/wifi-icon.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/settings.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/utils.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1,130 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
}
|
package/lib/commonjs/easing.js
CHANGED
|
@@ -1 +1,69 @@
|
|
|
1
|
-
"use strict";
|
|
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";
|
|
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";
|
|
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";
|
|
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";
|
|
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);
|