@apps-in-toss/framework 0.0.23 → 0.0.25
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/index.cjs +595 -484
- package/dist/index.d.cts +41 -26
- package/dist/index.d.ts +41 -26
- package/dist/index.js +561 -451
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -4,76 +4,31 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
// src/index.ts
|
|
8
|
+
import { Analytics as InternalAnalytics } from "@apps-in-toss/analytics";
|
|
9
|
+
|
|
7
10
|
// src/core/registerApp.tsx
|
|
11
|
+
import { Analytics } from "@apps-in-toss/analytics";
|
|
8
12
|
import { TDSProvider } from "@toss-design-system/react-native";
|
|
9
|
-
import { Bedrock } from "react-native-bedrock";
|
|
13
|
+
import { Bedrock as Bedrock2 } from "react-native-bedrock";
|
|
10
14
|
|
|
11
15
|
// src/core/components/AppEvent.tsx
|
|
12
16
|
import { useEffect } from "react";
|
|
13
|
-
import { getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
|
|
17
|
+
import { Bedrock, getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
|
|
14
18
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
// src/env.ts
|
|
20
|
+
var env = {
|
|
21
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/native-modules/tossCore.ts
|
|
25
|
+
import { NativeModules as NativeModules2 } from "react-native";
|
|
18
26
|
|
|
19
27
|
// src/native-modules/AppsInTossModule.ts
|
|
20
28
|
import { NativeModules } from "react-native";
|
|
21
29
|
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
22
30
|
var AppsInTossModule = AppsInTossModuleInstance;
|
|
23
31
|
|
|
24
|
-
// src/utils/generateUUID.ts
|
|
25
|
-
function generateUUID(placeholder) {
|
|
26
|
-
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/native-event-emitter/internal/appBridge.ts
|
|
30
|
-
var INTERNAL__callbacks = /* @__PURE__ */ new Map();
|
|
31
|
-
function invokeAppBridgeCallback(id, ...args) {
|
|
32
|
-
const callback = INTERNAL__callbacks.get(id);
|
|
33
|
-
callback?.call(null, ...args);
|
|
34
|
-
return Boolean(callback);
|
|
35
|
-
}
|
|
36
|
-
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
37
|
-
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
38
|
-
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
39
|
-
const promise = AppsInTossModuleInstance[methodName]({
|
|
40
|
-
params,
|
|
41
|
-
callbacks: callbackMap
|
|
42
|
-
});
|
|
43
|
-
void promise.then(onSuccess).catch(onError);
|
|
44
|
-
return unregisterAll;
|
|
45
|
-
}
|
|
46
|
-
function registerCallbacks(callbacks) {
|
|
47
|
-
const callbackMap = {};
|
|
48
|
-
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
49
|
-
const id = registerCallback(callback, callbackName);
|
|
50
|
-
callbackMap[callbackName] = id;
|
|
51
|
-
}
|
|
52
|
-
const unregisterAll = () => {
|
|
53
|
-
Object.values(callbackMap).forEach(unregisterCallback);
|
|
54
|
-
};
|
|
55
|
-
return { callbackMap, unregisterAll };
|
|
56
|
-
}
|
|
57
|
-
function registerCallback(callback, name = "unnamed") {
|
|
58
|
-
const uniqueId = generateUUID();
|
|
59
|
-
const callbackId = `${uniqueId}__${name}`;
|
|
60
|
-
INTERNAL__callbacks.set(callbackId, callback);
|
|
61
|
-
return callbackId;
|
|
62
|
-
}
|
|
63
|
-
function unregisterCallback(id) {
|
|
64
|
-
INTERNAL__callbacks.delete(id);
|
|
65
|
-
}
|
|
66
|
-
function getCallbackIds() {
|
|
67
|
-
return Array.from(INTERNAL__callbacks.keys());
|
|
68
|
-
}
|
|
69
|
-
var INTERNAL__appBridgeHandler = {
|
|
70
|
-
invokeAppBridgeCallback,
|
|
71
|
-
invokeAppBridgeMethod,
|
|
72
|
-
registerCallback,
|
|
73
|
-
unregisterCallback,
|
|
74
|
-
getCallbackIds
|
|
75
|
-
};
|
|
76
|
-
|
|
77
32
|
// src/native-modules/getOperationalEnvironment.ts
|
|
78
33
|
function getOperationalEnvironment() {
|
|
79
34
|
return AppsInTossModule.operationalEnvironment;
|
|
@@ -170,113 +125,104 @@ function isMinVersionSupported(minVersions) {
|
|
|
170
125
|
return compareVersions(currentVersion, minVersion) >= 0;
|
|
171
126
|
}
|
|
172
127
|
|
|
173
|
-
// src/native-modules/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
128
|
+
// src/native-modules/tossCore.ts
|
|
129
|
+
var TossCoreModule = NativeModules2.TossCoreModule;
|
|
130
|
+
function tossCoreEventLog(params) {
|
|
131
|
+
const supported = isMinVersionSupported({ ios: "5.210.0", android: "5.210.0" });
|
|
132
|
+
const isSandbox = getOperationalEnvironment() === "sandbox";
|
|
133
|
+
if (!supported || isSandbox) {
|
|
134
|
+
return;
|
|
178
135
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
onEvent({ type: "dismissed" });
|
|
186
|
-
},
|
|
187
|
-
onAdFailedToShow: () => {
|
|
188
|
-
onEvent({ type: "failedToShow" });
|
|
189
|
-
},
|
|
190
|
-
onAdImpression: () => {
|
|
191
|
-
onEvent({ type: "impression" });
|
|
192
|
-
},
|
|
193
|
-
onAdShow: () => {
|
|
194
|
-
onEvent({ type: "show" });
|
|
195
|
-
},
|
|
196
|
-
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
197
|
-
onError
|
|
136
|
+
TossCoreModule.eventLog({
|
|
137
|
+
params: {
|
|
138
|
+
log_name: params.log_name,
|
|
139
|
+
log_type: params.log_type,
|
|
140
|
+
params: params.params
|
|
141
|
+
}
|
|
198
142
|
});
|
|
199
|
-
return unregisterCallbacks;
|
|
200
143
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
144
|
+
|
|
145
|
+
// src/core/hooks/useReferrer.ts
|
|
146
|
+
import { useMemo } from "react";
|
|
147
|
+
import { getSchemeUri } from "react-native-bedrock";
|
|
148
|
+
function useReferrer() {
|
|
149
|
+
return useMemo(() => {
|
|
150
|
+
try {
|
|
151
|
+
return new URL(getSchemeUri()).searchParams.get("referrer");
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}, []);
|
|
212
156
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
157
|
+
|
|
158
|
+
// src/core/components/AppEvent.tsx
|
|
159
|
+
var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
|
|
160
|
+
function isPrivateScheme() {
|
|
161
|
+
try {
|
|
162
|
+
return new URL(getSchemeUri2()).protocol === "intoss-private:";
|
|
163
|
+
} catch {
|
|
164
|
+
return false;
|
|
217
165
|
}
|
|
218
|
-
const { onEvent, onError, options } = params;
|
|
219
|
-
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
220
|
-
onAdClicked: () => {
|
|
221
|
-
onEvent({ type: "clicked" });
|
|
222
|
-
},
|
|
223
|
-
onAdDismissed: () => {
|
|
224
|
-
onEvent({ type: "dismissed" });
|
|
225
|
-
},
|
|
226
|
-
onAdFailedToShow: () => {
|
|
227
|
-
onEvent({ type: "failedToShow" });
|
|
228
|
-
},
|
|
229
|
-
onAdImpression: () => {
|
|
230
|
-
onEvent({ type: "impression" });
|
|
231
|
-
},
|
|
232
|
-
onAdShow: () => {
|
|
233
|
-
onEvent({ type: "show" });
|
|
234
|
-
},
|
|
235
|
-
onUserEarnedReward: () => {
|
|
236
|
-
onEvent({ type: "userEarnedReward" });
|
|
237
|
-
},
|
|
238
|
-
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
239
|
-
onError
|
|
240
|
-
});
|
|
241
|
-
return unregisterCallbacks;
|
|
242
166
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
167
|
+
function EntryAppEvent() {
|
|
168
|
+
const referrer = useReferrer() ?? "";
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
tossCoreEventLog({
|
|
171
|
+
log_name: "appsintoss_app_visit::impression__enter_appsintoss",
|
|
172
|
+
log_type: "info",
|
|
173
|
+
params: {
|
|
174
|
+
is_transform: true,
|
|
175
|
+
schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
|
|
176
|
+
referrer,
|
|
177
|
+
deployment_id: env.getDeploymentId(),
|
|
178
|
+
app_name: Bedrock.appName,
|
|
179
|
+
is_private: isPrivateScheme()
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}, [referrer]);
|
|
183
|
+
return null;
|
|
254
184
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
185
|
+
function SystemAppEvent({ ...initialProps }) {
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
tossCoreEventLog({
|
|
188
|
+
log_name: "AppsInTossInitialProps",
|
|
189
|
+
log_type: "debug",
|
|
190
|
+
params: {
|
|
191
|
+
...initialProps,
|
|
192
|
+
schemeUri: getSchemeUri2(),
|
|
193
|
+
deployment_id: env.getDeploymentId(),
|
|
194
|
+
app_name: Bedrock.appName,
|
|
195
|
+
is_private: isPrivateScheme()
|
|
196
|
+
}
|
|
268
197
|
});
|
|
269
|
-
};
|
|
198
|
+
}, [initialProps]);
|
|
199
|
+
return null;
|
|
270
200
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
201
|
+
var AppEvent = {
|
|
202
|
+
Entry: EntryAppEvent,
|
|
203
|
+
System: SystemAppEvent
|
|
204
|
+
};
|
|
275
205
|
|
|
276
|
-
// src/
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
206
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
207
|
+
import { useBridge } from "@toss-design-system/react-native";
|
|
208
|
+
import { useEffect as useEffect2 } from "react";
|
|
209
|
+
|
|
210
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
211
|
+
import { BedrockEvent } from "react-native-bedrock";
|
|
212
|
+
|
|
213
|
+
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
214
|
+
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
215
|
+
var EntryMessageExitedEvent = class extends BedrockEventDefinition {
|
|
216
|
+
name = "entryMessageExited";
|
|
217
|
+
remove() {
|
|
218
|
+
}
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
220
|
+
listener(_) {
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
225
|
+
import { BedrockEventDefinition as BedrockEventDefinition2 } from "react-native-bedrock";
|
|
280
226
|
|
|
281
227
|
// src/native-modules/getPermission.ts
|
|
282
228
|
function getPermission(permission) {
|
|
@@ -300,201 +246,21 @@ async function requestPermission(permission) {
|
|
|
300
246
|
}
|
|
301
247
|
}
|
|
302
248
|
|
|
303
|
-
// src/native-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (permissionStatus === "denied") {
|
|
307
|
-
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
308
|
-
}
|
|
309
|
-
return AppsInTossModule.setClipboardText({ text });
|
|
310
|
-
}
|
|
249
|
+
// src/native-event-emitter/nativeEventEmitter.ts
|
|
250
|
+
import { NativeEventEmitter } from "react-native";
|
|
251
|
+
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
311
252
|
|
|
312
|
-
// src/native-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
size,
|
|
324
|
-
offset,
|
|
325
|
-
query
|
|
326
|
-
}) {
|
|
327
|
-
const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
|
|
328
|
-
if (permissionStatus === "denied") {
|
|
329
|
-
throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
330
|
-
}
|
|
331
|
-
const contacts = await AppsInTossModule.fetchContacts({
|
|
332
|
-
size,
|
|
333
|
-
offset,
|
|
334
|
-
query
|
|
335
|
-
});
|
|
336
|
-
return {
|
|
337
|
-
result: contacts.result,
|
|
338
|
-
nextOffset: contacts.nextOffset ?? null,
|
|
339
|
-
done: contacts.done
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// src/native-modules/fetchAlbumPhotos.ts
|
|
344
|
-
var DEFAULT_MAX_COUNT = 10;
|
|
345
|
-
var DEFAULT_MAX_WIDTH = 1024;
|
|
346
|
-
async function fetchAlbumPhotos(options) {
|
|
347
|
-
const permissionStatus = await requestPermission({ name: "photos", access: "read" });
|
|
348
|
-
if (permissionStatus === "denied") {
|
|
349
|
-
throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
350
|
-
}
|
|
351
|
-
const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
|
|
352
|
-
...options,
|
|
353
|
-
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
354
|
-
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
355
|
-
});
|
|
356
|
-
return albumPhotos;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// src/native-modules/getCurrentLocation.ts
|
|
360
|
-
async function getCurrentLocation(options) {
|
|
361
|
-
const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
|
|
362
|
-
if (permissionStatus === "denied") {
|
|
363
|
-
throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
364
|
-
}
|
|
365
|
-
const position = await AppsInTossModule.getCurrentLocation(options);
|
|
366
|
-
return position;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// src/native-modules/openCamera.ts
|
|
370
|
-
async function openCamera(options) {
|
|
371
|
-
const permissionStatus = await requestPermission({ name: "camera", access: "access" });
|
|
372
|
-
if (permissionStatus === "denied") {
|
|
373
|
-
throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
374
|
-
}
|
|
375
|
-
const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
|
|
376
|
-
return photo;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// src/native-modules/appLogin.ts
|
|
380
|
-
async function appLogin() {
|
|
381
|
-
return AppsInTossModule.appLogin({});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// src/native-modules/getTossAppVersion.ts
|
|
385
|
-
function getTossAppVersion() {
|
|
386
|
-
return AppsInTossModule.tossAppVersion;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// src/native-modules/getDeviceId.ts
|
|
390
|
-
function getDeviceId() {
|
|
391
|
-
return AppsInTossModule.deviceId;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// src/native-modules/storage.ts
|
|
395
|
-
function getItem(key) {
|
|
396
|
-
return AppsInTossModule.getStorageItem({ key });
|
|
397
|
-
}
|
|
398
|
-
function setItem(key, value) {
|
|
399
|
-
return AppsInTossModule.setStorageItem({
|
|
400
|
-
key,
|
|
401
|
-
value
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
function removeItem(key) {
|
|
405
|
-
return AppsInTossModule.removeStorageItem({ key });
|
|
406
|
-
}
|
|
407
|
-
function clearItems() {
|
|
408
|
-
return AppsInTossModule.clearStorage({});
|
|
409
|
-
}
|
|
410
|
-
var Storage = {
|
|
411
|
-
getItem,
|
|
412
|
-
setItem,
|
|
413
|
-
removeItem,
|
|
414
|
-
clearItems
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
// src/native-modules/eventLog.ts
|
|
418
|
-
function normalizeParams(params) {
|
|
419
|
-
return Object.fromEntries(
|
|
420
|
-
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
async function eventLog(params) {
|
|
424
|
-
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
425
|
-
console.log("[eventLogDebug]", {
|
|
426
|
-
log_name: params.log_name,
|
|
427
|
-
log_type: params.log_type,
|
|
428
|
-
params: normalizeParams(params.params)
|
|
429
|
-
});
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
const isSupported = isMinVersionSupported({
|
|
433
|
-
android: "5.208.0",
|
|
434
|
-
ios: "5.208.0"
|
|
435
|
-
});
|
|
436
|
-
if (!isSupported) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
return AppsInTossModule.eventLog({
|
|
440
|
-
log_name: params.log_name,
|
|
441
|
-
log_type: params.log_type,
|
|
442
|
-
params: normalizeParams(params.params)
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// src/native-modules/getTossShareLink.ts
|
|
447
|
-
async function getTossShareLink(path) {
|
|
448
|
-
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
449
|
-
const shareUrl = new URL(shareLink);
|
|
450
|
-
shareUrl.searchParams.set("deep_link_value", path);
|
|
451
|
-
shareUrl.searchParams.set("af_dp", path);
|
|
452
|
-
return shareUrl.toString();
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// src/native-modules/index.ts
|
|
456
|
-
var TossPay = {
|
|
457
|
-
checkoutPayment
|
|
458
|
-
};
|
|
459
|
-
var GoogleAdMob = {
|
|
460
|
-
loadAdMobInterstitialAd,
|
|
461
|
-
showAdMobInterstitialAd,
|
|
462
|
-
loadAdMobRewardedAd,
|
|
463
|
-
showAdMobRewardedAd
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
// src/native-event-emitter/appsInTossEvent.ts
|
|
467
|
-
import { BedrockEvent } from "react-native-bedrock";
|
|
468
|
-
|
|
469
|
-
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
470
|
-
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
471
|
-
var EntryMessageExitedEvent = class extends BedrockEventDefinition {
|
|
472
|
-
name = "entryMessageExited";
|
|
473
|
-
remove() {
|
|
474
|
-
}
|
|
475
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
476
|
-
listener(_) {
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
481
|
-
import { BedrockEventDefinition as BedrockEventDefinition2 } from "react-native-bedrock";
|
|
482
|
-
|
|
483
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
484
|
-
import { NativeEventEmitter } from "react-native";
|
|
485
|
-
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
486
|
-
|
|
487
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
488
|
-
var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
489
|
-
name = "updateLocationEvent";
|
|
490
|
-
subscriptionCount = 0;
|
|
491
|
-
ref = {
|
|
492
|
-
remove: () => {
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
remove() {
|
|
496
|
-
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
497
|
-
this.ref.remove();
|
|
253
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
254
|
+
var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
255
|
+
name = "updateLocationEvent";
|
|
256
|
+
subscriptionCount = 0;
|
|
257
|
+
ref = {
|
|
258
|
+
remove: () => {
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
remove() {
|
|
262
|
+
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
263
|
+
this.ref.remove();
|
|
498
264
|
}
|
|
499
265
|
listener(options, onEvent, onError) {
|
|
500
266
|
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
@@ -514,6 +280,61 @@ var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
|
514
280
|
|
|
515
281
|
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
516
282
|
import { BedrockEventDefinition as BedrockEventDefinition3 } from "react-native-bedrock";
|
|
283
|
+
|
|
284
|
+
// src/utils/generateUUID.ts
|
|
285
|
+
function generateUUID(placeholder) {
|
|
286
|
+
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/native-event-emitter/internal/appBridge.ts
|
|
290
|
+
var INTERNAL__callbacks = /* @__PURE__ */ new Map();
|
|
291
|
+
function invokeAppBridgeCallback(id, ...args) {
|
|
292
|
+
const callback = INTERNAL__callbacks.get(id);
|
|
293
|
+
callback?.call(null, ...args);
|
|
294
|
+
return Boolean(callback);
|
|
295
|
+
}
|
|
296
|
+
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
297
|
+
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
298
|
+
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
299
|
+
const promise = AppsInTossModuleInstance[methodName]({
|
|
300
|
+
params,
|
|
301
|
+
callbacks: callbackMap
|
|
302
|
+
});
|
|
303
|
+
void promise.then(onSuccess).catch(onError);
|
|
304
|
+
return unregisterAll;
|
|
305
|
+
}
|
|
306
|
+
function registerCallbacks(callbacks) {
|
|
307
|
+
const callbackMap = {};
|
|
308
|
+
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
309
|
+
const id = registerCallback(callback, callbackName);
|
|
310
|
+
callbackMap[callbackName] = id;
|
|
311
|
+
}
|
|
312
|
+
const unregisterAll = () => {
|
|
313
|
+
Object.values(callbackMap).forEach(unregisterCallback);
|
|
314
|
+
};
|
|
315
|
+
return { callbackMap, unregisterAll };
|
|
316
|
+
}
|
|
317
|
+
function registerCallback(callback, name = "unnamed") {
|
|
318
|
+
const uniqueId = generateUUID();
|
|
319
|
+
const callbackId = `${uniqueId}__${name}`;
|
|
320
|
+
INTERNAL__callbacks.set(callbackId, callback);
|
|
321
|
+
return callbackId;
|
|
322
|
+
}
|
|
323
|
+
function unregisterCallback(id) {
|
|
324
|
+
INTERNAL__callbacks.delete(id);
|
|
325
|
+
}
|
|
326
|
+
function getCallbackIds() {
|
|
327
|
+
return Array.from(INTERNAL__callbacks.keys());
|
|
328
|
+
}
|
|
329
|
+
var INTERNAL__appBridgeHandler = {
|
|
330
|
+
invokeAppBridgeCallback,
|
|
331
|
+
invokeAppBridgeMethod,
|
|
332
|
+
registerCallback,
|
|
333
|
+
unregisterCallback,
|
|
334
|
+
getCallbackIds
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
517
338
|
var UNSAFE__nativeEventEmitter = nativeEventEmitter;
|
|
518
339
|
var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends BedrockEventDefinition3 {
|
|
519
340
|
static INTERNAL__appBridgeSubscription;
|
|
@@ -551,101 +372,176 @@ var appsInTossEvent = new BedrockEvent([
|
|
|
551
372
|
new EntryMessageExitedEvent()
|
|
552
373
|
]);
|
|
553
374
|
|
|
554
|
-
// src/
|
|
555
|
-
function
|
|
556
|
-
|
|
375
|
+
// src/core/utils/getAppsInTossGlobals.ts
|
|
376
|
+
function getAppsInTossGlobals() {
|
|
377
|
+
if (global.__appsInToss == null) {
|
|
378
|
+
throw new Error("invalid apps-in-toss globals");
|
|
379
|
+
}
|
|
380
|
+
return global.__appsInToss;
|
|
557
381
|
}
|
|
558
382
|
|
|
559
|
-
// src/
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
// src/core/hooks/useReferrer.ts
|
|
565
|
-
import { useMemo } from "react";
|
|
566
|
-
import { getSchemeUri } from "react-native-bedrock";
|
|
567
|
-
function useReferrer() {
|
|
568
|
-
return useMemo(() => {
|
|
569
|
-
try {
|
|
570
|
-
return new URL(getSchemeUri()).searchParams.get("referrer");
|
|
571
|
-
} catch {
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
}, []);
|
|
383
|
+
// src/core/utils/toIcon.ts
|
|
384
|
+
function toIcon(source) {
|
|
385
|
+
return source.startsWith("http") ? { source: { uri: source } } : { name: source };
|
|
575
386
|
}
|
|
576
387
|
|
|
577
|
-
// src/core/
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
388
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
389
|
+
function useAppsInTossBridge() {
|
|
390
|
+
const controller = useBridge();
|
|
391
|
+
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
392
|
+
useEffect2(() => {
|
|
393
|
+
const commonProps = {
|
|
394
|
+
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
395
|
+
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
396
|
+
color: appsInTossGlobals2.brandPrimaryColor,
|
|
397
|
+
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
398
|
+
};
|
|
399
|
+
controller.open({
|
|
400
|
+
...commonProps,
|
|
401
|
+
onExited: () => {
|
|
402
|
+
appsInTossEvent.emit("entryMessageExited", void 0);
|
|
590
403
|
}
|
|
591
404
|
});
|
|
592
|
-
}, [
|
|
593
|
-
return null;
|
|
405
|
+
}, []);
|
|
594
406
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
407
|
+
|
|
408
|
+
// src/async-bridges.ts
|
|
409
|
+
var async_bridges_exports = {};
|
|
410
|
+
__export(async_bridges_exports, {
|
|
411
|
+
appLogin: () => appLogin,
|
|
412
|
+
checkoutPayment: () => checkoutPayment,
|
|
413
|
+
eventLog: () => eventLog,
|
|
414
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
415
|
+
fetchContacts: () => fetchContacts,
|
|
416
|
+
getClipboardText: () => getClipboardText,
|
|
417
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
418
|
+
getTossShareLink: () => getTossShareLink,
|
|
419
|
+
openCamera: () => openCamera,
|
|
420
|
+
setClipboardText: () => setClipboardText
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// src/native-modules/setClipboardText.ts
|
|
424
|
+
async function setClipboardText(text) {
|
|
425
|
+
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
426
|
+
if (permissionStatus === "denied") {
|
|
427
|
+
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
428
|
+
}
|
|
429
|
+
return AppsInTossModule.setClipboardText({ text });
|
|
608
430
|
}
|
|
609
|
-
var AppEvent = {
|
|
610
|
-
Entry: EntryAppEvent,
|
|
611
|
-
System: SystemAppEvent
|
|
612
|
-
};
|
|
613
431
|
|
|
614
|
-
// src/
|
|
615
|
-
|
|
616
|
-
|
|
432
|
+
// src/native-modules/getClipboardText.ts
|
|
433
|
+
async function getClipboardText() {
|
|
434
|
+
const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
|
|
435
|
+
if (permissionStatus === "denied") {
|
|
436
|
+
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
437
|
+
}
|
|
438
|
+
return AppsInTossModule.getClipboardText({});
|
|
439
|
+
}
|
|
617
440
|
|
|
618
|
-
// src/
|
|
619
|
-
function
|
|
620
|
-
|
|
621
|
-
|
|
441
|
+
// src/native-modules/fetchContacts.ts
|
|
442
|
+
async function fetchContacts({
|
|
443
|
+
size,
|
|
444
|
+
offset,
|
|
445
|
+
query
|
|
446
|
+
}) {
|
|
447
|
+
const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
|
|
448
|
+
if (permissionStatus === "denied") {
|
|
449
|
+
throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
622
450
|
}
|
|
623
|
-
|
|
451
|
+
const contacts = await AppsInTossModule.fetchContacts({
|
|
452
|
+
size,
|
|
453
|
+
offset,
|
|
454
|
+
query
|
|
455
|
+
});
|
|
456
|
+
return {
|
|
457
|
+
result: contacts.result,
|
|
458
|
+
nextOffset: contacts.nextOffset ?? null,
|
|
459
|
+
done: contacts.done
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/native-modules/fetchAlbumPhotos.ts
|
|
464
|
+
var DEFAULT_MAX_COUNT = 10;
|
|
465
|
+
var DEFAULT_MAX_WIDTH = 1024;
|
|
466
|
+
async function fetchAlbumPhotos(options) {
|
|
467
|
+
const permissionStatus = await requestPermission({ name: "photos", access: "read" });
|
|
468
|
+
if (permissionStatus === "denied") {
|
|
469
|
+
throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
470
|
+
}
|
|
471
|
+
const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
|
|
472
|
+
...options,
|
|
473
|
+
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
474
|
+
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
475
|
+
});
|
|
476
|
+
return albumPhotos;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/native-modules/getCurrentLocation.ts
|
|
480
|
+
async function getCurrentLocation(options) {
|
|
481
|
+
const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
|
|
482
|
+
if (permissionStatus === "denied") {
|
|
483
|
+
throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
484
|
+
}
|
|
485
|
+
const position = await AppsInTossModule.getCurrentLocation(options);
|
|
486
|
+
return position;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/native-modules/openCamera.ts
|
|
490
|
+
async function openCamera(options) {
|
|
491
|
+
const permissionStatus = await requestPermission({ name: "camera", access: "access" });
|
|
492
|
+
if (permissionStatus === "denied") {
|
|
493
|
+
throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
494
|
+
}
|
|
495
|
+
const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
|
|
496
|
+
return photo;
|
|
624
497
|
}
|
|
625
498
|
|
|
626
|
-
// src/
|
|
627
|
-
function
|
|
628
|
-
return
|
|
499
|
+
// src/native-modules/appLogin.ts
|
|
500
|
+
async function appLogin() {
|
|
501
|
+
return AppsInTossModule.appLogin({});
|
|
629
502
|
}
|
|
630
503
|
|
|
631
|
-
// src/
|
|
632
|
-
function
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
504
|
+
// src/native-modules/checkoutPayment.ts
|
|
505
|
+
async function checkoutPayment(options) {
|
|
506
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// src/native-modules/eventLog.ts
|
|
510
|
+
function normalizeParams(params) {
|
|
511
|
+
return Object.fromEntries(
|
|
512
|
+
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
async function eventLog(params) {
|
|
516
|
+
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
517
|
+
console.log("[eventLogDebug]", {
|
|
518
|
+
log_name: params.log_name,
|
|
519
|
+
log_type: params.log_type,
|
|
520
|
+
params: normalizeParams(params.params)
|
|
647
521
|
});
|
|
648
|
-
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const isSupported = isMinVersionSupported({
|
|
525
|
+
android: "5.208.0",
|
|
526
|
+
ios: "5.208.0"
|
|
527
|
+
});
|
|
528
|
+
if (!isSupported) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
return AppsInTossModule.eventLog({
|
|
532
|
+
log_name: params.log_name,
|
|
533
|
+
log_type: params.log_type,
|
|
534
|
+
params: normalizeParams(params.params)
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/native-modules/getTossShareLink.ts
|
|
539
|
+
async function getTossShareLink(path) {
|
|
540
|
+
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
541
|
+
const shareUrl = new URL(shareLink);
|
|
542
|
+
shareUrl.searchParams.set("deep_link_value", path);
|
|
543
|
+
shareUrl.searchParams.set("af_dp", path);
|
|
544
|
+
return shareUrl.toString();
|
|
649
545
|
}
|
|
650
546
|
|
|
651
547
|
// src/core/registerApp.tsx
|
|
@@ -661,12 +557,19 @@ function TDSContainer({ children }) {
|
|
|
661
557
|
useAppsInTossBridge();
|
|
662
558
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
663
559
|
}
|
|
664
|
-
function registerApp(container, { context }) {
|
|
665
|
-
|
|
560
|
+
function registerApp(container, { context, analytics }) {
|
|
561
|
+
Analytics.init({
|
|
562
|
+
logger: (params) => void eventLog(params),
|
|
563
|
+
debug: analytics?.debug ?? __DEV__
|
|
564
|
+
});
|
|
565
|
+
return Bedrock2.registerApp(AppsInTossContainer.bind(null, container), {
|
|
666
566
|
appName: getAppName(),
|
|
667
567
|
context,
|
|
668
|
-
|
|
669
|
-
|
|
568
|
+
router: {
|
|
569
|
+
screenContainer: Analytics.Screen,
|
|
570
|
+
defaultScreenOption: {
|
|
571
|
+
statusBarStyle: "dark"
|
|
572
|
+
}
|
|
670
573
|
}
|
|
671
574
|
});
|
|
672
575
|
}
|
|
@@ -684,14 +587,170 @@ var AppsInToss = {
|
|
|
684
587
|
registerApp
|
|
685
588
|
};
|
|
686
589
|
|
|
590
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
591
|
+
function startUpdateLocation(eventParams) {
|
|
592
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
|
|
596
|
+
function noop() {
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// src/native-modules/ads/googleAdMob.ts
|
|
600
|
+
function loadAdMobInterstitialAd(params) {
|
|
601
|
+
if (!loadAdMobInterstitialAd.isSupported()) {
|
|
602
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
603
|
+
return noop;
|
|
604
|
+
}
|
|
605
|
+
const { onEvent, onError, options } = params;
|
|
606
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobInterstitialAd", options, {
|
|
607
|
+
onAdClicked: () => {
|
|
608
|
+
onEvent({ type: "clicked" });
|
|
609
|
+
},
|
|
610
|
+
onAdDismissed: () => {
|
|
611
|
+
onEvent({ type: "dismissed" });
|
|
612
|
+
},
|
|
613
|
+
onAdFailedToShow: () => {
|
|
614
|
+
onEvent({ type: "failedToShow" });
|
|
615
|
+
},
|
|
616
|
+
onAdImpression: () => {
|
|
617
|
+
onEvent({ type: "impression" });
|
|
618
|
+
},
|
|
619
|
+
onAdShow: () => {
|
|
620
|
+
onEvent({ type: "show" });
|
|
621
|
+
},
|
|
622
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
623
|
+
onError
|
|
624
|
+
});
|
|
625
|
+
return unregisterCallbacks;
|
|
626
|
+
}
|
|
627
|
+
function showAdMobInterstitialAd(params) {
|
|
628
|
+
if (!showAdMobInterstitialAd.isSupported()) {
|
|
629
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
630
|
+
return noop;
|
|
631
|
+
}
|
|
632
|
+
const { onEvent, onError, options } = params;
|
|
633
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobInterstitialAd", options, {
|
|
634
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
635
|
+
onError
|
|
636
|
+
});
|
|
637
|
+
return unregisterCallbacks;
|
|
638
|
+
}
|
|
639
|
+
function loadAdMobRewardedAd(params) {
|
|
640
|
+
if (!loadAdMobRewardedAd.isSupported()) {
|
|
641
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
642
|
+
return noop;
|
|
643
|
+
}
|
|
644
|
+
const { onEvent, onError, options } = params;
|
|
645
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
646
|
+
onAdClicked: () => {
|
|
647
|
+
onEvent({ type: "clicked" });
|
|
648
|
+
},
|
|
649
|
+
onAdDismissed: () => {
|
|
650
|
+
onEvent({ type: "dismissed" });
|
|
651
|
+
},
|
|
652
|
+
onAdFailedToShow: () => {
|
|
653
|
+
onEvent({ type: "failedToShow" });
|
|
654
|
+
},
|
|
655
|
+
onAdImpression: () => {
|
|
656
|
+
onEvent({ type: "impression" });
|
|
657
|
+
},
|
|
658
|
+
onAdShow: () => {
|
|
659
|
+
onEvent({ type: "show" });
|
|
660
|
+
},
|
|
661
|
+
onUserEarnedReward: () => {
|
|
662
|
+
onEvent({ type: "userEarnedReward" });
|
|
663
|
+
},
|
|
664
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
665
|
+
onError
|
|
666
|
+
});
|
|
667
|
+
return unregisterCallbacks;
|
|
668
|
+
}
|
|
669
|
+
function showAdMobRewardedAd(params) {
|
|
670
|
+
if (!showAdMobRewardedAd.isSupported()) {
|
|
671
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
672
|
+
return noop;
|
|
673
|
+
}
|
|
674
|
+
const { onEvent, onError, options } = params;
|
|
675
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobRewardedAd", options, {
|
|
676
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
677
|
+
onError
|
|
678
|
+
});
|
|
679
|
+
return unregisterCallbacks;
|
|
680
|
+
}
|
|
681
|
+
var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
682
|
+
var IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
683
|
+
var UNSUPPORTED_ERROR_MESSAGE = "This feature is not supported in the current environment";
|
|
684
|
+
var ENVIRONMENT = getOperationalEnvironment();
|
|
685
|
+
function createIsSupported() {
|
|
686
|
+
return () => {
|
|
687
|
+
if (ENVIRONMENT !== "toss") {
|
|
688
|
+
console.warn("Google AdMob is not supported in the current environment");
|
|
689
|
+
return false;
|
|
690
|
+
}
|
|
691
|
+
return isMinVersionSupported({
|
|
692
|
+
android: ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION,
|
|
693
|
+
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
loadAdMobInterstitialAd.isSupported = createIsSupported();
|
|
698
|
+
loadAdMobRewardedAd.isSupported = createIsSupported();
|
|
699
|
+
showAdMobInterstitialAd.isSupported = createIsSupported();
|
|
700
|
+
showAdMobRewardedAd.isSupported = createIsSupported();
|
|
701
|
+
|
|
702
|
+
// src/native-modules/getTossAppVersion.ts
|
|
703
|
+
function getTossAppVersion() {
|
|
704
|
+
return AppsInTossModule.tossAppVersion;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/native-modules/getDeviceId.ts
|
|
708
|
+
function getDeviceId() {
|
|
709
|
+
return AppsInTossModule.deviceId;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/native-modules/storage.ts
|
|
713
|
+
function getItem(key) {
|
|
714
|
+
return AppsInTossModule.getStorageItem({ key });
|
|
715
|
+
}
|
|
716
|
+
function setItem(key, value) {
|
|
717
|
+
return AppsInTossModule.setStorageItem({
|
|
718
|
+
key,
|
|
719
|
+
value
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
function removeItem(key) {
|
|
723
|
+
return AppsInTossModule.removeStorageItem({ key });
|
|
724
|
+
}
|
|
725
|
+
function clearItems() {
|
|
726
|
+
return AppsInTossModule.clearStorage({});
|
|
727
|
+
}
|
|
728
|
+
var Storage = {
|
|
729
|
+
getItem,
|
|
730
|
+
setItem,
|
|
731
|
+
removeItem,
|
|
732
|
+
clearItems
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
// src/native-modules/index.ts
|
|
736
|
+
var TossPay = {
|
|
737
|
+
checkoutPayment
|
|
738
|
+
};
|
|
739
|
+
var GoogleAdMob = {
|
|
740
|
+
loadAdMobInterstitialAd,
|
|
741
|
+
showAdMobInterstitialAd,
|
|
742
|
+
loadAdMobRewardedAd,
|
|
743
|
+
showAdMobRewardedAd
|
|
744
|
+
};
|
|
745
|
+
|
|
687
746
|
// src/components/WebView.tsx
|
|
688
747
|
import {
|
|
689
748
|
PartnerWebViewScreen,
|
|
690
749
|
ExternalWebViewScreen
|
|
691
750
|
} from "@toss-design-system/react-native";
|
|
692
751
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
|
|
693
|
-
import { useMemo as useMemo3 } from "react";
|
|
694
|
-
import { getSchemeUri as
|
|
752
|
+
import { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
753
|
+
import { getSchemeUri as getSchemeUri4, useBedrockEvent } from "react-native-bedrock";
|
|
695
754
|
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
696
755
|
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
697
756
|
|
|
@@ -842,21 +901,6 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
842
901
|
] });
|
|
843
902
|
});
|
|
844
903
|
|
|
845
|
-
// src/async-bridges.ts
|
|
846
|
-
var async_bridges_exports = {};
|
|
847
|
-
__export(async_bridges_exports, {
|
|
848
|
-
appLogin: () => appLogin,
|
|
849
|
-
checkoutPayment: () => checkoutPayment,
|
|
850
|
-
eventLog: () => eventLog,
|
|
851
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
852
|
-
fetchContacts: () => fetchContacts,
|
|
853
|
-
getClipboardText: () => getClipboardText,
|
|
854
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
855
|
-
getTossShareLink: () => getTossShareLink,
|
|
856
|
-
openCamera: () => openCamera,
|
|
857
|
-
setClipboardText: () => setClipboardText
|
|
858
|
-
});
|
|
859
|
-
|
|
860
904
|
// src/bridge-handler/useBridgeHandler.tsx
|
|
861
905
|
import { useCallback as useCallback2, useMemo as useMemo2, useRef } from "react";
|
|
862
906
|
function serializeError(error) {
|
|
@@ -998,6 +1042,54 @@ __export(event_bridges_exports, {
|
|
|
998
1042
|
startUpdateLocation: () => startUpdateLocation
|
|
999
1043
|
});
|
|
1000
1044
|
|
|
1045
|
+
// src/utils/log.ts
|
|
1046
|
+
import { getSchemeUri as getSchemeUri3 } from "react-native-bedrock";
|
|
1047
|
+
|
|
1048
|
+
// src/utils/extractDateFromUUIDv7.ts
|
|
1049
|
+
var extractDateFromUUIDv7 = (uuid) => {
|
|
1050
|
+
const timestampHex = uuid.split("-").join("").slice(0, 12);
|
|
1051
|
+
const timestamp = Number.parseInt(timestampHex, 16);
|
|
1052
|
+
return new Date(timestamp);
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
// src/utils/log.ts
|
|
1056
|
+
var getGroupId = (url) => {
|
|
1057
|
+
try {
|
|
1058
|
+
const urlObject = new URL(url);
|
|
1059
|
+
return {
|
|
1060
|
+
groupId: urlObject.pathname,
|
|
1061
|
+
search: urlObject.search.startsWith("?") ? urlObject.search.substring(1) : urlObject.search
|
|
1062
|
+
};
|
|
1063
|
+
} catch {
|
|
1064
|
+
return {
|
|
1065
|
+
groupId: "unknown",
|
|
1066
|
+
search: "unknown"
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
var getReferrer = () => {
|
|
1071
|
+
try {
|
|
1072
|
+
const referrer = new URL(getSchemeUri3());
|
|
1073
|
+
return referrer.searchParams.get("referrer");
|
|
1074
|
+
} catch {
|
|
1075
|
+
return "";
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
var trackScreen = (url) => {
|
|
1079
|
+
const { groupId, search } = getGroupId(url);
|
|
1080
|
+
const log = {
|
|
1081
|
+
log_type: "screen",
|
|
1082
|
+
log_name: `${groupId}::screen`,
|
|
1083
|
+
params: {
|
|
1084
|
+
search,
|
|
1085
|
+
referrer: getReferrer(),
|
|
1086
|
+
deployment_id: env.getDeploymentId(),
|
|
1087
|
+
deployment_timestamp: extractDateFromUUIDv7(env.getDeploymentId()).getTime()
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
return eventLog(log);
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1001
1093
|
// src/components/WebView.tsx
|
|
1002
1094
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1003
1095
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
@@ -1010,7 +1102,7 @@ var WEBVIEW_TYPES = {
|
|
|
1010
1102
|
};
|
|
1011
1103
|
function mergeSchemeQueryParamsInto(url) {
|
|
1012
1104
|
const baseUrl = new URL(url);
|
|
1013
|
-
const schemeUrl = new URL(
|
|
1105
|
+
const schemeUrl = new URL(getSchemeUri4());
|
|
1014
1106
|
baseUrl.pathname = schemeUrl.pathname;
|
|
1015
1107
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
1016
1108
|
baseUrl.searchParams.set(key, value);
|
|
@@ -1065,7 +1157,9 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1065
1157
|
loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
|
|
1066
1158
|
showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
|
|
1067
1159
|
loadAdMobRewardedAd_isSupported: GoogleAdMob.loadAdMobRewardedAd.isSupported,
|
|
1068
|
-
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported
|
|
1160
|
+
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported,
|
|
1161
|
+
/** env */
|
|
1162
|
+
getDeploymentId: env.getDeploymentId
|
|
1069
1163
|
},
|
|
1070
1164
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1071
1165
|
// @ts-expect-error
|
|
@@ -1112,6 +1206,11 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1112
1206
|
}, [type, props]);
|
|
1113
1207
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
1114
1208
|
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
1209
|
+
const handleNavigationStateChange = useCallback3((event) => {
|
|
1210
|
+
if (event.url) {
|
|
1211
|
+
trackScreen(event.url);
|
|
1212
|
+
}
|
|
1213
|
+
}, []);
|
|
1115
1214
|
return /* @__PURE__ */ jsx5(
|
|
1116
1215
|
BaseWebView,
|
|
1117
1216
|
{
|
|
@@ -1123,6 +1222,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1123
1222
|
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
1124
1223
|
thirdPartyCookiesEnabled: true,
|
|
1125
1224
|
onMessage: handler.onMessage,
|
|
1225
|
+
onNavigationStateChange: handleNavigationStateChange,
|
|
1126
1226
|
injectedJavaScript: handler.injectedJavaScript,
|
|
1127
1227
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
1128
1228
|
}
|
|
@@ -1168,8 +1268,18 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
1168
1268
|
Accuracy3[Accuracy3["BestForNavigation"] = 6] = "BestForNavigation";
|
|
1169
1269
|
return Accuracy3;
|
|
1170
1270
|
})(Accuracy2 || {});
|
|
1271
|
+
|
|
1272
|
+
// src/index.ts
|
|
1273
|
+
export * from "@apps-in-toss/analytics";
|
|
1274
|
+
var Analytics2 = {
|
|
1275
|
+
init: InternalAnalytics.init,
|
|
1276
|
+
Impression: InternalAnalytics.Impression,
|
|
1277
|
+
Press: InternalAnalytics.Press,
|
|
1278
|
+
Area: InternalAnalytics.Area
|
|
1279
|
+
};
|
|
1171
1280
|
export {
|
|
1172
1281
|
Accuracy2 as Accuracy,
|
|
1282
|
+
Analytics2 as Analytics,
|
|
1173
1283
|
AppsInToss,
|
|
1174
1284
|
GoogleAdMob,
|
|
1175
1285
|
Storage,
|