@se-studio/core-ui 1.24.3 → 1.24.5
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/CHANGELOG.md +12 -0
- package/CMS_INFRASTRUCTURE.md +1 -1
- package/dist/components/HeroLoopVideo.d.ts +2 -2
- package/dist/components/HeroLoopVideo.d.ts.map +1 -1
- package/dist/components/HeroLoopVideo.js +11 -40
- package/dist/components/HeroLoopVideo.js.map +1 -1
- package/dist/components/HtmlComponent.d.ts.map +1 -1
- package/dist/components/HtmlComponent.js +2 -5
- package/dist/components/HtmlComponent.js.map +1 -1
- package/dist/components/LocalVideo.d.ts.map +1 -1
- package/dist/components/LocalVideo.js +1 -1
- package/dist/components/LocalVideo.js.map +1 -1
- package/dist/utils/wrapHtmlComponentJs.d.ts +10 -0
- package/dist/utils/wrapHtmlComponentJs.d.ts.map +1 -0
- package/dist/utils/wrapHtmlComponentJs.js +12 -0
- package/dist/utils/wrapHtmlComponentJs.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @se-studio/core-ui
|
|
2
2
|
|
|
3
|
+
## 1.24.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dbfb662: Render mute-loop heroes as a plain `<video poster preload="none">` with 1080/720 `<source media>` children. Drop idle injection, load(), and the overlay poster image.
|
|
8
|
+
|
|
9
|
+
## 1.24.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2c479e7: Wrap HtmlComponent customJs in an IIFE so `hcRoot` is per-instance. Two HtmlComponents with scripts on the same page no longer throw `Identifier 'hcRoot' has already been declared`.
|
|
14
|
+
|
|
3
15
|
## 1.24.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/CMS_INFRASTRUCTURE.md
CHANGED
|
@@ -144,7 +144,7 @@ export function PageRenderer({ page }) {
|
|
|
144
144
|
|
|
145
145
|
### HtmlComponent entries
|
|
146
146
|
|
|
147
|
-
Contentful **HTML component** entries (`type: 'HtmlComponent'`) render through `HtmlComponent` inside `CmsContent` and `CmsEmbeddedContent`. Optional config:
|
|
147
|
+
Contentful **HTML component** entries (`type: 'HtmlComponent'`) render through `HtmlComponent` inside `CmsContent` and `CmsEmbeddedContent`. `customJs` runs inside an IIFE with a per-instance `hcRoot` (safe to place more than one scripted HtmlComponent on a page). Optional config:
|
|
148
148
|
|
|
149
149
|
- **`htmlComponentFullWidthClassName`** — Tailwind (or other) classes applied when the entry has `fullWidth: true`. If unset, a built-in viewport-breakout default is used; override per project to match your grid.
|
|
150
150
|
|
|
@@ -4,10 +4,10 @@ export declare function shouldOfferHero1080(visualSizes?: IVisualSizes): boolean
|
|
|
4
4
|
export declare function heroLoopErrorMessage(error: IHeroDelivery['error'] | 'not_mute_loop'): string;
|
|
5
5
|
export declare function formatHeroDurationSec(durationSec?: number): string | undefined;
|
|
6
6
|
export declare function heroLoopErrorMeta(delivery: IHeroDelivery): string | undefined;
|
|
7
|
-
export declare function HeroLoopVideo({ delivery, autoPlay, loop, visualSizes, contained: _contained, dontCrop, verticalCropPosition, horizontalCropPosition, className, style,
|
|
7
|
+
export declare function HeroLoopVideo({ delivery, autoPlay, loop, visualSizes, contained: _contained, dontCrop, verticalCropPosition, horizontalCropPosition, className, style, }: {
|
|
8
8
|
delivery: IHeroDelivery;
|
|
9
9
|
dontCrop?: boolean | null;
|
|
10
10
|
verticalCropPosition?: Vertical | null;
|
|
11
11
|
horizontalCropPosition?: Horizontal | null;
|
|
12
|
-
} & Pick<IVideoProps, 'autoPlay' | 'loop' | 'visualSizes' | 'contained' | 'className' | 'style'
|
|
12
|
+
} & Pick<IVideoProps, 'autoPlay' | 'loop' | 'visualSizes' | 'contained' | 'className' | 'style'>): import("react").JSX.Element;
|
|
13
13
|
//# sourceMappingURL=HeroLoopVideo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeroLoopVideo.d.ts","sourceRoot":"","sources":["../../src/components/HeroLoopVideo.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"HeroLoopVideo.d.ts","sourceRoot":"","sources":["../../src/components/HeroLoopVideo.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAIpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAU3C,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,OAAO,CAUvE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,MAAM,CAc5F;AAED,wBAAgB,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM9E;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAa7E;AASD,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EAAE,UAAU,EACrB,QAAQ,EACR,oBAAoB,EACpB,sBAAsB,EACtB,SAAS,EACT,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,oBAAoB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvC,sBAAsB,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;CAC5C,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC,+BAmF/F"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { processSizes } from '@se-studio/core-data-types';
|
|
4
|
-
import
|
|
5
|
-
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
6
5
|
import { cn } from '../utils/cn';
|
|
7
6
|
import { CONTAINED_VIDEO_CLASSES, CONTENT_VIDEO_CLASSES, calculateCropDetails, shouldShowFullFrameVideo, } from './Visual';
|
|
8
7
|
const LAPTOP_MIN_WIDTH = 1024;
|
|
@@ -59,8 +58,9 @@ function aspectStyle(width, height) {
|
|
|
59
58
|
}
|
|
60
59
|
return { aspectRatio: '16 / 9' };
|
|
61
60
|
}
|
|
62
|
-
export function HeroLoopVideo({ delivery, autoPlay, loop, visualSizes, contained: _contained, dontCrop, verticalCropPosition, horizontalCropPosition, className, style,
|
|
61
|
+
export function HeroLoopVideo({ delivery, autoPlay, loop, visualSizes, contained: _contained, dontCrop, verticalCropPosition, horizontalCropPosition, className, style, }) {
|
|
63
62
|
const isMuteLoop = Boolean(autoPlay && loop);
|
|
63
|
+
const videoRef = useRef(null);
|
|
64
64
|
const crop = calculateCropDetails({
|
|
65
65
|
dontCrop,
|
|
66
66
|
verticalCropPosition,
|
|
@@ -71,6 +71,12 @@ export function HeroLoopVideo({ delivery, autoPlay, loop, visualSizes, contained
|
|
|
71
71
|
...aspectStyle(delivery.width, delivery.height),
|
|
72
72
|
...style,
|
|
73
73
|
};
|
|
74
|
+
// Safari autoplay checks the muted property, not only the attribute.
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (videoRef.current) {
|
|
77
|
+
videoRef.current.muted = true;
|
|
78
|
+
}
|
|
79
|
+
}, []);
|
|
74
80
|
const error = !isMuteLoop
|
|
75
81
|
? 'not_mute_loop'
|
|
76
82
|
: delivery.status === 'rejected' || delivery.status === 'failed'
|
|
@@ -83,44 +89,9 @@ export function HeroLoopVideo({ delivery, autoPlay, loop, visualSizes, contained
|
|
|
83
89
|
if (delivery.status !== 'ready' || !delivery.src720) {
|
|
84
90
|
return (_jsx("div", { className: cn('relative w-full bg-black/5', className), style: boxStyle, "aria-hidden": true }));
|
|
85
91
|
}
|
|
86
|
-
return (_jsx(HeroLoopReadyVideo, { delivery: delivery, visualSizes: visualSizes, className: className, boxStyle: boxStyle, showFullFrame: showFullFrame, crop: crop, loading: loading, fetchPriority: fetchPriority }));
|
|
87
|
-
}
|
|
88
|
-
function HeroLoopReadyVideo({ delivery, visualSizes, className, boxStyle, showFullFrame, crop, loading, fetchPriority, }) {
|
|
89
|
-
const videoRef = useRef(null);
|
|
90
92
|
const offer1080 = Boolean(delivery.src1080 && shouldOfferHero1080(visualSizes));
|
|
91
|
-
const poster = delivery.poster;
|
|
92
|
-
const [posterVisible, setPosterVisible] = useState(Boolean(poster));
|
|
93
|
-
const [sourcesReady, setSourcesReady] = useState(!poster);
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
if (videoRef.current) {
|
|
96
|
-
videoRef.current.muted = true;
|
|
97
|
-
}
|
|
98
|
-
}, []);
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (sourcesReady) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const activate = () => setSourcesReady(true);
|
|
104
|
-
if (typeof requestIdleCallback !== 'undefined') {
|
|
105
|
-
const id = requestIdleCallback(activate, { timeout: 2500 });
|
|
106
|
-
return () => cancelIdleCallback(id);
|
|
107
|
-
}
|
|
108
|
-
const timer = window.setTimeout(activate, 2000);
|
|
109
|
-
return () => window.clearTimeout(timer);
|
|
110
|
-
}, [sourcesReady]);
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (!sourcesReady) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const video = videoRef.current;
|
|
116
|
-
if (!video) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
video.load();
|
|
120
|
-
void video.play().catch(() => { });
|
|
121
|
-
}, [sourcesReady]);
|
|
122
93
|
const width = delivery.width && delivery.width > 0 ? delivery.width : 1920;
|
|
123
94
|
const height = delivery.height && delivery.height > 0 ? delivery.height : 1080;
|
|
124
|
-
return (
|
|
95
|
+
return (_jsx("div", { className: cn('relative block w-full', className), style: boxStyle, children: _jsxs("video", { ref: videoRef, poster: delivery.poster, "aria-hidden": true, className: cn(showFullFrame ? CONTENT_VIDEO_CLASSES : CONTAINED_VIDEO_CLASSES), playsInline: true, autoPlay: true, loop: true, muted: true, controls: false, width: width, height: height, preload: "none", style: { display: 'block', ...crop }, children: [offer1080 && delivery.src1080 ? (_jsx("source", { src: delivery.src1080, media: `(min-width: ${String(LAPTOP_MIN_WIDTH)}px)`, type: "video/mp4" })) : null, _jsx("source", { src: delivery.src720, type: "video/mp4" }), _jsx("track", { kind: "captions", default: true })] }) }));
|
|
125
96
|
}
|
|
126
97
|
//# sourceMappingURL=HeroLoopVideo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeroLoopVideo.js","sourceRoot":"","sources":["../../src/components/HeroLoopVideo.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"HeroLoopVideo.js","sourceRoot":"","sources":["../../src/components/HeroLoopVideo.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAElB,MAAM,gBAAgB,GAA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AAI,EAAC,WAAW,GAChB,CACH,CAAC,CAAC,CAAC,IAAI,EACR,iBAAQ,GAAG,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAC,WAAW,GAAG,EACjD,gBAAO,IAAI,EAAC,UAAU,EAAC,OAAO,SAAG,IAC3B,GACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlComponent.d.ts","sourceRoot":"","sources":["../../src/components/HtmlComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"HtmlComponent.d.ts","sourceRoot":"","sources":["../../src/components/HtmlComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAMrE,0FAA0F;AAC1F,eAAO,MAAM,sCAAsC,8DACU,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IACpD,mHAAmH;IACnH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAC5B,EAAE,EACF,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,0BAA0B,GAC3B,EAAE,kBAAkB,+BA6BpB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from '../utils/cn';
|
|
3
3
|
import { scopeCss } from '../utils/scopeCss';
|
|
4
|
+
import { wrapHtmlComponentJs } from '../utils/wrapHtmlComponentJs';
|
|
4
5
|
import { HtmlComponentScript } from './HtmlComponentScript';
|
|
5
6
|
/** Default Tailwind breakout when `fullWidth` is true and no renderer override is set. */
|
|
6
7
|
export const defaultHtmlComponentFullWidthClassName = 'relative left-1/2 w-screen max-w-[100vw] -translate-x-1/2';
|
|
@@ -17,11 +18,7 @@ export const defaultHtmlComponentFullWidthClassName = 'relative left-1/2 w-scree
|
|
|
17
18
|
export function HtmlComponent({ id, rawHtml, customCss, customJs, fullWidth, scriptStrategy, loadScriptOnce, flowPositionIndex, fullWidthBreakoutClassName, }) {
|
|
18
19
|
const scopedCss = customCss ? scopeCss(customCss, id) : undefined;
|
|
19
20
|
const scriptId = loadScriptOnce ? `hc-${id}` : `hc-${id}-${flowPositionIndex}`;
|
|
20
|
-
|
|
21
|
-
// `document.querySelector('[data-hc-id]')` which would match the first component on the page.
|
|
22
|
-
const scopedJs = customJs
|
|
23
|
-
? `const hcRoot = document.querySelector('[data-hc-id="${id}"]');\n${customJs}`
|
|
24
|
-
: undefined;
|
|
21
|
+
const scopedJs = customJs ? wrapHtmlComponentJs(id, customJs) : undefined;
|
|
25
22
|
let breakout;
|
|
26
23
|
if (fullWidth) {
|
|
27
24
|
if (fullWidthBreakoutClassName !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlComponent.js","sourceRoot":"","sources":["../../src/components/HtmlComponent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,0FAA0F;AAC1F,MAAM,CAAC,MAAM,sCAAsC,GACjD,2DAA2D,CAAC;AAS9D;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,EAAE,EACF,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,0BAA0B,GACP;IACnB,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,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AC5C,QAAQ,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,0BAA0B,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,sCAAsC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,CACL,6BAAiB,EAAE,uBAAqB,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,aACxF,SAAS,IAAI,0BAAQ,SAAS,GAAS,EAExC,cAAK,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAI,EACpD,QAAQ,IAAI,CACX,KAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,GAClB,CACH,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalVideo.d.ts","sourceRoot":"","sources":["../../src/components/LocalVideo.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAiC,EAAE,EAAE,MAAM,OAAO,CAAC;AAI/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiB3C,QAAA,MAAM,UAAU,EAAE,EAAE,CAClB;IACE,KAAK,EAAE,WAAW,GAAG,UAAU,CAAC;IAChC,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"LocalVideo.d.ts","sourceRoot":"","sources":["../../src/components/LocalVideo.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAiC,EAAE,EAAE,MAAM,OAAO,CAAC;AAI/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiB3C,QAAA,MAAM,UAAU,EAAE,EAAE,CAClB;IACE,KAAK,EAAE,WAAW,GAAG,UAAU,CAAC;IAChC,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C,GAAG,WAAW,CA8GhB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -19,7 +19,7 @@ const LocalVideo = ({ video, autoPlay, loop, controls, poster, contained, analyt
|
|
|
19
19
|
const resolvedAutoPlay = video.autoPlay ?? autoPlay;
|
|
20
20
|
const resolvedLoop = video.loop ?? loop;
|
|
21
21
|
if (video.heroDelivery) {
|
|
22
|
-
return (_jsx(HeroLoopVideo, { delivery: video.heroDelivery, autoPlay: resolvedAutoPlay, loop: resolvedLoop, visualSizes: props.visualSizes, contained: contained, dontCrop: video.dontCrop, verticalCropPosition: video.verticalCropPosition, horizontalCropPosition: video.horizontalCropPosition, className: props.className, style: props.style
|
|
22
|
+
return (_jsx(HeroLoopVideo, { delivery: video.heroDelivery, autoPlay: resolvedAutoPlay, loop: resolvedLoop, visualSizes: props.visualSizes, contained: contained, dontCrop: video.dontCrop, verticalCropPosition: video.verticalCropPosition, horizontalCropPosition: video.horizontalCropPosition, className: props.className, style: props.style }));
|
|
23
23
|
}
|
|
24
24
|
const playbackUrl = hostedPlaybackUrl(video);
|
|
25
25
|
if (!playbackUrl) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalVideo.js","sourceRoot":"","sources":["../../src/components/LocalVideo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OA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Z,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,cAAc,KAClB,eAAe,KACf,KAAK;QACT,8DAA8D;QAC9D,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAChD,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,GACpD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps HtmlComponent `customJs` so `hcRoot` is function-scoped.
|
|
3
|
+
*
|
|
4
|
+
* `@se-studio/core-ui` prepends `const hcRoot = …` so authors can query this
|
|
5
|
+
* instance. Inline `next/script` payloads on one page share a JS realm, so a
|
|
6
|
+
* second top-level `const hcRoot` throws and the later script never runs.
|
|
7
|
+
* An IIFE keeps the documented `hcRoot` name without colliding.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wrapHtmlComponentJs(id: string, customJs: string): string;
|
|
10
|
+
//# sourceMappingURL=wrapHtmlComponentJs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapHtmlComponentJs.d.ts","sourceRoot":"","sources":["../../src/utils/wrapHtmlComponentJs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps HtmlComponent `customJs` so `hcRoot` is function-scoped.
|
|
3
|
+
*
|
|
4
|
+
* `@se-studio/core-ui` prepends `const hcRoot = …` so authors can query this
|
|
5
|
+
* instance. Inline `next/script` payloads on one page share a JS realm, so a
|
|
6
|
+
* second top-level `const hcRoot` throws and the later script never runs.
|
|
7
|
+
* An IIFE keeps the documented `hcRoot` name without colliding.
|
|
8
|
+
*/
|
|
9
|
+
export function wrapHtmlComponentJs(id, customJs) {
|
|
10
|
+
return `(function () {\n const hcRoot = document.querySelector('[data-hc-id="' + ${JSON.stringify(id)} + '"]');\n${customJs}\n})();`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=wrapHtmlComponentJs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapHtmlComponentJs.js","sourceRoot":"","sources":["../../src/utils/wrapHtmlComponentJs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAU,EAAE,QAAgB;IAC9D,OAAO,6EAA6E,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,cAAc,QAAQ,SAAS,CAAC;AACxI,CAAC"}
|