diff --git a/README.md b/README.md index eafdcdb..97d74fd 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ const dataUrl = editorRef.current?.editor?.getImage(); Two distinct channels: - **`onLoadError`** — the editor loaded fine, but the _image_ couldn't be loaded into the canvas (CORS, dead URL, decode error). -- **`onError`** — the wrapper couldn't reach a working editor: the embed script failed to load, editor creation was rejected, or re-applying a changed `image` failed. After a CDN failure the wrapper automatically resets its loader state, so a later remount retries from scratch. +- **`onError`** — the wrapper couldn't reach a working editor: the embed script failed to load, editor creation was rejected, or re-applying a changed `image` failed. A later remount retries from scratch after a CDN failure. The wrapper also clears its own loader state, but only tears down a script tag it injected itself — an embed the host page loaded is left intact for its other consumers. ## Tools diff --git a/src/ImageEditor.tsx b/src/ImageEditor.tsx index a01c9e8..84f3831 100644 --- a/src/ImageEditor.tsx +++ b/src/ImageEditor.tsx @@ -133,10 +133,13 @@ function ImageEditorInner( } }) .catch((error) => { - // If the versioned bundle never evaluated, the CDN loader has - // cached a rejected promise it will return forever — hard-reset it - // so the next mount attempt can retry from scratch. When the impl - // global exists, the failure was a mount error; keep the loader. + // If the versioned bundle never evaluated, drop the loader state + // we own so the next mount starts from a fresh embed.js. This is + // not what makes recovery possible — embed.js nulls its own cached + // promise on failure — so on a host-loaded page resetLoader leaves + // the tag and global in place and only our cache is cleared. When + // the impl global exists the failure was a mount error, not a + // bundle-load one; keep the loader. if (!window.__ImageEditorImpl__) { resetLoader(scriptUrl); } diff --git a/src/loadScript.ts b/src/loadScript.ts index 8cceb77..d1554ac 100644 --- a/src/loadScript.ts +++ b/src/loadScript.ts @@ -15,6 +15,13 @@ interface TrackedLoad { // share a single