@maoyugames/phaser-framework 1.0.11 → 1.0.16
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/dist/{BasePlatform-BCOkvvDW.d.ts → BasePlatform-CwVOo3_q.d.ts} +3 -1
- package/dist/{chunk-H5CUVYCN.js → chunk-PDESBWLX.js} +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/platform/capacitor.d.ts +2 -2
- package/dist/platform/capacitor.js +1 -1
- package/dist/platform/facebook.d.ts +2 -2
- package/dist/platform/facebook.js +1 -1
- package/dist/platform/tiktok.d.ts +4 -2
- package/dist/platform/tiktok.js +291 -54
- package/dist/platform/web.d.ts +2 -2
- package/dist/platform/web.js +1 -1
- package/dist/platform/wechat.d.ts +1 -1
- package/dist/{types-DtcRFbM0.d.ts → types-WJYVtDfo.d.ts} +29 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as IPlatform,
|
|
1
|
+
import { d as IPlatform, r as PlatformName, S as SafeArea, v as SystemInfo, L as LaunchOptions, k as IPlatformNet, o as IPlatformStorage, i as IPlatformLifecycle, g as IPlatformAuth, e as IPlatformAds, l as IPlatformPayment, h as IPlatformDevice, f as IPlatformAnalytics, m as IPlatformShortcut, j as IPlatformMission, P as PlatformInfo } from './types-WJYVtDfo.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 平台抽象基类:封装"有 DOM/BOM 的环境"通用实现,供
|
|
@@ -35,6 +35,8 @@ declare abstract class BasePlatform implements IPlatform {
|
|
|
35
35
|
readonly payment?: IPlatformPayment;
|
|
36
36
|
readonly device?: IPlatformDevice;
|
|
37
37
|
readonly analytics?: IPlatformAnalytics;
|
|
38
|
+
readonly shortcut?: IPlatformShortcut;
|
|
39
|
+
readonly mission?: IPlatformMission;
|
|
38
40
|
get info(): PlatformInfo;
|
|
39
41
|
abstract init(): Promise<void>;
|
|
40
42
|
getLaunchOptions(): LaunchOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as HttpRequestOptions, U as Unsubscribe, H as Handler,
|
|
2
|
-
export { a as HttpMethod, c as HttpResponse, I as IDisposable, e as IPlatformAds, f as IPlatformAnalytics, g as IPlatformAuth, h as IPlatformDevice, j as
|
|
1
|
+
import { b as HttpRequestOptions, U as Unsubscribe, H as Handler, p as LogLevel, A as AdResult, t as PurchaseResult, q as LoginResult, d as IPlatform, i as IPlatformLifecycle, S as SafeArea } from './types-WJYVtDfo.js';
|
|
2
|
+
export { a as HttpMethod, c as HttpResponse, I as IDisposable, e as IPlatformAds, f as IPlatformAnalytics, g as IPlatformAuth, h as IPlatformDevice, j as IPlatformMission, k as IPlatformNet, l as IPlatformPayment, m as IPlatformShortcut, n as IPlatformSocket, o as IPlatformStorage, L as LaunchOptions, P as PlatformInfo, r as PlatformName, s as PlatformUnsupportedError, R as Result, u as SocketOptions, v as SystemInfo, V as Vec2, w as err, x as ok } from './types-WJYVtDfo.js';
|
|
3
3
|
import Phaser from 'phaser';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BasePlatform } from '../BasePlatform-
|
|
1
|
+
import { r as PlatformName, h as IPlatformDevice, i as IPlatformLifecycle } from '../types-WJYVtDfo.js';
|
|
2
|
+
import { B as BasePlatform } from '../BasePlatform-CwVOo3_q.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Capacitor(原生 WebView 容器)平台适配器。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BasePlatform } from '../BasePlatform-
|
|
1
|
+
import { r as PlatformName, o as IPlatformStorage, g as IPlatformAuth, e as IPlatformAds, l as IPlatformPayment, h as IPlatformDevice, i as IPlatformLifecycle } from '../types-WJYVtDfo.js';
|
|
2
|
+
import { B as BasePlatform } from '../BasePlatform-CwVOo3_q.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Facebook Instant Games 平台适配器。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BasePlatform } from '../BasePlatform-
|
|
1
|
+
import { r as PlatformName, g as IPlatformAuth, e as IPlatformAds, l as IPlatformPayment, h as IPlatformDevice, f as IPlatformAnalytics, m as IPlatformShortcut, j as IPlatformMission, i as IPlatformLifecycle } from '../types-WJYVtDfo.js';
|
|
2
|
+
import { B as BasePlatform } from '../BasePlatform-CwVOo3_q.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* TikTok Mini Games(Minis)平台适配器。
|
|
@@ -23,6 +23,8 @@ declare class TikTokPlatform extends BasePlatform {
|
|
|
23
23
|
readonly payment: IPlatformPayment;
|
|
24
24
|
readonly device: IPlatformDevice;
|
|
25
25
|
readonly analytics: IPlatformAnalytics;
|
|
26
|
+
readonly shortcut: IPlatformShortcut;
|
|
27
|
+
readonly mission: IPlatformMission;
|
|
26
28
|
readonly lifecycle: IPlatformLifecycle;
|
|
27
29
|
init(): Promise<void>;
|
|
28
30
|
}
|
package/dist/platform/tiktok.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasePlatform } from '../chunk-
|
|
1
|
+
import { BasePlatform } from '../chunk-PDESBWLX.js';
|
|
2
2
|
import { PlatformUnsupportedError } from '../chunk-II3JM4R3.js';
|
|
3
3
|
import { __publicField } from '../chunk-PKBMQBKP.js';
|
|
4
4
|
|
|
@@ -10,74 +10,286 @@ function requireTT(capability) {
|
|
|
10
10
|
if (!hasTT()) throw new PlatformUnsupportedError("tiktok", capability);
|
|
11
11
|
}
|
|
12
12
|
var TikTokAuth = class {
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
13
|
+
// 登录用 game.login(静默登录,2026-05-29 核对 SDK + 官方接入指南 §2 确认):它是 SDK 的
|
|
14
|
+
// class method,返回 authResponse.code,后端用此 code 调 /v2/oauth/token/ 换 access_token+open_id。
|
|
15
|
+
// 早先误用 authorizeOpenContext 的 code(非标准 OAuth code),后端换 token 报 invalid_request:
|
|
16
|
+
// malformed,导致登录全废 → 一切需鉴权功能(购买/排行榜/同步)401。已纠正为 game.login。
|
|
17
|
+
// game.login 是 callback 式({success,fail,complete}),这里包成 Promise。
|
|
18
|
+
login() {
|
|
18
19
|
requireTT("auth.login");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
let settled = false;
|
|
22
|
+
const timer = setTimeout(() => {
|
|
23
|
+
if (settled) return;
|
|
24
|
+
settled = true;
|
|
25
|
+
reject(new Error("TikTok login timeout (no callback in 10s)"));
|
|
26
|
+
}, 1e4);
|
|
27
|
+
const finish = (fn) => {
|
|
28
|
+
if (settled) return;
|
|
29
|
+
settled = true;
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
fn();
|
|
32
|
+
};
|
|
33
|
+
const onResult = (res) => {
|
|
34
|
+
const code = res?.code ?? res?.authResponse?.code ?? "";
|
|
35
|
+
finish(
|
|
36
|
+
() => code ? resolve({ code, raw: res }) : reject(new Error(`TikTok login failed: ${JSON.stringify(res?.error ?? res ?? "no code")}`))
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
TTMinis.game.login({
|
|
41
|
+
success: onResult,
|
|
42
|
+
fail: (err) => finish(() => reject(new Error(`TikTok login fail: ${err?.errMsg ?? JSON.stringify(err)}`)))
|
|
43
|
+
});
|
|
44
|
+
} catch (e) {
|
|
45
|
+
try {
|
|
46
|
+
TTMinis.game.login(
|
|
47
|
+
(r) => onResult(r)
|
|
48
|
+
);
|
|
49
|
+
} catch {
|
|
50
|
+
finish(() => reject(e));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
28
54
|
}
|
|
29
|
-
// TikTok H5 SDK 没有客户端 user info API。nickname/avatar
|
|
30
|
-
// /v2/user/info/ 取(
|
|
55
|
+
// TikTok H5 SDK 没有客户端 user info API。nickname/avatar 由后端用 access_token 调
|
|
56
|
+
// /v2/user/info/ 取(需 explicit authorize 的 user.info.basic scope),客户端拿到的 user 已含。
|
|
31
57
|
async getProfile() {
|
|
32
58
|
return null;
|
|
33
59
|
}
|
|
34
60
|
};
|
|
35
61
|
var TikTokAds = class {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
62
|
+
// TikTok H5 SDK 只有 createRewardedVideoAd(没有 preload/show/Interstitial 单独 API,
|
|
63
|
+
// 实测 2026-05-28 反编译 connect.tiktok-minis.com/game/sdk.js 36 个 game.* 方法确认)。
|
|
64
|
+
// 之前 framework 调 preloadRewardedVideo / showRewardedVideo / showInterstitialAd 全部
|
|
65
|
+
// throw TypeError,被 try-catch 吞掉返 'failed',审核因此判"未集成有效营收功能"。
|
|
66
|
+
//
|
|
67
|
+
// 修复:统一走 createRewardedVideoAd(优先同步签名拿 ad 实例,失败试异步 callback 签名),
|
|
68
|
+
// ad.onClose 等结果后 ad.show 触发展示;preloadRewarded 退化为 noop(SDK 自身管预加载)。
|
|
69
|
+
async preloadRewarded(_adUnitId) {
|
|
39
70
|
}
|
|
40
|
-
|
|
71
|
+
showRewarded(adUnitId) {
|
|
41
72
|
requireTT("ads.showRewarded");
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
const onResult = (isEnded) => resolve(isEnded ? "completed" : "skipped");
|
|
75
|
+
const onError = (msg) => {
|
|
76
|
+
console.warn("[ads.showRewarded] error:", msg);
|
|
77
|
+
resolve("failed");
|
|
78
|
+
};
|
|
79
|
+
try {
|
|
80
|
+
const adSync = TTMinis.game.createRewardedVideoAd({ adUnitId });
|
|
81
|
+
if (adSync && typeof adSync.show === "function") {
|
|
82
|
+
this.wireAd(adSync, onResult, onError);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.warn("[ads] sync createRewardedVideoAd failed, try async:", e?.message);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
TTMinis.game.createRewardedVideoAd((res) => {
|
|
90
|
+
if (res?.is_success && res.rewardedVideoAd) {
|
|
91
|
+
this.wireAd(res.rewardedVideoAd, onResult, onError);
|
|
92
|
+
} else {
|
|
93
|
+
onError(JSON.stringify(res?.error ?? "create failed"));
|
|
94
|
+
}
|
|
95
|
+
}, { adUnitId });
|
|
96
|
+
} catch (e) {
|
|
97
|
+
onError(e?.message ?? "createRewardedVideoAd both signatures failed");
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
wireAd(ad, onResult, onError) {
|
|
102
|
+
let settled = false;
|
|
42
103
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
104
|
+
ad.onClose((res) => {
|
|
105
|
+
if (settled) return;
|
|
106
|
+
settled = true;
|
|
107
|
+
onResult(!!res?.isEnded);
|
|
108
|
+
});
|
|
109
|
+
} catch (e) {
|
|
110
|
+
onError(`onClose unsupported: ${e?.message}`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (typeof ad.onError === "function") {
|
|
114
|
+
try {
|
|
115
|
+
ad.onError((res) => {
|
|
116
|
+
if (settled) return;
|
|
117
|
+
settled = true;
|
|
118
|
+
onError(res?.error?.error_msg ?? "ad error");
|
|
119
|
+
});
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
47
122
|
}
|
|
123
|
+
void ad.show().catch((e) => {
|
|
124
|
+
if (settled) return;
|
|
125
|
+
settled = true;
|
|
126
|
+
onError(e?.message ?? "show rejected");
|
|
127
|
+
});
|
|
48
128
|
}
|
|
49
|
-
|
|
129
|
+
// 插页广告:官方文档 createInterstitialAd 自 SDK 0.3.0;当前反编译版 sdk.js 未见此 API,
|
|
130
|
+
// 真机 SDK 版本可能更高。typeof 检测:SDK 有就用(create → onClose/onError → show),没有降级 failed。
|
|
131
|
+
showInterstitial(adUnitId) {
|
|
50
132
|
requireTT("ads.showInterstitial");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
133
|
+
const create = TTMinis.game.createInterstitialAd;
|
|
134
|
+
if (typeof create !== "function") return Promise.resolve("failed");
|
|
135
|
+
return new Promise((resolve) => {
|
|
136
|
+
let settled = false;
|
|
137
|
+
const done = (r) => {
|
|
138
|
+
if (!settled) {
|
|
139
|
+
settled = true;
|
|
140
|
+
resolve(r);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
try {
|
|
144
|
+
const ad = create.call(TTMinis.game, { adUnitId });
|
|
145
|
+
if (!ad || typeof ad.show !== "function") {
|
|
146
|
+
done("failed");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
ad.onClose(() => done("closed"));
|
|
151
|
+
} catch {
|
|
152
|
+
}
|
|
153
|
+
if (typeof ad.onError === "function") {
|
|
154
|
+
try {
|
|
155
|
+
ad.onError((res) => {
|
|
156
|
+
console.warn("[ads.showInterstitial] error:", res?.error?.error_msg);
|
|
157
|
+
done("failed");
|
|
158
|
+
});
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
void ad.show().catch((e) => {
|
|
163
|
+
console.warn("[ads.showInterstitial] show rejected:", e?.message);
|
|
164
|
+
done("failed");
|
|
165
|
+
});
|
|
166
|
+
} catch (e) {
|
|
167
|
+
console.warn("[ads.showInterstitial] create threw:", e?.message);
|
|
168
|
+
done("failed");
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var TikTokShortcut = class {
|
|
174
|
+
// SDK callback-style API;每个都用 typeof 检测 + 静默降级,避免老 SDK 没此方法 throw 阻断业务。
|
|
175
|
+
check() {
|
|
176
|
+
if (!hasTT() || typeof TTMinis.game.checkShortcut !== "function") return Promise.resolve(false);
|
|
177
|
+
return new Promise((resolve) => {
|
|
178
|
+
try {
|
|
179
|
+
TTMinis.game.checkShortcut({
|
|
180
|
+
success: (res) => resolve(!!res?.exist),
|
|
181
|
+
fail: () => resolve(false)
|
|
182
|
+
});
|
|
183
|
+
} catch {
|
|
184
|
+
resolve(false);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
add() {
|
|
189
|
+
if (!hasTT() || typeof TTMinis.game.addShortcut !== "function") return Promise.resolve(false);
|
|
190
|
+
return new Promise((resolve) => {
|
|
191
|
+
try {
|
|
192
|
+
TTMinis.game.addShortcut({
|
|
193
|
+
success: () => resolve(true),
|
|
194
|
+
fail: () => resolve(false)
|
|
195
|
+
});
|
|
196
|
+
} catch {
|
|
197
|
+
resolve(false);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
getMissionReward() {
|
|
202
|
+
if (!hasTT() || typeof TTMinis.game.getShortcutMissionReward !== "function") {
|
|
203
|
+
return Promise.resolve({ canReceive: false });
|
|
56
204
|
}
|
|
205
|
+
return new Promise((resolve) => {
|
|
206
|
+
try {
|
|
207
|
+
TTMinis.game.getShortcutMissionReward({
|
|
208
|
+
success: (res) => resolve({ canReceive: !!res?.canReceiveReward }),
|
|
209
|
+
fail: () => resolve({ canReceive: false })
|
|
210
|
+
});
|
|
211
|
+
} catch {
|
|
212
|
+
resolve({ canReceive: false });
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var TikTokMission = class {
|
|
218
|
+
startEntrance() {
|
|
219
|
+
if (!hasTT() || typeof TTMinis.game.startEntranceMission !== "function") return Promise.resolve({ ok: false });
|
|
220
|
+
return new Promise((resolve) => {
|
|
221
|
+
try {
|
|
222
|
+
TTMinis.game.startEntranceMission({
|
|
223
|
+
success: () => resolve({ ok: true }),
|
|
224
|
+
fail: () => resolve({ ok: false })
|
|
225
|
+
});
|
|
226
|
+
} catch {
|
|
227
|
+
resolve({ ok: false });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
getEntranceReward() {
|
|
232
|
+
if (!hasTT() || typeof TTMinis.game.getEntranceMissionReward !== "function") return Promise.resolve({ canReceive: false });
|
|
233
|
+
return new Promise((resolve) => {
|
|
234
|
+
try {
|
|
235
|
+
TTMinis.game.getEntranceMissionReward({
|
|
236
|
+
success: (res) => resolve({ canReceive: !!res?.canReceiveReward }),
|
|
237
|
+
fail: () => resolve({ canReceive: false })
|
|
238
|
+
});
|
|
239
|
+
} catch {
|
|
240
|
+
resolve({ canReceive: false });
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
getFyfReward() {
|
|
245
|
+
if (!hasTT() || typeof TTMinis.game.getFyfMissionReward !== "function") return Promise.resolve({ canReceive: false });
|
|
246
|
+
return new Promise((resolve) => {
|
|
247
|
+
try {
|
|
248
|
+
TTMinis.game.getFyfMissionReward({
|
|
249
|
+
success: (res) => resolve({ canReceive: !!res?.canReceiveReward }),
|
|
250
|
+
fail: () => resolve({ canReceive: false })
|
|
251
|
+
});
|
|
252
|
+
} catch {
|
|
253
|
+
resolve({ canReceive: false });
|
|
254
|
+
}
|
|
255
|
+
});
|
|
57
256
|
}
|
|
58
257
|
};
|
|
59
258
|
var TikTokPayment = class {
|
|
60
|
-
|
|
259
|
+
// TikTok IAP(2026-05-29 飞书接入指南):后端预下单拿 trade_order_id,前端 game.pay 拉起收银台。
|
|
260
|
+
// purchase 的 productId 参数在 TikTok 下被用作 trade_order_id(业务后端已下单);也兼容从
|
|
261
|
+
// extra.orderId / extra.tradeOrderId 取(ShopModule 传的是 {orderId: trade_order_id})。
|
|
262
|
+
// resolve 仅表示「客户端支付面板流程结束」,真正发货由 webhook + 业务层轮询后端订单状态确认。
|
|
263
|
+
purchase(productId, extra) {
|
|
61
264
|
requireTT("payment.purchase");
|
|
62
|
-
const
|
|
63
|
-
return {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
265
|
+
const tradeOrderId = extra?.orderId ?? extra?.tradeOrderId ?? productId;
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
let settled = false;
|
|
268
|
+
try {
|
|
269
|
+
TTMinis.game.pay({
|
|
270
|
+
trade_order_id: tradeOrderId,
|
|
271
|
+
success: () => {
|
|
272
|
+
if (settled) return;
|
|
273
|
+
settled = true;
|
|
274
|
+
resolve({ productId, transactionId: tradeOrderId, receipt: tradeOrderId, raw: { trade_order_id: tradeOrderId } });
|
|
275
|
+
},
|
|
276
|
+
fail: (err) => {
|
|
277
|
+
if (settled) return;
|
|
278
|
+
settled = true;
|
|
279
|
+
reject(new Error(`TikTok pay failed: ${err?.errMsg ?? "unknown"}`));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
} catch (e) {
|
|
283
|
+
if (!settled) {
|
|
284
|
+
settled = true;
|
|
285
|
+
reject(e);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
69
289
|
}
|
|
290
|
+
// TikTok H5 SDK 未确认 getUnfinishedPurchases;掉单恢复靠后端订单状态查询 + webhook,这里返空。
|
|
70
291
|
async restore() {
|
|
71
|
-
|
|
72
|
-
const fn = TTMinis.game.getUnfinishedPurchases;
|
|
73
|
-
if (!fn) return [];
|
|
74
|
-
const list = await fn.call(TTMinis.game) ?? [];
|
|
75
|
-
return list.map((res) => ({
|
|
76
|
-
productId: res.productId,
|
|
77
|
-
transactionId: res.transactionId ?? "",
|
|
78
|
-
receipt: res.receipt ?? "",
|
|
79
|
-
raw: res
|
|
80
|
-
}));
|
|
292
|
+
return [];
|
|
81
293
|
}
|
|
82
294
|
};
|
|
83
295
|
var TikTokDevice = class {
|
|
@@ -108,12 +320,35 @@ var TikTokDevice = class {
|
|
|
108
320
|
const res = await TTMinis.game.getClipboardData();
|
|
109
321
|
return res?.data ?? "";
|
|
110
322
|
}
|
|
111
|
-
|
|
323
|
+
// shareAppMessage 是 callback 式(2026-05-30 反编译核对),不是 Promise;这里包成 Promise。
|
|
324
|
+
share(payload) {
|
|
112
325
|
requireTT("device.share");
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
326
|
+
return new Promise((resolve, reject) => {
|
|
327
|
+
let settled = false;
|
|
328
|
+
try {
|
|
329
|
+
TTMinis.game.shareAppMessage({
|
|
330
|
+
title: payload.title,
|
|
331
|
+
imageUrl: payload.imageUrl,
|
|
332
|
+
query: payload.query,
|
|
333
|
+
success: () => {
|
|
334
|
+
if (!settled) {
|
|
335
|
+
settled = true;
|
|
336
|
+
resolve();
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
fail: (err) => {
|
|
340
|
+
if (!settled) {
|
|
341
|
+
settled = true;
|
|
342
|
+
reject(new Error(`share failed: ${err?.errMsg ?? "unknown"}`));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
} catch (e) {
|
|
347
|
+
if (!settled) {
|
|
348
|
+
settled = true;
|
|
349
|
+
reject(e);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
117
352
|
});
|
|
118
353
|
}
|
|
119
354
|
};
|
|
@@ -151,6 +386,8 @@ var TikTokPlatform = class extends BasePlatform {
|
|
|
151
386
|
__publicField(this, "payment", new TikTokPayment());
|
|
152
387
|
__publicField(this, "device", new TikTokDevice());
|
|
153
388
|
__publicField(this, "analytics", new TikTokAnalytics());
|
|
389
|
+
__publicField(this, "shortcut", new TikTokShortcut());
|
|
390
|
+
__publicField(this, "mission", new TikTokMission());
|
|
154
391
|
// 用 TTMinis 桥接的生命周期,缺失时由其内部退回 noop;DOM 退路在 init 中按需补
|
|
155
392
|
__publicField(this, "lifecycle", new TikTokLifecycle());
|
|
156
393
|
}
|
package/dist/platform/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BasePlatform } from '../BasePlatform-
|
|
1
|
+
import { r as PlatformName, h as IPlatformDevice } from '../types-WJYVtDfo.js';
|
|
2
|
+
import { B as BasePlatform } from '../BasePlatform-CwVOo3_q.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Web(普通浏览器 / H5)平台适配器。
|
package/dist/platform/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as IPlatform,
|
|
1
|
+
import { d as IPlatform, k as IPlatformNet, o as IPlatformStorage, i as IPlatformLifecycle, g as IPlatformAuth, e as IPlatformAds, l as IPlatformPayment, h as IPlatformDevice, P as PlatformInfo, L as LaunchOptions } from '../types-WJYVtDfo.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 微信小游戏平台适配器。
|
|
@@ -207,6 +207,32 @@ interface IPlatformDevice {
|
|
|
207
207
|
query?: string;
|
|
208
208
|
}): Promise<void>;
|
|
209
209
|
}
|
|
210
|
+
/** 桌面快捷方式(TikTok minigame 审核硬性要求;不支持的平台为 undefined) */
|
|
211
|
+
interface IPlatformShortcut {
|
|
212
|
+
/** 是否已添加到桌面(平台不支持时 resolve false) */
|
|
213
|
+
check(): Promise<boolean>;
|
|
214
|
+
/** 触发平台原生"添加到桌面"系统提示,resolve 表示添加成功 */
|
|
215
|
+
add(): Promise<boolean>;
|
|
216
|
+
/** 查询"添加桌面快捷方式"任务奖励状态(可领取且未领取返 true) */
|
|
217
|
+
getMissionReward?(): Promise<{
|
|
218
|
+
canReceive: boolean;
|
|
219
|
+
}>;
|
|
220
|
+
}
|
|
221
|
+
/** 任务系统(TikTok minigame 审核硬性要求 - 侧边栏入口任务) */
|
|
222
|
+
interface IPlatformMission {
|
|
223
|
+
/** 触发侧边栏入口任务(SDK 把用户带到 TikTok profile sidebar 完成教育流程) */
|
|
224
|
+
startEntrance(): Promise<{
|
|
225
|
+
ok: boolean;
|
|
226
|
+
}>;
|
|
227
|
+
/** 查询入口任务奖励状态 */
|
|
228
|
+
getEntranceReward(): Promise<{
|
|
229
|
+
canReceive: boolean;
|
|
230
|
+
}>;
|
|
231
|
+
/** 查询"For You Feed 入口"任务奖励状态(若启用) */
|
|
232
|
+
getFyfReward?(): Promise<{
|
|
233
|
+
canReceive: boolean;
|
|
234
|
+
}>;
|
|
235
|
+
}
|
|
210
236
|
/** 平台原生埋点(可选;通常业务用 AnalyticsManager 统一上报) */
|
|
211
237
|
interface IPlatformAnalytics {
|
|
212
238
|
reportEvent(name: string, params?: Record<string, unknown>): void;
|
|
@@ -234,6 +260,8 @@ interface IPlatform {
|
|
|
234
260
|
readonly payment?: IPlatformPayment;
|
|
235
261
|
readonly device?: IPlatformDevice;
|
|
236
262
|
readonly analytics?: IPlatformAnalytics;
|
|
263
|
+
readonly shortcut?: IPlatformShortcut;
|
|
264
|
+
readonly mission?: IPlatformMission;
|
|
237
265
|
}
|
|
238
266
|
|
|
239
|
-
export { type AdResult as A, type Handler as H, type IDisposable as I, type LaunchOptions as L, type PlatformInfo as P, type Result as R, type SafeArea as S, type Unsubscribe as U, type Vec2 as V, type HttpMethod as a, type HttpRequestOptions as b, type HttpResponse as c, type IPlatform as d, type IPlatformAds as e, type IPlatformAnalytics as f, type IPlatformAuth as g, type IPlatformDevice as h, type IPlatformLifecycle as i, type
|
|
267
|
+
export { type AdResult as A, type Handler as H, type IDisposable as I, type LaunchOptions as L, type PlatformInfo as P, type Result as R, type SafeArea as S, type Unsubscribe as U, type Vec2 as V, type HttpMethod as a, type HttpRequestOptions as b, type HttpResponse as c, type IPlatform as d, type IPlatformAds as e, type IPlatformAnalytics as f, type IPlatformAuth as g, type IPlatformDevice as h, type IPlatformLifecycle as i, type IPlatformMission as j, type IPlatformNet as k, type IPlatformPayment as l, type IPlatformShortcut as m, type IPlatformSocket as n, type IPlatformStorage as o, LogLevel as p, type LoginResult as q, type PlatformName as r, PlatformUnsupportedError as s, type PurchaseResult as t, type SocketOptions as u, type SystemInfo as v, err as w, ok as x };
|