allotaxonometer-ui 0.1.6 → 0.1.7
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/index.js +3 -279
- package/dist/ssr/index.js +3 -4
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1679,282 +1679,6 @@ function rank_turbulence_divergence(mixedelements, alpha) {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
1681
|
|
|
1682
|
-
const VOID = -1;
|
|
1683
|
-
const PRIMITIVE = 0;
|
|
1684
|
-
const ARRAY = 1;
|
|
1685
|
-
const OBJECT = 2;
|
|
1686
|
-
const DATE = 3;
|
|
1687
|
-
const REGEXP = 4;
|
|
1688
|
-
const MAP = 5;
|
|
1689
|
-
const SET = 6;
|
|
1690
|
-
const ERROR = 7;
|
|
1691
|
-
const BIGINT = 8;
|
|
1692
|
-
// export const SYMBOL = 9;
|
|
1693
|
-
|
|
1694
|
-
const env = typeof self === 'object' ? self : globalThis;
|
|
1695
|
-
|
|
1696
|
-
const deserializer = ($, _) => {
|
|
1697
|
-
const as = (out, index) => {
|
|
1698
|
-
$.set(index, out);
|
|
1699
|
-
return out;
|
|
1700
|
-
};
|
|
1701
|
-
|
|
1702
|
-
const unpair = index => {
|
|
1703
|
-
if ($.has(index))
|
|
1704
|
-
return $.get(index);
|
|
1705
|
-
|
|
1706
|
-
const [type, value] = _[index];
|
|
1707
|
-
switch (type) {
|
|
1708
|
-
case PRIMITIVE:
|
|
1709
|
-
case VOID:
|
|
1710
|
-
return as(value, index);
|
|
1711
|
-
case ARRAY: {
|
|
1712
|
-
const arr = as([], index);
|
|
1713
|
-
for (const index of value)
|
|
1714
|
-
arr.push(unpair(index));
|
|
1715
|
-
return arr;
|
|
1716
|
-
}
|
|
1717
|
-
case OBJECT: {
|
|
1718
|
-
const object = as({}, index);
|
|
1719
|
-
for (const [key, index] of value)
|
|
1720
|
-
object[unpair(key)] = unpair(index);
|
|
1721
|
-
return object;
|
|
1722
|
-
}
|
|
1723
|
-
case DATE:
|
|
1724
|
-
return as(new Date(value), index);
|
|
1725
|
-
case REGEXP: {
|
|
1726
|
-
const {source, flags} = value;
|
|
1727
|
-
return as(new RegExp(source, flags), index);
|
|
1728
|
-
}
|
|
1729
|
-
case MAP: {
|
|
1730
|
-
const map = as(new Map, index);
|
|
1731
|
-
for (const [key, index] of value)
|
|
1732
|
-
map.set(unpair(key), unpair(index));
|
|
1733
|
-
return map;
|
|
1734
|
-
}
|
|
1735
|
-
case SET: {
|
|
1736
|
-
const set = as(new Set, index);
|
|
1737
|
-
for (const index of value)
|
|
1738
|
-
set.add(unpair(index));
|
|
1739
|
-
return set;
|
|
1740
|
-
}
|
|
1741
|
-
case ERROR: {
|
|
1742
|
-
const {name, message} = value;
|
|
1743
|
-
return as(new env[name](message), index);
|
|
1744
|
-
}
|
|
1745
|
-
case BIGINT:
|
|
1746
|
-
return as(BigInt(value), index);
|
|
1747
|
-
case 'BigInt':
|
|
1748
|
-
return as(Object(BigInt(value)), index);
|
|
1749
|
-
case 'ArrayBuffer':
|
|
1750
|
-
return as(new Uint8Array(value).buffer, value);
|
|
1751
|
-
case 'DataView': {
|
|
1752
|
-
const { buffer } = new Uint8Array(value);
|
|
1753
|
-
return as(new DataView(buffer), value);
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
return as(new env[type](value), index);
|
|
1757
|
-
};
|
|
1758
|
-
|
|
1759
|
-
return unpair;
|
|
1760
|
-
};
|
|
1761
|
-
|
|
1762
|
-
/**
|
|
1763
|
-
* @typedef {Array<string,any>} Record a type representation
|
|
1764
|
-
*/
|
|
1765
|
-
|
|
1766
|
-
/**
|
|
1767
|
-
* Returns a deserialized value from a serialized array of Records.
|
|
1768
|
-
* @param {Record[]} serialized a previously serialized value.
|
|
1769
|
-
* @returns {any}
|
|
1770
|
-
*/
|
|
1771
|
-
const deserialize = serialized => deserializer(new Map, serialized)(0);
|
|
1772
|
-
|
|
1773
|
-
const EMPTY = '';
|
|
1774
|
-
|
|
1775
|
-
const {toString} = {};
|
|
1776
|
-
const {keys} = Object;
|
|
1777
|
-
|
|
1778
|
-
const typeOf = value => {
|
|
1779
|
-
const type = typeof value;
|
|
1780
|
-
if (type !== 'object' || !value)
|
|
1781
|
-
return [PRIMITIVE, type];
|
|
1782
|
-
|
|
1783
|
-
const asString = toString.call(value).slice(8, -1);
|
|
1784
|
-
switch (asString) {
|
|
1785
|
-
case 'Array':
|
|
1786
|
-
return [ARRAY, EMPTY];
|
|
1787
|
-
case 'Object':
|
|
1788
|
-
return [OBJECT, EMPTY];
|
|
1789
|
-
case 'Date':
|
|
1790
|
-
return [DATE, EMPTY];
|
|
1791
|
-
case 'RegExp':
|
|
1792
|
-
return [REGEXP, EMPTY];
|
|
1793
|
-
case 'Map':
|
|
1794
|
-
return [MAP, EMPTY];
|
|
1795
|
-
case 'Set':
|
|
1796
|
-
return [SET, EMPTY];
|
|
1797
|
-
case 'DataView':
|
|
1798
|
-
return [ARRAY, asString];
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
if (asString.includes('Array'))
|
|
1802
|
-
return [ARRAY, asString];
|
|
1803
|
-
|
|
1804
|
-
if (asString.includes('Error'))
|
|
1805
|
-
return [ERROR, asString];
|
|
1806
|
-
|
|
1807
|
-
return [OBJECT, asString];
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
const shouldSkip = ([TYPE, type]) => (
|
|
1811
|
-
TYPE === PRIMITIVE &&
|
|
1812
|
-
(type === 'function' || type === 'symbol')
|
|
1813
|
-
);
|
|
1814
|
-
|
|
1815
|
-
const serializer = (strict, json, $, _) => {
|
|
1816
|
-
|
|
1817
|
-
const as = (out, value) => {
|
|
1818
|
-
const index = _.push(out) - 1;
|
|
1819
|
-
$.set(value, index);
|
|
1820
|
-
return index;
|
|
1821
|
-
};
|
|
1822
|
-
|
|
1823
|
-
const pair = value => {
|
|
1824
|
-
if ($.has(value))
|
|
1825
|
-
return $.get(value);
|
|
1826
|
-
|
|
1827
|
-
let [TYPE, type] = typeOf(value);
|
|
1828
|
-
switch (TYPE) {
|
|
1829
|
-
case PRIMITIVE: {
|
|
1830
|
-
let entry = value;
|
|
1831
|
-
switch (type) {
|
|
1832
|
-
case 'bigint':
|
|
1833
|
-
TYPE = BIGINT;
|
|
1834
|
-
entry = value.toString();
|
|
1835
|
-
break;
|
|
1836
|
-
case 'function':
|
|
1837
|
-
case 'symbol':
|
|
1838
|
-
if (strict)
|
|
1839
|
-
throw new TypeError('unable to serialize ' + type);
|
|
1840
|
-
entry = null;
|
|
1841
|
-
break;
|
|
1842
|
-
case 'undefined':
|
|
1843
|
-
return as([VOID], value);
|
|
1844
|
-
}
|
|
1845
|
-
return as([TYPE, entry], value);
|
|
1846
|
-
}
|
|
1847
|
-
case ARRAY: {
|
|
1848
|
-
if (type) {
|
|
1849
|
-
let spread = value;
|
|
1850
|
-
if (type === 'DataView') {
|
|
1851
|
-
spread = new Uint8Array(value.buffer);
|
|
1852
|
-
}
|
|
1853
|
-
else if (type === 'ArrayBuffer') {
|
|
1854
|
-
spread = new Uint8Array(value);
|
|
1855
|
-
}
|
|
1856
|
-
return as([type, [...spread]], value);
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
const arr = [];
|
|
1860
|
-
const index = as([TYPE, arr], value);
|
|
1861
|
-
for (const entry of value)
|
|
1862
|
-
arr.push(pair(entry));
|
|
1863
|
-
return index;
|
|
1864
|
-
}
|
|
1865
|
-
case OBJECT: {
|
|
1866
|
-
if (type) {
|
|
1867
|
-
switch (type) {
|
|
1868
|
-
case 'BigInt':
|
|
1869
|
-
return as([type, value.toString()], value);
|
|
1870
|
-
case 'Boolean':
|
|
1871
|
-
case 'Number':
|
|
1872
|
-
case 'String':
|
|
1873
|
-
return as([type, value.valueOf()], value);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
if (json && ('toJSON' in value))
|
|
1878
|
-
return pair(value.toJSON());
|
|
1879
|
-
|
|
1880
|
-
const entries = [];
|
|
1881
|
-
const index = as([TYPE, entries], value);
|
|
1882
|
-
for (const key of keys(value)) {
|
|
1883
|
-
if (strict || !shouldSkip(typeOf(value[key])))
|
|
1884
|
-
entries.push([pair(key), pair(value[key])]);
|
|
1885
|
-
}
|
|
1886
|
-
return index;
|
|
1887
|
-
}
|
|
1888
|
-
case DATE:
|
|
1889
|
-
return as([TYPE, value.toISOString()], value);
|
|
1890
|
-
case REGEXP: {
|
|
1891
|
-
const {source, flags} = value;
|
|
1892
|
-
return as([TYPE, {source, flags}], value);
|
|
1893
|
-
}
|
|
1894
|
-
case MAP: {
|
|
1895
|
-
const entries = [];
|
|
1896
|
-
const index = as([TYPE, entries], value);
|
|
1897
|
-
for (const [key, entry] of value) {
|
|
1898
|
-
if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
|
|
1899
|
-
entries.push([pair(key), pair(entry)]);
|
|
1900
|
-
}
|
|
1901
|
-
return index;
|
|
1902
|
-
}
|
|
1903
|
-
case SET: {
|
|
1904
|
-
const entries = [];
|
|
1905
|
-
const index = as([TYPE, entries], value);
|
|
1906
|
-
for (const entry of value) {
|
|
1907
|
-
if (strict || !shouldSkip(typeOf(entry)))
|
|
1908
|
-
entries.push(pair(entry));
|
|
1909
|
-
}
|
|
1910
|
-
return index;
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
const {message} = value;
|
|
1915
|
-
return as([TYPE, {name: type, message}], value);
|
|
1916
|
-
};
|
|
1917
|
-
|
|
1918
|
-
return pair;
|
|
1919
|
-
};
|
|
1920
|
-
|
|
1921
|
-
/**
|
|
1922
|
-
* @typedef {Array<string,any>} Record a type representation
|
|
1923
|
-
*/
|
|
1924
|
-
|
|
1925
|
-
/**
|
|
1926
|
-
* Returns an array of serialized Records.
|
|
1927
|
-
* @param {any} value a serializable value.
|
|
1928
|
-
* @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that,
|
|
1929
|
-
* if `true`, will not throw errors on incompatible types, and behave more
|
|
1930
|
-
* like JSON stringify would behave. Symbol and Function will be discarded.
|
|
1931
|
-
* @returns {Record[]}
|
|
1932
|
-
*/
|
|
1933
|
-
const serialize = (value, {json, lossy} = {}) => {
|
|
1934
|
-
const _ = [];
|
|
1935
|
-
return serializer(!(json || lossy), !!json, new Map, _)(value), _;
|
|
1936
|
-
};
|
|
1937
|
-
|
|
1938
|
-
/**
|
|
1939
|
-
* @typedef {Array<string,any>} Record a type representation
|
|
1940
|
-
*/
|
|
1941
|
-
|
|
1942
|
-
/**
|
|
1943
|
-
* Returns an array of serialized Records.
|
|
1944
|
-
* @param {any} any a serializable value.
|
|
1945
|
-
* @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with
|
|
1946
|
-
* a transfer option (ignored when polyfilled) and/or non standard fields that
|
|
1947
|
-
* fallback to the polyfill if present.
|
|
1948
|
-
* @returns {Record[]}
|
|
1949
|
-
*/
|
|
1950
|
-
const structuredClone$1 = typeof structuredClone === "function" ?
|
|
1951
|
-
/* c8 ignore start */
|
|
1952
|
-
(any, options) => (
|
|
1953
|
-
options && ('json' in options || 'lossy' in options) ?
|
|
1954
|
-
deserialize(serialize(any, options)) : structuredClone(any)
|
|
1955
|
-
) :
|
|
1956
|
-
(any, options) => deserialize(serialize(any, options));
|
|
1957
|
-
|
|
1958
1682
|
function rank2coord(rank) { return Math.floor(Math.log10(rank) / (1/15)) }
|
|
1959
1683
|
|
|
1960
1684
|
// Augment information already in `me` class with coordinates.
|
|
@@ -2048,11 +1772,11 @@ function diamond_count(mixedelements, wordshift) {
|
|
|
2048
1772
|
mixedelements[1]['ranks'] = indices_deltas.map(i => mixedelements[1]['ranks'][i]);
|
|
2049
1773
|
mixedelements[1]['probs'] = indices_deltas.map(i => mixedelements[1]['probs'][i]);
|
|
2050
1774
|
|
|
2051
|
-
const deltas_loss =
|
|
2052
|
-
|
|
1775
|
+
const deltas_loss = [...deltas];
|
|
1776
|
+
[...deltas];
|
|
2053
1777
|
|
|
2054
1778
|
which(mixedelements[0]['ranks'].map((d,i) => mixedelements[0]['ranks'][i] > mixedelements[1]['ranks'][i])).map(e => deltas_loss[e] = -1);
|
|
2055
|
-
which(mixedelements[0]['ranks'].map((d,i) => mixedelements[1]['ranks'][i] < mixedelements[1]['ranks'][i])).map(e =>
|
|
1779
|
+
which(mixedelements[0]['ranks'].map((d,i) => mixedelements[1]['ranks'][i] < mixedelements[1]['ranks'][i])).map(e => -1);
|
|
2056
1780
|
|
|
2057
1781
|
|
|
2058
1782
|
const counts = diamond_counts(mixedelements);
|
package/dist/ssr/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as $ from "svelte/internal/server";
|
|
|
2
2
|
import * as d3 from "d3";
|
|
3
3
|
import { map, extent, InternSet, range, rollup, scaleLinear, scaleBand, rgb, interpolateInferno, scaleOrdinal } from "d3";
|
|
4
4
|
import { descending, sum, group, extent as extent$1 } from "d3-array";
|
|
5
|
-
import structuredClone from "@ungap/structured-clone";
|
|
6
5
|
function rgbArrayToCss(rgbArray) {
|
|
7
6
|
const [r, g, b] = rgbArray.map((v) => Math.round(v * 255));
|
|
8
7
|
return `rgb(${r}, ${g}, ${b})`;
|
|
@@ -773,10 +772,10 @@ function diamond_count(mixedelements, wordshift) {
|
|
|
773
772
|
mixedelements[1]["counts"] = indices_deltas.map((i) => mixedelements[1]["counts"][i]);
|
|
774
773
|
mixedelements[1]["ranks"] = indices_deltas.map((i) => mixedelements[1]["ranks"][i]);
|
|
775
774
|
mixedelements[1]["probs"] = indices_deltas.map((i) => mixedelements[1]["probs"][i]);
|
|
776
|
-
const deltas_loss =
|
|
777
|
-
|
|
775
|
+
const deltas_loss = [...deltas];
|
|
776
|
+
[...deltas];
|
|
778
777
|
which(mixedelements[0]["ranks"].map((d, i) => mixedelements[0]["ranks"][i] > mixedelements[1]["ranks"][i])).map((e) => deltas_loss[e] = -1);
|
|
779
|
-
which(mixedelements[0]["ranks"].map((d, i) => mixedelements[1]["ranks"][i] < mixedelements[1]["ranks"][i])).map((e) =>
|
|
778
|
+
which(mixedelements[0]["ranks"].map((d, i) => mixedelements[1]["ranks"][i] < mixedelements[1]["ranks"][i])).map((e) => -1);
|
|
780
779
|
const counts = diamond_counts(mixedelements);
|
|
781
780
|
return { "counts": counts, "deltas": deltas, "max_delta_loss": Math.max(...deltas_loss) };
|
|
782
781
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "allotaxonometer-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Headless UI components for allotaxonometer visualizations built with Svelte 5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,8 +37,7 @@
|
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/Vermont-Complex-Systems/allotaxonometer-ui/issues"
|
|
39
39
|
},
|
|
40
|
-
"
|
|
41
|
-
"@ungap/structured-clone": "1.3.0",
|
|
40
|
+
"dependencies": {
|
|
42
41
|
"d3": "^7.0.0",
|
|
43
42
|
"svelte": "^5.0.0"
|
|
44
43
|
},
|