@inappstory/game-center-api 1.2.2 → 1.2.3

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/README.md CHANGED
@@ -40,22 +40,13 @@ createSdkApi({
40
40
 
41
41
  ```tsx
42
42
  const gameLoaded = () => {
43
- if (GameCenterApi.isSdkSupportGameShouldForegroundCallback()) {
44
- GameCenterApi.gameLoadedSdkCallback();
45
- } else {
46
- // fallback for old sdk versions
47
- gameShouldForeground();
48
- }
43
+ GameCenterApi.gameLoadedSdkCallback();
49
44
  };
50
45
 
51
46
  const gameStarted = () => {
52
47
  setTimeout(() => {
53
48
  // Wait for render complete - then remove native loader screen
54
- if (GameCenterApi.isSdkSupportGameShouldForegroundCallback()) {
55
- GameCenterApi.gameShouldForegroundCallback();
56
- } else {
57
- GameCenterApi.gameLoadedSdkCallback();
58
- }
49
+ GameCenterApi.gameShouldForegroundCallback();
59
50
  }, 50);
60
51
  };
61
52
 
package/lib/env.d.ts CHANGED
@@ -14,4 +14,12 @@ declare let iosMh: Record<string, any>;
14
14
  declare const isDev: boolean;
15
15
  declare const getSdkVersion: () => string | false | null;
16
16
  declare const getSemverSdkVersion: () => false | SemVer | null;
17
- export { isIos, isWeb, isAndroid, iosMh, isDev, getSdkVersion, getSemverSdkVersion };
17
+ /**
18
+ * Get host application build version
19
+ */
20
+ declare const getApplicationBuildVersion: () => number | null;
21
+ /**
22
+ * Get host application sem version
23
+ */
24
+ declare const getApplicationVersion: () => string | null;
25
+ export { isIos, isWeb, isAndroid, iosMh, isDev, getSdkVersion, getSemverSdkVersion, getApplicationBuildVersion, getApplicationVersion };
package/lib/env.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.iosMh = exports.isAndroid = exports.isWeb = exports.isIos = void 0;
3
+ exports.getApplicationVersion = exports.getApplicationBuildVersion = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.iosMh = exports.isAndroid = exports.isWeb = exports.isIos = void 0;
4
4
  const gameLaunchConfig_1 = require("./gameLaunchConfig");
5
5
  const semver = require("semver");
6
6
  const isAndroid = Boolean(window.Android && window.Android.gameLoaded);
@@ -45,3 +45,36 @@ const getSemverSdkVersion = () => {
45
45
  return semverSdkVersion;
46
46
  };
47
47
  exports.getSemverSdkVersion = getSemverSdkVersion;
48
+ /**
49
+ * For match app build version and app sem version from user agent
50
+ * InAppStorySDK/750 Dalvik/2.1.0 (Linux; U; Android 11; XQ-AT51 Build/58.1.A.5.530) Application/258 (com.inappstory.android 3.1.0)
51
+ */
52
+ const appVersionFromUserAgentRegexp = /.*Application\/(\d+)\s\([a-zA-Z.]+\s([0-9.]+)\)/;
53
+ /**
54
+ * Get host application build version
55
+ */
56
+ const getApplicationBuildVersion = () => {
57
+ const userAgent = gameLaunchConfig_1.gameLaunchConfig.clientConfig.userAgent;
58
+ if (userAgent) {
59
+ const match = userAgent.match(appVersionFromUserAgentRegexp);
60
+ if (match && match[1]) {
61
+ return parseInt(match[1]);
62
+ }
63
+ }
64
+ return null;
65
+ };
66
+ exports.getApplicationBuildVersion = getApplicationBuildVersion;
67
+ /**
68
+ * Get host application sem version
69
+ */
70
+ const getApplicationVersion = () => {
71
+ const userAgent = gameLaunchConfig_1.gameLaunchConfig.clientConfig.userAgent;
72
+ if (userAgent) {
73
+ const match = userAgent.match(appVersionFromUserAgentRegexp);
74
+ if (match && match[2]) {
75
+ return match[2];
76
+ }
77
+ }
78
+ return null;
79
+ };
80
+ exports.getApplicationVersion = getApplicationVersion;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getSdkVersion, getSemverSdkVersion, isAndroid, isDev, isIos, isWeb } from "./env";
1
+ import { getApplicationBuildVersion, getApplicationVersion, getSdkVersion, getSemverSdkVersion, isAndroid, isDev, isIos, isWeb } from "./env";
2
2
  import { gameLaunchConfig, getIsDemoMode, getSessionId, getApiBaseUrl } from "./gameLaunchConfig";
3
3
  import { getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList } from "./gameResources";
4
4
  import { sendIasApiRequest } from "./iasApi";
@@ -23,7 +23,7 @@ export type { RequestInfo as APIRequestInfo, Response as APIResponse } from "./i
23
23
  export type { Placeholder, GameLaunchConfig };
24
24
  export type { ProjectFontFamily } from "./gameResources";
25
25
  export type { ResourceInterface } from "./ResourceManager";
26
- export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, share, vibrate, getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, getIsDemoMode, getSessionId, getApiBaseUrl, ScreenOrientation, PlaceholderType, fetchLocalFile, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, };
26
+ export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, share, vibrate, getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, getIsDemoMode, getSessionId, getApiBaseUrl, ScreenOrientation, PlaceholderType, fetchLocalFile, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, };
27
27
  declare const GameCenterApi: {
28
28
  createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: Partial<{
29
29
  mounted: () => void;
@@ -88,5 +88,7 @@ declare const GameCenterApi: {
88
88
  backGesture: boolean;
89
89
  }>> | undefined) => void;
90
90
  gameOnForeground: Promise<void>;
91
+ getApplicationVersion: () => string | null;
92
+ getApplicationBuildVersion: () => number | null;
91
93
  };
92
94
  export { GameCenterApi as default };
package/lib/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.share = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
3
+ exports.default = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.share = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
4
4
  const env_1 = require("./env");
5
+ Object.defineProperty(exports, "getApplicationBuildVersion", { enumerable: true, get: function () { return env_1.getApplicationBuildVersion; } });
6
+ Object.defineProperty(exports, "getApplicationVersion", { enumerable: true, get: function () { return env_1.getApplicationVersion; } });
5
7
  Object.defineProperty(exports, "getSdkVersion", { enumerable: true, get: function () { return env_1.getSdkVersion; } });
6
8
  Object.defineProperty(exports, "getSemverSdkVersion", { enumerable: true, get: function () { return env_1.getSemverSdkVersion; } });
7
9
  Object.defineProperty(exports, "isAndroid", { enumerable: true, get: function () { return env_1.isAndroid; } });
@@ -101,6 +103,8 @@ const GameCenterApi = {
101
103
  hasFilePickerApi: filePicker_1.hasFilePickerApi,
102
104
  gameShouldForegroundCallback: initGame_1.gameShouldForegroundCallback,
103
105
  gameOnForeground: initGame_1.gameOnForeground,
106
+ getApplicationVersion: env_1.getApplicationVersion,
107
+ getApplicationBuildVersion: env_1.getApplicationBuildVersion,
104
108
  };
105
109
  exports.default = GameCenterApi;
106
110
  // export { Placeholder as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "semver": "^7.3.8",