@hyperframes/studio-server 0.7.18 → 0.7.19

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.
package/dist/index.js CHANGED
@@ -424,6 +424,8 @@ import {
424
424
  removeAnimationFromScript,
425
425
  addKeyframeToScript,
426
426
  removeKeyframeFromScript,
427
+ moveKeyframeInScript,
428
+ resizeKeyframedTweenInScript,
427
429
  updateKeyframeInScript,
428
430
  convertToKeyframesFromScript,
429
431
  removeAllKeyframesFromScript,
@@ -436,7 +438,8 @@ import {
436
438
  splitAnimationsInScript,
437
439
  splitIntoPropertyGroupsFromScript,
438
440
  shiftPositionsInScript,
439
- scalePositionsInScript
441
+ scalePositionsInScript,
442
+ dedupePositionWritesInScript
440
443
  } from "@hyperframes/parsers/gsap-writer-acorn";
441
444
 
442
445
  // src/helpers/sourceMutation.ts
@@ -1151,6 +1154,8 @@ var HOLD_SYNC_MUTATION_TYPES = /* @__PURE__ */ new Set([
1151
1154
  "add-keyframe",
1152
1155
  "update-keyframe",
1153
1156
  "remove-keyframe",
1157
+ "move-keyframe",
1158
+ "resize-keyframed-tween",
1154
1159
  "remove-all-keyframes",
1155
1160
  "add-with-keyframes",
1156
1161
  "replace-with-keyframes",
@@ -1259,6 +1264,14 @@ function executeGsapMutationAcorn(body, block, respond) {
1259
1264
  }
1260
1265
  return script;
1261
1266
  }
1267
+ case "consolidate-position-writes": {
1268
+ if (!body.targetSelector) return block.scriptText;
1269
+ return dedupePositionWritesInScript(
1270
+ block.scriptText,
1271
+ body.targetSelector,
1272
+ body.keepAnimationId
1273
+ );
1274
+ }
1262
1275
  case "remove-property": {
1263
1276
  const r = requireAnimation(block.scriptText, body.animationId);
1264
1277
  if ("err" in r) return r.err;
@@ -1290,6 +1303,23 @@ function executeGsapMutationAcorn(body, block, respond) {
1290
1303
  case "remove-keyframe": {
1291
1304
  return removeKeyframeFromScript(block.scriptText, body.animationId, body.percentage);
1292
1305
  }
1306
+ case "move-keyframe": {
1307
+ return moveKeyframeInScript(
1308
+ block.scriptText,
1309
+ body.animationId,
1310
+ body.fromPercentage,
1311
+ body.toPercentage
1312
+ );
1313
+ }
1314
+ case "resize-keyframed-tween": {
1315
+ return resizeKeyframedTweenInScript(
1316
+ block.scriptText,
1317
+ body.animationId,
1318
+ body.position,
1319
+ body.duration,
1320
+ body.pctRemap
1321
+ );
1322
+ }
1293
1323
  case "update-keyframe": {
1294
1324
  return updateKeyframeInScript(
1295
1325
  block.scriptText,
@@ -1422,6 +1452,8 @@ async function executeGsapMutationRecast(body, block, respond) {
1422
1452
  removeAnimationFromScript: removeAnimationFromScript2,
1423
1453
  addKeyframeToScript: addKeyframeToScript2,
1424
1454
  removeKeyframeFromScript: removeKeyframeFromScript2,
1455
+ moveKeyframeInScript: moveKeyframeInScript2,
1456
+ resizeKeyframedTweenInScript: resizeKeyframedTweenInScript2,
1425
1457
  updateKeyframeInScript: updateKeyframeInScript2,
1426
1458
  convertToKeyframesInScript,
1427
1459
  removeAllKeyframesFromScript: removeAllKeyframesFromScript2,
@@ -1436,7 +1468,8 @@ async function executeGsapMutationRecast(body, block, respond) {
1436
1468
  removeArcPathFromScript: removeArcPathFromScript2,
1437
1469
  addAnimationWithKeyframesToScript: addAnimationWithKeyframesToScript2,
1438
1470
  splitAnimationsInScript: splitAnimationsInScript2,
1439
- splitIntoPropertyGroups
1471
+ splitIntoPropertyGroups,
1472
+ dedupePositionWritesInScript: dedupePositionWritesInScript2
1440
1473
  } = parser;
1441
1474
  function requireAnimation(scriptText, animationId) {
1442
1475
  const parsed = parseGsapScriptAcorn(scriptText);
@@ -1521,6 +1554,14 @@ async function executeGsapMutationRecast(body, block, respond) {
1521
1554
  }
1522
1555
  return script;
1523
1556
  }
1557
+ case "consolidate-position-writes": {
1558
+ if (!body.targetSelector) return block.scriptText;
1559
+ return dedupePositionWritesInScript2(
1560
+ block.scriptText,
1561
+ body.targetSelector,
1562
+ body.keepAnimationId
1563
+ );
1564
+ }
1524
1565
  case "remove-property": {
1525
1566
  const r = requireAnimation(block.scriptText, body.animationId);
1526
1567
  if ("err" in r) return r.err;
@@ -1552,6 +1593,23 @@ async function executeGsapMutationRecast(body, block, respond) {
1552
1593
  case "remove-keyframe": {
1553
1594
  return removeKeyframeFromScript2(block.scriptText, body.animationId, body.percentage);
1554
1595
  }
1596
+ case "move-keyframe": {
1597
+ return moveKeyframeInScript2(
1598
+ block.scriptText,
1599
+ body.animationId,
1600
+ body.fromPercentage,
1601
+ body.toPercentage
1602
+ );
1603
+ }
1604
+ case "resize-keyframed-tween": {
1605
+ return resizeKeyframedTweenInScript2(
1606
+ block.scriptText,
1607
+ body.animationId,
1608
+ body.position,
1609
+ body.duration,
1610
+ body.pctRemap
1611
+ );
1612
+ }
1555
1613
  case "update-keyframe": {
1556
1614
  return updateKeyframeInScript2(
1557
1615
  block.scriptText,
@@ -3848,11 +3906,13 @@ function registerThumbnailRoutes(api, adapter) {
3848
3906
  let compW = vpWidth || 1920;
3849
3907
  let compH = vpHeight || 1080;
3850
3908
  let sourceMtime = 0;
3851
- if (!vpWidth) {
3852
- const htmlFile = join11(project.dir, compPath);
3853
- if (existsSync7(htmlFile)) {
3854
- sourceMtime = Math.round(statSync4(htmlFile).mtimeMs);
3855
- const html = readFileSync10(htmlFile, "utf-8");
3909
+ let sourceKey = "";
3910
+ const htmlFile = join11(project.dir, compPath);
3911
+ if (existsSync7(htmlFile)) {
3912
+ const html = readFileSync10(htmlFile, "utf-8");
3913
+ sourceKey = `_${createHash2("sha1").update(html).digest("hex").slice(0, 16)}`;
3914
+ sourceMtime = Math.round(statSync4(htmlFile).mtimeMs);
3915
+ if (!vpWidth) {
3856
3916
  const wMatch = html.match(/data-width=["'](\d+)["']/);
3857
3917
  const hMatch = html.match(/data-height=["'](\d+)["']/);
3858
3918
  if (wMatch?.[1]) compW = parseInt(wMatch[1]);
@@ -3877,11 +3937,11 @@ function registerThumbnailRoutes(api, adapter) {
3877
3937
  const cacheDir = join11(project.dir, ".thumbnails");
3878
3938
  const selectorKey = selector ? `_${selector.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 80)}_${selectorIndex ?? 0}` : "";
3879
3939
  const urlVersionKey = urlVersion ? `_${urlVersion.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 32)}` : "";
3880
- const cacheKey = `${THUMBNAIL_CACHE_VERSION}${urlVersionKey}${manualEditsKey}${motionKey}_${format}_${compPath.replace(/\//g, "_")}_${compW}x${compH}_${sourceMtime}_${seekTime.toFixed(2)}${selectorKey}.${format === "png" ? "png" : "jpg"}`;
3940
+ const cacheKey = `${THUMBNAIL_CACHE_VERSION}${urlVersionKey}${manualEditsKey}${motionKey}${sourceKey}_${format}_${compPath.replace(/\//g, "_")}_${compW}x${compH}_${sourceMtime}_${seekTime.toFixed(2)}${selectorKey}.${format === "png" ? "png" : "jpg"}`;
3881
3941
  const cachePath = join11(cacheDir, cacheKey);
3882
3942
  if (existsSync7(cachePath)) {
3883
3943
  return new Response(new Uint8Array(readFileSync10(cachePath)), {
3884
- headers: { "Content-Type": contentType, "Cache-Control": "public, max-age=60" }
3944
+ headers: { "Content-Type": contentType, "Cache-Control": "no-cache" }
3885
3945
  });
3886
3946
  }
3887
3947
  try {
@@ -3905,7 +3965,7 @@ function registerThumbnailRoutes(api, adapter) {
3905
3965
  if (!existsSync7(cacheDir)) mkdirSync5(cacheDir, { recursive: true });
3906
3966
  writeFileSync6(cachePath, buffer);
3907
3967
  return new Response(new Uint8Array(buffer), {
3908
- headers: { "Content-Type": contentType, "Cache-Control": "public, max-age=60" }
3968
+ headers: { "Content-Type": contentType, "Cache-Control": "no-cache" }
3909
3969
  });
3910
3970
  } catch (err) {
3911
3971
  const msg = err instanceof Error ? err.message : String(err);