@flamingo-stack/openframe-frontend-core 0.0.177 → 0.0.178
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-6LDN3CIY.js → chunk-AAX27BCR.js} +189 -348
- package/dist/chunk-AAX27BCR.js.map +1 -0
- package/dist/{chunk-WX7PT5C7.cjs → chunk-ALW3D72O.cjs} +61 -2
- package/dist/chunk-ALW3D72O.cjs.map +1 -0
- package/dist/{chunk-KB2N44BY.js → chunk-FMWHOUFE.js} +61 -2
- package/dist/chunk-FMWHOUFE.js.map +1 -0
- package/dist/{chunk-C6ZMI4UB.cjs → chunk-L4T24AN4.cjs} +113 -272
- package/dist/chunk-L4T24AN4.cjs.map +1 -0
- package/dist/components/features/index.cjs +3 -5
- package/dist/components/features/index.cjs.map +1 -1
- package/dist/components/features/index.js +2 -4
- package/dist/components/features/video-player.d.ts +17 -20
- package/dist/components/features/video-player.d.ts.map +1 -1
- package/dist/components/features/youtube-embed.d.ts +18 -4
- package/dist/components/features/youtube-embed.d.ts.map +1 -1
- package/dist/components/index.cjs +3 -5
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +2 -4
- package/dist/components/navigation/index.cjs +3 -3
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/hooks/index.cjs +4 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/use-near-viewport.d.ts +42 -0
- package/dist/hooks/use-near-viewport.d.ts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/src/components/features/video-player.tsx +39 -176
- package/src/components/features/youtube-embed.tsx +107 -224
- package/src/hooks/index.ts +3 -0
- package/src/hooks/use-near-viewport.ts +118 -0
- package/dist/chunk-6LDN3CIY.js.map +0 -1
- package/dist/chunk-C6ZMI4UB.cjs.map +0 -1
- package/dist/chunk-KB2N44BY.js.map +0 -1
- package/dist/chunk-WX7PT5C7.cjs.map +0 -1
- package/src/components/features/__tests__/video-player.test.tsx +0 -142
|
@@ -3052,6 +3052,64 @@ function useNatsClient(clientOptions, options = {}) {
|
|
|
3052
3052
|
};
|
|
3053
3053
|
}
|
|
3054
3054
|
|
|
3055
|
+
// src/hooks/use-near-viewport.ts
|
|
3056
|
+
import { useEffect as useEffect16, useRef as useRef11, useState as useState21, useCallback as useCallback12 } from "react";
|
|
3057
|
+
var observers = /* @__PURE__ */ new Map();
|
|
3058
|
+
var subscribers = /* @__PURE__ */ new WeakMap();
|
|
3059
|
+
function getObserverFor(rootMargin) {
|
|
3060
|
+
const existing = observers.get(rootMargin);
|
|
3061
|
+
if (existing) return existing;
|
|
3062
|
+
const io = new IntersectionObserver(
|
|
3063
|
+
(entries) => {
|
|
3064
|
+
entries.forEach((entry) => {
|
|
3065
|
+
if (!entry.isIntersecting) return;
|
|
3066
|
+
const cb = subscribers.get(entry.target);
|
|
3067
|
+
if (cb) {
|
|
3068
|
+
cb();
|
|
3069
|
+
io.unobserve(entry.target);
|
|
3070
|
+
subscribers.delete(entry.target);
|
|
3071
|
+
}
|
|
3072
|
+
});
|
|
3073
|
+
},
|
|
3074
|
+
{ rootMargin }
|
|
3075
|
+
);
|
|
3076
|
+
observers.set(rootMargin, io);
|
|
3077
|
+
return io;
|
|
3078
|
+
}
|
|
3079
|
+
function useNearViewport(rootMargin = "500px") {
|
|
3080
|
+
const [isNear, setIsNear] = useState21(false);
|
|
3081
|
+
const elRef = useRef11(null);
|
|
3082
|
+
const ref = useCallback12(
|
|
3083
|
+
(node) => {
|
|
3084
|
+
const prev = elRef.current;
|
|
3085
|
+
if (prev) {
|
|
3086
|
+
const stillOurs = subscribers.get(prev);
|
|
3087
|
+
if (stillOurs) {
|
|
3088
|
+
subscribers.delete(prev);
|
|
3089
|
+
observers.get(rootMargin)?.unobserve(prev);
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
elRef.current = node;
|
|
3093
|
+
if (!node) return;
|
|
3094
|
+
const cb = () => setIsNear(true);
|
|
3095
|
+
subscribers.set(node, cb);
|
|
3096
|
+
getObserverFor(rootMargin).observe(node);
|
|
3097
|
+
},
|
|
3098
|
+
[rootMargin]
|
|
3099
|
+
);
|
|
3100
|
+
useEffect16(() => {
|
|
3101
|
+
return () => {
|
|
3102
|
+
const el = elRef.current;
|
|
3103
|
+
if (!el) return;
|
|
3104
|
+
if (subscribers.get(el)) {
|
|
3105
|
+
subscribers.delete(el);
|
|
3106
|
+
observers.get(rootMargin)?.unobserve(el);
|
|
3107
|
+
}
|
|
3108
|
+
};
|
|
3109
|
+
}, [rootMargin]);
|
|
3110
|
+
return { ref, isNear };
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3055
3113
|
export {
|
|
3056
3114
|
useAutoLimitTags,
|
|
3057
3115
|
platformIcons,
|
|
@@ -3133,6 +3191,7 @@ export {
|
|
|
3133
3191
|
createSearchParams,
|
|
3134
3192
|
useCursorPaginationState,
|
|
3135
3193
|
createNatsClient,
|
|
3136
|
-
useNatsClient
|
|
3194
|
+
useNatsClient,
|
|
3195
|
+
useNearViewport
|
|
3137
3196
|
};
|
|
3138
|
-
//# sourceMappingURL=chunk-
|
|
3197
|
+
//# sourceMappingURL=chunk-FMWHOUFE.js.map
|