@inappstory/game-center-api 1.3.5 → 1.3.7
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/lib/gameResources.d.ts +3 -6
- package/lib/gameResources.js +18 -25
- package/lib/index.d.ts +5 -1
- package/lib/index.js +4 -1
- package/lib/sdkApi/index.d.ts +2 -0
- package/lib/sdkApi/index.js +7 -2
- package/lib/sdkApi/openGameInstance.d.ts +2 -0
- package/lib/sdkApi/openGameInstance.h.d.ts +3 -0
- package/lib/sdkApi/openGameInstance.h.js +2 -0
- package/lib/sdkApi/openGameInstance.js +8 -0
- package/package.json +1 -1
package/lib/gameResources.d.ts
CHANGED
|
@@ -16,14 +16,11 @@ export declare class Resource implements ResourceInterface {
|
|
|
16
16
|
}
|
|
17
17
|
export declare abstract class ResourceList implements Iterable<ResourceInterface> {
|
|
18
18
|
protected orderOfFetch: number;
|
|
19
|
+
protected _hashMap: Record<string, Resource> | null;
|
|
20
|
+
protected get hashMap(): Readonly<Record<string, Resource>>;
|
|
19
21
|
constructor();
|
|
20
|
-
|
|
21
|
-
[k: string]: string;
|
|
22
|
-
};
|
|
23
|
-
getAssetByKey(key: string, defaultValue: any): any;
|
|
24
|
-
protected _assets: Array<Resource> | undefined;
|
|
22
|
+
getAssetByKey<T>(key: string, defaultValue: T): string | T;
|
|
25
23
|
protected rawMapGetter(): Record<string, string>;
|
|
26
|
-
protected get __assets(): Resource[];
|
|
27
24
|
protected prepareSrc(src: string, key: string): string;
|
|
28
25
|
protected onCacheDone(): void;
|
|
29
26
|
[Symbol.iterator](): {
|
package/lib/gameResources.js
CHANGED
|
@@ -43,47 +43,40 @@ class Resource {
|
|
|
43
43
|
exports.Resource = Resource;
|
|
44
44
|
class ResourceList {
|
|
45
45
|
orderOfFetch = 0;
|
|
46
|
-
|
|
47
|
-
get
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
_hashMap = null;
|
|
47
|
+
get hashMap() {
|
|
48
|
+
if (this._hashMap === null) {
|
|
49
|
+
const map = this.rawMapGetter();
|
|
50
|
+
this._hashMap = {};
|
|
51
|
+
let src;
|
|
52
|
+
for (let key in map) {
|
|
53
|
+
src = map[key];
|
|
54
|
+
this._hashMap[key] = new Resource(key, this.prepareSrc(src, key), src, this.orderOfFetch);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return this._hashMap;
|
|
58
|
+
}
|
|
59
|
+
constructor() { }
|
|
60
|
+
getAssetByKey(key, defaultValue) {
|
|
61
|
+
const resource = this.hashMap[key] ?? null;
|
|
62
|
+
return resource === null ? defaultValue : resource.getCacheUri();
|
|
58
63
|
}
|
|
59
|
-
_assets = undefined;
|
|
60
64
|
rawMapGetter() {
|
|
61
65
|
return {};
|
|
62
66
|
}
|
|
63
|
-
get __assets() {
|
|
64
|
-
if (this._assets == null) {
|
|
65
|
-
const map = this.rawMapGetter();
|
|
66
|
-
this._assets = new Array();
|
|
67
|
-
for (let key in map) {
|
|
68
|
-
let src = map[key];
|
|
69
|
-
this._assets.push(new Resource(key, this.prepareSrc(src, key), src, this.orderOfFetch));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return this._assets;
|
|
73
|
-
}
|
|
74
67
|
prepareSrc(src, key) {
|
|
75
68
|
return src;
|
|
76
69
|
}
|
|
77
70
|
onCacheDone() { }
|
|
78
71
|
[Symbol.iterator]() {
|
|
79
72
|
let pointer = 0;
|
|
80
|
-
const
|
|
73
|
+
const resources = Object.values(this.hashMap);
|
|
81
74
|
return {
|
|
82
75
|
next() {
|
|
83
|
-
if (pointer <
|
|
76
|
+
if (pointer < resources.length) {
|
|
84
77
|
return {
|
|
85
78
|
done: false,
|
|
86
|
-
value:
|
|
79
|
+
value: resources[pointer++],
|
|
87
80
|
};
|
|
88
81
|
}
|
|
89
82
|
else {
|
package/lib/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { vibrate } from "./sdkApi/vibrate";
|
|
|
11
11
|
import { ScreenOrientation, Placeholder, PlaceholderType, GameLaunchConfig } from "./gameLaunchConfig.h";
|
|
12
12
|
import { fetchLocalFile } from "./sdkApi/fetchLocalFile";
|
|
13
13
|
import { openStory } from "./sdkApi/openStory";
|
|
14
|
+
import { openGameInstance } from "./sdkApi/openGameInstance";
|
|
14
15
|
import { eventGame } from "./sdkApi/events";
|
|
15
16
|
import { ResourceManager } from "./ResourceManager";
|
|
16
17
|
import { hasFilePickerApi, openFilePicker } from "./sdkApi/filePicker";
|
|
@@ -22,7 +23,9 @@ export type { RequestInfo as APIRequestInfo, Response as APIResponse } from "./i
|
|
|
22
23
|
export type { Placeholder, GameLaunchConfig };
|
|
23
24
|
export type { ProjectFontFamily } from "./gameResources";
|
|
24
25
|
export type { ResourceInterface } from "./ResourceManager";
|
|
25
|
-
export {
|
|
26
|
+
export type { OpenStoryOptions } from "./sdkApi/openStory.h";
|
|
27
|
+
export type { OpenGameInstanceOptions } from "./sdkApi/openGameInstance.h";
|
|
28
|
+
export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, shareText, shareUrl, shareFiles, 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, openGameInstance, };
|
|
26
29
|
declare const GameCenterApi: {
|
|
27
30
|
createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: Partial<{
|
|
28
31
|
mounted: () => void;
|
|
@@ -86,5 +89,6 @@ declare const GameCenterApi: {
|
|
|
86
89
|
gameOnForeground: Promise<void>;
|
|
87
90
|
getApplicationVersion: () => string | null;
|
|
88
91
|
getApplicationBuildVersion: () => number | null;
|
|
92
|
+
openGameInstance: (openGameInstance: import("./sdkApi/openGameInstance.h").OpenGameInstanceOptions) => void;
|
|
89
93
|
};
|
|
90
94
|
export { GameCenterApi as default };
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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.shareFiles = exports.shareUrl = exports.shareText = 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.openGameInstance = 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.shareFiles = exports.shareUrl = exports.shareText = 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
5
|
Object.defineProperty(exports, "getApplicationBuildVersion", { enumerable: true, get: function () { return env_1.getApplicationBuildVersion; } });
|
|
6
6
|
Object.defineProperty(exports, "getApplicationVersion", { enumerable: true, get: function () { return env_1.getApplicationVersion; } });
|
|
@@ -51,6 +51,8 @@ const fetchLocalFile_1 = require("./sdkApi/fetchLocalFile");
|
|
|
51
51
|
Object.defineProperty(exports, "fetchLocalFile", { enumerable: true, get: function () { return fetchLocalFile_1.fetchLocalFile; } });
|
|
52
52
|
const openStory_1 = require("./sdkApi/openStory");
|
|
53
53
|
Object.defineProperty(exports, "openStory", { enumerable: true, get: function () { return openStory_1.openStory; } });
|
|
54
|
+
const openGameInstance_1 = require("./sdkApi/openGameInstance");
|
|
55
|
+
Object.defineProperty(exports, "openGameInstance", { enumerable: true, get: function () { return openGameInstance_1.openGameInstance; } });
|
|
54
56
|
const events_1 = require("./sdkApi/events");
|
|
55
57
|
Object.defineProperty(exports, "eventGame", { enumerable: true, get: function () { return events_1.eventGame; } });
|
|
56
58
|
const ResourceManager_1 = require("./ResourceManager");
|
|
@@ -109,6 +111,7 @@ const GameCenterApi = {
|
|
|
109
111
|
gameOnForeground: initGame_1.gameOnForeground,
|
|
110
112
|
getApplicationVersion: env_1.getApplicationVersion,
|
|
111
113
|
getApplicationBuildVersion: env_1.getApplicationBuildVersion,
|
|
114
|
+
openGameInstance: openGameInstance_1.openGameInstance,
|
|
112
115
|
};
|
|
113
116
|
exports.default = GameCenterApi;
|
|
114
117
|
// export { Placeholder as default};
|
package/lib/sdkApi/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { SdkApiCallbacks } from "./index.h";
|
|
5
5
|
import { OpenStoryOptions } from "./openStory.h";
|
|
6
|
+
import { OpenGameInstanceOptions } from "./openGameInstance.h";
|
|
6
7
|
export declare const createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: SdkApiCallbacks) => void;
|
|
7
8
|
export type CloseGameReaderOptions = {
|
|
8
9
|
[key: string]: any;
|
|
9
10
|
openUrl?: string;
|
|
10
11
|
openStory?: OpenStoryOptions;
|
|
12
|
+
openGameInstance?: OpenGameInstanceOptions;
|
|
11
13
|
};
|
|
12
14
|
export declare const closeGameReader: (data?: CloseGameReaderOptions) => void;
|
|
13
15
|
export declare const reloadGameReader: () => void;
|
package/lib/sdkApi/index.js
CHANGED
|
@@ -136,9 +136,13 @@ const sdkCloseGameReader = (data) => {
|
|
|
136
136
|
const devPayload = data ?? {};
|
|
137
137
|
const openUrl = data?.openUrl != null ? data.openUrl : null;
|
|
138
138
|
const openStory = data?.openStory != null ? data.openStory : null;
|
|
139
|
+
const openGameInstance = data?.openGameInstance != null ? data.openGameInstance : null;
|
|
140
|
+
if (openGameInstance != null && openGameInstance.id != null) {
|
|
141
|
+
openGameInstance.id = String(openGameInstance.id);
|
|
142
|
+
}
|
|
139
143
|
if (env_1.isAndroid) {
|
|
140
144
|
// {openUrl: null, openStory: {id: 1, slideIndex: 0}}
|
|
141
|
-
const config = JSON.stringify({ openUrl, openStory });
|
|
145
|
+
const config = JSON.stringify({ openUrl, openStory, openGameInstance });
|
|
142
146
|
window.Android.gameComplete(JSON.stringify(data), JSON.stringify(devPayload), config);
|
|
143
147
|
}
|
|
144
148
|
else if (env_1.isIos) {
|
|
@@ -148,11 +152,12 @@ const sdkCloseGameReader = (data) => {
|
|
|
148
152
|
result: devPayload,
|
|
149
153
|
openUrl,
|
|
150
154
|
openStory,
|
|
155
|
+
openGameInstance,
|
|
151
156
|
}));
|
|
152
157
|
}
|
|
153
158
|
else if (env_1.isWeb) {
|
|
154
159
|
if (Source_1.webSource.sourceWindow && Source_1.webSource.sourceWindowOrigin) {
|
|
155
|
-
Source_1.webSource.sourceWindow.postMessage(["gameComplete", data, devPayload, null, openStory], Source_1.webSource.sourceWindowOrigin);
|
|
160
|
+
Source_1.webSource.sourceWindow.postMessage(["gameComplete", data, devPayload, null, openStory, openGameInstance], Source_1.webSource.sourceWindowOrigin);
|
|
156
161
|
}
|
|
157
162
|
}
|
|
158
163
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openGameInstance = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const openGameInstance = (openGameInstance) => {
|
|
6
|
+
(0, index_1.closeGameReader)({ openGameInstance });
|
|
7
|
+
};
|
|
8
|
+
exports.openGameInstance = openGameInstance;
|