@jolibox/sdk 1.1.2 → 1.1.4-beta.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.
Files changed (89) hide show
  1. package/.eslintrc.js +3 -0
  2. package/.rush/temp/package-deps_build.json +28 -0
  3. package/.rush/temp/shrinkwrap-deps.json +76 -0
  4. package/README.md +1 -96
  5. package/dist/api/__tests__/canIUse.test.d.ts +1 -0
  6. package/dist/api/can-i-use.d.ts +1 -0
  7. package/dist/api/get-system-info.d.ts +3 -0
  8. package/dist/api/index.d.ts +2 -0
  9. package/dist/errors.d.ts +2 -0
  10. package/dist/index.cjs.js +1 -0
  11. package/dist/index.d.ts +19 -337
  12. package/dist/index.es.js +1 -0
  13. package/dist/index.iife.js +1 -12
  14. package/dist/loader/h5.d.ts +6 -0
  15. package/dist/loader/index.d.ts +16 -0
  16. package/dist/loader/native.d.ts +6 -0
  17. package/dist/loader/version.d.ts +2 -0
  18. package/dist/sdks/ads.d.ts +11 -0
  19. package/dist/sdks/keyboard.d.ts +34 -0
  20. package/dist/sdks/lifecycle.d.ts +16 -0
  21. package/dist/sdks/runtime.d.ts +1 -0
  22. package/dist/sdks/sdk.d.ts +11 -0
  23. package/dist/sdks/storage.d.ts +8 -0
  24. package/dist/utils/can-i-use.d.ts +2 -0
  25. package/dist/utils/report.d.ts +3 -0
  26. package/package.json +23 -33
  27. package/sdk.build.log +17 -0
  28. package/src/api/__tests__/canIUse.test.ts +76 -0
  29. package/src/api/can-i-use.ts +38 -0
  30. package/src/api/get-system-info.ts +14 -0
  31. package/src/api/index.ts +2 -0
  32. package/src/errors.ts +42 -0
  33. package/src/index.ts +29 -0
  34. package/src/loader/h5.ts +175 -0
  35. package/src/loader/index.ts +65 -0
  36. package/src/loader/native.ts +62 -0
  37. package/src/loader/version.ts +44 -0
  38. package/src/sdks/ads.ts +32 -0
  39. package/src/sdks/keyboard.ts +50 -0
  40. package/src/sdks/lifecycle.ts +32 -0
  41. package/src/sdks/runtime.ts +3 -0
  42. package/src/sdks/sdk.ts +22 -0
  43. package/src/sdks/storage.ts +35 -0
  44. package/src/utils/can-i-use.ts +24 -0
  45. package/src/utils/report.ts +23 -0
  46. package/tsconfig.json +12 -107
  47. package/README-zh_cn.md +0 -96
  48. package/dist/index.cjs +0 -2
  49. package/dist/index.cjs.map +0 -1
  50. package/dist/index.d.cts +0 -342
  51. package/dist/index.iife.js.map +0 -1
  52. package/dist/index.js +0 -2
  53. package/dist/index.js.map +0 -1
  54. package/docs/.nojekyll +0 -1
  55. package/docs/assets/highlight.css +0 -106
  56. package/docs/assets/icons.js +0 -18
  57. package/docs/assets/icons.svg +0 -1
  58. package/docs/assets/main.js +0 -60
  59. package/docs/assets/navigation.js +0 -1
  60. package/docs/assets/search.js +0 -1
  61. package/docs/assets/style.css +0 -1493
  62. package/docs/classes/ads.JoliboxAds.html +0 -41
  63. package/docs/classes/index.JoliboxSDK.html +0 -4
  64. package/docs/classes/loader.JoliboxSDKLoader.html +0 -7
  65. package/docs/classes/runtime.JoliboxRuntime.html +0 -8
  66. package/docs/documents/README.html +0 -38
  67. package/docs/enums/runtime.JoliboxRuntimeEvents.html +0 -7
  68. package/docs/index.html +0 -38
  69. package/docs/interfaces/ads.IAdConfigParams.html +0 -12
  70. package/docs/interfaces/ads.IAdUnitParams.html +0 -11
  71. package/docs/interfaces/ads.IAdsInitParams.html +0 -5
  72. package/docs/interfaces/ads.IInterstitialsParams.html +0 -15
  73. package/docs/interfaces/ads.IPlacementInfo.html +0 -59
  74. package/docs/interfaces/ads.IPrerollParams.html +0 -6
  75. package/docs/interfaces/ads.IRewardParams.html +0 -18
  76. package/docs/interfaces/index.IJoliboxConfig.html +0 -3
  77. package/docs/interfaces/loader.IJoliboxSDKLoaderConfig.html +0 -3
  78. package/docs/interfaces/loader.IRemoteVersionMetadata.html +0 -4
  79. package/docs/interfaces/loader.IVersionMetadata.html +0 -4
  80. package/docs/modules/ads.html +0 -12
  81. package/docs/modules/index.html +0 -4
  82. package/docs/modules/loader.html +0 -5
  83. package/docs/modules/runtime.html +0 -4
  84. package/docs/modules.html +0 -6
  85. package/docs/types/ads.AdUnitFormat.html +0 -2
  86. package/docs/types/ads.IAdBreakParams.html +0 -2
  87. package/tsup.config.ts +0 -27
  88. package/typedoc.config.mjs +0 -19
  89. package/vitest.config.ts +0 -10
package/dist/index.d.cts DELETED
@@ -1,342 +0,0 @@
1
- import { JoliboxRuntime, JoliboxCloudStorage } from '@jolibox/web-sync-sdk';
2
-
3
- declare global {
4
- interface Window {
5
- JOLIBOX_ENV: "WEB" | "IOS" | "ANDROID" | "WINDOWS" | "MACOS" | "LINUX";
6
- JoliboxSDKLoader: typeof JoliboxSDKLoader;
7
- }
8
- }
9
- interface IVersionMetadata {
10
- version: string;
11
- syncScriptUrl?: string;
12
- asyncScriptUrl?: string;
13
- }
14
- interface IJoliboxSDKLoaderConfig {
15
- loaderMetadata?: IVersionMetadata;
16
- }
17
- declare class JoliboxSDKLoader {
18
- loaderMetadata: IVersionMetadata;
19
- constructor({ loaderMetadata }?: IJoliboxSDKLoaderConfig);
20
- private get currentVersion();
21
- private get defaultMetadata();
22
- computeLoaderMetaData: () => IVersionMetadata;
23
- loadScript: () => void;
24
- fetchUpdateLoaderMetadata: (installedSDKVersion?: string, localSDKVersion?: string, env?: "WEB" | "IOS" | "ANDROID" | "WINDOWS" | "MACOS" | "LINUX") => Promise<void>;
25
- }
26
-
27
- declare global {
28
- interface Window {
29
- JoliboxAds: typeof JoliboxAds;
30
- }
31
- }
32
- interface IAdsInitParams {
33
- /**
34
- * (OPTIONAL) Game ID provided by Jolibox
35
- */
36
- gameId?: string;
37
- }
38
- interface IAdConfigParams {
39
- /**
40
- * (OPTIONAL) Whether ads should always be preloaded before the first call to adBreak()
41
- *
42
- * The default value of auto leaves the decision up to the Ad Placement API. preloadAdBreaks can be set only once with adConfig(), and further values passed to preloadAdBreaks have no effect.
43
- *
44
- * Setting preloadAdBreaks after the first call to adBreak() has no effect.
45
- */
46
- preloadAdBreaks?: "on" | "auto";
47
- /**
48
- * (OPTIONAL) Whether the game is currently playing sound.
49
- *
50
- * This call specifies whether your game is capable of sound, and whether the sound was enabled (ie unmuted) before the call to adBreak(). This helps the Ad Placement API to select the right kind of ad for your game.
51
- *
52
- * Call this function as soon as the sound state of your game changes, as the Ad Placement API may have to request new creatives, and this gives it the maximum amount of time to do so.
53
- *
54
- * The default value is sound on. So most games will need to make a call to adConfig() when they start to declare that they have sound enabled.
55
- */
56
- sound?: "on" | "off";
57
- /**
58
- * (OPTIONAL) Called when the API has initialized and has finished preloading ads (if you requested preloading using the preloadAdBreaks above).
59
- * @returns
60
- */
61
- onReady?: () => void;
62
- }
63
- /**
64
- * PlacementInfo object passed by **adBreakDone** function
65
- */
66
- interface IPlacementInfo {
67
- /**
68
- * the type argument passed to adBreak()
69
- */
70
- breakType: string;
71
- /**
72
- * the name argument passed to adBreak()
73
- */
74
- breakName: string;
75
- breakFormat: "interstitial" | "reward";
76
- /**
77
- * the status of this placement and can be one of the following values:
78
- *
79
- * | breakStatus | Reason |
80
- * | -------- | ------- |
81
- * | 'notReady' | The Ad Placement API had not initialised |
82
- * | 'timeout' | A placement timed out because the Ad Placement API took too long to respond |
83
- * | 'invalid' | The placement was invalid and was ignored–for instance there should only be one preroll placement per page load, subsequent prerolls are failed with this status |
84
- * | 'error' | There was a JavaScript error in a callback |
85
- * | 'noAdPreloaded' | An ad had not been preloaded yet so this placement was skipped |
86
- * | 'frequencyCapped' | An ad wasn't shown because the frequency cap was applied to this placement |
87
- * | 'ignored' | The user didn't click on a reward prompt before they reached the next placement, that is showAdFn() wasn't called before the next adBreak(). |
88
- * | 'other' | The ad was not shown for another reason. (e.g., The ad was still being fetched, or a previously cached ad was disposed because the screen was resized/rotated.) |
89
- * | 'dismissed' | The user dismissed a rewarded ad before viewing it to completion |
90
- * | 'viewed' | The ad was viewed by the user |
91
- */
92
- breakStatus: "notReady" | "timeout" | "error" | "noAdPreloaded" | "frequencyCapped" | "ignored" | "other" | "dismissed" | "viewed";
93
- }
94
- /**
95
- * Parameter when calling adBreak
96
- */
97
- type IAdBreakParams = IPrerollParams | IInterstitialsParams | IRewardParams;
98
- /**
99
- * Parameter when calling preroll type adBreak
100
- */
101
- interface IPrerollParams {
102
- /**
103
- * 'preroll' before the game loads (before UI has rendered)
104
- */
105
- type: "preroll";
106
- /**
107
- * (OPTIONAL) Always called as the last step in an adBreak(), even if there was no ad shown. Function takes as argument a placementInfo object
108
- * @param placementInfo
109
- * @returns
110
- */
111
- adBreakDone?: (placementInfo: IPlacementInfo) => void;
112
- }
113
- interface IInterstitialsParams {
114
- /**
115
- * 'start' before the gameplay starts (after UI has rendered)
116
- * 'pause' the player pauses the game
117
- * 'next' player navigates to the next level
118
- * 'browse' the player explores options outside of the gameplay
119
- */
120
- type: "start" | "pause" | "next" | "browse";
121
- /**
122
- * (OPTIONAL) a name for this particular ad placement within your game. It is an internal identifier, and is not shown to the player. In future releases this identifier may be used to enable additional reporting and optimization features.
123
- *
124
- * We recommend you name all of your placements.
125
- */
126
- name?: string;
127
- /**
128
- * (OPTIONAL) Called before the ad is displayed. The game should pause and mute the sound. These actions must be done synchronously. The ad will be displayed immediately after this callback finishes.
129
- *
130
- * @returns
131
- */
132
- beforeAd?: () => void;
133
- /**
134
- * (OPTIONAL) Called after the ad is finished (for any reason). For rewarded ads, it is called after either adDismissed or adViewed, depending on player actions. This function should be used to resume game flow. For example, use to unmute the sound and start the next level.
135
- * @returns
136
- */
137
- afterAd?: () => void;
138
- /**
139
- * (OPTIONAL) Always called as the last step in an adBreak(), even if there was no ad shown. Function takes as argument a placementInfo object
140
- *
141
- * @param placementInfo
142
- * @returns
143
- */
144
- adBreakDone?: (placementInfo: IPlacementInfo) => void;
145
- }
146
- interface IRewardParams {
147
- /**
148
- * 'reward' a rewarded ad
149
- */
150
- type: "reward";
151
- /**
152
- * (OPTIONAL) a name for this particular ad placement within your game. It is an internal identifier, and is not shown to the player. In future releases this identifier may be used to enable additional reporting and optimization features.
153
- *
154
- * We recommend you name all of your placements.
155
- */
156
- name?: string;
157
- /**
158
- * (OPTIONAL) Called before the ad is displayed. The game should pause and mute the sound. These actions must be done synchronously. The ad will be displayed immediately after this callback finishes.
159
- * @returns
160
- */
161
- beforeAd?: () => void;
162
- /**
163
- * (OPTIONAL) Called after the ad is finished (for any reason). For rewarded ads, it is called after either adDismissed or adViewed, depending on player actions. This function should be used to resume game flow. For example, use to unmute the sound and start the next level.
164
- * @returns
165
- */
166
- afterAd?: () => void;
167
- /**
168
- * (OPTIONAL) Always called as the last step in an adBreak(), even if there was no ad shown. Function takes as argument a placementInfo object defined
169
- * @param placementInfo
170
- * @returns
171
- */
172
- adBreakDone?: (placementInfo: IPlacementInfo) => void;
173
- /**
174
- * Called if a rewarded ad is available. The function should take a single argument–showAdFn() which must be called to display the rewarded ad.
175
- * @param showAdFn
176
- * @returns
177
- */
178
- beforeReward: (showAdFn: () => void) => void;
179
- /**
180
- * Called only for rewarded ads when the player dismisses the ad. It is only called if the player dismisses the ad before it completes. In this case the reward should not be granted.
181
- * @returns
182
- */
183
- adDismissed: () => void;
184
- /**
185
- * Called only for rewarded ads when the player completes the ad and should be granted the reward.
186
- * @returns
187
- */
188
- adViewed: () => void;
189
- }
190
- /**
191
- * Ad unit format, can be 'rectangle', 'vertical', 'horizontal'
192
- */
193
- type AdUnitFormat = "rectangle" | "vertical" | "horizontal";
194
- interface IAdUnitParams {
195
- /**
196
- * The element to attach the ad unit to, either an HTMLElement or a string selector. Should be the parent element of the ad unit (<ins> tag).
197
- */
198
- el: HTMLElement | string;
199
- /**
200
- * (OPTIONAL) Reserved for future usage. The slot ID of the ad unit. Currently the slot ID is automatically set by the SDK.
201
- */
202
- slot?: string;
203
- /**
204
- * (OPTIONAL) Ad format for the ad unit. Can be 'auto' or a single format or an array of formats. Default is 'auto'. If passed as an array, the array will be joined by ', ' and pass to the data-ad-format attribute.
205
- */
206
- adFormat?: "auto" | AdUnitFormat | AdUnitFormat[];
207
- /**
208
- * (OPTIONAL) Whether the ad unit should be full width and responsive. Default is false.
209
- */
210
- fullWidthResponsive?: "true" | "false";
211
- /**
212
- * (OPTIONAL) Custom style for the ad unit. Default is empty.
213
- */
214
- style?: string;
215
- }
216
- /**
217
- * Jolibox Ads SDK
218
- */
219
- declare class JoliboxAds {
220
- /**
221
- * Internal constructor, should not be called directly
222
- */
223
- constructor();
224
- /**
225
- * Init JoliboxAds. Must be called before any other ads functions.
226
- * @param config
227
- * @returns
228
- */
229
- init: (config?: IAdsInitParams) => void;
230
- /**
231
- * The adConfig() call communicates the game's current configuration to the Ad Placement API. The Ad Placement API can use this to tune the way it preloads ads and to filter the kinds of ads it requests so they're suitable (eg. video ads that require sound).
232
- * @param params
233
- */
234
- adConfig: (params: IAdConfigParams) => void;
235
- /**
236
- * adBreak() is the key function for placing ads within your game. It defines an ad placement and takes an object called a placement config that specifies everything required to show an ad.
237
- *
238
- * The adBreak() function defines a placement where an ad could be shown. Whether an ad actually shows depends on factors such as the following:
239
- *
240
- * - The type of ad placement that you declared
241
- * - Is this ad at the start of the game? Between levels? At a moment when the player has paused the game?
242
- * - Whether a suitable ad exists for the current player
243
- * - Is this ad relevant to them?
244
- * - Is it consistent with their data privacy and consent settings?
245
- * - The number of ads the player has seen recently
246
- * - The control settings—for example, ad frequency, you've configured for this game
247
- * - Either as hints in the tag, or,
248
- * - Within AdSense—note that the controls available in AdSense will evolve over time.
249
- *
250
- * The kind of ad that shows also depends on similar factors.
251
- *
252
- * Note that a call to adBreak() might not show an ad at all. It simply declares a place where an ad could be shown.
253
- *
254
- * This is unlike traditional APIs in which your code always knows if an ad is available, and you decide within the game whether to show it. This approach of letting the Ad Placement API decide if an ad shows in a particular placement is a pattern that is sometimes referred to as "inversion of control".
255
- *
256
- * The reason we're transitioning our games API to this model is firstly, it shortens the code you have to write within your game. Secondly, it makes it easier to deliver policy compliant placements with a great user experience, which in turn has allowed us to deliver some of our highest performing formats to games publishers. Lastly, it more cleanly separates the process of placing ads in your game from the monetization decisions about the type and number of ads to show.
257
- *
258
- * We want you to be able to change your monetization settings and control the user experience without having to edit and release a new version of your game, initially by specifying hints in the tag. But in future releases, we will be able to provide controls directly in the AdSense and AdMob frontends.
259
- * @param params
260
- */
261
- adBreak: (params: IAdBreakParams) => void;
262
- /**
263
- * adUnit() is a function that creates an ad unit and attaches it to a parent element. The ad unit is a single ad placement that can be used to show ads.
264
- *
265
- * Currently we only provide support for creating ad units as `<ins>` tags with the class 'adsbygoogle'. This is the standard way to create ad units with Google AdSense.
266
- *
267
- * After calling this method, the ad unit is attached to the parent element you specify as el in the params object.
268
- *
269
- * By default, the client ID and channel ID are automatically set by the SDK. And the slot name is set to the position of the ad unit. You can override these values by passing the slot and channelId in the params object.
270
- *
271
- * @param params
272
- * @returns
273
- */
274
- adUnit: (params: IAdUnitParams) => Promise<void>;
275
- }
276
-
277
- declare global {
278
- interface Window {
279
- JoliboxAnalytics: typeof JoliboxAnalytics;
280
- }
281
- }
282
- /**
283
- * Jolibox Analytics SDK
284
- */
285
- declare class JoliboxAnalytics {
286
- constructor();
287
- /**
288
- * Track an event, will be sent to the analytics server
289
- * Currently not open to the public
290
- *
291
- * @param eventName event name, must be a string
292
- * @param extra (OPTIONAL) extra data, must be an object or null or undefined, must not have nested objects
293
- */
294
- private trackEvent;
295
- }
296
-
297
- declare global {
298
- interface IJoliboxSDK extends JoliboxSDK {
299
- _commandPipe: ICommandPipe[];
300
- }
301
- interface Window {
302
- __JOLIBOX_LOCAL_SDK_VERSION__: string;
303
- joliboxenv?: {
304
- joliboxEnv: "staging" | "production";
305
- testAdsMode: boolean;
306
- apiBaseURL: string;
307
- };
308
- joliboxsdk: IJoliboxSDK;
309
- JoliboxSDK: typeof JoliboxSDK;
310
- }
311
- interface ImportMeta {
312
- env: {
313
- JOLIBOX_SDK_VERSION: string;
314
- };
315
- }
316
- }
317
- /**
318
- * Jolibox SDK Constructor Config
319
- */
320
- interface IJoliboxConfig {
321
- useRuntimeSDK?: boolean;
322
- loaderConfig?: IJoliboxSDKLoaderConfig;
323
- joliboxEnv?: "staging" | "production";
324
- testAdsMode?: boolean;
325
- apiBaseURL?: string;
326
- }
327
- interface ICommandPipe {
328
- cmd: string;
329
- params: any;
330
- }
331
- declare class JoliboxSDK {
332
- private loader;
333
- ads: JoliboxAds;
334
- private anaytics;
335
- runtime: JoliboxRuntime;
336
- storage: JoliboxCloudStorage;
337
- private hostToApiMap;
338
- private setJoliboxEnv;
339
- constructor({ useRuntimeSDK, loaderConfig, joliboxEnv, testAdsMode, apiBaseURL, }?: IJoliboxConfig);
340
- }
341
-
342
- export { type IJoliboxConfig, JoliboxSDK, JoliboxSDK as default };