diff --git a/@types/ysdk.d.ts b/@types/ysdk.d.ts deleted file mode 100644 index f4fab8e..0000000 --- a/@types/ysdk.d.ts +++ /dev/null @@ -1,292 +0,0 @@ -declare module "ysdk" { - global { - const YaGames: { - init(opts?: { - screen: { - fullscreen?: boolean; - orientation?: { - value: "portrait" | "landscape"; - lock?: boolean; - }; - }; - }): Promise; - }; - } - - namespace YandexGames { - interface SDK { - environment: Environment; - - deviceInfo: DeviceInfo; - - features: Partial<{ - LoadingAPI: { - ready(): void; - }; - }>; - - clipboard: { - writeText(text: string): void; - }; - - screen: { - fullscreen: { - STATUS_ON: "on"; - STATUS_OFF: "off"; - status: string; - request(): Promise; - exit(): Promise; - }; - }; - - getStorage(): Promise; - - auth: { - openAuthDialog(): Promise; - }; - - getPlayer(opts: { - signed?: TSigned; - }): Promise : Player>; - - feedback: { - canReview(): Promise<{ - value: boolean; - reason?: FeedbackError; - }>; - requestReview(): Promise<{ feedbackSent: boolean }>; - }; - - adv: { - showFullscreenAdv(opts?: { - callbacks?: { - onOpen?: () => void; - onClose?: (wasShown: boolean) => void; - onError?: (error: string) => void; - onOffline?: () => void; - }; - }): void; - - showRewardedVideo(opts?: { - callbacks?: { - onOpen?: () => void; - onClose?: (wasShown: boolean) => void; - onError?: (error: string) => void; - onRewarded?: () => void; - }; - }): void; - - showBannerAdv(): Promise<{ reason?: StickyAdvError }>; - - hideBannerAdv(): void; - - getBannerAdvStatus(): Promise<{ - stickyAdvIsShowing: boolean; - reason?: StickyAdvError; - }>; - }; - - EVENTS: { - EXIT: "EXIT"; - HISTORY_BACK: "HISTORY_BACK"; - }; - - dispatchEvent(eventName: SdkEventName, detail?: any): Promise; - - onEvent(eventName: SdkEventName, listener: Function): () => void; - - shortcut: { - canShowPrompt(): Promise<{ canShow: boolean }>; - showPrompt(): Promise<{ outcome: "accepted" | "rejected" }>; - }; - - getPayments(opts?: { - signed?: TSigned; - }): Promise>; - - getLeaderboards(): Promise; - - getFlags(params?: GetFlagsParams): Promise; - - isAvailableMethod(methodName: string): Promise; - } - - interface IFlags { - [key: string]: string; - } - - interface ClientFeature { - name: string; - value: string; - } - - interface GetFlagsParams { - defaultFlags?: IFlags; - clientFeatures?: ClientFeature[]; - } - - type Signed = T & { signature: string }; - - export interface Environment { - get app(): { - id: string; - }; - get browser(): { - lang: string; - }; - get i18n(): { - lang: ISO_639_1; - tld: TopLevelDomain; - }; - get payload(): string | null; - } - - export interface DeviceInfo { - get type(): string; - isMobile(): boolean; - isTablet(): boolean; - isDesktop(): boolean; - isTV(): boolean; - } - - export type SafeStorage = typeof localStorage; - - export interface Player { - getUniqueID(): string; - getName(): string; - getPhoto(size: "small" | "medium" | "large"): string; - getIDsPerGame(): Promise<{ appID: number; userID: string }[]>; - getMode(): "lite" | ""; - getData(keys?: (keyof TData)[]): Promise>; - setData(data: Partial, flush?: boolean): Promise; - getStats(keys?: (keyof TStats)[]): Promise>; - setStats>( - stats: Partial - ): Promise; - incrementStats>( - stats: Partial - ): Promise>; - } - - export interface Purchase { - productID: string; - purchaseToken: string; - developerPayload?: string; - } - - export interface Product { - id: string; - title: string; - description: string; - imageURI: string; - /** - * @description String in format: "\ \" - */ - price: string; - priceValue: string; - priceCurrencyCode: string; - getPriceCurrencyImage(size: CurrencyImageSize): string; - } - - export interface Payments { - getPurchases(): Promise< - TSigned extends true ? Signed : Purchase[] - >; - getCatalog(): Promise; - purchase(opts?: { - id: string; - developerPayload?: string; - }): Promise : Purchase>; - consumePurchase(token: string): Promise; - } - - type FeedbackError = - | "NO_AUTH" - | "GAME_RATED" - | "REVIEW_ALREADY_REQUESTED" - | "UNKNOWN"; - - type StickyAdvError = "ADV_IS_NOT_CONNECTED" | "UNKNOWN"; - - type SdkEventName = "EXIT" | "HISTORY_BACK"; - - type CurrencyImageSize = "small" | "medium" | "svg"; - - export interface Leaderboards { - getLeaderboardDescription( - leaderboardName: string - ): Promise; - - setLeaderboardScore( - leaderboardName: string, - score: number, - extraData?: string - ): Promise; - - /** - * @throws {{code: string}} - */ - getLeaderboardPlayerEntry( - leaderboardName: string - ): Promise; - - getLeaderboardEntries( - leaderboardName: string, - opts?: { - includeUser?: boolean; - quantityAround?: number; - quantityTop?: number; - } - ): Promise; - } - - export interface LeaderboardEntriesData { - leaderboard: LeaderboardDescription; - ranges: { start: number; size: number }[]; - userRank: number; - entries: LeaderboardEntry[]; - } - - export interface LeaderboardEntry { - score: number; - extraData?: string; - rank: number; - player: { - getAvatarSrc(size: "small" | "medium" | "large"): string; - getAvatarSrcSet(size: "small" | "medium" | "large"): string; - lang: string; - publicName: string; - scopePermissions: { - avatar: string; - public_name: string; - }; - uniqueID: string; - }; - formattedScore: string; - } - - export interface LeaderboardDescription { - appID: string; - default: boolean; - description: { - invert_sort_order: boolean; - score_format: { - options: { - decimal_offset: number; - }; - }; - type: "numberic" | "time"; - }; - name: string; - title: { - [lang: string]: string; - }; - } - - /* prettier-ignore */ - export type ISO_639_1 = 'af' | 'am' | 'ar' | 'az' | 'be' | 'bg' | 'bn' | 'ca' | 'cs' | 'da' | 'de' | 'el' | 'en' | 'es' | 'et' | 'eu' | 'fa' | 'fi' | 'fr' | 'gl' | 'he' | 'hi' | 'hr' | 'hu' | 'hy' | 'id' | 'is' | 'it' | 'ja' | 'ka' | 'kk' | 'km' | 'kn' | 'ko' | 'ky' | 'lo' | 'lt' | 'lv' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'my' | 'ne' | 'nl' | 'no' | 'pl' | 'pt' | 'ro' | 'ru' | 'si' | 'sk' | 'sl' | 'sr' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'tk' | 'tl' | 'tr' | 'uk' | 'ur' | 'uz' | 'vi' | 'zh' | 'zu'; - - /* prettier-ignore */ - export type TopLevelDomain = 'az' | 'by' | 'co.il' | 'com' | 'com.am' | 'com.ge' | 'com.tr' | 'ee' | 'fr' | 'kg' | 'kz' | 'lt' | 'lv' | 'md' | 'ru' | 'tj' | 'tm' | 'ua' | 'uz'; - } -} diff --git a/scripts/bundle.js b/scripts/bundle.js index 7f3bb9e..107c4dc 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -5,7 +5,7 @@ const package = require("../package.json"); const config = { folders: ["@cc", "@types", "dist", "docs", "i18n", "static"], - modules: ["@babel", "i18next", "regenerator-runtime"], + modules: ["@babel", "i18next", "regenerator-runtime", "@types/ysdk"], files: [ "AUTHORS", "CHANGELOG.md", diff --git a/static/assets/ysdk.ts b/static/assets/ysdk.ts index 08dcd6e..2d5d586 100644 --- a/static/assets/ysdk.ts +++ b/static/assets/ysdk.ts @@ -1,9 +1,9 @@ -import { YandexGames } from "ysdk"; +import type { SDK } from "ysdk"; import { game, cclegacy } from "cc"; import { EDITOR } from "cc/env"; import { L10NManager } from "./core/l10n"; -export let ysdk = {} as YandexGames.SDK; +export let ysdk = {} as SDK; export const l10n = L10NManager.instance; diff --git a/static/package.json b/static/package.json index 1230df0..112ab3e 100644 --- a/static/package.json +++ b/static/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { + "@types/ysdk": "^1.0.5", "i18next": "^22.4.15" } } diff --git a/yarn.lock b/yarn.lock index 9956856..a4930fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -413,6 +413,11 @@ resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.4.tgz#e884a59338da907bda8d2ed03e01c5c49d036f1c" integrity sha512-zAuJWQflfx6dYJM62vna+Sn5aeSWhh3OB+wfUEACNcqUSc0AGc5JKl+ycL1vrH7frGTXhJchYjE1Hak8L819dA== +"@types/ysdk@^1.0.5": + version "1.0.5" + resolved "https://npm.lisgames.ru/@types/ysdk/-/ysdk-1.0.5.tgz#cd13fe66e96663dd0c30bbeb61d3513bdfbd99ff" + integrity sha512-zQgSxm4bXaT0LzNtB/goDRgBZbjVse0BYXFJOqvw8fgIxfbTP/sL1eJrgTF7t0QgMn/obgMwANnk/csZVchwpw== + "@vue/babel-helper-vue-transform-on@^1.1.5": version "1.1.5" resolved "https://registry.yarnpkg.com/@vue/babel-helper-vue-transform-on/-/babel-helper-vue-transform-on-1.1.5.tgz#a976486b21e108e545524fe41ffe3fc9bbc28c7f"