@deepblend/dsh-blender-ui 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -2822,6 +2822,7 @@ window.__ModuleLoader__.load({
2822
2822
  let live = false
2823
2823
  let loadSequence = 0
2824
2824
  let diffSequence = 0
2825
+ let previewSourceGeneration = 0
2825
2826
  let creationAttempt = null
2826
2827
  const draftStorage = creationDraftStorage(settings)
2827
2828
  let creationDraftId = newCreationKey(), creationDraftRoot = null, persistedCreationSignature = null
@@ -2883,6 +2884,8 @@ window.__ModuleLoader__.load({
2883
2884
  }
2884
2885
  /** Change the snapshot and tell everyone. @param {object} patch */
2885
2886
  const set = (patch) => {
2887
+ if (['projectId', 'projectsRoot', 'activeProjectId']
2888
+ .some(key => Object.hasOwn(patch, key) && patch[key] !== data[key])) previewSourceGeneration += 1
2886
2889
  // Automatic edit images are source snapshots too. They cannot override
2887
2890
  // fresh rows from another store, even when its project/revision IDs match.
2888
2891
  if (Object.hasOwn(patch, 'projectsRoot') && patch.projectsRoot !== data.projectsRoot) {
@@ -4052,10 +4055,27 @@ window.__ModuleLoader__.load({
4052
4055
  },
4053
4056
 
4054
4057
  renderPreview: async () => {
4058
+ const projectId = data.activeProjectId, projectsRoot = data.projectsRoot, generation = previewSourceGeneration
4059
+ if (!projectId || data.previewBusy || data.busy.patch || data.busy.editor || data.busy.assembly || data.busy.restore) return
4055
4060
  setIn('notices', 'preview', null)
4056
4061
  set({ previewBusy: true, previewResult: null })
4057
- const outcome = await postJson(fetchImpl, projectRoute(target(), '/preview'), { revision: data.selected?.scene?.revision })
4058
- set({ previewBusy: false, ...(outcome.ok ? { compareMode: 'renders' } : {}) })
4062
+ // A save receipt can arrive before the asynchronous panel refresh.
4063
+ // Resolve the current revision from the Host instead of rendering the
4064
+ // cached scene. A failed read must never fall back to older geometry.
4065
+ const fresh = await readRoute(fetchImpl, `${ROUTES.state}?projectId=${encodeURIComponent(projectId)}&preview=${++tick}`, 'state')
4066
+ if (generation !== previewSourceGeneration || data.activeProjectId !== projectId || data.projectsRoot !== projectsRoot) {
4067
+ set({ previewBusy: false }); return
4068
+ }
4069
+ const selected = fresh.payload?.selected
4070
+ const coherent = fresh.status === 'ok' && fresh.payload.projectsRoot === projectsRoot
4071
+ && selected?.project?.projectId === projectId && selected?.scene?.revision
4072
+ && selected.currentRevision === selected.scene.revision
4073
+ const outcome = coherent
4074
+ ? await postJson(fetchImpl, projectRoute(projectId, '/preview'), { revision: selected.scene.revision })
4075
+ : { ok: false, error: fresh.error || { code: 'UI_PREVIEW_MISMATCH', message: t('preview.sourceMismatch') } }
4076
+ set({ previewBusy: false })
4077
+ if (generation !== previewSourceGeneration || data.activeProjectId !== projectId || data.projectsRoot !== projectsRoot) return
4078
+ if (outcome.ok) set({ compareMode: 'renders' })
4059
4079
  set({
4060
4080
  previewResult: outcome.ok
4061
4081
  ? {
@@ -4137,6 +4157,7 @@ window.__ModuleLoader__.load({
4137
4157
  void load()
4138
4158
  },
4139
4159
  stop() {
4160
+ previewSourceGeneration += 1
4140
4161
  loadSequence += 1
4141
4162
  diffSequence += 1
4142
4163
  closeCreationDraft()
@@ -5337,7 +5358,7 @@ window.__ModuleLoader__.load({
5337
5358
  Button({
5338
5359
  tone: 'primary',
5339
5360
  action: 'render-preview',
5340
- disabled: state.previewBusy || state.activeProjectId === null,
5361
+ disabled: state.previewBusy || state.activeProjectId === null || state.busy?.patch || state.busy?.editor || state.busy?.assembly || state.busy?.restore,
5341
5362
  onClick: actions.renderPreview,
5342
5363
  children: state.previewBusy ? t('preview.rendering') : t('preview.render'),
5343
5364
  }),
package/lib/index.js CHANGED
@@ -78,7 +78,7 @@ export const WORKBENCH_PAGE_ROOT_ID = 'deepblend-workbench'
78
78
  * because this page supplies no platform modules: React is a console seed
79
79
  * word, the workbench core does not use it, and `client.js` reads it lazily
80
80
  * precisely so that this call can pass `{}`.
81
- * 3. `import('@deepblend/dsh-blender-ui')` — the console's own graph row,
81
+ * 3. Import the mounted bundle client, or the independently installed UI client — the console's own graph row,
82
82
  * fetched from the console's own bundle route. There is no second copy of
83
83
  * the workbench anywhere for this to find.
84
84
  * 4. `mountStandalone(root)` — the one function that differs between the faces.
@@ -95,7 +95,10 @@ export function workbenchPageBootstrap(rootId) {
95
95
  try {
96
96
  await globalThis.__DSH_BOOT_READY__?.promise
97
97
  const modules = window.__ModuleLoader__.create({ boot: window.__DSH_BOOT__, staticModules: {} })
98
- const bundle = await modules.import('@deepblend/dsh-blender-ui')
98
+ const ownsBundleClient = (window.__DSH_BOOT__.entries || []).some(entry => entry.id === '@deepblend/dsh-blender-bundle')
99
+ const bundle = ownsBundleClient
100
+ ? await modules.import('@deepblend/dsh-blender-bundle')
101
+ : await modules.import('@deepblend/dsh-blender-ui')
99
102
  await bundle.mountStandalone(root)
100
103
  root.dataset.deepblendStandalone = 'ready'
101
104
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepblend/dsh-blender-ui",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "DeepBlend workbench UI: Host half (typed HTTP API) and Web Client half (sidebar, panels, tool cards).",
6
6
  "main": "lib/index.js",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@deepblend/dsh-blender-contracts": "0.6.0"
22
+ "@deepblend/dsh-blender-contracts": "0.6.2"
23
23
  },
24
24
  "license": "MIT",
25
25
  "repository": {