The Trimble Connect Workspace API facilitates interaction between client applications and the Trimble Connect Web application, including the 3D Viewer. It primarily uses `window.postMessage()` for secure communication, allowing for two main integration patterns: embedding Trimble Connect Web Modules or the 3D Viewer within an `iframe` in a client application, or embedding the client application itself as an extension within Trimble Connect Web or the 3D Viewer. This library, currently at version 0.3.34, is actively maintained, with release notes and updates frequently published by Trimble. Its key differentiator is providing a standardized, type-safe interface for programmatic control and data exchange within the Trimble Connect ecosystem, abstracting the complexities of cross-origin `postMessage` communication.
npm install trimble-connect-workspace-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to the Trimble Connect Workspace API as an extension, retrieving project details, setting a UI status message, and dynamically updating the extension's menu. It includes basic error handling and event listening.
Migrate all existing integrations from `trimble-connect-project-workspace-api` to `trimble-connect-workspace-api`. Ensure your `package.json` reflects the correct dependency and update import statements and API calls according to the new API's documentation.
Configure your server to respond with appropriate CORS headers (`Access-Control-Allow-Origin`, `Access-Control-Allow-Methods`, etc.) for the manifest file URL. For development, `Access-Control-Allow-Origin: *` might suffice, but for production, restrict `Access-Control-Allow-Origin` to `web.connect.trimble.com` or other official Trimble Connect domains.
Always use the provided `WorkspaceAPI.connect()` method and its returned instance for all communications. Avoid direct `window.postMessage()` calls unless absolutely necessary and ensure robust origin validation if custom `postMessage` handling is implemented. Review Trimble Connect's security guidelines for extensions.
Update any hardcoded URLs or bookmarks pointing to the old 3D Viewer domain (`3d.connect.trimble.com`) to use the new domain (`web.connect.trimble.com`). While the old domain continued to work for a transitional period, it is no longer supported.
Ensure `await WorkspaceAPI.connect(...)` is used within an `async` function. Check the console for connection errors or timeouts. Verify the target window (`window.parent` for extensions, `iframe.contentWindow` for embedded viewers) is accessible and ready, and that the Trimble Connect application is loaded and listening. Increase the timeout if necessary.
Ensure that the Trimble Connect Workspace API is initialized correctly via `WorkspaceAPI.connect()` with the appropriate target window, as it handles the cross-origin `postMessage` communication securely. Avoid direct JavaScript access to `iframe.contentWindow` properties (e.g., `iframe.contentWindow.document`) if the origins differ. Verify that if you are embedding a Trimble Connect component, the `iframe` itself is correctly configured and the host application is properly allowing cross-origin communication as per Trimble's guidelines.
Configure your web server to include `Access-Control-Allow-Origin` headers for your `manifest.json` file. For development, `Access-Control-Allow-Origin: *` can be used. For production, specify `web.connect.trimble.com` (and other relevant Trimble Connect domains) as the allowed origin.
No dependency data recorded yet.