@maoyugames/phaser-framework 1.0.16 → 1.0.18

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.
@@ -1,4 +1,4 @@
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';
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-BceYZWGr.js';
2
2
 
3
3
  /**
4
4
  * 平台抽象基类:封装"有 DOM/BOM 的环境"通用实现,供
package/dist/cli/index.js CHANGED
@@ -318,7 +318,7 @@ function escapeAttr(s) {
318
318
  }
319
319
 
320
320
  // src/cli/shells/facebook.ts
321
- var DEFAULT_FB_SDK_VERSION = "7.1";
321
+ var DEFAULT_FB_SDK_VERSION = "8.0";
322
322
  function renderFacebookHtml(cfg, scriptSrc) {
323
323
  const title = escapeHtml(cfg?.appName ?? "Facebook Instant Game");
324
324
  const sdkVersion = (cfg?.fbSdkVersion ?? DEFAULT_FB_SDK_VERSION).trim();
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
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-BceYZWGr.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-BceYZWGr.js';
3
3
  import Phaser from 'phaser';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
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';
1
+ import { r as PlatformName, h as IPlatformDevice, i as IPlatformLifecycle } from '../types-BceYZWGr.js';
2
+ import { B as BasePlatform } from '../BasePlatform-Bod6yNYx.js';
3
3
 
4
4
  /**
5
5
  * Capacitor(原生 WebView 容器)平台适配器。
@@ -1,5 +1,5 @@
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';
1
+ import { r as PlatformName, o as IPlatformStorage, g as IPlatformAuth, e as IPlatformAds, l as IPlatformPayment, h as IPlatformDevice, m as IPlatformShortcut, i as IPlatformLifecycle } from '../types-BceYZWGr.js';
2
+ import { B as BasePlatform } from '../BasePlatform-Bod6yNYx.js';
3
3
 
4
4
  /**
5
5
  * Facebook Instant Games 平台适配器。
@@ -26,6 +26,7 @@ declare class FacebookPlatform extends BasePlatform {
26
26
  readonly ads: IPlatformAds;
27
27
  readonly payment: IPlatformPayment;
28
28
  readonly device: IPlatformDevice;
29
+ readonly shortcut: IPlatformShortcut;
29
30
  readonly lifecycle: IPlatformLifecycle;
30
31
  init(): Promise<void>;
31
32
  }
@@ -93,6 +93,11 @@ var FacebookAuth = class {
93
93
  if (!name && !photo) return null;
94
94
  return { nickname: name ?? "", avatarUrl: photo ?? "" };
95
95
  }
96
+ // FB 的 player 信息(getName/getPhoto)无需额外授权弹窗即可读(与 TikTok 需 explicit authorize
97
+ // 拿 user.info.basic 不同)。authorize 直接复用 login() 的结果返回,业务层「按需引导授权」逻辑通用。
98
+ authorize(_scope) {
99
+ return this.login();
100
+ }
96
101
  };
97
102
  var FacebookAds = class {
98
103
  constructor() {
@@ -144,6 +149,37 @@ var FacebookAds = class {
144
149
  }
145
150
  }
146
151
  };
152
+ var FacebookShortcut = class {
153
+ check() {
154
+ if (!hasFB() || typeof FBInstant.canCreateShortcutAsync !== "function") {
155
+ return Promise.resolve(false);
156
+ }
157
+ try {
158
+ return FBInstant.canCreateShortcutAsync().then(
159
+ (ok) => !!ok,
160
+ () => false
161
+ );
162
+ } catch {
163
+ return Promise.resolve(false);
164
+ }
165
+ }
166
+ add() {
167
+ if (!hasFB() || typeof FBInstant.createShortcutAsync !== "function") {
168
+ return Promise.resolve(false);
169
+ }
170
+ try {
171
+ return FBInstant.createShortcutAsync().then(
172
+ () => true,
173
+ () => false
174
+ );
175
+ } catch {
176
+ return Promise.resolve(false);
177
+ }
178
+ }
179
+ getMissionReward() {
180
+ return Promise.resolve({ canReceive: false });
181
+ }
182
+ };
147
183
  var FacebookPayment = class {
148
184
  async purchase(productId, extra) {
149
185
  requireFB("payment.purchase");
@@ -224,6 +260,9 @@ var FacebookPlatform = class extends BasePlatform {
224
260
  __publicField(this, "ads", new FacebookAds());
225
261
  __publicField(this, "payment", new FacebookPayment());
226
262
  __publicField(this, "device", new FacebookDevice());
263
+ __publicField(this, "shortcut", new FacebookShortcut());
264
+ // mission 不实现(FB 无"侧边栏入口任务"概念,TikTok 特有);保持 undefined,
265
+ // 业务层 App.platform.mission?.startEntrance() 会安全跳过。
227
266
  __publicField(this, "lifecycle", new FacebookLifecycle(
228
267
  () => this.getLaunchOptions()
229
268
  ));
@@ -1,5 +1,5 @@
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';
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-BceYZWGr.js';
2
+ import { B as BasePlatform } from '../BasePlatform-Bod6yNYx.js';
3
3
 
4
4
  /**
5
5
  * TikTok Mini Games(Minis)平台适配器。
@@ -57,6 +57,37 @@ var TikTokAuth = class {
57
57
  async getProfile() {
58
58
  return null;
59
59
  }
60
+ // 显式授权(game.authorize):弹 TikTok 授权页拿带 scope 的 code,后端换 token 后调 /v2/user/info/
61
+ // 取 nickname/avatar。callback 式,包成 Promise + 10s 超时(同 login,防永久 pending)。
62
+ authorize(scope = "user.info.basic") {
63
+ requireTT("auth.authorize");
64
+ return new Promise((resolve, reject) => {
65
+ let settled = false;
66
+ const timer = setTimeout(() => {
67
+ if (settled) return;
68
+ settled = true;
69
+ reject(new Error("TikTok authorize timeout"));
70
+ }, 1e4);
71
+ const finish = (fn) => {
72
+ if (settled) return;
73
+ settled = true;
74
+ clearTimeout(timer);
75
+ fn();
76
+ };
77
+ try {
78
+ TTMinis.game.authorize({
79
+ scope,
80
+ success: (res) => {
81
+ const code = res?.code ?? res?.authResponse?.code ?? "";
82
+ finish(() => code ? resolve({ code, raw: res }) : reject(new Error("authorize: no code")));
83
+ },
84
+ fail: (err) => finish(() => reject(new Error(`TikTok authorize fail: ${err?.errMsg ?? JSON.stringify(err)}`)))
85
+ });
86
+ } catch (e) {
87
+ finish(() => reject(e));
88
+ }
89
+ });
90
+ }
60
91
  };
61
92
  var TikTokAds = class {
62
93
  // TikTok H5 SDK 只有 createRewardedVideoAd(没有 preload/show/Interstitial 单独 API,
@@ -1,5 +1,5 @@
1
- import { r as PlatformName, h as IPlatformDevice } from '../types-WJYVtDfo.js';
2
- import { B as BasePlatform } from '../BasePlatform-CwVOo3_q.js';
1
+ import { r as PlatformName, h as IPlatformDevice } from '../types-BceYZWGr.js';
2
+ import { B as BasePlatform } from '../BasePlatform-Bod6yNYx.js';
3
3
 
4
4
  /**
5
5
  * Web(普通浏览器 / H5)平台适配器。
@@ -1,4 +1,4 @@
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';
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-BceYZWGr.js';
2
2
 
3
3
  /**
4
4
  * 微信小游戏平台适配器。
@@ -169,6 +169,11 @@ interface IPlatformAuth {
169
169
  nickname: string;
170
170
  avatarUrl: string;
171
171
  } | null>;
172
+ /**
173
+ * 显式授权(弹授权页),返回带额外 scope 的 code,后端换 token 后可拿 nickname/avatar。
174
+ * 平台不支持时为 undefined。用于「按需引导用户授权显示昵称」(如首次进排行榜)。
175
+ */
176
+ authorize?(scope?: string): Promise<LoginResult>;
172
177
  }
173
178
  /** 广告 */
174
179
  type AdResult = 'completed' | 'skipped' | 'failed' | 'closed';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maoyugames/phaser-framework",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "多平台 Phaser 游戏框架:业务/底层分离,HTTP/WebSocket/KCP,Web/TikTok/微信/Facebook/App 隔离打包",
5
5
  "type": "module",
6
6
  "license": "MIT",