Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions examples/storybook-hub/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions examples/storybook-hub/package.json

This file was deleted.

212 changes: 0 additions & 212 deletions examples/storybook-hub/src/client/main.ts

This file was deleted.

12 changes: 0 additions & 12 deletions examples/storybook-hub/tsconfig.json

This file was deleted.

13 changes: 0 additions & 13 deletions examples/storybook-hub/uno.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"docs": "pnpm -C docs run docs",
"docs:build": "pnpm -C docs run docs:build",
"docs:serve": "pnpm -C docs run docs:serve",
"storybook": "pnpm -r --parallel --if-present run storybook",
"storybook": "pnpm -C storybook dev",
"storybook:build": "pnpm --filter @devframes/storybook run storybook:build",
"lint": "eslint --cache",
"test": "pnpm run build && vitest",
Expand Down
27 changes: 27 additions & 0 deletions packages/hub/src/node/__tests__/host-docks.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { DevframeViewLauncher } from '../../types/docks'
import type { DevframeHubContext } from '../context'
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
Expand Down Expand Up @@ -305,4 +306,30 @@ describe('devframeDockHost ~builtin category', () => {
expect(updatedLauncher?.digest).toBe('done')
expect(updatedLauncher?.status).toBe('success')
})

it('updates a registered entry whose stored view was frozen (Immer-projected shared state)', () => {
const host = new DevframeDocksHost(createContext())
const handle = host.register<DevframeViewLauncher>({
type: 'launcher',
id: 'app:build',
title: 'Build',
icon: 'ph:hammer-duotone',
launcher: { title: 'Run build', status: 'idle', command: 'app:run-build' },
})

// Projecting the entry into `devframe:docks` shared state runs it through
// Immer's `produce`, which deep-freezes the very object the registry holds.
Object.freeze(host.values()[0])

// The launch handler patches the launcher as the process boots; the update
// must not throw "Cannot assign to read only property" on the frozen entry.
expect(() => handle.update({
launcher: { title: 'Run build', status: 'loading', command: 'app:run-build', terminalSessionId: 'build-session', digest: 'compiling…' },
})).not.toThrow()

const entry = host.values()[0]
const launcher = entry.type === 'launcher' ? entry.launcher : undefined
expect(launcher?.status).toBe('loading')
expect(launcher?.digest).toBe('compiling…')
})
})
7 changes: 6 additions & 1 deletion packages/hub/src/node/host-docks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export class DevframeDocksHost implements DevframeDocksHostType {
if (patch.id && patch.id !== view.id) {
throw diagnostics.DF8101({ id: view.id, attempted: patch.id })
}
this.update(Object.assign(this.views.get(view.id)!, patch))
// Merge into a fresh object rather than mutating the stored entry in
// place: once projected into the `devframe:docks` shared state, the
// stored entry is deep-frozen by Immer, so an in-place `Object.assign`
// would throw "Cannot assign to read only property". A new object is
// always writable, and `update()` swaps it into the registry.
this.update({ ...this.views.get(view.id)!, ...patch } as DevframeDockUserEntry)
},
}
}
Expand Down
Loading
Loading