rampkit-expo-dev 0.0.85 → 0.0.88

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.
@@ -1127,6 +1127,124 @@ function Overlay(props) {
1127
1127
  detail: { screenIndex: ${screenIndex}, screenId: '${screenId}' }
1128
1128
  }));
1129
1129
  } catch(e) {}
1130
+
1131
+ // Process on-open actions (SDK-side handling)
1132
+ // This ensures actions run when screen becomes VISIBLE, not when loaded
1133
+ try {
1134
+ if (window.__rampkitOnOpenActionsProcessed) return; // Only run once per screen visibility
1135
+ window.__rampkitOnOpenActionsProcessed = true;
1136
+
1137
+ var elements = document.querySelectorAll('[data-on-open-actions]');
1138
+ elements.forEach(function(el) {
1139
+ try {
1140
+ var actionsStr = el.getAttribute('data-on-open-actions');
1141
+ if (!actionsStr) return;
1142
+
1143
+ // Decode HTML entities
1144
+ actionsStr = actionsStr.replace(/"/g, '"').replace(/"/g, '"')
1145
+ .replace(/'/g, "'").replace(/'/g, "'")
1146
+ .replace(/&lt;/g, '<').replace(/&gt;/g, '>')
1147
+ .replace(/&amp;/g, '&');
1148
+
1149
+ var actions = JSON.parse(actionsStr);
1150
+ if (!Array.isArray(actions)) return;
1151
+
1152
+ console.log('[RampKit] Processing on-open actions:', actions.length);
1153
+
1154
+ // Execute actions in sequence with delays
1155
+ var executeActions = function(actionList, index) {
1156
+ if (index >= actionList.length) return;
1157
+ if (!window.__rampkitScreenVisible) return; // Stop if screen became inactive
1158
+
1159
+ var action = actionList[index];
1160
+ var actionType = action.type || action.actionType;
1161
+
1162
+ console.log('[RampKit] Executing on-open action:', actionType);
1163
+
1164
+ if (actionType === 'wait') {
1165
+ var waitMs = action.waitMs || action.duration || 1000;
1166
+ setTimeout(function() {
1167
+ executeActions(actionList, index + 1);
1168
+ }, waitMs);
1169
+ return;
1170
+ }
1171
+
1172
+ if (actionType === 'navigate' || actionType === 'continue') {
1173
+ var target = action.targetScreenId || action.target || '__continue__';
1174
+ var animation = action.animation || 'fade';
1175
+ window.ReactNativeWebView.postMessage(JSON.stringify({
1176
+ type: 'rampkit:navigate',
1177
+ targetScreenId: target,
1178
+ animation: animation,
1179
+ fromOnOpen: true
1180
+ }));
1181
+ // Don't continue to next action after navigate
1182
+ return;
1183
+ }
1184
+
1185
+ if (actionType === 'goBack') {
1186
+ window.ReactNativeWebView.postMessage(JSON.stringify({
1187
+ type: 'rampkit:goBack',
1188
+ animation: action.animation || 'fade',
1189
+ fromOnOpen: true
1190
+ }));
1191
+ return;
1192
+ }
1193
+
1194
+ if (actionType === 'requestReview' || actionType === 'request-review') {
1195
+ window.ReactNativeWebView.postMessage(JSON.stringify({
1196
+ type: 'rampkit:request-review',
1197
+ fromOnOpen: true
1198
+ }));
1199
+ executeActions(actionList, index + 1);
1200
+ return;
1201
+ }
1202
+
1203
+ if (actionType === 'requestNotificationPermission' || actionType === 'request-notification-permission') {
1204
+ window.ReactNativeWebView.postMessage(JSON.stringify({
1205
+ type: 'rampkit:request-notification-permission',
1206
+ ios: action.ios,
1207
+ android: action.android,
1208
+ behavior: action.behavior,
1209
+ fromOnOpen: true
1210
+ }));
1211
+ executeActions(actionList, index + 1);
1212
+ return;
1213
+ }
1214
+
1215
+ if (actionType === 'haptic') {
1216
+ window.ReactNativeWebView.postMessage(JSON.stringify({
1217
+ type: 'rampkit:haptic',
1218
+ hapticType: action.hapticType || 'impact',
1219
+ impactStyle: action.impactStyle || 'Medium',
1220
+ fromOnOpen: true
1221
+ }));
1222
+ executeActions(actionList, index + 1);
1223
+ return;
1224
+ }
1225
+
1226
+ if (actionType === 'close') {
1227
+ window.ReactNativeWebView.postMessage(JSON.stringify({
1228
+ type: 'rampkit:close',
1229
+ fromOnOpen: true
1230
+ }));
1231
+ return;
1232
+ }
1233
+
1234
+ // Unknown action, continue to next
1235
+ executeActions(actionList, index + 1);
1236
+ };
1237
+
1238
+ // Start executing actions
1239
+ executeActions(actions, 0);
1240
+
1241
+ } catch(e) {
1242
+ console.log('[RampKit] Error processing on-open actions:', e);
1243
+ }
1244
+ });
1245
+ } catch(e) {
1246
+ console.log('[RampKit] Error finding on-open actions:', e);
1247
+ }
1130
1248
  })();`;
1131
1249
  // @ts-ignore: injectJavaScript exists on WebView instance
1132
1250
  wv.injectJavaScript(activateScript);
@@ -1143,6 +1261,7 @@ function Overlay(props) {
1143
1261
  }
1144
1262
  const deactivateScript = `(function() {
1145
1263
  window.__rampkitScreenVisible = false;
1264
+ window.__rampkitOnOpenActionsProcessed = false; // Reset so on-open can run again if user returns
1146
1265
  console.log('🔒 Screen ${screenIndex} DEACTIVATED');
1147
1266
 
1148
1267
  // Pause all Lottie animations
@@ -1913,7 +2032,13 @@ function Overlay(props) {
1913
2032
  // 3) A page requested an in-app review prompt
1914
2033
  if ((data === null || data === void 0 ? void 0 : data.type) === "rampkit:request-review" ||
1915
2034
  (data === null || data === void 0 ? void 0 : data.type) === "rampkit:review") {
1916
- const executeReview = async () => {
2035
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2036
+ if (!isScreenActive(i)) {
2037
+ if (__DEV__)
2038
+ console.log(`[Rampkit] Ignoring review request from inactive screen ${i} (SDK handles on-open)`);
2039
+ return;
2040
+ }
2041
+ (async () => {
1917
2042
  try {
1918
2043
  const available = await RampKitNative_1.StoreReview.isAvailableAsync();
1919
2044
  if (available) {
@@ -1921,36 +2046,22 @@ function Overlay(props) {
1921
2046
  }
1922
2047
  }
1923
2048
  catch (_) { }
1924
- };
1925
- // Only execute if screen is active, otherwise queue for later
1926
- if (isScreenActive(i)) {
1927
- executeReview();
1928
- }
1929
- else {
1930
- if (__DEV__)
1931
- console.log(`[Rampkit] Queuing review request from inactive screen ${i}`);
1932
- queueAction(i, executeReview);
1933
- }
2049
+ })();
1934
2050
  return;
1935
2051
  }
1936
2052
  // 4) A page requested notification permission
1937
2053
  if ((data === null || data === void 0 ? void 0 : data.type) === "rampkit:request-notification-permission") {
1938
- const executeNotification = () => {
1939
- handleNotificationPermissionRequest({
1940
- ios: data === null || data === void 0 ? void 0 : data.ios,
1941
- android: data === null || data === void 0 ? void 0 : data.android,
1942
- behavior: data === null || data === void 0 ? void 0 : data.behavior,
1943
- });
1944
- };
1945
- // Only execute if screen is active, otherwise queue for later
1946
- if (isScreenActive(i)) {
1947
- executeNotification();
1948
- }
1949
- else {
2054
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2055
+ if (!isScreenActive(i)) {
1950
2056
  if (__DEV__)
1951
- console.log(`[Rampkit] Queuing notification request from inactive screen ${i}`);
1952
- queueAction(i, executeNotification);
2057
+ console.log(`[Rampkit] Ignoring notification request from inactive screen ${i} (SDK handles on-open)`);
2058
+ return;
1953
2059
  }
2060
+ handleNotificationPermissionRequest({
2061
+ ios: data === null || data === void 0 ? void 0 : data.ios,
2062
+ android: data === null || data === void 0 ? void 0 : data.android,
2063
+ behavior: data === null || data === void 0 ? void 0 : data.behavior,
2064
+ });
1954
2065
  return;
1955
2066
  }
1956
2067
  // 5) Onboarding finished event from page
@@ -1988,56 +2099,48 @@ function Overlay(props) {
1988
2099
  }
1989
2100
  if ((data === null || data === void 0 ? void 0 : data.type) === "rampkit:continue" ||
1990
2101
  (data === null || data === void 0 ? void 0 : data.type) === "continue") {
1991
- const executeContinue = () => handleAdvance(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
1992
- // Queue if screen is not active (e.g., on-open actions during preload)
2102
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
1993
2103
  if (!isScreenActive(i)) {
1994
2104
  if (__DEV__)
1995
- console.log(`[Rampkit] Queuing continue from inactive screen ${i}`);
1996
- queueAction(i, executeContinue);
2105
+ console.log(`[Rampkit] Ignoring continue from inactive screen ${i} (SDK handles on-open)`);
1997
2106
  return;
1998
2107
  }
1999
- executeContinue();
2108
+ handleAdvance(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2000
2109
  return;
2001
2110
  }
2002
2111
  if ((data === null || data === void 0 ? void 0 : data.type) === "rampkit:navigate") {
2003
- const target = data === null || data === void 0 ? void 0 : data.targetScreenId;
2004
- const executeNavigate = () => {
2005
- if (target === "__goBack__") {
2006
- handleGoBack(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2007
- return;
2008
- }
2009
- if (!target || target === "__continue__") {
2010
- handleAdvance(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2011
- return;
2012
- }
2013
- const targetIndex = props.screens.findIndex((s) => s.id === target);
2014
- if (targetIndex >= 0) {
2015
- navigateToIndex(targetIndex, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2016
- }
2017
- else {
2018
- handleAdvance(i);
2019
- }
2020
- };
2021
- // Queue if screen is not active (e.g., on-open actions during preload)
2112
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2022
2113
  if (!isScreenActive(i)) {
2023
2114
  if (__DEV__)
2024
- console.log(`[Rampkit] Queuing navigate from inactive screen ${i}`);
2025
- queueAction(i, executeNavigate);
2115
+ console.log(`[Rampkit] Ignoring navigate from inactive screen ${i} (SDK handles on-open)`);
2116
+ return;
2117
+ }
2118
+ const target = data === null || data === void 0 ? void 0 : data.targetScreenId;
2119
+ if (target === "__goBack__") {
2120
+ handleGoBack(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2026
2121
  return;
2027
2122
  }
2028
- executeNavigate();
2123
+ if (!target || target === "__continue__") {
2124
+ handleAdvance(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2125
+ return;
2126
+ }
2127
+ const targetIndex = props.screens.findIndex((s) => s.id === target);
2128
+ if (targetIndex >= 0) {
2129
+ navigateToIndex(targetIndex, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2130
+ }
2131
+ else {
2132
+ handleAdvance(i);
2133
+ }
2029
2134
  return;
2030
2135
  }
2031
2136
  if ((data === null || data === void 0 ? void 0 : data.type) === "rampkit:goBack") {
2032
- const executeGoBack = () => handleGoBack(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2033
- // Queue if screen is not active (e.g., on-open actions during preload)
2137
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2034
2138
  if (!isScreenActive(i)) {
2035
2139
  if (__DEV__)
2036
- console.log(`[Rampkit] Queuing goBack from inactive screen ${i}`);
2037
- queueAction(i, executeGoBack);
2140
+ console.log(`[Rampkit] Ignoring goBack from inactive screen ${i} (SDK handles on-open)`);
2038
2141
  return;
2039
2142
  }
2040
- executeGoBack();
2143
+ handleGoBack(i, (data === null || data === void 0 ? void 0 : data.animation) || "fade");
2041
2144
  return;
2042
2145
  }
2043
2146
  if ((data === null || data === void 0 ? void 0 : data.type) === "rampkit:close") {
@@ -2059,19 +2162,23 @@ function Overlay(props) {
2059
2162
  if (raw === "rampkit:tap" ||
2060
2163
  raw === "next" ||
2061
2164
  raw === "continue") {
2062
- const executeAdvance = () => handleAdvance(i);
2063
- // Queue if screen is not active (e.g., on-open actions during preload)
2165
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2064
2166
  if (!isScreenActive(i)) {
2065
2167
  if (__DEV__)
2066
- console.log(`[Rampkit] Queuing ${raw} from inactive screen ${i}`);
2067
- queueAction(i, executeAdvance);
2168
+ console.log(`[Rampkit] Ignoring ${raw} from inactive screen ${i} (SDK handles on-open)`);
2068
2169
  return;
2069
2170
  }
2070
- executeAdvance();
2171
+ handleAdvance(i);
2071
2172
  return;
2072
2173
  }
2073
2174
  if (raw === "rampkit:request-review" || raw === "rampkit:review") {
2074
- const executeReview = async () => {
2175
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2176
+ if (!isScreenActive(i)) {
2177
+ if (__DEV__)
2178
+ console.log(`[Rampkit] Ignoring review request (raw) from inactive screen ${i} (SDK handles on-open)`);
2179
+ return;
2180
+ }
2181
+ (async () => {
2075
2182
  try {
2076
2183
  const available = await RampKitNative_1.StoreReview.isAvailableAsync();
2077
2184
  if (available) {
@@ -2079,29 +2186,17 @@ function Overlay(props) {
2079
2186
  }
2080
2187
  }
2081
2188
  catch (_) { }
2082
- };
2083
- // Only execute if screen is active, otherwise queue for later
2084
- if (isScreenActive(i)) {
2085
- executeReview();
2086
- }
2087
- else {
2088
- if (__DEV__)
2089
- console.log(`[Rampkit] Queuing review request (raw) from inactive screen ${i}`);
2090
- queueAction(i, executeReview);
2091
- }
2189
+ })();
2092
2190
  return;
2093
2191
  }
2094
2192
  if (raw === "rampkit:request-notification-permission") {
2095
- const executeNotification = () => handleNotificationPermissionRequest(undefined);
2096
- // Only execute if screen is active, otherwise queue for later
2097
- if (isScreenActive(i)) {
2098
- executeNotification();
2099
- }
2100
- else {
2193
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2194
+ if (!isScreenActive(i)) {
2101
2195
  if (__DEV__)
2102
- console.log(`[Rampkit] Queuing notification request (raw) from inactive screen ${i}`);
2103
- queueAction(i, executeNotification);
2196
+ console.log(`[Rampkit] Ignoring notification request (raw) from inactive screen ${i} (SDK handles on-open)`);
2197
+ return;
2104
2198
  }
2199
+ handleNotificationPermissionRequest(undefined);
2105
2200
  return;
2106
2201
  }
2107
2202
  if (raw === "rampkit:onboarding-finished") {
@@ -2121,44 +2216,38 @@ function Overlay(props) {
2121
2216
  return;
2122
2217
  }
2123
2218
  if (raw === "rampkit:goBack") {
2124
- const executeGoBack = () => handleGoBack(i);
2125
- // Queue if screen is not active (e.g., on-open actions during preload)
2219
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2126
2220
  if (!isScreenActive(i)) {
2127
2221
  if (__DEV__)
2128
- console.log(`[Rampkit] Queuing goBack (raw) from inactive screen ${i}`);
2129
- queueAction(i, executeGoBack);
2222
+ console.log(`[Rampkit] Ignoring goBack (raw) from inactive screen ${i} (SDK handles on-open)`);
2130
2223
  return;
2131
2224
  }
2132
- executeGoBack();
2225
+ handleGoBack(i);
2133
2226
  return;
2134
2227
  }
2135
2228
  if (raw.startsWith("rampkit:navigate:")) {
2136
- const target = raw.slice("rampkit:navigate:".length);
2137
- const executeNavigate = () => {
2138
- if (target === "__goBack__") {
2139
- handleGoBack(i);
2140
- return;
2141
- }
2142
- if (!target || target === "__continue__") {
2143
- handleAdvance(i);
2144
- return;
2145
- }
2146
- const targetIndex = props.screens.findIndex((s) => s.id === target);
2147
- if (targetIndex >= 0) {
2148
- navigateToIndex(targetIndex);
2149
- }
2150
- else {
2151
- handleAdvance(i);
2152
- }
2153
- };
2154
- // Queue if screen is not active (e.g., on-open actions during preload)
2229
+ // Only process from active screen (on-open actions are handled by SDK in activateScreen)
2155
2230
  if (!isScreenActive(i)) {
2156
2231
  if (__DEV__)
2157
- console.log(`[Rampkit] Queuing navigate (raw) from inactive screen ${i}`);
2158
- queueAction(i, executeNavigate);
2232
+ console.log(`[Rampkit] Ignoring navigate (raw) from inactive screen ${i} (SDK handles on-open)`);
2159
2233
  return;
2160
2234
  }
2161
- executeNavigate();
2235
+ const target = raw.slice("rampkit:navigate:".length);
2236
+ if (target === "__goBack__") {
2237
+ handleGoBack(i);
2238
+ return;
2239
+ }
2240
+ if (!target || target === "__continue__") {
2241
+ handleAdvance(i);
2242
+ return;
2243
+ }
2244
+ const targetIndex = props.screens.findIndex((s) => s.id === target);
2245
+ if (targetIndex >= 0) {
2246
+ navigateToIndex(targetIndex);
2247
+ }
2248
+ else {
2249
+ handleAdvance(i);
2250
+ }
2162
2251
  return;
2163
2252
  }
2164
2253
  if (raw === "rampkit:close") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rampkit-expo-dev",
3
- "version": "0.0.85",
3
+ "version": "0.0.88",
4
4
  "description": "The Expo SDK for RampKit. Build, test, and personalize app onboardings with instant updates.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",