@clypra-studio/engine 1.9.0 → 1.10.1

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.cjs CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/index.ts
@@ -83,6 +93,8 @@ __export(index_exports, {
83
93
  LayerAnimationSchema: () => LayerAnimationSchema,
84
94
  LayoutEngine: () => LayoutEngine,
85
95
  LiveBroadcastBridge: () => LiveBroadcastBridge,
96
+ MAX_ASSET_BYTES: () => MAX_ASSET_BYTES,
97
+ MAX_LOTTIE_BYTES: () => MAX_LOTTIE_BYTES,
86
98
  MediaEncoderRegistry: () => MediaEncoderRegistry,
87
99
  MediaImageEngine: () => MediaImageEngine,
88
100
  MetricEngine: () => MetricEngine,
@@ -172,6 +184,7 @@ __export(index_exports, {
172
184
  calculateMediaFit: () => calculateMediaFit,
173
185
  calculateResizeBounds: () => calculateResizeBounds,
174
186
  calculateRotationAngle: () => calculateRotationAngle,
187
+ calculateSha256: () => calculateSha256,
175
188
  canonicalContentHash: () => canonicalContentHash,
176
189
  canonicalTemplateHash: () => canonicalTemplateHash,
177
190
  canonicalizeSceneDocument: () => canonicalizeSceneDocument,
@@ -215,8 +228,13 @@ __export(index_exports, {
215
228
  downloadLottieMp4: () => downloadLottieMp4,
216
229
  downloadPngSequenceZip: () => downloadPngSequenceZip,
217
230
  downloadSceneWebM: () => downloadSceneWebM,
231
+ drawComicBurst: () => drawComicBurst,
218
232
  drawPerCharText: () => drawPerCharText,
233
+ drawRibbonBanner: () => drawRibbonBanner,
219
234
  drawRoundedRect: () => drawRoundedRect,
235
+ drawSpeechBubble: () => drawSpeechBubble,
236
+ drawThoughtCloud: () => drawThoughtCloud,
237
+ drawTornPaper: () => drawTornPaper,
220
238
  duplicateTrackAtPlayhead: () => duplicateTrackAtPlayhead,
221
239
  ease: () => ease,
222
240
  editorCommandSystem: () => editorCommandSystem,
@@ -288,6 +306,8 @@ __export(index_exports, {
288
306
  injectSolidColor: () => injectSolidColor,
289
307
  injectText: () => injectText,
290
308
  injectTextStyle: () => injectTextStyle,
309
+ inspectLottieJson: () => inspectLottieJson,
310
+ inspectStickerAsset: () => inspectStickerAsset,
291
311
  interpolateColorString: () => interpolateColorString,
292
312
  interpolateValue: () => interpolateValue,
293
313
  isKeyframed: () => isKeyframed,
@@ -318,6 +338,7 @@ __export(index_exports, {
318
338
  propertyInspectorEngine: () => propertyInspectorEngine,
319
339
  propertyInterpolator: () => propertyInterpolator,
320
340
  pruneTracksForLayer: () => pruneTracksForLayer,
341
+ pseudoNoise: () => pseudoNoise,
321
342
  rainbowCharFillColors: () => rainbowCharFillColors,
322
343
  readLayerScalar: () => readLayerScalar,
323
344
  readStyleFromLottieLayer: () => readStyleFromLottieLayer,
@@ -326,6 +347,7 @@ __export(index_exports, {
326
347
  removeKeyframe: () => removeKeyframe,
327
348
  removeTemplateKeyframe: () => removeTemplateKeyframe,
328
349
  removeTrack: () => removeTrack,
350
+ renderBubbleBackground: () => renderBubbleBackground,
329
351
  renderCanonicalToCanvas: () => renderCanonicalToCanvas,
330
352
  renderEvaluatedSceneToCanvas: () => renderEvaluatedSceneToCanvas,
331
353
  renderPngSequence: () => renderPngSequence,
@@ -339,6 +361,7 @@ __export(index_exports, {
339
361
  resolveAnchorPosition: () => resolveAnchorPosition,
340
362
  resolveAnimatedScalar: () => resolveAnimatedScalar,
341
363
  resolveBehaviorToAnimationSpec: () => resolveBehaviorToAnimationSpec,
364
+ resolveBubbleLayout: () => resolveBubbleLayout,
342
365
  resolveConform: () => resolveConform,
343
366
  resolveDocumentForBreakpoint: () => resolveDocumentForBreakpoint,
344
367
  resolveExportCanvasDimensions: () => resolveExportCanvasDimensions,
@@ -355,6 +378,7 @@ __export(index_exports, {
355
378
  runtimeAssetResolver: () => runtimeAssetResolver,
356
379
  sampleVideoContextAtTime: () => sampleVideoContextAtTime,
357
380
  scanLottieFonts: () => scanLottieFonts,
381
+ scanLottieNodes: () => scanLottieNodes,
358
382
  scanTextLayers: () => scanTextLayers,
359
383
  sceneToConfig: () => sceneToConfig,
360
384
  searchEffects: () => searchEffects,
@@ -13788,6 +13812,244 @@ function renderTextTemplateToCanvas(ctx, input) {
13788
13812
  };
13789
13813
  }
13790
13814
 
13815
+ // src/rendering/textBubbles.ts
13816
+ function resolveBubbleLayout(textWidth, textHeight, layout) {
13817
+ const p = layout.padding ?? {
13818
+ top: 14,
13819
+ right: 18,
13820
+ bottom: 14,
13821
+ left: 18
13822
+ };
13823
+ const rawOuterW = textWidth + p.left + p.right;
13824
+ const rawOuterH = textHeight + p.top + p.bottom;
13825
+ let outerWidth = Math.max(rawOuterW, layout.minWidth);
13826
+ let outerHeight = Math.max(rawOuterH, layout.minHeight);
13827
+ if (layout.preserveAspectRatio && layout.minWidth > 0 && layout.minHeight > 0) {
13828
+ const aspect = layout.minWidth / layout.minHeight;
13829
+ const currentAspect = outerWidth / outerHeight;
13830
+ if (currentAspect > aspect) {
13831
+ outerHeight = outerWidth / aspect;
13832
+ } else {
13833
+ outerWidth = outerHeight * aspect;
13834
+ }
13835
+ }
13836
+ const textOffsetX = (p.left - p.right) / 2;
13837
+ const textOffsetY = (p.top - p.bottom) / 2;
13838
+ return {
13839
+ outerWidth,
13840
+ outerHeight,
13841
+ textOffsetX,
13842
+ textOffsetY,
13843
+ contentWidth: outerWidth - p.left - p.right,
13844
+ contentHeight: outerHeight - p.top - p.bottom
13845
+ };
13846
+ }
13847
+
13848
+ // src/rendering/bubbleRenderer.ts
13849
+ function pseudoNoise(seed) {
13850
+ const x = Math.sin(seed * 12.9898 + 78.233) * 43758.5453;
13851
+ return x - Math.floor(x);
13852
+ }
13853
+ function drawTornPaper(ctx, x, y, width, height, fillColor = "#faf9f6", shadow = true) {
13854
+ ctx.save();
13855
+ if (shadow) {
13856
+ ctx.shadowColor = "rgba(0, 0, 0, 0.35)";
13857
+ ctx.shadowBlur = 12;
13858
+ ctx.shadowOffsetX = 0;
13859
+ ctx.shadowOffsetY = 4;
13860
+ }
13861
+ ctx.fillStyle = fillColor;
13862
+ ctx.beginPath();
13863
+ const steps = Math.max(16, Math.floor(width / 14));
13864
+ const stepW = width / steps;
13865
+ ctx.moveTo(x, y + 6);
13866
+ for (let i = 0; i <= steps; i++) {
13867
+ const curX = x + i * stepW;
13868
+ const n = pseudoNoise(i * 1.37 + 10);
13869
+ const wave2 = Math.sin(i / steps * Math.PI * 3) * 3;
13870
+ const curY = y + (n * 5 - 2.5) + wave2;
13871
+ if (i === 0) ctx.lineTo(curX, curY);
13872
+ else ctx.lineTo(curX, curY);
13873
+ }
13874
+ ctx.lineTo(x + width, y + height - 6);
13875
+ for (let i = steps; i >= 0; i--) {
13876
+ const curX = x + i * stepW;
13877
+ const n = pseudoNoise(i * 2.19 + 50);
13878
+ const wave2 = Math.sin(i / steps * Math.PI * 2) * 4;
13879
+ const curY = y + height + (n * 6 - 3) + wave2;
13880
+ ctx.lineTo(curX, curY);
13881
+ }
13882
+ ctx.lineTo(x, y + 6);
13883
+ ctx.closePath();
13884
+ ctx.fill();
13885
+ if (shadow) {
13886
+ ctx.shadowColor = "transparent";
13887
+ ctx.shadowBlur = 0;
13888
+ }
13889
+ const paperGrad = ctx.createLinearGradient(x, y, x, y + height);
13890
+ paperGrad.addColorStop(0, "rgba(255, 255, 255, 0.4)");
13891
+ paperGrad.addColorStop(0.5, "rgba(0, 0, 0, 0.02)");
13892
+ paperGrad.addColorStop(1, "rgba(0, 0, 0, 0.06)");
13893
+ ctx.fillStyle = paperGrad;
13894
+ ctx.fill();
13895
+ ctx.restore();
13896
+ }
13897
+ function drawSpeechBubble(ctx, x, y, width, height, fillColor = "#ffffff", strokeColor = "#000000", strokeWidth = 2, radius = 16) {
13898
+ ctx.save();
13899
+ const tailH = Math.min(16, height * 0.25);
13900
+ const bodyH = height - tailH;
13901
+ ctx.fillStyle = fillColor;
13902
+ ctx.strokeStyle = strokeColor;
13903
+ ctx.lineWidth = strokeWidth;
13904
+ ctx.beginPath();
13905
+ if (typeof ctx.roundRect === "function") {
13906
+ ctx.roundRect(x, y, width, bodyH, radius);
13907
+ } else {
13908
+ ctx.rect(x, y, width, bodyH);
13909
+ }
13910
+ ctx.fill();
13911
+ if (strokeWidth > 0) ctx.stroke();
13912
+ const tailBaseX = x + width * 0.25;
13913
+ const tailBaseW = Math.min(24, width * 0.2);
13914
+ const tailTipX = x + width * 0.15;
13915
+ const tailTipY = y + height;
13916
+ ctx.beginPath();
13917
+ ctx.moveTo(tailBaseX, y + bodyH - 2);
13918
+ ctx.quadraticCurveTo(tailBaseX + 2, y + bodyH + tailH * 0.6, tailTipX, tailTipY);
13919
+ ctx.quadraticCurveTo(tailBaseX + tailBaseW * 0.7, y + bodyH + tailH * 0.4, tailBaseX + tailBaseW, y + bodyH - 2);
13920
+ ctx.closePath();
13921
+ ctx.fill();
13922
+ if (strokeWidth > 0) ctx.stroke();
13923
+ ctx.beginPath();
13924
+ if (typeof ctx.roundRect === "function") {
13925
+ ctx.roundRect(x + 1, y + 1, width - 2, bodyH - 2, radius);
13926
+ } else {
13927
+ ctx.rect(x + 1, y + 1, width - 2, bodyH - 2);
13928
+ }
13929
+ ctx.fill();
13930
+ ctx.restore();
13931
+ }
13932
+ function drawThoughtCloud(ctx, x, y, width, height, fillColor = "#ffffff", strokeColor = "#000000", strokeWidth = 2) {
13933
+ ctx.save();
13934
+ ctx.fillStyle = fillColor;
13935
+ ctx.strokeStyle = strokeColor;
13936
+ ctx.lineWidth = strokeWidth;
13937
+ const cx = x + width / 2;
13938
+ const cy = y + height / 2;
13939
+ const rx = width * 0.44;
13940
+ const ry = height * 0.38;
13941
+ ctx.beginPath();
13942
+ const lobes = 8;
13943
+ for (let i = 0; i < lobes; i++) {
13944
+ const angle = i / lobes * Math.PI * 2;
13945
+ const lx = cx + Math.cos(angle) * rx;
13946
+ const ly = cy + Math.sin(angle) * ry;
13947
+ const lobeR = Math.min(width, height) * 0.28;
13948
+ ctx.moveTo(lx + lobeR, ly);
13949
+ ctx.arc(lx, ly, lobeR, 0, Math.PI * 2);
13950
+ }
13951
+ ctx.fill();
13952
+ if (strokeWidth > 0) ctx.stroke();
13953
+ ctx.restore();
13954
+ }
13955
+ function drawComicBurst(ctx, x, y, width, height, fillColor = "#ffffff", strokeColor = "#000000", strokeWidth = 3) {
13956
+ ctx.save();
13957
+ ctx.fillStyle = fillColor;
13958
+ ctx.strokeStyle = strokeColor;
13959
+ ctx.lineWidth = strokeWidth;
13960
+ const cx = x + width / 2;
13961
+ const cy = y + height / 2;
13962
+ const points = 16;
13963
+ const outerRx = width / 2;
13964
+ const outerRy = height / 2;
13965
+ const innerRx = width * 0.32;
13966
+ const innerRy = height * 0.32;
13967
+ ctx.beginPath();
13968
+ for (let i = 0; i < points * 2; i++) {
13969
+ const angle = i / (points * 2) * Math.PI * 2 - Math.PI / 2;
13970
+ const isOuter = i % 2 === 0;
13971
+ const rx = isOuter ? outerRx : innerRx;
13972
+ const ry = isOuter ? outerRy : innerRy;
13973
+ const px = cx + Math.cos(angle) * rx;
13974
+ const py = cy + Math.sin(angle) * ry;
13975
+ if (i === 0) ctx.moveTo(px, py);
13976
+ else ctx.lineTo(px, py);
13977
+ }
13978
+ ctx.closePath();
13979
+ ctx.fill();
13980
+ if (strokeWidth > 0) ctx.stroke();
13981
+ ctx.restore();
13982
+ }
13983
+ function drawRibbonBanner(ctx, x, y, width, height, fillColor = "#facc15", strokeColor = "#000000", strokeWidth = 2) {
13984
+ ctx.save();
13985
+ ctx.fillStyle = fillColor;
13986
+ ctx.strokeStyle = strokeColor;
13987
+ ctx.lineWidth = strokeWidth;
13988
+ const notch = Math.min(18, width * 0.08);
13989
+ ctx.beginPath();
13990
+ ctx.moveTo(x, y);
13991
+ ctx.lineTo(x + width - notch, y);
13992
+ ctx.lineTo(x + width, y + height / 2);
13993
+ ctx.lineTo(x + width - notch, y + height);
13994
+ ctx.lineTo(x, y + height);
13995
+ ctx.lineTo(x + notch, y + height / 2);
13996
+ ctx.closePath();
13997
+ ctx.fill();
13998
+ if (strokeWidth > 0) ctx.stroke();
13999
+ ctx.restore();
14000
+ }
14001
+ function renderBubbleBackground(ctx, presetId, x, y, width, height, options) {
14002
+ if (!presetId || presetId === "none") return false;
14003
+ const color = options?.color || "#ffffff";
14004
+ const opacity = options?.opacity ?? 1;
14005
+ ctx.save();
14006
+ if (opacity < 1) {
14007
+ ctx.globalAlpha *= opacity;
14008
+ }
14009
+ if (presetId === "bubble-paper-torn" || presetId === "bubble-paper-torn-beige" || presetId === "bubble-paper-kraft" || presetId === "bubble-paper-notebook") {
14010
+ const paperColor = presetId === "bubble-paper-kraft" ? "#d4a373" : presetId === "bubble-paper-torn-beige" ? "#f3eed9" : "#faf9f6";
14011
+ drawTornPaper(ctx, x, y, width, height, color || paperColor, true);
14012
+ ctx.restore();
14013
+ return true;
14014
+ }
14015
+ if (presetId === "bubble-speech-round" || presetId === "bubble-speech-oval" || presetId === "bubble-speech-tall") {
14016
+ drawSpeechBubble(ctx, x, y, width, height, color, "#000000", 2, 16);
14017
+ ctx.restore();
14018
+ return true;
14019
+ }
14020
+ if (presetId === "bubble-cloud-dotted" || presetId === "bubble-cloud-morning" || presetId === "bubble-cloud-yellow") {
14021
+ drawThoughtCloud(ctx, x, y, width, height, color, "#000000", 2);
14022
+ ctx.restore();
14023
+ return true;
14024
+ }
14025
+ if (presetId === "bubble-comic-bam" || presetId === "bubble-comic-dark-hero") {
14026
+ const burstColor = presetId === "bubble-comic-dark-hero" ? "#18181b" : color;
14027
+ const strokeColor = presetId === "bubble-comic-dark-hero" ? "#ef4444" : "#000000";
14028
+ drawComicBurst(ctx, x, y, width, height, burstColor, strokeColor, 3);
14029
+ ctx.restore();
14030
+ return true;
14031
+ }
14032
+ if (presetId === "bubble-ribbon-sunny" || presetId === "bubble-ribbon-yellow") {
14033
+ drawRibbonBanner(ctx, x, y, width, height, color || "#facc15", "#000000", 2);
14034
+ ctx.restore();
14035
+ return true;
14036
+ }
14037
+ const radius = options?.borderRadius ?? 8;
14038
+ ctx.shadowColor = "rgba(0, 0, 0, 0.2)";
14039
+ ctx.shadowBlur = 8;
14040
+ ctx.shadowOffsetY = 2;
14041
+ ctx.fillStyle = color;
14042
+ ctx.beginPath();
14043
+ if (typeof ctx.roundRect === "function") {
14044
+ ctx.roundRect(x, y, width, height, radius);
14045
+ } else {
14046
+ ctx.rect(x, y, width, height);
14047
+ }
14048
+ ctx.fill();
14049
+ ctx.restore();
14050
+ return true;
14051
+ }
14052
+
13791
14053
  // src/rendering/index.ts
13792
14054
  function renderCanonicalToCanvas(ctx, input) {
13793
14055
  if (input.capability === "text-template") {
@@ -24473,6 +24735,170 @@ function renderEvaluatedSceneToCanvas(scene, ctx, options = {}) {
24473
24735
  scene.nodes.forEach((node) => drawNode(ctx, node, scene.time));
24474
24736
  }
24475
24737
 
24738
+ // src/stickers/stickerScanner.ts
24739
+ var MAX_LOTTIE_BYTES = 300 * 1024;
24740
+ var MAX_ASSET_BYTES = 2 * 1024 * 1024;
24741
+ function scanLottieNodes(node, found = { expressions: 0, remoteUrls: 0 }) {
24742
+ if (Array.isArray(node)) {
24743
+ for (const item of node) {
24744
+ scanLottieNodes(item, found);
24745
+ }
24746
+ } else if (node && typeof node === "object") {
24747
+ if (typeof node.x === "string" && node.x.trim() !== "" && "k" in node) {
24748
+ found.expressions++;
24749
+ }
24750
+ for (const value of Object.values(node)) {
24751
+ scanLottieNodes(value, found);
24752
+ }
24753
+ } else if (typeof node === "string" && /^https?:\/\//i.test(node)) {
24754
+ found.remoteUrls++;
24755
+ }
24756
+ return found;
24757
+ }
24758
+ function inspectLottieJson(jsonOrString) {
24759
+ const errors = [];
24760
+ let json;
24761
+ if (typeof jsonOrString === "string") {
24762
+ try {
24763
+ json = JSON.parse(jsonOrString);
24764
+ } catch (err) {
24765
+ return { valid: false, errors: [`Lottie file is not valid JSON: ${err.message}`] };
24766
+ }
24767
+ } else {
24768
+ json = jsonOrString;
24769
+ }
24770
+ if (!json || typeof json !== "object") {
24771
+ return { valid: false, errors: ["Lottie data must be a JSON object"] };
24772
+ }
24773
+ for (const field of ["v", "fr", "ip", "op", "w", "h", "layers"]) {
24774
+ if (!(field in json)) {
24775
+ errors.push(`Lottie header missing required field "${field}"`);
24776
+ }
24777
+ }
24778
+ const found = scanLottieNodes(json);
24779
+ if (found.expressions > 0) {
24780
+ errors.push(`Lottie contains ${found.expressions} expression(s); expressions are strictly forbidden`);
24781
+ }
24782
+ if (found.remoteUrls > 0) {
24783
+ errors.push(`Lottie references ${found.remoteUrls} remote URL(s); all assets must be embedded`);
24784
+ }
24785
+ const fps = typeof json.fr === "number" && json.fr > 0 ? json.fr : 30;
24786
+ const ip = typeof json.ip === "number" ? json.ip : 0;
24787
+ const op = typeof json.op === "number" ? json.op : ip;
24788
+ const durationMs = Math.round((op - ip) / fps * 1e3);
24789
+ const layerCount = Array.isArray(json.layers) ? json.layers.length : 0;
24790
+ const width = Math.round(Number(json.w || 0));
24791
+ const height = Math.round(Number(json.h || 0));
24792
+ if (width < 16 || width > 2048) {
24793
+ errors.push(`Lottie width ${width} is outside permitted range [16, 2048]`);
24794
+ }
24795
+ if (height < 16 || height > 2048) {
24796
+ errors.push(`Lottie height ${height} is outside permitted range [16, 2048]`);
24797
+ }
24798
+ return {
24799
+ valid: errors.length === 0,
24800
+ errors,
24801
+ dimensions: { width, height },
24802
+ animation: {
24803
+ durationMs: Math.max(1, durationMs),
24804
+ fps,
24805
+ loop: true,
24806
+ lottie: {
24807
+ layerCount,
24808
+ hasExpressions: false
24809
+ }
24810
+ }
24811
+ };
24812
+ }
24813
+ function inspectStickerAsset(data, filenameHint = "") {
24814
+ const errors = [];
24815
+ let u8;
24816
+ if (typeof data === "string") {
24817
+ u8 = new TextEncoder().encode(data);
24818
+ } else if (data instanceof Uint8Array) {
24819
+ u8 = data;
24820
+ } else {
24821
+ u8 = new Uint8Array(data);
24822
+ }
24823
+ const bytes = u8.length;
24824
+ const isPng = u8.length >= 8 && u8[0] === 137 && u8[1] === 80 && u8[2] === 78 && u8[3] === 71 && u8[4] === 13 && u8[5] === 10 && u8[6] === 26 && u8[7] === 10;
24825
+ const isWebp = u8.length >= 12 && u8[0] === 82 && u8[1] === 73 && u8[2] === 70 && u8[3] === 70 && u8[8] === 87 && u8[9] === 69 && u8[10] === 66 && u8[11] === 80;
24826
+ const isJson = !isPng && !isWebp && (filenameHint.toLowerCase().endsWith(".json") || u8[0] === 123);
24827
+ const isSvg = !isPng && !isWebp && !isJson && (filenameHint.toLowerCase().endsWith(".svg") || u8[0] === 60);
24828
+ if (isJson) {
24829
+ if (bytes > MAX_LOTTIE_BYTES) {
24830
+ errors.push(`Lottie file size (${bytes} bytes) exceeds maximum limit of ${MAX_LOTTIE_BYTES} bytes (300 KB)`);
24831
+ }
24832
+ const text = new TextDecoder("utf8").decode(u8);
24833
+ const lottieScan = inspectLottieJson(text);
24834
+ if (!lottieScan.valid) {
24835
+ errors.push(...lottieScan.errors);
24836
+ }
24837
+ return {
24838
+ valid: errors.length === 0,
24839
+ errors,
24840
+ bytes,
24841
+ mime: "application/json",
24842
+ dimensions: lottieScan.dimensions,
24843
+ animation: lottieScan.animation
24844
+ };
24845
+ }
24846
+ if (bytes > MAX_ASSET_BYTES) {
24847
+ errors.push(`Asset file size (${bytes} bytes) exceeds maximum limit of ${MAX_ASSET_BYTES} bytes (2 MB)`);
24848
+ }
24849
+ if (isPng) {
24850
+ let width = 0;
24851
+ let height = 0;
24852
+ if (u8.length >= 24) {
24853
+ const view = new DataView(u8.buffer, u8.byteOffset, u8.byteLength);
24854
+ width = view.getUint32(16);
24855
+ height = view.getUint32(20);
24856
+ }
24857
+ return {
24858
+ valid: errors.length === 0,
24859
+ errors,
24860
+ bytes,
24861
+ mime: "image/png",
24862
+ dimensions: width > 0 && height > 0 ? { width, height } : void 0
24863
+ };
24864
+ }
24865
+ if (isWebp) {
24866
+ return {
24867
+ valid: errors.length === 0,
24868
+ errors,
24869
+ bytes,
24870
+ mime: "image/webp"
24871
+ };
24872
+ }
24873
+ if (isSvg) {
24874
+ return {
24875
+ valid: errors.length === 0,
24876
+ errors,
24877
+ bytes,
24878
+ mime: "image/svg+xml"
24879
+ };
24880
+ }
24881
+ return {
24882
+ valid: false,
24883
+ errors: ["Unsupported file format; allowed formats are Lottie JSON, WebP, PNG, and SVG"],
24884
+ bytes,
24885
+ mime: "application/octet-stream"
24886
+ };
24887
+ }
24888
+ async function calculateSha256(data) {
24889
+ const u8 = typeof data === "string" ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);
24890
+ if (typeof crypto !== "undefined" && crypto.subtle) {
24891
+ const hashBuf = await crypto.subtle.digest("SHA-256", u8);
24892
+ return Array.from(new Uint8Array(hashBuf)).map((b) => b.toString(16).padStart(2, "0")).join("");
24893
+ }
24894
+ try {
24895
+ const nodeCrypto = await import("crypto");
24896
+ return nodeCrypto.createHash("sha256").update(u8).digest("hex");
24897
+ } catch {
24898
+ throw new Error("No cryptographic hash implementation available");
24899
+ }
24900
+ }
24901
+
24476
24902
  // src/index.ts
24477
24903
  var VERSION = "1.4.0";
24478
24904
  // Annotate the CommonJS export names for ESM import in node:
@@ -24541,6 +24967,8 @@ var VERSION = "1.4.0";
24541
24967
  LayerAnimationSchema,
24542
24968
  LayoutEngine,
24543
24969
  LiveBroadcastBridge,
24970
+ MAX_ASSET_BYTES,
24971
+ MAX_LOTTIE_BYTES,
24544
24972
  MediaEncoderRegistry,
24545
24973
  MediaImageEngine,
24546
24974
  MetricEngine,
@@ -24630,6 +25058,7 @@ var VERSION = "1.4.0";
24630
25058
  calculateMediaFit,
24631
25059
  calculateResizeBounds,
24632
25060
  calculateRotationAngle,
25061
+ calculateSha256,
24633
25062
  canonicalContentHash,
24634
25063
  canonicalTemplateHash,
24635
25064
  canonicalizeSceneDocument,
@@ -24673,8 +25102,13 @@ var VERSION = "1.4.0";
24673
25102
  downloadLottieMp4,
24674
25103
  downloadPngSequenceZip,
24675
25104
  downloadSceneWebM,
25105
+ drawComicBurst,
24676
25106
  drawPerCharText,
25107
+ drawRibbonBanner,
24677
25108
  drawRoundedRect,
25109
+ drawSpeechBubble,
25110
+ drawThoughtCloud,
25111
+ drawTornPaper,
24678
25112
  duplicateTrackAtPlayhead,
24679
25113
  ease,
24680
25114
  editorCommandSystem,
@@ -24746,6 +25180,8 @@ var VERSION = "1.4.0";
24746
25180
  injectSolidColor,
24747
25181
  injectText,
24748
25182
  injectTextStyle,
25183
+ inspectLottieJson,
25184
+ inspectStickerAsset,
24749
25185
  interpolateColorString,
24750
25186
  interpolateValue,
24751
25187
  isKeyframed,
@@ -24776,6 +25212,7 @@ var VERSION = "1.4.0";
24776
25212
  propertyInspectorEngine,
24777
25213
  propertyInterpolator,
24778
25214
  pruneTracksForLayer,
25215
+ pseudoNoise,
24779
25216
  rainbowCharFillColors,
24780
25217
  readLayerScalar,
24781
25218
  readStyleFromLottieLayer,
@@ -24784,6 +25221,7 @@ var VERSION = "1.4.0";
24784
25221
  removeKeyframe,
24785
25222
  removeTemplateKeyframe,
24786
25223
  removeTrack,
25224
+ renderBubbleBackground,
24787
25225
  renderCanonicalToCanvas,
24788
25226
  renderEvaluatedSceneToCanvas,
24789
25227
  renderPngSequence,
@@ -24797,6 +25235,7 @@ var VERSION = "1.4.0";
24797
25235
  resolveAnchorPosition,
24798
25236
  resolveAnimatedScalar,
24799
25237
  resolveBehaviorToAnimationSpec,
25238
+ resolveBubbleLayout,
24800
25239
  resolveConform,
24801
25240
  resolveDocumentForBreakpoint,
24802
25241
  resolveExportCanvasDimensions,
@@ -24813,6 +25252,7 @@ var VERSION = "1.4.0";
24813
25252
  runtimeAssetResolver,
24814
25253
  sampleVideoContextAtTime,
24815
25254
  scanLottieFonts,
25255
+ scanLottieNodes,
24816
25256
  scanTextLayers,
24817
25257
  sceneToConfig,
24818
25258
  searchEffects,