dopaminejs 3.3.0 → 3.5.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/{DataService-Bd1S-C1N.js → DataService-QQBNqJtN.js} +324 -151
- package/dist/DataService-Xk7egYXe.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -2
- package/dist/dopamine.cjs +1 -1
- package/dist/dopamine.global.js +37 -0
- package/dist/dopamine.js +3 -3
- package/dist/games.js +1 -2
- package/dist/{host-Bm0Kq5Th.cjs → host-1c7QSAKI.cjs} +2 -2
- package/dist/{host-CSnyl6nv.js → host-_essSMef.js} +15 -18
- package/dist/testing.cjs +1 -1
- package/dist/testing.js +13 -13
- package/package.json +4 -2
- package/spec/README.md +114 -14
- package/spec/fixtures/merge.json +384 -0
- package/spec/fixtures/migrate.json +388 -22
- package/spec/fixtures/recovery.json +1861 -0
- package/spec/schema.json +3 -3
- package/src/dopamine/core/RewardSystem.js +187 -24
- package/src/dopamine/core/merge.js +116 -1
- package/src/dopamine/core/store.js +90 -32
- package/src/dopamine/host.js +3 -1
- package/src/testing.js +2 -1
- package/types/index.d.ts +25 -4
- package/dist/DataService-GRTvq4BS.cjs +0 -1
package/spec/fixtures/merge.json
CHANGED
|
@@ -1734,6 +1734,390 @@
|
|
|
1734
1734
|
}
|
|
1735
1735
|
}
|
|
1736
1736
|
]
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
"name": "a negative sum is dropped on validate",
|
|
1740
|
+
"clock": "2026-08-07T09:00:00",
|
|
1741
|
+
"device": "me",
|
|
1742
|
+
"note": "Sums only grow, like the other counters. A negative sum is invalid and dropped, so two huge negatives cannot add to a value that is not a finite number.",
|
|
1743
|
+
"steps": [
|
|
1744
|
+
{
|
|
1745
|
+
"op": "validate",
|
|
1746
|
+
"doc": {
|
|
1747
|
+
"v": 3,
|
|
1748
|
+
"sumsBy": {
|
|
1749
|
+
"g": {
|
|
1750
|
+
"kills": {
|
|
1751
|
+
"a": 5,
|
|
1752
|
+
"b": -1
|
|
1753
|
+
},
|
|
1754
|
+
"time": {
|
|
1755
|
+
"a": -1e+308,
|
|
1756
|
+
"b": -1e+308
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
},
|
|
1761
|
+
"as": "v",
|
|
1762
|
+
"expect": {
|
|
1763
|
+
"returnsExact": {
|
|
1764
|
+
"sumsBy": {
|
|
1765
|
+
"g": {
|
|
1766
|
+
"kills": {
|
|
1767
|
+
"a": 5
|
|
1768
|
+
},
|
|
1769
|
+
"time": {}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
]
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
"name": "the string 0x10 is not a number",
|
|
1779
|
+
"clock": "2026-08-07T09:00:00",
|
|
1780
|
+
"device": "me",
|
|
1781
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1782
|
+
"steps": [
|
|
1783
|
+
{
|
|
1784
|
+
"op": "validate",
|
|
1785
|
+
"doc": {
|
|
1786
|
+
"v": 3,
|
|
1787
|
+
"level": "0x10"
|
|
1788
|
+
},
|
|
1789
|
+
"as": "v",
|
|
1790
|
+
"expect": {
|
|
1791
|
+
"returnsExact": {
|
|
1792
|
+
"level": 1
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
]
|
|
1797
|
+
},
|
|
1798
|
+
{
|
|
1799
|
+
"name": "the string 0b11 is not a number",
|
|
1800
|
+
"clock": "2026-08-07T09:00:00",
|
|
1801
|
+
"device": "me",
|
|
1802
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1803
|
+
"steps": [
|
|
1804
|
+
{
|
|
1805
|
+
"op": "validate",
|
|
1806
|
+
"doc": {
|
|
1807
|
+
"v": 3,
|
|
1808
|
+
"level": "0b11"
|
|
1809
|
+
},
|
|
1810
|
+
"as": "v",
|
|
1811
|
+
"expect": {
|
|
1812
|
+
"returnsExact": {
|
|
1813
|
+
"level": 1
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
]
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
"name": "the string 0o7 is not a number",
|
|
1821
|
+
"clock": "2026-08-07T09:00:00",
|
|
1822
|
+
"device": "me",
|
|
1823
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1824
|
+
"steps": [
|
|
1825
|
+
{
|
|
1826
|
+
"op": "validate",
|
|
1827
|
+
"doc": {
|
|
1828
|
+
"v": 3,
|
|
1829
|
+
"level": "0o7"
|
|
1830
|
+
},
|
|
1831
|
+
"as": "v",
|
|
1832
|
+
"expect": {
|
|
1833
|
+
"returnsExact": {
|
|
1834
|
+
"level": 1
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
]
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
"name": "the string 1e3 is not a number",
|
|
1842
|
+
"clock": "2026-08-07T09:00:00",
|
|
1843
|
+
"device": "me",
|
|
1844
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1845
|
+
"steps": [
|
|
1846
|
+
{
|
|
1847
|
+
"op": "validate",
|
|
1848
|
+
"doc": {
|
|
1849
|
+
"v": 3,
|
|
1850
|
+
"level": "1e3"
|
|
1851
|
+
},
|
|
1852
|
+
"as": "v",
|
|
1853
|
+
"expect": {
|
|
1854
|
+
"returnsExact": {
|
|
1855
|
+
"level": 1
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
]
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
"name": "the string +5 is not a number",
|
|
1863
|
+
"clock": "2026-08-07T09:00:00",
|
|
1864
|
+
"device": "me",
|
|
1865
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1866
|
+
"steps": [
|
|
1867
|
+
{
|
|
1868
|
+
"op": "validate",
|
|
1869
|
+
"doc": {
|
|
1870
|
+
"v": 3,
|
|
1871
|
+
"level": "+5"
|
|
1872
|
+
},
|
|
1873
|
+
"as": "v",
|
|
1874
|
+
"expect": {
|
|
1875
|
+
"returnsExact": {
|
|
1876
|
+
"level": 1
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
]
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
"name": "the string 5. is not a number",
|
|
1884
|
+
"clock": "2026-08-07T09:00:00",
|
|
1885
|
+
"device": "me",
|
|
1886
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1887
|
+
"steps": [
|
|
1888
|
+
{
|
|
1889
|
+
"op": "validate",
|
|
1890
|
+
"doc": {
|
|
1891
|
+
"v": 3,
|
|
1892
|
+
"level": "5."
|
|
1893
|
+
},
|
|
1894
|
+
"as": "v",
|
|
1895
|
+
"expect": {
|
|
1896
|
+
"returnsExact": {
|
|
1897
|
+
"level": 1
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
]
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
"name": "the string 1e21 is not a number",
|
|
1905
|
+
"clock": "2026-08-07T09:00:00",
|
|
1906
|
+
"device": "me",
|
|
1907
|
+
"note": "Only plain decimal strings are read. Hex, binary, octal, exponent, a sign of + and a trailing dot fall back to the default.",
|
|
1908
|
+
"steps": [
|
|
1909
|
+
{
|
|
1910
|
+
"op": "validate",
|
|
1911
|
+
"doc": {
|
|
1912
|
+
"v": 3,
|
|
1913
|
+
"level": "1e21"
|
|
1914
|
+
},
|
|
1915
|
+
"as": "v",
|
|
1916
|
+
"expect": {
|
|
1917
|
+
"returnsExact": {
|
|
1918
|
+
"level": 1
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
]
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
"name": "plain decimal strings are read",
|
|
1926
|
+
"clock": "2026-08-07T09:00:00",
|
|
1927
|
+
"device": "me",
|
|
1928
|
+
"note": "Whitespace around a plain decimal is fine. A negative amount is dropped as before.",
|
|
1929
|
+
"steps": [
|
|
1930
|
+
{
|
|
1931
|
+
"op": "validate",
|
|
1932
|
+
"doc": {
|
|
1933
|
+
"v": 3,
|
|
1934
|
+
"level": " 12 ",
|
|
1935
|
+
"xpBy": {
|
|
1936
|
+
"a": "1.5",
|
|
1937
|
+
"b": "-3"
|
|
1938
|
+
}
|
|
1939
|
+
},
|
|
1940
|
+
"as": "v",
|
|
1941
|
+
"expect": {
|
|
1942
|
+
"returnsExact": {
|
|
1943
|
+
"level": 12,
|
|
1944
|
+
"xpBy": {
|
|
1945
|
+
"a": 1.5
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
]
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
"name": "an unknown field on one side is kept",
|
|
1954
|
+
"clock": "2026-08-07T09:00:00",
|
|
1955
|
+
"device": "me",
|
|
1956
|
+
"note": "No rule joins a field the core does not know, so a field on one side stays.",
|
|
1957
|
+
"steps": [
|
|
1958
|
+
{
|
|
1959
|
+
"op": "merge",
|
|
1960
|
+
"a": {
|
|
1961
|
+
"v": 3,
|
|
1962
|
+
"theme": "dark"
|
|
1963
|
+
},
|
|
1964
|
+
"b": {
|
|
1965
|
+
"v": 3
|
|
1966
|
+
},
|
|
1967
|
+
"as": "m",
|
|
1968
|
+
"expect": {
|
|
1969
|
+
"returns": {
|
|
1970
|
+
"theme": "dark"
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
{
|
|
1975
|
+
"op": "merge",
|
|
1976
|
+
"a": {
|
|
1977
|
+
"v": 3
|
|
1978
|
+
},
|
|
1979
|
+
"b": {
|
|
1980
|
+
"v": 3,
|
|
1981
|
+
"theme": "dark"
|
|
1982
|
+
},
|
|
1983
|
+
"as": "n",
|
|
1984
|
+
"expect": {
|
|
1985
|
+
"returns": {
|
|
1986
|
+
"theme": "dark"
|
|
1987
|
+
},
|
|
1988
|
+
"same": [
|
|
1989
|
+
[
|
|
1990
|
+
"m",
|
|
1991
|
+
"n"
|
|
1992
|
+
]
|
|
1993
|
+
]
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
]
|
|
1997
|
+
},
|
|
1998
|
+
{
|
|
1999
|
+
"name": "unknown numbers join by value",
|
|
2000
|
+
"clock": "2026-08-07T09:00:00",
|
|
2001
|
+
"device": "me",
|
|
2002
|
+
"note": "99 against 100 gives 100, not the larger text. The order of the sides does not matter.",
|
|
2003
|
+
"steps": [
|
|
2004
|
+
{
|
|
2005
|
+
"op": "merge",
|
|
2006
|
+
"a": {
|
|
2007
|
+
"v": 3,
|
|
2008
|
+
"coins": 99
|
|
2009
|
+
},
|
|
2010
|
+
"b": {
|
|
2011
|
+
"v": 3,
|
|
2012
|
+
"coins": 100
|
|
2013
|
+
},
|
|
2014
|
+
"as": "ab",
|
|
2015
|
+
"expect": {
|
|
2016
|
+
"returns": {
|
|
2017
|
+
"coins": 100
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
"op": "merge",
|
|
2023
|
+
"a": {
|
|
2024
|
+
"v": 3,
|
|
2025
|
+
"coins": 100
|
|
2026
|
+
},
|
|
2027
|
+
"b": {
|
|
2028
|
+
"v": 3,
|
|
2029
|
+
"coins": 99
|
|
2030
|
+
},
|
|
2031
|
+
"as": "ba",
|
|
2032
|
+
"expect": {
|
|
2033
|
+
"returns": {
|
|
2034
|
+
"coins": 100
|
|
2035
|
+
},
|
|
2036
|
+
"same": [
|
|
2037
|
+
[
|
|
2038
|
+
"ab",
|
|
2039
|
+
"ba"
|
|
2040
|
+
]
|
|
2041
|
+
]
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
]
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
"name": "unknown strings and objects join by larger text, newer save does not win",
|
|
2048
|
+
"clock": "2026-08-07T09:00:00",
|
|
2049
|
+
"device": "me",
|
|
2050
|
+
"note": "No field has its own time, so recency is not used. The larger canonical JSON text wins whichever side is newer, and the order of the sides does not matter.",
|
|
2051
|
+
"steps": [
|
|
2052
|
+
{
|
|
2053
|
+
"op": "merge",
|
|
2054
|
+
"a": {
|
|
2055
|
+
"v": 3,
|
|
2056
|
+
"lastPlayedAt": 2,
|
|
2057
|
+
"theme": "dark",
|
|
2058
|
+
"opts": {
|
|
2059
|
+
"b": 1,
|
|
2060
|
+
"a": 2
|
|
2061
|
+
}
|
|
2062
|
+
},
|
|
2063
|
+
"b": {
|
|
2064
|
+
"v": 3,
|
|
2065
|
+
"lastPlayedAt": 1,
|
|
2066
|
+
"theme": "light",
|
|
2067
|
+
"opts": {
|
|
2068
|
+
"a": 2,
|
|
2069
|
+
"b": 3
|
|
2070
|
+
}
|
|
2071
|
+
},
|
|
2072
|
+
"as": "ab",
|
|
2073
|
+
"expect": {
|
|
2074
|
+
"returns": {
|
|
2075
|
+
"theme": "light",
|
|
2076
|
+
"opts": {
|
|
2077
|
+
"a": 2,
|
|
2078
|
+
"b": 3
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
"op": "merge",
|
|
2085
|
+
"a": {
|
|
2086
|
+
"v": 3,
|
|
2087
|
+
"lastPlayedAt": 1,
|
|
2088
|
+
"theme": "light",
|
|
2089
|
+
"opts": {
|
|
2090
|
+
"a": 2,
|
|
2091
|
+
"b": 3
|
|
2092
|
+
}
|
|
2093
|
+
},
|
|
2094
|
+
"b": {
|
|
2095
|
+
"v": 3,
|
|
2096
|
+
"lastPlayedAt": 2,
|
|
2097
|
+
"theme": "dark",
|
|
2098
|
+
"opts": {
|
|
2099
|
+
"b": 1,
|
|
2100
|
+
"a": 2
|
|
2101
|
+
}
|
|
2102
|
+
},
|
|
2103
|
+
"as": "ba",
|
|
2104
|
+
"expect": {
|
|
2105
|
+
"returns": {
|
|
2106
|
+
"theme": "light",
|
|
2107
|
+
"opts": {
|
|
2108
|
+
"a": 2,
|
|
2109
|
+
"b": 3
|
|
2110
|
+
}
|
|
2111
|
+
},
|
|
2112
|
+
"same": [
|
|
2113
|
+
[
|
|
2114
|
+
"ab",
|
|
2115
|
+
"ba"
|
|
2116
|
+
]
|
|
2117
|
+
]
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
]
|
|
1737
2121
|
}
|
|
1738
2122
|
]
|
|
1739
2123
|
}
|