@series-inc/venus-sdk 2.2.1 → 2.4.0

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.
@@ -847,7 +847,13 @@ function initializeLocalNotifications(venusApi, host) {
847
847
  venusApi.scheduleLocalNotifAsync = async (options) => {
848
848
  const id = await host.notifications.scheduleLocalNotification(
849
849
  options.title,
850
- options.body
850
+ options.body,
851
+ {
852
+ trigger: options.trigger,
853
+ priority: options.priority,
854
+ groupId: options.groupId,
855
+ payload: options.payload
856
+ }
851
857
  );
852
858
  if (id) {
853
859
  return id;
@@ -6157,6 +6163,75 @@ function initializeLoggingApi(venusApi, host) {
6157
6163
  };
6158
6164
  }
6159
6165
 
6166
+ // src/shared-assets/consts.ts
6167
+ var BurgerTimeAssetsCdnPath = "burger-time/Core.stow";
6168
+ var CharacterAssetsCdnPath = "burger-time/Character.stow";
6169
+
6170
+ // src/shared-assets/RpcSharedAssetsApi.ts
6171
+ var RpcSharedAssetsApi = class {
6172
+ constructor(rpcClient, venusApi) {
6173
+ __publicField(this, "venusApi");
6174
+ __publicField(this, "rpcClient");
6175
+ this.rpcClient = rpcClient;
6176
+ this.venusApi = venusApi;
6177
+ }
6178
+ async loadBurgerTimeAssetsBundle() {
6179
+ try {
6180
+ const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
6181
+ assetKey: "burgerTimeCoreBundle"
6182
+ });
6183
+ return base64ToArrayBuffer(response.base64Data);
6184
+ } catch (err) {
6185
+ try {
6186
+ const blob = await this.venusApi.cdn.fetchBlob(BurgerTimeAssetsCdnPath);
6187
+ return await blob.arrayBuffer();
6188
+ } catch (e) {
6189
+ throw new Error("Failed to load burgerTimeAssetsBundle");
6190
+ }
6191
+ }
6192
+ }
6193
+ async loadCharactersBundle() {
6194
+ try {
6195
+ const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
6196
+ assetKey: "characters"
6197
+ });
6198
+ return base64ToArrayBuffer(response.base64Data);
6199
+ } catch (err) {
6200
+ try {
6201
+ const blob = await this.venusApi.cdn.fetchBlob(CharacterAssetsCdnPath);
6202
+ return await blob.arrayBuffer();
6203
+ } catch (e) {
6204
+ throw new Error("Failed to load charactersBundle");
6205
+ }
6206
+ }
6207
+ }
6208
+ };
6209
+ function base64ToArrayBuffer(base64) {
6210
+ const binaryString = atob(base64);
6211
+ const len = binaryString.length;
6212
+ const bytes = new Uint8Array(len);
6213
+ for (let i = 0; i < len; i++) {
6214
+ bytes[i] = binaryString.charCodeAt(i);
6215
+ }
6216
+ return bytes.buffer;
6217
+ }
6218
+
6219
+ // src/shared-assets/MockSharedAssetsApi.ts
6220
+ var MockSharedAssetsApi = class {
6221
+ constructor(venusApi) {
6222
+ __publicField(this, "venusApi");
6223
+ this.venusApi = venusApi;
6224
+ }
6225
+ async loadBurgerTimeAssetsBundle() {
6226
+ const blob = await this.venusApi.cdn.fetchBlob(BurgerTimeAssetsCdnPath);
6227
+ return await blob.arrayBuffer();
6228
+ }
6229
+ async loadCharactersBundle() {
6230
+ const blob = await this.venusApi.cdn.fetchBlob(CharacterAssetsCdnPath);
6231
+ return await blob.arrayBuffer();
6232
+ }
6233
+ };
6234
+
6160
6235
  // src/MockHost.ts
6161
6236
  var MockHost = class {
6162
6237
  constructor(venusApi) {
@@ -6181,6 +6256,7 @@ var MockHost = class {
6181
6256
  __publicField(this, "rooms");
6182
6257
  __publicField(this, "logging");
6183
6258
  __publicField(this, "iap");
6259
+ __publicField(this, "state", 0 /* PLAYING */);
6184
6260
  __publicField(this, "venusApi");
6185
6261
  __publicField(this, "_isInitialized", false);
6186
6262
  __publicField(this, "_overlay");
@@ -6213,6 +6289,7 @@ var MockHost = class {
6213
6289
  this.logging = new MockLoggingApi();
6214
6290
  this.iap = new MockIapApi();
6215
6291
  venusApi.isMock = () => true;
6292
+ this.venusApi.sharedAssets = new MockSharedAssetsApi(this.venusApi);
6216
6293
  }
6217
6294
  get isInitialized() {
6218
6295
  return this._isInitialized;
@@ -6243,6 +6320,7 @@ var MockHost = class {
6243
6320
  createOverlay() {
6244
6321
  const venusApi = this.venusApi;
6245
6322
  venusApi.config.ui.controls = this.updateUiControls();
6323
+ const uiControls = venusApi.config.ui.controls;
6246
6324
  const overlayContainer = document.createElement("div");
6247
6325
  overlayContainer.id = "venus-mock-overlay";
6248
6326
  overlayContainer.style.cssText = `
@@ -6255,75 +6333,18 @@ var MockHost = class {
6255
6333
  z-index: 10000;
6256
6334
  `;
6257
6335
  document.body.appendChild(overlayContainer);
6258
- const uiControls = venusApi.config.ui.controls;
6259
- const dynamicPlayButton = {
6260
- x: 0,
6261
- y: window.innerHeight - 60,
6262
- width: window.innerWidth,
6263
- height: 60
6264
- };
6265
- const playButton = this.createOverlayButton(
6266
- "play",
6267
- "Play",
6268
- dynamicPlayButton,
6269
- () => {
6270
- this.triggerLifecycleEvent("PLAY" /* PLAY */);
6271
- this.setOverlayElementVisibility("play", false);
6272
- this.setOverlayElementVisibility("visibility", false);
6273
- },
6274
- "linear-gradient(90deg, #3b82f6, #1d4ed8)",
6275
- // Blue gradient instead of pink/blue
6276
- "#FFFFFF"
6277
- );
6278
- overlayContainer.appendChild(playButton);
6279
- const visibilityButtonSize = 40;
6280
- const visibilityButtonMargin = 10;
6281
- const showHideToggle = this.createOverlayButton(
6282
- "visibility",
6283
- "\u{1F441}\uFE0F",
6284
- {
6285
- x: window.innerWidth - visibilityButtonSize - 20,
6286
- // Right side with margin
6287
- y: window.innerHeight - 60 - visibilityButtonSize - visibilityButtonMargin,
6288
- // Above play button
6289
- width: visibilityButtonSize,
6290
- height: visibilityButtonSize
6291
- },
6292
- () => {
6293
- if (this._overlay.appVisibilityState === "visible") {
6294
- this._overlay.appVisibilityState = "hidden";
6295
- if (this._overlay.elements.visibility) {
6296
- this._overlay.elements.visibility.innerHTML = "\u{1F6AB}";
6297
- this._overlay.elements.visibility.title = "App is hidden (click to show)";
6298
- }
6299
- this.triggerLifecycleEvent("HIDDEN" /* HIDDEN */);
6300
- } else {
6301
- this._overlay.appVisibilityState = "visible";
6302
- if (this._overlay.elements.visibility) {
6303
- this._overlay.elements.visibility.innerHTML = "\u{1F441}\uFE0F";
6304
- this._overlay.elements.visibility.title = "App is visible (click to hide)";
6305
- }
6306
- this.triggerLifecycleEvent("SHOWN" /* SHOWN */);
6307
- }
6308
- },
6309
- "rgba(59, 130, 246, 0.7)",
6310
- // Blue background
6311
- "#FFFFFF"
6312
- );
6313
- showHideToggle.title = "App is visible (click to hide)";
6314
- overlayContainer.appendChild(showHideToggle);
6315
- const closeButton = this.createOverlayButton(
6336
+ const menuButton = this.createOverlayButton(
6316
6337
  "close",
6317
- "\u2715",
6318
- uiControls.closeButton,
6338
+ "Menu",
6339
+ uiControls.menuButton,
6319
6340
  () => {
6320
- this.triggerLifecycleEvent("QUIT" /* QUIT */);
6341
+ this.handleMenuButtonClicked();
6321
6342
  },
6322
6343
  "rgba(59, 130, 246, 0.7)",
6323
6344
  // Blue background instead of black
6324
6345
  "#FFFFFF"
6325
6346
  );
6326
- overlayContainer.appendChild(closeButton);
6347
+ overlayContainer.appendChild(menuButton);
6327
6348
  const adOverlay = this.setupAdOverlay();
6328
6349
  const actionSheet = this.setupActionSheetOverlay();
6329
6350
  window.addEventListener("resize", () => {
@@ -6332,9 +6353,7 @@ var MockHost = class {
6332
6353
  return {
6333
6354
  container: overlayContainer,
6334
6355
  elements: {
6335
- play: playButton,
6336
- visibility: showHideToggle,
6337
- close: closeButton
6356
+ menuButton
6338
6357
  },
6339
6358
  appVisibilityState: "visible",
6340
6359
  actionSheetOverlay: actionSheet,
@@ -6347,6 +6366,30 @@ var MockHost = class {
6347
6366
  }
6348
6367
  };
6349
6368
  }
6369
+ async handleMenuButtonClicked() {
6370
+ this.triggerLifecycleEvent("PAUSE" /* PAUSE */);
6371
+ const sleepAwakeToggleAction = {
6372
+ label: "\u23F0 Awake",
6373
+ id: "sleepAwakeToggle"
6374
+ };
6375
+ if (this.state === 1 /* PAUSED */) {
6376
+ sleepAwakeToggleAction.label = "\u{1F4A4} Sleep";
6377
+ }
6378
+ const action = await this.showActionSheetOverlay([sleepAwakeToggleAction]);
6379
+ if (action === sleepAwakeToggleAction.id) {
6380
+ if (this.state === 1 /* PAUSED */) {
6381
+ this.state = 2 /* SLEEPING */;
6382
+ this.triggerLifecycleEvent("HIDDEN" /* HIDDEN */);
6383
+ } else {
6384
+ this.state = 1 /* PAUSED */;
6385
+ this.triggerLifecycleEvent("SHOWN" /* SHOWN */);
6386
+ }
6387
+ } else {
6388
+ if (this.state === 1 /* PAUSED */) {
6389
+ this.triggerLifecycleEvent("RESUME" /* RESUME */);
6390
+ }
6391
+ }
6392
+ }
6350
6393
  async showAdOverlay(type) {
6351
6394
  return new Promise((resolve, reject) => {
6352
6395
  const overlay = this._overlay;
@@ -6465,26 +6508,13 @@ var MockHost = class {
6465
6508
  const overlay = this._overlay;
6466
6509
  venusApi.config.ui.controls = this.updateUiControls();
6467
6510
  const uiControls = venusApi.config.ui.controls;
6468
- const playBtn = overlay.elements.play;
6469
- const playPos = uiControls.playButton;
6470
- playBtn.style.left = `${playPos.x}px`;
6471
- playBtn.style.top = `${playPos.y}px`;
6472
- playBtn.style.width = `${playPos.width}px`;
6473
- playBtn.style.minWidth = `${playPos.width}px`;
6474
- playBtn.style.height = `${playPos.height}px`;
6475
- const menuBtn = overlay.elements.menu;
6511
+ const menuBtn = overlay.elements.menuButton;
6476
6512
  const menuPos = uiControls.menuButton;
6477
6513
  menuBtn.style.left = `${menuPos.x}px`;
6478
6514
  menuBtn.style.top = `${menuPos.y}px`;
6479
6515
  menuBtn.style.width = `${menuPos.width}px`;
6480
6516
  menuBtn.style.minWidth = `${menuPos.width}px`;
6481
6517
  menuBtn.style.height = `${menuPos.height}px`;
6482
- const visibilityBtn = overlay.elements.visibility;
6483
- const visibilityButtonSize = 40;
6484
- const visibilityButtonMargin = 10;
6485
- visibilityBtn.style.left = `${window.innerWidth - visibilityButtonSize - 20}px`;
6486
- visibilityBtn.style.top = `${window.innerHeight - 60 - visibilityButtonSize - visibilityButtonMargin}px`;
6487
- visibilityBtn.style.minWidth = `${visibilityButtonSize}px`;
6488
6518
  }
6489
6519
  triggerLifecycleEvent(name) {
6490
6520
  console.log("Trigger Lifecycle Event: ", name);
@@ -6504,10 +6534,6 @@ var MockHost = class {
6504
6534
  this._mockLifecyclesApi.triggerOnResumeCallbacks();
6505
6535
  } else if (name == "QUIT" /* QUIT */) {
6506
6536
  this._mockLifecyclesApi.triggerOnQuitCallbacks();
6507
- setTimeout(() => {
6508
- this.setOverlayElementVisibility("play", true);
6509
- this.setOverlayElementVisibility("visibility", true);
6510
- }, 100);
6511
6537
  } else if (name == "SHOWN" /* SHOWN */) {
6512
6538
  this._mockLifecyclesApi.triggerOnShowCallbacks({
6513
6539
  hudInsets: { top: 60, bottom: 120, left: 0, right: 0 }
@@ -6516,10 +6542,11 @@ var MockHost = class {
6516
6542
  this._mockLifecyclesApi.triggerOnHideCallbacks();
6517
6543
  }
6518
6544
  }
6519
- setOverlayElementVisibility(id, visible) {
6545
+ setOverlayElementVisibility(element, visible) {
6520
6546
  const overlay = this._overlay;
6521
- if (overlay.elements[id]) {
6522
- overlay.elements[id].style.display = visible ? "flex" : "none";
6547
+ const elements = overlay.elements;
6548
+ if (elements[element]) {
6549
+ elements[element].style.display = visible ? "flex" : "none";
6523
6550
  }
6524
6551
  }
6525
6552
  setupAdOverlay() {
@@ -6812,8 +6839,6 @@ var VenusTransport = class {
6812
6839
  this.logInfo("No message found. Ignoring message...");
6813
6840
  return;
6814
6841
  }
6815
- this.logInfo(`message received:
6816
- ${JSON.stringify(message, null, 2)}`);
6817
6842
  this.notifyVenusMessageReceived(message);
6818
6843
  if (message.type === "PLAY" /* PLAY */ || message.type === "PAUSE" /* PAUSE */ || message.type === "RESUME" /* RESUME */ || message.type === "SHOWN" /* SHOWN */ || message.type === "HIDDEN" /* HIDDEN */ || message.type === "CLEANUP" /* CLEANUP */ || message.type === "QUIT" /* QUIT */) {
6819
6844
  const notification = {
@@ -6914,8 +6939,6 @@ ${JSON.stringify(message, null, 2)}`);
6914
6939
  }
6915
6940
  sendVenusMessage(message) {
6916
6941
  const messageAsString = JSON.stringify(message, null, 2);
6917
- this.logInfo(`Sending message:
6918
- ${messageAsString}`);
6919
6942
  const reactNativeWebView = window.ReactNativeWebView;
6920
6943
  if (reactNativeWebView) {
6921
6944
  reactNativeWebView.postMessage(messageAsString);
@@ -6943,7 +6966,6 @@ ${messageAsString}`);
6943
6966
  this.logInfo(`Stopped`);
6944
6967
  }
6945
6968
  handleNotification(notification) {
6946
- this.logInfo("Notification received: ", notification.id);
6947
6969
  for (const callback of this.onNotificationCallbacks) {
6948
6970
  callback(notification);
6949
6971
  }
@@ -7012,7 +7034,8 @@ var RpcNotificationsApi = class {
7012
7034
  body,
7013
7035
  data: options?.payload,
7014
7036
  key: options?.groupId,
7015
- priority: options?.priority || 1
7037
+ priority: options?.priority || 1,
7038
+ trigger: options?.trigger ?? null
7016
7039
  };
7017
7040
  const response = await this.rpcClient.call(
7018
7041
  "H5_SCHEDULE_LOCAL_NOTIFICATION" /* SCHEDULE_LOCAL_NOTIFICATION */,
@@ -7042,7 +7065,8 @@ var RpcNotificationsApi = class {
7042
7065
  id: notif.identifier,
7043
7066
  title: notif.content.title,
7044
7067
  body: notif.content.body,
7045
- payload: notif.content.data
7068
+ payload: notif.content.data,
7069
+ trigger: notif.trigger
7046
7070
  };
7047
7071
  });
7048
7072
  return notifications;
@@ -7497,7 +7521,7 @@ var RpcRoomsApi = class {
7497
7521
 
7498
7522
  // src/RemoteHost.ts
7499
7523
  var getCdnBaseUrl = () => {
7500
- return process.env.EXPO_PUBLIC_H5_CDN_URL_PRODUCTION || "https://venus-static-01293ak.web.app/";
7524
+ return "https://venus-static-01293ak.web.app/";
7501
7525
  };
7502
7526
  var RemoteHost = class {
7503
7527
  constructor(venusApi) {
@@ -7577,6 +7601,7 @@ var RemoteHost = class {
7577
7601
  this.logging = new RpcLoggingApi(this, rpcClient);
7578
7602
  this.iap = new RpcIapApi(rpcClient);
7579
7603
  venusApi.isMock = () => false;
7604
+ this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
7580
7605
  console.log("[Venus SDK] Remote host created");
7581
7606
  }
7582
7607
  get isInitialized() {
@@ -7684,7 +7709,7 @@ function createHost(venusApi, isMock) {
7684
7709
  }
7685
7710
 
7686
7711
  // src/version.ts
7687
- var SDK_VERSION = "2.2.1";
7712
+ var SDK_VERSION = "2.3.0";
7688
7713
 
7689
7714
  // src/venus-api/index.js
7690
7715
  var HapticStyle = {