Repository navigation
[COMMEX-2353] Let a dom-bundle UI extension request host actions - #1546
Open
jolinger-godaddy wants to merge 1 commit into
Open
jolinger-godaddy wants to merge 1 commit into
jolinger-godaddy wants to merge 1 commit into
Conversation
The mount input carries an optional requestAction. Target and UiExtensionRuntimeHost take an onActionRequest handler; without one, requests reject with action_rejected.
🦋 Changeset detectedLatest commit: f8451ed The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
dom-bundleUI extension has no way to ask its host to do anything. The runtime already has anonActionRequestmount option, but nothing reaches it. This adds the channel, opt-in on both sides.DomExtensionMountInputgets an optionalrequestAction({ action, input }). It resolves with the host's result. The same function stays valid for the life of the mount and always reaches the host's current committed handler.TargetandUiExtensionRuntimeHosttake an optionalonActionRequest(request, source). Changing it doesn't remount the extension.source.extensionis built from the host's own record of the extension, so a bundle can't change what was checked or pass itself off as another extension. The extension gets a structured clone of the result.action_rejectedruntime error when there's no handler, the host rejects, a value can't be cloned, the action name is missing, blank or has spaces around it, or the extension unmounts, including while a request is still waiting on the host. The host's own reason never goes back to the extension.onActionRequestmount option gets an optional secondsourceargument, so existing runtimes that call it with the request alone still compile.getEnabledStoreUiExtensions({ storeId, target, apiHost }): the same discovery requestuseEnabledStoreUiExtensionssends, for hosts that pick a target's extensions before they render.requestAction, and older hosts don't pass a handler.Changeset
@godaddy/reactminor.Test Plan
dom-bundle-runtime.test.ts: request and source reach the handler; metadata comes from the host's record, taken at mount, after the bundle or the record changes; request read once and cloned; an unreadable action name; uncloneable input rejected without calling the host; result cloned; host rejection rebuilt without its reason; no handler; no action name; after unmount; pending request rejected at unmount; requests during a failed mount's cleanup never reach the host; uncloneable result; padded names; a newer mount during load, during a failed mount's cleanup, during an earlier unmount and during a queued update; one unmount when the host unmounts before or during a failed queued update's cleanup.runtime-host.test.tsx(new): a new handler is used without a remount; no handler rejects.discovery.test.ts(new): the non-hook read sends the hook's request, and sends nothing without a store id or target.target.test.tsx:onActionRequestgets the request and the extension's metadata.pnpm vitest run src/ui-extensions(48 passing),tsc --noEmit, andbiome checkon the changed files.