P2-03: manage hashed OPFS project resources

This commit is contained in:
2026-08-02 05:15:13 -04:00
parent 657c4beb9f
commit 5f0d9a8d0e
7 changed files with 139 additions and 10 deletions

View File

@@ -112,6 +112,21 @@ test('project persistence remains behind the facade contract', async () => {
assert.equal(facade.project.capabilities().mode, 'sqlite-memory')
})
test('project resources use content identity and reference counting', async () => {
const facade = createMockFacade()
const bytes = new Uint8Array([1, 2, 3, 5, 8])
const first = await facade.project.resource.put(bytes, 'application/octet-stream')
const second = await facade.project.resource.put(bytes, 'application/octet-stream')
assert.equal(first.hash, second.hash)
assert.equal(second.refCount, 2)
bytes[0] = 99
assert.deepEqual([...((await facade.project.resource.get(first.hash)) || [])], [1, 2, 3, 5, 8])
await facade.project.resource.release(first.hash)
assert.deepEqual([...((await facade.project.resource.get(first.hash)) || [])], [1, 2, 3, 5, 8])
await facade.project.resource.release(first.hash)
assert.equal(await facade.project.resource.get(first.hash), null)
})
test('Part Design feature tasks commit a document object and remain undoable', () => {
const facade = createMockFacade()
const before = facade.app.document.getActive()