@huaqiu/dsh-hardware-ui 0.7.18 → 0.7.20

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.
@@ -0,0 +1,255 @@
1
+ /**
2
+ * STEP / STP document renderer.
3
+ *
4
+ * Why direct parsing, not host-side conversion: the ordering spec demands the
5
+ * model be viewable without launching SolidCraft and without asking the user to
6
+ * convert anything (§6.2), and this repository already had a proven
7
+ * browser-side path for mechanical formats — `occt-import-js` (OpenCascade
8
+ * compiled to WebAssembly), vendored in `web-vue` for exactly this purpose.
9
+ * With it the `.step`/`.stp` file stays authoritative, nothing is derived, no
10
+ * cache can go stale, and the whole pipeline runs offline because the `.wasm`
11
+ * ships in the package rather than at a CDN URL.
12
+ *
13
+ * The cost is stated instead of hidden: the reader is a synchronous WebAssembly
14
+ * call, so a pathological model blocks the main thread while it tessellates.
15
+ * The size gate below is what bounds that, and the reader instance is created
16
+ * once per page and shared — the 7.6 MB `.wasm` is compiled a single time no
17
+ * matter how many STEP documents are opened.
18
+ *
19
+ * Resource ownership: everything this module creates (geometries, materials,
20
+ * renderer, controls, observers, canvas) is released by `dispose()`. Nothing is
21
+ * cached per document, so closing a tab leaves no model behind.
22
+ *
23
+ * @module @huaqiu/dsh-hardware-ui/client/document/step
24
+ */
25
+
26
+ import {
27
+ AmbientLight, Box3, BufferGeometry, Color, DirectionalLight, DoubleSide, Float32BufferAttribute, Group,
28
+ HemisphereLight, Mesh, MeshStandardMaterial, PerspectiveCamera, Scene, Vector3, WebGLRenderer,
29
+ } from 'three'
30
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
31
+ import occtimportjs, { type OcctModule } from 'occt-import-js'
32
+ import { DocumentRenderError, waitForLayout, DEFAULT_RENDER_TIMEOUT_MS } from './mount.js'
33
+
34
+ /** A live 3D document body. */
35
+ export interface MountedStepDocument {
36
+ /** Release every GPU resource, listener, observer and element this mount created. Idempotent. */
37
+ dispose(): void
38
+ /** Re-fit the camera to the model bounds. */
39
+ fit(): void
40
+ }
41
+
42
+ /** Largest STEP document this renderer will tessellate. */
43
+ export const MAX_STEP_BYTES = 32 * 1024 * 1024
44
+
45
+ /** Neutral steel that reads as machined metal under the two-light rig below. */
46
+ const DEFAULT_MATERIAL_COLOR = 0xb8bcc4
47
+
48
+ /** One shared reader instance per page: compiling the module again per document would cost seconds. */
49
+ let readerPromise: Promise<OcctModule> | undefined
50
+
51
+ function messageOf(error: unknown): string {
52
+ return error instanceof Error ? error.message : typeof error === 'string' ? error : 'unknown error'
53
+ }
54
+
55
+ /**
56
+ * Instantiate the OpenCascade reader from locally served wasm bytes.
57
+ * @param wasmUrl - same-origin URL of the packaged `occt-import-js.wasm`.
58
+ * @param signal - document lifetime; cancels the download only.
59
+ * @returns the ready module, cached for the page.
60
+ */
61
+ export function loadOcctReader(wasmUrl: string, signal: AbortSignal): Promise<OcctModule> {
62
+ readerPromise ??= (async () => {
63
+ let response: Response
64
+ try {
65
+ response = await fetch(wasmUrl, { credentials: 'same-origin' })
66
+ } catch (error) {
67
+ readerPromise = undefined
68
+ throw new DocumentRenderError('render', `wasm fetch failed: ${messageOf(error)}`)
69
+ }
70
+ if (!response.ok) {
71
+ readerPromise = undefined
72
+ throw new DocumentRenderError('render', `wasm fetch failed: HTTP ${response.status}`)
73
+ }
74
+ const wasmBinary = await response.arrayBuffer()
75
+ try {
76
+ return await occtimportjs({ wasmBinary })
77
+ } catch (error) {
78
+ readerPromise = undefined
79
+ throw new DocumentRenderError('render', `wasm instantiation failed: ${messageOf(error)}`)
80
+ }
81
+ })()
82
+ // The download is the only cancellable part; instantiation itself is atomic.
83
+ return readerPromise.catch((error: unknown) => {
84
+ if (signal.aborted) throw new DocumentRenderError('aborted', 'render abandoned')
85
+ throw error instanceof DocumentRenderError ? error : new DocumentRenderError('render', messageOf(error))
86
+ })
87
+ }
88
+
89
+ /** Drop the cached reader, so the next mount reloads it. Used by tests and by a failed load. */
90
+ export function resetOcctReader(): void {
91
+ readerPromise = undefined
92
+ }
93
+
94
+ export interface StepDocumentRequest {
95
+ /** Exact `.step`/`.stp` bytes; the source file is never modified. */
96
+ readonly bytes: Uint8Array
97
+ readonly container: HTMLElement
98
+ readonly signal: AbortSignal
99
+ /** Same-origin URL of the packaged reader wasm. */
100
+ readonly wasmUrl: string
101
+ readonly timeoutMs?: number
102
+ }
103
+
104
+ /**
105
+ * Tessellate one STEP/STP document and show it with orbit, pan and zoom.
106
+ * @param request - bytes, target container, lifetime, wasm source.
107
+ * @returns the live mount; call `dispose()` when the document closes or reloads.
108
+ */
109
+ export async function mountStepDocument(request: StepDocumentRequest): Promise<MountedStepDocument> {
110
+ const { bytes, container, signal, wasmUrl } = request
111
+ const timeoutMs = request.timeoutMs ?? DEFAULT_RENDER_TIMEOUT_MS
112
+ if (signal.aborted) throw new DocumentRenderError('aborted', 'render abandoned')
113
+ if (bytes.byteLength === 0) throw new DocumentRenderError('parse', 'file is empty')
114
+ if (bytes.byteLength > MAX_STEP_BYTES) {
115
+ throw new DocumentRenderError('toolarge', `${bytes.byteLength} bytes exceeds ${MAX_STEP_BYTES}`)
116
+ }
117
+
118
+ await waitForLayout(container, signal)
119
+ if (signal.aborted) throw new DocumentRenderError('aborted', 'render abandoned')
120
+
121
+ const reader = await loadOcctReader(wasmUrl, signal)
122
+ if (signal.aborted) throw new DocumentRenderError('aborted', 'render abandoned')
123
+
124
+ let importResult
125
+ try {
126
+ importResult = reader.ReadStepFile(bytes, null)
127
+ } catch (error) {
128
+ throw new DocumentRenderError('parse', messageOf(error))
129
+ }
130
+ if (!importResult.success || importResult.meshes.length === 0) {
131
+ throw new DocumentRenderError('parse', 'no solid geometry')
132
+ }
133
+
134
+ const scene = new Scene()
135
+ const group = new Group()
136
+ const geometries: BufferGeometry[] = []
137
+ const materials: MeshStandardMaterial[] = []
138
+ for (const mesh of importResult.meshes) {
139
+ const geometry = new BufferGeometry()
140
+ geometry.setAttribute('position', new Float32BufferAttribute([...mesh.attributes.position.array], 3))
141
+ if (mesh.attributes.normal !== undefined) {
142
+ geometry.setAttribute('normal', new Float32BufferAttribute([...mesh.attributes.normal.array], 3))
143
+ }
144
+ if (mesh.index !== undefined) geometry.setIndex([...mesh.index.array])
145
+ if (mesh.attributes.normal === undefined) geometry.computeVertexNormals()
146
+ const rgb = mesh.color
147
+ const material = new MeshStandardMaterial({
148
+ color: rgb !== undefined && rgb.length >= 3
149
+ ? new Color(rgb[0] ?? 0.7, rgb[1] ?? 0.7, rgb[2] ?? 0.7)
150
+ : new Color(DEFAULT_MATERIAL_COLOR),
151
+ metalness: 0.25,
152
+ roughness: 0.55,
153
+ // Imported solids do not guarantee consistent winding; a single-sided
154
+ // material would show holes on inverted faces.
155
+ side: DoubleSide,
156
+ })
157
+ materials.push(material)
158
+ geometries.push(geometry)
159
+ const object = new Mesh(geometry, material)
160
+ object.name = mesh.name ?? ''
161
+ group.add(object)
162
+ }
163
+ scene.add(group)
164
+
165
+ scene.add(new AmbientLight(0xffffff, 0.55))
166
+ scene.add(new HemisphereLight(0xffffff, 0x30343c, 1.1))
167
+ const key = new DirectionalLight(0xffffff, 2.1)
168
+ key.position.set(1, 1.6, 1.1)
169
+ scene.add(key)
170
+ const fill = new DirectionalLight(0xffffff, 0.9)
171
+ fill.position.set(-1.2, -0.8, -0.7)
172
+ scene.add(fill)
173
+
174
+ let renderer: WebGLRenderer
175
+ try {
176
+ renderer = new WebGLRenderer({ antialias: true, alpha: true })
177
+ } catch (error) {
178
+ for (const geometry of geometries) geometry.dispose()
179
+ for (const material of materials) material.dispose()
180
+ throw new DocumentRenderError('render', `webgl unavailable: ${messageOf(error)}`)
181
+ }
182
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2))
183
+
184
+ const bounds = new Box3().setFromObject(group)
185
+ const center = bounds.getCenter(new Vector3())
186
+ const size = bounds.getSize(new Vector3())
187
+ const radius = Math.max(size.x, size.y, size.z, 0.001) / 2
188
+ const camera = new PerspectiveCamera(45, 1, Math.max(radius / 1000, 0.01), radius * 1000)
189
+
190
+ const fit = (): void => {
191
+ const distance = (radius / Math.sin((camera.fov * Math.PI) / 360)) * 1.15
192
+ const direction = new Vector3(0.9, 0.65, 1).normalize()
193
+ camera.position.copy(center).addScaledVector(direction, distance)
194
+ camera.near = Math.max(radius / 1000, 0.01)
195
+ camera.far = distance * 20
196
+ camera.updateProjectionMatrix()
197
+ controls.target.copy(center)
198
+ controls.update()
199
+ draw()
200
+ }
201
+
202
+ const controls = new OrbitControls(camera, renderer.domElement)
203
+ controls.enableDamping = false
204
+ controls.screenSpacePanning = true
205
+
206
+ const canvas = renderer.domElement
207
+ canvas.style.cssText = 'position:absolute;inset:0;display:block;width:100%;height:100%;outline:none;touch-action:none'
208
+ canvas.dataset.stepCanvas = ''
209
+ container.append(canvas)
210
+
211
+ let frame = 0
212
+ const draw = (): void => {
213
+ if (frame !== 0) return
214
+ frame = requestAnimationFrame(() => {
215
+ frame = 0
216
+ renderer.render(scene, camera)
217
+ })
218
+ }
219
+ const resize = (): void => {
220
+ const width = Math.max(container.clientWidth, 1)
221
+ const height = Math.max(container.clientHeight, 1)
222
+ renderer.setSize(width, height, false)
223
+ camera.aspect = width / height
224
+ camera.updateProjectionMatrix()
225
+ draw()
226
+ }
227
+ const onControls = (): void => { draw() }
228
+ const onDoubleClick = (): void => { fit() }
229
+ controls.addEventListener('change', onControls)
230
+ renderer.domElement.addEventListener('dblclick', onDoubleClick)
231
+ const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(resize)
232
+ observer?.observe(container)
233
+ resize()
234
+ fit()
235
+
236
+ let disposed = false
237
+ return {
238
+ fit,
239
+ dispose: () => {
240
+ if (disposed) return
241
+ disposed = true
242
+ if (frame !== 0) cancelAnimationFrame(frame)
243
+ observer?.disconnect()
244
+ controls.removeEventListener('change', onControls)
245
+ controls.dispose()
246
+ renderer.domElement.removeEventListener('dblclick', onDoubleClick)
247
+ for (const geometry of geometries) geometry.dispose()
248
+ for (const material of materials) material.dispose()
249
+ scene.clear()
250
+ group.clear()
251
+ renderer.dispose()
252
+ canvas.remove()
253
+ },
254
+ }
255
+ }
@@ -18,16 +18,25 @@
18
18
  * scope").
19
19
  */
20
20
  import { HardwareSettingsSection, HardwareViewerBody } from './components.js'
21
+ import { ToolchainIndicator, ToolchainToastHost } from './toolchain-view.js'
22
+ import { TOOLCHAIN_ONBOARDING_STEP, ToolchainOnboarding } from './wizard.js'
23
+ import { ToolchainController } from './toolchain.js'
21
24
  import type {
22
25
  ConfigFormLike, HardwareController, HardwareDestination, HardwareInstallationConfig,
23
26
  ViewerNavigationParams,
24
27
  } from './model.js'
25
28
  import { createHardwareStore } from './store.js'
26
- import { COPY } from './copy.js'
29
+ import { COPY, HARDWARE_UI_NS, installCopyLocale, type CopyLocale } from './copy.js'
27
30
  import { loadInstallations, loadProjects, openArtifact } from './transport.js'
31
+ import { installDocumentPreviews } from './document/index.js'
32
+ import { setOrderPageOpener } from './order-page.js'
33
+ import { ORDER_TAB_ID, ORDER_TAB_KIND, OrderTabBody, orderTabRegistration } from './order-tab.js'
34
+ import { OrderWatcher } from './order-watcher.js'
35
+ import type { DocumentClientContext, WorkspaceFilesRemote } from './document/contract.js'
36
+ import type { ProbeSheetFile } from './document/EcadBody.js'
28
37
 
29
38
  /** Real Cordis service names this browser plugin waits for. */
30
- export const inject = ['slots', 'sidebarRight', 'sidebarRightTabs', 'configForms'] as const
39
+ export const inject = ['slots', 'locale', 'sidebarRight', 'sidebarRightTabs', 'configForms'] as const
31
40
 
32
41
  export const HARDWARE_SETTINGS_ID = 'hardware-engineering'
33
42
  export const HARDWARE_TAB_ID = '@huaqiu/dsh-hardware-ui'
@@ -41,6 +50,8 @@ interface SlotSpec {
41
50
  key?: string
42
51
  order?: number
43
52
  label?: () => string
53
+ /** Makes the renderer re-derive the entry's `t` seat on a locale switch. */
54
+ locale?: string
44
55
  store?: unknown
45
56
  inject?: (...args: unknown[]) => unknown
46
57
  }
@@ -50,6 +61,8 @@ interface ClientContext {
50
61
  inject(key: string, callback: () => () => void): () => void
51
62
  register(spec: SlotSpec, component: unknown): () => void
52
63
  }
64
+ /** DSH's locale service; optional so a Host without it still gets the panel. */
65
+ readonly locale?: CopyLocale
53
66
  readonly sidebarRight?: {
54
67
  openTab(kind: string, options?: {
55
68
  params?: Readonly<Record<string, unknown>>
@@ -61,6 +74,8 @@ interface ClientContext {
61
74
  id: string
62
75
  kind: string
63
76
  keepMounted?: boolean
77
+ /** One tab per order; without it every order would share one page. */
78
+ multiple?: boolean
64
79
  title: (address: string) => string
65
80
  /**
66
81
  * Seed this kind into a fresh docked pane, i.e. make it the page the
@@ -72,7 +87,55 @@ interface ClientContext {
72
87
  readonly configForms?: {
73
88
  get<T>(entryId: string): ConfigFormLike<T>
74
89
  }
90
+ /**
91
+ * Workspace byte reads, used to resolve the child sheets a schematic declares.
92
+ *
93
+ * Readable only from inside a nested `inject(['remote', …])` scope: Cordis
94
+ * throws `cannot get property "remote" without inject` on a direct access, and
95
+ * declaring `remote` on the whole plugin would drop the product panel on a
96
+ * Host that has no client remote.
97
+ */
98
+ readonly remote?: { readonly workspaceFiles?: WorkspaceFilesRemote }
99
+ /** DSH's document-renderer registry; absent on a Host without document previews. */
100
+ readonly documentPreviews?: DocumentClientContext['documentPreviews']
75
101
  effect?(fn: () => (() => void) | void, label?: string): void
102
+ inject?(dependencies: readonly string[], callback: (scope: ClientContext) => void): void
103
+ }
104
+
105
+ /** Holder for a dependency that arrives after this plugin installs its renderers. */
106
+ interface WorkspaceHolder {
107
+ files?: WorkspaceFilesRemote
108
+ }
109
+
110
+ /**
111
+ * Build the child-sheet probe for the document renderers.
112
+ *
113
+ * Existence is answered by the Host, not by this plugin: a one-byte read through
114
+ * the session's own workspace endpoint either succeeds or reports a structured
115
+ * failure. Nothing here decides what the workspace contains — that is precisely
116
+ * the authority the document preview must not duplicate.
117
+ *
118
+ * The remote is read from a holder, not off the context: the dependency is
119
+ * acquired by nested injection (see `apply`), which resolves after the renderers
120
+ * are registered, and resolving it per mount means a schematic opened later still
121
+ * gets a working probe. While it is absent the factory answers `undefined`, which
122
+ * the body already treats as "list the references, do not claim they exist".
123
+ * @param workspace - holder filled by nested injection once `remote` is available.
124
+ * @returns a per-session probe factory that stays usable across a late dependency.
125
+ */
126
+ function sheetProbeFactory(workspace: WorkspaceHolder): (sessionId: string) => ProbeSheetFile | undefined {
127
+ return sessionId => {
128
+ const files = workspace.files
129
+ if (files === undefined) return undefined
130
+ return async (path, signal) => {
131
+ try {
132
+ const result = await files.readBytes(sessionId, path, { range: { offset: 0, length: 1 } }, signal)
133
+ return result.ok
134
+ } catch {
135
+ return false
136
+ }
137
+ }
138
+ }
76
139
  }
77
140
 
78
141
  /** Artifact kind discriminator carried in navigation params. */
@@ -102,6 +165,13 @@ export function apply(ctx: ClientContext): void {
102
165
  else fn()
103
166
  }
104
167
 
168
+ // Register the product's zh/en dictionaries with DSH's locale service and
169
+ // bind the copy facade to the active language. Everything below reads through
170
+ // that facade, so a language switch follows the host setting without any
171
+ // render site knowing about locales.
172
+ const disposeCopy = installCopyLocale(ctx.locale)
173
+ effect(() => disposeCopy, 'hardware-ui: dictionaries')
174
+
105
175
  const controller: HardwareController = {
106
176
  discover(cwd, project, session) {
107
177
  return loadProjects(cwd, project, session)
@@ -144,6 +214,21 @@ export function apply(ctx: ClientContext): void {
144
214
  },
145
215
  }
146
216
 
217
+ // One toolchain controller for every seat (§10.5). Created here, not inside a
218
+ // component, so the wizard step, the Settings section, the notices and the
219
+ // sidebar dot share one poll and one idea of what is configured — and a
220
+ // download keeps running while the user navigates or closes the panel.
221
+ const toolchain = new ToolchainController()
222
+ const face = { ...controller, toolchain }
223
+ effect(() => { toolchain.start(); return () => { toolchain.stop() } }, 'hardware-ui: toolchain capability')
224
+
225
+ effect(() => ctx.sidebarRightTabs?.register({
226
+ id: ORDER_TAB_ID,
227
+ kind: ORDER_TAB_KIND,
228
+ multiple: true,
229
+ title: () => COPY.order.tabTitle,
230
+ }) ?? (() => {}), 'hardware-ui: order tab type')
231
+
147
232
  effect(() => ctx.sidebarRightTabs?.register({
148
233
  id: HARDWARE_TAB_ID,
149
234
  kind: HARDWARE_TAB_KIND,
@@ -160,16 +245,99 @@ export function apply(ctx: ClientContext): void {
160
245
  effect(() => slots.inject('sidebar.right.pane.tab', () => slots.register({
161
246
  name: 'sidebar.right.pane.tab',
162
247
  key: HARDWARE_TAB_ID,
248
+ locale: HARDWARE_UI_NS,
163
249
  store: viewerStore,
164
- inject: () => controller,
250
+ inject: () => face,
165
251
  }, HardwareViewerBody)), 'hardware-ui: viewer body')
166
252
 
253
+ effect(() => slots.inject('sidebar.right.pane.tab', () => slots.register(
254
+ orderTabRegistration() as never,
255
+ OrderTabBody,
256
+ )), 'hardware-ui: order page body')
257
+
167
258
  effect(() => slots.inject('settings.section', () => slots.register({
168
259
  name: 'settings.section',
169
260
  id: HARDWARE_SETTINGS_ID,
170
261
  order: 85,
171
262
  label: () => COPY.product.name,
263
+ locale: HARDWARE_UI_NS,
172
264
  store: rootStore,
173
- inject: () => controller,
265
+ inject: () => face,
174
266
  }, HardwareSettingsSection)), 'hardware-ui: CAD installation settings')
267
+
268
+ // First run is a `settings.onboarding` step, not a panel drawer: the shell
269
+ // mounts it on a blank first session, and the step owns its own modal chrome.
270
+ // Registering here also makes `openOnboarding('hardware-engineering-toolchain')`
271
+ // work from the launcher when a user wants the wizard back.
272
+ effect(() => slots.inject('settings.onboarding', () => slots.register({
273
+ name: 'settings.onboarding',
274
+ id: TOOLCHAIN_ONBOARDING_STEP,
275
+ order: 12,
276
+ label: () => COPY.toolchain.onboardingTitle,
277
+ locale: HARDWARE_UI_NS,
278
+ inject: () => ({ toolchain, configForm: () => ctx.configForms?.get<HardwareInstallationConfig>(HARDWARE_CONFIG_ENTRY) }),
279
+ }, ToolchainOnboarding)), 'hardware-ui: toolchain onboarding step')
280
+
281
+ // Notices ride the shell overlay (§11): a download that finished while the
282
+ // user was reading a schematic must still reach them, and no failure here
283
+ // opens a modal.
284
+ effect(() => slots.inject('shell.overlay', () => slots.register({
285
+ name: 'shell.overlay',
286
+ id: 'hardware-ui-toolchain-toasts',
287
+ locale: HARDWARE_UI_NS,
288
+ inject: () => ({ controller: toolchain }),
289
+ }, ToolchainToastHost)), 'hardware-ui: toolchain notices')
290
+
291
+ // The quiet sidebar dot (§10.4): visible only while a tool is still missing,
292
+ // and never a second badge on the settings toggle (that seat is single and
293
+ // owned by the desktop-update indicator).
294
+ effect(() => slots.inject('sidebar.footer.action', () => slots.register({
295
+ name: 'sidebar.footer.action',
296
+ id: 'hardware-ui-toolchain-indicator',
297
+ order: 10,
298
+ locale: HARDWARE_UI_NS,
299
+ inject: () => ({ controller: toolchain }),
300
+ }, ToolchainIndicator)), 'hardware-ui: toolchain indicator')
301
+
302
+ // An order page belongs in the panel beside its board, not in the OS browser.
303
+ // `browser` is DSH's own tab kind; when this Host has no sidebar or no such
304
+ // kind, the opener reports failure and `openOrderPage` falls back, so a placed
305
+ // order is never lost to a missing tab.
306
+ setOrderPageOpener(url => {
307
+ const tabs = ctx.sidebarRight
308
+ if (tabs === undefined) return false
309
+ tabs.openTab(ORDER_TAB_KIND, { params: { url }, revealIfOpened: true })
310
+ return true
311
+ })
312
+
313
+ // Agent-driven orders end in a tool result, which no client code sees. The
314
+ // watcher reads the transcript and opens the page through the same opener.
315
+ effect(() => slots.inject('conversation.session.header.actions', () => slots.register({
316
+ name: 'conversation.session.header.actions',
317
+ id: 'hardware-ui-order-watcher',
318
+ order: 999,
319
+ inject: () => ({}),
320
+ }, OrderWatcher)), 'hardware-ui: order page in a Browser tab')
321
+
322
+ // Document renderers ride DSH's own document pipeline: they contribute four
323
+ // registry entries and four bodies, and nothing else. Installed through a
324
+ // nested injection so a Host without the document-preview service loses only
325
+ // the ECAD previews, not the product panel.
326
+ //
327
+ // The same applies to the child-sheet probe's dependency: `remote` is acquired
328
+ // in its own nested injection rather than read off `ctx` (Cordis throws on an
329
+ // undeclared access) or declared plugin-wide (which would take the product
330
+ // panel down with it on a Host without a client remote).
331
+ const workspace: WorkspaceHolder = {}
332
+ const documentOptions = { probeSheet: sheetProbeFactory(workspace) }
333
+ if (ctx.inject !== undefined) {
334
+ ctx.inject(['remote', 'remote.workspaceFiles'], (scope) => {
335
+ workspace.files = scope.remote?.workspaceFiles
336
+ })
337
+ ctx.inject(['documentPreviews'], (scope) => {
338
+ installDocumentPreviews(scope as unknown as DocumentClientContext, documentOptions)
339
+ })
340
+ } else {
341
+ installDocumentPreviews(ctx as unknown as DocumentClientContext, documentOptions)
342
+ }
175
343
  }