@hyve-sdk/js 1.4.0 → 1.4.1

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/dist/index.js CHANGED
@@ -1251,14 +1251,21 @@ var BillingService = class {
1251
1251
  throw new Error("Stripe not initialized");
1252
1252
  }
1253
1253
  try {
1254
+ if (this.checkoutElement) {
1255
+ this.log("info", "[BillingService] Unmounting existing checkout element");
1256
+ this.unmountCheckoutElement();
1257
+ await new Promise((resolve) => setTimeout(resolve, 100));
1258
+ }
1254
1259
  const container = document.getElementById(elementId);
1255
1260
  if (!container) {
1256
1261
  throw new Error(`Element with id "${elementId}" not found in the DOM`);
1257
1262
  }
1258
1263
  container.innerHTML = "";
1264
+ this.log("info", "[BillingService] Creating new checkout instance");
1259
1265
  this.checkoutElement = await this.stripe.initEmbeddedCheckout({
1260
1266
  clientSecret
1261
1267
  });
1268
+ this.log("info", "[BillingService] Mounting checkout element to DOM");
1262
1269
  this.checkoutElement.mount(`#${elementId}`);
1263
1270
  this.setupCheckoutEventListeners();
1264
1271
  } catch (error) {
@@ -1296,7 +1303,14 @@ var BillingService = class {
1296
1303
  */
1297
1304
  unmountCheckoutElement() {
1298
1305
  if (this.checkoutElement) {
1299
- this.checkoutElement.unmount();
1306
+ try {
1307
+ this.checkoutElement.unmount();
1308
+ if (typeof this.checkoutElement.destroy === "function") {
1309
+ this.checkoutElement.destroy();
1310
+ }
1311
+ } catch (error) {
1312
+ this.log("warn", "[BillingService] Error unmounting checkout element:", error?.message);
1313
+ }
1300
1314
  this.checkoutElement = null;
1301
1315
  }
1302
1316
  }
package/dist/index.mjs CHANGED
@@ -1209,14 +1209,21 @@ var BillingService = class {
1209
1209
  throw new Error("Stripe not initialized");
1210
1210
  }
1211
1211
  try {
1212
+ if (this.checkoutElement) {
1213
+ this.log("info", "[BillingService] Unmounting existing checkout element");
1214
+ this.unmountCheckoutElement();
1215
+ await new Promise((resolve) => setTimeout(resolve, 100));
1216
+ }
1212
1217
  const container = document.getElementById(elementId);
1213
1218
  if (!container) {
1214
1219
  throw new Error(`Element with id "${elementId}" not found in the DOM`);
1215
1220
  }
1216
1221
  container.innerHTML = "";
1222
+ this.log("info", "[BillingService] Creating new checkout instance");
1217
1223
  this.checkoutElement = await this.stripe.initEmbeddedCheckout({
1218
1224
  clientSecret
1219
1225
  });
1226
+ this.log("info", "[BillingService] Mounting checkout element to DOM");
1220
1227
  this.checkoutElement.mount(`#${elementId}`);
1221
1228
  this.setupCheckoutEventListeners();
1222
1229
  } catch (error) {
@@ -1254,7 +1261,14 @@ var BillingService = class {
1254
1261
  */
1255
1262
  unmountCheckoutElement() {
1256
1263
  if (this.checkoutElement) {
1257
- this.checkoutElement.unmount();
1264
+ try {
1265
+ this.checkoutElement.unmount();
1266
+ if (typeof this.checkoutElement.destroy === "function") {
1267
+ this.checkoutElement.destroy();
1268
+ }
1269
+ } catch (error) {
1270
+ this.log("warn", "[BillingService] Error unmounting checkout element:", error?.message);
1271
+ }
1258
1272
  this.checkoutElement = null;
1259
1273
  }
1260
1274
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyve-sdk/js",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Hyve SDK - TypeScript wrapper for Hyve game server integration",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -15,6 +15,14 @@
15
15
  "README.md",
16
16
  "LICENSE"
17
17
  ],
18
+ "scripts": {
19
+ "lint": "eslint . --max-warnings 0",
20
+ "check-types": "tsc --noEmit",
21
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
+ "prepublishOnly": "pnpm run build && pnpm run check-types",
23
+ "publish:npm": "pnpm publish --access public",
24
+ "publish:dry-run": "pnpm publish --dry-run --access public --no-git-checks"
25
+ },
18
26
  "keywords": [
19
27
  "hyve",
20
28
  "game",
@@ -48,18 +56,11 @@
48
56
  }
49
57
  },
50
58
  "devDependencies": {
59
+ "@repo/eslint-config": "workspace:*",
60
+ "@repo/typescript-config": "workspace:*",
51
61
  "@types/minimatch": "^5.1.2",
52
62
  "@types/uuid": "^10.0.0",
53
63
  "tsup": "^8.4.0",
54
- "typescript": "^5.3.3",
55
- "@repo/eslint-config": "0.0.0",
56
- "@repo/typescript-config": "0.0.0"
57
- },
58
- "scripts": {
59
- "lint": "eslint . --max-warnings 0",
60
- "check-types": "tsc --noEmit",
61
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
62
- "publish:npm": "pnpm publish --access public",
63
- "publish:dry-run": "pnpm publish --dry-run --access public --no-git-checks"
64
+ "typescript": "^5.3.3"
64
65
  }
65
- }
66
+ }