@tanstack/react-store
Advanced tools
Comparing version 0.0.1-beta.118 to 0.0.1-beta.120
@@ -15,2 +15,3 @@ /** | ||
require('react'); | ||
var withSelector = require('use-sync-external-store/shim/with-selector'); | ||
@@ -21,6 +22,25 @@ var store = require('@tanstack/store'); | ||
// const isMountedRef = React.useRef(false) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>({ | ||
// ref: undefined!, | ||
// }) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>(() => ({ | ||
// ref: selector(store.state), | ||
// })) | ||
// if (!shallow(selector(store.state), state.ref)) { | ||
// setState(() => ({ ref: selector(store.state) })) | ||
// } | ||
// useLayoutEffect(() => { | ||
// console.log('effect') | ||
// const cb = () => { | ||
// const next = selector(store.state) | ||
// console.log('onsub') | ||
// if (!shallow(next, state.ref)) { | ||
// console.log('set') | ||
// setState(() => ({ ref: selector(store.state) })) | ||
// } | ||
// } | ||
// return store.subscribe(cb) | ||
// }, []) | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow); | ||
@@ -32,3 +52,3 @@ | ||
// if (slice !== state.ref) { | ||
// if (!shallow(slice, state.ref)) { | ||
// setState({ ref: slice }) | ||
@@ -35,0 +55,0 @@ // } |
@@ -11,2 +11,3 @@ /** | ||
*/ | ||
import 'react'; | ||
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'; | ||
@@ -17,6 +18,25 @@ export * from '@tanstack/store'; | ||
// const isMountedRef = React.useRef(false) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>({ | ||
// ref: undefined!, | ||
// }) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>(() => ({ | ||
// ref: selector(store.state), | ||
// })) | ||
// if (!shallow(selector(store.state), state.ref)) { | ||
// setState(() => ({ ref: selector(store.state) })) | ||
// } | ||
// useLayoutEffect(() => { | ||
// console.log('effect') | ||
// const cb = () => { | ||
// const next = selector(store.state) | ||
// console.log('onsub') | ||
// if (!shallow(next, state.ref)) { | ||
// console.log('set') | ||
// setState(() => ({ ref: selector(store.state) })) | ||
// } | ||
// } | ||
// return store.subscribe(cb) | ||
// }, []) | ||
const slice = useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow); | ||
@@ -28,3 +48,3 @@ | ||
// if (slice !== state.ref) { | ||
// if (!shallow(slice, state.ref)) { | ||
// setState({ ref: slice }) | ||
@@ -31,0 +51,0 @@ // } |
@@ -14,7 +14,7 @@ { | ||
"name": "store/build/esm/index.js", | ||
"uid": "e526-10" | ||
"uid": "a144-11" | ||
}, | ||
{ | ||
"name": "react-store/src/index.tsx", | ||
"uid": "e526-12" | ||
"uid": "a144-13" | ||
} | ||
@@ -29,20 +29,20 @@ ] | ||
"nodeParts": { | ||
"e526-10": { | ||
"a144-11": { | ||
"renderedLength": 1359, | ||
"gzipLength": 537, | ||
"brotliLength": 0, | ||
"mainUid": "e526-9" | ||
"mainUid": "a144-10" | ||
}, | ||
"e526-12": { | ||
"renderedLength": 1244, | ||
"gzipLength": 505, | ||
"a144-13": { | ||
"renderedLength": 1778, | ||
"gzipLength": 607, | ||
"brotliLength": 0, | ||
"mainUid": "e526-11" | ||
"mainUid": "a144-12" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"e526-9": { | ||
"a144-10": { | ||
"id": "/packages/store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "e526-10" | ||
"index.production.js": "a144-11" | ||
}, | ||
@@ -52,17 +52,20 @@ "imported": [], | ||
{ | ||
"uid": "e526-11" | ||
"uid": "a144-12" | ||
} | ||
] | ||
}, | ||
"e526-11": { | ||
"a144-12": { | ||
"id": "/packages/react-store/src/index.tsx", | ||
"moduleParts": { | ||
"index.production.js": "e526-12" | ||
"index.production.js": "a144-13" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "e526-13" | ||
"uid": "a144-14" | ||
}, | ||
{ | ||
"uid": "e526-9" | ||
"uid": "a144-15" | ||
}, | ||
{ | ||
"uid": "a144-10" | ||
} | ||
@@ -73,3 +76,14 @@ ], | ||
}, | ||
"e526-13": { | ||
"a144-14": { | ||
"id": "react", | ||
"moduleParts": {}, | ||
"imported": [], | ||
"importedBy": [ | ||
{ | ||
"uid": "a144-12" | ||
} | ||
], | ||
"isExternal": true | ||
}, | ||
"a144-15": { | ||
"id": "use-sync-external-store/shim/with-selector", | ||
@@ -80,3 +94,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "e526-11" | ||
"uid": "a144-12" | ||
} | ||
@@ -83,0 +97,0 @@ ], |
@@ -12,6 +12,6 @@ /** | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('use-sync-external-store/shim/with-selector')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'use-sync-external-store/shim/with-selector'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactLoaders = {}, global.withSelector)); | ||
})(this, (function (exports, withSelector) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-sync-external-store/shim/with-selector')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-sync-external-store/shim/with-selector'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactLoaders = {}, global.React, global.withSelector)); | ||
})(this, (function (exports, React, withSelector) { 'use strict'; | ||
@@ -73,6 +73,25 @@ /** | ||
// const isMountedRef = React.useRef(false) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>({ | ||
// ref: undefined!, | ||
// }) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>(() => ({ | ||
// ref: selector(store.state), | ||
// })) | ||
// if (!shallow(selector(store.state), state.ref)) { | ||
// setState(() => ({ ref: selector(store.state) })) | ||
// } | ||
// useLayoutEffect(() => { | ||
// console.log('effect') | ||
// const cb = () => { | ||
// const next = selector(store.state) | ||
// console.log('onsub') | ||
// if (!shallow(next, state.ref)) { | ||
// console.log('set') | ||
// setState(() => ({ ref: selector(store.state) })) | ||
// } | ||
// } | ||
// return store.subscribe(cb) | ||
// }, []) | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow); | ||
@@ -84,3 +103,3 @@ | ||
// if (slice !== state.ref) { | ||
// if (!shallow(slice, state.ref)) { | ||
// setState({ ref: slice }) | ||
@@ -87,0 +106,0 @@ // } |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactLoaders={},t.withSelector)}(this,(function(t,e){"use strict"; | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactLoaders={},t.React,t.withSelector)}(this,(function(t,e,s){"use strict"; | ||
/** | ||
@@ -22,3 +22,3 @@ * @tanstack/store/src/index.ts | ||
* @license MIT | ||
*/function s(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t);if(s.length!==Object.keys(e).length)return!1;for(let i=0;i<s.length;i++)if(!Object.prototype.hasOwnProperty.call(e,s[i])||!Object.is(t[s[i]],e[s[i]]))return!1;return!0}t.Store=class{listeners=new Set;_batching=!1;_flushing=0;constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.options?.onUpdate?.(),this._flush()};_flush=()=>{if(this._batching)return;const t=++this._flushing;this.listeners.forEach((e=>{this._flushing===t&&e()}))};batch=t=>{if(this._batching)return t();this._batching=!0,t(),this._batching=!1,this._flush()}},t.shallow=s,t.useStore=function(t,i=(t=>t)){return e.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),i,s)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
*/function i(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t);if(s.length!==Object.keys(e).length)return!1;for(let i=0;i<s.length;i++)if(!Object.prototype.hasOwnProperty.call(e,s[i])||!Object.is(t[s[i]],e[s[i]]))return!1;return!0}t.Store=class{listeners=new Set;_batching=!1;_flushing=0;constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.options?.onUpdate?.(),this._flush()};_flush=()=>{if(this._batching)return;const t=++this._flushing;this.listeners.forEach((e=>{this._flushing===t&&e()}))};batch=t=>{if(this._batching)return t();this._batching=!0,t(),this._batching=!1,this._flush()}},t.shallow=i,t.useStore=function(t,e=(t=>t)){return s.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,i)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/react-store", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.118", | ||
"version": "0.0.1-beta.120", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "tanstack/react-store", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173825
500