@astronox/core 0.5.1 → 0.5.3

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": "@astronox/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Reusable Astro components, patterns, styles, and infrastructure for AstroNox sites.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -54,27 +54,18 @@ const adBlockingStorageKey = adBlockingRecovery?.storageKey ?? '';
54
54
  storageAvailable = false;
55
55
  }
56
56
 
57
- const cooldownActive =
57
+ let cooldownActive =
58
58
  storedTimestamp !== undefined &&
59
59
  now - storedTimestamp < adBlockingRedisplayIntervalMs;
60
- let adBlockingAuthorized = false;
61
- let blockerConfirmed = false;
62
- let timestampPersisted = false;
63
60
 
64
- const persistAuthorizationTimestamp = () => {
65
- if (
66
- cooldownActive ||
67
- !storageAvailable ||
68
- !adBlockingAuthorized ||
69
- !blockerConfirmed ||
70
- timestampPersisted
71
- ) {
72
- return;
73
- }
61
+ const startCooldown = () => {
62
+ if (cooldownActive) return;
63
+
64
+ cooldownActive = true;
65
+ if (!storageAvailable) return;
74
66
 
75
67
  try {
76
68
  window.localStorage.setItem(adBlockingStorageKey, String(Date.now()));
77
- timestampPersisted = true;
78
69
  } catch {
79
70
  storageAvailable = false;
80
71
  }
@@ -85,7 +76,11 @@ const adBlockingStorageKey = adBlockingRecovery?.storageKey ?? '';
85
76
 
86
77
  if (cooldownActive) {
87
78
  const adBlockingType = googlefc.MessageTypeEnum?.AD_BLOCKING;
88
- if (typeof adBlockingType === 'number') {
79
+ if (
80
+ (typeof adBlockingType === 'string' && adBlockingType.length > 0) ||
81
+ (typeof adBlockingType === 'number' &&
82
+ Number.isFinite(adBlockingType))
83
+ ) {
89
84
  message.proceed(false, [adBlockingType]);
90
85
  return;
91
86
  }
@@ -94,40 +89,9 @@ const adBlockingStorageKey = adBlockingRecovery?.storageKey ?? '';
94
89
  return;
95
90
  }
96
91
 
97
- adBlockingAuthorized = true;
92
+ startCooldown();
98
93
  message.proceed(true);
99
- persistAuthorizationTimestamp();
100
94
  };
101
-
102
- googlefc.callbackQueue.push({
103
- AD_BLOCK_DATA_READY: () => {
104
- if (
105
- typeof googlefc.getAdBlockerStatus !== 'function' ||
106
- !googlefc.AdBlockerStatusEnum
107
- ) {
108
- return;
109
- }
110
-
111
- const status = googlefc.getAdBlockerStatus();
112
- if (typeof status !== 'number' || !Number.isFinite(status)) return;
113
-
114
- const statusEnum = googlefc.AdBlockerStatusEnum;
115
- const blockerStatuses = new Set(
116
- [
117
- statusEnum.EXTENSION_AD_BLOCKER,
118
- statusEnum.EXTENSION_LEVEL_AD_BLOCKER,
119
- statusEnum.NETWORK_LEVEL_AD_BLOCKER,
120
- ].filter(
121
- (value) => typeof value === 'number' && Number.isFinite(value),
122
- ),
123
- );
124
-
125
- if (!blockerStatuses.has(status)) return;
126
-
127
- blockerConfirmed = true;
128
- persistAuthorizationTimestamp();
129
- },
130
- });
131
95
  }
132
96
 
133
97
  if (!publisherLauncher) return;