@legendapp/state 2.2.0-next.91 → 2.2.0-next.93
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/babel.js +28 -14
- package/babel.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +75 -28
- package/index.js.map +1 -1
- package/index.mjs +74 -29
- package/index.mjs.map +1 -1
- package/package.json +11 -6
- package/react.js +7 -4
- package/react.js.map +1 -1
- package/react.mjs +8 -5
- package/react.mjs.map +1 -1
- package/src/ObservableObject.ts +63 -28
- package/src/babel/index.ts +36 -23
- package/src/createObservable.ts +1 -0
- package/src/globals.ts +1 -0
- package/src/linked.ts +4 -1
- package/src/observableInterfaces.ts +3 -1
- package/src/onChange.ts +11 -1
- package/src/react/Computed.tsx +2 -1
- package/src/react/usePauseProvider.tsx +7 -4
- package/src/react/useSelector.ts +2 -2
- package/src/sync/syncObservable.ts +20 -4
- package/src/sync/syncTypes.ts +1 -1
- package/src/sync-plugins/crud.ts +54 -45
- package/src/sync-plugins/fetch.ts +14 -5
- package/src/sync-plugins/keel.ts +45 -30
- package/src/sync-plugins/supabase.ts +31 -34
- package/src/sync-plugins/tanstack-query.ts +113 -0
- package/src/sync-plugins/tanstack-react-query.ts +12 -0
- package/sync-plugins/crud.d.ts +7 -7
- package/sync-plugins/crud.js +41 -33
- package/sync-plugins/crud.js.map +1 -1
- package/sync-plugins/crud.mjs +43 -35
- package/sync-plugins/crud.mjs.map +1 -1
- package/sync-plugins/fetch.d.ts +8 -2
- package/sync-plugins/fetch.js +3 -2
- package/sync-plugins/fetch.js.map +1 -1
- package/sync-plugins/fetch.mjs +4 -3
- package/sync-plugins/fetch.mjs.map +1 -1
- package/sync-plugins/keel.d.ts +3 -3
- package/sync-plugins/keel.js +38 -25
- package/sync-plugins/keel.js.map +1 -1
- package/sync-plugins/keel.mjs +38 -25
- package/sync-plugins/keel.mjs.map +1 -1
- package/sync-plugins/supabase.d.ts +2 -1
- package/sync-plugins/supabase.js +19 -24
- package/sync-plugins/supabase.js.map +1 -1
- package/sync-plugins/supabase.mjs +20 -25
- package/sync-plugins/supabase.mjs.map +1 -1
- package/sync-plugins/tanstack-query.d.ts +11 -0
- package/sync-plugins/tanstack-query.js +71 -0
- package/sync-plugins/tanstack-query.js.map +1 -0
- package/sync-plugins/tanstack-query.mjs +69 -0
- package/sync-plugins/tanstack-query.mjs.map +1 -0
- package/sync-plugins/tanstack-react-query.d.ts +3 -0
- package/sync-plugins/tanstack-react-query.js +11 -0
- package/sync-plugins/tanstack-react-query.js.map +1 -0
- package/sync-plugins/tanstack-react-query.mjs +9 -0
- package/sync-plugins/tanstack-react-query.mjs.map +1 -0
- package/sync.js +17 -4
- package/sync.js.map +1 -1
- package/sync.mjs +18 -5
- package/sync.mjs.map +1 -1
- package/react-hooks/useObservableQuery.d.ts +0 -6
- package/react-hooks/useObservableQuery.js +0 -152
- package/react-hooks/useObservableQuery.js.map +0 -1
- package/react-hooks/useObservableQuery.mjs +0 -131
- package/react-hooks/useObservableQuery.mjs.map +0 -1
- package/src/old-plugins/query.ts +0 -129
- package/src/react-hooks/useObservableQuery.ts +0 -205
package/babel.js
CHANGED
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
var types = require('@babel/types');
|
|
4
4
|
|
|
5
5
|
function babel () {
|
|
6
|
-
let
|
|
6
|
+
let hasLegendImport = false;
|
|
7
7
|
return {
|
|
8
8
|
visitor: {
|
|
9
|
-
Program() {
|
|
10
|
-
imported = {};
|
|
11
|
-
},
|
|
12
9
|
ImportDeclaration: {
|
|
13
10
|
enter(path) {
|
|
14
11
|
if (path.node.source.value === '@legendapp/state/react') {
|
|
15
12
|
const specifiers = path.node.specifiers;
|
|
16
13
|
for (let i = 0; i < specifiers.length; i++) {
|
|
17
14
|
const s = specifiers[i].imported.name;
|
|
18
|
-
if (!
|
|
19
|
-
|
|
15
|
+
if (!hasLegendImport && (s === 'Computed' || s === 'Memo' || s === 'Show')) {
|
|
16
|
+
hasLegendImport = true;
|
|
17
|
+
path.skip();
|
|
18
|
+
break;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
}
|
|
@@ -24,16 +23,24 @@ function babel () {
|
|
|
24
23
|
},
|
|
25
24
|
JSXElement: {
|
|
26
25
|
enter(path) {
|
|
26
|
+
if (!hasLegendImport) {
|
|
27
|
+
path.skip();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
27
30
|
const openingElement = path.node.openingElement;
|
|
28
|
-
const children_ = path.node.children;
|
|
29
31
|
const name = openingElement.name.name;
|
|
30
32
|
if (name === 'Computed' || name === 'Memo' || name === 'Show') {
|
|
31
|
-
const children =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const children = removeEmptyText(path.node.children);
|
|
34
|
+
if (children.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
if (children[0].type === 'JSXElement' ||
|
|
37
|
+
(children[0].type === 'JSXExpressionContainer' &&
|
|
38
|
+
children[0].expression.type !== 'ArrowFunctionExpression' &&
|
|
39
|
+
children[0].expression.type !== 'FunctionExpression' &&
|
|
40
|
+
children[0].expression.type !== 'MemberExpression' &&
|
|
41
|
+
children[0].expression.type !== 'Identifier')) {
|
|
42
|
+
const attrs = openingElement.attributes;
|
|
43
|
+
path.replaceWith(types.jsxElement(types.jsxOpeningElement(types.jsxIdentifier(name), attrs), types.jsxClosingElement(types.jsxIdentifier(name)), [types.jsxExpressionContainer(types.arrowFunctionExpression([], maybeWrapFragment(children)))]));
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
},
|
|
@@ -41,7 +48,14 @@ function babel () {
|
|
|
41
48
|
},
|
|
42
49
|
};
|
|
43
50
|
}
|
|
44
|
-
function
|
|
51
|
+
function maybeWrapFragment(children) {
|
|
52
|
+
if (children.length === 1 && children[0].type == 'JSXElement')
|
|
53
|
+
return children[0];
|
|
54
|
+
if (children.length === 1 && children[0].type == 'JSXExpressionContainer')
|
|
55
|
+
return children[0].expression;
|
|
56
|
+
return types.jsxFragment(types.jsxOpeningFragment(), types.jsxClosingFragment(), children);
|
|
57
|
+
}
|
|
58
|
+
function removeEmptyText(nodes) {
|
|
45
59
|
return nodes.filter((node) => !(node.type === 'JSXText' && node.value.trim().length === 0));
|
|
46
60
|
}
|
|
47
61
|
|
package/babel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel.js","sources":["./src/babel/index.ts"],"sourcesContent":[null],"names":["jsxElement","jsxOpeningElement","jsxIdentifier","jsxClosingElement","jsxExpressionContainer","arrowFunctionExpression","jsxFragment","jsxOpeningFragment","jsxClosingFragment"],"mappings":";;;;AAYc,cAAA,IAAA;
|
|
1
|
+
{"version":3,"file":"babel.js","sources":["./src/babel/index.ts"],"sourcesContent":[null],"names":["jsxElement","jsxOpeningElement","jsxIdentifier","jsxClosingElement","jsxExpressionContainer","arrowFunctionExpression","jsxFragment","jsxOpeningFragment","jsxClosingFragment"],"mappings":"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"}
|
package/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { observe } from './src/observe';
|
|
|
13
13
|
export { proxy } from './src/proxy';
|
|
14
14
|
export { trackSelector } from './src/trackSelector';
|
|
15
15
|
export { when, whenReady } from './src/when';
|
|
16
|
+
export { isObserved, shouldIgnoreUnobserved } from './src/ObservableObject';
|
|
16
17
|
import { get, getProxy, peek, set } from './src/ObservableObject';
|
|
17
18
|
import { createPreviousHandler } from './src/batching';
|
|
18
19
|
import { clone, ensureNodeValue, findIDKey, getNode, getNodeValue, getPathType, safeParse, safeStringify, setNodeValue } from './src/globals';
|
package/index.js
CHANGED
|
@@ -211,6 +211,7 @@ function getChildNode(node, key, asFunction) {
|
|
|
211
211
|
parent: node,
|
|
212
212
|
key,
|
|
213
213
|
lazy: true,
|
|
214
|
+
numListenersRecursive: 0,
|
|
214
215
|
};
|
|
215
216
|
// Lookup functions are bound with the child key
|
|
216
217
|
if (((_b = node.lazyFn) === null || _b === void 0 ? void 0 : _b.length) === 1) {
|
|
@@ -708,10 +709,13 @@ function getNodeAtPath(obj, path) {
|
|
|
708
709
|
return o;
|
|
709
710
|
}
|
|
710
711
|
|
|
711
|
-
function linked(params) {
|
|
712
|
+
function linked(params, options) {
|
|
712
713
|
if (isFunction(params)) {
|
|
713
714
|
params = { get: params };
|
|
714
715
|
}
|
|
716
|
+
if (options) {
|
|
717
|
+
params = { ...params, ...options };
|
|
718
|
+
}
|
|
715
719
|
const ret = function () {
|
|
716
720
|
return { [symbolLinked]: params };
|
|
717
721
|
};
|
|
@@ -731,6 +735,7 @@ function createObservable(value, makePrimitive, extractPromise, createObject, cr
|
|
|
731
735
|
let node = {
|
|
732
736
|
root,
|
|
733
737
|
lazy: true,
|
|
738
|
+
numListenersRecursive: 0,
|
|
734
739
|
};
|
|
735
740
|
if (valueIsFunction) {
|
|
736
741
|
node = Object.assign(() => { }, node);
|
|
@@ -806,6 +811,7 @@ function onChange(node, callback, options = {}, fromLinks) {
|
|
|
806
811
|
// Add listeners for linked from nodes
|
|
807
812
|
(_a = node.linkedFromNodes) === null || _a === void 0 ? void 0 : _a.forEach((linkedFromNode) => addLinkedNodeListeners(linkedFromNode));
|
|
808
813
|
// Go up through the parents and add listeners for linked from nodes
|
|
814
|
+
node.numListenersRecursive++;
|
|
809
815
|
let parent = node.parent;
|
|
810
816
|
let pathParent = [node.key];
|
|
811
817
|
while (parent) {
|
|
@@ -817,12 +823,18 @@ function onChange(node, callback, options = {}, fromLinks) {
|
|
|
817
823
|
}
|
|
818
824
|
}
|
|
819
825
|
}
|
|
826
|
+
parent.numListenersRecursive++;
|
|
820
827
|
pathParent = [parent.key, ...pathParent];
|
|
821
828
|
parent = parent.parent;
|
|
822
829
|
}
|
|
823
830
|
return () => {
|
|
824
831
|
listeners.delete(listener);
|
|
825
832
|
extraDisposes === null || extraDisposes === void 0 ? void 0 : extraDisposes.forEach((fn) => fn());
|
|
833
|
+
let parent = node;
|
|
834
|
+
while (parent) {
|
|
835
|
+
parent.numListenersRecursive--;
|
|
836
|
+
parent = parent.parent;
|
|
837
|
+
}
|
|
826
838
|
};
|
|
827
839
|
}
|
|
828
840
|
function createCb(linkedFromNode, path, callback) {
|
|
@@ -1453,7 +1465,7 @@ const proxyHandler = {
|
|
|
1453
1465
|
}
|
|
1454
1466
|
else if (ArrayLoopers.has(p)) {
|
|
1455
1467
|
// Update that this node was accessed for observers
|
|
1456
|
-
updateTracking(node);
|
|
1468
|
+
updateTracking(node, true);
|
|
1457
1469
|
return function (cbOrig, thisArg) {
|
|
1458
1470
|
const isReduce = p === 'reduce';
|
|
1459
1471
|
// Callbacks are given the Proxy rather than the underlying data
|
|
@@ -1786,6 +1798,8 @@ function extractPromise(node, value, setter) {
|
|
|
1786
1798
|
});
|
|
1787
1799
|
}
|
|
1788
1800
|
function extractFunctionOrComputed(node, k, v) {
|
|
1801
|
+
// We want to extract these types of values from the observable's raw value so that
|
|
1802
|
+
// the raw value does not contain Promises, Observables or functions
|
|
1789
1803
|
if (isPromise(v)) {
|
|
1790
1804
|
const childNode = getChildNode(node, k);
|
|
1791
1805
|
extractPromise(childNode, v);
|
|
@@ -1816,13 +1830,22 @@ function get(node, options) {
|
|
|
1816
1830
|
function peek(node) {
|
|
1817
1831
|
return peekInternal(node, true);
|
|
1818
1832
|
}
|
|
1833
|
+
let isFlushing = false;
|
|
1819
1834
|
function peekInternal(node, activateRecursive) {
|
|
1835
|
+
var _a;
|
|
1836
|
+
isFlushing = true;
|
|
1837
|
+
if ((_a = node.dirtyChildren) === null || _a === void 0 ? void 0 : _a.size) {
|
|
1838
|
+
const dirty = Array.from(node.dirtyChildren);
|
|
1839
|
+
node.dirtyChildren.clear();
|
|
1840
|
+
dirty.forEach((node) => node.dirtyFn && peekInternal(node));
|
|
1841
|
+
}
|
|
1820
1842
|
if (node.dirtyFn) {
|
|
1821
1843
|
const dirtyFn = node.dirtyFn;
|
|
1822
1844
|
node.dirtyFn = undefined;
|
|
1823
1845
|
globalState.dirtyNodes.delete(node);
|
|
1824
1846
|
dirtyFn();
|
|
1825
1847
|
}
|
|
1848
|
+
isFlushing = false;
|
|
1826
1849
|
let value = getNodeValue(node);
|
|
1827
1850
|
value = checkLazy(node, value, !!activateRecursive);
|
|
1828
1851
|
return value;
|
|
@@ -1857,27 +1880,14 @@ function checkLazy(node, value, activateRecursive) {
|
|
|
1857
1880
|
}
|
|
1858
1881
|
}
|
|
1859
1882
|
if ((lazy || node.needsExtract) && !isObservable(value) && !isPrimitive(value)) {
|
|
1883
|
+
// If this is a purposeful get, check descendants for observable or auto activated linked
|
|
1860
1884
|
if (activateRecursive) {
|
|
1861
|
-
|
|
1885
|
+
recursivelyAutoActivate(value, node);
|
|
1862
1886
|
}
|
|
1887
|
+
// If this is an extractable node, extract it from parent before it's accessed
|
|
1863
1888
|
if (node.parent) {
|
|
1864
1889
|
extractFunctionOrComputed(node.parent, node.key, origValue);
|
|
1865
1890
|
}
|
|
1866
|
-
// for (const key in value) {
|
|
1867
|
-
// if (hasOwnProperty.call(value, key)) {
|
|
1868
|
-
// const property = Object.getOwnPropertyDescriptor(value, key);
|
|
1869
|
-
// if (property?.get) {
|
|
1870
|
-
// delete value[key];
|
|
1871
|
-
// value[key] = property.set
|
|
1872
|
-
// ? linked({
|
|
1873
|
-
// get: property.get,
|
|
1874
|
-
// set: ({ value }) => property.set!(value),
|
|
1875
|
-
// })
|
|
1876
|
-
// : property.get;
|
|
1877
|
-
// }
|
|
1878
|
-
// extractFunctionOrComputed(node, key, value[key]);
|
|
1879
|
-
// }
|
|
1880
|
-
// }
|
|
1881
1891
|
}
|
|
1882
1892
|
return value;
|
|
1883
1893
|
}
|
|
@@ -1904,6 +1914,37 @@ function reactivateNode(node, lazyFn) {
|
|
|
1904
1914
|
node.lazyFn = lazyFn;
|
|
1905
1915
|
node.lazy = true;
|
|
1906
1916
|
}
|
|
1917
|
+
function isObserved(node) {
|
|
1918
|
+
var _a, _b;
|
|
1919
|
+
let parent = node;
|
|
1920
|
+
let hasListeners = node.numListenersRecursive > 0;
|
|
1921
|
+
while (parent && !hasListeners) {
|
|
1922
|
+
if (!!((_a = parent.listeners) === null || _a === void 0 ? void 0 : _a.size) || !!((_b = parent.listenersImmediate) === null || _b === void 0 ? void 0 : _b.size)) {
|
|
1923
|
+
hasListeners = true;
|
|
1924
|
+
}
|
|
1925
|
+
parent = parent.parent;
|
|
1926
|
+
}
|
|
1927
|
+
return hasListeners;
|
|
1928
|
+
}
|
|
1929
|
+
function shouldIgnoreUnobserved(node, refreshFn) {
|
|
1930
|
+
if (!isFlushing) {
|
|
1931
|
+
const hasListeners = isObserved(node);
|
|
1932
|
+
if (!hasListeners) {
|
|
1933
|
+
if (refreshFn) {
|
|
1934
|
+
node.dirtyFn = refreshFn;
|
|
1935
|
+
}
|
|
1936
|
+
let parent = node;
|
|
1937
|
+
while (parent) {
|
|
1938
|
+
if (!parent.dirtyChildren) {
|
|
1939
|
+
parent.dirtyChildren = new Set();
|
|
1940
|
+
}
|
|
1941
|
+
parent.dirtyChildren.add(node);
|
|
1942
|
+
parent = parent.parent;
|
|
1943
|
+
}
|
|
1944
|
+
return true;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1907
1948
|
function activateNodeFunction(node, lazyFn) {
|
|
1908
1949
|
// let prevTarget$: Observable<any>;
|
|
1909
1950
|
// let curTarget$: Observable<any>;
|
|
@@ -1927,6 +1968,12 @@ function activateNodeFunction(node, lazyFn) {
|
|
|
1927
1968
|
isFirst = false;
|
|
1928
1969
|
setNodeValue(node, undefined);
|
|
1929
1970
|
}
|
|
1971
|
+
else if (!isFlushing && refreshFn) {
|
|
1972
|
+
if (shouldIgnoreUnobserved(node, refreshFn)) {
|
|
1973
|
+
ignoreThisUpdate = true;
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1930
1977
|
// Run the function at this node
|
|
1931
1978
|
let value = activateFn();
|
|
1932
1979
|
let didSetToObs = false;
|
|
@@ -1934,8 +1981,6 @@ function activateNodeFunction(node, lazyFn) {
|
|
|
1934
1981
|
if (isObservable(value)) {
|
|
1935
1982
|
didSetToObs = true;
|
|
1936
1983
|
value = setToObservable(node, value);
|
|
1937
|
-
// } else {
|
|
1938
|
-
// traverseObject(value, node)
|
|
1939
1984
|
}
|
|
1940
1985
|
if (isFunction(value)) {
|
|
1941
1986
|
value = value();
|
|
@@ -1981,9 +2026,9 @@ function activateNodeFunction(node, lazyFn) {
|
|
|
1981
2026
|
wasPromise = wasPromise || isPromise(value);
|
|
1982
2027
|
return value;
|
|
1983
2028
|
}, (e) => {
|
|
2029
|
+
const { value, nodes, refresh } = e;
|
|
2030
|
+
refreshFn = refresh;
|
|
1984
2031
|
if (!ignoreThisUpdate) {
|
|
1985
|
-
const { value, nodes, refresh } = e;
|
|
1986
|
-
refreshFn = refresh;
|
|
1987
2032
|
if (!wasPromise || !globalState.isLoadingRemote) {
|
|
1988
2033
|
if (wasPromise) {
|
|
1989
2034
|
if (node.activationState) {
|
|
@@ -2028,8 +2073,8 @@ function activateNodeFunction(node, lazyFn) {
|
|
|
2028
2073
|
}
|
|
2029
2074
|
disposes.forEach((fn) => fn());
|
|
2030
2075
|
disposes = [];
|
|
2031
|
-
nodes === null || nodes === void 0 ? void 0 : nodes.forEach(({ node }) => {
|
|
2032
|
-
disposes.push(onChange(node, markDirty, { immediate: true }));
|
|
2076
|
+
nodes === null || nodes === void 0 ? void 0 : nodes.forEach(({ node, track }) => {
|
|
2077
|
+
disposes.push(onChange(node, markDirty, { immediate: true, trackingType: track }));
|
|
2033
2078
|
});
|
|
2034
2079
|
}
|
|
2035
2080
|
e.cancel = true;
|
|
@@ -2143,7 +2188,7 @@ function setToObservable(node, value) {
|
|
|
2143
2188
|
}
|
|
2144
2189
|
return value;
|
|
2145
2190
|
}
|
|
2146
|
-
function
|
|
2191
|
+
function recursivelyAutoActivate(obj, node) {
|
|
2147
2192
|
if (isObject(obj) || isArray(obj)) {
|
|
2148
2193
|
const pathStack = []; // Maintain a stack for path tracking
|
|
2149
2194
|
const getNodeAtPath = () => {
|
|
@@ -2157,10 +2202,10 @@ function traverseObject(obj, node) {
|
|
|
2157
2202
|
}
|
|
2158
2203
|
return childNode;
|
|
2159
2204
|
};
|
|
2160
|
-
|
|
2205
|
+
recursivelyAutoActivateInner(obj, pathStack, getNodeAtPath);
|
|
2161
2206
|
}
|
|
2162
2207
|
}
|
|
2163
|
-
function
|
|
2208
|
+
function recursivelyAutoActivateInner(obj, pathStack, getNodeAtPath) {
|
|
2164
2209
|
var _a;
|
|
2165
2210
|
for (const key in obj) {
|
|
2166
2211
|
if (hasOwnProperty.call(obj, key)) {
|
|
@@ -2182,7 +2227,7 @@ function traverseObjectInner(obj, pathStack, getNodeAtPath) {
|
|
|
2182
2227
|
}
|
|
2183
2228
|
if (typeof value === 'object') {
|
|
2184
2229
|
pathStack.push({ key, value });
|
|
2185
|
-
|
|
2230
|
+
recursivelyAutoActivateInner(value, pathStack, getNodeAtPath); // Recursively traverse
|
|
2186
2231
|
pathStack.pop();
|
|
2187
2232
|
}
|
|
2188
2233
|
}
|
|
@@ -2438,6 +2483,7 @@ exports.isNumber = isNumber;
|
|
|
2438
2483
|
exports.isObject = isObject;
|
|
2439
2484
|
exports.isObservable = isObservable;
|
|
2440
2485
|
exports.isObservableValueReady = isObservableValueReady;
|
|
2486
|
+
exports.isObserved = isObserved;
|
|
2441
2487
|
exports.isPrimitive = isPrimitive;
|
|
2442
2488
|
exports.isPromise = isPromise;
|
|
2443
2489
|
exports.isString = isString;
|
|
@@ -2454,6 +2500,7 @@ exports.setAtPath = setAtPath;
|
|
|
2454
2500
|
exports.setInObservableAtPath = setInObservableAtPath;
|
|
2455
2501
|
exports.setSilently = setSilently;
|
|
2456
2502
|
exports.setupTracking = setupTracking;
|
|
2503
|
+
exports.shouldIgnoreUnobserved = shouldIgnoreUnobserved;
|
|
2457
2504
|
exports.symbolDelete = symbolDelete;
|
|
2458
2505
|
exports.syncState = syncState;
|
|
2459
2506
|
exports.trackSelector = trackSelector;
|