Skip to content

update exp imports to nx2#546

Open
hannessolo wants to merge 23 commits into
mainfrom
nx2-exp
Open

update exp imports to nx2#546
hannessolo wants to merge 23 commits into
mainfrom
nx2-exp

Conversation

@hannessolo

@hannessolo hannessolo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@aem-code-sync

aem-code-sync Bot commented Jun 24, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

claude and others added 2 commits June 25, 2026 11:23
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude and others added 2 commits June 25, 2026 13:01
exp/utils.js used nx2 loadIms while the block still rendered the nx1
profile, giving each side its own memoized promise against the same
window.adobeIMS. The second setup overwrote window.adobeid but imslib
had already fired onReady, so the nx2 promise timed out after 5s.

- exp.js: import nx2 profile element
- nx2 profile: dispatch loaded CustomEvent with _ims detail (matches
  nx1 contract that exp's @loaded handler relies on)
- nx2 ims: accept loginPopup arg, set modalMode + modalSettings so
  the iframe's sign-in opens a modal instead of redirecting

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When the consuming app hasn't called setConfig yet, getConfig returns
{ error } with no log function — so the catch handler in loadIms
itself threw a TypeError, masking the real underlying IMS error.
Fall back to console.warn, log the original error, and guard the
_ims.anonymous check so a thrown loadIms doesn't crash render.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The module-level destructure of imsClientId / imsScope / env races
with the host's setConfig() at module init time. In some load orders
(iframe contexts in particular) ims.js' TLA resolves before
setConfig() lands, pinning imsClientId to undefined — imslib then
hangs and the 5s timeout fires.

Move config resolution into setup() so the values used to build
window.adobeid are the latest, falling back to the module-level
capture if the call-time read returns nothing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
In the iframe + branch-URL context, imslib's onReady fires around
6-7s after load (vs typically <1s on prod). 5s was tripping the
timeout before imslib had a chance to settle, even though adobeIMS
ended up fully initialized with a valid token.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When loadIms is called after imslib has already been initialized
(another caller, page reload with persistent context, an earlier
script that loaded imslib), our setup would overwrite window.adobeid
with a fresh onReady but imslib never re-fires it — and we'd time
out after 5/15s even though a valid access token is available.

Short-circuit setup when window.adobeIMS exists: consume the existing
token directly (or resolve { anonymous: true }) instead of trying to
re-bootstrap imslib. Drops the temporary instrumentation added in
the previous commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
loc() crashed when called before setConfig completed, since
getConfig() returns { error } in that window and the strings
destructure was undefined. nx-profile's sign-in render hits this in
iframe contexts where the user is third-party-anonymous: the
sign-in button uses loc\`Sign in\`. Optional-chain the get so loc
falls back to the literal key (already the documented fallback)
instead of throwing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nx2 loadStyle no longer auto-loads styles into the document; it just
returns a constructable stylesheet for shadow adoption. SL's CSS
targets :root, which doesn't match inside a shadow tree, so the
--s2-* custom-property cascade was never set up and exp's typography
fell back to browser defaults (visible as oversized "Edit experiment"
heading and 50% slider label vs the prod build).

Adopt the same SL sheet on document so :root matches and the custom
properties inherit into the shadow tree as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
claude and others added 2 commits June 25, 2026 14:18
Real root cause was: window.adobeIMS already initialized by the time
our setup ran, so imslib never re-fired onReady. The short-circuit
in setup() handles that. With the right fix in place, several earlier
changes are no longer load-bearing:

- nx2/utils/ims.js: drop loginPopup/modalMode plumbing (da-live's
  initIms wins the setup race so it never takes effect anyway), drop
  the async setup + per-call resolveNxConfig re-read (the config-race
  hypothesis was wrong), restore IMS_TIMEOUT to 5s.
- nx2/blocks/profile/profile.js: drop defensive config.log fallback
  and _ims guard in loadIms — loadIms no longer throws on happy path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
claude and others added 2 commits June 25, 2026 16:13
Root cause of the IMS timeout: da-live's /plugins/exp page lacks
<meta name="nxver">, so it boots in nx1 mode and initIms imports
nx/utils/ims.js. But this branch's exp block statically imports the
nx2 profile, which pulls in nx2/utils/ims.js. Two loadIms modules
in the same window, each bootstrapping imslib — the second one's
onReady never fires because imslib reads adobeid once at load time.

Append nxver=2 to the iframe URL so da-live runs nx2 inside it.
Then initIms uses the same loadIms module as exp's statics, single
memoization, single setup. Applied to both the main and branched
EXP_SRC paths so the fix holds once the migration lands on main.

Revert the defensive short-circuit in nx2/utils/ims.js — no longer
needed once the modules are aligned, and the bootstrap function
goes back to byte-identical with main.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Re-apply the nxver=2 flag on the iframe src (proper root-cause fix
for dual loadIms memoization) and rename --spacing-100/200/300 to
--s2-spacing-100/200/300 in exp/views/{new,edit,login}.css. The
nx2 styles.css renamed the spacing scale; values are identical
(8/12/16px) so this is a pure name rename.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
With nxver=2, the iframe body becomes a CSS grid (nx2 styles target
[meta content=app-frame]). The grid puts <main> in the named "main"
area; <nx-exp> is appended later and auto-placed in an implicit row,
but its 650px intrinsic height overflows into main's area and they
overlap. main has position: relative, so it paints above the static
nx-exp host, hiding the palette body. Set :host position: relative
+ z-index: 1 so nx-exp wins the stacking order. No-op under nx1
(body isn't a grid; positioning doesn't change visual layout).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
imslib's default signIn() redirects the current frame to the IMS
login page. In an iframe context that redirect is blocked by IMS's
X-Frame-Options, so clicking "Sign in" in the exp palette
(which lives in a da-live iframe inside the customer page) fails.

Set window.adobeid.modalMode = true + modalSettings.allowedOrigin
when window.self !== window.top so imslib uses its popup flow
instead. modalSettings.allowedOrigin scopes the postMessage callback
back to our own origin. No behavior change for top-level contexts.

The earlier loginPopup arg on loadIms was insufficient because
da-live's initIms() is the first caller (no args) and the
memoized promise locked in modalMode: undefined.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The slider bar was being drawn with input[type=range]::after, but
::before/::after pseudo-elements don't apply to form controls per
spec and current Chrome no longer paints them. Result: the slider
thumb was visible but the track was missing.

Switch to ::-webkit-slider-runnable-track and ::-moz-range-track
(the standards-compliant track pseudos). Adjust the thumb margin-top
to center it on the 2px track (-7px = -(thumb-height/2) + (track-height/2)).
Add a ::-moz-range-thumb sibling to match the webkit thumb in Firefox.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Firefox needs appearance: none on ::-moz-range-thumb explicitly —
appearance on the input itself doesn't propagate to the thumb, so
without it Firefox keeps its default rectangular UA thumb.

The percent label was positioned with top: -10px relative to the
wrapper. After switching the track from ::after to the proper track
pseudo, the input/wrapper got shorter, and -10px no longer cleared
the label's text body past the bar. Anchor it with bottom: 100%
instead so it always floats above the wrapper regardless of the
wrapper's own height, plus a 2px gap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
sharanyavinod
sharanyavinod previously approved these changes Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[nx2] EXP

3 participants