Visitar URL original
docs(architecture): define the iDevice runtime contract (#2511) by erseco · Pull Request #2513 · exelearning/exelearning · GitHub
Skip to content

docs(architecture): define the iDevice runtime contract (#2511) - #2513

Open
erseco wants to merge 7 commits into
mainfrom
feature/2511-idevice-runtime-contract
Open

erseco wants to merge 7 commits into
mainfrom
feature/2511-idevice-runtime-contract

Conversation

@erseco

@erseco erseco commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #2511

Thanks @ignaciogros for opening this and for spotting the pattern behind #2170 and #2510.

Problem

iDevice runtime scripts, the two hosts that drive them (exe_export.js on exported pages, IdeviceNode / IdevicesEngine in the editor) and the shared libraries have no written contract. Every enhancement and every teardown gets wired again case by case: #2170 (effects), #2510 (lightbox), #2271 / #2293 (edition teardown), and #2434 (the editor reloads the whole page after a remote edit because runtimes act page-wide).

What this PR adds (documentation only)

Change directory doc/architecture/changes/2511-idevice-runtime-contract/:

  • proposal.md: motivation, problem, scope, goals and non-goals.
  • spec.md: the contract, as numbered requirements (R2–R8), scenarios and acceptance criteria:
    • instance identity by component id;
    • render lifecycle: view → mount → behaviour → init (may return a Promise) → enhance → rendered, with an error boundary and a timeout per instance;
    • self-updates through $exe.ideviceRuntime.rendered(node, 'update');
    • one enhancement step whose entries take a context and are idempotent;
    • ready signal: the exe-idevice-rendered event per instance and exe-idevices-rendered per page, replacing the 200 ms delays before print and search highlighting;
    • teardown through $exe.ideviceRuntime.destroy(node) and an optional destroyRuntime hook;
    • compatibility with legacy runtimes.
  • design.md: how it is built. A new host-neutral classic script, exe_idevice_runtime.js, is loaded by both hosts; it is needed because exe_export.js is not loaded in the workarea. The design also covers the changes to each host, migration, security, accessibility, performance and testing.
  • research.md: a survey of all 53 base iDevices and the shared enhancements, with file and line evidence. It covers which runtimes act page-wide, which work asynchronously after init, which resources leak, and which enhancements are not idempotent.
  • tasks.md: a phased adoption plan, one PR per step. The runtime core and the enhancement list come first, then the editor host, then the jsonOnlyIdevices one by one, then the gamification helpers. The HTML-type games get a separate follow-up issue.

ADRs, all Proposed:

  • ADR-2511-01: run every iDevice instance through one render lifecycle that ends in a DOM event.
  • ADR-2511-02: share one enhancement step between the editor and exported pages. It builds on ADR-2510-01 from Export: bind lightbox links in iDevices rendered after page init. #2512.
  • ADR-2511-03: own exported iDevice resources with a lifecycle shared with editions. It is the runtime counterpart of ADR-2293-01.

Decisions to review

  1. Ready signal: a DOM CustomEvent (exe-idevice-rendered, with reason and status in detail). init may return a Promise, which the host waits for under a timeout. Sync iDevices need no change.
  2. Enhancement step: $exe.ideviceRuntime.enhance(context) in a file both hosts load. afterIdeviceRendered() stays as a wrapper around it, and the two copies of loadLegacyExeFunctionalitiesExport() collapse into it.
  3. Teardown: a ResourceLifecycle with the same API as EditionLifecycle, one per instance, plus an optional destroyRuntime(ideviceId, node) hook. The name avoids destroy, which the 3D viewer runtime and SimpleLightbox already use. EditionLifecycle will delegate to it so the two lifecycles cannot drift apart.

Left out

Validation

  • make architecture-check: Architecture records OK — 37 records, 7 changes.
  • All relative links in the new files resolve. doc/architecture/adr/ and changes/ are excluded from MkDocs navigation (mkdocs.yml).
  • No screenshots: documentation only.

Add the change document 2511-idevice-runtime-contract (proposal, spec,
design, research and tasks) and three proposed ADRs:

- ADR-2511-01: run every iDevice instance through one render lifecycle
  that ends in an `exe-idevice-rendered` DOM event.
- ADR-2511-02: share one enhancement step between the editor and
  exported pages; enhancements take a context and are idempotent.
- ADR-2511-03: own exported iDevice resources with a lifecycle shared
  with editions (the runtime counterpart of ADR-2293-01).

Documentation only; adoption is planned in tasks.md.

Closes #2511
@erseco erseco added documentation Improvements or additions to documentation iDevices labels Oct 6, 2026
@erseco erseco self-assigned this Oct 6, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Deploying exelearning with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4a6be77
Status: ✅  Deploy successful!
Preview URL: https://fc6cf1ad.exelearning.pages.dev
Branch Preview URL: https://feature-2511-idevice-runtime.exelearning.pages.dev

View logs

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.26%. Comparing base (bce8f99) to head (4a6be77).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2513   +/-   ##
=======================================
  Coverage   92.25%   92.26%           
=======================================
  Files         479      479           
  Lines       89517    89517           
=======================================
+ Hits        82584    82591    +7     
+ Misses       6933     6926    -7     
Flag Coverage Δ
frontend 92.26% <ø> (+<0.01%) ⬆️
unittests 92.26% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@ignaciogros
ignaciogros requested a review from mnarvaezm October 6, 2026 11:37
@ignaciogros ignaciogros added this to the v4.0.6 milestone Oct 6, 2026

@ignaciogros ignaciogros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Could you please check if these details need to be fixed before moving the ADRs to Accepted?

  • Where enhance() lives: proposal.md and the ADR table in design.md say "in common.js", but design.md §1 puts it in the separate exe_idevice_runtime.js precisely to keep it out of common.js.
  • Editor after a save: ADR-2511-02 says the two editor methods become one enhance(document) call, while design.md §4 and tasks.md step 2 say enhance(document) on page load plus enhance(node) after a save. Could the ADR say the same?
  • Scope of destroy(node): the spec defines the instance as the .idevice_node and R7.2.4 drops jQuery data and events for its subtree, but the editor design calls destroy(this.ideviceBody). Could you state that only the iDevice's content is cleaned, not the .idevice_node itself, so the handlers the editor binds to the node (drag, selection…) survive?

Additional comment:

The "Left out" note in the PR description about ADR-2510-01 is outdated: #2512 is merged and the files already link it.

- enhance() lives in the shared runtime script, not in common.js.
- ADR-2511-02: the editor enhances the whole page on load and only the
  saved iDevice after a save, as design.md and tasks.md already said.
- Define the content root, and make destroy(node) clean only the
  instance's content: the editor's handlers on the .idevice_node survive.
@erseco

erseco commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, all four were right and are fixed in the latest commit:

  • enhance() now consistently lives in the shared runtime script (exe_idevice_runtime.js), not common.js.
  • ADR-2511-02 now matches design §4 and tasks: enhance(document) on page load, enhance(node) on the saved iDevice after a save.
  • The spec defines a content root (the .idevice_node on exported pages, .idevice_body in the editor). destroy(node) only cleans its descendants, so the editor's handlers on the .idevice_node survive (R7.1, R7.2.4, R7.3, design §4, ADR-2511-03).
  • The outdated "Left out" note about ADR-2510-01 is struck through in the PR description.

@erseco
erseco dismissed ignaciogros’s stale review October 6, 2026 12:30

Addressed in 0f-latest commit; see the reply above.

@erseco
erseco requested a review from ignaciogros October 6, 2026 12:30
@ignaciogros ignaciogros modified the milestones: v4.0.6, v4.0.7 Oct 28, 2026
@ignaciogros

Copy link
Copy Markdown
Contributor

Moving this to v4.0.7: we agreed to review the architecture decisions together in that release, and this PR adds ADR-2511-01/02/03 alongside the runtime contract, so it will be reviewed then with the related records (ADR-2510-01, ADR-2293-01).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation iDevices

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define the iDevice runtime contract

2 participants