@tanstack/store
Advanced tools
Comparing version 0.1.3 to 0.3.0
{ | ||
"name": "@tanstack/store", | ||
"author": "Tanner Linsley", | ||
"version": "0.1.3", | ||
"version": "0.3.0", | ||
"license": "MIT", | ||
@@ -21,14 +21,14 @@ "repository": "tanstack/store", | ||
"type": "module", | ||
"types": "build/legacy/index.d.ts", | ||
"main": "build/legacy/index.cjs", | ||
"module": "build/legacy/index.js", | ||
"types": "dist/esm/index.d.ts", | ||
"main": "dist/cjs/index.cjs", | ||
"module": "dist/esm/index.js", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./build/modern/index.d.ts", | ||
"default": "./build/modern/index.js" | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./build/modern/index.d.cts", | ||
"default": "./build/modern/index.cjs" | ||
"types": "./dist/cjs/index.d.cts", | ||
"default": "./dist/cjs/index.cjs" | ||
} | ||
@@ -40,14 +40,18 @@ }, | ||
"files": [ | ||
"build", | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"clean": "rimraf ./build && rimraf ./coverage", | ||
"clean": "rimraf ./dist && rimraf ./coverage", | ||
"test:eslint": "eslint --ext .ts,.tsx ./src", | ||
"test:types": "tsc", | ||
"test:lib": "vitest run --coverage", | ||
"test:types:versions49": "node ../../node_modules/typescript49/lib/tsc.js --project tsconfig.legacy.json", | ||
"test:types:versions50": "node ../../node_modules/typescript50/lib/tsc.js", | ||
"test:types:versions51": "node ../../node_modules/typescript51/lib/tsc.js", | ||
"test:types:versions52": "tsc", | ||
"test:types": "pnpm run \"/^test:types:versions.*/\"", | ||
"test:lib": "vitest", | ||
"test:lib:dev": "pnpm run test:lib --watch", | ||
"test:build": "publint --strict", | ||
"build": "tsup" | ||
"build": "vite build" | ||
} | ||
} |
export type AnyUpdater = (...args: any[]) => any | ||
export type Listener = (opts: { priority: Priority }) => void | ||
export type Listener = () => void | ||
export type Priority = 'high' | 'low' | ||
interface StoreOptions< | ||
@@ -16,4 +14,3 @@ TState, | ||
) => () => void | ||
onUpdate?: (opts: { priority: Priority }) => void | ||
defaultPriority?: Priority | ||
onUpdate?: () => void | ||
} | ||
@@ -30,3 +27,2 @@ | ||
_flushing = 0 | ||
_nextPriority: null | Priority = null | ||
@@ -47,8 +43,3 @@ constructor(initialState: TState, options?: StoreOptions<TState, TUpdater>) { | ||
setState = ( | ||
updater: TUpdater, | ||
opts?: { | ||
priority: Priority | ||
}, | ||
) => { | ||
setState = (updater: TUpdater) => { | ||
const previous = this.state | ||
@@ -59,15 +50,4 @@ this.state = this.options?.updateFn | ||
const priority = opts?.priority ?? this.options?.defaultPriority ?? 'high' | ||
if (this._nextPriority === null) { | ||
this._nextPriority = priority | ||
} else if (this._nextPriority === 'high') { | ||
this._nextPriority = priority | ||
} else { | ||
this._nextPriority = this.options?.defaultPriority ?? 'high' | ||
} | ||
// Always run onUpdate, regardless of batching | ||
this.options?.onUpdate?.({ | ||
priority: this._nextPriority, | ||
}) | ||
this.options?.onUpdate?.() | ||
@@ -83,5 +63,3 @@ // Attempt to flush | ||
if (this._flushing !== flushId) return | ||
listener({ | ||
priority: this._nextPriority ?? 'high', | ||
}) | ||
listener() | ||
}) | ||
@@ -88,0 +66,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
15837
10
230
1