@tldraw/tlstore
Advanced tools
Comparing version 2.0.0-canary.50612409121c to 2.0.0-canary.50bae6d4a129
@@ -568,2 +568,3 @@ import { Atom } from 'signia'; | ||
createSelectedComputedCache: <T, J, V extends R = R>(name: string, selector: (record: V) => T | undefined, derive: (input: T) => J | undefined) => ComputedCache<J, V>; | ||
private _integrityChecker?; | ||
/* Excluded from this release type: ensureStoreIsUsable */ | ||
@@ -687,3 +688,3 @@ private _isPossiblyCorrupted; | ||
migrateStoreSnapshot(storeSnapshot: StoreSnapshot<R>, persistedSchema: SerializedSchema): MigrationResult<StoreSnapshot<R>>; | ||
/* Excluded from this release type: ensureStoreIsUsable */ | ||
/* Excluded from this release type: createIntegrityChecker */ | ||
/* Excluded from this release type: derivePresenceState */ | ||
@@ -706,3 +707,3 @@ serialize(): SerializedSchema; | ||
}) => R; | ||
/* Excluded from this release type: ensureStoreIsUsable */ | ||
/* Excluded from this release type: createIntegrityChecker */ | ||
/* Excluded from this release type: derivePresenceState */ | ||
@@ -709,0 +710,0 @@ }; |
@@ -26,2 +26,3 @@ "use strict"; | ||
module.exports = __toCommonJS(Store_exports); | ||
var import_utils = require("@tldraw/utils"); | ||
var import_signia = require("signia"); | ||
@@ -96,3 +97,3 @@ var import_Cache = require("./Cache"); | ||
}, | ||
{ scheduleEffect: (cb) => requestAnimationFrame(cb) } | ||
{ scheduleEffect: (cb) => (0, import_utils.throttledRaf)(cb) } | ||
); | ||
@@ -468,5 +469,7 @@ } | ||
}; | ||
_integrityChecker; | ||
/** @internal */ | ||
ensureStoreIsUsable() { | ||
this.schema.ensureStoreIsUsable(this); | ||
this._integrityChecker ??= this.schema.createIntegrityChecker(this); | ||
this._integrityChecker?.(); | ||
} | ||
@@ -473,0 +476,0 @@ _isPossiblyCorrupted = false; |
@@ -150,4 +150,4 @@ "use strict"; | ||
/** @internal */ | ||
ensureStoreIsUsable(store) { | ||
this.options.ensureStoreIsUsable?.(store); | ||
createIntegrityChecker(store) { | ||
return this.options.createIntegrityChecker?.(store) ?? void 0; | ||
} | ||
@@ -154,0 +154,0 @@ /** @internal */ |
{ | ||
"name": "@tldraw/tlstore", | ||
"description": "A tiny little drawing app (store).", | ||
"version": "2.0.0-canary.50612409121c", | ||
"version": "2.0.0-canary.50bae6d4a129", | ||
"packageManager": "yarn@3.5.0", | ||
@@ -37,3 +37,3 @@ "author": { | ||
"test-coverage": "lazy inherit", | ||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts", | ||
"build": "yarn run -T tsx ../../scripts/build-package.ts", | ||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts", | ||
@@ -46,3 +46,3 @@ "prepack": "yarn run -T tsx ../../scripts/prepack.ts", | ||
"dependencies": { | ||
"@tldraw/utils": "2.0.0-canary.50612409121c", | ||
"@tldraw/utils": "2.0.0-canary.50bae6d4a129", | ||
"lodash.isequal": "^4.5.0", | ||
@@ -49,0 +49,0 @@ "nanoid": "4.0.2" |
@@ -0,1 +1,2 @@ | ||
import { throttledRaf } from '@tldraw/utils' | ||
import { atom, Atom, computed, Computed, Reactor, reactor, transact } from 'signia' | ||
@@ -175,3 +176,3 @@ import { BaseRecord, ID } from './BaseRecord' | ||
}, | ||
{ scheduleEffect: (cb) => requestAnimationFrame(cb) } | ||
{ scheduleEffect: (cb) => throttledRaf(cb) } | ||
) | ||
@@ -625,5 +626,8 @@ } | ||
private _integrityChecker?: () => void | undefined | ||
/** @internal */ | ||
ensureStoreIsUsable() { | ||
this.schema.ensureStoreIsUsable(this) | ||
this._integrityChecker ??= this.schema.createIntegrityChecker(this) | ||
this._integrityChecker?.() | ||
} | ||
@@ -630,0 +634,0 @@ |
@@ -51,3 +51,3 @@ import { getOwnProperty, objectMapValues } from '@tldraw/utils' | ||
/** @internal */ | ||
ensureStoreIsUsable?: (store: Store<R, P>) => void | ||
createIntegrityChecker?: (store: Store<R, P>) => void | ||
/** @internal */ | ||
@@ -244,4 +244,4 @@ derivePresenceState?: (store: Store<R, P>) => Signal<R | null> | ||
/** @internal */ | ||
ensureStoreIsUsable(store: Store<R, P>): void { | ||
this.options.ensureStoreIsUsable?.(store) | ||
createIntegrityChecker(store: Store<R, P>): (() => void) | undefined { | ||
return this.options.createIntegrityChecker?.(store) ?? undefined | ||
} | ||
@@ -248,0 +248,0 @@ |
@@ -472,22 +472,29 @@ import { Computed, react, RESET_VALUE, transact } from 'signia' | ||
it('flushes history before attaching listeners', async () => { | ||
store.put([Author.create({ name: 'J.R.R Tolkein', id: Author.createCustomId('tolkein') })]) | ||
const firstListener = jest.fn() | ||
store.listen(firstListener) | ||
expect(firstListener).toHaveBeenCalledTimes(0) | ||
try { | ||
// @ts-expect-error | ||
globalThis.__FORCE_RAF_IN_TESTS__ = true | ||
store.put([Author.create({ name: 'J.R.R Tolkein', id: Author.createCustomId('tolkein') })]) | ||
const firstListener = jest.fn() | ||
store.listen(firstListener) | ||
expect(firstListener).toHaveBeenCalledTimes(0) | ||
store.put([Author.create({ name: 'Chips McCoy', id: Author.createCustomId('chips') })]) | ||
store.put([Author.create({ name: 'Chips McCoy', id: Author.createCustomId('chips') })]) | ||
expect(firstListener).toHaveBeenCalledTimes(0) | ||
expect(firstListener).toHaveBeenCalledTimes(0) | ||
const secondListener = jest.fn() | ||
const secondListener = jest.fn() | ||
store.listen(secondListener) | ||
store.listen(secondListener) | ||
expect(firstListener).toHaveBeenCalledTimes(1) | ||
expect(secondListener).toHaveBeenCalledTimes(0) | ||
expect(firstListener).toHaveBeenCalledTimes(1) | ||
expect(secondListener).toHaveBeenCalledTimes(0) | ||
await new Promise((resolve) => requestAnimationFrame(resolve)) | ||
await new Promise((resolve) => requestAnimationFrame(resolve)) | ||
expect(firstListener).toHaveBeenCalledTimes(1) | ||
expect(secondListener).toHaveBeenCalledTimes(0) | ||
expect(firstListener).toHaveBeenCalledTimes(1) | ||
expect(secondListener).toHaveBeenCalledTimes(0) | ||
} finally { | ||
// @ts-expect-error | ||
globalThis.__FORCE_RAF_IN_TESTS__ = false | ||
} | ||
}) | ||
@@ -494,0 +501,0 @@ |
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
Sorry, the diff of this file is not supported yet
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
533545
9167
0
+ Added@tldraw/utils@2.0.0-canary.50bae6d4a129(transitive)
- Removed@tldraw/utils@2.0.0-canary.50612409121c(transitive)