maidr 2.25.0 → 2.26.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/dist/maidr.js +218 -16
- package/dist/maidr.min.js +1 -1
- package/package.json +1 -1
package/dist/maidr.js
CHANGED
|
@@ -1222,7 +1222,7 @@ class Menu {
|
|
|
1222
1222
|
document
|
|
1223
1223
|
.getElementById('gemini_multi_container')
|
|
1224
1224
|
.classList.add('hidden');
|
|
1225
|
-
document.getElementById('openai_multi').checked = true;
|
|
1225
|
+
document.getElementById('openai_multi').checked = true; // refactor note: this hidden checkbox stuff is stupid and should be removed. We're sorta replacing with the visible checkboxes.
|
|
1226
1226
|
document.getElementById('gemini_multi').checked = false;
|
|
1227
1227
|
} else if (e.target.value == 'gemini') {
|
|
1228
1228
|
document
|
|
@@ -1492,7 +1492,7 @@ class Menu {
|
|
|
1492
1492
|
}
|
|
1493
1493
|
|
|
1494
1494
|
if (constants.emailAuthKey && constants.clientToken) {
|
|
1495
|
-
console.log('email auth key and client token found');
|
|
1495
|
+
//console.log('email auth key and client token found');
|
|
1496
1496
|
for (let model in constants.LLMModels) {
|
|
1497
1497
|
document.getElementById(`LLM_model_${model}`).checked = true;
|
|
1498
1498
|
}
|
|
@@ -1566,8 +1566,12 @@ class Menu {
|
|
|
1566
1566
|
});
|
|
1567
1567
|
|
|
1568
1568
|
constants.LLMPreferences = document.getElementById('LLM_preferences').value;
|
|
1569
|
-
constants.LLMOpenAiMulti =
|
|
1570
|
-
|
|
1569
|
+
constants.LLMOpenAiMulti =
|
|
1570
|
+
document.getElementById('LLM_model_openai').checked;
|
|
1571
|
+
constants.LLMGeminiMulti =
|
|
1572
|
+
document.getElementById('LLM_model_gemini').checked;
|
|
1573
|
+
constants.LLMClaudeMulti =
|
|
1574
|
+
document.getElementById('LLM_model_claude').checked;
|
|
1571
1575
|
constants.autoInitLLM = document.getElementById('init_llm_on_load').checked;
|
|
1572
1576
|
|
|
1573
1577
|
// aria
|
|
@@ -1797,6 +1801,7 @@ class ChatLLM {
|
|
|
1797
1801
|
this.firstMulti = true;
|
|
1798
1802
|
this.firstOpen = true;
|
|
1799
1803
|
this.shown = false;
|
|
1804
|
+
this.awaitingNumChats = 0;
|
|
1800
1805
|
this.CreateComponent();
|
|
1801
1806
|
this.SetEvents();
|
|
1802
1807
|
if (constants.autoInitLLM) {
|
|
@@ -2005,7 +2010,7 @@ class ChatLLM {
|
|
|
2005
2010
|
*
|
|
2006
2011
|
* @param {Event|undefined} e - The event that triggered the copy action. If undefined, the entire chat history is copied.
|
|
2007
2012
|
*/
|
|
2008
|
-
CopyChatHistory(e) {
|
|
2013
|
+
CopyChatHistory(e, actuallyCopy = true) {
|
|
2009
2014
|
let text = '';
|
|
2010
2015
|
let notificationText = '';
|
|
2011
2016
|
if (typeof e == 'undefined') {
|
|
@@ -2067,10 +2072,12 @@ class ChatLLM {
|
|
|
2067
2072
|
}
|
|
2068
2073
|
}
|
|
2069
2074
|
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2075
|
+
if (actuallyCopy) {
|
|
2076
|
+
try {
|
|
2077
|
+
navigator.clipboard.writeText(markdown); // note: this fails if you're on the inspector. That's fine as it'll never happen to real users
|
|
2078
|
+
} catch (err) {
|
|
2079
|
+
console.error('Failed to copy: ', err);
|
|
2080
|
+
}
|
|
2074
2081
|
}
|
|
2075
2082
|
return markdown;
|
|
2076
2083
|
}
|
|
@@ -2204,7 +2211,7 @@ class ChatLLM {
|
|
|
2204
2211
|
let inprogressFreq = freq * 2;
|
|
2205
2212
|
|
|
2206
2213
|
if (onoff) {
|
|
2207
|
-
// if turning on
|
|
2214
|
+
// if turning on clear old intervals and timeouts
|
|
2208
2215
|
if (constants.waitingInterval) {
|
|
2209
2216
|
// destroy old waiting sound
|
|
2210
2217
|
clearInterval(constants.waitingInterval);
|
|
@@ -2255,6 +2262,9 @@ class ChatLLM {
|
|
|
2255
2262
|
if (constants.LLMOpenAiMulti) {
|
|
2256
2263
|
constants.waitingQueue++;
|
|
2257
2264
|
}
|
|
2265
|
+
if (constants.LLMClaudeMulti) {
|
|
2266
|
+
constants.waitingQueue++;
|
|
2267
|
+
}
|
|
2258
2268
|
}
|
|
2259
2269
|
}
|
|
2260
2270
|
}
|
|
@@ -2335,7 +2345,7 @@ class ChatLLM {
|
|
|
2335
2345
|
|
|
2336
2346
|
// if we're tracking, log the data
|
|
2337
2347
|
if (constants.canTrack) {
|
|
2338
|
-
let chatHist = chatLLM.CopyChatHistory();
|
|
2348
|
+
let chatHist = chatLLM.CopyChatHistory(undefined, false);
|
|
2339
2349
|
let data = {};
|
|
2340
2350
|
data.chatHistory = chatHist;
|
|
2341
2351
|
if (constants.emailAuthKey) data.username = constants.emailAuthKey;
|
|
@@ -2721,7 +2731,7 @@ class ChatLLM {
|
|
|
2721
2731
|
const API_KEY = constants.geminiAuthKey;
|
|
2722
2732
|
const genAI = new GoogleGenerativeAI(API_KEY);
|
|
2723
2733
|
const model = genAI.getGenerativeModel({
|
|
2724
|
-
model: 'gemini-
|
|
2734
|
+
model: 'gemini-2.0-flash-exp',
|
|
2725
2735
|
}); // old model was 'gemini-pro-vision'
|
|
2726
2736
|
|
|
2727
2737
|
// Create the prompt
|
|
@@ -3256,7 +3266,7 @@ class Tracker {
|
|
|
3256
3266
|
* @param {Object} data - The data to be saved.
|
|
3257
3267
|
*/
|
|
3258
3268
|
async SaveTrackerData(data) {
|
|
3259
|
-
console.log('about to save data', data);
|
|
3269
|
+
//console.log('about to save data', data);
|
|
3260
3270
|
if (this.isLocal) {
|
|
3261
3271
|
localStorage.setItem(constants.project_id, JSON.stringify(data));
|
|
3262
3272
|
} else {
|
|
@@ -3275,7 +3285,7 @@ class Tracker {
|
|
|
3275
3285
|
}
|
|
3276
3286
|
|
|
3277
3287
|
const result = await response.json();
|
|
3278
|
-
console.log('Data saved successfully:', result);
|
|
3288
|
+
//console.log('Data saved successfully:', result);
|
|
3279
3289
|
return result;
|
|
3280
3290
|
} catch (error) {
|
|
3281
3291
|
console.error('Error saving data:', error);
|
|
@@ -8605,7 +8615,8 @@ class Control {
|
|
|
8605
8615
|
this.InitChartClass();
|
|
8606
8616
|
this.SetBTSControls();
|
|
8607
8617
|
this.SetPrefixControls();
|
|
8608
|
-
this.
|
|
8618
|
+
this.SetKeyControls();
|
|
8619
|
+
this.SetMouseControls();
|
|
8609
8620
|
}
|
|
8610
8621
|
|
|
8611
8622
|
/**
|
|
@@ -8868,6 +8879,197 @@ class Control {
|
|
|
8868
8879
|
]);
|
|
8869
8880
|
}
|
|
8870
8881
|
|
|
8882
|
+
/**
|
|
8883
|
+
* Sets up event listeners for mouse controls
|
|
8884
|
+
* If you're on a chart, and within 24px of a point, set your position there and update the chart
|
|
8885
|
+
* If you're near multiple, figure it out.
|
|
8886
|
+
* This requires the selector to be set in the maidr object.
|
|
8887
|
+
* @returns {void}
|
|
8888
|
+
*/
|
|
8889
|
+
SetMouseControls() {
|
|
8890
|
+
// to set this up, we run the event at the document level, and then deal with what we've hovered on in individual chart types
|
|
8891
|
+
// for bar hist stacked, we check if we've hovered on an element of the selector
|
|
8892
|
+
// for box line, we use coordinates and find the closest point
|
|
8893
|
+
if ('selector' in singleMaidr) {
|
|
8894
|
+
let selectorElems = document.querySelectorAll(singleMaidr.selector);
|
|
8895
|
+
if (selectorElems.length > 0) {
|
|
8896
|
+
constants.events.push([
|
|
8897
|
+
document,
|
|
8898
|
+
'mousemove',
|
|
8899
|
+
function (e) {
|
|
8900
|
+
if (constants.chartType == 'bar' || constants.chartType == 'hist') {
|
|
8901
|
+
// check if we've hit a selector
|
|
8902
|
+
if (e.target.matches(singleMaidr.selector)) {
|
|
8903
|
+
let index = Array.from(selectorElems).indexOf(e.target);
|
|
8904
|
+
if (index != position.x) {
|
|
8905
|
+
position.x = index;
|
|
8906
|
+
control.UpdateAll();
|
|
8907
|
+
}
|
|
8908
|
+
}
|
|
8909
|
+
} else if (constants.chartType == 'box') {
|
|
8910
|
+
// here follows a nasty function where we use bounding boxes from the highlight feature compare to our hover coords
|
|
8911
|
+
let closestDistance = Infinity;
|
|
8912
|
+
let closestIndex = -1;
|
|
8913
|
+
let clickX = e.clientX;
|
|
8914
|
+
let clickY = e.clientY;
|
|
8915
|
+
let expandedBox = null;
|
|
8916
|
+
let padding = 15;
|
|
8917
|
+
const chartBounds = constants.chart.getBoundingClientRect();
|
|
8918
|
+
|
|
8919
|
+
// Iterate through plot.plotBounds using regular loops
|
|
8920
|
+
for (
|
|
8921
|
+
let groupIndex = 0;
|
|
8922
|
+
groupIndex < plot.plotBounds.length;
|
|
8923
|
+
groupIndex++
|
|
8924
|
+
) {
|
|
8925
|
+
const group = plot.plotBounds[groupIndex];
|
|
8926
|
+
|
|
8927
|
+
for (let boxIndex = 0; boxIndex < group.length; boxIndex++) {
|
|
8928
|
+
const box = group[boxIndex];
|
|
8929
|
+
|
|
8930
|
+
if (
|
|
8931
|
+
box.top === undefined ||
|
|
8932
|
+
box.left === undefined ||
|
|
8933
|
+
box.bottom === undefined ||
|
|
8934
|
+
box.right === undefined
|
|
8935
|
+
) {
|
|
8936
|
+
continue; // Skip invalid boxes
|
|
8937
|
+
}
|
|
8938
|
+
// Expand the bounding box by 15px
|
|
8939
|
+
let expandedBoxAdjustedCoords = {
|
|
8940
|
+
x: box.left - padding - chartBounds.left,
|
|
8941
|
+
y: box.top - padding - chartBounds.top,
|
|
8942
|
+
width: box.width + padding * 2,
|
|
8943
|
+
height: box.height + padding * 2,
|
|
8944
|
+
};
|
|
8945
|
+
expandedBox = {
|
|
8946
|
+
top: expandedBoxAdjustedCoords.y,
|
|
8947
|
+
left: expandedBoxAdjustedCoords.x,
|
|
8948
|
+
bottom:
|
|
8949
|
+
expandedBoxAdjustedCoords.y +
|
|
8950
|
+
expandedBoxAdjustedCoords.height,
|
|
8951
|
+
right:
|
|
8952
|
+
expandedBoxAdjustedCoords.x +
|
|
8953
|
+
expandedBoxAdjustedCoords.width,
|
|
8954
|
+
};
|
|
8955
|
+
// Calculate the center of the bounding box
|
|
8956
|
+
const centerX = (expandedBox.left + expandedBox.right) / 2;
|
|
8957
|
+
const centerY = (expandedBox.top + expandedBox.bottom) / 2;
|
|
8958
|
+
|
|
8959
|
+
// Calculate the Euclidean distance
|
|
8960
|
+
const distance = Math.sqrt(
|
|
8961
|
+
(centerX - clickX) ** 2 + (centerY - clickY) ** 2
|
|
8962
|
+
);
|
|
8963
|
+
|
|
8964
|
+
//console.log( 'clicked coords: (', clickX, ', ', clickY, ') | box coords: (', centerX, ', ', centerY, ') | distance: ', distance, 'array index: [', groupIndex, ',', boxIndex, ']');
|
|
8965
|
+
|
|
8966
|
+
// Update the closest box if this one is nearer, and is inside the bounding box
|
|
8967
|
+
if (distance < closestDistance) {
|
|
8968
|
+
if (
|
|
8969
|
+
clickX >= expandedBox.left &&
|
|
8970
|
+
clickX <= expandedBox.right &&
|
|
8971
|
+
clickY >= expandedBox.top &&
|
|
8972
|
+
clickY <= expandedBox.bottom
|
|
8973
|
+
) {
|
|
8974
|
+
closestDistance = distance;
|
|
8975
|
+
closestIndex = [groupIndex, boxIndex];
|
|
8976
|
+
}
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
}
|
|
8980
|
+
|
|
8981
|
+
// did we get one?
|
|
8982
|
+
if (closestDistance < Infinity) {
|
|
8983
|
+
//console.log('found a box, index', closestIndex);
|
|
8984
|
+
if (constants.plotOrientation == 'horz') {
|
|
8985
|
+
if (
|
|
8986
|
+
position.x != closestIndex[0] ||
|
|
8987
|
+
position.y != closestIndex[1]
|
|
8988
|
+
) {
|
|
8989
|
+
position.x = closestIndex[1];
|
|
8990
|
+
position.y = closestIndex[0];
|
|
8991
|
+
control.UpdateAll();
|
|
8992
|
+
}
|
|
8993
|
+
} else {
|
|
8994
|
+
if (
|
|
8995
|
+
position.x != closestIndex[0] ||
|
|
8996
|
+
position.y != closestIndex[1]
|
|
8997
|
+
) {
|
|
8998
|
+
position.x = closestIndex[0];
|
|
8999
|
+
position.y = closestIndex[1];
|
|
9000
|
+
control.UpdateAll();
|
|
9001
|
+
}
|
|
9002
|
+
}
|
|
9003
|
+
}
|
|
9004
|
+
} else if (constants.chartType == 'heat') {
|
|
9005
|
+
// check if we've hit a selector
|
|
9006
|
+
let index = Array.from(selectorElems).indexOf(e.target);
|
|
9007
|
+
if (
|
|
9008
|
+
position.x != Math.floor(index / plot.num_rows) ||
|
|
9009
|
+
position.y != plot.num_rows - (index % plot.num_rows) - 1
|
|
9010
|
+
) {
|
|
9011
|
+
position.x = Math.floor(index / plot.num_rows);
|
|
9012
|
+
position.y = plot.num_rows - (index % plot.num_rows) - 1;
|
|
9013
|
+
control.UpdateAll();
|
|
9014
|
+
}
|
|
9015
|
+
} else if (constants.chartType == 'line') {
|
|
9016
|
+
// compare coordinates and get the point we're closest to, if we're within 24px
|
|
9017
|
+
let chartBounds = constants.chart.getBoundingClientRect();
|
|
9018
|
+
let scaleX =
|
|
9019
|
+
constants.chart.viewBox.baseVal.width / chartBounds.width;
|
|
9020
|
+
let scaleY =
|
|
9021
|
+
constants.chart.viewBox.baseVal.height / chartBounds.height;
|
|
9022
|
+
|
|
9023
|
+
let closestDistance = Infinity;
|
|
9024
|
+
let closestIndex = -1;
|
|
9025
|
+
let clickX = (e.clientX - chartBounds.left) * scaleX;
|
|
9026
|
+
let clickY = (e.clientY - chartBounds.top) * scaleY;
|
|
9027
|
+
let pointX, pointY;
|
|
9028
|
+
for (let i = 0; i < plot.chartLineX.length; i++) {
|
|
9029
|
+
pointX = plot.chartLineX[i] - chartBounds.left;
|
|
9030
|
+
pointY = plot.chartLineY[i] - chartBounds.top;
|
|
9031
|
+
let distance = Math.sqrt(
|
|
9032
|
+
(pointX - clickX) ** 2 + (pointY - clickY) ** 2
|
|
9033
|
+
);
|
|
9034
|
+
//console.log( 'distance', distance, 'given clicked coords (', clickX, ', ', clickY, ') and target coords (', pointX, ', ', pointY, ')');
|
|
9035
|
+
if (distance < closestDistance) {
|
|
9036
|
+
closestDistance = distance;
|
|
9037
|
+
closestIndex = i;
|
|
9038
|
+
}
|
|
9039
|
+
}
|
|
9040
|
+
if (closestDistance < 24) {
|
|
9041
|
+
if (position.x != closestIndex) {
|
|
9042
|
+
position.x = closestIndex;
|
|
9043
|
+
control.UpdateAll();
|
|
9044
|
+
}
|
|
9045
|
+
}
|
|
9046
|
+
} else if (
|
|
9047
|
+
constants.chartType == 'stacked_bar' ||
|
|
9048
|
+
constants.chartType == 'stacked_normalized_bar' ||
|
|
9049
|
+
constants.chartType == 'dodged_bar'
|
|
9050
|
+
) {
|
|
9051
|
+
// check if we've hit a selector
|
|
9052
|
+
if (e.target.matches(singleMaidr.selector)) {
|
|
9053
|
+
outerLoop: for (let i = 0; i < plot.elements.length; i++) {
|
|
9054
|
+
for (let j = 0; j < plot.elements[i].length; j++) {
|
|
9055
|
+
if (plot.elements[i][j] == e.target) {
|
|
9056
|
+
if (position.x != i || position.y != j) {
|
|
9057
|
+
position.x = i;
|
|
9058
|
+
position.y = j;
|
|
9059
|
+
control.UpdateAll();
|
|
9060
|
+
}
|
|
9061
|
+
break outerLoop;
|
|
9062
|
+
}
|
|
9063
|
+
}
|
|
9064
|
+
}
|
|
9065
|
+
}
|
|
9066
|
+
}
|
|
9067
|
+
},
|
|
9068
|
+
]);
|
|
9069
|
+
}
|
|
9070
|
+
}
|
|
9071
|
+
}
|
|
9072
|
+
|
|
8871
9073
|
/**
|
|
8872
9074
|
* Sets up event listeners for main controls
|
|
8873
9075
|
* - Arrow keys: basic motion
|
|
@@ -8880,7 +9082,7 @@ class Control {
|
|
|
8880
9082
|
*
|
|
8881
9083
|
* @returns {void}
|
|
8882
9084
|
*/
|
|
8883
|
-
async
|
|
9085
|
+
async SetKeyControls() {
|
|
8884
9086
|
constants.events.push([
|
|
8885
9087
|
document,
|
|
8886
9088
|
'keydown',
|