rampkit-expo-dev 0.0.11 → 0.0.12

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.
@@ -21,4 +21,5 @@ export declare class RampKitCore {
21
21
  onShowPaywall?: (payload?: any) => void;
22
22
  showPaywall?: (payload?: any) => void;
23
23
  }): void;
24
+ closeOnboarding(): void;
24
25
  }
package/build/RampKit.js CHANGED
@@ -117,6 +117,9 @@ class RampKitCore {
117
117
  console.log("[RampKit] ShowOnboarding: failed to show overlay", e);
118
118
  }
119
119
  }
120
+ closeOnboarding() {
121
+ (0, RampkitOverlay_1.closeRampkitOverlay)();
122
+ }
120
123
  }
121
124
  exports.RampKitCore = RampKitCore;
122
125
  RampKitCore.ONBOARDING_URL = "https://dqplcvw3fzili.cloudfront.net/labelaiOnboarding.json";
@@ -16,6 +16,7 @@ export declare function showRampkitOverlay(opts: {
16
16
  onShowPaywall?: (payload?: any) => void;
17
17
  }): void;
18
18
  export declare function hideRampkitOverlay(): void;
19
+ export declare function closeRampkitOverlay(): void;
19
20
  export declare function preloadRampkitOverlay(opts: {
20
21
  onboardingId: string;
21
22
  screens: ScreenPayload[];
@@ -31,5 +32,6 @@ declare function Overlay(props: {
31
32
  onRequestClose: () => void;
32
33
  onOnboardingFinished?: (payload?: any) => void;
33
34
  onShowPaywall?: (payload?: any) => void;
35
+ onRegisterClose?: (handler: (() => void) | null) => void;
34
36
  }): any;
35
37
  export default Overlay;
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.injectedNoSelect = exports.injectedHardening = void 0;
40
40
  exports.showRampkitOverlay = showRampkitOverlay;
41
41
  exports.hideRampkitOverlay = hideRampkitOverlay;
42
+ exports.closeRampkitOverlay = closeRampkitOverlay;
42
43
  exports.preloadRampkitOverlay = preloadRampkitOverlay;
43
44
  const jsx_runtime_1 = require("react/jsx-runtime");
44
45
  const react_1 = __importStar(require("react"));
@@ -129,6 +130,7 @@ exports.injectedNoSelect = `
129
130
  let sibling = null;
130
131
  let preloadSibling = null;
131
132
  const preloadCache = new Map();
133
+ let activeCloseHandler = null;
132
134
  function showRampkitOverlay(opts) {
133
135
  console.log("showRampkitOverlay");
134
136
  if (sibling)
@@ -136,9 +138,12 @@ function showRampkitOverlay(opts) {
136
138
  const prebuiltDocs = preloadCache.get(opts.onboardingId);
137
139
  sibling = new react_native_root_siblings_1.default(((0, jsx_runtime_1.jsx)(Overlay, { onboardingId: opts.onboardingId, screens: opts.screens, variables: opts.variables, requiredScripts: opts.requiredScripts, prebuiltDocs: prebuiltDocs, onRequestClose: () => {
138
140
  var _a;
141
+ activeCloseHandler = null;
139
142
  hideRampkitOverlay();
140
143
  (_a = opts.onClose) === null || _a === void 0 ? void 0 : _a.call(opts);
141
- }, onOnboardingFinished: opts.onOnboardingFinished, onShowPaywall: opts.onShowPaywall })));
144
+ }, onOnboardingFinished: opts.onOnboardingFinished, onShowPaywall: opts.onShowPaywall, onRegisterClose: (handler) => {
145
+ activeCloseHandler = handler;
146
+ } })));
142
147
  // Once shown, we can safely discard the preloader sibling if present
143
148
  if (preloadSibling) {
144
149
  preloadSibling.destroy();
@@ -150,6 +155,14 @@ function hideRampkitOverlay() {
150
155
  sibling.destroy();
151
156
  sibling = null;
152
157
  }
158
+ activeCloseHandler = null;
159
+ }
160
+ function closeRampkitOverlay() {
161
+ if (activeCloseHandler) {
162
+ activeCloseHandler();
163
+ return;
164
+ }
165
+ hideRampkitOverlay();
153
166
  }
154
167
  function preloadRampkitOverlay(opts) {
155
168
  try {
@@ -269,6 +282,14 @@ function Overlay(props) {
269
282
  props.onRequestClose();
270
283
  });
271
284
  }, [isClosing, overlayOpacity, props.onRequestClose]);
285
+ react_1.default.useEffect(() => {
286
+ var _a;
287
+ (_a = props.onRegisterClose) === null || _a === void 0 ? void 0 : _a.call(props, handleRequestClose);
288
+ return () => {
289
+ var _a;
290
+ (_a = props.onRegisterClose) === null || _a === void 0 ? void 0 : _a.call(props, null);
291
+ };
292
+ }, [handleRequestClose, props.onRegisterClose]);
272
293
  // Android hardware back goes to previous page, then closes
273
294
  const navigateToIndex = (nextIndex) => {
274
295
  if (nextIndex === index ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rampkit-expo-dev",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
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",