releasebird-javascript-sdk 1.0.46 → 1.0.48

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.
@@ -76,20 +76,33 @@ export class RbirdBannerManager {
76
76
  }
77
77
 
78
78
  this.banners.forEach(banner => {
79
- console.log('[RbirdBannerManager] Rendering banner:', banner.id, 'Type:', banner.type);
79
+ console.log('[RbirdBannerManager] Processing banner:', banner.id, 'Type:', banner.type, 'Placement:', banner.placement);
80
80
  if (banner.type === 'INLINE') {
81
81
  this.renderInlineBanner(banner);
82
82
  } else if (banner.type === 'FLOATING') {
83
83
  this.renderFloatingBanner(banner);
84
+ } else {
85
+ console.warn('[RbirdBannerManager] Unknown banner type:', banner.type);
84
86
  }
85
87
  });
86
88
  }
87
89
 
88
90
  renderInlineBanner(banner) {
89
91
  // Find all elements with data-rbird-banner attribute matching the banner's placement
90
- const targetElements = document.querySelectorAll(`[data-rbird-banner="${banner.placement || 'default'}"]`);
92
+ const placement = banner.placement || 'default';
93
+ console.log('[RbirdBannerManager] Looking for inline banner placement:', placement);
94
+ const targetElements = document.querySelectorAll(`[data-rbird-banner="${placement}"]`);
95
+
96
+ console.log('[RbirdBannerManager] Found', targetElements.length, 'target elements for placement:', placement);
97
+
98
+ if (targetElements.length === 0) {
99
+ console.warn('[RbirdBannerManager] No target elements found for inline banner with placement:', placement,
100
+ 'Make sure you have an element with data-rbird-banner="' + placement + '" in your HTML');
101
+ return;
102
+ }
91
103
 
92
104
  targetElements.forEach(targetElement => {
105
+ console.log('[RbirdBannerManager] Appending banner to element:', targetElement);
93
106
  const bannerElement = this.createBannerElement(banner, false);
94
107
  targetElement.appendChild(bannerElement);
95
108
  this.displayedBanners.add(banner.id);
@@ -118,6 +118,7 @@ export default class RbirdScreenshotManager {
118
118
  cacheBust: true,
119
119
  width: window.innerWidth,
120
120
  height: window.innerHeight,
121
+ skipFonts: true, // Skip web fonts to avoid CORS issues
121
122
  style: {
122
123
  margin: '0',
123
124
  padding: '0'
@@ -132,6 +133,28 @@ export default class RbirdScreenshotManager {
132
133
  return false;
133
134
  }
134
135
  return true;
136
+ },
137
+ onclone: (clonedDocument) => {
138
+ // Remove external stylesheets that may cause CORS issues
139
+ const stylesheets = clonedDocument.querySelectorAll('link[rel="stylesheet"]');
140
+ stylesheets.forEach((stylesheet) => {
141
+ const href = stylesheet.getAttribute('href');
142
+ // Check if it's an external stylesheet (different domain)
143
+ if (href && (href.startsWith('http://') || href.startsWith('https://')) &&
144
+ !href.includes(window.location.hostname)) {
145
+ console.log('[Screenshot] Removing external stylesheet:', href);
146
+ stylesheet.remove();
147
+ }
148
+ });
149
+
150
+ // Remove any style elements that might have problematic imports
151
+ const styles = clonedDocument.querySelectorAll('style');
152
+ styles.forEach((style) => {
153
+ if (style.textContent && style.textContent.includes('@import')) {
154
+ console.log('[Screenshot] Removing style with @import');
155
+ style.remove();
156
+ }
157
+ });
135
158
  }
136
159
  }).then(function (dataUrl) {
137
160
  // Restore visibility
@@ -156,16 +179,98 @@ export default class RbirdScreenshotManager {
156
179
  that.deactivateMarker();
157
180
 
158
181
  }).catch((e) => {
159
- // Restore visibility on error
160
- loader.style.visibility = 'visible';
161
- if (closeButton) {
162
- closeButton.style.visibility = originalCloseButtonVisibility;
163
- }
164
- if (toolbar) {
165
- toolbar.style.visibility = originalToolbarVisibility;
166
- }
167
- that.hideLoader();
168
- console.error('Screenshot error:', e);
182
+ console.error('Screenshot error with toJpeg:', e);
183
+
184
+ // Try alternative method: toPng with more lenient options
185
+ console.log('[Screenshot] Trying alternative method with toPng...');
186
+ htmlToImage.toPng(document.body, {
187
+ quality: 0.95,
188
+ pixelRatio: 1, // Lower resolution for fallback
189
+ cacheBust: true,
190
+ width: window.innerWidth,
191
+ height: window.innerHeight,
192
+ skipFonts: true,
193
+ includeQueryParams: false,
194
+ style: {
195
+ margin: '0',
196
+ padding: '0'
197
+ },
198
+ filter: (node) => {
199
+ if (node.id === 'rbirdScreenshotLoader') {
200
+ return false;
201
+ }
202
+ if (node.classList && node.classList.contains('menu')) {
203
+ return false;
204
+ }
205
+ // Also filter out external iframes and problematic elements
206
+ if (node.tagName === 'IFRAME' || node.tagName === 'OBJECT' || node.tagName === 'EMBED') {
207
+ return false;
208
+ }
209
+ return true;
210
+ },
211
+ onclone: (clonedDocument) => {
212
+ // More aggressive cleanup for fallback
213
+ const stylesheets = clonedDocument.querySelectorAll('link[rel="stylesheet"]');
214
+ stylesheets.forEach((stylesheet) => {
215
+ const href = stylesheet.getAttribute('href');
216
+ if (href && (href.startsWith('http://') || href.startsWith('https://')) &&
217
+ !href.includes(window.location.hostname)) {
218
+ stylesheet.remove();
219
+ }
220
+ });
221
+
222
+ // Remove all external scripts
223
+ const scripts = clonedDocument.querySelectorAll('script');
224
+ scripts.forEach((script) => {
225
+ const src = script.getAttribute('src');
226
+ if (src && (src.startsWith('http://') || src.startsWith('https://')) &&
227
+ !src.includes(window.location.hostname)) {
228
+ script.remove();
229
+ }
230
+ });
231
+
232
+ // Remove problematic style elements
233
+ const styles = clonedDocument.querySelectorAll('style');
234
+ styles.forEach((style) => {
235
+ if (style.textContent && (style.textContent.includes('@import') || style.textContent.includes('cookiehub'))) {
236
+ style.remove();
237
+ }
238
+ });
239
+ }
240
+ }).then(function (dataUrl) {
241
+ // Restore visibility
242
+ loader.style.visibility = 'visible';
243
+ if (closeButton) {
244
+ closeButton.style.visibility = originalCloseButtonVisibility;
245
+ }
246
+ if (toolbar) {
247
+ toolbar.style.visibility = originalToolbarVisibility;
248
+ }
249
+
250
+ that.hideLoader();
251
+
252
+ const widgetInstance = that.getRbirdWebsiteWidget().getInstance();
253
+ if (widgetInstance.iframe) {
254
+ widgetInstance.iframe.contentWindow?.postMessage({
255
+ type: 'screenshot',
256
+ screenshot: dataUrl
257
+ }, '*');
258
+ }
259
+
260
+ that.deactivateMarker();
261
+ }).catch((fallbackError) => {
262
+ // Restore visibility on final error
263
+ loader.style.visibility = 'visible';
264
+ if (closeButton) {
265
+ closeButton.style.visibility = originalCloseButtonVisibility;
266
+ }
267
+ if (toolbar) {
268
+ toolbar.style.visibility = originalToolbarVisibility;
269
+ }
270
+ that.hideLoader();
271
+ console.error('Screenshot failed with both methods:', fallbackError);
272
+ alert('Screenshot failed. This page has external resources that prevent screenshots from being captured. Please try on a different page.');
273
+ });
169
274
  });
170
275
  });
171
276
  }, 100);
package/src/Styles.js CHANGED
@@ -130,6 +130,18 @@ export const injectStyledCSS = (
130
130
  }
131
131
  }
132
132
 
133
+ /* iOS-spezifische Anpassung für dynamische Viewport-Höhe */
134
+ @supports (-webkit-touch-callout: none) {
135
+ .cta__modal {
136
+ height: 100dvh !important;
137
+ max-height: 100dvh !important;
138
+ }
139
+
140
+ .rbird-content-iframe {
141
+ height: 100dvh !important;
142
+ }
143
+ }
144
+
133
145
  .cta__modal_loading {
134
146
  position: fixed;
135
147
  outline: none;
package/webpack.config.js CHANGED
@@ -65,8 +65,8 @@ module.exports = {
65
65
  plugins: [
66
66
  new webpack.DefinePlugin({
67
67
  PRODUCTION: 'true',
68
- API: JSON.stringify("https://api.releasebird.com/papi"),
69
- CONTENT_URL: JSON.stringify("https://wcontent.releasebird.net"),
68
+ API: JSON.stringify("http://localhost:8040/papi"),
69
+ CONTENT_URL: JSON.stringify("http://localhost:4001"),
70
70
  }),
71
71
  {
72
72
  apply: (compiler) => {