@temple-wallet/extension-ads 8.1.0-dev.5 → 8.1.0

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.
Files changed (90) hide show
  1. package/dist/ads-actions/helpers.d.ts +17 -0
  2. package/dist/ads-actions/helpers.js +96 -0
  3. package/dist/ads-actions/helpers.js.map +1 -0
  4. package/dist/ads-actions/index.d.ts +3 -0
  5. package/dist/ads-actions/index.js +63 -0
  6. package/dist/ads-actions/index.js.map +1 -0
  7. package/dist/ads-actions/process-elements-to-hide-or-remove-rule.d.ts +3 -0
  8. package/dist/ads-actions/process-elements-to-hide-or-remove-rule.js +19 -0
  9. package/dist/ads-actions/process-elements-to-hide-or-remove-rule.js.map +1 -0
  10. package/dist/ads-actions/process-permanent-rule.d.ts +3 -0
  11. package/dist/ads-actions/process-permanent-rule.js +143 -0
  12. package/dist/ads-actions/process-permanent-rule.js.map +1 -0
  13. package/dist/ads-actions/process-providers-ads.d.ts +3 -0
  14. package/dist/ads-actions/process-providers-ads.js +137 -0
  15. package/dist/ads-actions/process-providers-ads.js.map +1 -0
  16. package/dist/ads-actions/process-rule.d.ts +3 -0
  17. package/dist/ads-actions/process-rule.js +98 -0
  18. package/dist/ads-actions/process-rule.js.map +1 -0
  19. package/dist/ads-configuration.d.ts +31 -0
  20. package/dist/ads-configuration.js +30 -0
  21. package/dist/ads-configuration.js.map +1 -0
  22. package/dist/constants.d.ts +11 -0
  23. package/dist/constants.js +12 -0
  24. package/dist/constants.js.map +1 -0
  25. package/dist/execute-ads-actions/ads-views/index.d.ts +3 -0
  26. package/dist/execute-ads-actions/ads-views/index.js +4 -0
  27. package/dist/execute-ads-actions/ads-views/index.js.map +1 -0
  28. package/dist/execute-ads-actions/ads-views/make-ads-tw-view.d.ts +3 -0
  29. package/dist/execute-ads-actions/ads-views/make-ads-tw-view.js +40 -0
  30. package/dist/execute-ads-actions/ads-views/make-ads-tw-view.js.map +1 -0
  31. package/dist/execute-ads-actions/ads-views/make-extension-iframe-view.d.ts +3 -0
  32. package/dist/execute-ads-actions/ads-views/make-extension-iframe-view.js +22 -0
  33. package/dist/execute-ads-actions/ads-views/make-extension-iframe-view.js.map +1 -0
  34. package/dist/execute-ads-actions/ads-views/make-tkey-ad.d.ts +3 -0
  35. package/dist/execute-ads-actions/ads-views/make-tkey-ad.js +38 -0
  36. package/dist/execute-ads-actions/ads-views/make-tkey-ad.js.map +1 -0
  37. package/dist/execute-ads-actions/index.d.ts +2 -0
  38. package/dist/execute-ads-actions/index.js +23 -0
  39. package/dist/execute-ads-actions/index.js.map +1 -0
  40. package/dist/execute-ads-actions/observing.d.ts +1 -0
  41. package/dist/execute-ads-actions/observing.js +129 -0
  42. package/dist/execute-ads-actions/observing.js.map +1 -0
  43. package/dist/execute-ads-actions/override-element-styles.d.ts +2 -0
  44. package/dist/execute-ads-actions/override-element-styles.js +6 -0
  45. package/dist/execute-ads-actions/override-element-styles.js.map +1 -0
  46. package/dist/execute-ads-actions/process-insert-ad-action.d.ts +2 -0
  47. package/dist/execute-ads-actions/process-insert-ad-action.js +153 -0
  48. package/dist/execute-ads-actions/process-insert-ad-action.js.map +1 -0
  49. package/dist/index.d.ts +0 -1
  50. package/dist/index.js +14 -12
  51. package/dist/index.js.map +1 -0
  52. package/dist/render-ads-stack.d.ts +7 -0
  53. package/dist/render-ads-stack.js +156 -0
  54. package/dist/render-ads-stack.js.map +1 -0
  55. package/dist/temple-wallet-api.d.ts +23 -0
  56. package/dist/temple-wallet-api.js +67 -0
  57. package/dist/temple-wallet-api.js.map +1 -0
  58. package/dist/transform-raw-rules.d.ts +3 -0
  59. package/dist/transform-raw-rules.js +137 -0
  60. package/dist/transform-raw-rules.js.map +1 -0
  61. package/dist/types/ad-view.d.ts +7 -0
  62. package/dist/types/ad-view.js +2 -0
  63. package/dist/types/ad-view.js.map +1 -0
  64. package/dist/types/ads-actions.d.ts +56 -0
  65. package/dist/types/ads-actions.js +15 -0
  66. package/dist/types/ads-actions.js.map +1 -0
  67. package/dist/types/ads-meta.d.ts +19 -0
  68. package/dist/types/ads-meta.js +2 -0
  69. package/dist/types/ads-meta.js.map +1 -0
  70. package/dist/types/ads-provider.d.ts +8 -0
  71. package/dist/types/ads-provider.js +9 -0
  72. package/dist/types/ads-provider.js.map +1 -0
  73. package/dist/types/ads-rules.d.ts +26 -0
  74. package/dist/types/ads-rules.js +2 -0
  75. package/dist/types/ads-rules.js.map +1 -0
  76. package/dist/types/temple-wallet-api.d.ts +78 -0
  77. package/dist/types/temple-wallet-api.js +2 -0
  78. package/dist/types/temple-wallet-api.js.map +1 -0
  79. package/dist/utils.d.ts +6 -0
  80. package/dist/utils.js +4 -0
  81. package/dist/utils.js.map +1 -0
  82. package/package.json +3 -2
  83. package/src/ads-actions/helpers.ts +2 -36
  84. package/src/ads-actions/process-permanent-rule.ts +3 -5
  85. package/src/ads-actions/process-providers-ads.ts +2 -28
  86. package/src/execute-ads-actions/observing.ts +1 -3
  87. package/src/execute-ads-actions/process-insert-ad-action.ts +4 -24
  88. package/src/render-ads-stack.ts +2 -12
  89. package/src/temple-wallet-api.ts +2 -1
  90. package/src/types/ads-actions.ts +0 -1
@@ -33,15 +33,7 @@ const processInsertAdActionOnce = async (
33
33
  insertionPoint: HTMLDivElement | HTMLTableCellElement,
34
34
  onAdsStackError: (error: Error) => void
35
35
  ) => {
36
- const {
37
- elementStyle = {},
38
- stylesOverrides = [],
39
- adsMetadata,
40
- wrapperType,
41
- originalHeight,
42
- originalWidth,
43
- shouldUseBlurredBackground
44
- } = action;
36
+ const { elementStyle = {}, stylesOverrides = [], adsMetadata, wrapperType, originalHeight, originalWidth } = action;
45
37
 
46
38
  stylesOverrides.sort((a, b) => a.parentDepth - b.parentDepth);
47
39
 
@@ -57,8 +49,8 @@ const processInsertAdActionOnce = async (
57
49
  const { dimensions: minDimensions } =
58
50
  typeof firstAdMetadataOrId === 'number' ? AdsConfiguration.bannerAdsMeta[firstAdMetadataOrId] : firstAdMetadataOrId;
59
51
  const dimensions = {
60
- width: shouldUseBlurredBackground ? Math.max(originalWidth, minDimensions.width) : minDimensions.width,
61
- height: shouldUseBlurredBackground ? Math.max(originalHeight, minDimensions.height) : minDimensions.height
52
+ width: Math.max(originalWidth, minDimensions.width),
53
+ height: Math.max(originalHeight, minDimensions.height)
62
54
  };
63
55
  adElement.style.width = wrapperType === 'tbody' ? '100%' : `${dimensions.width}px`;
64
56
  adElement.style.height = `${dimensions.height}px`;
@@ -82,23 +74,11 @@ const processInsertAdActionOnce = async (
82
74
  action.element.replaceWith(wrapperElement);
83
75
  break;
84
76
  default:
85
- const nextSibling = action.parent.children[action.insertionIndex];
86
77
  if (action.isSiblingReplacement) {
87
78
  wrapperElement.setAttribute(SIBLING_REPLACEMENT_ATTRIBUTE_NAME, 'true');
88
- const observer = new MutationObserver(mutations => {
89
- const hasRemoveSiblingMutation = mutations.some(mutation =>
90
- Array.from(mutation.removedNodes).includes(nextSibling)
91
- );
92
-
93
- if (hasRemoveSiblingMutation) {
94
- wrapperElement.remove();
95
- observer.disconnect();
96
- }
97
- });
98
- observer.observe(action.parent, { childList: true });
99
79
  }
100
80
  stylesOverridesCurrentElement = action.parent;
101
- action.parent.insertBefore(wrapperElement, nextSibling);
81
+ action.parent.insertBefore(wrapperElement, action.parent.children[action.insertionIndex]);
102
82
  break;
103
83
  }
104
84
 
@@ -35,8 +35,6 @@ export const renderAdsStack = async (
35
35
  typeof adMetadataOrId === 'number' ? AdsConfiguration.bannerAdsMeta[adMetadataOrId] : adMetadataOrId;
36
36
  broadcastMessage({ id: adId, type: AD_RENDER_START_MESSAGE_TYPE, adMetadata });
37
37
 
38
- document.body.style.backgroundColor = adMetadata.source.native ? 'transparent' : '#F2F2F2';
39
-
40
38
  const { source, dimensions } = adMetadata;
41
39
  let adView: AdView;
42
40
  switch (source.providerName) {
@@ -60,17 +58,9 @@ export const renderAdsStack = async (
60
58
  else templeLabelElement.removeAttribute('active');
61
59
 
62
60
  const updateBackground = (creativeSet: CreativeSet = {}) => {
63
- const prevBackgroundElement = document.getElementById(BACKGROUND_ELEMENT_ID);
64
- if (source.native && prevBackgroundElement) {
65
- rootElement.removeChild(prevBackgroundElement);
66
- }
67
-
68
- if (source.native) {
69
- return;
70
- }
71
-
72
61
  try {
73
62
  const { image, video } = creativeSet;
63
+ const prevBackgroundElement = document.getElementById(BACKGROUND_ELEMENT_ID);
74
64
  let backgroundElement: HTMLImageElement | HTMLVideoElement | undefined;
75
65
  if (image) {
76
66
  backgroundElement = document.createElement('img');
@@ -108,7 +98,7 @@ export const renderAdsStack = async (
108
98
  if (prevBackgroundElement) {
109
99
  rootElement.replaceChild(backgroundElement, prevBackgroundElement);
110
100
  } else {
111
- rootElement.prepend(backgroundElement);
101
+ rootElement.appendChild(backgroundElement);
112
102
  }
113
103
  } catch (e) {
114
104
  console.error(e);
@@ -1,3 +1,4 @@
1
+ import axiosFetchAdapter from '@vespaiach/axios-fetch-adapter';
1
2
  import axios, { AxiosInstance, AxiosResponse } from 'axios';
2
3
 
3
4
  import {
@@ -24,7 +25,7 @@ export class TempleWalletApi {
24
25
  constructor(baseUrl: string) {
25
26
  this.api = axios.create({
26
27
  baseURL: new URL('/api', baseUrl).href,
27
- adapter: 'fetch'
28
+ adapter: axiosFetchAdapter
28
29
  });
29
30
  }
30
31
 
@@ -31,7 +31,6 @@ interface InsertAdActionProps
31
31
  stylesOverrides?: AdStylesOverrides[];
32
32
  originalWidth: number;
33
33
  originalHeight: number;
34
- shouldUseBlurredBackground?: boolean;
35
34
  }
36
35
 
37
36
  export interface ReplaceAllChildrenWithAdAction extends AdActionBase, InsertAdActionProps {