@lvce-editor/preview-worker 2.4.0 → 2.5.0

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.
@@ -90403,40 +90403,6 @@ const states = new Map();
90403
90403
  const set = (uid, entry) => {
90404
90404
  states.set(uid, entry);
90405
90405
  };
90406
- const addAnimationFrameHandle = (uid, handle) => {
90407
- const entry = states.get(uid);
90408
- if (entry) {
90409
- entry.animationFrameHandles.push(handle);
90410
- }
90411
- };
90412
-
90413
- const FRAME_INTERVAL = 16;
90414
- const overrideRequestAnimationFrame = (window, uid) => {
90415
- let nextId = 1;
90416
- const callbacks = new Map();
90417
- const tick = () => {
90418
- const currentCallbacks = [...callbacks.entries()];
90419
- callbacks.clear();
90420
- const timestamp = performance.now();
90421
- for (const [, callback] of currentCallbacks) {
90422
- try {
90423
- callback(timestamp);
90424
- } catch (error) {
90425
- console.warn('[preview-worker] requestAnimationFrame callback error:', error);
90426
- }
90427
- }
90428
- };
90429
- window.requestAnimationFrame = callback => {
90430
- const id = nextId++;
90431
- callbacks.set(id, callback);
90432
- const handle = setTimeout(tick, FRAME_INTERVAL);
90433
- addAnimationFrameHandle(uid, handle);
90434
- return id;
90435
- };
90436
- window.cancelAnimationFrame = id => {
90437
- callbacks.delete(id);
90438
- };
90439
- };
90440
90406
 
90441
90407
  const patchCanvasElements = async (document, uid) => {
90442
90408
  const canvasElements = document.querySelectorAll('canvas');
@@ -90480,7 +90446,6 @@ const patchCanvasElements = async (document, uid) => {
90480
90446
  const updateContent = async (state, uri) => {
90481
90447
  try {
90482
90448
  // Read the file content using RendererWorker RPC
90483
- // @ts-ignore
90484
90449
  const content = await readFile(uri);
90485
90450
 
90486
90451
  // Parse the content into virtual DOM and CSS
@@ -90501,7 +90466,6 @@ const updateContent = async (state, uri) => {
90501
90466
  window: happyDomWindow
90502
90467
  } = createWindow(content);
90503
90468
  await patchCanvasElements(happyDomDocument, state.uid);
90504
- overrideRequestAnimationFrame(happyDomWindow, state.uid);
90505
90469
  executeScripts(happyDomWindow, happyDomDocument, scripts);
90506
90470
  const elementMap = new Map();
90507
90471
  const serialized = serialize(happyDomDocument, elementMap);
@@ -90512,7 +90476,8 @@ const updateContent = async (state, uri) => {
90512
90476
  elementMap,
90513
90477
  window: happyDomWindow
90514
90478
  });
90515
- } catch {
90479
+ } catch (error) {
90480
+ console.error(error);
90516
90481
  // If script execution fails, fall back to static HTML parsing
90517
90482
  }
90518
90483
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/preview-worker",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Preview Worker",
5
5
  "repository": {
6
6
  "type": "git",