@extend-ai/react-docx 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/dist/index.cjs CHANGED
@@ -28458,6 +28458,7 @@ var DocxDetachedThumbnailSurfaceRenderer = class {
28458
28458
  root;
28459
28459
  activePageIndex;
28460
28460
  activeRenderKey;
28461
+ rootGeneration = 0;
28461
28462
  async renderPageSurface(params) {
28462
28463
  if (typeof document === "undefined" || typeof window === "undefined") {
28463
28464
  return void 0;
@@ -28483,16 +28484,24 @@ var DocxDetachedThumbnailSurfaceRenderer = class {
28483
28484
  return this.waitForPageSurface(registry, pageIndex);
28484
28485
  }
28485
28486
  clear() {
28486
- if (this.root) {
28487
- this.root.unmount();
28488
- this.root = void 0;
28489
- }
28490
- if (this.host?.parentNode) {
28491
- this.host.parentNode.removeChild(this.host);
28492
- }
28487
+ const root = this.root;
28488
+ const host = this.host;
28489
+ this.rootGeneration += 1;
28490
+ this.root = void 0;
28493
28491
  this.host = void 0;
28494
28492
  this.activePageIndex = void 0;
28495
28493
  this.activeRenderKey = void 0;
28494
+ const dispose = () => {
28495
+ root?.unmount();
28496
+ if (host?.parentNode) {
28497
+ host.parentNode.removeChild(host);
28498
+ }
28499
+ };
28500
+ if (root && typeof window !== "undefined") {
28501
+ window.setTimeout(dispose, 0);
28502
+ } else {
28503
+ dispose();
28504
+ }
28496
28505
  }
28497
28506
  async ensureRoot() {
28498
28507
  if (this.root) {
@@ -28501,6 +28510,7 @@ var DocxDetachedThumbnailSurfaceRenderer = class {
28501
28510
  if (typeof document === "undefined") {
28502
28511
  return;
28503
28512
  }
28513
+ const generation = this.rootGeneration;
28504
28514
  const host = document.createElement("div");
28505
28515
  host.setAttribute("data-docx-thumbnail-detached-renderer", "true");
28506
28516
  Object.assign(host.style, {
@@ -28517,6 +28527,12 @@ var DocxDetachedThumbnailSurfaceRenderer = class {
28517
28527
  document.body.appendChild(host);
28518
28528
  this.host = host;
28519
28529
  const { createRoot } = await import("react-dom/client");
28530
+ if (generation !== this.rootGeneration) {
28531
+ if (host.parentNode) {
28532
+ host.parentNode.removeChild(host);
28533
+ }
28534
+ return;
28535
+ }
28520
28536
  this.root = createRoot(host);
28521
28537
  }
28522
28538
  async waitForPageSurface(registry, pageIndex) {