@ait-co/devtools 0.0.1 → 0.0.2
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 +430 -134
- package/dist/chunk-6PPZTREF.js +569 -0
- package/dist/chunk-6PPZTREF.js.map +1 -0
- package/dist/mock/index.d.ts +22 -6
- package/dist/mock/index.js +87 -272
- package/dist/mock/index.js.map +1 -1
- package/dist/panel/index.d.ts +1 -1
- package/dist/panel/index.js +588 -32
- package/dist/panel/index.js.map +1 -1
- package/dist/unplugin/index.cjs +13 -12
- package/dist/unplugin/index.cjs.map +1 -1
- package/dist/unplugin/index.d.cts +51 -0
- package/dist/unplugin/index.d.ts +51 -0
- package/dist/unplugin/index.js +13 -12
- package/dist/unplugin/index.js.map +1 -1
- package/package.json +19 -10
- package/dist/chunk-YYIIG3JT.js +0 -146
- package/dist/chunk-YYIIG3JT.js.map +0 -1
package/dist/mock/index.d.ts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ait-devtools 중앙 상태 관리
|
|
2
|
+
* @ait-co/devtools 중앙 상태 관리
|
|
3
3
|
* DevTools Panel과 mock 구현체가 이 상태를 공유한다.
|
|
4
4
|
*/
|
|
5
5
|
type PlatformOS = 'ios' | 'android';
|
|
6
6
|
type OperationalEnvironment = 'toss' | 'sandbox';
|
|
7
|
-
type NetworkStatus
|
|
7
|
+
type NetworkStatus = 'OFFLINE' | 'WIFI' | '2G' | '3G' | '4G' | '5G' | 'WWAN' | 'UNKNOWN';
|
|
8
8
|
type PermissionStatus = 'notDetermined' | 'denied' | 'allowed';
|
|
9
9
|
type PermissionName = 'clipboard' | 'contacts' | 'photos' | 'geolocation' | 'camera' | 'microphone';
|
|
10
10
|
type HapticFeedbackType = 'tickWeak' | 'tap' | 'tickMedium' | 'softMedium' | 'basicWeak' | 'basicMedium' | 'success' | 'error' | 'wiggle' | 'confetti';
|
|
11
|
+
type DeviceApiMode = 'mock' | 'web' | 'prompt';
|
|
12
|
+
interface DeviceModes {
|
|
13
|
+
camera: DeviceApiMode;
|
|
14
|
+
photos: DeviceApiMode;
|
|
15
|
+
location: DeviceApiMode;
|
|
16
|
+
network: 'mock' | 'web';
|
|
17
|
+
clipboard: 'mock' | 'web';
|
|
18
|
+
}
|
|
19
|
+
interface MockData {
|
|
20
|
+
images: string[];
|
|
21
|
+
clipboardText: string;
|
|
22
|
+
}
|
|
11
23
|
interface LocationCoords {
|
|
12
24
|
latitude: number;
|
|
13
25
|
longitude: number;
|
|
@@ -61,7 +73,7 @@ interface AitDevtoolsState {
|
|
|
61
73
|
icon: string;
|
|
62
74
|
primaryColor: string;
|
|
63
75
|
};
|
|
64
|
-
networkStatus: NetworkStatus
|
|
76
|
+
networkStatus: NetworkStatus;
|
|
65
77
|
permissions: Record<PermissionName, PermissionStatus>;
|
|
66
78
|
location: MockLocation;
|
|
67
79
|
safeAreaInsets: SafeAreaInsets$1;
|
|
@@ -105,6 +117,9 @@ interface AitDevtoolsState {
|
|
|
105
117
|
}>;
|
|
106
118
|
};
|
|
107
119
|
analyticsLog: AnalyticsLogEntry[];
|
|
120
|
+
deviceModes: DeviceModes;
|
|
121
|
+
mockData: MockData;
|
|
122
|
+
panelEditable: boolean;
|
|
108
123
|
}
|
|
109
124
|
declare class AitStateManager {
|
|
110
125
|
private _state;
|
|
@@ -144,6 +159,7 @@ declare function appsInTossSignTossCert(_params: AppsInTossSignTossCertParams):
|
|
|
144
159
|
/**
|
|
145
160
|
* 화면/네비게이션/이벤트 mock
|
|
146
161
|
*/
|
|
162
|
+
|
|
147
163
|
declare function closeView(): Promise<void>;
|
|
148
164
|
declare function openURL(url: string): Promise<void>;
|
|
149
165
|
declare function share(message: {
|
|
@@ -179,7 +195,6 @@ declare function getLocale(): string;
|
|
|
179
195
|
declare function getDeviceId(): string;
|
|
180
196
|
declare function getGroupId(): string;
|
|
181
197
|
declare function getNetworkStatus(): Promise<NetworkStatus>;
|
|
182
|
-
type NetworkStatus = 'OFFLINE' | 'WIFI' | '2G' | '3G' | '4G' | '5G' | 'WWAN' | 'UNKNOWN';
|
|
183
198
|
declare function getServerTime(): Promise<number | undefined>;
|
|
184
199
|
interface GraniteEventMap {
|
|
185
200
|
backEvent: {
|
|
@@ -255,6 +270,7 @@ declare const SafeAreaInsets: {
|
|
|
255
270
|
/** @deprecated */
|
|
256
271
|
declare function getSafeAreaInsets(): number;
|
|
257
272
|
|
|
273
|
+
declare function getDefaultPlaceholderImages(): string[];
|
|
258
274
|
declare const Storage: {
|
|
259
275
|
getItem: (key: string) => Promise<string | null>;
|
|
260
276
|
setItem: (key: string, value: string) => Promise<void>;
|
|
@@ -290,7 +306,7 @@ declare const startUpdateLocation: typeof _startUpdateLocation & {
|
|
|
290
306
|
getPermission: () => Promise<PermissionStatus>;
|
|
291
307
|
openPermissionDialog: () => Promise<"denied" | "allowed">;
|
|
292
308
|
};
|
|
293
|
-
declare const openCamera: ((
|
|
309
|
+
declare const openCamera: ((_options?: {
|
|
294
310
|
base64?: boolean;
|
|
295
311
|
maxWidth?: number;
|
|
296
312
|
}) => Promise<{
|
|
@@ -610,4 +626,4 @@ declare function requestPermission(permission: {
|
|
|
610
626
|
|
|
611
627
|
type Primitive = string | number | boolean | null | undefined | symbol;
|
|
612
628
|
|
|
613
|
-
export { Accuracy, type AitDevtoolsState, Analytics, type AnalyticsLogEntry, GoogleAdMob, type HapticFeedbackType, IAP, type IapNextResult, type LocationCoords, type MockContact, type MockIapProduct, type MockLocation, type NetworkStatus
|
|
629
|
+
export { Accuracy, type AitDevtoolsState, Analytics, type AnalyticsLogEntry, type DeviceApiMode, type DeviceModes, GoogleAdMob, type HapticFeedbackType, IAP, type IapNextResult, type LocationCoords, type MockContact, type MockData, type MockIapProduct, type MockLocation, type NetworkStatus, type OperationalEnvironment, type PermissionName, type PermissionStatus, type PlatformOS, type Primitive, SafeAreaInsets, type SafeAreaInsets$1 as SafeAreaInsetsType, Storage, TossAds, aitState, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, env, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAppsInTossGlobals, getClipboardText, getCurrentLocation, getDefaultPlaceholderImages, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPermission, getPlatformOS, getSafeAreaInsets, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, graniteEvent, grantPromotionReward, grantPromotionRewardForGame, isMinVersionSupported, loadFullScreenAd, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPermissionDialog, openURL, partner, requestPermission, requestReview, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, showFullScreenAd, startUpdateLocation, submitGameCenterLeaderBoardScore, tdsEvent };
|
package/dist/mock/index.js
CHANGED
|
@@ -1,67 +1,77 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Accuracy,
|
|
3
|
+
Storage,
|
|
4
|
+
aitState,
|
|
5
|
+
createMockProxy,
|
|
6
|
+
fetchAlbumPhotos,
|
|
7
|
+
fetchContacts,
|
|
8
|
+
generateHapticFeedback,
|
|
9
|
+
getClipboardText,
|
|
10
|
+
getCurrentLocation,
|
|
11
|
+
getDefaultPlaceholderImages,
|
|
12
|
+
getNetworkStatusByMode,
|
|
13
|
+
getPermission,
|
|
14
|
+
openCamera,
|
|
15
|
+
openPermissionDialog,
|
|
16
|
+
requestPermission,
|
|
17
|
+
saveBase64Data,
|
|
18
|
+
setClipboardText,
|
|
19
|
+
startUpdateLocation
|
|
20
|
+
} from "../chunk-6PPZTREF.js";
|
|
4
21
|
|
|
5
22
|
// src/mock/auth/index.ts
|
|
6
|
-
function appLogin() {
|
|
7
|
-
return
|
|
23
|
+
async function appLogin() {
|
|
24
|
+
return {
|
|
8
25
|
authorizationCode: `mock-auth-${crypto.randomUUID()}`,
|
|
9
26
|
referrer: aitState.state.environment === "toss" ? "DEFAULT" : "SANDBOX"
|
|
10
|
-
}
|
|
27
|
+
};
|
|
11
28
|
}
|
|
12
|
-
function getIsTossLoginIntegratedService() {
|
|
13
|
-
return
|
|
29
|
+
async function getIsTossLoginIntegratedService() {
|
|
30
|
+
return aitState.state.auth.isTossLoginIntegrated;
|
|
14
31
|
}
|
|
15
|
-
function getUserKeyForGame() {
|
|
16
|
-
if (!aitState.state.auth.userKeyHash) return
|
|
17
|
-
return
|
|
32
|
+
async function getUserKeyForGame() {
|
|
33
|
+
if (!aitState.state.auth.userKeyHash) return void 0;
|
|
34
|
+
return { hash: aitState.state.auth.userKeyHash, type: "HASH" };
|
|
18
35
|
}
|
|
19
|
-
function appsInTossSignTossCert(_params) {
|
|
20
|
-
console.log("[ait-devtools] appsInTossSignTossCert called (no-op in mock)");
|
|
21
|
-
return Promise.resolve();
|
|
36
|
+
async function appsInTossSignTossCert(_params) {
|
|
37
|
+
console.log("[@ait-co/devtools] appsInTossSignTossCert called (no-op in mock)");
|
|
22
38
|
}
|
|
23
39
|
|
|
24
40
|
// src/mock/navigation/index.ts
|
|
25
|
-
function closeView() {
|
|
26
|
-
console.log("[ait-devtools] closeView called");
|
|
41
|
+
async function closeView() {
|
|
42
|
+
console.log("[@ait-co/devtools] closeView called");
|
|
27
43
|
window.history.back();
|
|
28
|
-
return Promise.resolve();
|
|
29
44
|
}
|
|
30
|
-
function openURL(url) {
|
|
31
|
-
console.log("[ait-devtools] openURL:", url);
|
|
45
|
+
async function openURL(url) {
|
|
46
|
+
console.log("[@ait-co/devtools] openURL:", url);
|
|
32
47
|
window.open(url, "_blank");
|
|
33
|
-
return Promise.resolve();
|
|
34
48
|
}
|
|
35
|
-
function share(message) {
|
|
49
|
+
async function share(message) {
|
|
36
50
|
if (navigator.share) {
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
await navigator.share({ text: message.message });
|
|
52
|
+
return;
|
|
39
53
|
}
|
|
40
|
-
console.log("[ait-devtools] share:", message.message);
|
|
41
|
-
return Promise.resolve();
|
|
54
|
+
console.log("[@ait-co/devtools] share:", message.message);
|
|
42
55
|
}
|
|
43
|
-
function getTossShareLink(path, _ogImageUrl) {
|
|
44
|
-
return
|
|
56
|
+
async function getTossShareLink(path, _ogImageUrl) {
|
|
57
|
+
return `https://toss.im/share/mock${path}`;
|
|
45
58
|
}
|
|
46
|
-
function setIosSwipeGestureEnabled(_options) {
|
|
47
|
-
console.log("[ait-devtools] setIosSwipeGestureEnabled:", _options.isEnabled);
|
|
48
|
-
return Promise.resolve();
|
|
59
|
+
async function setIosSwipeGestureEnabled(_options) {
|
|
60
|
+
console.log("[@ait-co/devtools] setIosSwipeGestureEnabled:", _options.isEnabled);
|
|
49
61
|
}
|
|
50
|
-
function setDeviceOrientation(_options) {
|
|
51
|
-
console.log("[ait-devtools] setDeviceOrientation:", _options.type);
|
|
52
|
-
return Promise.resolve();
|
|
62
|
+
async function setDeviceOrientation(_options) {
|
|
63
|
+
console.log("[@ait-co/devtools] setDeviceOrientation:", _options.type);
|
|
53
64
|
}
|
|
54
|
-
function setScreenAwakeMode(options) {
|
|
55
|
-
console.log("[ait-devtools] setScreenAwakeMode:", options.enabled);
|
|
56
|
-
return
|
|
65
|
+
async function setScreenAwakeMode(options) {
|
|
66
|
+
console.log("[@ait-co/devtools] setScreenAwakeMode:", options.enabled);
|
|
67
|
+
return { enabled: options.enabled };
|
|
57
68
|
}
|
|
58
|
-
function setSecureScreen(options) {
|
|
59
|
-
console.log("[ait-devtools] setSecureScreen:", options.enabled);
|
|
60
|
-
return
|
|
69
|
+
async function setSecureScreen(options) {
|
|
70
|
+
console.log("[@ait-co/devtools] setSecureScreen:", options.enabled);
|
|
71
|
+
return { enabled: options.enabled };
|
|
61
72
|
}
|
|
62
|
-
function requestReview() {
|
|
63
|
-
console.log("[ait-devtools] requestReview called");
|
|
64
|
-
return Promise.resolve();
|
|
73
|
+
async function requestReview() {
|
|
74
|
+
console.log("[@ait-co/devtools] requestReview called");
|
|
65
75
|
}
|
|
66
76
|
requestReview.isSupported = () => true;
|
|
67
77
|
function getPlatformOS() {
|
|
@@ -98,11 +108,13 @@ function getDeviceId() {
|
|
|
98
108
|
function getGroupId() {
|
|
99
109
|
return aitState.state.groupId;
|
|
100
110
|
}
|
|
101
|
-
function getNetworkStatus() {
|
|
102
|
-
|
|
111
|
+
async function getNetworkStatus() {
|
|
112
|
+
const modeResult = getNetworkStatusByMode();
|
|
113
|
+
if (modeResult) return modeResult;
|
|
114
|
+
return aitState.state.networkStatus;
|
|
103
115
|
}
|
|
104
|
-
function getServerTime() {
|
|
105
|
-
return
|
|
116
|
+
async function getServerTime() {
|
|
117
|
+
return Date.now();
|
|
106
118
|
}
|
|
107
119
|
getServerTime.isSupported = () => true;
|
|
108
120
|
var graniteEvent = {
|
|
@@ -162,198 +174,6 @@ function getSafeAreaInsets() {
|
|
|
162
174
|
return aitState.state.safeAreaInsets.top;
|
|
163
175
|
}
|
|
164
176
|
|
|
165
|
-
// src/mock/proxy.ts
|
|
166
|
-
var WARNED = /* @__PURE__ */ new Set();
|
|
167
|
-
function createMockProxy(moduleName, implementations) {
|
|
168
|
-
return new Proxy(implementations, {
|
|
169
|
-
get(target, prop) {
|
|
170
|
-
if (prop in target) return target[prop];
|
|
171
|
-
if (typeof prop === "symbol") return void 0;
|
|
172
|
-
if (!WARNED.has(`${moduleName}.${prop}`)) {
|
|
173
|
-
console.warn(
|
|
174
|
-
`[ait-devtools] ${moduleName}.${prop} is not mocked yet. Returning no-op. Please update ait-devtools or file an issue.`
|
|
175
|
-
);
|
|
176
|
-
WARNED.add(`${moduleName}.${prop}`);
|
|
177
|
-
}
|
|
178
|
-
return async () => void 0;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/mock/permissions.ts
|
|
184
|
-
function getPermission(name) {
|
|
185
|
-
return Promise.resolve(aitState.state.permissions[name]);
|
|
186
|
-
}
|
|
187
|
-
function openPermissionDialog(name) {
|
|
188
|
-
const current = aitState.state.permissions[name];
|
|
189
|
-
if (current === "allowed") return Promise.resolve("allowed");
|
|
190
|
-
aitState.patch("permissions", { [name]: "allowed" });
|
|
191
|
-
return Promise.resolve("allowed");
|
|
192
|
-
}
|
|
193
|
-
function requestPermission(permission) {
|
|
194
|
-
return openPermissionDialog(permission.name);
|
|
195
|
-
}
|
|
196
|
-
function withPermission(fn, permissionName) {
|
|
197
|
-
const enhanced = fn;
|
|
198
|
-
enhanced.getPermission = () => getPermission(permissionName);
|
|
199
|
-
enhanced.openPermissionDialog = () => openPermissionDialog(permissionName);
|
|
200
|
-
return enhanced;
|
|
201
|
-
}
|
|
202
|
-
function checkPermission(name, fnName) {
|
|
203
|
-
const status = aitState.state.permissions[name];
|
|
204
|
-
if (status === "denied") {
|
|
205
|
-
throw new Error(`[ait-devtools] ${fnName}: Permission "${name}" is denied. Change it in the DevTools panel.`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/mock/device/index.ts
|
|
210
|
-
var Storage = createMockProxy("Storage", {
|
|
211
|
-
getItem: async (key) => {
|
|
212
|
-
return localStorage.getItem(`__ait_storage:${key}`);
|
|
213
|
-
},
|
|
214
|
-
setItem: async (key, value) => {
|
|
215
|
-
localStorage.setItem(`__ait_storage:${key}`, value);
|
|
216
|
-
},
|
|
217
|
-
removeItem: async (key) => {
|
|
218
|
-
localStorage.removeItem(`__ait_storage:${key}`);
|
|
219
|
-
},
|
|
220
|
-
clearItems: async () => {
|
|
221
|
-
const keys = Object.keys(localStorage).filter((k) => k.startsWith("__ait_storage:"));
|
|
222
|
-
keys.forEach((k) => localStorage.removeItem(k));
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
|
|
226
|
-
Accuracy2[Accuracy2["Lowest"] = 1] = "Lowest";
|
|
227
|
-
Accuracy2[Accuracy2["Low"] = 2] = "Low";
|
|
228
|
-
Accuracy2[Accuracy2["Balanced"] = 3] = "Balanced";
|
|
229
|
-
Accuracy2[Accuracy2["High"] = 4] = "High";
|
|
230
|
-
Accuracy2[Accuracy2["Highest"] = 5] = "Highest";
|
|
231
|
-
Accuracy2[Accuracy2["BestForNavigation"] = 6] = "BestForNavigation";
|
|
232
|
-
return Accuracy2;
|
|
233
|
-
})(Accuracy || {});
|
|
234
|
-
function buildLocation() {
|
|
235
|
-
return {
|
|
236
|
-
coords: { ...aitState.state.location.coords },
|
|
237
|
-
timestamp: Date.now(),
|
|
238
|
-
accessLocation: aitState.state.location.accessLocation
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
var _getCurrentLocation = async (_options) => {
|
|
242
|
-
checkPermission("geolocation", "getCurrentLocation");
|
|
243
|
-
return buildLocation();
|
|
244
|
-
};
|
|
245
|
-
var getCurrentLocation = withPermission(_getCurrentLocation, "geolocation");
|
|
246
|
-
function _startUpdateLocation(eventParams) {
|
|
247
|
-
const { onEvent, options } = eventParams;
|
|
248
|
-
const interval = Math.max(options.timeInterval, 500);
|
|
249
|
-
const id = setInterval(() => {
|
|
250
|
-
const loc = buildLocation();
|
|
251
|
-
loc.coords.latitude += (Math.random() - 0.5) * 1e-4;
|
|
252
|
-
loc.coords.longitude += (Math.random() - 0.5) * 1e-4;
|
|
253
|
-
onEvent(loc);
|
|
254
|
-
}, interval);
|
|
255
|
-
return () => clearInterval(id);
|
|
256
|
-
}
|
|
257
|
-
var startUpdateLocation = Object.assign(_startUpdateLocation, {
|
|
258
|
-
getPermission: () => withPermission(_getCurrentLocation, "geolocation").getPermission(),
|
|
259
|
-
openPermissionDialog: () => withPermission(_getCurrentLocation, "geolocation").openPermissionDialog()
|
|
260
|
-
});
|
|
261
|
-
var _openCamera = async (options) => {
|
|
262
|
-
checkPermission("camera", "openCamera");
|
|
263
|
-
return new Promise((resolve, reject) => {
|
|
264
|
-
const input = document.createElement("input");
|
|
265
|
-
input.type = "file";
|
|
266
|
-
input.accept = "image/*";
|
|
267
|
-
input.capture = "environment";
|
|
268
|
-
input.onchange = () => {
|
|
269
|
-
const file = input.files?.[0];
|
|
270
|
-
if (!file) {
|
|
271
|
-
reject(new Error("No file selected"));
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const reader = new FileReader();
|
|
275
|
-
reader.onload = () => {
|
|
276
|
-
resolve({
|
|
277
|
-
id: crypto.randomUUID(),
|
|
278
|
-
dataUri: reader.result
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
reader.readAsDataURL(file);
|
|
282
|
-
};
|
|
283
|
-
input.click();
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
var openCamera = withPermission(_openCamera, "camera");
|
|
287
|
-
var _fetchAlbumPhotos = async (options) => {
|
|
288
|
-
checkPermission("photos", "fetchAlbumPhotos");
|
|
289
|
-
const maxCount = options?.maxCount ?? 10;
|
|
290
|
-
return new Promise((resolve, reject) => {
|
|
291
|
-
const input = document.createElement("input");
|
|
292
|
-
input.type = "file";
|
|
293
|
-
input.accept = "image/*";
|
|
294
|
-
input.multiple = true;
|
|
295
|
-
input.onchange = async () => {
|
|
296
|
-
const files = Array.from(input.files ?? []).slice(0, maxCount);
|
|
297
|
-
if (files.length === 0) {
|
|
298
|
-
reject(new Error("No files selected"));
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
const results = await Promise.all(
|
|
302
|
-
files.map((file) => new Promise((res) => {
|
|
303
|
-
const reader = new FileReader();
|
|
304
|
-
reader.onload = () => res({ id: crypto.randomUUID(), dataUri: reader.result });
|
|
305
|
-
reader.readAsDataURL(file);
|
|
306
|
-
}))
|
|
307
|
-
);
|
|
308
|
-
resolve(results);
|
|
309
|
-
};
|
|
310
|
-
input.click();
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
var fetchAlbumPhotos = withPermission(_fetchAlbumPhotos, "photos");
|
|
314
|
-
var _fetchContacts = async (options) => {
|
|
315
|
-
checkPermission("contacts", "fetchContacts");
|
|
316
|
-
let contacts = aitState.state.contacts;
|
|
317
|
-
if (options.query?.contains) {
|
|
318
|
-
const q = options.query.contains.toLowerCase();
|
|
319
|
-
contacts = contacts.filter((c) => c.name.toLowerCase().includes(q) || c.phoneNumber.includes(q));
|
|
320
|
-
}
|
|
321
|
-
const sliced = contacts.slice(options.offset, options.offset + options.size);
|
|
322
|
-
const nextOffset = options.offset + options.size;
|
|
323
|
-
return {
|
|
324
|
-
result: sliced,
|
|
325
|
-
nextOffset: nextOffset < contacts.length ? nextOffset : null,
|
|
326
|
-
done: nextOffset >= contacts.length
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
var fetchContacts = withPermission(_fetchContacts, "contacts");
|
|
330
|
-
var _getClipboardText = async () => {
|
|
331
|
-
checkPermission("clipboard", "getClipboardText");
|
|
332
|
-
try {
|
|
333
|
-
return await navigator.clipboard.readText();
|
|
334
|
-
} catch {
|
|
335
|
-
return "";
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
var getClipboardText = withPermission(_getClipboardText, "clipboard");
|
|
339
|
-
var _setClipboardText = async (text) => {
|
|
340
|
-
checkPermission("clipboard", "setClipboardText");
|
|
341
|
-
await navigator.clipboard.writeText(text);
|
|
342
|
-
};
|
|
343
|
-
var setClipboardText = withPermission(_setClipboardText, "clipboard");
|
|
344
|
-
function generateHapticFeedback(options) {
|
|
345
|
-
console.log(`[ait-devtools] haptic: ${options.type}`);
|
|
346
|
-
aitState.logAnalytics({ type: "haptic", params: { hapticType: options.type } });
|
|
347
|
-
return Promise.resolve();
|
|
348
|
-
}
|
|
349
|
-
function saveBase64Data(params) {
|
|
350
|
-
const a = document.createElement("a");
|
|
351
|
-
a.href = `data:${params.mimeType};base64,${params.data}`;
|
|
352
|
-
a.download = params.fileName;
|
|
353
|
-
a.click();
|
|
354
|
-
return Promise.resolve();
|
|
355
|
-
}
|
|
356
|
-
|
|
357
177
|
// src/mock/iap/index.ts
|
|
358
178
|
var orderCounter = 0;
|
|
359
179
|
function generateOrderId() {
|
|
@@ -404,12 +224,12 @@ var IAP = createMockProxy("IAP", {
|
|
|
404
224
|
// 반환되는 cancel 함수는 mock에서는 no-op이다 (실제 SDK는 결제 UI를 닫음)
|
|
405
225
|
createOneTimePurchaseOrder(params) {
|
|
406
226
|
const sku = params.options.sku ?? params.options.productId ?? "";
|
|
407
|
-
handlePurchase(sku, params.options.processProductGrant, params.onEvent, params.onError).catch((e) => console.error("[ait-devtools] IAP unexpected error:", e));
|
|
227
|
+
handlePurchase(sku, params.options.processProductGrant, params.onEvent, params.onError).catch((e) => console.error("[@ait-co/devtools] IAP unexpected error:", e));
|
|
408
228
|
return () => {
|
|
409
229
|
};
|
|
410
230
|
},
|
|
411
231
|
createSubscriptionPurchaseOrder(params) {
|
|
412
|
-
handlePurchase(params.options.sku, params.options.processProductGrant, params.onEvent, params.onError).catch((e) => console.error("[ait-devtools] IAP unexpected error:", e));
|
|
232
|
+
handlePurchase(params.options.sku, params.options.processProductGrant, params.onEvent, params.onError).catch((e) => console.error("[@ait-co/devtools] IAP unexpected error:", e));
|
|
413
233
|
return () => {
|
|
414
234
|
};
|
|
415
235
|
},
|
|
@@ -459,18 +279,14 @@ var IAP = createMockProxy("IAP", {
|
|
|
459
279
|
};
|
|
460
280
|
}
|
|
461
281
|
});
|
|
462
|
-
function checkoutPayment(options) {
|
|
282
|
+
async function checkoutPayment(options) {
|
|
463
283
|
const { nextResult, failReason } = aitState.state.payment;
|
|
464
|
-
console.log("[ait-devtools] checkoutPayment:", options.params.payToken);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
resolve({ success: false, reason: failReason || "Mock payment failed" });
|
|
471
|
-
}
|
|
472
|
-
}, 300);
|
|
473
|
-
});
|
|
284
|
+
console.log("[@ait-co/devtools] checkoutPayment:", options.params.payToken);
|
|
285
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
286
|
+
if (nextResult === "success") {
|
|
287
|
+
return { success: true };
|
|
288
|
+
}
|
|
289
|
+
return { success: false, reason: failReason || "Mock payment failed" };
|
|
474
290
|
}
|
|
475
291
|
|
|
476
292
|
// src/mock/ads/index.ts
|
|
@@ -512,14 +328,14 @@ var GoogleAdMob = createMockProxy("GoogleAdMob", {
|
|
|
512
328
|
});
|
|
513
329
|
var TossAds = createMockProxy("TossAds", {
|
|
514
330
|
initialize: withIsSupported((_options) => {
|
|
515
|
-
console.log("[ait-devtools] TossAds.initialize (mock)");
|
|
331
|
+
console.log("[@ait-co/devtools] TossAds.initialize (mock)");
|
|
516
332
|
}),
|
|
517
333
|
attach: withIsSupported((_adGroupId, target, _options) => {
|
|
518
334
|
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
519
335
|
if (el) {
|
|
520
336
|
const placeholder = document.createElement("div");
|
|
521
337
|
placeholder.style.cssText = "background:#f0f0f0;border:1px dashed #999;padding:16px;text-align:center;color:#666;font-size:14px;";
|
|
522
|
-
placeholder.textContent = "[ait-devtools] TossAds Placeholder";
|
|
338
|
+
placeholder.textContent = "[@ait-co/devtools] TossAds Placeholder";
|
|
523
339
|
el.appendChild(placeholder);
|
|
524
340
|
}
|
|
525
341
|
}),
|
|
@@ -528,7 +344,7 @@ var TossAds = createMockProxy("TossAds", {
|
|
|
528
344
|
if (el) {
|
|
529
345
|
const placeholder = document.createElement("div");
|
|
530
346
|
placeholder.style.cssText = "background:#f0f0f0;border:1px dashed #999;padding:12px;text-align:center;color:#666;font-size:12px;";
|
|
531
|
-
placeholder.textContent = "[ait-devtools] Banner Ad Placeholder";
|
|
347
|
+
placeholder.textContent = "[@ait-co/devtools] Banner Ad Placeholder";
|
|
532
348
|
el.appendChild(placeholder);
|
|
533
349
|
}
|
|
534
350
|
return { destroy: () => {
|
|
@@ -560,32 +376,31 @@ var showFullScreenAd = withIsSupported((args) => {
|
|
|
560
376
|
});
|
|
561
377
|
|
|
562
378
|
// src/mock/game/index.ts
|
|
563
|
-
function grantPromotionReward(params) {
|
|
564
|
-
console.log("[ait-devtools] grantPromotionReward:", params.params);
|
|
565
|
-
return
|
|
379
|
+
async function grantPromotionReward(params) {
|
|
380
|
+
console.log("[@ait-co/devtools] grantPromotionReward:", params.params);
|
|
381
|
+
return { key: `mock-reward-${Date.now()}` };
|
|
566
382
|
}
|
|
567
|
-
function grantPromotionRewardForGame(params) {
|
|
568
|
-
console.log("[ait-devtools] grantPromotionRewardForGame:", params.params);
|
|
569
|
-
return
|
|
383
|
+
async function grantPromotionRewardForGame(params) {
|
|
384
|
+
console.log("[@ait-co/devtools] grantPromotionRewardForGame:", params.params);
|
|
385
|
+
return { key: `mock-reward-${Date.now()}` };
|
|
570
386
|
}
|
|
571
|
-
function submitGameCenterLeaderBoardScore(params) {
|
|
387
|
+
async function submitGameCenterLeaderBoardScore(params) {
|
|
572
388
|
aitState.patch("game", {
|
|
573
389
|
leaderboardScores: [...aitState.state.game.leaderboardScores, { score: params.score, timestamp: Date.now() }]
|
|
574
390
|
});
|
|
575
|
-
return
|
|
391
|
+
return { statusCode: "SUCCESS" };
|
|
576
392
|
}
|
|
577
|
-
function getGameCenterGameProfile() {
|
|
393
|
+
async function getGameCenterGameProfile() {
|
|
578
394
|
const profile = aitState.state.game.profile;
|
|
579
|
-
if (!profile) return
|
|
580
|
-
return
|
|
395
|
+
if (!profile) return { statusCode: "PROFILE_NOT_FOUND" };
|
|
396
|
+
return {
|
|
581
397
|
statusCode: "SUCCESS",
|
|
582
398
|
nickname: profile.nickname,
|
|
583
399
|
profileImageUri: profile.profileImageUri
|
|
584
|
-
}
|
|
400
|
+
};
|
|
585
401
|
}
|
|
586
|
-
function openGameCenterLeaderboard() {
|
|
587
|
-
console.log("[ait-devtools] openGameCenterLeaderboard (no-op in browser)");
|
|
588
|
-
return Promise.resolve();
|
|
402
|
+
async function openGameCenterLeaderboard() {
|
|
403
|
+
console.log("[@ait-co/devtools] openGameCenterLeaderboard (no-op in browser)");
|
|
589
404
|
}
|
|
590
405
|
function contactsViral(params) {
|
|
591
406
|
setTimeout(() => {
|
|
@@ -616,18 +431,17 @@ var Analytics = {
|
|
|
616
431
|
return Promise.resolve();
|
|
617
432
|
}
|
|
618
433
|
};
|
|
619
|
-
function eventLog(params) {
|
|
434
|
+
async function eventLog(params) {
|
|
620
435
|
aitState.logAnalytics({ type: params.log_type, params: { log_name: params.log_name, ...params.params } });
|
|
621
|
-
return Promise.resolve();
|
|
622
436
|
}
|
|
623
437
|
|
|
624
438
|
// src/mock/partner/index.ts
|
|
625
439
|
var partner = {
|
|
626
440
|
async addAccessoryButton(options) {
|
|
627
|
-
console.log("[ait-devtools] partner.addAccessoryButton:", options);
|
|
441
|
+
console.log("[@ait-co/devtools] partner.addAccessoryButton:", options);
|
|
628
442
|
},
|
|
629
443
|
async removeAccessoryButton() {
|
|
630
|
-
console.log("[ait-devtools] partner.removeAccessoryButton");
|
|
444
|
+
console.log("[@ait-co/devtools] partner.removeAccessoryButton");
|
|
631
445
|
}
|
|
632
446
|
};
|
|
633
447
|
export {
|
|
@@ -653,6 +467,7 @@ export {
|
|
|
653
467
|
getAppsInTossGlobals,
|
|
654
468
|
getClipboardText,
|
|
655
469
|
getCurrentLocation,
|
|
470
|
+
getDefaultPlaceholderImages,
|
|
656
471
|
getDeviceId,
|
|
657
472
|
getGameCenterGameProfile,
|
|
658
473
|
getGroupId,
|