@clypra-studio/engine 1.4.0 → 1.6.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.
- package/dist/{chunk-E6O6LZME.js → chunk-7ORA5BPW.js} +14 -299
- package/dist/chunk-7ORA5BPW.js.map +1 -0
- package/dist/chunk-NG4F55V7.js +300 -0
- package/dist/chunk-NG4F55V7.js.map +1 -0
- package/dist/{chunk-3UEOLDJJ.js → chunk-SH7HOGVX.js} +1 -1
- package/dist/chunk-SH7HOGVX.js.map +1 -0
- package/dist/chunk-V5D5SJPO.js +1946 -0
- package/dist/chunk-V5D5SJPO.js.map +1 -0
- package/dist/index-DKJxLj6P.d.cts +122 -0
- package/dist/index-DbojK0dC.d.ts +491 -0
- package/dist/index-QSvA1MMy.d.ts +122 -0
- package/dist/index-l2Qgw6Dt.d.cts +491 -0
- package/dist/index.cjs +3669 -484
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +248 -150
- package/dist/index.d.ts +248 -150
- package/dist/index.js +2226 -930
- package/dist/index.js.map +1 -1
- package/dist/rendering/index.cjs +3743 -0
- package/dist/rendering/index.cjs.map +1 -0
- package/dist/rendering/index.d.cts +2 -0
- package/dist/rendering/index.d.ts +2 -0
- package/dist/rendering/index.js +23 -0
- package/dist/rendering/index.js.map +1 -0
- package/dist/textEffects/index.cjs +13 -5
- package/dist/textEffects/index.cjs.map +1 -1
- package/dist/textEffects/index.d.cts +2 -1
- package/dist/textEffects/index.d.ts +2 -1
- package/dist/textEffects/index.js +6 -4
- package/dist/{index-C18SQ-y6.d.cts → types-CoshNXmU.d.cts} +142 -129
- package/dist/{index-C18SQ-y6.d.ts → types-CoshNXmU.d.ts} +142 -129
- package/dist/videoEffects/index.cjs.map +1 -1
- package/dist/videoEffects/index.js +1 -1
- package/package.json +6 -1
- package/dist/chunk-3UEOLDJJ.js.map +0 -1
- package/dist/chunk-E6O6LZME.js.map +0 -1
|
@@ -274,12 +274,20 @@ var _roundRect = null;
|
|
|
274
274
|
var _letterSpacing = null;
|
|
275
275
|
var _offscreenCanvas = null;
|
|
276
276
|
function probe2d() {
|
|
277
|
-
if (typeof
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
278
|
+
try {
|
|
279
|
+
return new OffscreenCanvas(1, 1).getContext("2d");
|
|
280
|
+
} catch {
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (typeof document !== "undefined") {
|
|
284
|
+
try {
|
|
285
|
+
return document.createElement("canvas").getContext("2d");
|
|
286
|
+
} catch {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
282
289
|
}
|
|
290
|
+
return null;
|
|
283
291
|
}
|
|
284
292
|
function supportsCtxFilter() {
|
|
285
293
|
if (_ctxFilter !== null) return _ctxFilter;
|
|
@@ -2446,292 +2454,6 @@ function layerToTextEffectConfig(layer2) {
|
|
|
2446
2454
|
return config;
|
|
2447
2455
|
}
|
|
2448
2456
|
|
|
2449
|
-
// src/fontLoader.ts
|
|
2450
|
-
var FONT_VARIANTS = [
|
|
2451
|
-
// Poppins variants
|
|
2452
|
-
{ variantName: "Poppins-Regular", baseFontFamily: "Poppins", weight: 400, style: "normal" },
|
|
2453
|
-
{ variantName: "Poppins-Bold", baseFontFamily: "Poppins", weight: 700, style: "normal" },
|
|
2454
|
-
{ variantName: "Poppins-Italic", baseFontFamily: "Poppins", weight: 400, style: "italic" },
|
|
2455
|
-
{ variantName: "Poppins-BoldItalic", baseFontFamily: "Poppins", weight: 700, style: "italic" },
|
|
2456
|
-
// Montserrat variants
|
|
2457
|
-
{ variantName: "Montserrat-Regular", baseFontFamily: "Montserrat", weight: 400, style: "normal" },
|
|
2458
|
-
{ variantName: "Montserrat-Bold", baseFontFamily: "Montserrat", weight: 700, style: "normal" },
|
|
2459
|
-
{ variantName: "Montserrat-ExtraBold", baseFontFamily: "Montserrat", weight: 800, style: "normal" },
|
|
2460
|
-
{ variantName: "Montserrat-Black", baseFontFamily: "Montserrat", weight: 900, style: "normal" },
|
|
2461
|
-
{ variantName: "Montserrat-Italic", baseFontFamily: "Montserrat", weight: 400, style: "italic" },
|
|
2462
|
-
{ variantName: "Montserrat-BoldItalic", baseFontFamily: "Montserrat", weight: 700, style: "italic" },
|
|
2463
|
-
{ variantName: "Montserrat-ExtraBoldItalic", baseFontFamily: "Montserrat", weight: 800, style: "italic" },
|
|
2464
|
-
{ variantName: "Montserrat-BlackItalic", baseFontFamily: "Montserrat", weight: 900, style: "italic" },
|
|
2465
|
-
// Arial variants (System Fonts)
|
|
2466
|
-
{ variantName: "Arial", baseFontFamily: "Arial", weight: 400, style: "normal" },
|
|
2467
|
-
{ variantName: "Arial-Bold", baseFontFamily: "Arial", weight: 700, style: "normal" },
|
|
2468
|
-
{ variantName: "Arial-Italic", baseFontFamily: "Arial", weight: 400, style: "italic" },
|
|
2469
|
-
{ variantName: "Arial-BoldItalic", baseFontFamily: "Arial", weight: 700, style: "italic" }
|
|
2470
|
-
];
|
|
2471
|
-
function injectFontVariantRules() {
|
|
2472
|
-
if (document.getElementById("lottie-font-variants")) {
|
|
2473
|
-
return;
|
|
2474
|
-
}
|
|
2475
|
-
const style = document.createElement("style");
|
|
2476
|
-
style.id = "lottie-font-variants";
|
|
2477
|
-
let css = "/* Dynamically injected font variants for lottie-web */\n";
|
|
2478
|
-
FONT_VARIANTS.forEach((variant) => {
|
|
2479
|
-
const resolvedFamily = resolveFontFamilyName(variant.baseFontFamily);
|
|
2480
|
-
css += `
|
|
2481
|
-
@font-face {
|
|
2482
|
-
font-family: "${variant.variantName}";
|
|
2483
|
-
src: local("${resolvedFamily}"), local("${variant.baseFontFamily}");
|
|
2484
|
-
font-weight: ${variant.weight};
|
|
2485
|
-
font-style: ${variant.style};
|
|
2486
|
-
font-display: swap;
|
|
2487
|
-
}
|
|
2488
|
-
`;
|
|
2489
|
-
});
|
|
2490
|
-
style.textContent = css;
|
|
2491
|
-
document.head.appendChild(style);
|
|
2492
|
-
console.log("\u2705 Font variant rules injected for lottie-web");
|
|
2493
|
-
}
|
|
2494
|
-
async function initializeFontSystem() {
|
|
2495
|
-
try {
|
|
2496
|
-
const preloaderId = "font-system-preloader";
|
|
2497
|
-
if (!document.getElementById(preloaderId) && document.body) {
|
|
2498
|
-
const preloader = document.createElement("div");
|
|
2499
|
-
preloader.id = preloaderId;
|
|
2500
|
-
preloader.style.position = "absolute";
|
|
2501
|
-
preloader.style.width = "0";
|
|
2502
|
-
preloader.style.height = "0";
|
|
2503
|
-
preloader.style.overflow = "hidden";
|
|
2504
|
-
preloader.style.visibility = "hidden";
|
|
2505
|
-
preloader.style.opacity = "0";
|
|
2506
|
-
preloader.style.pointerEvents = "none";
|
|
2507
|
-
preloader.style.zIndex = "-9999";
|
|
2508
|
-
const preloadItems = [
|
|
2509
|
-
{ family: "Poppins", weight: 400, style: "normal" },
|
|
2510
|
-
{ family: "Poppins", weight: 700, style: "normal" },
|
|
2511
|
-
{ family: "Poppins", weight: 400, style: "italic" },
|
|
2512
|
-
{ family: "Poppins", weight: 700, style: "italic" },
|
|
2513
|
-
{ family: "Montserrat", weight: 400, style: "normal" },
|
|
2514
|
-
{ family: "Montserrat", weight: 700, style: "normal" },
|
|
2515
|
-
{ family: "Montserrat", weight: 800, style: "normal" },
|
|
2516
|
-
{ family: "Montserrat", weight: 900, style: "normal" },
|
|
2517
|
-
{ family: "Montserrat", weight: 400, style: "italic" },
|
|
2518
|
-
{ family: "Montserrat", weight: 700, style: "italic" },
|
|
2519
|
-
{ family: "Montserrat", weight: 800, style: "italic" },
|
|
2520
|
-
{ family: "Montserrat", weight: 900, style: "italic" }
|
|
2521
|
-
];
|
|
2522
|
-
preloadItems.forEach((item) => {
|
|
2523
|
-
const span = document.createElement("span");
|
|
2524
|
-
span.style.fontFamily = `'${item.family}'`;
|
|
2525
|
-
span.style.fontWeight = String(item.weight);
|
|
2526
|
-
span.style.fontStyle = item.style;
|
|
2527
|
-
span.innerText = "preload";
|
|
2528
|
-
preloader.appendChild(span);
|
|
2529
|
-
});
|
|
2530
|
-
document.body.appendChild(preloader);
|
|
2531
|
-
}
|
|
2532
|
-
await document.fonts.load("400 16px Poppins");
|
|
2533
|
-
await document.fonts.load("700 16px Poppins");
|
|
2534
|
-
await document.fonts.load("italic 400 16px Poppins");
|
|
2535
|
-
await document.fonts.load("italic 700 16px Poppins");
|
|
2536
|
-
await document.fonts.load("400 16px Montserrat");
|
|
2537
|
-
await document.fonts.load("700 16px Montserrat");
|
|
2538
|
-
await document.fonts.load("800 16px Montserrat");
|
|
2539
|
-
await document.fonts.load("900 16px Montserrat");
|
|
2540
|
-
await document.fonts.load("italic 400 16px Montserrat");
|
|
2541
|
-
await document.fonts.load("italic 700 16px Montserrat");
|
|
2542
|
-
await document.fonts.load("italic 800 16px Montserrat");
|
|
2543
|
-
await document.fonts.load("italic 900 16px Montserrat");
|
|
2544
|
-
injectFontVariantRules();
|
|
2545
|
-
console.log("\u2705 Font system initialized (Poppins + Montserrat)");
|
|
2546
|
-
} catch (error) {
|
|
2547
|
-
console.warn("\u26A0\uFE0F Font loading warning:", error);
|
|
2548
|
-
injectFontVariantRules();
|
|
2549
|
-
}
|
|
2550
|
-
}
|
|
2551
|
-
function checkFontVariant(variantName) {
|
|
2552
|
-
if (typeof document === "undefined" || !document.fonts) return false;
|
|
2553
|
-
return document.fonts.check(`16px "${variantName}"`);
|
|
2554
|
-
}
|
|
2555
|
-
var FontLoader = class {
|
|
2556
|
-
state = {
|
|
2557
|
-
loading: /* @__PURE__ */ new Set(),
|
|
2558
|
-
loaded: /* @__PURE__ */ new Set(),
|
|
2559
|
-
failed: /* @__PURE__ */ new Map(),
|
|
2560
|
-
promises: /* @__PURE__ */ new Map()
|
|
2561
|
-
};
|
|
2562
|
-
async ensureFont(descriptor) {
|
|
2563
|
-
const resolvedFamily = resolveFontFamilyName(descriptor.family);
|
|
2564
|
-
const resolvedDescriptor = { ...descriptor, family: resolvedFamily };
|
|
2565
|
-
const key = this.getFontKey(resolvedDescriptor);
|
|
2566
|
-
if (this.state.loaded.has(key)) {
|
|
2567
|
-
return {
|
|
2568
|
-
font: descriptor,
|
|
2569
|
-
loaded: true,
|
|
2570
|
-
loadTimeMs: 0
|
|
2571
|
-
};
|
|
2572
|
-
}
|
|
2573
|
-
if (this.state.failed.has(key)) {
|
|
2574
|
-
return {
|
|
2575
|
-
font: descriptor,
|
|
2576
|
-
loaded: false,
|
|
2577
|
-
error: this.state.failed.get(key),
|
|
2578
|
-
loadTimeMs: 0
|
|
2579
|
-
};
|
|
2580
|
-
}
|
|
2581
|
-
if (this.state.promises.has(key)) {
|
|
2582
|
-
return this.state.promises.get(key);
|
|
2583
|
-
}
|
|
2584
|
-
const promise = this.loadFont(resolvedDescriptor).then((res) => ({
|
|
2585
|
-
...res,
|
|
2586
|
-
font: descriptor
|
|
2587
|
-
}));
|
|
2588
|
-
this.state.promises.set(key, promise);
|
|
2589
|
-
return promise;
|
|
2590
|
-
}
|
|
2591
|
-
async ensureFonts(descriptors) {
|
|
2592
|
-
return Promise.all(descriptors.map((desc) => this.ensureFont(desc)));
|
|
2593
|
-
}
|
|
2594
|
-
async waitForFontsReady() {
|
|
2595
|
-
if (typeof document === "undefined" || !document.fonts) {
|
|
2596
|
-
return;
|
|
2597
|
-
}
|
|
2598
|
-
await document.fonts.ready;
|
|
2599
|
-
}
|
|
2600
|
-
isLoaded(descriptor) {
|
|
2601
|
-
const key = this.getFontKey(descriptor);
|
|
2602
|
-
return this.state.loaded.has(key);
|
|
2603
|
-
}
|
|
2604
|
-
getStats() {
|
|
2605
|
-
return {
|
|
2606
|
-
loaded: this.state.loaded.size,
|
|
2607
|
-
loading: this.state.loading.size,
|
|
2608
|
-
failed: this.state.failed.size
|
|
2609
|
-
};
|
|
2610
|
-
}
|
|
2611
|
-
clear() {
|
|
2612
|
-
this.state.loading.clear();
|
|
2613
|
-
this.state.loaded.clear();
|
|
2614
|
-
this.state.failed.clear();
|
|
2615
|
-
this.state.promises.clear();
|
|
2616
|
-
}
|
|
2617
|
-
async loadFont(descriptor) {
|
|
2618
|
-
const key = this.getFontKey(descriptor);
|
|
2619
|
-
const startTime = performance.now();
|
|
2620
|
-
this.state.loading.add(key);
|
|
2621
|
-
const SYSTEM_FONTS = /* @__PURE__ */ new Set([
|
|
2622
|
-
"arial",
|
|
2623
|
-
"georgia",
|
|
2624
|
-
"times new roman",
|
|
2625
|
-
"courier new",
|
|
2626
|
-
"arial rounded mt bold",
|
|
2627
|
-
"impact",
|
|
2628
|
-
"helvetica",
|
|
2629
|
-
"sans-serif",
|
|
2630
|
-
"serif",
|
|
2631
|
-
"monospace"
|
|
2632
|
-
]);
|
|
2633
|
-
const isGoogleFont = (family) => {
|
|
2634
|
-
return !SYSTEM_FONTS.has(family.toLowerCase());
|
|
2635
|
-
};
|
|
2636
|
-
const injectGoogleFontLink = (family) => {
|
|
2637
|
-
if (typeof document === "undefined") return;
|
|
2638
|
-
const fontId = `gfont-${family.replace(/\s+/g, "-").toLowerCase()}`;
|
|
2639
|
-
if (document.getElementById(fontId)) return;
|
|
2640
|
-
const link = document.createElement("link");
|
|
2641
|
-
link.id = fontId;
|
|
2642
|
-
link.rel = "stylesheet";
|
|
2643
|
-
link.href = `https://fonts.googleapis.com/css2?family=${family.replace(/\s+/g, "+")}:wght@400;500;600;700;800;900&display=swap`;
|
|
2644
|
-
document.head.appendChild(link);
|
|
2645
|
-
console.log(`[FontLoader] Dynamically injected Google Fonts stylesheet for: ${family}`);
|
|
2646
|
-
};
|
|
2647
|
-
try {
|
|
2648
|
-
if (typeof document === "undefined" || !document.fonts) {
|
|
2649
|
-
throw new Error("Font API not available");
|
|
2650
|
-
}
|
|
2651
|
-
const weight = this.normalizeFontWeight(descriptor.weight);
|
|
2652
|
-
const style = descriptor.style || "normal";
|
|
2653
|
-
const fontFace = `${style} ${weight} 16px "${descriptor.family}"`;
|
|
2654
|
-
if (isGoogleFont(descriptor.family)) {
|
|
2655
|
-
injectGoogleFontLink(descriptor.family);
|
|
2656
|
-
}
|
|
2657
|
-
if (document.fonts.check(fontFace)) {
|
|
2658
|
-
this.state.loaded.add(key);
|
|
2659
|
-
this.state.loading.delete(key);
|
|
2660
|
-
this.state.promises.delete(key);
|
|
2661
|
-
return {
|
|
2662
|
-
font: descriptor,
|
|
2663
|
-
loaded: true,
|
|
2664
|
-
loadTimeMs: performance.now() - startTime
|
|
2665
|
-
};
|
|
2666
|
-
}
|
|
2667
|
-
await document.fonts.load(fontFace);
|
|
2668
|
-
if (!document.fonts.check(fontFace)) {
|
|
2669
|
-
const fallbackFontFace = `${style} 400 16px "${descriptor.family}"`;
|
|
2670
|
-
if (weight !== 400 && document.fonts.check(fallbackFontFace)) {
|
|
2671
|
-
console.log(`[FontLoader] Strict check failed for "${fontFace}", but weight 400 is loaded. Accepting fallback.`);
|
|
2672
|
-
} else {
|
|
2673
|
-
throw new Error(`Font "${descriptor.family}" failed to load`);
|
|
2674
|
-
}
|
|
2675
|
-
}
|
|
2676
|
-
this.state.loaded.add(key);
|
|
2677
|
-
this.state.loading.delete(key);
|
|
2678
|
-
this.state.promises.delete(key);
|
|
2679
|
-
return {
|
|
2680
|
-
font: descriptor,
|
|
2681
|
-
loaded: true,
|
|
2682
|
-
loadTimeMs: performance.now() - startTime
|
|
2683
|
-
};
|
|
2684
|
-
} catch (error) {
|
|
2685
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
2686
|
-
this.state.failed.set(key, errorMessage);
|
|
2687
|
-
this.state.loading.delete(key);
|
|
2688
|
-
this.state.promises.delete(key);
|
|
2689
|
-
return {
|
|
2690
|
-
font: descriptor,
|
|
2691
|
-
loaded: false,
|
|
2692
|
-
error: errorMessage,
|
|
2693
|
-
loadTimeMs: performance.now() - startTime
|
|
2694
|
-
};
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
getFontKey(descriptor) {
|
|
2698
|
-
const weight = this.normalizeFontWeight(descriptor.weight);
|
|
2699
|
-
const style = descriptor.style || "normal";
|
|
2700
|
-
return `${descriptor.family}|${weight}|${style}`;
|
|
2701
|
-
}
|
|
2702
|
-
normalizeFontWeight(weight) {
|
|
2703
|
-
if (typeof weight === "number") {
|
|
2704
|
-
return weight;
|
|
2705
|
-
}
|
|
2706
|
-
if (!weight) return 400;
|
|
2707
|
-
const asNum = parseInt(weight, 10);
|
|
2708
|
-
if (!isNaN(asNum) && asNum >= 100 && asNum <= 900) {
|
|
2709
|
-
return asNum;
|
|
2710
|
-
}
|
|
2711
|
-
const weightMap = {
|
|
2712
|
-
normal: 400,
|
|
2713
|
-
bold: 700,
|
|
2714
|
-
lighter: 300,
|
|
2715
|
-
bolder: 700
|
|
2716
|
-
};
|
|
2717
|
-
return weightMap[weight] ?? 400;
|
|
2718
|
-
}
|
|
2719
|
-
};
|
|
2720
|
-
var globalFontLoader = null;
|
|
2721
|
-
function getFontLoader() {
|
|
2722
|
-
if (!globalFontLoader) {
|
|
2723
|
-
globalFontLoader = new FontLoader();
|
|
2724
|
-
}
|
|
2725
|
-
return globalFontLoader;
|
|
2726
|
-
}
|
|
2727
|
-
function resetFontLoader() {
|
|
2728
|
-
globalFontLoader = null;
|
|
2729
|
-
}
|
|
2730
|
-
async function ensureFontsLoaded(descriptors) {
|
|
2731
|
-
const loader = getFontLoader();
|
|
2732
|
-
return loader.ensureFonts(descriptors);
|
|
2733
|
-
}
|
|
2734
|
-
|
|
2735
2457
|
// src/engine/animation.ts
|
|
2736
2458
|
function ease(t, kind = "linear") {
|
|
2737
2459
|
switch (kind) {
|
|
@@ -2968,13 +2690,6 @@ export {
|
|
|
2968
2690
|
resolveFontFamilyName,
|
|
2969
2691
|
_buildConfig,
|
|
2970
2692
|
layerToTextEffectConfig,
|
|
2971
|
-
injectFontVariantRules,
|
|
2972
|
-
initializeFontSystem,
|
|
2973
|
-
checkFontVariant,
|
|
2974
|
-
FontLoader,
|
|
2975
|
-
getFontLoader,
|
|
2976
|
-
resetFontLoader,
|
|
2977
|
-
ensureFontsLoaded,
|
|
2978
2693
|
ease,
|
|
2979
2694
|
resolveAnimatedScalar,
|
|
2980
2695
|
applyTimelineAtTime,
|
|
@@ -2988,4 +2703,4 @@ export {
|
|
|
2988
2703
|
setSceneTime,
|
|
2989
2704
|
resetSceneTime
|
|
2990
2705
|
};
|
|
2991
|
-
//# sourceMappingURL=chunk-
|
|
2706
|
+
//# sourceMappingURL=chunk-7ORA5BPW.js.map
|