@apps-in-toss/devtools 3.0.5 → 3.1.0-beta.1

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/mock/2x.d.ts CHANGED
@@ -131,6 +131,39 @@ declare const showFullScreenAd: ((args: {
131
131
  }) => () => void) & {
132
132
  isSupported: () => boolean;
133
133
  };
134
+ declare const Ads: {
135
+ showTossAdOrShoppingAds: ((args: {
136
+ options: {
137
+ spaceUnitId: string;
138
+ adSpaceId: string;
139
+ };
140
+ onEvent: (event: {
141
+ type: string;
142
+ data?: {
143
+ unitType: string;
144
+ unitAmount: number;
145
+ };
146
+ }) => void;
147
+ onError: (error: unknown) => void;
148
+ }) => () => void) & {
149
+ isSupported: () => boolean;
150
+ };
151
+ showTossShoppingAds: ((args: {
152
+ options: {
153
+ adSpaceId: string;
154
+ };
155
+ onEvent: (event: {
156
+ type: string;
157
+ data?: {
158
+ unitType: string;
159
+ unitAmount: number;
160
+ };
161
+ }) => void;
162
+ onError: (error: unknown) => void;
163
+ }) => () => void) & {
164
+ isSupported: () => boolean;
165
+ };
166
+ };
134
167
  //#endregion
135
168
  //#region src/mock/analytics/index.d.ts
136
169
  /**
@@ -776,8 +809,8 @@ interface AddAccessoryButtonOptions {
776
809
  };
777
810
  }
778
811
  declare const partner: {
779
- addAccessoryButton: (options: AddAccessoryButtonOptions) => Promise<void>;
780
- removeAccessoryButton: () => Promise<void>;
812
+ addAccessoryButton(options: AddAccessoryButtonOptions): Promise<void>;
813
+ removeAccessoryButton(): Promise<void>;
781
814
  };
782
815
  //#endregion
783
816
  //#region src/mock/permissions.d.ts
@@ -1153,4 +1186,123 @@ declare function listUserPresets(): MockPreset[];
1153
1186
  declare function saveUserPreset(label: string, state: MockPresetState, description?: string): MockPreset;
1154
1187
  declare function deleteUserPreset(id: string): void;
1155
1188
  //#endregion
1156
- export { Accuracy, type AitDevtoolsState, Analytics, type AnalyticsLogEntry, type ConsentedUserData, type ConsentedUserDataKey, type DeclaredAgeRange, type DeviceApiMode, type DeviceModes, FetchAlbumPhotosPermissionError, FetchContactsPermissionError, GetClipboardTextPermissionError, GetCurrentLocationPermissionError, GoogleAdMob, type HapticFeedbackType, IAP, type IapNextResult, type LocationCoords, type MockContact, type MockData, type MockIapProduct, type MockLocation, type MockPreset, type MockPresetState, type NetworkStatus, OpenCameraPermissionError, type OperationalEnvironment, PermissionError, type PermissionName, type PermissionStatus, type PlatformOS, type Primitive, SafeAreaInsets, type SafeAreaInsets$1 as SafeAreaInsetsType, SetClipboardTextPermissionError, StartUpdateLocationPermissionError, Storage, TossAds, aitState, appLogin, applyPreset, appsInTossEvent, appsInTossSignTossCert, builtInPresets, captureCurrentState, checkoutPayment, closeView, contactsViral, createAsyncBridge, createConstantBridge, createEventBridge, deleteUserPreset, env, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getAppsInTossGlobals, getClipboardText, getConsentedUserData, getCurrentLocation, getDeclaredAgeRange, getDefaultPlaceholderImages, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPermission, getPlatformOS, getSafeAreaInsets, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, graniteEvent, grantPromotionReward, grantPromotionRewardForGame, isMinVersionSupported, listUserPresets, loadFullScreenAd, matchesPreset, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openPermissionDialog, openURL, partner, requestNotificationAgreement, requestPermission, requestReview, requestTossPayPaysBilling, saveBase64Data, saveUserPreset, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, showFullScreenAd, startUpdateLocation, submitGameCenterLeaderBoardScore, tdsEvent };
1189
+ //#region src/mock/safe-area-bridge.d.ts
1190
+ /** The postMessage envelope the launcher posts to the framed dev app (inset forward). */
1191
+ declare const SAFE_AREA_INSETS_MESSAGE_TYPE: "ait:safe-area-insets";
1192
+ /**
1193
+ * The postMessage command the launcher partner bar's `←` button sends to the
1194
+ * framed dev app (#510). The framed page calls `history.back()` in response.
1195
+ *
1196
+ * Protocol: only `{ type: 'ait:navigate-back' }` is valid. No other fields are
1197
+ * read or acted on — extra fields are silently ignored by the shape guard.
1198
+ * Game variant never sends this message (back button is partner-bar-only).
1199
+ */
1200
+ declare const NAVIGATE_BACK_MESSAGE_TYPE: "ait:navigate-back";
1201
+ /**
1202
+ * The postMessage envelope the framed mini-app self-reports its webViewType
1203
+ * with (#580). The mini-app knows its own type from the build constant
1204
+ * `__WEB_VIEW_TYPE__` (`granite.config.ts`'s `webViewProps.type`, injected by
1205
+ * the devtools unplugin). The launcher is cross-origin so it cannot read that
1206
+ * constant directly — the mini-app posts it to `window.parent` once so the
1207
+ * launcher (env-2 PWA shell) switches to game mode automatically, with no
1208
+ * manual `?navBarType=game` URL edit.
1209
+ *
1210
+ * Direction: this is the SEND side's contract (posted from inside the iframe by
1211
+ * `@ait-co/debug-console`'s `packages/debug-console/src/attach.ts`). The
1212
+ * launcher's receive half lives in
1213
+ * `e2e/fixture/launcher/Launcher.tsx` and mirrors the same value enum inline,
1214
+ * staying decoupled from the mock package internals — the same pattern the
1215
+ * other launcher message types follow.
1216
+ *
1217
+ * Value enum: only `'partner'` and `'game'` are valid. The SDK's deprecated
1218
+ * `'external'` alias of `partner` (web-framework 2.6.1) is mapped to `'partner'`
1219
+ * at the send site so the wire only ever carries the two shapes the launcher
1220
+ * emulates.
1221
+ */
1222
+ declare const WEB_VIEW_TYPE_MESSAGE_TYPE: "ait:web-view-type";
1223
+ /** The two webViewType shapes the launcher can emulate (#580). */
1224
+ type WebViewTypeValue = "partner" | "game";
1225
+ /**
1226
+ * Parse + validate a raw postMessage payload into a `SafeAreaInsets`, or return
1227
+ * null when it is not a well-formed `ait:safe-area-insets` message. Pure — unit
1228
+ * tested without a real MessageEvent.
1229
+ */
1230
+ declare function parseSafeAreaInsetsMessage(data: unknown): SafeAreaInsets$1 | null;
1231
+ /**
1232
+ * Parse + validate a raw postMessage payload into a webViewType value
1233
+ * (`'partner'` | `'game'`), or return `null` when it is not a well-formed
1234
+ * `ait:web-view-type` message (#580). Pure — unit tested without a real
1235
+ * MessageEvent.
1236
+ *
1237
+ * Strict shape guard (the safety boundary for the cross-origin receive path):
1238
+ * the payload must be a non-null object whose `type` is exactly
1239
+ * {@link WEB_VIEW_TYPE_MESSAGE_TYPE} and whose `value` is exactly `'partner'`
1240
+ * or `'game'` (an enum allow-list). Anything else — a foreign type, a missing
1241
+ * or non-string value, the deprecated `'external'` alias, or any other string —
1242
+ * returns `null` so a stray postMessage can never flip the launcher's visual
1243
+ * mode. The send site is responsible for collapsing `'external'` → `'partner'`
1244
+ * before posting; the parser does NOT silently accept it.
1245
+ */
1246
+ declare function parseWebViewTypeMessage(data: unknown): WebViewTypeValue | null;
1247
+ /**
1248
+ * Apply forwarded insets to the mock state. Skips the write (and the resulting
1249
+ * subscribe notify) when nothing changed, so repeated identical messages from a
1250
+ * resize storm don't churn subscribers.
1251
+ */
1252
+ declare function applyForwardedSafeAreaInsets(insets: SafeAreaInsets$1): void;
1253
+ /**
1254
+ * Install the window `message` listener that receives forwarded insets. Safe to
1255
+ * call multiple times (idempotent) and a no-op outside a browser (SSR/jsdom
1256
+ * without a window). Imported for its side effect by the mock barrel so any
1257
+ * consumer that aliases `@apps-in-toss/web-framework` to the mock gets it wired.
1258
+ *
1259
+ * On each valid `ait:safe-area-insets` message:
1260
+ * 1. Writes the corrected insets into the mock `SafeAreaInsets` state
1261
+ * (existing #484 behaviour — for apps that still read SDK insets).
1262
+ * 2. Drives the env-2 dead-band compensation style via
1263
+ * {@link applyEnv2Compensation} — injects a `body { margin-top: calc(-1 *
1264
+ * env(safe-area-inset-top)) }` style when `top === 0` (partner mode) and
1265
+ * removes it when `top > 0` (game / full-bleed mode).
1266
+ */
1267
+ declare function installSafeAreaInsetsBridge(): void;
1268
+ /**
1269
+ * Parse a raw postMessage payload as an `ait:navigate-back` command.
1270
+ *
1271
+ * Returns true when the payload is a well-formed navigate-back command
1272
+ * (`{ type: 'ait:navigate-back' }`), false otherwise. Pure — unit tested
1273
+ * without a real MessageEvent.
1274
+ *
1275
+ * Shape guard: only the `type` field is inspected; any extra fields are
1276
+ * ignored so future extensions do not break older receivers. The function
1277
+ * does NOT read any data field beyond `type` — no sensitive values, no host
1278
+ * disclosure (same principle as the insets bridge).
1279
+ */
1280
+ declare function isNavigateBackMessage(data: unknown): boolean;
1281
+ /**
1282
+ * Install the window `message` listener that handles `ait:navigate-back`
1283
+ * commands (#510). When the launcher partner bar's `←` button is clicked it
1284
+ * posts `{ type: 'ait:navigate-back' }` to the framed dev app; this listener
1285
+ * calls `dispatchHostBackNavigation()` from the navigation module.
1286
+ *
1287
+ * Dispatch semantics: if there are any `graniteEvent.addEventListener('backEvent', …)`
1288
+ * subscribers the CustomEvent `__ait:backEvent` is fired (same path as the env-1
1289
+ * panel back button — the mini-app intercept channel). When there are no
1290
+ * subscribers `history.back()` is called as the fallback. Back semantics are
1291
+ * owned entirely by the navigation module; this bridge only delegates.
1292
+ *
1293
+ * Safe to call multiple times (idempotent) and a no-op outside a browser.
1294
+ * Installed together with the inset bridge by `installBridges()` so any consumer
1295
+ * of the mock barrel gets both wired automatically.
1296
+ *
1297
+ * No-op on apps that predate this bridge — the launcher posts the message but
1298
+ * older mocks simply have no listener (harmless).
1299
+ */
1300
+ declare function installNavigateBackBridge(): void;
1301
+ /**
1302
+ * Install both env-2 postMessage bridges in one call (#484 insets + #510
1303
+ * navigate-back). The mock barrel calls this at import time so consumers get
1304
+ * all bridges wired without any explicit setup.
1305
+ */
1306
+ declare function installBridges(): void;
1307
+ //#endregion
1308
+ export { Accuracy, Ads, type AitDevtoolsState, Analytics, type AnalyticsLogEntry, type ConsentedUserData, type ConsentedUserDataKey, type DeclaredAgeRange, type DeviceApiMode, type DeviceModes, FetchAlbumPhotosPermissionError, FetchContactsPermissionError, GetClipboardTextPermissionError, GetCurrentLocationPermissionError, GoogleAdMob, type HapticFeedbackType, IAP, type IapNextResult, type LocationCoords, type MockContact, type MockData, type MockIapProduct, type MockLocation, type MockPreset, type MockPresetState, NAVIGATE_BACK_MESSAGE_TYPE, type NetworkStatus, OpenCameraPermissionError, type OperationalEnvironment, PermissionError, type PermissionName, type PermissionStatus, type PlatformOS, type Primitive, SAFE_AREA_INSETS_MESSAGE_TYPE, SafeAreaInsets, type SafeAreaInsets$1 as SafeAreaInsetsType, SetClipboardTextPermissionError, StartUpdateLocationPermissionError, Storage, TossAds, WEB_VIEW_TYPE_MESSAGE_TYPE, type WebViewTypeValue, aitState, appLogin, applyForwardedSafeAreaInsets, applyPreset, appsInTossEvent, appsInTossSignTossCert, builtInPresets, captureCurrentState, checkoutPayment, closeView, contactsViral, createAsyncBridge, createConstantBridge, createEventBridge, deleteUserPreset, env, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getAppsInTossGlobals, getClipboardText, getConsentedUserData, getCurrentLocation, getDeclaredAgeRange, getDefaultPlaceholderImages, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPermission, getPlatformOS, getSafeAreaInsets, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, graniteEvent, grantPromotionReward, grantPromotionRewardForGame, installBridges, installNavigateBackBridge, installSafeAreaInsetsBridge, isMinVersionSupported, isNavigateBackMessage, listUserPresets, loadFullScreenAd, matchesPreset, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openPermissionDialog, openURL, parseSafeAreaInsetsMessage, parseWebViewTypeMessage, partner, requestNotificationAgreement, requestPermission, requestReview, requestTossPayPaysBilling, saveBase64Data, saveUserPreset, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, showFullScreenAd, startUpdateLocation, submitGameCenterLeaderBoardScore, tdsEvent };