@quintype/native-components 2.30.3 → 2.30.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.30.3",
3
+ "version": "2.30.4",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -108,34 +108,12 @@ export const JSEmbedElement = (props) => {
108
108
  setHeight(parseInt(event.nativeEvent.data));
109
109
  };
110
110
 
111
- // Function to manually extract the base URL from an iframe src
112
- const extractBaseUrlFromIframe = (iframeHtml) => {
113
- const regex = /src="([^"]+)"/; // Regex to extract src URL from iframe
114
- const match = iframeHtml.match(regex);
115
-
116
- if (match && match[1]) {
117
- const srcUrl = match[1]; // The full src URL from iframe
118
-
119
- // Manually extract the base URL (protocol + host + pathname)
120
- const urlPattern = /^(https?:\/\/[^/]+(?:\/[^?]*)?)/;
121
- const baseUrlMatch = srcUrl.match(urlPattern);
122
-
123
- if (baseUrlMatch) {
124
- return baseUrlMatch[1]; // Return the base URL
125
- } else {
126
- console.error('Invalid URL format.');
127
- return null;
128
- }
129
- } else {
130
- console.error('Iframe src not found.');
131
- return null;
132
- }
133
- };
134
-
135
111
  const constructSource = () => {
112
+ const html = getHTMLContent(props.element['embed-js']);
113
+
136
114
  return {
137
- html: getHTMLContent(props.element['embed-js']),
138
- baseUrl: extractBaseUrlFromIframe(getDecodedContent(props.element['embed-js'])),
115
+ html,
116
+ baseUrl: props.appReferer,
139
117
  };
140
118
  };
141
119
 
@@ -220,4 +198,5 @@ JSEmbedElement.propTypes = {
220
198
  height: PropTypes.number,
221
199
  orientation: PropTypes.string,
222
200
  }),
201
+ appReferer: PropTypes.string,
223
202
  };
@@ -79,6 +79,7 @@ const getStoryCards = (
79
79
  currentLayout,
80
80
  getAd,
81
81
  locale,
82
+ appReferer,
82
83
  ) => cards.map((card, index, source) => (
83
84
  <View key={card?.id}>
84
85
  {isLiveBlog
@@ -121,6 +122,7 @@ const getStoryCards = (
121
122
  story={story}
122
123
  storyType={storyType}
123
124
  currentLayout={currentLayout}
125
+ appReferer={appReferer}
124
126
  />
125
127
  </>
126
128
  );
@@ -152,7 +154,8 @@ export const Story = ({
152
154
  gaTrigerredTTS,
153
155
  commentData,
154
156
  commentLoader,
155
- storyLayout
157
+ storyLayout,
158
+ appReferer,
156
159
  }) => {
157
160
  const { theme } = useContext(AppTheme);
158
161
  const { COLORS, FONT_SIZE, locale, DARK_MODE,translate, enableComments } = theme;
@@ -376,6 +379,7 @@ export const Story = ({
376
379
  onAuthorPress={onAuthorPress}
377
380
  onSectionPress={onSectionPress}
378
381
  storyLayout={storyLayout}
382
+ appReferer={appReferer}
379
383
  />
380
384
  { storyHasAccess === 'granted' && audioS3Key && (!showPlayer ?
381
385
  (<TouchableOpacity onPress={async()=>{
@@ -427,6 +431,7 @@ export const Story = ({
427
431
  currentLayout,
428
432
  getAd,
429
433
  locale,
434
+ appReferer,
430
435
  )}
431
436
 
432
437
  {(!(isStoryFree(story) === 0 || storyHasAccess === "granted") && showWall) && <View style={styles.overlay} >
@@ -492,4 +497,5 @@ Story.propTypes = {
492
497
  enableFbComments: PropTypes.bool,
493
498
  currentLayout: PropTypes.any,
494
499
  navigation: PropTypes.any,
500
+ appReferer: PropTypes.string,
495
501
  };
@@ -18,6 +18,7 @@ export const StoryContent = ({
18
18
  story,
19
19
  storyType,
20
20
  currentLayout,
21
+ appReferer,
21
22
  }) => {
22
23
  const textProps = {
23
24
  text: storyElement.text,
@@ -78,7 +79,7 @@ export const StoryContent = ({
78
79
  />
79
80
  );
80
81
  case STORY_ELEMENT_TYPES.YOUTUBE_VIDEO:
81
- return <AllComponents.YouTubePlayer card={storyElement} />;
82
+ return <AllComponents.YouTubePlayer card={storyElement} appReferer={appReferer} />;
82
83
  case STORY_ELEMENT_TYPES.FILE:
83
84
  return <AllComponents.PDFReader card={storyElement} story={story} />;
84
85
  case STORY_ELEMENT_TYPES.DATA:
@@ -109,7 +110,7 @@ export const StoryContent = ({
109
110
  // }
110
111
  // default: break;
111
112
  // }
112
- return <AllComponents.JSEmbedElement element={storyElement} currentLayout={currentLayout} />;
113
+ return <AllComponents.JSEmbedElement element={storyElement} currentLayout={currentLayout} appReferer={appReferer} />;
113
114
  }
114
115
  default:
115
116
  return null;
@@ -125,4 +126,5 @@ StoryContent.propTypes = {
125
126
  screenList: PropTypes.object,
126
127
  navigation: PropTypes.shape({ }),
127
128
  currentLayout: PropTypes.any,
129
+ appReferer: PropTypes.string,
128
130
  };
@@ -37,7 +37,7 @@ const getHeroImage = (cdn, story) => {
37
37
  };
38
38
 
39
39
  const getHeroComponent = (props) => {
40
- const { story = {},firstVideoElement, cdn } = props;
40
+ const { story = {},firstVideoElement, cdn, appReferer } = props;
41
41
 
42
42
  switch (story['story-template']) {
43
43
  case STORY_TYPES.VIDEO_STORY: {
@@ -51,6 +51,7 @@ const getHeroComponent = (props) => {
51
51
  <YouTubePlayer
52
52
  styles={{ container: { padding: 0 } }}
53
53
  card={firstVideoElement}
54
+ appReferer={appReferer}
54
55
  />
55
56
  );
56
57
  }
@@ -182,4 +183,5 @@ StoryHeader.propTypes = {
182
183
  id: PropTypes.string,
183
184
  'embed-url': PropTypes.string,
184
185
  }),
186
+ appReferer: PropTypes.string,
185
187
  };
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { View, useWindowDimensions } from "react-native";
4
4
  import { WebView } from "react-native-webview";
5
5
 
6
- export const YouTubePlayer = ({ card = {} }) => {
6
+ export const YouTubePlayer = ({ card = {}, appReferer }) => {
7
7
  const ytEmbedURL = card['embed-url'];
8
8
  if (!ytEmbedURL) return null;
9
9
 
@@ -53,7 +53,10 @@ export const YouTubePlayer = ({ card = {} }) => {
53
53
  <WebView
54
54
  mediaPlaybackRequiresUserAction
55
55
  style={styles.webViewContainer}
56
- source={{ html: getYoutubeIframe(ytEmbedURL), baseUrl:'https://www.youtube.com'}}
56
+ source={{
57
+ html: getYoutubeIframe(ytEmbedURL),
58
+ baseUrl: appReferer,
59
+ }}
57
60
  javaScriptEnabled
58
61
  domStorageEnabled
59
62
  startInLoadingState
@@ -78,4 +81,5 @@ const webviewStyles = (windowWidth) => {
78
81
 
79
82
  YouTubePlayer.propTypes = {
80
83
  card: PropTypes.any.isRequired,
84
+ appReferer: PropTypes.string,
81
85
  };
@@ -7,3 +7,4 @@ export * from './context';
7
7
  export * from './textUtils';
8
8
  export * from './testUtils';
9
9
  export * from './rtlUtil';
10
+ export * from './refererUtils';
@@ -0,0 +1,14 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ /**
4
+ * Generates the app referer URL based on platform and bundle IDs
5
+ * @param {string} androidBundleId - Android package name (e.g., 'com.example.app')
6
+ * @param {string} iosBundleId - iOS bundle identifier (e.g., 'com.example.app.ios')
7
+ * @returns {string} The referer URL for the current platform
8
+ */
9
+ export const getAppReferer = (androidBundleId, iosBundleId) => {
10
+ return Platform.select({
11
+ ios: `https://${iosBundleId}`,
12
+ android: `https://${androidBundleId}`,
13
+ });
14
+ };