app-devtools 0.14.0 → 0.17.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/main.js +118 -9
- package/package.json +2 -1
package/dist/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import { dequal } from 'dequal';
|
|
3
|
+
import { produce as produce$1 } from 'immer';
|
|
3
4
|
import { nanoid } from 'nanoid';
|
|
4
5
|
import { parse } from 'regexparam';
|
|
5
6
|
import * as diff from 'diff';
|
|
@@ -1445,7 +1446,7 @@ const colors = createThemeColors({
|
|
|
1445
1446
|
black: "#000"
|
|
1446
1447
|
});
|
|
1447
1448
|
const fonts = {
|
|
1448
|
-
primary: "Work Sans, sans-serif
|
|
1449
|
+
primary: '"Work Sans", sans-serif',
|
|
1449
1450
|
decorative: '"Fira Code", monospaced'
|
|
1450
1451
|
};
|
|
1451
1452
|
|
|
@@ -1481,8 +1482,11 @@ function createSignalRef(initialValue) {
|
|
|
1481
1482
|
set value(newValue) {
|
|
1482
1483
|
setValue(() => newValue);
|
|
1483
1484
|
},
|
|
1484
|
-
|
|
1485
|
-
setValue(() =>
|
|
1485
|
+
produce(recipe) {
|
|
1486
|
+
setValue((val) => produce$1(val, recipe));
|
|
1487
|
+
},
|
|
1488
|
+
peek() {
|
|
1489
|
+
return untrack(value);
|
|
1486
1490
|
}
|
|
1487
1491
|
};
|
|
1488
1492
|
}
|
|
@@ -1875,6 +1879,49 @@ function addCall(request) {
|
|
|
1875
1879
|
};
|
|
1876
1880
|
}
|
|
1877
1881
|
|
|
1882
|
+
const normalizeString = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
|
|
1883
|
+
|
|
1884
|
+
function searchQueryMatch(query, string) {
|
|
1885
|
+
const queryIndex = normalizeString(String(string)).indexOf(
|
|
1886
|
+
normalizeString(String(query))
|
|
1887
|
+
);
|
|
1888
|
+
return {
|
|
1889
|
+
matched: queryIndex !== -1,
|
|
1890
|
+
matchedIndex: queryIndex
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
function sortBy(arr, getPriority, { lowerFirst } = {}) {
|
|
1895
|
+
return [...arr].sort((a, b) => {
|
|
1896
|
+
const aPriority = getPriority(a);
|
|
1897
|
+
const bPriority = getPriority(b);
|
|
1898
|
+
if (aPriority < bPriority) {
|
|
1899
|
+
return lowerFirst ? -1 : 1;
|
|
1900
|
+
}
|
|
1901
|
+
if (aPriority > bPriority) {
|
|
1902
|
+
return lowerFirst ? 1 : -1;
|
|
1903
|
+
}
|
|
1904
|
+
return 0;
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
function searchItems({
|
|
1909
|
+
items,
|
|
1910
|
+
searchQuery,
|
|
1911
|
+
getStringToMatch
|
|
1912
|
+
}) {
|
|
1913
|
+
const searchedItems = [];
|
|
1914
|
+
for (const item of items) {
|
|
1915
|
+
const search = searchQueryMatch(searchQuery, getStringToMatch(item));
|
|
1916
|
+
if (search.matched) {
|
|
1917
|
+
searchedItems.push({ item, matchedIndex: search.matchedIndex });
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
return sortBy(searchedItems, (item) => item.matchedIndex, {
|
|
1921
|
+
lowerFirst: true
|
|
1922
|
+
}).map(({ item }) => item);
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1878
1925
|
const _tmpl$$8 = /*#__PURE__*/template(`<div><h1>API EXPLORER</h1><label><input type="text" placeholder="Search"></label><div></div></div>`);
|
|
1879
1926
|
const containerStyle$8 = u`
|
|
1880
1927
|
&&& {
|
|
@@ -1933,12 +1980,10 @@ const searchStyle = u`
|
|
|
1933
1980
|
const ApiExplorerMenu = () => {
|
|
1934
1981
|
const search = createSignalRef('');
|
|
1935
1982
|
const menuItems = createReconciledArray(() => {
|
|
1983
|
+
const [callSearch = '', requestSearch = ''] = search.value.split('>');
|
|
1936
1984
|
const callsEntries = Object.entries(callsStore.calls);
|
|
1937
1985
|
const filtered = [];
|
|
1938
1986
|
for (const [key, value] of callsEntries.reverse()) {
|
|
1939
|
-
if (search.value.trim() && !value.name.includes(search.value.toLowerCase())) {
|
|
1940
|
-
continue;
|
|
1941
|
-
}
|
|
1942
1987
|
const subitemsWithAlias = new Set();
|
|
1943
1988
|
for (const request of value.requests) {
|
|
1944
1989
|
if (request.alias) {
|
|
@@ -1947,11 +1992,26 @@ const ApiExplorerMenu = () => {
|
|
|
1947
1992
|
}
|
|
1948
1993
|
filtered.push({
|
|
1949
1994
|
id: key,
|
|
1950
|
-
subitemsWithAlias:
|
|
1995
|
+
subitemsWithAlias: searchItems({
|
|
1996
|
+
items: [...subitemsWithAlias],
|
|
1997
|
+
searchQuery: requestSearch.trim(),
|
|
1998
|
+
getStringToMatch(item) {
|
|
1999
|
+
return item;
|
|
2000
|
+
}
|
|
2001
|
+
}),
|
|
1951
2002
|
...value
|
|
1952
2003
|
});
|
|
1953
2004
|
}
|
|
1954
|
-
|
|
2005
|
+
const searchedItems = searchItems({
|
|
2006
|
+
items: filtered,
|
|
2007
|
+
searchQuery: callSearch.trim(),
|
|
2008
|
+
getStringToMatch(item) {
|
|
2009
|
+
return item.name;
|
|
2010
|
+
}
|
|
2011
|
+
});
|
|
2012
|
+
return sortBy(searchedItems, item => {
|
|
2013
|
+
return item.requests.at(-1)?.startTime || 0;
|
|
2014
|
+
});
|
|
1955
2015
|
}, 'id');
|
|
1956
2016
|
const _currentCallId = createMemo(() => uiStore.selectedCall);
|
|
1957
2017
|
return (() => {
|
|
@@ -3472,9 +3532,58 @@ const Root = () => {
|
|
|
3472
3532
|
return createComponent(App, {});
|
|
3473
3533
|
};
|
|
3474
3534
|
|
|
3535
|
+
function getGoogleFontsImportUrl(fonts) {
|
|
3536
|
+
let url = "";
|
|
3537
|
+
fonts.forEach(({ family, weights, italics }) => {
|
|
3538
|
+
url += `${url ? "&" : ""}family=${family}:`;
|
|
3539
|
+
if (weights[1] === "..") {
|
|
3540
|
+
url += `wght@${weights[0]}..${weights[2]}`;
|
|
3541
|
+
} else {
|
|
3542
|
+
url += "ital,wght@";
|
|
3543
|
+
weights.forEach((value, i) => {
|
|
3544
|
+
if (i !== 0) {
|
|
3545
|
+
url += ";";
|
|
3546
|
+
}
|
|
3547
|
+
url += `0,${value}`;
|
|
3548
|
+
});
|
|
3549
|
+
italics?.forEach((value) => {
|
|
3550
|
+
url += `;1,${value}`;
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
});
|
|
3554
|
+
return `https://fonts.googleapis.com/css2?${url}&display=swap`;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
let fontsWereAdded = false;
|
|
3558
|
+
function addGoogleFonts() {
|
|
3559
|
+
if (fontsWereAdded)
|
|
3560
|
+
return;
|
|
3561
|
+
fontsWereAdded = true;
|
|
3562
|
+
const googleFonts = getGoogleFontsImportUrl([
|
|
3563
|
+
{
|
|
3564
|
+
family: "Work+Sans",
|
|
3565
|
+
weights: [300, "..", 700]
|
|
3566
|
+
}
|
|
3567
|
+
]);
|
|
3568
|
+
const headID = document.getElementsByTagName("head")[0];
|
|
3569
|
+
const link = document.createElement("link");
|
|
3570
|
+
link.type = "text/css";
|
|
3571
|
+
link.rel = "stylesheet";
|
|
3572
|
+
link.href = googleFonts;
|
|
3573
|
+
headID?.appendChild(link);
|
|
3574
|
+
}
|
|
3575
|
+
|
|
3475
3576
|
let unmount = () => {};
|
|
3577
|
+
let isInitialized = false;
|
|
3476
3578
|
function initializeApp() {
|
|
3477
3579
|
dayjs.extend(relativeTime);
|
|
3580
|
+
if (isInitialized) {
|
|
3581
|
+
unmountApp();
|
|
3582
|
+
isInitialized = false;
|
|
3583
|
+
return;
|
|
3584
|
+
}
|
|
3585
|
+
isInitialized = true;
|
|
3586
|
+
addGoogleFonts();
|
|
3478
3587
|
if (navigator.platform.indexOf('Win') > -1) {
|
|
3479
3588
|
document.body.classList.add('windows');
|
|
3480
3589
|
}
|
|
@@ -3493,11 +3602,11 @@ function initializeDevTools({
|
|
|
3493
3602
|
}) {
|
|
3494
3603
|
tinykeys(window, {
|
|
3495
3604
|
[shortcut]: (e) => {
|
|
3496
|
-
e.preventDefault();
|
|
3497
3605
|
const active = document.activeElement;
|
|
3498
3606
|
const enteringText = active instanceof HTMLElement && (active.isContentEditable || active.tagName === "INPUT" || active.tagName === "TEXTAREA");
|
|
3499
3607
|
if (enteringText)
|
|
3500
3608
|
return;
|
|
3609
|
+
e.preventDefault();
|
|
3501
3610
|
initializeApp();
|
|
3502
3611
|
}
|
|
3503
3612
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"packageManager": "pnpm@6.29.1",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"dayjs": "^1.11.7",
|
|
25
25
|
"dequal": "^2.0.3",
|
|
26
26
|
"diff": "^5.1.0",
|
|
27
|
+
"immer": "^9.0.19",
|
|
27
28
|
"klona": "^2.0.6",
|
|
28
29
|
"nanoid": "^4.0.1",
|
|
29
30
|
"regexparam": "^2.0.1",
|