@looplay/sdk 0.8.8 → 0.8.9
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 +10 -9
- package/dist/looplay-sdk.cjs.js +50 -2
- package/dist/looplay-sdk.cjs.js.map +1 -1
- package/dist/looplay-sdk.esm.js +47 -3
- package/dist/looplay-sdk.esm.js.map +1 -1
- package/dist/looplay-sdk.min.js +5 -5
- package/dist/looplay-sdk.min.js.map +1 -1
- package/dist/types/constants.d.ts +20 -0
- package/dist/types/iframe/types.d.ts +4 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/looplay-sdk.esm.js
CHANGED
|
@@ -682,6 +682,43 @@ var ApiClient = class {
|
|
|
682
682
|
}
|
|
683
683
|
};
|
|
684
684
|
|
|
685
|
+
// src/constants.ts
|
|
686
|
+
var DEFAULT_API_URL = "https://miniapp-api.looplay.gg";
|
|
687
|
+
function resolveEnvParentOrigin() {
|
|
688
|
+
try {
|
|
689
|
+
if (typeof import.meta !== "undefined" && import.meta.env?.VITE_PARENT_ORIGIN) {
|
|
690
|
+
const val = import.meta.env.VITE_PARENT_ORIGIN;
|
|
691
|
+
if (typeof val === "string" && val.trim().length > 0) return val.trim();
|
|
692
|
+
}
|
|
693
|
+
} catch {
|
|
694
|
+
}
|
|
695
|
+
try {
|
|
696
|
+
if (typeof process !== "undefined" && process.env?.VITE_PARENT_ORIGIN) {
|
|
697
|
+
const val = process.env.VITE_PARENT_ORIGIN;
|
|
698
|
+
if (typeof val === "string" && val.trim().length > 0) return val.trim();
|
|
699
|
+
}
|
|
700
|
+
} catch {
|
|
701
|
+
}
|
|
702
|
+
return void 0;
|
|
703
|
+
}
|
|
704
|
+
function resolveEnvApiUrl() {
|
|
705
|
+
try {
|
|
706
|
+
if (typeof import.meta !== "undefined" && import.meta.env) {
|
|
707
|
+
const val = import.meta.env.VITE_API_URL ?? import.meta.env.VITE_LOOPLAY_API_URL;
|
|
708
|
+
if (typeof val === "string" && val.trim().length > 0) return val.trim();
|
|
709
|
+
}
|
|
710
|
+
} catch {
|
|
711
|
+
}
|
|
712
|
+
try {
|
|
713
|
+
if (typeof process !== "undefined" && process.env) {
|
|
714
|
+
const val = process.env.VITE_API_URL ?? process.env.VITE_LOOPLAY_API_URL;
|
|
715
|
+
if (typeof val === "string" && val.trim().length > 0) return val.trim();
|
|
716
|
+
}
|
|
717
|
+
} catch {
|
|
718
|
+
}
|
|
719
|
+
return void 0;
|
|
720
|
+
}
|
|
721
|
+
|
|
685
722
|
// src/looplay-sdk.ts
|
|
686
723
|
var LooplaySDK = class {
|
|
687
724
|
auth;
|
|
@@ -689,7 +726,12 @@ var LooplaySDK = class {
|
|
|
689
726
|
gameId;
|
|
690
727
|
initialized = false;
|
|
691
728
|
constructor(options = {}) {
|
|
692
|
-
const {
|
|
729
|
+
const {
|
|
730
|
+
auth,
|
|
731
|
+
baseUrl = resolveEnvApiUrl() ?? DEFAULT_API_URL,
|
|
732
|
+
fetch,
|
|
733
|
+
defaultHeaders
|
|
734
|
+
} = options;
|
|
693
735
|
if (auth) {
|
|
694
736
|
this.auth = new LooplayAuth(auth);
|
|
695
737
|
}
|
|
@@ -962,7 +1004,7 @@ var LooplayIframeAuth = class {
|
|
|
962
1004
|
return this.state.jwt;
|
|
963
1005
|
}
|
|
964
1006
|
getApiUrl() {
|
|
965
|
-
return this.state.apiUrl ?? this.options.apiUrl ??
|
|
1007
|
+
return this.state.apiUrl ?? this.options.apiUrl ?? resolveEnvApiUrl() ?? DEFAULT_API_URL;
|
|
966
1008
|
}
|
|
967
1009
|
/** Resolves to the configured `appId`, falling back to whatever the parent pushed as `gameId`. */
|
|
968
1010
|
getGameId() {
|
|
@@ -1338,6 +1380,8 @@ ${gameId}`;
|
|
|
1338
1380
|
}
|
|
1339
1381
|
resolveParentOrigin() {
|
|
1340
1382
|
if (this.options.parentOrigin) return this.options.parentOrigin;
|
|
1383
|
+
const envOrigin = resolveEnvParentOrigin();
|
|
1384
|
+
if (envOrigin) return envOrigin;
|
|
1341
1385
|
if (typeof document === "undefined" || !document.referrer) return null;
|
|
1342
1386
|
try {
|
|
1343
1387
|
return new URL(document.referrer).origin;
|
|
@@ -1379,6 +1423,6 @@ ${gameId}`;
|
|
|
1379
1423
|
}
|
|
1380
1424
|
};
|
|
1381
1425
|
|
|
1382
|
-
export { ApiClient, BrowserLocalStorageAuthStorage, HttpClient, HttpError, LOOPLAY_SDK_VERSION, LooplayAuth, LooplayIframeAuth, LooplaySDK, LooplaySDKError, MemoryAuthStorage, MissingAuthError, MissingBaseUrlError, NotAuthenticatedError, NotInitializedError, ServiceClient, TelegramAuthProvider };
|
|
1426
|
+
export { ApiClient, BrowserLocalStorageAuthStorage, DEFAULT_API_URL, HttpClient, HttpError, LOOPLAY_SDK_VERSION, LooplayAuth, LooplayIframeAuth, LooplaySDK, LooplaySDKError, MemoryAuthStorage, MissingAuthError, MissingBaseUrlError, NotAuthenticatedError, NotInitializedError, ServiceClient, TelegramAuthProvider, resolveEnvApiUrl, resolveEnvParentOrigin };
|
|
1383
1427
|
//# sourceMappingURL=looplay-sdk.esm.js.map
|
|
1384
1428
|
//# sourceMappingURL=looplay-sdk.esm.js.map
|