@hyperframes/core 0.8.193 → 0.8.194

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/gsapCdn.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- export declare function gsapCdnDist(gsapVersion?: string): string;
1
+ export declare const GSAP_BASE_URL_META = "hyperframes-gsap-base-url";
2
+ /** An npm-style mirror root; callers choose configuration without coupling this helper to a host. */
3
+ export declare function normalizeGsapBaseUrl(baseUrl?: string): string;
4
+ export declare function gsapCdnDist(gsapVersion?: string, baseUrl?: string): string;
2
5
  /** MotionPathPlugin at the composition's own gsap version; a skew registers with a GSAP warning. */
3
- export declare function motionPathPluginUrl(gsapVersion?: string): string;
6
+ export declare function motionPathPluginUrl(gsapVersion?: string, baseUrl?: string): string;
package/dist/gsapCdn.js CHANGED
@@ -1,9 +1,25 @@
1
1
  const GSAP_CDN_VERSION = "3.15.0";
2
- export function gsapCdnDist(gsapVersion) {
2
+ const GSAP_CDN_BASE_URL = "https://cdn.jsdelivr.net/npm";
3
+ export const GSAP_BASE_URL_META = "hyperframes-gsap-base-url";
4
+ /** An npm-style mirror root; callers choose configuration without coupling this helper to a host. */
5
+ export function normalizeGsapBaseUrl(baseUrl) {
6
+ const value = baseUrl?.trim();
7
+ if (!value)
8
+ return GSAP_CDN_BASE_URL;
9
+ if (!/^https?:\/\//i.test(value) || !URL.canParse(value) || /[?#]/.test(value)) {
10
+ throw new Error("GSAP base URL must be an absolute HTTP(S) URL without a query or fragment");
11
+ }
12
+ const url = new URL(value);
13
+ if (url.username || url.password) {
14
+ throw new Error("GSAP base URL must not contain credentials");
15
+ }
16
+ return url.href.replace(/\/+$/, "");
17
+ }
18
+ export function gsapCdnDist(gsapVersion, baseUrl) {
3
19
  const version = gsapVersion && /^\d+(\.\d+)*$/.test(gsapVersion) ? gsapVersion : GSAP_CDN_VERSION;
4
- return `https://cdn.jsdelivr.net/npm/gsap@${version}/dist/`;
20
+ return `${normalizeGsapBaseUrl(baseUrl)}/gsap@${version}/dist/`;
5
21
  }
6
22
  /** MotionPathPlugin at the composition's own gsap version; a skew registers with a GSAP warning. */
7
- export function motionPathPluginUrl(gsapVersion) {
8
- return `${gsapCdnDist(gsapVersion)}MotionPathPlugin.min.js`;
23
+ export function motionPathPluginUrl(gsapVersion, baseUrl) {
24
+ return `${gsapCdnDist(gsapVersion, baseUrl)}MotionPathPlugin.min.js`;
9
25
  }