@hyperframes/producer 0.1.9 → 0.1.10

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
@@ -99590,6 +99590,76 @@ ${right2.raw}`)
99590
99590
  });
99591
99591
  }
99592
99592
  }
99593
+ for (const script of scripts) {
99594
+ const templateLiteralSelectorPattern = /(?:querySelector|querySelectorAll)\s*\(\s*`[^`]*\$\{[^}]+\}[^`]*`\s*\)/g;
99595
+ let tlMatch;
99596
+ while ((tlMatch = templateLiteralSelectorPattern.exec(script.content)) !== null) {
99597
+ pushFinding({
99598
+ code: "template_literal_selector",
99599
+ severity: "error",
99600
+ message: "querySelector uses a template literal variable (e.g. `${compId}`). The HTML bundler's CSS parser crashes on these. Use a hardcoded string instead.",
99601
+ file: filePath,
99602
+ fixHint: "Replace the template literal variable with a hardcoded string. The bundler's CSS parser cannot handle interpolated variables in script content.",
99603
+ snippet: truncateSnippet(tlMatch[0])
99604
+ });
99605
+ }
99606
+ }
99607
+ {
99608
+ const cssTranslateSelectors = /* @__PURE__ */ new Map();
99609
+ const cssScaleSelectors = /* @__PURE__ */ new Map();
99610
+ for (const style of styles) {
99611
+ for (const [, selector, body] of style.content.matchAll(
99612
+ /([#.][a-zA-Z0-9_-]+)\s*\{([^}]+)\}/g
99613
+ )) {
99614
+ const tMatch = body?.match(/transform\s*:\s*([^;]+)/);
99615
+ if (!tMatch || !tMatch[1]) continue;
99616
+ const transformVal = tMatch[1].trim();
99617
+ if (/translate/i.test(transformVal)) {
99618
+ cssTranslateSelectors.set((selector ?? "").trim(), transformVal);
99619
+ }
99620
+ if (/scale/i.test(transformVal)) {
99621
+ cssScaleSelectors.set((selector ?? "").trim(), transformVal);
99622
+ }
99623
+ }
99624
+ }
99625
+ if (cssTranslateSelectors.size > 0 || cssScaleSelectors.size > 0) {
99626
+ for (const script of scripts) {
99627
+ if (!/gsap\.timeline/.test(script.content)) continue;
99628
+ const windows = extractGsapWindows(script.content);
99629
+ const conflicts = /* @__PURE__ */ new Map();
99630
+ for (const win of windows) {
99631
+ if (win.method === "fromTo") continue;
99632
+ const sel = win.targetSelector;
99633
+ const cssKey = sel.startsWith("#") || sel.startsWith(".") ? sel : `#${sel}`;
99634
+ const translateProps = win.properties.filter(
99635
+ (p) => ["x", "y", "xPercent", "yPercent"].includes(p)
99636
+ );
99637
+ const scaleProps = win.properties.filter((p) => p === "scale");
99638
+ const cssFromTranslate = translateProps.length > 0 ? cssTranslateSelectors.get(cssKey) : void 0;
99639
+ const cssFromScale = scaleProps.length > 0 ? cssScaleSelectors.get(cssKey) : void 0;
99640
+ if (!cssFromTranslate && !cssFromScale) continue;
99641
+ const existing = conflicts.get(sel) ?? {
99642
+ cssTransform: [cssFromTranslate, cssFromScale].filter(Boolean).join(" "),
99643
+ props: /* @__PURE__ */ new Set(),
99644
+ raw: win.raw
99645
+ };
99646
+ for (const p of [...translateProps, ...scaleProps]) existing.props.add(p);
99647
+ conflicts.set(sel, existing);
99648
+ }
99649
+ for (const [sel, { cssTransform, props, raw: raw2 }] of conflicts) {
99650
+ const propList = [...props].join("/");
99651
+ pushFinding({
99652
+ code: "gsap_css_transform_conflict",
99653
+ severity: "warning",
99654
+ message: `"${sel}" has CSS \`transform: ${cssTransform}\` and a GSAP tween animates ${propList}. GSAP will overwrite the full CSS transform, discarding any translateX(-50%) centering or CSS scale value.`,
99655
+ selector: sel,
99656
+ fixHint: `Remove the transform from CSS and use tl.fromTo('${sel}', { xPercent: -50, x: -1000 }, { xPercent: -50, x: 0 }) so GSAP owns the full transform state. tl.fromTo is exempt from this rule.`,
99657
+ snippet: truncateSnippet(raw2)
99658
+ });
99659
+ }
99660
+ }
99661
+ }
99662
+ }
99593
99663
  const errorCount = findings.filter((finding) => finding.severity === "error").length;
99594
99664
  const warningCount = findings.length - errorCount;
99595
99665
  return {
@@ -99733,6 +99803,7 @@ function extractGsapWindows(script) {
99733
99803
  end: animation.position + meta.effectiveDuration,
99734
99804
  properties: meta.properties.length > 0 ? meta.properties : Object.keys(animation.properties),
99735
99805
  overwriteAuto: meta.overwriteAuto,
99806
+ method: match2[1] ?? "to",
99736
99807
  raw: raw2
99737
99808
  });
99738
99809
  }