@unifold/connect-svelte 0.1.58 → 0.1.59
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.
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
});
|
|
19
19
|
readyPromise.catch(() => {});
|
|
20
20
|
|
|
21
|
+
const destroyedBeforeInitError = new Error(
|
|
22
|
+
"UnifoldProvider was destroyed before initialization completed"
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const abortIfDestroyed = (): boolean => {
|
|
26
|
+
if (!destroyed) return false;
|
|
27
|
+
rejectReady(destroyedBeforeInitError);
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
|
|
21
31
|
const ctx: UnifoldContext = {
|
|
22
32
|
beginDeposit: async (depositConfig) => {
|
|
23
33
|
await readyPromise;
|
|
@@ -36,13 +46,17 @@
|
|
|
36
46
|
// onMount is browser-only — it never fires during SSR.
|
|
37
47
|
onMount(async () => {
|
|
38
48
|
initStarted = true;
|
|
49
|
+
if (abortIfDestroyed()) return;
|
|
50
|
+
|
|
39
51
|
try {
|
|
40
52
|
const { createUnifold } = await import("@unifold/ui-web");
|
|
41
|
-
if (
|
|
53
|
+
if (abortIfDestroyed()) return;
|
|
42
54
|
|
|
43
55
|
const instance = await createUnifold(publishableKey, config);
|
|
44
56
|
if (destroyed) {
|
|
57
|
+
instance.closeDeposit();
|
|
45
58
|
instance.destroy();
|
|
59
|
+
rejectReady(destroyedBeforeInitError);
|
|
46
60
|
return;
|
|
47
61
|
}
|
|
48
62
|
|
|
@@ -60,10 +74,11 @@
|
|
|
60
74
|
// rejection crashes the SSR process.
|
|
61
75
|
onDestroy(() => {
|
|
62
76
|
destroyed = true;
|
|
77
|
+
unifold?.closeDeposit();
|
|
63
78
|
unifold?.destroy();
|
|
64
79
|
unifold = null;
|
|
65
80
|
if (initStarted) {
|
|
66
|
-
rejectReady(
|
|
81
|
+
rejectReady(destroyedBeforeInitError);
|
|
67
82
|
}
|
|
68
83
|
});
|
|
69
84
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/connect-svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.59",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Unifold Connect for Svelte - Native Svelte SDK for the Unifold deposit widget",
|
|
6
6
|
"exports": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@unifold/ui-web": "0.1.
|
|
19
|
+
"@unifold/ui-web": "0.1.59"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"svelte": "^4.0.0 || ^5.0.0"
|